codechicken.lib.vec.Cuboid6 Java Examples
The following examples show how to use
codechicken.lib.vec.Cuboid6.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StonePileModelGenerator.java From GregTech with GNU Lesser General Public License v3.0 | 6 votes |
private static List<IndexedCuboid6> generateCuboidList(Random random) { ArrayList<IndexedCuboid6> result = new ArrayList<>(); List<PositionedRect> occupiedAreas = new ArrayList<>(); int stonePlaceAttempts = 64; int maxStones = 8; int stonesPlaced = 0; for (int i = 0; i < stonePlaceAttempts && stonesPlaced < maxStones; i++) { int sizeX = 2 + random.nextInt(3); int sizeZ = 2 + random.nextInt(3); int stoneHeight = 4 + random.nextInt(4); int posX = random.nextInt(16 - sizeX); int posZ = random.nextInt(16 - sizeZ); PositionedRect rect = new PositionedRect(new Position(posX, posZ), new Size(sizeX, sizeZ)); if (occupiedAreas.stream().noneMatch(rect::intersects)) { Vector3 minVector = new Vector3(posX / 16.0, 0 / 16.0, posZ / 16.0); Cuboid6 bounds = new Cuboid6(minVector, minVector.copy()); bounds.max.add(sizeX / 16.0, stoneHeight / 16.0, sizeZ / 16.0); int brightness = 100 + random.nextInt(130); result.add(new IndexedCuboid6(brightness, bounds)); occupiedAreas.add(rect); stonesPlaced++; } } return result; }
Example #2
Source File: BlockPipe.java From GregTech with GNU Lesser General Public License v3.0 | 6 votes |
public static Cuboid6 getSideBox(EnumFacing side, float thickness) { float min = (1.0f - thickness) / 2.0f; float max = min + thickness; if (side == null) { return new Cuboid6(min, min, min, max, max, max); } else if (side == EnumFacing.DOWN) { return new Cuboid6(min, 0.0f, min, max, min, max); } else if (side == EnumFacing.UP) { return new Cuboid6(min, max, min, max, 1.0f, max); } else if (side == EnumFacing.WEST) { return new Cuboid6(0.0f, min, min, min, max, max); } else if (side == EnumFacing.EAST) { return new Cuboid6(max, min, min, 1.0f, max, max); } else if (side == EnumFacing.NORTH) { return new Cuboid6(min, min, 0.0f, max, max, min); } else if (side == EnumFacing.SOUTH) { return new Cuboid6(min, min, max, max, max, 1.0f); } else throw new IllegalArgumentException(side.toString()); }
Example #3
Source File: PartFrame.java From Framez with GNU General Public License v3.0 | 6 votes |
@Override public Iterable<IndexedCuboid6> getSubParts() { List<IndexedCuboid6> l = new ArrayList<IndexedCuboid6>(); Vec3dCube c1 = new Vec3dCube(0, 0, 0, 2 / 16D, 2 / 16D, 1); Vec3dCube c2 = new Vec3dCube(0, 2 / 16D, 0, 2 / 16D, 14 / 16D, 2 / 16D); Vec3dCube c3 = new Vec3dCube(0, 14 / 16D, 0, 2 / 16D, 1, 1); for (int i = 0; i < 4; i++) { l.add(new IndexedCuboid6(0, new Cuboid6(c1.clone().rotate(0, i * 90, 0, Vec3d.center).toAABB()))); l.add(new IndexedCuboid6(0, new Cuboid6(c2.clone().rotate(0, i * 90, 0, Vec3d.center).toAABB()))); l.add(new IndexedCuboid6(0, new Cuboid6(c3.clone().rotate(0, i * 90, 0, Vec3d.center).toAABB()))); } if (getWorld() != null && (!getWorld().isRemote || !Config.click_through_frames)) if (is2D()) l.add(new IndexedCuboid6(0, new Cuboid6(0, 0, 0, 1, 1, 1).expand(-0.001))); else l.add(new IndexedCuboid6(0, new Cuboid6(1 / 16D, 1 / 16D, 1 / 16D, 15 / 16D, 15 / 16D, 15 / 16D))); return l; }
Example #4
Source File: TileEnderChest.java From EnderStorage with MIT License | 6 votes |
@Override public void addTraceableCuboids(List<IndexedCuboid6> cuboids) { cuboids.add(new IndexedCuboid6(0, new Cuboid6(xCoord+1/16D, yCoord, zCoord+1/16D, xCoord+15/16D, yCoord+14/16D, zCoord+15/16D))); if(getRadianLidAngle(0) < 0) return; for(int button = 0; button < 3; button++) { EnderDyeButton ebutton = TileEnderChest.buttons[button].copy(); ebutton.rotate(0, 0.5625, 0.0625, 1, 0, 0, 0); ebutton.rotateMeta(rotation); cuboids.add(new IndexedCuboid6(button+1, new Cuboid6(ebutton.getMin(), ebutton.getMax()).add(Vector3.fromTileEntity(this)))); } cuboids.add(new IndexedCuboid6(4, new Cuboid6(new EnderKnobSlot(rotation).getSelectionBB()).add(Vector3.fromTileEntity(this)))); }
Example #5
Source File: InvPipeRenderer.java From GregTech with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void handleRenderBlockDamage(IBlockAccess world, BlockPos pos, IBlockState state, TextureAtlasSprite sprite, BufferBuilder buffer) { CCRenderState renderState = CCRenderState.instance(); renderState.reset(); renderState.bind(buffer); renderState.setPipeline(new Vector3(new Vec3d(pos)).translation(), new IconTransformation(sprite)); BlockInventoryPipe block = (BlockInventoryPipe) state.getBlock(); TileEntityInventoryPipe tileEntity = (TileEntityInventoryPipe) block.getPipeTileEntity(world, pos); if (tileEntity == null) { return; } InventoryPipeType pipeType = tileEntity.getPipeType(); if (pipeType == null) { return; } float thickness = pipeType.getThickness(); int connectedSidesMask = block.getActualConnections(tileEntity, world); Cuboid6 baseBox = BlockPipe.getSideBox(null, thickness); BlockRenderer.renderCuboid(renderState, baseBox, 0); for (EnumFacing renderSide : EnumFacing.VALUES) { if ((connectedSidesMask & (1 << renderSide.getIndex())) > 0) { Cuboid6 sideBox = BlockPipe.getSideBox(renderSide, thickness); BlockRenderer.renderCuboid(renderState, sideBox, 0); } } }
Example #6
Source File: MetaTileEntityRenderer.java From GregTech with GNU Lesser General Public License v3.0 | 6 votes |
@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); } }
Example #7
Source File: BlockCraftingGrid.java From Translocators with MIT License | 6 votes |
public List<IndexedCuboid6> getParts(World world, int x, int y, int z) { LinkedList<IndexedCuboid6> parts = new LinkedList<IndexedCuboid6>(); parts.add(new IndexedCuboid6(0, new Cuboid6(0, 0, 0, 1, 0.005, 1) .add(new Vector3(x, y, z)) )); TileCraftingGrid tcraft = (TileCraftingGrid) world.getTileEntity(x, y, z); for (int i = 0; i < 9; i++) { Cuboid6 box = new Cuboid6(1 / 16D, 0, 1 / 16D, 5 / 16D, 0.01, 5 / 16D) .apply(new Translation((i % 3) * 5 / 16D, 0, (i / 3) * 5 / 16D) .with(Rotation.quarterRotations[tcraft.rotation].at(center)) .with(new Translation(x, y, z))); parts.add(new IndexedCuboid6(i + 1, box)); } return parts; }
Example #8
Source File: CableRenderer.java From GregTech with GNU Lesser General Public License v3.0 | 6 votes |
private static void renderCableCube(int connections, CCRenderState renderState, IVertexOperation[] pipeline, IVertexOperation[] wire, IVertexOperation[] overlays, EnumFacing side, float thickness) { if ((connections & 1 << side.getIndex()) > 0) { boolean renderFrontSide = (connections & 1 << (6 + side.getIndex())) > 0; Cuboid6 cuboid6 = BlockCable.getSideBox(side, thickness); for (EnumFacing renderedSide : EnumFacing.VALUES) { if (renderedSide == side) { if (renderFrontSide) { renderCableSide(renderState, wire, renderedSide, cuboid6); renderCableSide(renderState, overlays, renderedSide, cuboid6); } } else if (renderedSide != side.getOpposite()) { renderCableSide(renderState, pipeline, renderedSide, cuboid6); } } } }
Example #9
Source File: TileTranslocator.java From Translocators with MIT License | 6 votes |
public void addTraceableCuboids(List<IndexedCuboid6> cuboids) { Vector3 pos = Vector3.fromTileEntity(this); Cuboid6 base = new Cuboid6(3/16D, 0, 3/16D, 13/16D, 2/16D, 13/16D); for(int i = 0; i < 6; i++) { Attachment a = attachments[i]; if(a != null) { cuboids.add(new IndexedCuboid6(i, transformPart(base, pos, i))); cuboids.add(new IndexedCuboid6(i+6, transformPart( new Cuboid6(6/16D, 0, 6/16D, 10/16D, a.a_insertpos*2/16D+1/16D, 10/16D), pos, i))); } } }
Example #10
Source File: CableRenderer.java From GregTech with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void handleRenderBlockDamage(IBlockAccess world, BlockPos pos, IBlockState state, TextureAtlasSprite sprite, BufferBuilder buffer) { CCRenderState renderState = CCRenderState.instance(); renderState.reset(); renderState.bind(buffer); renderState.setPipeline(new Vector3(new Vec3d(pos)).translation(), new IconTransformation(sprite)); BlockCable blockCable = (BlockCable) state.getBlock(); IPipeTile<Insulation, WireProperties> tileEntityCable = blockCable.getPipeTileEntity(world, pos); if (tileEntityCable == null) { return; } Insulation insulation = tileEntityCable.getPipeType(); if (insulation == null) { return; } float thickness = insulation.getThickness(); int connectedSidesMask = blockCable.getActualConnections(tileEntityCable, world); Cuboid6 baseBox = BlockCable.getSideBox(null, thickness); BlockRenderer.renderCuboid(renderState, baseBox, 0); for (EnumFacing renderSide : EnumFacing.VALUES) { if ((connectedSidesMask & (1 << renderSide.getIndex())) > 0) { Cuboid6 sideBox = BlockCable.getSideBox(renderSide, thickness); BlockRenderer.renderCuboid(renderState, sideBox, 0); } } }
Example #11
Source File: SimpleCubeRenderer.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@Override @SideOnly(Side.CLIENT) public void render(CCRenderState renderState, Matrix4 translation, IVertexOperation[] pipeline, Cuboid6 bounds) { for (EnumFacing side : EnumFacing.values()) { renderSided(side, translation, bounds, renderState, pipeline); } }
Example #12
Source File: TankRenderer.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@SideOnly(Side.CLIENT) public void renderFluid(CCRenderState renderState, Matrix4 translation, int connectionMask, double fillPercent, FluidStack fluidStack) { if (fluidStack != null) { int fluidStackColor = fluidStack.getFluid().getColor(fluidStack); double fluidLevelOffset = (offset(EnumFacing.UP, connectionMask) + offset(EnumFacing.DOWN, connectionMask)); double fluidLevel = fillPercent * (1.0 - fluidLevelOffset); Cuboid6 resultFluidCuboid = createFullOffsetCuboid(connectionMask); int resultFluidColor; if (fluidStack.getFluid().isGaseous(fluidStack)) { int opacity = (int) (fillPercent * 255); resultFluidColor = GTUtility.convertRGBtoRGBA_CL(fluidStackColor, opacity); } else { resultFluidCuboid.max.y = resultFluidCuboid.min.y + fluidLevel; resultFluidColor = GTUtility.convertRGBtoOpaqueRGBA_CL(fluidStackColor); } ColourMultiplier multiplier = new ColourMultiplier(resultFluidColor); IVertexOperation[] fluidPipeline = new IVertexOperation[]{multiplier}; TextureAtlasSprite fluidSprite = TextureUtils.getTexture(fluidStack.getFluid().getStill(fluidStack)); for (EnumFacing renderSide : EnumFacing.VALUES) { if (hasFaceBit(connectionMask, renderSide)) continue; Textures.renderFace(renderState, translation, fluidPipeline, renderSide, resultFluidCuboid, fluidSprite); } } }
Example #13
Source File: MetaTileEntityRenderer.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@Override public boolean renderBlock(IBlockAccess world, BlockPos pos, IBlockState state, BufferBuilder buffer) { MetaTileEntity metaTileEntity = BlockMachine.getMetaTileEntity(world, pos); if (metaTileEntity == null) { return false; } CCRenderState renderState = CCRenderState.instance(); renderState.reset(); renderState.bind(buffer); Matrix4 translation = new Matrix4().translate(pos.getX(), pos.getY(), pos.getZ()); BlockRenderLayer renderLayer = MinecraftForgeClient.getRenderLayer(); if (metaTileEntity.canRenderInLayer(renderLayer)) { renderState.lightMatrix.locate(world, pos); IVertexOperation[] pipeline = new IVertexOperation[]{renderState.lightMatrix}; metaTileEntity.renderMetaTileEntity(renderState, translation.copy(), pipeline); } Matrix4 coverTranslation = new Matrix4().translate(pos.getX(), pos.getY(), pos.getZ()); metaTileEntity.renderCovers(renderState, coverTranslation, renderLayer); if (metaTileEntity.isFragile() && renderLayer == BlockRenderLayer.CUTOUT) { TextureMap textureMap = Minecraft.getMinecraft().getTextureMapBlocks(); Random posRand = new Random(MathHelper.getPositionRandom(pos)); int destroyStage = posRand.nextInt(10); TextureAtlasSprite atlasSprite = textureMap.getAtlasSprite("minecraft:blocks/destroy_stage_" + destroyStage); for (EnumFacing face : EnumFacing.VALUES) { Textures.renderFace(renderState, translation, new IVertexOperation[0], face, Cuboid6.full, atlasSprite); } } return true; }
Example #14
Source File: ParticleHandlerUtil.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
public static void addBlockHitEffects(World world, Cuboid6 bounds, EnumFacing side, TextureAtlasSprite icon, int spriteColor, ParticleManager particleManager) { float border = 0.1F; Vector3 diff = bounds.max.copy().subtract(bounds.min).add(-2 * border); diff.x *= world.rand.nextDouble(); diff.y *= world.rand.nextDouble(); diff.z *= world.rand.nextDouble(); Vector3 pos = diff.add(bounds.min).add(border); float red = (spriteColor >> 16 & 255) / 255.0F; float green = (spriteColor >> 8 & 255) / 255.0F; float blue = (spriteColor & 255) / 255.0F; if (side == EnumFacing.DOWN) { diff.y = bounds.min.y - border; } if (side == EnumFacing.UP) { diff.y = bounds.max.y + border; } if (side == EnumFacing.NORTH) { diff.z = bounds.min.z - border; } if (side == EnumFacing.SOUTH) { diff.z = bounds.max.z + border; } if (side == EnumFacing.WEST) { diff.x = bounds.min.x - border; } if (side == EnumFacing.EAST) { diff.x = bounds.max.x + border; } DigIconParticle digIconParticle = new DigIconParticle(world, pos.x, pos.y, pos.z, 0, 0, 0, icon); digIconParticle.multiplyVelocity(0.2F); digIconParticle.multipleParticleScaleBy(0.6F); digIconParticle.setRBGColorF(red, green, blue); particleManager.addEffect(digIconParticle); }
Example #15
Source File: ParticleHandlerUtil.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
private static Cuboid6 getBoundingBox(IBlockState blockState, World world, RayTraceResult target) { BlockPos blockPos = target.getBlockPos(); if (target instanceof CuboidRayTraceResult) { return ((CuboidRayTraceResult) target).cuboid6.copy().add(blockPos); } return new Cuboid6(blockState.getBoundingBox(world, blockPos)).add(blockPos); }
Example #16
Source File: MetaTileEntityPrimitiveBlastFurnace.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void renderMetaTileEntity(CCRenderState renderState, Matrix4 translation, IVertexOperation[] pipeline) { super.renderMetaTileEntity(renderState, translation, pipeline); Textures.PRIMITIVE_BLAST_FURNACE_OVERLAY.render(renderState, translation, pipeline, getFrontFacing(), isActive()); if (isActive() && isStructureFormed()) { EnumFacing back = getFrontFacing().getOpposite(); Matrix4 offset = translation.copy().translate(back.getFrontOffsetX(), -0.3, back.getFrontOffsetZ()); TextureAtlasSprite sprite = TextureUtils.getBlockTexture("lava_still"); renderState.brightness = 0xF000F0; renderState.colour = 0xFFFFFFFF; Textures.renderFace(renderState, offset, new IVertexOperation[0], EnumFacing.UP, Cuboid6.full, sprite); } }
Example #17
Source File: TileEnderTank.java From EnderStorage with MIT License | 5 votes |
@Override public void addTraceableCuboids(List<IndexedCuboid6> cuboids) { Vector3 pos = new Vector3(xCoord, yCoord, zCoord); cuboids.add(new IndexedCuboid6(0, new Cuboid6(0.15, 0, 0.15, 0.85, 0.916, 0.85).add(pos))); for (int i = 0; i < 4; i++) cuboids.add(new IndexedCuboid6(i + 1, selectionBoxes[i].copy() .apply(Rotation.quarterRotations[rotation ^ 2].at(center)).add(pos))); }
Example #18
Source File: CoverFacade.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void renderCover(CCRenderState renderState, Matrix4 translation, IVertexOperation[] pipeline, Cuboid6 plateBox, BlockRenderLayer layer) { BlockRenderLayer oldLayer = MinecraftForgeClient.getRenderLayer(); ForgeHooksClient.setRenderLayer(layer); FacadeRenderer.renderBlockCover(renderState, translation, coverHolder.getWorld(), coverHolder.getPos(), attachedSide.getIndex(), facadeState, plateBox); ForgeHooksClient.setRenderLayer(oldLayer); }
Example #19
Source File: VoxelShapeCache.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 5 votes |
public static Cuboid6 getCuboid(VoxelShape shape) { MutablePair<AxisAlignedBB, Cuboid6> entry = getReverse(shape); if (entry.getRight() == null) { entry.setRight(new Cuboid6(// I hope this is okay, don't want to rely on AABB cache. shape.getStart(Direction.Axis.X), shape.getStart(Direction.Axis.Y), shape.getStart(Direction.Axis.Z),// shape.getEnd(Direction.Axis.X), shape.getEnd(Direction.Axis.Y), shape.getEnd(Direction.Axis.Z)// )); } return entry.getRight(); }
Example #20
Source File: VoxelShapeCache.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 5 votes |
public static AxisAlignedBB getAABB(VoxelShape shape) { MutablePair<AxisAlignedBB, Cuboid6> entry = getReverse(shape); if (entry.getLeft() == null) { entry.setLeft(shape.getBoundingBox()); } return entry.getLeft(); }
Example #21
Source File: VoxelShapeCache.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 5 votes |
public static VoxelShape getShape(Cuboid6 cuboid) { VoxelShape shape = cuboidToShapeCache.getIfPresent(cuboid); if (shape == null) { shape = VoxelShapes.create(cuboid.min.x, cuboid.min.y, cuboid.min.z, cuboid.max.x, cuboid.max.y, cuboid.max.z); cuboidToShapeCache.put(cuboid, shape); MutablePair<AxisAlignedBB, Cuboid6> entry = getReverse(shape); if (entry.getRight() == null) { entry.setRight(cuboid); } } return shape; }
Example #22
Source File: VoxelShapeCache.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 5 votes |
public static VoxelShape getShape(AxisAlignedBB aabb) { VoxelShape shape = bbToShapeCache.getIfPresent(aabb); if (shape == null) { shape = VoxelShapes.create(aabb); bbToShapeCache.put(aabb, shape); MutablePair<AxisAlignedBB, Cuboid6> entry = getReverse(shape); if (entry.getLeft() == null) { entry.setLeft(aabb); } } return shape; }
Example #23
Source File: BlockRenderer.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 5 votes |
/** * Renders faces of a cuboid with texture coordinates mapped to match a standard minecraft block * * @param bounds The bounding cuboid to render * @param sideMask A mask of faces not to render */ public static void renderCuboid(CCRenderState state, Cuboid6 bounds, int sideMask) { if (sideMask == 0x3F) { return; } BlockFace face = blockFaces.get(); state.setModel(face); for (int s = 0; s < 6; s++) { if ((sideMask & 1 << s) == 0) { face.loadCuboidFace(bounds, s); state.render(); } } }
Example #24
Source File: FacadeRenderer.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
public static void renderItemCover(CCRenderState ccrs, int side, ItemStack renderStack, Cuboid6 bounds) { Minecraft minecraft = Minecraft.getMinecraft(); RenderItem renderItem = minecraft.getRenderItem(); IBakedModel model = renderItem.getItemModelWithOverrides(renderStack, null, null); IBlockState state = FacadeHelper.lookupBlockForItem(renderStack); String cacheKey = state.getBlock().getRegistryName() + "|" + state.getBlock().getMetaFromState(state); List<CCQuad> renderQuads = itemQuadCache.getIfPresent(cacheKey); if (renderQuads == null) { List<BakedQuad> quads = new ArrayList<>(model.getQuads(null, null, 0)); for (EnumFacing face : EnumFacing.VALUES) { quads.addAll(model.getQuads(null, face, 0)); } renderQuads = applyItemTint(sliceQuads(CCQuad.fromArray(quads), side, bounds), renderStack); itemQuadCache.put(cacheKey, renderQuads); } AdvCCRSConsumer consumer = new AdvCCRSConsumer(ccrs); consumer.setTranslation(new Matrix4() .translate(Vector3.center.copy().subtract(bounds.center())) .scale(1.05, 1.05, 1.05)); for (CCQuad quad : renderQuads) { quad.pipe(consumer); } }
Example #25
Source File: SimpleOrientedCubeRenderer.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@SideOnly(Side.CLIENT) public void render(CCRenderState renderState, Matrix4 translation, IVertexOperation[] ops, Cuboid6 bounds, EnumFacing frontFacing) { Textures.renderFace(renderState, translation, ops, EnumFacing.UP, bounds, sprites[CubeSide.TOP.ordinal()]); Textures.renderFace(renderState, translation, ops, EnumFacing.DOWN, bounds, sprites[CubeSide.BOTTOM.ordinal()]); Textures.renderFace(renderState, translation, ops, frontFacing, bounds, sprites[CubeSide.FRONT.ordinal()]); Textures.renderFace(renderState, translation, ops, frontFacing.getOpposite(), bounds, sprites[CubeSide.BACK.ordinal()]); Textures.renderFace(renderState, translation, ops, frontFacing.rotateY(), bounds, sprites[CubeSide.LEFT.ordinal()]); Textures.renderFace(renderState, translation, ops, frontFacing.rotateYCCW(), bounds, sprites[CubeSide.RIGHT.ordinal()]); }
Example #26
Source File: FacadeRenderer.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
private static double clampF(double x, Cuboid6 b, int j) { double l = b.getSide(sides[j][0]); double u = b.getSide(sides[j][1]); if (x < l) { return l - (l - x) * 0.001953125f; } else if (x > u) { return u + (x - u) * 0.001953125f; } else { return x; } }
Example #27
Source File: CustomParticleHandler.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 5 votes |
@OnlyIn (Dist.CLIENT) public static void addBlockHitEffects(World world, Cuboid6 bounds, Direction side, TextureAtlasSprite icon, ParticleManager particleManager) { float border = 0.1F; Vector3 diff = bounds.max.copy().subtract(bounds.min).add(-2 * border); diff.x *= world.rand.nextDouble(); diff.y *= world.rand.nextDouble(); diff.z *= world.rand.nextDouble(); Vector3 pos = diff.add(bounds.min).add(border); if (side == Direction.DOWN) { diff.y = bounds.min.y - border; } if (side == Direction.UP) { diff.y = bounds.max.y + border; } if (side == Direction.NORTH) { diff.z = bounds.min.z - border; } if (side == Direction.SOUTH) { diff.z = bounds.max.z + border; } if (side == Direction.WEST) { diff.x = bounds.min.x - border; } if (side == Direction.EAST) { diff.x = bounds.max.x + border; } particleManager.addEffect(new CustomBreakingParticle(world, pos.x, pos.y, pos.z, 0, 0, 0, icon).multiplyVelocity(0.2F).multipleParticleScaleBy(0.6F)); }
Example #28
Source File: TileEntityCrusherBladeRenderer.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected void draw(TileEntityCrusherBlade tileEntity, CCRenderState renderState, Matrix4 translation, float partialTicks) { translation.translate(0.5, 0.5, 0.5); IBlockState blockState = tileEntity.getBlockState(); switch (blockState.getValue(BlockCrusherBlade.AXIS)) { case Y: break; case X: translation.rotate(Math.toRadians(90.0), Rotation.axes[3]); break; case Z: translation.rotate(Math.toRadians(90.0), Rotation.axes[5]); break; } if (blockState.getValue(BlockCrusherBlade.ACTIVE)) { long currentWorldTime = tileEntity.hasWorld() ? tileEntity.getWorld().getTotalWorldTime() : 0; translation.rotate(Math.toRadians(currentWorldTime * 12.0 % 180), Rotation.axes[1]); } translation.translate(-0.5, -0.5, -0.5); TextureAtlasSprite ironBlockTexture = TextureUtils.getBlockTexture("iron_block"); IVertexOperation[] operations = {}; for (Cuboid6 cuboid6 : BlockCrusherBlade.basicModel) { for (EnumFacing renderSide : EnumFacing.VALUES) { Textures.renderFace(renderState, translation, operations, renderSide, cuboid6, ironBlockTexture); } } }
Example #29
Source File: CableRenderer.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
public void renderCableBlock(Material material, Insulation insulation1, int insulationColor1, CCRenderState state, IVertexOperation[] pipeline, int connectMask) { int wireColor = GTUtility.convertRGBtoOpaqueRGBA_CL(material.materialRGB); float thickness = insulation1.thickness; IVertexOperation[] wire = ArrayUtils.addAll(pipeline, new IconTransformation(wireTexture), new ColourMultiplier(wireColor)); IVertexOperation[] overlays = wire; IVertexOperation[] insulation = wire; if (insulation1.insulationLevel != -1) { int insulationColor = GTUtility.convertRGBtoOpaqueRGBA_CL(insulationColor1); ColourMultiplier multiplier = new ColourMultiplier(insulationColor); insulation = ArrayUtils.addAll(pipeline, new IconTransformation(insulationTextures[5]), multiplier); overlays = ArrayUtils.addAll(pipeline, new IconTransformation(insulationTextures[insulation1.insulationLevel]), multiplier); } Cuboid6 cuboid6 = BlockCable.getSideBox(null, thickness); for (EnumFacing renderedSide : EnumFacing.VALUES) { if ((connectMask & 1 << renderedSide.getIndex()) == 0) { int oppositeIndex = renderedSide.getOpposite().getIndex(); if ((connectMask & 1 << oppositeIndex) > 0 && (connectMask & ~(1 << oppositeIndex)) == 0) { //if there is something on opposite side, render overlay + wire renderCableSide(state, wire, renderedSide, cuboid6); renderCableSide(state, overlays, renderedSide, cuboid6); } else { renderCableSide(state, insulation, renderedSide, cuboid6); } } } renderCableCube(connectMask, state, insulation, wire, overlays, EnumFacing.DOWN, thickness); renderCableCube(connectMask, state, insulation, wire, overlays, EnumFacing.UP, thickness); renderCableCube(connectMask, state, insulation, wire, overlays, EnumFacing.WEST, thickness); renderCableCube(connectMask, state, insulation, wire, overlays, EnumFacing.EAST, thickness); renderCableCube(connectMask, state, insulation, wire, overlays, EnumFacing.NORTH, thickness); renderCableCube(connectMask, state, insulation, wire, overlays, EnumFacing.SOUTH, thickness); }
Example #30
Source File: StoneRenderer.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void handleRenderBlockDamage(IBlockAccess world, BlockPos pos, IBlockState state, TextureAtlasSprite sprite, BufferBuilder buffer) { CCRenderState renderState = CCRenderState.instance(); renderState.reset(); renderState.bind(buffer); renderState.setPipeline(new Vector3(new Vec3d(pos)).translation(), new IconTransformation(sprite)); Cuboid6 baseBox = new Cuboid6(state.getBoundingBox(world, pos)); BlockRenderer.renderCuboid(renderState, baseBox, 0); }