mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 08:27:43 +01:00
add option to let copper golems open shulkers
This commit is contained in:
@@ -5,6 +5,7 @@ public net.minecraft.world.entity.Entity updateInWaterStateAndDoWaterCurrentPush
|
||||
public net.minecraft.world.entity.LivingEntity canGlide()Z
|
||||
public net.minecraft.world.entity.monster.Shulker MAX_SCALE
|
||||
public net.minecraft.world.entity.player.Player canGlide()Z
|
||||
public net.minecraft.world.level.block.ShulkerBoxBlock canOpen(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/entity/ShulkerBoxBlockEntity;)Z
|
||||
public net.minecraft.world.level.block.entity.FuelValues values
|
||||
public-f net.minecraft.world.entity.EntityType dimensions
|
||||
public-f net.minecraft.world.level.block.state.BlockBehaviour explosionResistance
|
||||
|
||||
@@ -5,25 +5,29 @@
|
||||
if (chunkNow != null) {
|
||||
for (BlockEntity blockEntity : chunkNow.getBlockEntities().values()) {
|
||||
- if (blockEntity instanceof ChestBlockEntity chestBlockEntity) {
|
||||
+ if (blockEntity instanceof net.minecraft.world.level.block.entity.BaseContainerBlockEntity chestBlockEntity) { // Purpur - copper golem can place items in barrels option
|
||||
+ if (blockEntity instanceof net.minecraft.world.level.block.entity.BaseContainerBlockEntity chestBlockEntity) { // Purpur - copper golem can place items in barrels or shulkers option
|
||||
double d1 = chestBlockEntity.getBlockPos().distToCenterSqr(mob.position());
|
||||
if (d1 < d) {
|
||||
TransportItemsBetweenContainers.TransportItemTarget transportItemTarget1 = this.isTargetValidToPick(
|
||||
@@ -338,7 +_,7 @@
|
||||
@@ -372,7 +_,11 @@
|
||||
}
|
||||
|
||||
private boolean hasValidTarget(Level level, PathfinderMob mob) {
|
||||
boolean flag = this.target != null && this.isWantedBlock(mob, this.target.state) && this.targetHasNotChanged(level, this.target);
|
||||
- if (flag && !this.isTargetBlocked(level, this.target)) {
|
||||
+ 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
|
||||
if (!this.state.equals(TransportItemsBetweenContainers.TransportItemState.TRAVELLING)) {
|
||||
return true;
|
||||
}
|
||||
private boolean isTargetBlocked(Level level, TransportItemsBetweenContainers.TransportItemTarget target) {
|
||||
- return ChestBlock.isChestBlockedAt(level, target.pos);
|
||||
+ // Purpur start - copper golem can place items in barrels or shulkers option
|
||||
+ boolean isBarrelBlocked = level.purpurConfig.copperGolemCanOpenBarrel && target.state.is(net.minecraft.world.level.block.Blocks.BARREL);
|
||||
+ 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);
|
||||
+ return isBarrelBlocked || isShulkerBlocked || net.minecraft.world.level.block.ChestBlock.isChestBlockedAt(level, target.pos);
|
||||
+ // Purpur end - copper golem can place items in barrels or shulkers option
|
||||
}
|
||||
|
||||
private boolean targetHasNotChanged(Level level, TransportItemsBetweenContainers.TransportItemTarget target) {
|
||||
@@ -449,7 +_,7 @@
|
||||
}
|
||||
|
||||
private boolean isWantedBlock(PathfinderMob mob, BlockState state) {
|
||||
- return isPickingUpItems(mob) ? this.sourceBlockType.test(state) : this.destinationBlockType.test(state);
|
||||
+ 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
|
||||
+ 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
|
||||
}
|
||||
|
||||
private static double getInteractionRange(PathfinderMob mob) {
|
||||
|
||||
@@ -5,7 +5,19 @@
|
||||
private static final int TICK_TO_PLAY_ON_REACHED_SOUND = 9;
|
||||
private static final Predicate<BlockState> TRANSPORT_ITEM_SOURCE_BLOCK = state -> state.is(BlockTags.COPPER_CHESTS);
|
||||
- private static final Predicate<BlockState> TRANSPORT_ITEM_DESTINATION_BLOCK = state -> state.is(Blocks.CHEST) || state.is(Blocks.TRAPPED_CHEST);
|
||||
+ private static final Predicate<BlockState> TRANSPORT_ITEM_DESTINATION_BLOCK = state -> state.is(Blocks.CHEST) || state.is(Blocks.TRAPPED_CHEST); // Purpur - copper golem can place items in barrels option - diff on change
|
||||
+ private static final Predicate<BlockState> TRANSPORT_ITEM_DESTINATION_BLOCK = state -> state.is(Blocks.CHEST) || state.is(Blocks.TRAPPED_CHEST); // Purpur - copper golem can place items in barrels or shulkers option - diff on change
|
||||
private static final ImmutableList<SensorType<? extends Sensor<? super CopperGolem>>> SENSOR_TYPES = ImmutableList.of(
|
||||
SensorType.NEAREST_LIVING_ENTITIES, SensorType.HURT_BY
|
||||
);
|
||||
@@ -158,6 +_,11 @@
|
||||
}
|
||||
|
||||
if (integer == 60) {
|
||||
+ // Purpur start - copper golem can place items in barrels or shulkers option
|
||||
+ if (container instanceof net.minecraft.world.level.block.entity.ShulkerBoxBlockEntity shulkerBoxBlockEntity && shulkerBoxBlockEntity.openCount > 0) {
|
||||
+ container.stopOpen(copperGolem);
|
||||
+ }
|
||||
+ // Purpur end - copper golem can place items in barrels or shulkers option
|
||||
if (container.getEntitiesWithContainerOpen().contains(pathfinderMob)) {
|
||||
container.stopOpen(copperGolem);
|
||||
}
|
||||
|
||||
@@ -1560,6 +1560,7 @@ public class PurpurWorldConfig {
|
||||
public boolean copperGolemTakeDamageFromWater = false;
|
||||
public boolean copperGolemAlwaysDropExp = false;
|
||||
public boolean copperGolemCanOpenBarrel = false;
|
||||
public boolean copperGolemCanOpenShulker = false;
|
||||
private void copperGolemSettings() {
|
||||
copperGolemRidable = getBoolean("mobs.copper_golem.ridable", copperGolemRidable);
|
||||
copperGolemRidableInWater = getBoolean("mobs.copper_golem.ridable-in-water", copperGolemRidableInWater);
|
||||
@@ -1572,6 +1573,7 @@ public class PurpurWorldConfig {
|
||||
copperGolemTakeDamageFromWater = getBoolean("mobs.copper_golem.takes-damage-from-water", copperGolemTakeDamageFromWater);
|
||||
copperGolemAlwaysDropExp = getBoolean("mobs.copper_golem.always-drop-exp", copperGolemAlwaysDropExp);
|
||||
copperGolemCanOpenBarrel = getBoolean("mobs.copper_golem.can-open-barrel", copperGolemCanOpenBarrel);
|
||||
copperGolemCanOpenShulker = getBoolean("mobs.copper_golem.can-open-shulker", copperGolemCanOpenShulker);
|
||||
}
|
||||
|
||||
public boolean cowRidable = false;
|
||||
|
||||
Reference in New Issue
Block a user