Search in sources :

Example 1 with BlockTypes_MetalsAll

use of blusunrize.immersiveengineering.common.blocks.BlockTypes_MetalsAll in project ImmersiveEngineering by BluSunrize.

the class ConveyorChute method modifyQuads.

@Override
@SideOnly(Side.CLIENT)
public List<BakedQuad> modifyQuads(List<BakedQuad> baseModel, @Nullable TileEntity tile, EnumFacing facing) {
    if (!initTextures) {
        for (BlockTypes_MetalsAll metal : BlockTypes_MetalsAll.values()) TEXTURE_GETTERS[metal.getMeta()] = rl -> Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite("immersiveengineering:blocks/sheetmetal_" + metal.getName());
        initTextures = true;
    }
    if (this.sheetmetalType < 0 || this.sheetmetalType >= TEXTURE_GETTERS.length)
        return baseModel;
    Function<ResourceLocation, TextureAtlasSprite> textureGetter = TEXTURE_GETTERS[this.sheetmetalType];
    if (chuteModel[this.sheetmetalType] == null)
        try {
            IModel iModel = ModelLoaderRegistry.getModel(new ResourceLocation("immersiveengineering:block/metal_device/chute.obj"));
            chuteModel[this.sheetmetalType] = new IBakedModel[] { iModel.bake(new OBJState(ImmutableList.of("base"), true, ModelRotation.X0_Y180), DefaultVertexFormats.ITEM, textureGetter), iModel.bake(new OBJState(ImmutableList.of("base"), true, ModelRotation.X0_Y0), DefaultVertexFormats.ITEM, textureGetter), iModel.bake(new OBJState(ImmutableList.of("base"), true, ModelRotation.X0_Y90), DefaultVertexFormats.ITEM, textureGetter), iModel.bake(new OBJState(ImmutableList.of("base"), true, ModelRotation.X0_Y270), DefaultVertexFormats.ITEM, textureGetter) };
        } catch (Exception ignored) {
        }
    float[] colour = { 1, 1, 1, 1 };
    Matrix4 matrix = new Matrix4(facing);
    baseModel.clear();
    if (diagonal) {
        IBlockState bs = tile != null && tile.getWorld() != null ? tile.getWorld().getBlockState(tile.getPos()) : IEContent.blockConveyor.getDefaultState();
        if (chuteModel[this.sheetmetalType] != null && facing.ordinal() >= 2)
            baseModel.addAll(chuteModel[this.sheetmetalType][facing.ordinal() - 2].getQuads(bs, null, 0));
    } else {
        Function<EnumFacing, TextureAtlasSprite> getSprite = f -> textureGetter.apply(null);
        baseModel.addAll(ClientUtils.createBakedBox(new Vector3f(0, 0, 0), new Vector3f(.0625f, 1, .0625f), matrix, facing, getSprite, colour));
        baseModel.addAll(ClientUtils.createBakedBox(new Vector3f(0, 0, .9375f), new Vector3f(.0625f, 1, 1), matrix, facing, getSprite, colour));
        baseModel.addAll(ClientUtils.createBakedBox(new Vector3f(.9375f, 0, 0), new Vector3f(1, 1, .0625f), matrix, facing, getSprite, colour));
        baseModel.addAll(ClientUtils.createBakedBox(new Vector3f(.9375f, 0, .9375f), new Vector3f(1, 1, 1), matrix, facing, getSprite, colour));
        if (renderWall(tile, EnumFacing.NORTH, facing))
            baseModel.addAll(ClientUtils.createBakedBox(new Vector3f(.0625f, 0, 0), new Vector3f(.9375f, 1, .0625f), matrix, facing, getSprite, colour));
        if (renderWall(tile, EnumFacing.SOUTH, facing))
            baseModel.addAll(ClientUtils.createBakedBox(new Vector3f(.0625f, 0, .9375f), new Vector3f(.9375f, 1, 1), matrix, facing, getSprite, colour));
        if (renderWall(tile, EnumFacing.WEST, facing))
            baseModel.addAll(ClientUtils.createBakedBox(new Vector3f(0, 0, .0625f), new Vector3f(.0625f, 1, .9375f), matrix, facing, getSprite, colour));
        if (renderWall(tile, EnumFacing.EAST, facing))
            baseModel.addAll(ClientUtils.createBakedBox(new Vector3f(.9375f, 0, .0625f), new Vector3f(1, 1, .9375f), matrix, facing, getSprite, colour));
    }
    return baseModel;
}
Also used : IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) IEContent(blusunrize.immersiveengineering.common.IEContent) AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) EnumHand(net.minecraft.util.EnumHand) Function(java.util.function.Function) ClientUtils(blusunrize.immersiveengineering.client.ClientUtils) ArrayList(java.util.ArrayList) DefaultVertexFormats(net.minecraft.client.renderer.vertex.DefaultVertexFormats) ItemStack(net.minecraft.item.ItemStack) ImmutableList(com.google.common.collect.ImmutableList) Block(net.minecraft.block.Block) Minecraft(net.minecraft.client.Minecraft) Side(net.minecraftforge.fml.relauncher.Side) IConveyorTile(blusunrize.immersiveengineering.api.tool.ConveyorHandler.IConveyorTile) BlockTypes_MetalsAll(blusunrize.immersiveengineering.common.blocks.BlockTypes_MetalsAll) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) SoundCategory(net.minecraft.util.SoundCategory) ConveyorHandler(blusunrize.immersiveengineering.api.tool.ConveyorHandler) Nullable(javax.annotation.Nullable) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) EntityItem(net.minecraft.entity.item.EntityItem) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) Entity(net.minecraft.entity.Entity) IESounds(blusunrize.immersiveengineering.common.util.IESounds) Utils(blusunrize.immersiveengineering.common.util.Utils) OBJState(net.minecraftforge.client.model.obj.OBJModel.OBJState) ModelLoaderRegistry(net.minecraftforge.client.model.ModelLoaderRegistry) EnumFacing(net.minecraft.util.EnumFacing) BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) IModel(net.minecraftforge.client.model.IModel) IBlockState(net.minecraft.block.state.IBlockState) List(java.util.List) Vector3f(org.lwjgl.util.vector.Vector3f) Matrix4(blusunrize.immersiveengineering.common.util.chickenbones.Matrix4) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ResourceLocation(net.minecraft.util.ResourceLocation) TileEntity(net.minecraft.tileentity.TileEntity) ModelRotation(net.minecraft.client.renderer.block.model.ModelRotation) Collections(java.util.Collections) IModel(net.minecraftforge.client.model.IModel) IBlockState(net.minecraft.block.state.IBlockState) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) EnumFacing(net.minecraft.util.EnumFacing) BlockTypes_MetalsAll(blusunrize.immersiveengineering.common.blocks.BlockTypes_MetalsAll) Matrix4(blusunrize.immersiveengineering.common.util.chickenbones.Matrix4) ResourceLocation(net.minecraft.util.ResourceLocation) Vector3f(org.lwjgl.util.vector.Vector3f) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) OBJState(net.minecraftforge.client.model.obj.OBJModel.OBJState) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Aggregations

ConveyorHandler (blusunrize.immersiveengineering.api.tool.ConveyorHandler)1 IConveyorTile (blusunrize.immersiveengineering.api.tool.ConveyorHandler.IConveyorTile)1 ClientUtils (blusunrize.immersiveengineering.client.ClientUtils)1 IEContent (blusunrize.immersiveengineering.common.IEContent)1 BlockTypes_MetalsAll (blusunrize.immersiveengineering.common.blocks.BlockTypes_MetalsAll)1 IESounds (blusunrize.immersiveengineering.common.util.IESounds)1 Utils (blusunrize.immersiveengineering.common.util.Utils)1 Matrix4 (blusunrize.immersiveengineering.common.util.chickenbones.Matrix4)1 ImmutableList (com.google.common.collect.ImmutableList)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 List (java.util.List)1 Function (java.util.function.Function)1 Nullable (javax.annotation.Nullable)1 Block (net.minecraft.block.Block)1 IBlockState (net.minecraft.block.state.IBlockState)1 Minecraft (net.minecraft.client.Minecraft)1 BakedQuad (net.minecraft.client.renderer.block.model.BakedQuad)1 IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)1 ModelRotation (net.minecraft.client.renderer.block.model.ModelRotation)1