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();
}
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);
}
}
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();
}
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;
}
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;
}
Aggregations