diff options
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/world/item/EnderEyeItem.java.patch')
-rw-r--r-- | patch-remap/mache-vineflower/net/minecraft/world/item/EnderEyeItem.java.patch | 164 |
1 files changed, 164 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/world/item/EnderEyeItem.java.patch b/patch-remap/mache-vineflower/net/minecraft/world/item/EnderEyeItem.java.patch new file mode 100644 index 0000000000..23e574aaab --- /dev/null +++ b/patch-remap/mache-vineflower/net/minecraft/world/item/EnderEyeItem.java.patch @@ -0,0 +1,164 @@ +--- a/net/minecraft/world/item/EnderEyeItem.java ++++ b/net/minecraft/world/item/EnderEyeItem.java +@@ -8,9 +8,10 @@ + import net.minecraft.sounds.SoundSource; + import net.minecraft.stats.Stats; + import net.minecraft.tags.StructureTags; +-import net.minecraft.world.InteractionHand; ++import net.minecraft.world.EnumHand; + import net.minecraft.world.InteractionResult; + import net.minecraft.world.InteractionResultHolder; ++import net.minecraft.world.entity.Entity; + import net.minecraft.world.entity.player.Player; + import net.minecraft.world.entity.projectile.EyeOfEnder; + import net.minecraft.world.item.context.UseOnContext; +@@ -19,92 +20,97 @@ + import net.minecraft.world.level.block.Block; + import net.minecraft.world.level.block.Blocks; + import net.minecraft.world.level.block.EndPortalFrameBlock; +-import net.minecraft.world.level.block.state.BlockState; ++import net.minecraft.world.level.block.state.IBlockData; + import net.minecraft.world.level.block.state.pattern.BlockPattern; + import net.minecraft.world.level.gameevent.GameEvent; + import net.minecraft.world.phys.BlockHitResult; + import net.minecraft.world.phys.HitResult; + + public class EnderEyeItem extends Item { ++ + public EnderEyeItem(Item.Properties properties) { + super(properties); + } + + @Override + public InteractionResult useOn(UseOnContext context) { +- Level level = context.getLevel(); +- BlockPos clickedPos = context.getClickedPos(); +- BlockState blockState = level.getBlockState(clickedPos); +- if (!blockState.is(Blocks.END_PORTAL_FRAME) || blockState.getValue(EndPortalFrameBlock.HAS_EYE)) { +- return InteractionResult.PASS; +- } else if (level.isClientSide) { +- return InteractionResult.SUCCESS; +- } else { +- BlockState blockState1 = blockState.setValue(EndPortalFrameBlock.HAS_EYE, Boolean.valueOf(true)); +- Block.pushEntitiesUp(blockState, blockState1, level, clickedPos); +- level.setBlock(clickedPos, blockState1, 2); +- level.updateNeighbourForOutputSignal(clickedPos, Blocks.END_PORTAL_FRAME); +- context.getItemInHand().shrink(1); +- level.levelEvent(1503, clickedPos, 0); +- BlockPattern.BlockPatternMatch blockPatternMatch = EndPortalFrameBlock.getOrCreatePortalShape().find(level, clickedPos); +- if (blockPatternMatch != null) { +- BlockPos blockPos = blockPatternMatch.getFrontTopLeft().offset(-3, 0, -3); ++ Level world = context.getLevel(); ++ BlockPos blockposition = context.getClickedPos(); ++ IBlockData iblockdata = world.getBlockState(blockposition); + +- for (int i = 0; i < 3; i++) { +- for (int i1 = 0; i1 < 3; i1++) { +- level.setBlock(blockPos.offset(i, 0, i1), Blocks.END_PORTAL.defaultBlockState(), 2); ++ if (iblockdata.is(Blocks.END_PORTAL_FRAME) && !(Boolean) iblockdata.getValue(EndPortalFrameBlock.HAS_EYE)) { ++ if (world.isClientSide) { ++ return InteractionResult.SUCCESS; ++ } else { ++ IBlockData iblockdata1 = (IBlockData) iblockdata.setValue(EndPortalFrameBlock.HAS_EYE, true); ++ ++ Block.pushEntitiesUp(iblockdata, iblockdata1, world, blockposition); ++ world.setBlock(blockposition, iblockdata1, 2); ++ world.updateNeighbourForOutputSignal(blockposition, Blocks.END_PORTAL_FRAME); ++ context.getItemInHand().shrink(1); ++ world.levelEvent(1503, blockposition, 0); ++ BlockPattern.BlockPatternMatch shapedetector_shapedetectorcollection = EndPortalFrameBlock.getOrCreatePortalShape().find(world, blockposition); ++ ++ if (shapedetector_shapedetectorcollection != null) { ++ BlockPos blockposition1 = shapedetector_shapedetectorcollection.getFrontTopLeft().offset(-3, 0, -3); ++ ++ for (int i = 0; i < 3; ++i) { ++ for (int j = 0; j < 3; ++j) { ++ world.setBlock(blockposition1.offset(i, 0, j), Blocks.END_PORTAL.defaultBlockState(), 2); ++ } + } ++ ++ world.globalLevelEvent(1038, blockposition1.offset(1, 0, 1), 0); + } + +- level.globalLevelEvent(1038, blockPos.offset(1, 0, 1), 0); ++ return InteractionResult.CONSUME; + } +- +- return InteractionResult.CONSUME; ++ } else { ++ return InteractionResult.PASS; + } + } + + @Override +- public InteractionResultHolder<ItemStack> use(Level level, Player player, InteractionHand hand) { +- ItemStack itemInHand = player.getItemInHand(hand); +- BlockHitResult playerPOVHitResult = getPlayerPOVHitResult(level, player, ClipContext.Fluid.NONE); +- if (playerPOVHitResult.getType() == HitResult.Type.BLOCK && level.getBlockState(playerPOVHitResult.getBlockPos()).is(Blocks.END_PORTAL_FRAME)) { +- return InteractionResultHolder.pass(itemInHand); ++ public InteractionResultHolder<ItemStack> use(Level level, Player player, EnumHand hand) { ++ ItemStack itemstack = player.getItemInHand(hand); ++ BlockHitResult movingobjectpositionblock = getPlayerPOVHitResult(level, player, ClipContext.Fluid.NONE); ++ ++ if (movingobjectpositionblock.getType() == HitResult.EnumMovingObjectType.BLOCK && level.getBlockState(movingobjectpositionblock.getBlockPos()).is(Blocks.END_PORTAL_FRAME)) { ++ return InteractionResultHolder.pass(itemstack); + } else { + player.startUsingItem(hand); +- if (level instanceof ServerLevel serverLevel) { +- BlockPos blockPos = serverLevel.findNearestMapStructure(StructureTags.EYE_OF_ENDER_LOCATED, player.blockPosition(), 100, false); +- if (blockPos != null) { +- EyeOfEnder eyeOfEnder = new EyeOfEnder(level, player.getX(), player.getY(0.5), player.getZ()); +- eyeOfEnder.setItem(itemInHand); +- eyeOfEnder.signalTo(blockPos); +- level.gameEvent(GameEvent.PROJECTILE_SHOOT, eyeOfEnder.position(), GameEvent.Context.of(player)); +- level.addFreshEntity(eyeOfEnder); ++ if (level instanceof ServerLevel) { ++ ServerLevel worldserver = (ServerLevel) level; ++ BlockPos blockposition = worldserver.findNearestMapStructure(StructureTags.EYE_OF_ENDER_LOCATED, player.blockPosition(), 100, false); ++ ++ if (blockposition != null) { ++ EyeOfEnder entityendersignal = new EyeOfEnder(level, player.getX(), player.getY(0.5D), player.getZ()); ++ ++ entityendersignal.setItem(itemstack); ++ entityendersignal.signalTo(blockposition); ++ level.gameEvent(GameEvent.PROJECTILE_SHOOT, entityendersignal.position(), GameEvent.Context.of((Entity) player)); ++ // CraftBukkit start ++ if (!level.addFreshEntity(entityendersignal)) { ++ return new InteractionResultHolder(InteractionResult.FAIL, itemstack); ++ } ++ // CraftBukkit end + if (player instanceof ServerPlayer) { +- CriteriaTriggers.USED_ENDER_EYE.trigger((ServerPlayer)player, blockPos); ++ CriteriaTriggers.USED_ENDER_EYE.trigger((ServerPlayer) player, blockposition); + } + +- level.playSound( +- null, +- player.getX(), +- player.getY(), +- player.getZ(), +- SoundEvents.ENDER_EYE_LAUNCH, +- SoundSource.NEUTRAL, +- 0.5F, +- 0.4F / (level.getRandom().nextFloat() * 0.4F + 0.8F) +- ); +- level.levelEvent(null, 1003, player.blockPosition(), 0); ++ level.playSound((Player) null, player.getX(), player.getY(), player.getZ(), SoundEvents.ENDER_EYE_LAUNCH, SoundSource.NEUTRAL, 0.5F, 0.4F / (level.getRandom().nextFloat() * 0.4F + 0.8F)); ++ level.levelEvent((Player) null, 1003, player.blockPosition(), 0); + if (!player.getAbilities().instabuild) { +- itemInHand.shrink(1); ++ itemstack.shrink(1); + } + + player.awardStat(Stats.ITEM_USED.get(this)); + player.swing(hand, true); +- return InteractionResultHolder.success(itemInHand); ++ return InteractionResultHolder.success(itemstack); + } + } + +- return InteractionResultHolder.consume(itemInHand); ++ return InteractionResultHolder.consume(itemstack); + } + } + } |