diff options
Diffstat (limited to 'patch-remap/mache-spigotflower/net/minecraft/world/item/TridentItem.java.patch')
-rw-r--r-- | patch-remap/mache-spigotflower/net/minecraft/world/item/TridentItem.java.patch | 245 |
1 files changed, 245 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower/net/minecraft/world/item/TridentItem.java.patch b/patch-remap/mache-spigotflower/net/minecraft/world/item/TridentItem.java.patch new file mode 100644 index 0000000000..65ea0af315 --- /dev/null +++ b/patch-remap/mache-spigotflower/net/minecraft/world/item/TridentItem.java.patch @@ -0,0 +1,245 @@ +--- a/net/minecraft/world/item/TridentItem.java ++++ b/net/minecraft/world/item/TridentItem.java +@@ -9,12 +9,12 @@ + import net.minecraft.sounds.SoundSource; + import net.minecraft.stats.Stats; + import net.minecraft.util.Mth; +-import net.minecraft.world.InteractionHand; ++import net.minecraft.world.EnumHand; + import net.minecraft.world.InteractionResultHolder; + import net.minecraft.world.entity.Entity; ++import net.minecraft.world.entity.EnumMoveType; + import net.minecraft.world.entity.EquipmentSlot; + import net.minecraft.world.entity.LivingEntity; +-import net.minecraft.world.entity.MoverType; + import net.minecraft.world.entity.ai.attributes.Attribute; + import net.minecraft.world.entity.ai.attributes.AttributeModifier; + import net.minecraft.world.entity.ai.attributes.Attributes; +@@ -23,18 +23,18 @@ + import net.minecraft.world.entity.projectile.ThrownTrident; + import net.minecraft.world.item.enchantment.EnchantmentHelper; + import net.minecraft.world.level.Level; +-import net.minecraft.world.level.block.state.BlockState; ++import net.minecraft.world.level.block.state.IBlockData; + import net.minecraft.world.phys.Vec3; + +-public class TridentItem extends Item implements Vanishable { ++public class TridentItem extends Item implements ItemVanishable { + + public static final int THROW_THRESHOLD_TIME = 10; + public static final float BASE_DAMAGE = 8.0F; + public static final float SHOOT_POWER = 2.5F; + private final Multimap<Attribute, AttributeModifier> defaultModifiers; + +- public TridentItem(Item.Properties item_properties) { +- super(item_properties); ++ public TridentItem(Item.Properties properties) { ++ super(properties); + Builder<Attribute, AttributeModifier> builder = ImmutableMultimap.builder(); + + builder.put(Attributes.ATTACK_DAMAGE, new AttributeModifier(TridentItem.BASE_ATTACK_DAMAGE_UUID, "Tool modifier", 8.0D, AttributeModifier.Operation.ADDITION)); +@@ -43,58 +43,80 @@ + } + + @Override +- @Override +- public boolean canAttackBlock(BlockState blockstate, Level level, BlockPos blockpos, Player player) { ++ public boolean canAttackBlock(IBlockData state, Level level, BlockPos pos, Player player) { + return !player.isCreative(); + } + + @Override +- @Override +- public UseAnim getUseAnimation(ItemStack itemstack) { +- return UseAnim.SPEAR; ++ public EnumAnimation getUseAnimation(ItemStack stack) { ++ return EnumAnimation.SPEAR; + } + + @Override +- @Override +- public int getUseDuration(ItemStack itemstack) { ++ public int getUseDuration(ItemStack stack) { + return 72000; + } + + @Override +- @Override +- public void releaseUsing(ItemStack itemstack, Level level, LivingEntity livingentity, int i) { +- if (livingentity instanceof Player) { +- Player player = (Player) livingentity; +- int j = this.getUseDuration(itemstack) - i; ++ public void releaseUsing(ItemStack stack, Level level, LivingEntity entityLiving, int timeLeft) { ++ if (entityLiving instanceof Player) { ++ Player entityhuman = (Player) entityLiving; ++ int j = this.getUseDuration(stack) - timeLeft; + + if (j >= 10) { +- int k = EnchantmentHelper.getRiptide(itemstack); ++ int k = EnchantmentHelper.getRiptide(stack); + +- if (k <= 0 || player.isInWaterOrRain()) { ++ if (k <= 0 || entityhuman.isInWaterOrRain()) { + if (!level.isClientSide) { +- itemstack.hurtAndBreak(1, player, (player1) -> { +- player1.broadcastBreakEvent(livingentity.getUsedItemHand()); ++ // CraftBukkit - moved down ++ /* ++ itemstack.hurtAndBreak(1, entityhuman, (entityhuman1) -> { ++ entityhuman1.broadcastBreakEvent(entityliving.getUsedItemHand()); + }); ++ */ + if (k == 0) { +- ThrownTrident throwntrident = new ThrownTrident(level, player, itemstack); ++ ThrownTrident entitythrowntrident = new ThrownTrident(level, entityhuman, stack); + +- throwntrident.shootFromRotation(player, player.getXRot(), player.getYRot(), 0.0F, 2.5F + (float) k * 0.5F, 1.0F); +- if (player.getAbilities().instabuild) { +- throwntrident.pickup = AbstractArrow.Pickup.CREATIVE_ONLY; ++ entitythrowntrident.shootFromRotation(entityhuman, entityhuman.getXRot(), entityhuman.getYRot(), 0.0F, 2.5F + (float) k * 0.5F, 1.0F); ++ if (entityhuman.getAbilities().instabuild) { ++ entitythrowntrident.pickup = AbstractArrow.Pickup.CREATIVE_ONLY; + } + +- level.addFreshEntity(throwntrident); +- level.playSound((Player) null, (Entity) throwntrident, SoundEvents.TRIDENT_THROW, SoundSource.PLAYERS, 1.0F, 1.0F); +- if (!player.getAbilities().instabuild) { +- player.getInventory().removeItem(itemstack); ++ // CraftBukkit start ++ if (!level.addFreshEntity(entitythrowntrident)) { ++ if (entityhuman instanceof net.minecraft.server.level.ServerPlayer) { ++ ((net.minecraft.server.level.ServerPlayer) entityhuman).getBukkitEntity().updateInventory(); ++ } ++ return; + } ++ ++ stack.hurtAndBreak(1, entityhuman, (entityhuman1) -> { ++ entityhuman1.broadcastBreakEvent(entityLiving.getUsedItemHand()); ++ }); ++ entitythrowntrident.pickupItemStack = stack.copy(); // SPIGOT-4511 update since damage call moved ++ // CraftBukkit end ++ ++ level.playSound((Player) null, (Entity) entitythrowntrident, SoundEvents.TRIDENT_THROW, SoundSource.PLAYERS, 1.0F, 1.0F); ++ if (!entityhuman.getAbilities().instabuild) { ++ entityhuman.getInventory().removeItem(stack); ++ } ++ // CraftBukkit start - SPIGOT-5458 also need in this branch :( ++ } else { ++ stack.hurtAndBreak(1, entityhuman, (entityhuman1) -> { ++ entityhuman1.broadcastBreakEvent(entityLiving.getUsedItemHand()); ++ }); ++ // CraftBukkkit end + } + } + +- player.awardStat(Stats.ITEM_USED.get(this)); ++ entityhuman.awardStat(Stats.ITEM_USED.get(this)); + if (k > 0) { +- float f = player.getYRot(); +- float f1 = player.getXRot(); ++ // CraftBukkit start ++ org.bukkit.event.player.PlayerRiptideEvent event = new org.bukkit.event.player.PlayerRiptideEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(stack)); ++ event.getPlayer().getServer().getPluginManager().callEvent(event); ++ // CraftBukkit end ++ float f = entityhuman.getYRot(); ++ float f1 = entityhuman.getXRot(); + float f2 = -Mth.sin(f * 0.017453292F) * Mth.cos(f1 * 0.017453292F); + float f3 = -Mth.sin(f1 * 0.017453292F); + float f4 = Mth.cos(f * 0.017453292F) * Mth.cos(f1 * 0.017453292F); +@@ -104,25 +126,25 @@ + f2 *= f6 / f5; + f3 *= f6 / f5; + f4 *= f6 / f5; +- player.push((double) f2, (double) f3, (double) f4); +- player.startAutoSpinAttack(20); +- if (player.onGround()) { ++ entityhuman.push((double) f2, (double) f3, (double) f4); ++ entityhuman.startAutoSpinAttack(20); ++ if (entityhuman.onGround()) { + float f7 = 1.1999999F; + +- player.move(MoverType.SELF, new Vec3(0.0D, 1.1999999284744263D, 0.0D)); ++ entityhuman.move(EnumMoveType.SELF, new Vec3(0.0D, 1.1999999284744263D, 0.0D)); + } + +- SoundEvent soundevent; ++ SoundEvent soundeffect; + + if (k >= 3) { +- soundevent = SoundEvents.TRIDENT_RIPTIDE_3; ++ soundeffect = SoundEvents.TRIDENT_RIPTIDE_3; + } else if (k == 2) { +- soundevent = SoundEvents.TRIDENT_RIPTIDE_2; ++ soundeffect = SoundEvents.TRIDENT_RIPTIDE_2; + } else { +- soundevent = SoundEvents.TRIDENT_RIPTIDE_1; ++ soundeffect = SoundEvents.TRIDENT_RIPTIDE_1; + } + +- level.playSound((Player) null, (Entity) player, soundevent, SoundSource.PLAYERS, 1.0F, 1.0F); ++ level.playSound((Player) null, (Entity) entityhuman, soundeffect, SoundSource.PLAYERS, 1.0F, 1.0F); + } + + } +@@ -131,35 +153,32 @@ + } + + @Override +- @Override +- public InteractionResultHolder<ItemStack> use(Level level, Player player, InteractionHand interactionhand) { +- ItemStack itemstack = player.getItemInHand(interactionhand); ++ public InteractionResultHolder<ItemStack> use(Level level, Player player, EnumHand hand) { ++ ItemStack itemstack = player.getItemInHand(hand); + + if (itemstack.getDamageValue() >= itemstack.getMaxDamage() - 1) { + return InteractionResultHolder.fail(itemstack); + } else if (EnchantmentHelper.getRiptide(itemstack) > 0 && !player.isInWaterOrRain()) { + return InteractionResultHolder.fail(itemstack); + } else { +- player.startUsingItem(interactionhand); ++ player.startUsingItem(hand); + return InteractionResultHolder.consume(itemstack); + } + } + + @Override +- @Override +- public boolean hurtEnemy(ItemStack itemstack, LivingEntity livingentity, LivingEntity livingentity1) { +- itemstack.hurtAndBreak(1, livingentity1, (livingentity2) -> { +- livingentity2.broadcastBreakEvent(EquipmentSlot.MAINHAND); ++ public boolean hurtEnemy(ItemStack stack, LivingEntity target, LivingEntity attacker) { ++ stack.hurtAndBreak(1, attacker, (entityliving2) -> { ++ entityliving2.broadcastBreakEvent(EquipmentSlot.MAINHAND); + }); + return true; + } + + @Override +- @Override +- public boolean mineBlock(ItemStack itemstack, Level level, BlockState blockstate, BlockPos blockpos, LivingEntity livingentity) { +- if ((double) blockstate.getDestroySpeed(level, blockpos) != 0.0D) { +- itemstack.hurtAndBreak(2, livingentity, (livingentity1) -> { +- livingentity1.broadcastBreakEvent(EquipmentSlot.MAINHAND); ++ public boolean mineBlock(ItemStack stack, Level level, IBlockData state, BlockPos pos, LivingEntity entityLiving) { ++ if ((double) state.getDestroySpeed(level, pos) != 0.0D) { ++ stack.hurtAndBreak(2, entityLiving, (entityliving1) -> { ++ entityliving1.broadcastBreakEvent(EquipmentSlot.MAINHAND); + }); + } + +@@ -167,13 +186,11 @@ + } + + @Override +- @Override +- public Multimap<Attribute, AttributeModifier> getDefaultAttributeModifiers(EquipmentSlot equipmentslot) { +- return equipmentslot == EquipmentSlot.MAINHAND ? this.defaultModifiers : super.getDefaultAttributeModifiers(equipmentslot); ++ public Multimap<Attribute, AttributeModifier> getDefaultAttributeModifiers(EquipmentSlot equipmentSlot) { ++ return equipmentSlot == EquipmentSlot.MAINHAND ? this.defaultModifiers : super.getDefaultAttributeModifiers(equipmentSlot); + } + + @Override +- @Override + public int getEnchantmentValue() { + return 1; + } |