Skip to content

Commit

Permalink
Add a source comment to fields targeted by the field_to_method.js cor…
Browse files Browse the repository at this point in the history
…emod (neoforged#486)
  • Loading branch information
Technici4n authored Jan 15, 2024
1 parent 42077b9 commit c1bf625
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 3 deletions.
5 changes: 4 additions & 1 deletion patches/net/minecraft/world/item/BucketItem.java.patch
Original file line number Diff line number Diff line change
@@ -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
Expand Down
12 changes: 12 additions & 0 deletions patches/net/minecraft/world/level/biome/Biome.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -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<Long2FloatLinkedOpenHashMap> temperatureCache = ThreadLocal.withInitial(() -> Util.make(() -> {
Long2FloatLinkedOpenHashMap long2floatlinkedopenhashmap = new Long2FloatLinkedOpenHashMap(1024, 0.25F) {
@@ -79,6 +_,7 @@
this.generationSettings = p_220532_;
this.mobSettings = p_220533_;
Expand Down
Original file line number Diff line number Diff line change
@@ -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<Block, Block> 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;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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<FluidState> stateCache;
Expand Down
8 changes: 8 additions & 0 deletions patches/net/minecraft/world/level/block/StairBlock.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
public static final Codec<Structure> DIRECT_CODEC = BuiltInRegistries.STRUCTURE_TYPE.byNameCodec().dispatch(Structure::type, StructureType::codec);
public static final Codec<Holder<Structure>> 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 <S extends Structure> RecordCodecBuilder<S, Structure.StructureSettings> settingsCodec(Instance<S> p_226568_) {
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/coremods/field_to_method.js
Original file line number Diff line number Diff line change
@@ -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': {
Expand Down

0 comments on commit c1bf625

Please sign in to comment.