mirror of
https://github.com/GTNewHorizons/Chisel.git
synced 2026-11-16 10:45:02 +00:00
RenderBlocksCTM will now respect the render bounds (read below)
This behavior allows for certain renderers to no longer be needed (carpet floor) and for some rendering to be possible (CTM slabs). A single version of marble slab has been implemented with CTM as an example, we will move over the rest of the textures once this is finalized.
This commit is contained in:
1 parent
3999d31342
commit
3013e263a2
17 files changed
+258
-105
No files matched your search
@@ -0,0 +1,76 @@
|
||||
package com.cricketcraft.chisel.client.render;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import com.cricketcraft.chisel.api.rendering.ISubmapManager;
|
||||
import com.cricketcraft.chisel.api.rendering.TextureSubmap;
|
||||
|
||||
public class SubmapManagerSlab implements ISubmapManager<RenderBlocksCTM> {
|
||||
|
||||
private static RenderBlocksCTM rb = new RenderBlocksCTM();
|
||||
|
||||
private TextureSubmap submap;
|
||||
private TextureSubmap submapSmall;
|
||||
private IIcon sideTexture;
|
||||
private String texture;
|
||||
|
||||
public SubmapManagerSlab(String texture) {
|
||||
this.texture = texture;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int side, int meta) {
|
||||
return submapSmall.getBaseIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
|
||||
return getIcon(side, world.getBlockMetadata(x, y, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons(String modName, Block block, IIconRegister register) {
|
||||
String path = modName + ":" + texture;
|
||||
submap = new TextureSubmap(register.registerIcon(path + "-ctm"), 4, 4);
|
||||
submapSmall = new TextureSubmap(register.registerIcon(path), 2, 2);
|
||||
sideTexture = register.registerIcon(path + "-side");
|
||||
}
|
||||
|
||||
@Override
|
||||
public RenderBlocksCTM createRenderContext(RenderBlocks rendererOld, IBlockAccess world) {
|
||||
rb.blockAccess = world;
|
||||
rb.renderMaxX = 1.0;
|
||||
rb.renderMaxY = 1f / 2f;
|
||||
rb.renderMaxZ = 1.0;
|
||||
|
||||
rb.submap = submap;
|
||||
rb.submapSmall = submapSmall;
|
||||
|
||||
rb.rendererOld = rendererOld;
|
||||
return rb;
|
||||
}
|
||||
|
||||
private boolean hadOverride = false;
|
||||
|
||||
@Override
|
||||
public void preRenderSide(RenderBlocksCTM renderer, IBlockAccess world, int x, int y, int z, ForgeDirection side) {
|
||||
if (side.ordinal() < 2 && !renderer.rendererOld.hasOverrideBlockTexture()) {
|
||||
renderer.rendererOld.setOverrideBlockTexture(sideTexture);
|
||||
hadOverride = false;
|
||||
} else {
|
||||
hadOverride = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postRenderSide(RenderBlocksCTM renderer, IBlockAccess world, int x, int y, int z, ForgeDirection side) {
|
||||
if (!hadOverride) {
|
||||
renderer.rendererOld.clearOverrideBlockTexture();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user