diff options
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/world/item/ChorusFruitItem.java.patch')
-rw-r--r-- | patch-remap/mache-vineflower/net/minecraft/world/item/ChorusFruitItem.java.patch | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/world/item/ChorusFruitItem.java.patch b/patch-remap/mache-vineflower/net/minecraft/world/item/ChorusFruitItem.java.patch new file mode 100644 index 0000000000..8f1c09e300 --- /dev/null +++ b/patch-remap/mache-vineflower/net/minecraft/world/item/ChorusFruitItem.java.patch @@ -0,0 +1,95 @@ +--- a/net/minecraft/world/item/ChorusFruitItem.java ++++ b/net/minecraft/world/item/ChorusFruitItem.java +@@ -5,6 +5,7 @@ + import net.minecraft.sounds.SoundEvents; + import net.minecraft.sounds.SoundSource; + import net.minecraft.util.Mth; ++import net.minecraft.world.entity.Entity; + import net.minecraft.world.entity.LivingEntity; + import net.minecraft.world.entity.animal.Fox; + import net.minecraft.world.entity.player.Player; +@@ -13,50 +14,62 @@ + import net.minecraft.world.phys.Vec3; + + public class ChorusFruitItem extends Item { ++ + public ChorusFruitItem(Item.Properties properties) { + super(properties); + } + + @Override + public ItemStack finishUsingItem(ItemStack stack, Level level, LivingEntity entityLiving) { +- ItemStack itemStack = super.finishUsingItem(stack, level, entityLiving); ++ ItemStack itemstack1 = super.finishUsingItem(stack, level, entityLiving); ++ + if (!level.isClientSide) { +- for (int i = 0; i < 16; i++) { +- double d = entityLiving.getX() + (entityLiving.getRandom().nextDouble() - 0.5) * 16.0; +- double d1 = Mth.clamp( +- entityLiving.getY() + (double)(entityLiving.getRandom().nextInt(16) - 8), +- (double)level.getMinBuildHeight(), +- (double)(level.getMinBuildHeight() + ((ServerLevel)level).getLogicalHeight() - 1) +- ); +- double d2 = entityLiving.getZ() + (entityLiving.getRandom().nextDouble() - 0.5) * 16.0; ++ for (int i = 0; i < 16; ++i) { ++ double d0 = entityLiving.getX() + (entityLiving.getRandom().nextDouble() - 0.5D) * 16.0D; ++ double d1 = Mth.clamp(entityLiving.getY() + (double) (entityLiving.getRandom().nextInt(16) - 8), (double) level.getMinBuildHeight(), (double) (level.getMinBuildHeight() + ((ServerLevel) level).getLogicalHeight() - 1)); ++ double d2 = entityLiving.getZ() + (entityLiving.getRandom().nextDouble() - 0.5D) * 16.0D; ++ + if (entityLiving.isPassenger()) { + entityLiving.stopRiding(); + } + +- Vec3 vec3 = entityLiving.position(); +- if (entityLiving.randomTeleport(d, d1, d2, true)) { +- level.gameEvent(GameEvent.TELEPORT, vec3, GameEvent.Context.of(entityLiving)); +- SoundSource soundSource; +- SoundEvent soundEvent; ++ Vec3 vec3d = entityLiving.position(); ++ ++ // CraftBukkit start - handle canceled status of teleport event ++ java.util.Optional<Boolean> status = entityLiving.randomTeleport(d0, d1, d2, true, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.CHORUS_FRUIT); ++ ++ if (!status.isPresent()) { ++ // teleport event was canceled, no more tries ++ break; ++ } ++ ++ if (status.get()) { ++ // CraftBukkit end ++ level.gameEvent(GameEvent.TELEPORT, vec3d, GameEvent.Context.of((Entity) entityLiving)); ++ SoundEvent soundeffect; ++ SoundSource soundcategory; ++ + if (entityLiving instanceof Fox) { +- soundEvent = SoundEvents.FOX_TELEPORT; +- soundSource = SoundSource.NEUTRAL; ++ soundeffect = SoundEvents.FOX_TELEPORT; ++ soundcategory = SoundSource.NEUTRAL; + } else { +- soundEvent = SoundEvents.CHORUS_FRUIT_TELEPORT; +- soundSource = SoundSource.PLAYERS; ++ soundeffect = SoundEvents.CHORUS_FRUIT_TELEPORT; ++ soundcategory = SoundSource.PLAYERS; + } + +- level.playSound(null, entityLiving.getX(), entityLiving.getY(), entityLiving.getZ(), soundEvent, soundSource); ++ level.playSound((Player) null, entityLiving.getX(), entityLiving.getY(), entityLiving.getZ(), soundeffect, soundcategory); + entityLiving.resetFallDistance(); + break; + } + } + +- if (entityLiving instanceof Player player) { +- player.getCooldowns().addCooldown(this, 20); ++ if (entityLiving instanceof Player) { ++ Player entityhuman = (Player) entityLiving; ++ ++ entityhuman.getCooldowns().addCooldown(this, 20); + } + } + +- return itemStack; ++ return itemstack1; + } + } |