use of gregtech.api.cover.ICoverable in project GregTech by GregTechCE.
the class CableRenderer method renderBlock.
@Override
public boolean renderBlock(IBlockAccess world, BlockPos pos, IBlockState state, BufferBuilder buffer) {
CCRenderState renderState = CCRenderState.instance();
renderState.reset();
renderState.bind(buffer);
renderState.setBrightness(world, pos);
IVertexOperation[] pipeline = { new Translation(pos) };
BlockCable blockCable = (BlockCable) state.getBlock();
TileEntityCable tileEntityCable = (TileEntityCable) blockCable.getPipeTileEntity(world, pos);
if (tileEntityCable == null)
return false;
int paintingColor = tileEntityCable.getInsulationColor();
int connectedSidesMask = blockCable.getActualConnections(tileEntityCable, world);
Insulation insulation = tileEntityCable.getPipeType();
Material material = tileEntityCable.getPipeMaterial();
if (insulation != null && material != null) {
BlockRenderLayer renderLayer = MinecraftForgeClient.getRenderLayer();
if (renderLayer == BlockRenderLayer.CUTOUT) {
renderCableBlock(material, insulation, paintingColor, renderState, pipeline, connectedSidesMask);
}
ICoverable coverable = tileEntityCable.getCoverableImplementation();
coverable.renderCovers(renderState, new Matrix4().translate(pos.getX(), pos.getY(), pos.getZ()), renderLayer);
}
return true;
}
use of gregtech.api.cover.ICoverable in project GregTech by GregTechCE.
the class FluidPipeRenderer method renderBlock.
@Override
public boolean renderBlock(IBlockAccess world, BlockPos pos, IBlockState state, BufferBuilder buffer) {
CCRenderState renderState = CCRenderState.instance();
renderState.reset();
renderState.bind(buffer);
renderState.setBrightness(world, pos);
BlockFluidPipe blockPipe = ((BlockFluidPipe) state.getBlock());
TileEntityFluidPipe tileEntityPipe = (TileEntityFluidPipe) blockPipe.getPipeTileEntity(world, pos);
if (tileEntityPipe == null) {
return false;
}
FluidPipeType fluidPipeType = tileEntityPipe.getPipeType();
Material pipeMaterial = tileEntityPipe.getPipeMaterial();
int paintingColor = tileEntityPipe.getInsulationColor();
if (fluidPipeType != null && pipeMaterial != null) {
BlockRenderLayer renderLayer = MinecraftForgeClient.getRenderLayer();
if (renderLayer == BlockRenderLayer.CUTOUT) {
int connectedSidesMask = blockPipe.getActualConnections(tileEntityPipe, world);
IVertexOperation[] pipeline = new IVertexOperation[] { new Translation(pos) };
renderPipeBlock(pipeMaterial, fluidPipeType, paintingColor, renderState, pipeline, connectedSidesMask);
}
ICoverable coverable = tileEntityPipe.getCoverableImplementation();
coverable.renderCovers(renderState, new Matrix4().translate(pos.getX(), pos.getY(), pos.getZ()), renderLayer);
}
return true;
}
use of gregtech.api.cover.ICoverable in project GregTech by GregTechCE.
the class CoverPlaceBehavior method onItemUseFirst.
@Override
public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) {
TileEntity tileEntity = world.getTileEntity(pos);
ICoverable coverable = tileEntity == null ? null : tileEntity.getCapability(GregtechTileCapabilities.CAPABILITY_COVERABLE, null);
if (coverable == null) {
return EnumActionResult.PASS;
}
EnumFacing coverSide = ICoverable.rayTraceCoverableSide(coverable, player);
if (coverable.getCoverAtSide(coverSide) != null || !coverable.canPlaceCoverOnSide(coverSide)) {
return EnumActionResult.PASS;
}
if (!world.isRemote) {
ItemStack itemStack = player.getHeldItem(hand);
boolean result = coverable.placeCoverOnSide(coverSide, itemStack, coverDefinition);
if (result && !player.capabilities.isCreativeMode) {
itemStack.shrink(1);
}
return result ? EnumActionResult.SUCCESS : EnumActionResult.FAIL;
}
return EnumActionResult.SUCCESS;
}
use of gregtech.api.cover.ICoverable in project GregTech by GregTechCE.
the class CrowbarBehaviour method onItemUseFirst.
@Override
public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos blockPos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) {
ItemStack stack = player.getHeldItem(hand);
IBlockState blockState = world.getBlockState(blockPos);
if (GTUtility.doDamageItem(stack, cost, true)) {
if (blockState.getBlock() instanceof BlockRailBase) {
if (world.isRemote) {
// always return success on client side
return EnumActionResult.SUCCESS;
} else if (player.isSneaking()) {
if (tryBreakRailBlock(blockState, world, blockPos, player)) {
GTUtility.doDamageItem(stack, cost, false);
return EnumActionResult.SUCCESS;
}
return EnumActionResult.FAIL;
} else {
if (tryRotateRailBlock(blockState, world, blockPos)) {
GTUtility.doDamageItem(stack, cost, false);
return EnumActionResult.SUCCESS;
}
return EnumActionResult.FAIL;
}
}
TileEntity tileEntity = world.getTileEntity(blockPos);
ICoverable coverable = tileEntity == null ? null : tileEntity.getCapability(GregtechTileCapabilities.CAPABILITY_COVERABLE, null);
EnumFacing coverSide = coverable == null ? null : ICoverable.rayTraceCoverableSide(coverable, player);
if (coverSide != null && coverable.getCoverAtSide(coverSide) != null) {
if (world.isRemote) {
// always return success on client side
return EnumActionResult.SUCCESS;
}
boolean result = coverable.removeCover(coverSide);
GTUtility.doDamageItem(stack, cost, false);
return result ? EnumActionResult.SUCCESS : EnumActionResult.PASS;
}
}
return EnumActionResult.PASS;
}
use of gregtech.api.cover.ICoverable in project GregTech by GregTechCE.
the class BlockPipe method getCollisionBox.
private List<IndexedCuboid6> getCollisionBox(IBlockAccess world, BlockPos pos) {
IPipeTile<PipeType, NodeDataType> pipeTile = getPipeTileEntity(world, pos);
if (pipeTile == null) {
return Collections.emptyList();
}
PipeType pipeType = pipeTile.getPipeType();
if (pipeType == null) {
return Collections.emptyList();
}
int actualConnections = getActualConnections(pipeTile, world);
float thickness = pipeType.getThickness();
ArrayList<IndexedCuboid6> result = new ArrayList<>();
result.add(new IndexedCuboid6(new PrimaryBoxData(false), getSideBox(null, thickness)));
ICoverable coverable = pipeTile.getCoverableImplementation();
for (EnumFacing side : EnumFacing.VALUES) {
if ((actualConnections & 1 << side.getIndex()) > 0) {
result.add(new IndexedCuboid6(new PipeConnectionData(side), getSideBox(side, thickness)));
}
}
coverable.addCoverCollisionBoundingBox(result);
return result;
}
Aggregations