diff options
Diffstat (limited to 'patch-remap/mache-spigotflower/net/minecraft/world/item/PotionItem.java.patch')
-rw-r--r-- | patch-remap/mache-spigotflower/net/minecraft/world/item/PotionItem.java.patch | 185 |
1 files changed, 185 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower/net/minecraft/world/item/PotionItem.java.patch b/patch-remap/mache-spigotflower/net/minecraft/world/item/PotionItem.java.patch new file mode 100644 index 0000000000..cdf203b6ae --- /dev/null +++ b/patch-remap/mache-spigotflower/net/minecraft/world/item/PotionItem.java.patch @@ -0,0 +1,185 @@ +--- a/net/minecraft/world/item/PotionItem.java ++++ b/net/minecraft/world/item/PotionItem.java +@@ -14,7 +14,7 @@ + import net.minecraft.sounds.SoundSource; + import net.minecraft.stats.Stats; + import net.minecraft.tags.BlockTags; +-import net.minecraft.world.InteractionHand; ++import net.minecraft.world.EnumHand; + import net.minecraft.world.InteractionResult; + import net.minecraft.world.InteractionResultHolder; + import net.minecraft.world.effect.MobEffectInstance; +@@ -26,125 +26,117 @@ + import net.minecraft.world.item.context.UseOnContext; + import net.minecraft.world.level.Level; + import net.minecraft.world.level.block.Blocks; +-import net.minecraft.world.level.block.state.BlockState; ++import net.minecraft.world.level.block.state.IBlockData; + import net.minecraft.world.level.gameevent.GameEvent; + + public class PotionItem extends Item { + + private static final int DRINK_DURATION = 32; + +- public PotionItem(Item.Properties item_properties) { +- super(item_properties); ++ public PotionItem(Item.Properties properties) { ++ super(properties); + } + + @Override +- @Override + public ItemStack getDefaultInstance() { + return PotionUtils.setPotion(super.getDefaultInstance(), Potions.WATER); + } + + @Override +- @Override +- public ItemStack finishUsingItem(ItemStack itemstack, Level level, LivingEntity livingentity) { +- Player player = livingentity instanceof Player ? (Player) livingentity : null; ++ public ItemStack finishUsingItem(ItemStack stack, Level level, LivingEntity entityLiving) { ++ Player entityhuman = entityLiving instanceof Player ? (Player) entityLiving : null; + +- if (player instanceof ServerPlayer) { +- CriteriaTriggers.CONSUME_ITEM.trigger((ServerPlayer) player, itemstack); ++ if (entityhuman instanceof ServerPlayer) { ++ CriteriaTriggers.CONSUME_ITEM.trigger((ServerPlayer) entityhuman, stack); + } + + if (!level.isClientSide) { +- List<MobEffectInstance> list = PotionUtils.getMobEffects(itemstack); ++ List<MobEffectInstance> list = PotionUtils.getMobEffects(stack); + Iterator iterator = list.iterator(); + + while (iterator.hasNext()) { +- MobEffectInstance mobeffectinstance = (MobEffectInstance) iterator.next(); ++ MobEffectInstance mobeffect = (MobEffectInstance) iterator.next(); + +- if (mobeffectinstance.getEffect().isInstantenous()) { +- mobeffectinstance.getEffect().applyInstantenousEffect(player, player, livingentity, mobeffectinstance.getAmplifier(), 1.0D); ++ if (mobeffect.getEffect().isInstantenous()) { ++ mobeffect.getEffect().applyInstantenousEffect(entityhuman, entityhuman, entityLiving, mobeffect.getAmplifier(), 1.0D); + } else { +- livingentity.addEffect(new MobEffectInstance(mobeffectinstance)); ++ entityLiving.addEffect(new MobEffectInstance(mobeffect), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.POTION_DRINK); // CraftBukkit + } + } + } + +- if (player != null) { +- player.awardStat(Stats.ITEM_USED.get(this)); +- if (!player.getAbilities().instabuild) { +- itemstack.shrink(1); ++ if (entityhuman != null) { ++ entityhuman.awardStat(Stats.ITEM_USED.get(this)); ++ if (!entityhuman.getAbilities().instabuild) { ++ stack.shrink(1); + } + } + +- if (player == null || !player.getAbilities().instabuild) { +- if (itemstack.isEmpty()) { ++ if (entityhuman == null || !entityhuman.getAbilities().instabuild) { ++ if (stack.isEmpty()) { + return new ItemStack(Items.GLASS_BOTTLE); + } + +- if (player != null) { +- player.getInventory().add(new ItemStack(Items.GLASS_BOTTLE)); ++ if (entityhuman != null) { ++ entityhuman.getInventory().add(new ItemStack(Items.GLASS_BOTTLE)); + } + } + +- livingentity.gameEvent(GameEvent.DRINK); +- return itemstack; ++ entityLiving.gameEvent(GameEvent.DRINK); ++ return stack; + } + + @Override +- @Override +- public InteractionResult useOn(UseOnContext useoncontext) { +- Level level = useoncontext.getLevel(); +- BlockPos blockpos = useoncontext.getClickedPos(); +- Player player = useoncontext.getPlayer(); +- ItemStack itemstack = useoncontext.getItemInHand(); +- BlockState blockstate = level.getBlockState(blockpos); ++ public InteractionResult useOn(UseOnContext context) { ++ Level world = context.getLevel(); ++ BlockPos blockposition = context.getClickedPos(); ++ Player entityhuman = context.getPlayer(); ++ ItemStack itemstack = context.getItemInHand(); ++ IBlockData iblockdata = world.getBlockState(blockposition); + +- if (useoncontext.getClickedFace() != Direction.DOWN && blockstate.is(BlockTags.CONVERTABLE_TO_MUD) && PotionUtils.getPotion(itemstack) == Potions.WATER) { +- level.playSound((Player) null, blockpos, SoundEvents.GENERIC_SPLASH, SoundSource.BLOCKS, 1.0F, 1.0F); +- player.setItemInHand(useoncontext.getHand(), ItemUtils.createFilledResult(itemstack, player, new ItemStack(Items.GLASS_BOTTLE))); +- player.awardStat(Stats.ITEM_USED.get(itemstack.getItem())); +- if (!level.isClientSide) { +- ServerLevel serverlevel = (ServerLevel) level; ++ if (context.getClickedFace() != Direction.DOWN && iblockdata.is(BlockTags.CONVERTABLE_TO_MUD) && PotionUtils.getPotion(itemstack) == Potions.WATER) { ++ world.playSound((Player) null, blockposition, SoundEvents.GENERIC_SPLASH, SoundSource.BLOCKS, 1.0F, 1.0F); ++ entityhuman.setItemInHand(context.getHand(), ItemUtils.createFilledResult(itemstack, entityhuman, new ItemStack(Items.GLASS_BOTTLE))); ++ entityhuman.awardStat(Stats.ITEM_USED.get(itemstack.getItem())); ++ if (!world.isClientSide) { ++ ServerLevel worldserver = (ServerLevel) world; + + for (int i = 0; i < 5; ++i) { +- serverlevel.sendParticles(ParticleTypes.SPLASH, (double) blockpos.getX() + level.random.nextDouble(), (double) (blockpos.getY() + 1), (double) blockpos.getZ() + level.random.nextDouble(), 1, 0.0D, 0.0D, 0.0D, 1.0D); ++ worldserver.sendParticles(ParticleTypes.SPLASH, (double) blockposition.getX() + world.random.nextDouble(), (double) (blockposition.getY() + 1), (double) blockposition.getZ() + world.random.nextDouble(), 1, 0.0D, 0.0D, 0.0D, 1.0D); + } + } + +- level.playSound((Player) null, blockpos, SoundEvents.BOTTLE_EMPTY, SoundSource.BLOCKS, 1.0F, 1.0F); +- level.gameEvent((Entity) null, GameEvent.FLUID_PLACE, blockpos); +- level.setBlockAndUpdate(blockpos, Blocks.MUD.defaultBlockState()); +- return InteractionResult.sidedSuccess(level.isClientSide); ++ world.playSound((Player) null, blockposition, SoundEvents.BOTTLE_EMPTY, SoundSource.BLOCKS, 1.0F, 1.0F); ++ world.gameEvent((Entity) null, GameEvent.FLUID_PLACE, blockposition); ++ world.setBlockAndUpdate(blockposition, Blocks.MUD.defaultBlockState()); ++ return InteractionResult.sidedSuccess(world.isClientSide); + } else { + return InteractionResult.PASS; + } + } + + @Override +- @Override +- public int getUseDuration(ItemStack itemstack) { ++ public int getUseDuration(ItemStack stack) { + return 32; + } + + @Override +- @Override +- public UseAnim getUseAnimation(ItemStack itemstack) { +- return UseAnim.DRINK; ++ public EnumAnimation getUseAnimation(ItemStack stack) { ++ return EnumAnimation.DRINK; + } + + @Override +- @Override +- public InteractionResultHolder<ItemStack> use(Level level, Player player, InteractionHand interactionhand) { +- return ItemUtils.startUsingInstantly(level, player, interactionhand); ++ public InteractionResultHolder<ItemStack> use(Level level, Player player, EnumHand hand) { ++ return ItemUtils.startUsingInstantly(level, player, hand); + } + + @Override +- @Override +- public String getDescriptionId(ItemStack itemstack) { +- return PotionUtils.getPotion(itemstack).getName(this.getDescriptionId() + ".effect."); ++ public String getDescriptionId(ItemStack stack) { ++ return PotionUtils.getPotion(stack).getName(this.getDescriptionId() + ".effect."); + } + + @Override +- @Override +- public void appendHoverText(ItemStack itemstack, @Nullable Level level, List<Component> list, TooltipFlag tooltipflag) { +- PotionUtils.addPotionTooltip(itemstack, list, 1.0F, level == null ? 20.0F : level.tickRateManager().tickrate()); ++ public void appendHoverText(ItemStack stack, @Nullable Level level, List<Component> tooltip, TooltipFlag flag) { ++ PotionUtils.addPotionTooltip(stack, tooltip, 1.0F, level == null ? 20.0F : level.tickRateManager().tickrate()); + } + } |