Better support for custom bows (#5209)

This commit is contained in:
Ben Staddon 2019-04-23 18:04:19 -04:00 committed by tterrag
parent 18d0f7ba0d
commit aef224221f
9 changed files with 117 additions and 2 deletions

View file

@ -1,5 +1,14 @@
--- a/net/minecraft/client/entity/AbstractClientPlayer.java
+++ b/net/minecraft/client/entity/AbstractClientPlayer.java
@@ -114,7 +114,7 @@
f = 1.0F;
}
- if (this.func_184587_cr() && this.func_184607_cu().func_77973_b() == Items.field_151031_f) {
+ if (this.func_184587_cr() && this.func_184607_cu().func_77973_b() instanceof net.minecraft.item.ItemBow) {
int i = this.func_184612_cw();
float f1 = (float)i / 20.0F;
if (f1 > 1.0F) {
@@ -126,6 +126,6 @@
f *= 1.0F - f1 * 0.15F;
}

View file

@ -1,5 +1,14 @@
--- a/net/minecraft/client/renderer/FirstPersonRenderer.java
+++ b/net/minecraft/client/renderer/FirstPersonRenderer.java
@@ -273,7 +273,7 @@
boolean flag1 = true;
if (abstractclientplayer.func_184587_cr()) {
ItemStack itemstack = abstractclientplayer.func_184607_cu();
- if (itemstack.func_77973_b() == Items.field_151031_f) {
+ if (itemstack.func_77973_b() instanceof net.minecraft.item.ItemBow) {
flag = abstractclientplayer.func_184600_cs() == EnumHand.MAIN_HAND;
flag1 = !flag;
}
@@ -286,12 +286,14 @@
if (flag) {
float f4 = enumhand == EnumHand.MAIN_HAND ? f : 0.0F;

View file

@ -0,0 +1,11 @@
--- a/net/minecraft/client/renderer/entity/layers/LayerHeldItemWitch.java
+++ b/net/minecraft/client/renderer/entity/layers/LayerHeldItemWitch.java
@@ -43,7 +43,7 @@
GlStateManager.func_179114_b(-5.0F, 0.0F, 1.0F, 0.0F);
float f1 = 0.375F;
GlStateManager.func_179152_a(0.375F, -0.375F, 0.375F);
- } else if (item == Items.field_151031_f) {
+ } else if (item instanceof net.minecraft.item.ItemBow) {
GlStateManager.func_179109_b(0.0F, 0.125F, -0.125F);
GlStateManager.func_179114_b(-45.0F, 0.0F, 1.0F, 0.0F);
float f2 = 0.625F;

View file

@ -0,0 +1,20 @@
--- a/net/minecraft/client/renderer/entity/model/ModelSkeleton.java
+++ b/net/minecraft/client/renderer/entity/model/ModelSkeleton.java
@@ -42,7 +42,7 @@
this.field_187076_m = ModelBiped.ArmPose.EMPTY;
this.field_187075_l = ModelBiped.ArmPose.EMPTY;
ItemStack itemstack = p_78086_1_.func_184586_b(EnumHand.MAIN_HAND);
- if (itemstack.func_77973_b() == Items.field_151031_f && ((AbstractSkeleton)p_78086_1_).func_184725_db()) {
+ if (itemstack.func_77973_b() instanceof net.minecraft.item.ItemBow && ((AbstractSkeleton)p_78086_1_).func_184725_db()) {
if (p_78086_1_.func_184591_cq() == EnumHandSide.RIGHT) {
this.field_187076_m = ModelBiped.ArmPose.BOW_AND_ARROW;
} else {
@@ -57,7 +57,7 @@
super.func_78087_a(p_78087_1_, p_78087_2_, p_78087_3_, p_78087_4_, p_78087_5_, p_78087_6_, p_78087_7_);
ItemStack itemstack = ((EntityLivingBase)p_78087_7_).func_184614_ca();
AbstractSkeleton abstractskeleton = (AbstractSkeleton)p_78087_7_;
- if (abstractskeleton.func_184725_db() && (itemstack.func_190926_b() || itemstack.func_77973_b() != Items.field_151031_f)) {
+ if (abstractskeleton.func_184725_db() && (itemstack.func_190926_b() || !(itemstack.func_77973_b() instanceof net.minecraft.item.ItemBow))) {
float f = MathHelper.func_76126_a(this.field_78095_p * (float)Math.PI);
float f1 = MathHelper.func_76126_a((1.0F - (1.0F - this.field_78095_p) * (1.0F - this.field_78095_p)) * (float)Math.PI);
this.field_178723_h.field_78808_h = 0.0F;

View file

@ -0,0 +1,11 @@
--- a/net/minecraft/entity/ai/EntityAIAttackRangedBow.java
+++ b/net/minecraft/entity/ai/EntityAIAttackRangedBow.java
@@ -35,7 +35,7 @@
}
protected boolean func_188498_f() {
- return !this.field_188499_a.func_184614_ca().func_190926_b() && this.field_188499_a.func_184614_ca().func_77973_b() == Items.field_151031_f;
+ return !this.field_188499_a.func_184614_ca().func_190926_b() && this.field_188499_a.func_184614_ca().func_77973_b() instanceof net.minecraft.item.ItemBow;
}
public boolean func_75253_b() {

View file

@ -0,0 +1,20 @@
--- a/net/minecraft/entity/monster/AbstractSkeleton.java
+++ b/net/minecraft/entity/monster/AbstractSkeleton.java
@@ -161,7 +161,7 @@
this.field_70714_bg.func_85156_a(this.field_85038_e);
this.field_70714_bg.func_85156_a(this.field_85037_d);
ItemStack itemstack = this.func_184614_ca();
- if (itemstack.func_77973_b() == Items.field_151031_f) {
+ if (itemstack.func_77973_b() instanceof net.minecraft.item.ItemBow) {
int i = 20;
if (this.field_70170_p.func_175659_aa() != EnumDifficulty.HARD) {
i = 40;
@@ -178,6 +178,8 @@
public void func_82196_d(EntityLivingBase p_82196_1_, float p_82196_2_) {
EntityArrow entityarrow = this.func_190726_a(p_82196_2_);
+ if (this.func_184614_ca().func_77973_b() instanceof net.minecraft.item.ItemBow)
+ entityarrow = ((net.minecraft.item.ItemBow) this.func_184614_ca().func_77973_b()).customizeArrow(entityarrow);
double d0 = p_82196_1_.field_70165_t - this.field_70165_t;
double d1 = p_82196_1_.func_174813_aQ().field_72338_b + (double)(p_82196_1_.field_70131_O / 3.0F) - entityarrow.field_70163_u;
double d2 = p_82196_1_.field_70161_v - this.field_70161_v;

View file

@ -0,0 +1,11 @@
--- a/net/minecraft/entity/monster/EntityIllusionIllager.java
+++ b/net/minecraft/entity/monster/EntityIllusionIllager.java
@@ -181,6 +181,8 @@
public void func_82196_d(EntityLivingBase p_82196_1_, float p_82196_2_) {
EntityArrow entityarrow = this.func_193097_t(p_82196_2_);
+ if (this.func_184614_ca().func_77973_b() instanceof net.minecraft.item.ItemBow)
+ entityarrow = ((net.minecraft.item.ItemBow) this.func_184614_ca().func_77973_b()).customizeArrow(entityarrow);
double d0 = p_82196_1_.field_70165_t - this.field_70165_t;
double d1 = p_82196_1_.func_174813_aQ().field_72338_b + (double)(p_82196_1_.field_70131_O / 3.0F) - entityarrow.field_70163_u;
double d2 = p_82196_1_.field_70161_v - this.field_70161_v;

View file

@ -1,6 +1,15 @@
--- a/net/minecraft/item/ItemBow.java
+++ b/net/minecraft/item/ItemBow.java
@@ -56,15 +56,19 @@
@@ -22,7 +22,7 @@
if (p_210310_2_ == null) {
return 0.0F;
} else {
- return p_210310_2_.func_184607_cu().func_77973_b() != Items.field_151031_f ? 0.0F : (float)(p_210310_0_.func_77988_m() - p_210310_2_.func_184605_cv()) / 20.0F;
+ return !(p_210310_2_.func_184607_cu().func_77973_b() instanceof ItemBow) ? 0.0F : (float)(p_210310_0_.func_77988_m() - p_210310_2_.func_184605_cv()) / 20.0F;
}
});
this.func_185043_a(new ResourceLocation("pulling"), (p_210309_0_, p_210309_1_, p_210309_2_) -> {
@@ -56,18 +56,23 @@
EntityPlayer entityplayer = (EntityPlayer)p_77615_3_;
boolean flag = entityplayer.field_71075_bZ.field_75098_d || EnchantmentHelper.func_77506_a(Enchantments.field_185312_x, p_77615_1_) > 0;
ItemStack itemstack = this.func_185060_a(entityplayer);
@ -22,7 +31,11 @@
if (!p_77615_2_.field_72995_K) {
ItemArrow itemarrow = (ItemArrow)(itemstack.func_77973_b() instanceof ItemArrow ? itemstack.func_77973_b() : Items.field_151032_g);
EntityArrow entityarrow = itemarrow.func_200887_a(p_77615_2_, itemstack, entityplayer);
@@ -130,6 +134,10 @@
+ entityarrow = this.customizeArrow(entityarrow);
entityarrow.func_184547_a(entityplayer, entityplayer.field_70125_A, entityplayer.field_70177_z, 0.0F, f * 3.0F, 1.0F);
if (f == 1.0F) {
entityarrow.func_70243_d(true);
@@ -130,6 +135,10 @@
public ActionResult<ItemStack> func_77659_a(World p_77659_1_, EntityPlayer p_77659_2_, EnumHand p_77659_3_) {
ItemStack itemstack = p_77659_2_.func_184586_b(p_77659_3_);
boolean flag = !this.func_185060_a(p_77659_2_).func_190926_b();
@ -33,3 +46,12 @@
if (!p_77659_2_.field_71075_bZ.field_75098_d && !flag) {
return flag ? new ActionResult<>(EnumActionResult.PASS, itemstack) : new ActionResult<>(EnumActionResult.FAIL, itemstack);
} else {
@@ -141,4 +150,8 @@
public int func_77619_b() {
return 1;
}
+
+ public EntityArrow customizeArrow(EntityArrow arrow) {
+ return arrow;
+ }
}

View file

@ -18,6 +18,8 @@ public net.minecraft.block.BlockFire func_176534_d(Lnet/minecraft/block/Block;)I
public net.minecraft.item.Item func_77656_e(I)Lnet.minecraft.item.Item; #setMaxDamage
public net.minecraft.item.Item func_77627_a(Z)Lnet.minecraft.item.Item; #setHasSubtypes
public net.minecraft.item.Item field_185051_m # properties
# ItemBow
protected net.minecraft.item.ItemBow func_185060_a(Lnet/minecraft/entity/player/EntityPlayer;)Lnet/minecraft/item/ItemStack; # findAmmo
# Fluid
public net.minecraft.fluid.Fluid func_180664_k()Lnet/minecraft/util/BlockRenderLayer; # getRenderLayer
# Entity