diff --git a/patches/minecraft/net/minecraft/client/renderer/chunk/RenderChunkRegion.java.patch b/patches/minecraft/net/minecraft/client/renderer/chunk/RenderChunkRegion.java.patch index e8b4b230aa..6cfca21ce4 100644 --- a/patches/minecraft/net/minecraft/client/renderer/chunk/RenderChunkRegion.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/chunk/RenderChunkRegion.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/chunk/RenderChunkRegion.java +++ b/net/minecraft/client/renderer/chunk/RenderChunkRegion.java -@@ -66,4 +_,9 @@ +@@ -66,4 +_,14 @@ public int m_141928_() { return this.f_112908_.m_141928_(); } @@ -8,5 +8,10 @@ + @Override + public float getShade(float normalX, float normalY, float normalZ, boolean shade) { + return this.f_112908_.getShade(normalX, normalY, normalZ, shade); ++ } ++ ++ @Override ++ public net.minecraftforge.client.model.data.ModelDataManager getModelDataManager() { ++ return f_112908_.getModelDataManager(); + } } diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeBlock.java b/src/main/java/net/minecraftforge/common/extensions/IForgeBlock.java index 4dab3c4bd2..450f69d17e 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeBlock.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeBlock.java @@ -24,6 +24,7 @@ import net.minecraft.world.entity.projectile.WitherSkull; import net.minecraft.world.item.*; import net.minecraft.world.item.context.UseOnContext; import net.minecraft.world.level.block.*; +import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.state.BlockBehaviour; import net.minecraft.world.level.levelgen.feature.configurations.TreeConfiguration; import net.minecraft.world.level.material.FluidState; @@ -37,6 +38,8 @@ import net.minecraft.world.phys.HitResult; import net.minecraft.world.phys.Vec3; import net.minecraft.server.level.ServerLevel; import net.minecraftforge.client.ForgeHooksClient; +import net.minecraftforge.client.model.data.ModelData; +import net.minecraftforge.client.model.data.ModelDataManager; import net.minecraftforge.common.ForgeHooks; import net.minecraftforge.common.IPlantable; @@ -920,4 +923,32 @@ public interface IForgeBlock { return defaultColor; } + + /** + * Returns the {@link BlockState} that this block reports to look like on the given side, for querying by other mods. + * Note: Overriding this does not change how this block renders. That must still be handled in the block's model. + *

+ * Common implementors would be covers and facades, or any other mimic blocks that proxy another block's model. + * Common consumers would be models with connected textures that wish to seamlessly connect to mimic blocks. + *

+ * Note that this method may be called on the server, or on any of the client's meshing threads.
+ * As such, if you need any data from your {@link BlockEntity}, you should put it in {@link ModelData} to guarantee + * safe concurrent access to it on the client.
+ * Calling {@link BlockGetter#getModelDataManager()} will return {@code null} if in a server context, where it is + * safe to query your {@link BlockEntity} directly. Otherwise, {@link ModelDataManager#getAt(BlockPos)} will return + * the {@link ModelData} for the queried block, or {@code null} if none is present. + * + * @param state The state of this block + * @param level The level this block is in + * @param pos The block's position in the level + * @param side The side of the block that is being queried + * @param queryState The state of the block that is querying the appearance, or {@code null} if not applicable + * @param queryPos The position of the block that is querying the appearance, or {@code null} if not applicable + * @return The appearance of this block on the given side. By default, the current state + * @see IForgeBlockState#getAppearance(BlockAndTintGetter, BlockPos, Direction, BlockState, BlockPos) + */ + default BlockState getAppearance(BlockState state, BlockAndTintGetter level, BlockPos pos, Direction side, @Nullable BlockState queryState, @Nullable BlockPos queryPos) + { + return state; + } } diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeBlockState.java b/src/main/java/net/minecraftforge/common/extensions/IForgeBlockState.java index 9b796c4f50..01b218b2df 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeBlockState.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeBlockState.java @@ -749,4 +749,20 @@ public interface IForgeBlockState { return self().getBlock().canBeHydrated(self(), getter, pos, fluid, fluidPos); } + + /** + * Returns the {@link BlockState} that this state reports to look like on the given side for querying by other mods. + * + * @param level The level this block is in + * @param pos The block's position in the level + * @param side The side of the block that is being queried + * @param queryState The state of the block that is querying the appearance, or {@code null} if not applicable + * @param queryPos The position of the block that is querying the appearance, or {@code null} if not applicable + * @return The appearance of this block from the given side + * @see IForgeBlock#getAppearance(BlockState, BlockAndTintGetter, BlockPos, Direction, BlockState, BlockPos) + */ + default BlockState getAppearance(BlockAndTintGetter level, BlockPos pos, Direction side, @Nullable BlockState queryState, @Nullable BlockPos queryPos) + { + return self().getBlock().getAppearance(self(), level, pos, side, queryState, queryPos); + } }