Search in sources :

Example 1 with BlockMachine

use of gregtech.api.block.machines.BlockMachine in project GregTech by GregTechCE.

the class MetaBlocks method init.

public static void init() {
    MACHINE = new BlockMachine();
    MACHINE.setRegistryName("machine");
    CABLE = new BlockCable(64, 2, 0);
    CABLE.setRegistryName("cable");
    BOILER_CASING = new BlockBoilerCasing();
    BOILER_CASING.setRegistryName("boiler_casing");
    METAL_CASING = new BlockMetalCasing();
    METAL_CASING.setRegistryName("metal_casing");
    TURBINE_CASING = new BlockTurbineCasing();
    TURBINE_CASING.setRegistryName("turbine_casing");
    MACHINE_CASING = new BlockMachineCasing();
    MACHINE_CASING.setRegistryName("machine_casing");
    MUTLIBLOCK_CASING = new BlockMultiblockCasing();
    MUTLIBLOCK_CASING.setRegistryName("multiblock_casing");
    WIRE_COIL = new BlockWireCoil();
    WIRE_COIL.setRegistryName("wire_coil");
    WARNING_SIGN = new BlockWarningSign();
    WARNING_SIGN.setRegistryName("warning_sign");
    GRANITE = new BlockGranite();
    GRANITE.setRegistryName("granite");
    BLACK_GRANITE = new StoneType(12, "black_granite", OrePrefix.oreBlackgranite, Materials.GraniteBlack, "gregtech:blocks/stones/granite/granite_black_stone", () -> GRANITE.withVariant(GraniteVariant.BLACK_GRANITE, ChiselingVariant.NORMAL), state -> state.getBlock() instanceof BlockGranite && ((BlockGranite) state.getBlock()).getVariant(state) == GraniteVariant.BLACK_GRANITE);
    RED_GRANITE = new StoneType(13, "red_granite", OrePrefix.oreRedgranite, Materials.GraniteRed, "gregtech:blocks/stones/granite/granite_red_stone", () -> GRANITE.withVariant(GraniteVariant.RED_GRANITE, ChiselingVariant.NORMAL), state -> state.getBlock() instanceof BlockGranite && ((BlockGranite) state.getBlock()).getVariant(state) == GraniteVariant.RED_GRANITE);
    MINERAL = new BlockMineral();
    MINERAL.setRegistryName("mineral");
    MARBLE = new StoneType(14, "marble", OrePrefix.oreMarble, Materials.Marble, "gregtech:blocks/stones/marble/marble_stone", () -> MINERAL.withVariant(MineralVariant.MARBLE, ChiselingVariant.NORMAL), state -> state.getBlock() instanceof BlockMineral && ((BlockMineral) state.getBlock()).getVariant(state) == BlockMineral.MineralVariant.MARBLE);
    BASALT = new StoneType(15, "basalt", OrePrefix.oreBasalt, Materials.Basalt, "gregtech:blocks/stones/basalt/basalt_stone", () -> MINERAL.withVariant(MineralVariant.BASALT, ChiselingVariant.NORMAL), state -> state.getBlock() instanceof BlockMineral && ((BlockMineral) state.getBlock()).getVariant(state) == BlockMineral.MineralVariant.BASALT);
    CONCRETE = new BlockConcrete();
    CONCRETE.setRegistryName("concrete");
    COMPRESSED = new HashMap<>();
    ORES = new ArrayList<>();
    StoneType.init();
    Material[] materialBuffer = new Material[16];
    Arrays.fill(materialBuffer, Materials._NULL);
    int generationIndex = 0;
    for (Material material : Material.MATERIAL_REGISTRY.getObjectsWithIds()) {
        if (material instanceof DustMaterial) {
            int id = Material.MATERIAL_REGISTRY.getIDForObject(material);
            int index = id / 16;
            if (index > generationIndex) {
                createCompressedBlock(materialBuffer, generationIndex);
                Arrays.fill(materialBuffer, Materials._NULL);
            }
            if (!OrePrefix.block.isIgnored(material)) {
                materialBuffer[id % 16] = material;
                generationIndex = index;
            }
            if (material.hasFlag(DustMaterial.MatFlags.GENERATE_ORE)) {
                createOreBlock((DustMaterial) material);
            }
        }
    }
    createCompressedBlock(materialBuffer, generationIndex);
}
Also used : java.util(java.util) GraniteVariant(gregtech.common.blocks.BlockGranite.GraniteVariant) Item(net.minecraft.item.Item) MetaTileEntities(gregtech.common.metatileentities.MetaTileEntities) MetaTileEntityRenderer(gregtech.api.render.MetaTileEntityRenderer) Materials(gregtech.api.unification.material.Materials) StoneType(gregtech.api.unification.ore.StoneType) Material(gregtech.api.unification.material.type.Material) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) StoneTypes(gregtech.api.unification.ore.StoneTypes) IProperty(net.minecraft.block.properties.IProperty) GregTechAPI(gregtech.api.GregTechAPI) Block(net.minecraft.block.Block) Minecraft(net.minecraft.client.Minecraft) Side(net.minecraftforge.fml.relauncher.Side) ChiselingVariant(gregtech.common.blocks.StoneBlock.ChiselingVariant) OrePrefix(gregtech.api.unification.ore.OrePrefix) ModelLoader(net.minecraftforge.client.model.ModelLoader) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) DefaultStateMapper(net.minecraft.client.renderer.block.statemap.DefaultStateMapper) ClientProxy(gregtech.common.ClientProxy) Streams(com.google.common.collect.Streams) Collectors(java.util.stream.Collectors) IBlockState(net.minecraft.block.state.IBlockState) DustMaterial(gregtech.api.unification.material.type.DustMaterial) MineralVariant(gregtech.common.blocks.BlockMineral.MineralVariant) BlockMachine(gregtech.api.block.machines.BlockMachine) BlockMachine(gregtech.api.block.machines.BlockMachine) StoneType(gregtech.api.unification.ore.StoneType) Material(gregtech.api.unification.material.type.Material) DustMaterial(gregtech.api.unification.material.type.DustMaterial) DustMaterial(gregtech.api.unification.material.type.DustMaterial)

Example 2 with BlockMachine

use of gregtech.api.block.machines.BlockMachine in project GregTech by GregTechCE.

the class MetaTileEntityRenderer method handleRenderBlockDamage.

@Override
public void handleRenderBlockDamage(IBlockAccess world, BlockPos pos, IBlockState state, TextureAtlasSprite sprite, BufferBuilder buffer) {
    BlockMachine blockMachine = ((BlockMachine) state.getBlock());
    Collection<AxisAlignedBB> boxes = blockMachine.getSelectedBoundingBoxes(world, pos, state);
    List<Cuboid6> cuboid6List = boxes.stream().map(aabb -> new Cuboid6(aabb).subtract(pos)).collect(Collectors.toList());
    CCRenderState renderState = CCRenderState.instance();
    renderState.reset();
    renderState.bind(buffer);
    IVertexOperation[] pipeline = new IVertexOperation[2];
    pipeline[0] = new Translation(pos);
    pipeline[1] = new IconTransformation(sprite);
    BlockFace blockFace = blockFaces.get();
    for (Cuboid6 boundingBox : cuboid6List) {
        for (EnumFacing face : EnumFacing.VALUES) {
            blockFace.loadCuboidFace(boundingBox, face.getIndex());
            renderState.setPipeline(blockFace, 0, blockFace.verts.length, pipeline);
            renderState.render();
        }
    }
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) ModelBakeEvent(net.minecraftforge.client.event.ModelBakeEvent) IconTransformation(codechicken.lib.vec.uv.IconTransformation) TransformType(net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) Matrix4f(javax.vecmath.Matrix4f) Block(net.minecraft.block.Block) Pair(org.apache.commons.lang3.tuple.Pair) Map(java.util.Map) RenderHelper(net.minecraft.client.renderer.RenderHelper) GL11(org.lwjgl.opengl.GL11) ModelBlock(net.minecraft.client.renderer.block.model.ModelBlock) MetaTileEntity(gregtech.api.metatileentity.MetaTileEntity) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) IIconRegister(codechicken.lib.texture.TextureUtils.IIconRegister) GlStateManager(net.minecraft.client.renderer.GlStateManager) IModelState(net.minecraftforge.common.model.IModelState) Collection(java.util.Collection) ItemTransformVec3f(net.minecraft.client.renderer.block.model.ItemTransformVec3f) Collectors(java.util.stream.Collectors) ICCBlockRenderer(codechicken.lib.render.block.ICCBlockRenderer) List(java.util.List) EnumBlockRenderType(net.minecraft.util.EnumBlockRenderType) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) Translation(codechicken.lib.vec.Translation) BufferBuilder(net.minecraft.client.renderer.BufferBuilder) AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) IItemRenderer(codechicken.lib.render.item.IItemRenderer) IVertexOperation(codechicken.lib.render.pipeline.IVertexOperation) TextureUtils(codechicken.lib.texture.TextureUtils) HashMap(java.util.HashMap) BlockFace(codechicken.lib.render.BlockRenderer.BlockFace) DefaultVertexFormats(net.minecraft.client.renderer.vertex.DefaultVertexFormats) ItemStack(net.minecraft.item.ItemStack) Minecraft(net.minecraft.client.Minecraft) TRSRTransformation(net.minecraftforge.common.model.TRSRTransformation) MachineItemBlock(gregtech.api.block.machines.MachineItemBlock) IResource(net.minecraft.client.resources.IResource) IBlockAccess(net.minecraft.world.IBlockAccess) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) CCRenderState(codechicken.lib.render.CCRenderState) GTLog(gregtech.api.util.GTLog) TextureMap(net.minecraft.client.renderer.texture.TextureMap) EnumFacing(net.minecraft.util.EnumFacing) BlockPos(net.minecraft.util.math.BlockPos) IOException(java.io.IOException) BlockRenderingRegistry(codechicken.lib.render.block.BlockRenderingRegistry) InputStreamReader(java.io.InputStreamReader) IBlockState(net.minecraft.block.state.IBlockState) MinecraftForge(net.minecraftforge.common.MinecraftForge) GTValues(gregtech.api.GTValues) ResourceLocation(net.minecraft.util.ResourceLocation) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) ItemBlock(net.minecraft.item.ItemBlock) LightUtil(net.minecraftforge.client.model.pipeline.LightUtil) BlockMachine(gregtech.api.block.machines.BlockMachine) Cuboid6(codechicken.lib.vec.Cuboid6) IVertexOperation(codechicken.lib.render.pipeline.IVertexOperation) Translation(codechicken.lib.vec.Translation) BlockMachine(gregtech.api.block.machines.BlockMachine) BlockFace(codechicken.lib.render.BlockRenderer.BlockFace) EnumFacing(net.minecraft.util.EnumFacing) Cuboid6(codechicken.lib.vec.Cuboid6) CCRenderState(codechicken.lib.render.CCRenderState) IconTransformation(codechicken.lib.vec.uv.IconTransformation)

Aggregations

BlockMachine (gregtech.api.block.machines.BlockMachine)2 Collectors (java.util.stream.Collectors)2 Block (net.minecraft.block.Block)2 IBlockState (net.minecraft.block.state.IBlockState)2 Minecraft (net.minecraft.client.Minecraft)2 ModelResourceLocation (net.minecraft.client.renderer.block.model.ModelResourceLocation)2 BlockFace (codechicken.lib.render.BlockRenderer.BlockFace)1 CCRenderState (codechicken.lib.render.CCRenderState)1 BlockRenderingRegistry (codechicken.lib.render.block.BlockRenderingRegistry)1 ICCBlockRenderer (codechicken.lib.render.block.ICCBlockRenderer)1 IItemRenderer (codechicken.lib.render.item.IItemRenderer)1 IVertexOperation (codechicken.lib.render.pipeline.IVertexOperation)1 TextureUtils (codechicken.lib.texture.TextureUtils)1 IIconRegister (codechicken.lib.texture.TextureUtils.IIconRegister)1 Cuboid6 (codechicken.lib.vec.Cuboid6)1 Translation (codechicken.lib.vec.Translation)1 IconTransformation (codechicken.lib.vec.uv.IconTransformation)1 Streams (com.google.common.collect.Streams)1 GTValues (gregtech.api.GTValues)1 GregTechAPI (gregtech.api.GregTechAPI)1