Fix ItemStack#isDamageable is not calling Item#isDamagable (#7221)

This commit is contained in:
mcenderdragon 2020-08-21 20:06:38 +02:00 committed by GitHub
parent 50197b1fa5
commit aaa1deeef2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 50 additions and 10 deletions

View File

@ -53,7 +53,7 @@
public boolean func_77616_k(ItemStack p_77616_1_) {
- return this.func_77639_j() == 1 && this.func_77645_m();
+ return this.getItemStackLimit(p_77616_1_) == 1 && this.func_77645_m();
+ return this.getItemStackLimit(p_77616_1_) == 1 && this.isDamageable(p_77616_1_);
}
protected static BlockRayTraceResult func_219968_a(World p_219968_0_, PlayerEntity p_219968_1_, RayTraceContext.FluidMode p_219968_2_) {
@ -93,7 +93,7 @@
+
+ @Override
+ public boolean isRepairable(ItemStack stack) {
+ return canRepair && func_77645_m();
+ return canRepair && isDamageable(stack);
+ }
+
+ @Override

View File

@ -19,7 +19,7 @@
private static final Logger field_199558_c = LogManager.getLogger();
public static final ItemStack field_190927_a = new ItemStack((Item)null);
public static final DecimalFormat field_111284_a = Util.func_200696_a(new DecimalFormat("#.##"), (p_234699_0_) -> {
@@ -109,7 +112,10 @@
@@ -109,14 +112,18 @@
p_i231596_3_.ifPresent(this::func_77982_d);
}
@ -30,8 +30,9 @@
+ this.capNBT = capNBT;
this.field_151002_e = p_i48204_1_ == null ? null : p_i48204_1_.func_199767_j();
this.field_77994_a = p_i48204_2_;
if (this.field_151002_e != null && this.field_151002_e.func_77645_m()) {
@@ -117,6 +123,7 @@
- if (this.field_151002_e != null && this.field_151002_e.func_77645_m()) {
+ if (this.field_151002_e != null && this.field_151002_e.isDamageable(this)) {
this.func_196085_b(this.func_77952_i());
}
this.func_190923_F();
@ -48,7 +49,13 @@
this.field_151002_e = Registry.field_212630_s.func_82594_a(new ResourceLocation(p_i47263_1_.func_74779_i("id")));
this.field_77994_a = p_i47263_1_.func_74771_c("Count");
if (p_i47263_1_.func_150297_b("tag", 10)) {
@@ -137,6 +146,7 @@
@@ -132,11 +141,12 @@
this.func_77973_b().func_179215_a(p_i47263_1_);
}
- if (this.func_77973_b().func_77645_m()) {
+ if (this.func_77973_b().isDamageable(this)) {
this.func_196085_b(this.func_77952_i());
}
this.func_190923_F();
@ -118,7 +125,7 @@
public boolean func_77984_f() {
- if (!this.field_190928_g && this.func_77973_b().func_77612_l() > 0) {
+ if (!this.field_190928_g && this.func_77973_b().getMaxDamage(this) > 0) {
+ if (!this.field_190928_g && this.func_77973_b().isDamageable(this)) {
CompoundNBT compoundnbt = this.func_77978_p();
return compoundnbt == null || !compoundnbt.func_74767_n("Unbreakable");
} else {
@ -190,6 +197,15 @@
}
}
@@ -479,7 +502,7 @@
public void func_77982_d(@Nullable CompoundNBT p_77982_1_) {
this.field_77990_d = p_77982_1_;
- if (this.func_77973_b().func_77645_m()) {
+ if (this.func_77973_b().isDamageable(this)) {
this.func_196085_b(this.func_77952_i());
}
@@ -673,6 +696,7 @@
}
}

View File

@ -0,0 +1,11 @@
--- a/net/minecraft/item/MerchantOffer.java
+++ b/net/minecraft/item/MerchantOffer.java
@@ -178,7 +178,7 @@
return true;
} else {
ItemStack itemstack = p_222201_1_.func_77946_l();
- if (itemstack.func_77973_b().func_77645_m()) {
+ if (itemstack.func_77973_b().isDamageable(itemstack)) {
itemstack.func_196085_b(itemstack.func_77952_i());
}

View File

@ -20,7 +20,7 @@
this.field_199807_b = p_i49381_1_.toArray((p_209360_0_) -> {
return new Ingredient.IItemList[p_209360_0_];
});
+ this.isSimple = !net.minecraftforge.fml.ModLoader.isDataGenRunning() && !Arrays.stream(field_199807_b).anyMatch(list -> list.func_199799_a().stream().anyMatch(stack -> stack.func_77973_b().func_77645_m()));
+ this.isSimple = !net.minecraftforge.fml.ModLoader.isDataGenRunning() && !Arrays.stream(field_199807_b).anyMatch(list -> list.func_199799_a().stream().anyMatch(stack -> stack.func_77973_b().isDamageable(stack)));
+ Ingredient.INSTANCES.add(this);
}

View File

@ -25,11 +25,13 @@
if (p_150788_1_.func_190926_b()) {
this.writeBoolean(false);
} else {
@@ -301,7 +310,7 @@
@@ -300,7 +309,7 @@
this.func_150787_b(Item.func_150891_b(item));
this.writeByte(p_150788_1_.func_190916_E());
CompoundNBT compoundnbt = null;
if (item.func_77645_m() || item.func_77651_p()) {
- if (item.func_77645_m() || item.func_77651_p()) {
- compoundnbt = p_150788_1_.func_77978_p();
+ if (item.isDamageable(p_150788_1_) || item.func_77651_p()) {
+ compoundnbt = limitedTag ? p_150788_1_.getShareTag() : p_150788_1_.func_77978_p();
}

View File

@ -848,4 +848,15 @@ public interface IForgeItem
{
return false;
}
/**
* Used to test if this item can be damaged, but with the ItemStack in question.
* Please note that in some cases no ItemStack is available, so the stack-less method will be used.
*
* @param stack ItemStack in the Chest slot of the entity.
*/
default boolean isDamageable(ItemStack stack)
{
return this.getItem().isDamageable();
}
}