aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-vineflower/net/minecraft/world/item/TridentItem.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/world/item/TridentItem.java.patch')
-rw-r--r--patch-remap/mache-vineflower/net/minecraft/world/item/TridentItem.java.patch244
1 files changed, 244 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/world/item/TridentItem.java.patch b/patch-remap/mache-vineflower/net/minecraft/world/item/TridentItem.java.patch
new file mode 100644
index 0000000000..36f0180224
--- /dev/null
+++ b/patch-remap/mache-vineflower/net/minecraft/world/item/TridentItem.java.patch
@@ -0,0 +1,244 @@
+--- a/net/minecraft/world/item/TridentItem.java
++++ b/net/minecraft/world/item/TridentItem.java
+@@ -1,19 +1,20 @@
+ package net.minecraft.world.item;
+
+ import com.google.common.collect.ImmutableMultimap;
+-import com.google.common.collect.Multimap;
+ import com.google.common.collect.ImmutableMultimap.Builder;
++import com.google.common.collect.Multimap;
+ import net.minecraft.core.BlockPos;
+ import net.minecraft.sounds.SoundEvent;
+ import net.minecraft.sounds.SoundEvents;
+ 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;
+@@ -22,10 +23,11 @@
+ 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;
+@@ -34,19 +36,20 @@
+ public TridentItem(Item.Properties properties) {
+ super(properties);
+ Builder<Attribute, AttributeModifier> builder = ImmutableMultimap.builder();
+- builder.put(Attributes.ATTACK_DAMAGE, new AttributeModifier(BASE_ATTACK_DAMAGE_UUID, "Tool modifier", 8.0, AttributeModifier.Operation.ADDITION));
+- builder.put(Attributes.ATTACK_SPEED, new AttributeModifier(BASE_ATTACK_SPEED_UUID, "Tool modifier", -2.9F, AttributeModifier.Operation.ADDITION));
++
++ builder.put(Attributes.ATTACK_DAMAGE, new AttributeModifier(TridentItem.BASE_ATTACK_DAMAGE_UUID, "Tool modifier", 8.0D, AttributeModifier.Operation.ADDITION));
++ builder.put(Attributes.ATTACK_SPEED, new AttributeModifier(TridentItem.BASE_ATTACK_SPEED_UUID, "Tool modifier", -2.9000000953674316D, AttributeModifier.Operation.ADDITION));
+ this.defaultModifiers = builder.build();
+ }
+
+ @Override
+- public boolean canAttackBlock(BlockState state, Level level, BlockPos pos, Player player) {
++ public boolean canAttackBlock(IBlockData state, Level level, BlockPos pos, Player player) {
+ return !player.isCreative();
+ }
+
+ @Override
+- public UseAnim getUseAnimation(ItemStack stack) {
+- return UseAnim.SPEAR;
++ public EnumAnimation getUseAnimation(ItemStack stack) {
++ return EnumAnimation.SPEAR;
+ }
+
+ @Override
+@@ -56,86 +59,127 @@
+
+ @Override
+ public void releaseUsing(ItemStack stack, Level level, LivingEntity entityLiving, int timeLeft) {
+- if (entityLiving instanceof Player player) {
+- int i = this.getUseDuration(stack) - timeLeft;
+- if (i >= 10) {
+- int riptide = EnchantmentHelper.getRiptide(stack);
+- if (riptide <= 0 || player.isInWaterOrRain()) {
++ if (entityLiving instanceof Player) {
++ Player entityhuman = (Player) entityLiving;
++ int j = this.getUseDuration(stack) - timeLeft;
++
++ if (j >= 10) {
++ int k = EnchantmentHelper.getRiptide(stack);
++
++ if (k <= 0 || entityhuman.isInWaterOrRain()) {
+ if (!level.isClientSide) {
+- stack.hurtAndBreak(1, player, contextEntity -> contextEntity.broadcastBreakEvent(entityLiving.getUsedItemHand()));
+- if (riptide == 0) {
+- ThrownTrident thrownTrident = new ThrownTrident(level, player, stack);
+- thrownTrident.shootFromRotation(player, player.getXRot(), player.getYRot(), 0.0F, 2.5F + (float)riptide * 0.5F, 1.0F);
+- if (player.getAbilities().instabuild) {
+- thrownTrident.pickup = AbstractArrow.Pickup.CREATIVE_ONLY;
++ // CraftBukkit - moved down
++ /*
++ itemstack.hurtAndBreak(1, entityhuman, (entityhuman1) -> {
++ entityhuman1.broadcastBreakEvent(entityliving.getUsedItemHand());
++ });
++ */
++ if (k == 0) {
++ ThrownTrident entitythrowntrident = new ThrownTrident(level, entityhuman, stack);
++
++ 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(null, thrownTrident, SoundEvents.TRIDENT_THROW, SoundSource.PLAYERS, 1.0F, 1.0F);
+- if (!player.getAbilities().instabuild) {
+- player.getInventory().removeItem(stack);
++ // 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));
+- if (riptide > 0) {
+- float yRot = player.getYRot();
+- float xRot = player.getXRot();
+- float f = -Mth.sin(yRot * (float) (Math.PI / 180.0)) * Mth.cos(xRot * (float) (Math.PI / 180.0));
+- float f1 = -Mth.sin(xRot * (float) (Math.PI / 180.0));
+- float f2 = Mth.cos(yRot * (float) (Math.PI / 180.0)) * Mth.cos(xRot * (float) (Math.PI / 180.0));
+- float squareRoot = Mth.sqrt(f * f + f1 * f1 + f2 * f2);
+- float f3 = 3.0F * ((1.0F + (float)riptide) / 4.0F);
+- f *= f3 / squareRoot;
+- f1 *= f3 / squareRoot;
+- f2 *= f3 / squareRoot;
+- player.push((double)f, (double)f1, (double)f2);
+- player.startAutoSpinAttack(20);
+- if (player.onGround()) {
+- float f4 = 1.1999999F;
+- player.move(MoverType.SELF, new Vec3(0.0, 1.1999999F, 0.0));
++ entityhuman.awardStat(Stats.ITEM_USED.get(this));
++ if (k > 0) {
++ // 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);
++ float f5 = Mth.sqrt(f2 * f2 + f3 * f3 + f4 * f4);
++ float f6 = 3.0F * ((1.0F + (float) k) / 4.0F);
++
++ f2 *= f6 / f5;
++ f3 *= f6 / f5;
++ f4 *= f6 / f5;
++ entityhuman.push((double) f2, (double) f3, (double) f4);
++ entityhuman.startAutoSpinAttack(20);
++ if (entityhuman.onGround()) {
++ float f7 = 1.1999999F;
++
++ entityhuman.move(EnumMoveType.SELF, new Vec3(0.0D, 1.1999999284744263D, 0.0D));
+ }
+
+- SoundEvent soundEvent;
+- if (riptide >= 3) {
+- soundEvent = SoundEvents.TRIDENT_RIPTIDE_3;
+- } else if (riptide == 2) {
+- soundEvent = SoundEvents.TRIDENT_RIPTIDE_2;
++ SoundEvent soundeffect;
++
++ if (k >= 3) {
++ soundeffect = SoundEvents.TRIDENT_RIPTIDE_3;
++ } else if (k == 2) {
++ soundeffect = SoundEvents.TRIDENT_RIPTIDE_2;
+ } else {
+- soundEvent = SoundEvents.TRIDENT_RIPTIDE_1;
++ soundeffect = SoundEvents.TRIDENT_RIPTIDE_1;
+ }
+
+- level.playSound(null, player, soundEvent, SoundSource.PLAYERS, 1.0F, 1.0F);
++ level.playSound((Player) null, (Entity) entityhuman, soundeffect, SoundSource.PLAYERS, 1.0F, 1.0F);
+ }
++
+ }
+ }
+ }
+ }
+
+ @Override
+- public InteractionResultHolder<ItemStack> use(Level level, Player player, InteractionHand hand) {
+- ItemStack itemInHand = player.getItemInHand(hand);
+- if (itemInHand.getDamageValue() >= itemInHand.getMaxDamage() - 1) {
+- return InteractionResultHolder.fail(itemInHand);
+- } else if (EnchantmentHelper.getRiptide(itemInHand) > 0 && !player.isInWaterOrRain()) {
+- return InteractionResultHolder.fail(itemInHand);
++ 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(hand);
+- return InteractionResultHolder.consume(itemInHand);
++ return InteractionResultHolder.consume(itemstack);
+ }
+ }
+
+ @Override
+ public boolean hurtEnemy(ItemStack stack, LivingEntity target, LivingEntity attacker) {
+- stack.hurtAndBreak(1, attacker, contextEntity -> contextEntity.broadcastBreakEvent(EquipmentSlot.MAINHAND));
++ stack.hurtAndBreak(1, attacker, (entityliving2) -> {
++ entityliving2.broadcastBreakEvent(EquipmentSlot.MAINHAND);
++ });
+ return true;
+ }
+
+ @Override
+- public boolean mineBlock(ItemStack stack, Level level, BlockState state, BlockPos pos, LivingEntity entityLiving) {
+- if ((double)state.getDestroySpeed(level, pos) != 0.0) {
+- stack.hurtAndBreak(2, entityLiving, contextEntity -> contextEntity.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);
++ });
+ }
+
+ return true;