|
5 | 5 | if (chunkNow != null) { |
6 | 6 | for (BlockEntity blockEntity : chunkNow.getBlockEntities().values()) { |
7 | 7 | - if (blockEntity instanceof ChestBlockEntity chestBlockEntity) { |
8 | | -+ if (blockEntity instanceof net.minecraft.world.level.block.entity.BaseContainerBlockEntity chestBlockEntity) { // Purpur - copper golem can place items in barrels option |
| 8 | ++ if (blockEntity instanceof net.minecraft.world.level.block.entity.BaseContainerBlockEntity chestBlockEntity) { // Purpur - copper golem can place items in barrels or shulkers option |
9 | 9 | double d1 = chestBlockEntity.getBlockPos().distToCenterSqr(mob.position()); |
10 | 10 | if (d1 < d) { |
11 | 11 | TransportItemsBetweenContainers.TransportItemTarget transportItemTarget1 = this.isTargetValidToPick( |
12 | | -@@ -338,7 +_,7 @@ |
| 12 | +@@ -372,7 +_,11 @@ |
| 13 | + } |
| 14 | + |
| 15 | + private boolean isTargetBlocked(Level level, TransportItemsBetweenContainers.TransportItemTarget target) { |
| 16 | +- return ChestBlock.isChestBlockedAt(level, target.pos); |
| 17 | ++ // Purpur start - copper golem can place items in barrels or shulkers option |
| 18 | ++ boolean isBarrelBlocked = level.purpurConfig.copperGolemCanOpenBarrel && target.state.is(net.minecraft.world.level.block.Blocks.BARREL); |
| 19 | ++ boolean isShulkerBlocked = level.purpurConfig.copperGolemCanOpenShulker && target.blockEntity instanceof net.minecraft.world.level.block.entity.ShulkerBoxBlockEntity shulkerBoxBlockEntity && !net.minecraft.world.level.block.ShulkerBoxBlock.canOpen(target.state, level, target.pos, shulkerBoxBlockEntity); |
| 20 | ++ return isBarrelBlocked || isShulkerBlocked || net.minecraft.world.level.block.ChestBlock.isChestBlockedAt(level, target.pos); |
| 21 | ++ // Purpur end - copper golem can place items in barrels or shulkers option |
| 22 | + } |
13 | 23 |
|
14 | | - private boolean hasValidTarget(Level level, PathfinderMob mob) { |
15 | | - boolean flag = this.target != null && this.isWantedBlock(mob, this.target.state) && this.targetHasNotChanged(level, this.target); |
16 | | -- if (flag && !this.isTargetBlocked(level, this.target)) { |
17 | | -+ if (flag && (mob.level().purpurConfig.copperGolemCanOpenBarrel && this.target.state.is(net.minecraft.world.level.block.Blocks.BARREL) || !this.isTargetBlocked(level, this.target))) { // Purpur - copper golem can place items in barrels option |
18 | | - if (!this.state.equals(TransportItemsBetweenContainers.TransportItemState.TRAVELLING)) { |
19 | | - return true; |
20 | | - } |
| 24 | + private boolean targetHasNotChanged(Level level, TransportItemsBetweenContainers.TransportItemTarget target) { |
21 | 25 | @@ -449,7 +_,7 @@ |
22 | 26 | } |
23 | 27 |
|
24 | 28 | private boolean isWantedBlock(PathfinderMob mob, BlockState state) { |
25 | 29 | - return isPickingUpItems(mob) ? this.sourceBlockType.test(state) : this.destinationBlockType.test(state); |
26 | | -+ return isPickingUpItems(mob) ? this.sourceBlockType.test(state) : (mob.level().purpurConfig.copperGolemCanOpenBarrel && state.is(net.minecraft.world.level.block.Blocks.BARREL)) || this.destinationBlockType.test(state); // Purpur - copper golem can place items in barrels option |
| 30 | ++ return isPickingUpItems(mob) ? this.sourceBlockType.test(state) : (mob.level().purpurConfig.copperGolemCanOpenBarrel && state.is(net.minecraft.world.level.block.Blocks.BARREL)) || (mob.level().purpurConfig.copperGolemCanOpenShulker && state.is(net.minecraft.tags.BlockTags.SHULKER_BOXES)) || this.destinationBlockType.test(state); // Purpur - copper golem can place items in barrels or shulkers option |
27 | 31 | } |
28 | 32 |
|
29 | 33 | private static double getInteractionRange(PathfinderMob mob) { |
0 commit comments