From c1bf62587a23aa051c2a61c4e4d08b95d4cb4f5b Mon Sep 17 00:00:00 2001 From: Technici4n <13494793+Technici4n@users.noreply.github.com> Date: Mon, 15 Jan 2024 05:24:50 +0100 Subject: [PATCH] Add a source comment to fields targeted by the field_to_method.js coremod (#486) --- .../net/minecraft/world/item/BucketItem.java.patch | 5 ++++- .../net/minecraft/world/level/biome/Biome.java.patch | 12 ++++++++++++ .../world/level/block/FlowerPotBlock.java.patch | 8 ++++++++ .../world/level/block/LiquidBlock.java.patch | 3 ++- .../world/level/block/StairBlock.java.patch | 8 ++++++++ .../level/levelgen/structure/Structure.java.patch | 2 +- src/main/resources/coremods/field_to_method.js | 3 +++ 7 files changed, 38 insertions(+), 3 deletions(-) diff --git a/patches/net/minecraft/world/item/BucketItem.java.patch b/patches/net/minecraft/world/item/BucketItem.java.patch index 48f3854ecd..95ae7ab273 100644 --- a/patches/net/minecraft/world/item/BucketItem.java.patch +++ b/patches/net/minecraft/world/item/BucketItem.java.patch @@ -1,7 +1,10 @@ --- a/net/minecraft/world/item/BucketItem.java +++ b/net/minecraft/world/item/BucketItem.java -@@ -31,9 +_,21 @@ +@@ -29,11 +_,24 @@ + import net.minecraft.world.phys.HitResult; + public class BucketItem extends Item implements DispensibleContainerItem { ++ /** Neo: Field accesses are redirected to {@link #getFluid()} with a coremod. */ private final Fluid content; + // Forge: Use the other constructor that takes a Supplier diff --git a/patches/net/minecraft/world/level/biome/Biome.java.patch b/patches/net/minecraft/world/level/biome/Biome.java.patch index c245703228..8d8591cbdf 100644 --- a/patches/net/minecraft/world/level/biome/Biome.java.patch +++ b/patches/net/minecraft/world/level/biome/Biome.java.patch @@ -11,6 +11,18 @@ BiomeGenerationSettings.CODEC.forGetter(p_220548_ -> p_220548_.generationSettings), MobSpawnSettings.CODEC.forGetter(p_220546_ -> p_220546_.mobSettings) ) +@@ -60,9 +_,11 @@ + ) + public static final PerlinSimplexNoise BIOME_INFO_NOISE = new PerlinSimplexNoise(new WorldgenRandom(new LegacyRandomSource(2345L)), ImmutableList.of(0)); + private static final int TEMPERATURE_CACHE_SIZE = 1024; ++ /** Neo: Field accesses are redirected to {@link #getModifiedClimateSettings()} with a coremod. */ + private final Biome.ClimateSettings climateSettings; + private final BiomeGenerationSettings generationSettings; + private final MobSpawnSettings mobSettings; ++ /** Neo: Field accesses are redirected to {@link #getModifiedSpecialEffects()} with a coremod. */ + private final BiomeSpecialEffects specialEffects; + private final ThreadLocal temperatureCache = ThreadLocal.withInitial(() -> Util.make(() -> { + Long2FloatLinkedOpenHashMap long2floatlinkedopenhashmap = new Long2FloatLinkedOpenHashMap(1024, 0.25F) { @@ -79,6 +_,7 @@ this.generationSettings = p_220532_; this.mobSettings = p_220533_; diff --git a/patches/net/minecraft/world/level/block/FlowerPotBlock.java.patch b/patches/net/minecraft/world/level/block/FlowerPotBlock.java.patch index a720793c96..3d349da803 100644 --- a/patches/net/minecraft/world/level/block/FlowerPotBlock.java.patch +++ b/patches/net/minecraft/world/level/block/FlowerPotBlock.java.patch @@ -1,5 +1,13 @@ --- a/net/minecraft/world/level/block/FlowerPotBlock.java +++ b/net/minecraft/world/level/block/FlowerPotBlock.java +@@ -35,6 +_,7 @@ + private static final Map POTTED_BY_CONTENT = Maps.newHashMap(); + public static final float AABB_SIZE = 3.0F; + protected static final VoxelShape SHAPE = Block.box(5.0, 0.0, 5.0, 11.0, 6.0, 11.0); ++ /** Neo: Field accesses are redirected to {@link #getPotted()} with a coremod. */ + private final Block potted; + + @Override @@ -42,10 +_,31 @@ return CODEC; } diff --git a/patches/net/minecraft/world/level/block/LiquidBlock.java.patch b/patches/net/minecraft/world/level/block/LiquidBlock.java.patch index d8e507022f..97aab8e672 100644 --- a/patches/net/minecraft/world/level/block/LiquidBlock.java.patch +++ b/patches/net/minecraft/world/level/block/LiquidBlock.java.patch @@ -1,10 +1,11 @@ --- a/net/minecraft/world/level/block/LiquidBlock.java +++ b/net/minecraft/world/level/block/LiquidBlock.java -@@ -51,7 +_,8 @@ +@@ -51,7 +_,9 @@ .apply(p_308830_, LiquidBlock::new) ); public static final IntegerProperty LEVEL = BlockStateProperties.LEVEL; - protected final FlowingFluid fluid; ++ /** Neo: Field accesses are redirected to {@link #getFluid()} with a coremod. */ + @Deprecated // Use getFluid + private final FlowingFluid fluid; private final List stateCache; diff --git a/patches/net/minecraft/world/level/block/StairBlock.java.patch b/patches/net/minecraft/world/level/block/StairBlock.java.patch index 3a9e787d1e..f95eedc97a 100644 --- a/patches/net/minecraft/world/level/block/StairBlock.java.patch +++ b/patches/net/minecraft/world/level/block/StairBlock.java.patch @@ -9,6 +9,14 @@ .apply(p_308839_, StairBlock::new) ); public static final DirectionProperty FACING = HorizontalDirectionalBlock.FACING; +@@ -47,6 +_,7 @@ + protected static final VoxelShape[] TOP_SHAPES = makeShapes(TOP_AABB, OCTET_NNN, OCTET_PNN, OCTET_NNP, OCTET_PNP); + protected static final VoxelShape[] BOTTOM_SHAPES = makeShapes(BOTTOM_AABB, OCTET_NPN, OCTET_PPN, OCTET_NPP, OCTET_PPP); + private static final int[] SHAPE_BY_STATE = new int[]{12, 5, 3, 10, 14, 13, 7, 11, 13, 7, 11, 14, 8, 4, 1, 2, 4, 1, 2, 8}; ++ /** Neo: Field accesses are redirected to {@link #getModelBlock()} with a coremod. */ + private final Block base; + protected final BlockState baseState; + @@ -84,7 +_,12 @@ return voxelshape; } diff --git a/patches/net/minecraft/world/level/levelgen/structure/Structure.java.patch b/patches/net/minecraft/world/level/levelgen/structure/Structure.java.patch index b9cec688cf..776216f9e6 100644 --- a/patches/net/minecraft/world/level/levelgen/structure/Structure.java.patch +++ b/patches/net/minecraft/world/level/levelgen/structure/Structure.java.patch @@ -5,7 +5,7 @@ public static final Codec DIRECT_CODEC = BuiltInRegistries.STRUCTURE_TYPE.byNameCodec().dispatch(Structure::type, StructureType::codec); public static final Codec> CODEC = RegistryFileCodec.create(Registries.STRUCTURE, DIRECT_CODEC); - protected final Structure.StructureSettings settings; -+ //Forge: Make this field private so that the redirect coremod can target it ++ /** Neo: Field accesses are redirected to {@link #getModifiedStructureSettings()} with a coremod. */ + private final Structure.StructureSettings settings; public static RecordCodecBuilder settingsCodec(Instance p_226568_) { diff --git a/src/main/resources/coremods/field_to_method.js b/src/main/resources/coremods/field_to_method.js index 0816b69d03..50e3333195 100644 --- a/src/main/resources/coremods/field_to_method.js +++ b/src/main/resources/coremods/field_to_method.js @@ -1,5 +1,8 @@ var ASMAPI = Java.type('net.neoforged.coremod.api.ASMAPI') +// If you add or remove a new field, +// please also add or remove a corresponding comment in the source code, +// in the interest of modders reading it. function initializeCoreMod() { return { 'biome': {