diff options
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/world/item/BowItem.java.patch')
-rw-r--r-- | patch-remap/mache-vineflower/net/minecraft/world/item/BowItem.java.patch | 200 |
1 files changed, 200 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/world/item/BowItem.java.patch b/patch-remap/mache-vineflower/net/minecraft/world/item/BowItem.java.patch new file mode 100644 index 0000000000..4607fa28b2 --- /dev/null +++ b/patch-remap/mache-vineflower/net/minecraft/world/item/BowItem.java.patch @@ -0,0 +1,200 @@ +--- a/net/minecraft/world/item/BowItem.java ++++ b/net/minecraft/world/item/BowItem.java +@@ -4,7 +4,7 @@ + import net.minecraft.sounds.SoundEvents; + import net.minecraft.sounds.SoundSource; + import net.minecraft.stats.Stats; +-import net.minecraft.world.InteractionHand; ++import net.minecraft.world.EnumHand; + import net.minecraft.world.InteractionResultHolder; + import net.minecraft.world.entity.LivingEntity; + import net.minecraft.world.entity.player.Player; +@@ -13,7 +13,8 @@ + import net.minecraft.world.item.enchantment.Enchantments; + import net.minecraft.world.level.Level; + +-public class BowItem extends ProjectileWeaponItem implements Vanishable { ++public class BowItem extends ProjectileWeaponItem implements ItemVanishable { ++ + public static final int MAX_DRAW_DURATION = 20; + public static final int DEFAULT_RANGE = 15; + +@@ -23,79 +24,97 @@ + + @Override + public void releaseUsing(ItemStack stack, Level level, LivingEntity entityLiving, int timeLeft) { +- if (entityLiving instanceof Player player) { +- boolean flag = player.getAbilities().instabuild || EnchantmentHelper.getItemEnchantmentLevel(Enchantments.INFINITY_ARROWS, stack) > 0; +- ItemStack projectile = player.getProjectile(stack); +- if (!projectile.isEmpty() || flag) { +- if (projectile.isEmpty()) { +- projectile = new ItemStack(Items.ARROW); ++ if (entityLiving instanceof Player) { ++ Player entityhuman = (Player) entityLiving; ++ boolean flag = entityhuman.getAbilities().instabuild || EnchantmentHelper.getItemEnchantmentLevel(Enchantments.INFINITY_ARROWS, stack) > 0; ++ ItemStack itemstack1 = entityhuman.getProjectile(stack); ++ ++ if (!itemstack1.isEmpty() || flag) { ++ if (itemstack1.isEmpty()) { ++ itemstack1 = new ItemStack(Items.ARROW); + } + +- int i = this.getUseDuration(stack) - timeLeft; +- float powerForTime = getPowerForTime(i); +- if (!((double)powerForTime < 0.1)) { +- boolean flag1 = flag && projectile.is(Items.ARROW); ++ int j = this.getUseDuration(stack) - timeLeft; ++ float f = getPowerForTime(j); ++ ++ if ((double) f >= 0.1D) { ++ boolean flag1 = flag && itemstack1.is(Items.ARROW); ++ + if (!level.isClientSide) { +- ArrowItem arrowItem = (ArrowItem)(projectile.getItem() instanceof ArrowItem ? projectile.getItem() : Items.ARROW); +- AbstractArrow abstractArrow = arrowItem.createArrow(level, projectile, player); +- abstractArrow.shootFromRotation(player, player.getXRot(), player.getYRot(), 0.0F, powerForTime * 3.0F, 1.0F); +- if (powerForTime == 1.0F) { +- abstractArrow.setCritArrow(true); ++ ArrowItem itemarrow = (ArrowItem) (itemstack1.getItem() instanceof ArrowItem ? itemstack1.getItem() : Items.ARROW); ++ AbstractArrow entityarrow = itemarrow.createArrow(level, itemstack1, entityhuman); ++ ++ entityarrow.shootFromRotation(entityhuman, entityhuman.getXRot(), entityhuman.getYRot(), 0.0F, f * 3.0F, 1.0F); ++ if (f == 1.0F) { ++ entityarrow.setCritArrow(true); + } + +- int itemEnchantmentLevel = EnchantmentHelper.getItemEnchantmentLevel(Enchantments.POWER_ARROWS, stack); +- if (itemEnchantmentLevel > 0) { +- abstractArrow.setBaseDamage(abstractArrow.getBaseDamage() + (double)itemEnchantmentLevel * 0.5 + 0.5); ++ int k = EnchantmentHelper.getItemEnchantmentLevel(Enchantments.POWER_ARROWS, stack); ++ ++ if (k > 0) { ++ entityarrow.setBaseDamage(entityarrow.getBaseDamage() + (double) k * 0.5D + 0.5D); + } + +- int itemEnchantmentLevel1 = EnchantmentHelper.getItemEnchantmentLevel(Enchantments.PUNCH_ARROWS, stack); +- if (itemEnchantmentLevel1 > 0) { +- abstractArrow.setKnockback(itemEnchantmentLevel1); ++ int l = EnchantmentHelper.getItemEnchantmentLevel(Enchantments.PUNCH_ARROWS, stack); ++ ++ if (l > 0) { ++ entityarrow.setKnockback(l); + } + + if (EnchantmentHelper.getItemEnchantmentLevel(Enchantments.FLAMING_ARROWS, stack) > 0) { +- abstractArrow.setSecondsOnFire(100); ++ entityarrow.setSecondsOnFire(100); + } ++ // CraftBukkit start ++ org.bukkit.event.entity.EntityShootBowEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityShootBowEvent(entityhuman, stack, itemstack1, entityarrow, entityhuman.getUsedItemHand(), f, !flag1); ++ if (event.isCancelled()) { ++ event.getProjectile().remove(); ++ return; ++ } ++ flag1 = !event.shouldConsumeItem(); ++ // CraftBukkit end + +- stack.hurtAndBreak(1, player, player1 -> player1.broadcastBreakEvent(player.getUsedItemHand())); +- if (flag1 || player.getAbilities().instabuild && (projectile.is(Items.SPECTRAL_ARROW) || projectile.is(Items.TIPPED_ARROW))) { +- abstractArrow.pickup = AbstractArrow.Pickup.CREATIVE_ONLY; ++ stack.hurtAndBreak(1, entityhuman, (entityhuman1) -> { ++ entityhuman1.broadcastBreakEvent(entityhuman.getUsedItemHand()); ++ }); ++ if (flag1 || entityhuman.getAbilities().instabuild && (itemstack1.is(Items.SPECTRAL_ARROW) || itemstack1.is(Items.TIPPED_ARROW))) { ++ entityarrow.pickup = AbstractArrow.Pickup.CREATIVE_ONLY; + } + +- level.addFreshEntity(abstractArrow); ++ // CraftBukkit start ++ if (event.getProjectile() == entityarrow.getBukkitEntity()) { ++ if (!level.addFreshEntity(entityarrow)) { ++ if (entityhuman instanceof net.minecraft.server.level.ServerPlayer) { ++ ((net.minecraft.server.level.ServerPlayer) entityhuman).getBukkitEntity().updateInventory(); ++ } ++ return; ++ } ++ } ++ // CraftBukkit end + } + +- level.playSound( +- null, +- player.getX(), +- player.getY(), +- player.getZ(), +- SoundEvents.ARROW_SHOOT, +- SoundSource.PLAYERS, +- 1.0F, +- 1.0F / (level.getRandom().nextFloat() * 0.4F + 1.2F) + powerForTime * 0.5F +- ); +- if (!flag1 && !player.getAbilities().instabuild) { +- projectile.shrink(1); +- if (projectile.isEmpty()) { +- player.getInventory().removeItem(projectile); ++ level.playSound((Player) null, entityhuman.getX(), entityhuman.getY(), entityhuman.getZ(), SoundEvents.ARROW_SHOOT, SoundSource.PLAYERS, 1.0F, 1.0F / (level.getRandom().nextFloat() * 0.4F + 1.2F) + f * 0.5F); ++ if (!flag1 && !entityhuman.getAbilities().instabuild) { ++ itemstack1.shrink(1); ++ if (itemstack1.isEmpty()) { ++ entityhuman.getInventory().removeItem(itemstack1); + } + } + +- player.awardStat(Stats.ITEM_USED.get(this)); ++ entityhuman.awardStat(Stats.ITEM_USED.get(this)); + } + } + } + } + + public static float getPowerForTime(int charge) { +- float f = (float)charge / 20.0F; +- float var2 = (f * f + f * 2.0F) / 3.0F; +- if (var2 > 1.0F) { +- var2 = 1.0F; ++ float f = (float) charge / 20.0F; ++ ++ f = (f * f + f * 2.0F) / 3.0F; ++ if (f > 1.0F) { ++ f = 1.0F; + } + +- return var2; ++ return f; + } + + @Override +@@ -104,25 +123,26 @@ + } + + @Override +- public UseAnim getUseAnimation(ItemStack stack) { +- return UseAnim.BOW; ++ public EnumAnimation getUseAnimation(ItemStack stack) { ++ return EnumAnimation.BOW; + } + + @Override +- public InteractionResultHolder<ItemStack> use(Level level, Player player, InteractionHand hand) { +- ItemStack itemInHand = player.getItemInHand(hand); +- boolean flag = !player.getProjectile(itemInHand).isEmpty(); ++ public InteractionResultHolder<ItemStack> use(Level level, Player player, EnumHand hand) { ++ ItemStack itemstack = player.getItemInHand(hand); ++ boolean flag = !player.getProjectile(itemstack).isEmpty(); ++ + if (!player.getAbilities().instabuild && !flag) { +- return InteractionResultHolder.fail(itemInHand); ++ return InteractionResultHolder.fail(itemstack); + } else { + player.startUsingItem(hand); +- return InteractionResultHolder.consume(itemInHand); ++ return InteractionResultHolder.consume(itemstack); + } + } + + @Override + public Predicate<ItemStack> getAllSupportedProjectiles() { +- return ARROW_ONLY; ++ return BowItem.ARROW_ONLY; + } + + @Override |