[1.18.x] Add supplier to FlowerBlock so it works with custom MobEffects (#9140)

* add supplier to FlowerBlock so it works with custom MobEffects

* address comments by @Matyrobbrt

* address comments by @ChampionAsh5357

* fix missing exc entry

* remove null check and rename constructor parameter
This commit is contained in:
Minecraftschurli authored and GitHub committed 2022-12-20 21:48:08 +10:30
1 parent 2c3cb2025e
commit 03b75632d8
2 files changed
+42

No files matched your search

@@ -0,0 +1,41 @@
--- a/net/minecraft/world/level/block/FlowerBlock.java
+++ b/net/minecraft/world/level/block/FlowerBlock.java
@@ -15,6 +_,17 @@
private final MobEffect f_53508_;
private final int f_53509_;
+ private final java.util.function.Supplier<MobEffect> suspiciousStewEffectSupplier;
+
+ public FlowerBlock(java.util.function.Supplier<MobEffect> effectSupplier, int p_53513_, BlockBehaviour.Properties p_53514_) {
+ super(p_53514_);
+ this.f_53508_ = null;
+ this.suspiciousStewEffectSupplier = effectSupplier;
+ this.f_53509_ = p_53513_;
+ }
+
+ /** @deprecated FORGE: Use supplier version instead */
+ @Deprecated
public FlowerBlock(MobEffect p_53512_, int p_53513_, BlockBehaviour.Properties p_53514_) {
super(p_53514_);
this.f_53508_ = p_53512_;
@@ -23,6 +_,7 @@
} else {
this.f_53509_ = p_53513_ * 20;
}
+ this.suspiciousStewEffectSupplier = net.minecraftforge.registries.RegistryObject.create(p_53512_.getRegistryName(), net.minecraftforge.registries.ForgeRegistries.MOB_EFFECTS);
}
@@ -36,10 +_,12 @@
}
public MobEffect m_53521_() {
+ if (true) return this.suspiciousStewEffectSupplier.get();
return this.f_53508_;
}
public int m_53522_() {
+ if (!this.suspiciousStewEffectSupplier.get().m_8093_()) return this.f_53509_ * 20;
return this.f_53509_;
}
}
+1
View File
@@ -59,6 +59,7 @@ net/minecraft/world/item/crafting/RecipeManager.fromJson(Lnet/minecraft/resource
net/minecraft/world/level/Level.markAndNotifyBlock(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/chunk/LevelChunk;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/block/state/BlockState;II)V=|p_46605_,levelchunk,blockstate,p_46606_,p_46607_,p_46608_
net/minecraft/world/level/LevelSettings.<init>(Ljava/lang/String;Lnet/minecraft/world/level/GameType;ZLnet/minecraft/world/Difficulty;ZLnet/minecraft/world/level/GameRules;Lnet/minecraft/world/level/DataPackConfig;Lcom/mojang/serialization/Lifecycle;)V=|p_46910_,p_46911_,p_46912_,p_46913_,p_46914_,p_46915_,p_46916_,lifecycle
net/minecraft/world/level/block/FireBlock.tryCatchFire(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;ILjava/util/Random;ILnet/minecraft/core/Direction;)V=|p_53432_,p_53433_,p_53434_,p_53435_,p_53436_,face
net/minecraft/world/level/block/FlowerBlock.<init>(Ljava/util/function/Supplier;ILnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V=|effectSupplier,p_53513_,p_53514_
net/minecraft/world/level/block/FlowerPotBlock.<init>(Ljava/util/function/Supplier;Ljava/util/function/Supplier;Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V=|emptyPot,p_53528_,properties
net/minecraft/world/level/block/LiquidBlock.<init>(Ljava/util/function/Supplier;Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V=|p_54694_,p_54695_
net/minecraft/world/level/dimension/LevelStem.<init>(Lnet/minecraft/core/Holder;Lnet/minecraft/world/level/chunk/ChunkGenerator;Z)V=|p_204519_,p_204520_,useServerSeed