use of pl.asie.charset.lib.render.model.SimpleMultiLayerBakedModel in project Charset by CharsetMC.
the class ProxyClient method bakeModels.
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void bakeModels(ModelBakeEvent event) {
if (prismModel != null) {
for (Orientation o : Orientation.values()) {
ModelResourceLocation location = new ModelResourceLocation("charset:laser_prism", "orientation=" + o.name().toLowerCase());
IBakedModel model = prismModel.bake(o.toTransformation(), DefaultVertexFormats.BLOCK, ModelLoader.defaultTextureGetter());
event.getModelRegistry().putObject(location, model);
}
}
// Patch jars to glow
for (EnumFacing facing : EnumFacing.VALUES) {
for (LaserColor color : LaserColor.VALUES) {
if (color == LaserColor.NONE)
continue;
IBlockState state = CharsetLaser.blockJar.getDefaultState().withProperty(CharsetLaser.LASER_COLOR, color).withProperty(Properties.FACING, facing);
ModelResourceLocation location = new ModelResourceLocation("charset:light_jar", "color=" + color.getName() + ",facing=" + facing.getName());
IBakedModel model = event.getModelRegistry().getObject(location);
VertexFormat format = new VertexFormat(DefaultVertexFormats.ITEM);
format.addElement(DefaultVertexFormats.TEX_2S);
if (model != null) {
SimpleMultiLayerBakedModel result = new SimpleMultiLayerBakedModel(model);
BlockRenderLayer layerPre = MinecraftForgeClient.getRenderLayer();
for (BlockRenderLayer layer : BlockRenderLayer.values()) {
if (CharsetLaser.blockJar.canRenderInLayer(CharsetLaser.blockJar.getDefaultState(), layer)) {
ForgeHooksClient.setRenderLayer(layer);
for (int i = 0; i <= 6; i++) {
EnumFacing facingIn = (i < 6) ? EnumFacing.getFront(i) : null;
for (BakedQuad quadIn : model.getQuads(state, facingIn, 0)) {
result.addQuad(layer, facingIn, ModelTransformer.transform(quadIn, (quad, element, data) -> {
if (quad.getTintIndex() == 1 && element == DefaultVertexFormats.TEX_2S) {
return new float[] { 15f * 0x20 / 0xFFFF, 0, 0, 0 };
}
return data;
}, (bakedQuad -> {
if (bakedQuad.getTintIndex() == 1) {
return format;
} else {
return bakedQuad.getFormat();
}
})));
}
}
}
}
ForgeHooksClient.setRenderLayer(layerPre);
event.getModelRegistry().putObject(location, result);
}
}
}
}
use of pl.asie.charset.lib.render.model.SimpleMultiLayerBakedModel in project Charset by CharsetMC.
the class CharsetStorageTanks method bakeModels.
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void bakeModels(ModelBakeEvent event) {
for (int i = 0; i < 12; i++) {
IBlockState state = tankBlock.getDefaultState().withProperty(BlockTank.VARIANT, i);
ModelResourceLocation location = new ModelResourceLocation("charset:fluidtank", "connections=" + i);
IBakedModel model = event.getModelRegistry().getObject(location);
if (model != null) {
SimpleMultiLayerBakedModel result = new SimpleMultiLayerBakedModel(model);
BlockRenderLayer targetLayer = (i >= 4 && i < 8) ? BlockRenderLayer.TRANSLUCENT : BlockRenderLayer.CUTOUT;
for (int j = 0; j <= 6; j++) {
EnumFacing facingIn = (j < 6) ? EnumFacing.getFront(j) : null;
for (BakedQuad quadIn : model.getQuads(state, facingIn, 0)) {
result.addQuad(targetLayer, facingIn, quadIn);
}
}
event.getModelRegistry().putObject(location, result);
}
}
}
Aggregations