Fixed Food not using effect suppliers, to better support delayed initialization and registry replacements. (#6411)
This commit is contained in:
parent
1c02312ae6
commit
977428e42c
1 changed files with 73 additions and 0 deletions
73
patches/minecraft/net/minecraft/item/Food.java.patch
Normal file
73
patches/minecraft/net/minecraft/item/Food.java.patch
Normal file
|
@ -0,0 +1,73 @@
|
|||
--- a/net/minecraft/item/Food.java
|
||||
+++ b/net/minecraft/item/Food.java
|
||||
@@ -11,15 +11,26 @@
|
||||
private final boolean field_221472_c;
|
||||
private final boolean field_221473_d;
|
||||
private final boolean field_221474_e;
|
||||
- private final List<Pair<EffectInstance, Float>> field_221475_f;
|
||||
+ private final List<Pair<java.util.function.Supplier<EffectInstance>, Float>> field_221475_f;
|
||||
+
|
||||
+ private Food(Food.Builder builder) {
|
||||
+ this.field_221470_a = builder.field_221458_a;
|
||||
+ this.field_221471_b = builder.field_221459_b;
|
||||
+ this.field_221472_c = builder.field_221460_c;
|
||||
+ this.field_221473_d = builder.field_221461_d;
|
||||
+ this.field_221474_e = builder.field_221462_e;
|
||||
+ this.field_221475_f = builder.field_221463_f;
|
||||
+ }
|
||||
|
||||
+ // Forge: Use builder method instead
|
||||
+ @Deprecated
|
||||
private Food(int p_i50106_1_, float p_i50106_2_, boolean p_i50106_3_, boolean p_i50106_4_, boolean p_i50106_5_, List<Pair<EffectInstance, Float>> p_i50106_6_) {
|
||||
this.field_221470_a = p_i50106_1_;
|
||||
this.field_221471_b = p_i50106_2_;
|
||||
this.field_221472_c = p_i50106_3_;
|
||||
this.field_221473_d = p_i50106_4_;
|
||||
this.field_221474_e = p_i50106_5_;
|
||||
- this.field_221475_f = p_i50106_6_;
|
||||
+ this.field_221475_f = p_i50106_6_.stream().map(pair -> Pair.<java.util.function.Supplier<EffectInstance>, Float>of(pair::getLeft, pair.getRight())).collect(java.util.stream.Collectors.toList());
|
||||
}
|
||||
|
||||
public int func_221466_a() {
|
||||
@@ -43,7 +54,7 @@
|
||||
}
|
||||
|
||||
public List<Pair<EffectInstance, Float>> func_221464_f() {
|
||||
- return this.field_221475_f;
|
||||
+ return this.field_221475_f.stream().map(pair -> Pair.of(pair.getLeft() != null ? pair.getLeft().get() : null, pair.getRight())).collect(java.util.stream.Collectors.toList());
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
@@ -52,7 +63,7 @@
|
||||
private boolean field_221460_c;
|
||||
private boolean field_221461_d;
|
||||
private boolean field_221462_e;
|
||||
- private final List<Pair<EffectInstance, Float>> field_221463_f = Lists.newArrayList();
|
||||
+ private final List<Pair<java.util.function.Supplier<EffectInstance>, Float>> field_221463_f = Lists.newArrayList();
|
||||
|
||||
public Food.Builder func_221456_a(int p_221456_1_) {
|
||||
this.field_221458_a = p_221456_1_;
|
||||
@@ -78,14 +89,21 @@
|
||||
this.field_221462_e = true;
|
||||
return this;
|
||||
}
|
||||
+
|
||||
+ public Food.Builder effect(java.util.function.Supplier<EffectInstance> effectIn, float probability) {
|
||||
+ this.field_221463_f.add(Pair.of(effectIn, probability));
|
||||
+ return this;
|
||||
+ }
|
||||
|
||||
+ // Forge: Use supplier method instead
|
||||
+ @Deprecated
|
||||
public Food.Builder func_221452_a(EffectInstance p_221452_1_, float p_221452_2_) {
|
||||
- this.field_221463_f.add(Pair.of(p_221452_1_, p_221452_2_));
|
||||
+ this.field_221463_f.add(Pair.of(() -> p_221452_1_, p_221452_2_));
|
||||
return this;
|
||||
}
|
||||
|
||||
public Food func_221453_d() {
|
||||
- return new Food(this.field_221458_a, this.field_221459_b, this.field_221460_c, this.field_221461_d, this.field_221462_e, this.field_221463_f);
|
||||
+ return new Food(this);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue