aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-vineflower/net/minecraft/world/item/ArmorStandItem.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/world/item/ArmorStandItem.java.patch')
-rw-r--r--patch-remap/mache-vineflower/net/minecraft/world/item/ArmorStandItem.java.patch89
1 files changed, 89 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/world/item/ArmorStandItem.java.patch b/patch-remap/mache-vineflower/net/minecraft/world/item/ArmorStandItem.java.patch
new file mode 100644
index 0000000000..1b400dd595
--- /dev/null
+++ b/patch-remap/mache-vineflower/net/minecraft/world/item/ArmorStandItem.java.patch
@@ -0,0 +1,89 @@
+--- a/net/minecraft/world/item/ArmorStandItem.java
++++ b/net/minecraft/world/item/ArmorStandItem.java
+@@ -8,9 +8,11 @@
+ import net.minecraft.sounds.SoundSource;
+ import net.minecraft.util.Mth;
+ 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;
+ import net.minecraft.world.item.context.UseOnContext;
+ import net.minecraft.world.level.Level;
+@@ -19,42 +21,50 @@
+ import net.minecraft.world.phys.Vec3;
+
+ public class ArmorStandItem extends Item {
++
+ public ArmorStandItem(Item.Properties properties) {
+ super(properties);
+ }
+
+ @Override
+ public InteractionResult useOn(UseOnContext context) {
+- Direction clickedFace = context.getClickedFace();
+- if (clickedFace == Direction.DOWN) {
++ Direction enumdirection = context.getClickedFace();
++
++ if (enumdirection == Direction.DOWN) {
+ return InteractionResult.FAIL;
+ } else {
+- Level level = context.getLevel();
+- BlockPlaceContext blockPlaceContext = new BlockPlaceContext(context);
+- BlockPos clickedPos = blockPlaceContext.getClickedPos();
+- ItemStack itemInHand = context.getItemInHand();
+- Vec3 vec3 = Vec3.atBottomCenterOf(clickedPos);
+- AABB aABB = EntityType.ARMOR_STAND.getDimensions().makeBoundingBox(vec3.x(), vec3.y(), vec3.z());
+- if (level.noCollision(null, aABB) && level.getEntities(null, aABB).isEmpty()) {
+- if (level instanceof ServerLevel serverLevel) {
+- Consumer<ArmorStand> consumer = EntityType.createDefaultStackConfig(serverLevel, itemInHand, context.getPlayer());
+- ArmorStand armorStand = EntityType.ARMOR_STAND
+- .create(serverLevel, itemInHand.getTag(), consumer, clickedPos, MobSpawnType.SPAWN_EGG, true, true);
+- if (armorStand == null) {
++ 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 (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 (entityarmorstand == null) {
+ return InteractionResult.FAIL;
+ }
+
+- 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(
+- null, armorStand.getX(), armorStand.getY(), armorStand.getZ(), SoundEvents.ARMOR_STAND_PLACE, SoundSource.BLOCKS, 0.75F, 0.8F
+- );
+- armorStand.gameEvent(GameEvent.ENTITY_PLACE, context.getPlayer());
++ float f = (float) Mth.floor((Mth.wrapDegrees(context.getRotation() - 180.0F) + 22.5F) / 45.0F) * 45.0F;
++
++ 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());
+ }
+
+- itemInHand.shrink(1);
+- return InteractionResult.sidedSuccess(level.isClientSide);
++ itemstack.shrink(1);
++ return InteractionResult.sidedSuccess(world.isClientSide);
+ } else {
+ return InteractionResult.FAIL;
+ }