Add IExtensibleEnum#init, extend FillerBlockType/PlacementBehaviour

This commit is contained in:
tterrag 2019-09-21 15:57:32 -04:00
parent 07bcff5067
commit dee844e232
5 changed files with 73 additions and 0 deletions

View File

@ -0,0 +1,34 @@
--- a/net/minecraft/world/gen/feature/OreFeatureConfig.java
+++ b/net/minecraft/world/gen/feature/OreFeatureConfig.java
@@ -1,5 +1,6 @@
package net.minecraft.world.gen.feature;
+import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.mojang.datafixers.Dynamic;
import com.mojang.datafixers.types.DynamicOps;
@@ -34,7 +35,7 @@
return new OreFeatureConfig(orefeatureconfig$fillerblocktype, blockstate, i);
}
- public static enum FillerBlockType {
+ public static enum FillerBlockType implements net.minecraftforge.common.IExtensibleEnum {
NATURAL_STONE("natural_stone", (p_214739_0_) -> {
if (p_214739_0_ == null) {
return false;
@@ -67,5 +68,15 @@
public Predicate<BlockState> func_214738_b() {
return this.field_214743_e;
}
+
+ public static FillerBlockType create(String enumName, String p_i50618_3_, Predicate<BlockState> p_i50618_4_) {
+ throw new IllegalStateException("Enum not extended");
+ }
+
+ @Override
+ @Deprecated
+ public void init() {
+ field_214741_c.put(func_214737_a(), this);
+ }
}
}

View File

@ -0,0 +1,27 @@
--- a/net/minecraft/world/gen/feature/jigsaw/JigsawPattern.java
+++ b/net/minecraft/world/gen/feature/jigsaw/JigsawPattern.java
@@ -72,7 +72,7 @@
return this.field_214953_e.size();
}
- public static enum PlacementBehaviour {
+ public static enum PlacementBehaviour implements net.minecraftforge.common.IExtensibleEnum {
TERRAIN_MATCHING("terrain_matching", ImmutableList.of(new GravityStructureProcessor(Heightmap.Type.WORLD_SURFACE_WG, -1))),
RIGID("rigid", ImmutableList.of());
@@ -98,5 +98,15 @@
public ImmutableList<StructureProcessor> func_214937_b() {
return this.field_214941_e;
}
+
+ public static PlacementBehaviour create(String enumName, String p_i50487_3_, ImmutableList<StructureProcessor> p_i50487_4_) {
+ throw new IllegalStateException("Enum not extended");
+ }
+
+ @Override
+ @Deprecated
+ public void init() {
+ field_214939_c.put(func_214936_a(), this);
+ }
}
}

View File

@ -215,6 +215,9 @@ public class RuntimeEnumExtender implements ILaunchPluginService {
//EnumHelper.cleanEnumCache(ThisType.class)
ins.visitLdcInsn(classType);
ins.invokestatic(UNSAFE_HACKS.getInternalName(), "cleanEnumCache", CLEAN_DESC, false);
//init ret
ins.load(vars, classType);
ins.invokeinterface(MARKER_IFACE.getInternalName(), "init", "()V");
//return ret
ins.load(vars, classType);
ins.areturn(classType);

View File

@ -41,4 +41,10 @@ package net.minecraftforge.common;
*/
public interface IExtensibleEnum
{
/**
* Called by generated factory code to do any post-constructor setup required by
* the enum. Should not be called manually.
*/
@Deprecated
default void init() {}
}

View File

@ -68,6 +68,9 @@ net/minecraft/world/chunk/BlockStateContainer.setBits(IZ)V=|p_186012_1_,forceBit
net/minecraft/world/end/DragonFightManager.<init>(Lnet/minecraft/world/server/ServerWorld;Lnet/minecraft/nbt/CompoundNBT;Lnet/minecraft/world/dimension/EndDimension;)V=|p_i46669_1_,p_i46669_2_,dim
net/minecraft/world/gen/feature/OreFeatureConfig$FillerBlockType.create(Ljava/lang/String;Ljava/lang/String;Ljava/util/function/Predicate;)Lnet/minecraft/world/gen/feature/OreFeatureConfig$FillerBlockType;=|enumName,p_i50618_3_,p_i50618_4_
net/minecraft/world/gen/feature/jigsaw/JigsawPattern$PlacementBehaviour.create(Ljava/lang/String;Ljava/lang/String;Lcom/google/common/collect/ImmutableList;)Lnet/minecraft/world/gen/feature/jigsaw/JigsawPattern$PlacementBehaviour;=|enumName,p_i50487_3_,p_i50487_4_
net/minecraft/entity/EntityType.<init>(Lnet/minecraft/entity/EntityType$IFactory;Lnet/minecraft/entity/EntityClassification;ZZZLcom/mojang/datafixers/types/Type;Lnet/minecraft/entity/EntitySize;Ljava/util/function/Predicate;Ljava/util/function/ToIntFunction;Ljava/util/function/ToIntFunction;Ljava/util/function/BiFunction;)V=|p_i50385_1_,p_i50385_2_,p_i50385_3_,p_i50385_4_,p_i50385_5_,p_i50385_6_,p_i50385_7_,velocityUpdateSupplier,trackingRangeSupplier,updateIntervalSupplier,customClientFactory
net/minecraft/world/spawner/WorldEntitySpawner.getSpawnList(Lnet/minecraft/world/gen/ChunkGenerator;Lnet/minecraft/entity/EntityClassification;Ljava/util/Random;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/world/World;)Z|p_222264_0_,p_222264_1_,p_222264_2_,p_222264_3_,world
net/minecraft/world/spawner/WorldEntitySpawner.getSpawnList(Lnet/minecraft/world/gen/ChunkGenerator;Lnet/minecraft/entity/EntityClassification;Lnet/minecraft/world/biome/Biome$SpawnListEntry;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/world/World;)Z|p_222261_0_,p_222261_1_,p_222261_2_,p_222261_3_,world