2023-04-23 14:01:31 +02:00
|
|
|
package team.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 team.chisel.ctmlib.RenderBlocksCTM;
|
|
|
|
|
import team.chisel.ctmlib.TextureSubmap;
|
|
|
|
|
|
2023-04-24 19:16:33 +02:00
|
|
|
public class SubmapManagerSpecialMaterial extends SubmapManagerBase {
|
|
|
|
|
|
|
|
|
|
public enum MaterialType {
|
|
|
|
|
NEONITE,
|
|
|
|
|
GLOTEK
|
|
|
|
|
}
|
2023-04-23 14:01:31 +02:00
|
|
|
|
|
|
|
|
private static class RenderBlocksCTMFullbright extends RenderBlocksCTM {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void fillLightmap(int bottomLeft, int bottomRight, int topRight, int topLeft) {
|
2023-04-24 19:16:33 +02:00
|
|
|
enableAmbientOcclusionIfInWorld();
|
2023-04-23 14:01:31 +02:00
|
|
|
int maxLight = 0xF000F0;
|
|
|
|
|
super.fillLightmap(maxLight, maxLight, maxLight, maxLight);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void fillColormap(float bottomLeft, float bottomRight, float topRight, float topLeft, float[][] map) {
|
2023-04-24 19:16:33 +02:00
|
|
|
enableAmbientOcclusionIfInWorld();
|
2023-04-23 14:01:31 +02:00
|
|
|
int color = 0xFFFFFF;
|
|
|
|
|
super.fillColormap(color, color, color, color, map);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean renderStandardBlock(Block block, int x, int y, int z) {
|
|
|
|
|
boolean ret = super.renderStandardBlock(block, x, y, z);
|
|
|
|
|
this.enableAO = false;
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-24 19:16:33 +02:00
|
|
|
private void enableAmbientOcclusionIfInWorld() {
|
2023-04-23 14:01:31 +02:00
|
|
|
if (this.inWorld) {
|
|
|
|
|
this.enableAO = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2023-04-24 19:16:33 +02:00
|
|
|
private static RenderBlocksCTMFullbright renderBlocksFullbright;
|
2023-04-23 14:01:31 +02:00
|
|
|
|
|
|
|
|
private String color;
|
2023-04-24 19:16:33 +02:00
|
|
|
private MaterialType materialType;
|
2023-04-23 14:01:31 +02:00
|
|
|
private TextureSubmap submap, submapSmall;
|
|
|
|
|
|
2023-04-24 19:16:33 +02:00
|
|
|
public SubmapManagerSpecialMaterial(String color, MaterialType materialType) {
|
2023-04-23 14:01:31 +02:00
|
|
|
this.color = color;
|
2023-04-24 19:16:33 +02:00
|
|
|
this.materialType = materialType;
|
2023-04-23 14:01:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public IIcon getIcon(int side, int meta) {
|
|
|
|
|
return submapSmall.getBaseIcon();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void registerIcons(String modName, Block block, IIconRegister register) {
|
2023-04-24 19:16:33 +02:00
|
|
|
String materialName = materialType.name().toLowerCase();
|
|
|
|
|
submap = new TextureSubmap(register.registerIcon(modName + ":" + materialName + "/" + color + "-ctm"), 4, 4);
|
|
|
|
|
submapSmall = new TextureSubmap(register.registerIcon(modName + ":" + materialName + "/" + color), 2, 2);
|
2023-04-23 14:01:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public RenderBlocks createRenderContext(RenderBlocks rendererOld, Block block, IBlockAccess world) {
|
2023-04-24 19:16:33 +02:00
|
|
|
if (renderBlocksFullbright == null) {
|
|
|
|
|
renderBlocksFullbright = new RenderBlocksCTMFullbright();
|
2023-04-23 14:01:31 +02:00
|
|
|
}
|
2023-04-24 19:16:33 +02:00
|
|
|
renderBlocksFullbright.setRenderBoundsFromBlock(block);
|
|
|
|
|
renderBlocksFullbright.submap = submap;
|
|
|
|
|
renderBlocksFullbright.submapSmall = submapSmall;
|
|
|
|
|
return renderBlocksFullbright;
|
2023-04-23 14:01:31 +02:00
|
|
|
}
|
|
|
|
|
}
|