Search in sources :

Example 21 with MetaTileEntity

use of gregtech.api.metatileentity.MetaTileEntity in project GregTech by GregTechCE.

the class MachineItemBlock method getCreatorModId.

@Nullable
@Override
public String getCreatorModId(ItemStack itemStack) {
    MetaTileEntity metaTileEntity = getMetaTileEntity(itemStack);
    if (metaTileEntity == null) {
        return GTValues.MODID;
    }
    ResourceLocation metaTileEntityId = metaTileEntity.metaTileEntityId;
    return metaTileEntityId.getNamespace();
}
Also used : ResourceLocation(net.minecraft.util.ResourceLocation) MetaTileEntity(gregtech.api.metatileentity.MetaTileEntity) ITieredMetaTileEntity(gregtech.api.metatileentity.ITieredMetaTileEntity) Nullable(javax.annotation.Nullable)

Example 22 with MetaTileEntity

use of gregtech.api.metatileentity.MetaTileEntity in project GregTech by GregTechCE.

the class MetaTileEntityRenderer method handleRenderBlockDamage.

@Override
public void handleRenderBlockDamage(IBlockAccess world, BlockPos pos, IBlockState state, TextureAtlasSprite sprite, BufferBuilder buffer) {
    MetaTileEntity metaTileEntity = BlockMachine.getMetaTileEntity(world, pos);
    ArrayList<IndexedCuboid6> boundingBox = new ArrayList<>();
    if (metaTileEntity != null) {
        metaTileEntity.addCollisionBoundingBox(boundingBox);
        metaTileEntity.addCoverCollisionBoundingBox(boundingBox);
    }
    CCRenderState renderState = CCRenderState.instance();
    renderState.reset();
    renderState.bind(buffer);
    renderState.setPipeline(new Vector3(new Vec3d(pos)).translation(), new IconTransformation(sprite));
    for (Cuboid6 cuboid : boundingBox) {
        BlockRenderer.renderCuboid(renderState, cuboid, 0);
    }
}
Also used : IndexedCuboid6(codechicken.lib.raytracer.IndexedCuboid6) ArrayList(java.util.ArrayList) IRenderMetaTileEntity(gregtech.api.metatileentity.IRenderMetaTileEntity) MetaTileEntity(gregtech.api.metatileentity.MetaTileEntity) IFastRenderMetaTileEntity(gregtech.api.metatileentity.IFastRenderMetaTileEntity) Vector3(codechicken.lib.vec.Vector3) CCRenderState(codechicken.lib.render.CCRenderState) IndexedCuboid6(codechicken.lib.raytracer.IndexedCuboid6) Cuboid6(codechicken.lib.vec.Cuboid6) Vec3d(net.minecraft.util.math.Vec3d) IconTransformation(codechicken.lib.vec.uv.IconTransformation)

Example 23 with MetaTileEntity

use of gregtech.api.metatileentity.MetaTileEntity in project GregTech by GregTechCE.

the class MetaTileEntityRenderer method renderItem.

@Override
public void renderItem(ItemStack rawStack, TransformType transformType) {
    ItemStack stack = ModCompatibility.getRealItemStack(rawStack);
    if (!(stack.getItem() instanceof MachineItemBlock)) {
        return;
    }
    MetaTileEntity metaTileEntity = MachineItemBlock.getMetaTileEntity(stack);
    if (metaTileEntity == null) {
        return;
    }
    GlStateManager.enableBlend();
    CCRenderState renderState = CCRenderState.instance();
    renderState.reset();
    renderState.startDrawing(GL11.GL_QUADS, DefaultVertexFormats.ITEM);
    metaTileEntity.setRenderContextStack(stack);
    metaTileEntity.renderMetaTileEntity(renderState, new Matrix4(), new IVertexOperation[0]);
    if (metaTileEntity instanceof IFastRenderMetaTileEntity) {
        ((IFastRenderMetaTileEntity) metaTileEntity).renderMetaTileEntityFast(renderState, new Matrix4(), 0.0f);
    }
    metaTileEntity.setRenderContextStack(null);
    renderState.draw();
    if (metaTileEntity instanceof IRenderMetaTileEntity) {
        ((IRenderMetaTileEntity) metaTileEntity).renderMetaTileEntityDynamic(0.0, 0.0, 0.0, 0.0f);
    }
    GlStateManager.disableBlend();
}
Also used : MachineItemBlock(gregtech.api.block.machines.MachineItemBlock) IRenderMetaTileEntity(gregtech.api.metatileentity.IRenderMetaTileEntity) MetaTileEntity(gregtech.api.metatileentity.MetaTileEntity) IFastRenderMetaTileEntity(gregtech.api.metatileentity.IFastRenderMetaTileEntity) IFastRenderMetaTileEntity(gregtech.api.metatileentity.IFastRenderMetaTileEntity) ItemStack(net.minecraft.item.ItemStack) CCRenderState(codechicken.lib.render.CCRenderState) IRenderMetaTileEntity(gregtech.api.metatileentity.IRenderMetaTileEntity) Matrix4(codechicken.lib.vec.Matrix4)

Example 24 with MetaTileEntity

use of gregtech.api.metatileentity.MetaTileEntity in project GregTech by GregTechCE.

the class MetaTileEntityTank method getTankTile.

private MetaTileEntityTank getTankTile(BlockPos blockPos) {
    MetaTileEntity metaTileEntity = BlockMachine.getMetaTileEntity(getWorld(), blockPos);
    if (!(metaTileEntity instanceof MetaTileEntityTank)) {
        return null;
    }
    MetaTileEntityTank metaTileEntityTank = (MetaTileEntityTank) metaTileEntity;
    if (metaTileEntityTank.isRemoved || metaTileEntityTank.material != material || metaTileEntityTank.tankSize != tankSize || !isTankFluidEqual(metaTileEntityTank, this)) {
        return null;
    }
    return metaTileEntityTank;
}
Also used : MetaTileEntity(gregtech.api.metatileentity.MetaTileEntity) IFastRenderMetaTileEntity(gregtech.api.metatileentity.IFastRenderMetaTileEntity)

Example 25 with MetaTileEntity

use of gregtech.api.metatileentity.MetaTileEntity in project GregTech by GregTechCE.

the class MetaTileEntityTank method getControllerEntity.

private MetaTileEntityTank getControllerEntity() {
    if (controllerPos == null) {
        return null;
    }
    MetaTileEntityTank cachedController = controllerCache.get();
    if (cachedController != null) {
        if (cachedController.isValid()) {
            return cachedController;
        } else {
            controllerCache.clear();
        }
    }
    MetaTileEntity metaTileEntity = BlockMachine.getMetaTileEntity(getWorld(), controllerPos);
    if (metaTileEntity instanceof MetaTileEntityTank) {
        this.controllerCache = new WeakReference<>((MetaTileEntityTank) metaTileEntity);
        return (MetaTileEntityTank) metaTileEntity;
    }
    return null;
}
Also used : MetaTileEntity(gregtech.api.metatileentity.MetaTileEntity) IFastRenderMetaTileEntity(gregtech.api.metatileentity.IFastRenderMetaTileEntity)

Aggregations

MetaTileEntity (gregtech.api.metatileentity.MetaTileEntity)25 IFastRenderMetaTileEntity (gregtech.api.metatileentity.IFastRenderMetaTileEntity)6 CCRenderState (codechicken.lib.render.CCRenderState)5 ItemStack (net.minecraft.item.ItemStack)5 Matrix4 (codechicken.lib.vec.Matrix4)4 IRenderMetaTileEntity (gregtech.api.metatileentity.IRenderMetaTileEntity)4 MetaTileEntityHolder (gregtech.api.metatileentity.MetaTileEntityHolder)4 ResourceLocation (net.minecraft.util.ResourceLocation)4 ArrayList (java.util.ArrayList)3 CuboidRayTraceResult (codechicken.lib.raytracer.CuboidRayTraceResult)2 IndexedCuboid6 (codechicken.lib.raytracer.IndexedCuboid6)2 IVertexOperation (codechicken.lib.render.pipeline.IVertexOperation)2 IMetaTileEntity (gregtech.api.interfaces.metatileentity.IMetaTileEntity)2 ITieredMetaTileEntity (gregtech.api.metatileentity.ITieredMetaTileEntity)2 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)2 TileEntity (net.minecraft.tileentity.TileEntity)2 EnumFacing (net.minecraft.util.EnumFacing)2 ColourMultiplier (codechicken.lib.render.pipeline.ColourMultiplier)1 Cuboid6 (codechicken.lib.vec.Cuboid6)1 Vector3 (codechicken.lib.vec.Vector3)1