Skip to content

Commit

Permalink
fix multipart not rendering - patch from HalogenMods/Chlorine
Browse files Browse the repository at this point in the history
  • Loading branch information
yatsukiko authored and yatsukiko committed Feb 13, 2021
1 parent 7fe8bb3 commit d86ae7c
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import me.jellysquid.mods.sodium.client.gl.sampler.GlSampler;
import me.jellysquid.mods.sodium.client.render.chunk.shader.ChunkProgram;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.AtlasTexture;
import net.minecraft.inventory.container.PlayerContainer;
import net.minecraft.client.renderer.texture.Texture;
import net.minecraft.client.renderer.texture.TextureManager;
import org.lwjgl.opengl.GL11;
Expand Down Expand Up @@ -43,7 +43,7 @@ public void bind() {
LightmapTextureManagerAccessor lightmapTextureManager =
((LightmapTextureManagerAccessor) client.gameRenderer.getLightTexture());

Texture blockAtlasTex = textureManager.getTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE);
Texture blockAtlasTex = textureManager.getTexture(PlayerContainer.LOCATION_BLOCKS_TEXTURE);
Texture lightTex = lightmapTextureManager.getTexture();

this.bindTexture(blockAtlasTex, ChunkProgramTextureUnit.BLOCK_ATLAS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import me.jellysquid.mods.sodium.client.render.chunk.shader.ChunkProgram;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.AtlasTexture;
import net.minecraft.inventory.container.PlayerContainer;
import org.lwjgl.opengl.GL20;

public class ChunkProgramSingleTexture extends ChunkProgramTextureComponent {
Expand Down Expand Up @@ -33,7 +33,7 @@ public void delete() {
@Override
public void setMipmapping(boolean mipped) {
Minecraft.getInstance().getTextureManager()
.getTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE)
.getTexture(PlayerContainer.LOCATION_BLOCKS_TEXTURE)
.setBlurMipmapDirect(false, mipped);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public ChunkBuildResult<T> performBuild(ChunkRenderContext pipeline, ChunkBuildB
}
}

if (block.isTileEntityProvider()) {
if (blockState.hasTileEntity()) {
TileEntity entity = this.slice.getBlockEntity(pos, Chunk.CreateEntityType.CHECK);

if (entity != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.IBlockDisplayReader;
import net.minecraftforge.client.model.data.IModelData;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.injection.At;
Expand All @@ -33,8 +34,8 @@
public class MixinBlockModelRenderer {
private final XoRoShiRoRandom random = new XoRoShiRoRandom();

@Inject(method = "renderModel(Lnet/minecraft/world/IBlockDisplayReader;Lnet/minecraft/client/renderer/model/IBakedModel;Lnet/minecraft/block/BlockState;Lnet/minecraft/util/math/BlockPos;Lcom/mojang/blaze3d/matrix/MatrixStack;Lcom/mojang/blaze3d/vertex/IVertexBuilder;ZLjava/util/Random;JI)Z", at = @At("HEAD"), cancellable = true)
private void preRenderBlockInWorld(IBlockDisplayReader world, IBakedModel model, BlockState state, BlockPos pos, MatrixStack matrixStack, IVertexBuilder consumer, boolean cull, Random rand, long seed, int int_1, CallbackInfoReturnable<Boolean> cir) {
@Inject(method = "renderModel(Lnet/minecraft/world/IBlockDisplayReader;Lnet/minecraft/client/renderer/model/IBakedModel;Lnet/minecraft/block/BlockState;Lnet/minecraft/util/math/BlockPos;Lcom/mojang/blaze3d/matrix/MatrixStack;Lcom/mojang/blaze3d/vertex/IVertexBuilder;ZLjava/util/Random;JILnet/minecraftforge/client/model/data/IModelData;)Z", at = @At("HEAD"), cancellable = true, remap = false)
private void preRenderBlockInWorld(IBlockDisplayReader world, IBakedModel model, BlockState state, BlockPos pos, MatrixStack matrixStack, IVertexBuilder consumer, boolean cull, Random rand, long seed, int int_1, IModelData modelData, CallbackInfoReturnable<Boolean> cir) {
GlobalRenderContext renderer = GlobalRenderContext.getInstance(world);
BlockRenderer blockRenderer = renderer.getBlockRenderer();

Expand All @@ -47,9 +48,8 @@ private void preRenderBlockInWorld(IBlockDisplayReader world, IBakedModel model,
* @reason Use optimized vertex writer intrinsics, avoid allocations
* @author JellySquid
*/
@Deprecated
@Overwrite
public void renderModelBrightnessColor(MatrixStack.Entry entry, IVertexBuilder vertexConsumer, BlockState blockState, IBakedModel bakedModel, float red, float green, float blue, int light, int overlay) {
@Overwrite(remap = false)
public void renderModel(MatrixStack.Entry entry, IVertexBuilder vertexConsumer, BlockState blockState, IBakedModel bakedModel, float red, float green, float blue, int light, int overlay, IModelData modelData) {
XoRoShiRoRandom random = this.random;
QuadVertexConsumer quadConsumer = (QuadVertexConsumer) vertexConsumer;

Expand All @@ -61,14 +61,14 @@ public void renderModelBrightnessColor(MatrixStack.Entry entry, IVertexBuilder v
int defaultColor = ColorABGR.pack(red, green, blue, 1.0F);

for (Direction direction : DirectionUtil.ALL_DIRECTIONS) {
List<BakedQuad> quads = bakedModel.getQuads(blockState, direction, random.setSeedAndReturn(42L));
List<BakedQuad> quads = bakedModel.getQuads(blockState, direction, random.setSeedAndReturn(42L), modelData);

if (!quads.isEmpty()) {
renderQuad(entry, quadConsumer, defaultColor, quads, light, overlay);
}
}

List<BakedQuad> quads = bakedModel.getQuads(blockState, null, random.setSeedAndReturn(42L));
List<BakedQuad> quads = bakedModel.getQuads(blockState, null, random.setSeedAndReturn(42L), modelData);

if (!quads.isEmpty()) {
renderQuad(entry, quadConsumer, defaultColor, quads, light, overlay);
Expand All @@ -93,4 +93,4 @@ private static void renderQuad(MatrixStack.Entry entry, QuadVertexConsumer verti
SpriteUtil.markSpriteActive(quad.getSprite());
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public List<BakedQuad> getQuads(BlockState state, Direction face, Random random,
for (IBakedModel model : models) {
random.setSeed(seed);

list.addAll(model.getQuads(state, face, random));
list.addAll(model.getQuads(state, face, random, modelData));
}

return list;
Expand Down

0 comments on commit d86ae7c

Please sign in to comment.