From dee844e2329a3f85a9b15840dcbecadd2078923e Mon Sep 17 00:00:00 2001 From: tterrag Date: Sat, 21 Sep 2019 15:57:32 -0400 Subject: [PATCH] Add IExtensibleEnum#init, extend FillerBlockType/PlacementBehaviour --- .../gen/feature/OreFeatureConfig.java.patch | 34 +++++++++++++++++++ .../feature/jigsaw/JigsawPattern.java.patch | 27 +++++++++++++++ .../common/asm/RuntimeEnumExtender.java | 3 ++ .../common/IExtensibleEnum.java | 6 ++++ src/main/resources/forge.exc | 3 ++ 5 files changed, 73 insertions(+) create mode 100644 patches/minecraft/net/minecraft/world/gen/feature/OreFeatureConfig.java.patch create mode 100644 patches/minecraft/net/minecraft/world/gen/feature/jigsaw/JigsawPattern.java.patch diff --git a/patches/minecraft/net/minecraft/world/gen/feature/OreFeatureConfig.java.patch b/patches/minecraft/net/minecraft/world/gen/feature/OreFeatureConfig.java.patch new file mode 100644 index 000000000..0a17bcdd9 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/gen/feature/OreFeatureConfig.java.patch @@ -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 func_214738_b() { + return this.field_214743_e; + } ++ ++ public static FillerBlockType create(String enumName, String p_i50618_3_, Predicate p_i50618_4_) { ++ throw new IllegalStateException("Enum not extended"); ++ } ++ ++ @Override ++ @Deprecated ++ public void init() { ++ field_214741_c.put(func_214737_a(), this); ++ } + } + } diff --git a/patches/minecraft/net/minecraft/world/gen/feature/jigsaw/JigsawPattern.java.patch b/patches/minecraft/net/minecraft/world/gen/feature/jigsaw/JigsawPattern.java.patch new file mode 100644 index 000000000..fb7478745 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/gen/feature/jigsaw/JigsawPattern.java.patch @@ -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 func_214937_b() { + return this.field_214941_e; + } ++ ++ public static PlacementBehaviour create(String enumName, String p_i50487_3_, ImmutableList p_i50487_4_) { ++ throw new IllegalStateException("Enum not extended"); ++ } ++ ++ @Override ++ @Deprecated ++ public void init() { ++ field_214939_c.put(func_214936_a(), this); ++ } + } + } diff --git a/src/fmllauncher/java/net/minecraftforge/common/asm/RuntimeEnumExtender.java b/src/fmllauncher/java/net/minecraftforge/common/asm/RuntimeEnumExtender.java index fa4d62cc7..6cf007747 100644 --- a/src/fmllauncher/java/net/minecraftforge/common/asm/RuntimeEnumExtender.java +++ b/src/fmllauncher/java/net/minecraftforge/common/asm/RuntimeEnumExtender.java @@ -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); diff --git a/src/main/java/net/minecraftforge/common/IExtensibleEnum.java b/src/main/java/net/minecraftforge/common/IExtensibleEnum.java index cc7455169..7619756bc 100644 --- a/src/main/java/net/minecraftforge/common/IExtensibleEnum.java +++ b/src/main/java/net/minecraftforge/common/IExtensibleEnum.java @@ -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() {} } diff --git a/src/main/resources/forge.exc b/src/main/resources/forge.exc index faf8e0c9a..d953f5785 100644 --- a/src/main/resources/forge.exc +++ b/src/main/resources/forge.exc @@ -68,6 +68,9 @@ net/minecraft/world/chunk/BlockStateContainer.setBits(IZ)V=|p_186012_1_,forceBit net/minecraft/world/end/DragonFightManager.(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.(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