diff options
Diffstat (limited to 'patch-remap/mache-spigotflower/net/minecraft/world/item/ArmorStandItem.java.patch')
-rw-r--r-- | patch-remap/mache-spigotflower/net/minecraft/world/item/ArmorStandItem.java.patch | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower/net/minecraft/world/item/ArmorStandItem.java.patch b/patch-remap/mache-spigotflower/net/minecraft/world/item/ArmorStandItem.java.patch new file mode 100644 index 0000000000..cb1b5174b4 --- /dev/null +++ b/patch-remap/mache-spigotflower/net/minecraft/world/item/ArmorStandItem.java.patch @@ -0,0 +1,85 @@ +--- a/net/minecraft/world/item/ArmorStandItem.java ++++ b/net/minecraft/world/item/ArmorStandItem.java +@@ -10,7 +10,7 @@ + import net.minecraft.world.InteractionResult; + import net.minecraft.world.entity.Entity; + import net.minecraft.world.entity.EntityType; +-import net.minecraft.world.entity.MobSpawnType; ++import net.minecraft.world.entity.EnumMobSpawn; + import net.minecraft.world.entity.decoration.ArmorStand; + import net.minecraft.world.entity.player.Player; + import net.minecraft.world.item.context.BlockPlaceContext; +@@ -22,45 +22,49 @@ + + public class ArmorStandItem extends Item { + +- public ArmorStandItem(Item.Properties item_properties) { +- super(item_properties); ++ public ArmorStandItem(Item.Properties properties) { ++ super(properties); + } + + @Override +- @Override +- public InteractionResult useOn(UseOnContext useoncontext) { +- Direction direction = useoncontext.getClickedFace(); ++ public InteractionResult useOn(UseOnContext context) { ++ Direction enumdirection = context.getClickedFace(); + +- if (direction == Direction.DOWN) { ++ if (enumdirection == Direction.DOWN) { + return InteractionResult.FAIL; + } else { +- Level level = useoncontext.getLevel(); +- BlockPlaceContext blockplacecontext = new BlockPlaceContext(useoncontext); +- BlockPos blockpos = blockplacecontext.getClickedPos(); +- ItemStack itemstack = useoncontext.getItemInHand(); +- Vec3 vec3 = Vec3.atBottomCenterOf(blockpos); +- AABB aabb = EntityType.ARMOR_STAND.getDimensions().makeBoundingBox(vec3.x(), vec3.y(), vec3.z()); ++ Level world = context.getLevel(); ++ BlockPlaceContext blockactioncontext = new BlockPlaceContext(context); ++ BlockPos blockposition = blockactioncontext.getClickedPos(); ++ ItemStack itemstack = context.getItemInHand(); ++ Vec3 vec3d = Vec3.atBottomCenterOf(blockposition); ++ AABB axisalignedbb = EntityType.ARMOR_STAND.getDimensions().makeBoundingBox(vec3d.x(), vec3d.y(), vec3d.z()); + +- if (level.noCollision((Entity) null, aabb) && level.getEntities((Entity) null, aabb).isEmpty()) { +- if (level instanceof ServerLevel) { +- ServerLevel serverlevel = (ServerLevel) level; +- Consumer<ArmorStand> consumer = EntityType.createDefaultStackConfig(serverlevel, itemstack, useoncontext.getPlayer()); +- ArmorStand armorstand = (ArmorStand) EntityType.ARMOR_STAND.create(serverlevel, itemstack.getTag(), consumer, blockpos, MobSpawnType.SPAWN_EGG, true, true); ++ if (world.noCollision((Entity) null, axisalignedbb) && world.getEntities((Entity) null, axisalignedbb).isEmpty()) { ++ if (world instanceof ServerLevel) { ++ ServerLevel worldserver = (ServerLevel) world; ++ Consumer<ArmorStand> consumer = EntityType.createDefaultStackConfig(worldserver, itemstack, context.getPlayer()); ++ ArmorStand entityarmorstand = (ArmorStand) EntityType.ARMOR_STAND.create(worldserver, itemstack.getTag(), consumer, blockposition, EnumMobSpawn.SPAWN_EGG, true, true); + +- if (armorstand == null) { ++ if (entityarmorstand == null) { + return InteractionResult.FAIL; + } + +- float f = (float) Mth.floor((Mth.wrapDegrees(useoncontext.getRotation() - 180.0F) + 22.5F) / 45.0F) * 45.0F; ++ float f = (float) Mth.floor((Mth.wrapDegrees(context.getRotation() - 180.0F) + 22.5F) / 45.0F) * 45.0F; + +- armorstand.moveTo(armorstand.getX(), armorstand.getY(), armorstand.getZ(), f, 0.0F); +- serverlevel.addFreshEntityWithPassengers(armorstand); +- level.playSound((Player) null, armorstand.getX(), armorstand.getY(), armorstand.getZ(), SoundEvents.ARMOR_STAND_PLACE, SoundSource.BLOCKS, 0.75F, 0.8F); +- armorstand.gameEvent(GameEvent.ENTITY_PLACE, useoncontext.getPlayer()); ++ entityarmorstand.moveTo(entityarmorstand.getX(), entityarmorstand.getY(), entityarmorstand.getZ(), f, 0.0F); ++ // CraftBukkit start ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPlaceEvent(context, entityarmorstand).isCancelled()) { ++ return InteractionResult.FAIL; ++ } ++ // CraftBukkit end ++ worldserver.addFreshEntityWithPassengers(entityarmorstand); ++ world.playSound((Player) null, entityarmorstand.getX(), entityarmorstand.getY(), entityarmorstand.getZ(), SoundEvents.ARMOR_STAND_PLACE, SoundSource.BLOCKS, 0.75F, 0.8F); ++ entityarmorstand.gameEvent(GameEvent.ENTITY_PLACE, context.getPlayer()); + } + + itemstack.shrink(1); +- return InteractionResult.sidedSuccess(level.isClientSide); ++ return InteractionResult.sidedSuccess(world.isClientSide); + } else { + return InteractionResult.FAIL; + } |