use of riskyken.armourersWorkshop.api.common.skin.cubes.ICubeColour in project Armourers-Workshop by RiskyKen.
the class RenderBlockGlowing method renderWorldBlock.
@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
if (block instanceof IPantableBlock) {
int light = block.getLightValue(world, x, y, z);
Tessellator tessellator = Tessellator.instance;
ICubeColour colour = ((IPantableBlock) block).getColour(world, x, y, z);
boolean rendered = false;
renderer.renderAllFaces = false;
if (light > 1) {
rendered = renderFaces(world, x, y, z, colour, block, renderer);
} else {
rendered = renderFacesWithLighting(world, x, y, z, colour, block, renderer);
}
return rendered;
} else {
renderer.renderAllFaces = false;
return renderer.renderStandardBlock(block, x, y, z);
}
}
use of riskyken.armourersWorkshop.api.common.skin.cubes.ICubeColour in project Armourers-Workshop by RiskyKen.
the class RenderBlockColourable method renderTileEntityAt.
public void renderTileEntityAt(TileEntityColourable tileEntity, double x, double y, double z, float partialTickTime) {
ICubeColour cubeColour = tileEntity.getColour();
// ModRenderHelper.disableLighting();
GL11.glDisable(GL11.GL_LIGHTING);
ModRenderHelper.enableAlphaBlend();
renderer.startDrawingQuads();
renderer.setColourRGBA_F(0.7F, 0.7F, 0.7F, markerAlpha);
if (markerAlpha > 0F) {
for (int i = 0; i < 6; i++) {
ForgeDirection dir = ForgeDirection.getOrientation(i);
int paintType = cubeColour.getPaintType(i) & 0xFF;
if (paintType != 255) {
bindTexture(MARKERS);
GL11.glColor3f(0.77F, 0.77F, 0.77F);
PaintType pt = PaintType.getPaintTypeFromUKey(paintType);
renderFaceWithMarker(x, y, z, dir, pt.ordinal());
}
}
}
renderer.draw();
GL11.glColor4f(1F, 1F, 1F, 1F);
ModRenderHelper.disableAlphaBlend();
ModRenderHelper.enableLighting();
RenderHelper.enableStandardItemLighting();
}
use of riskyken.armourersWorkshop.api.common.skin.cubes.ICubeColour in project Armourers-Workshop by RiskyKen.
the class ItemBlendingTool method usedOnBlockSide.
@SuppressWarnings("deprecation")
@Override
public void usedOnBlockSide(ItemStack stack, EntityPlayer player, World world, BlockLocation bl, Block block, int side) {
int intensity = UtilItems.getIntensityFromStack(stack, 16);
int radiusSample = (Integer) ToolOptions.RADIUS_SAMPLE.readFromNBT(stack.getTagCompound(), 2);
int radiusEffect = (Integer) ToolOptions.RADIUS_EFFECT.readFromNBT(stack.getTagCompound(), 1);
ArrayList<BlockLocation> blockSamples = BlockUtils.findTouchingBlockFaces(world, bl.x, bl.y, bl.z, side, radiusSample);
ArrayList<BlockLocation> blockEffects = BlockUtils.findTouchingBlockFaces(world, bl.x, bl.y, bl.z, side, radiusEffect);
if (blockSamples.size() == 0 | blockEffects.size() == 0) {
return;
}
int r = 0;
int g = 0;
int b = 0;
for (int i = 0; i < blockSamples.size(); i++) {
BlockLocation loc = blockSamples.get(i);
Block tarBlock = world.getBlock(loc.x, loc.y, loc.z);
if (tarBlock instanceof IPantableBlock) {
IPantableBlock pBlock = (IPantableBlock) tarBlock;
ICubeColour c = pBlock.getColour(world, loc.x, loc.y, loc.z);
r += c.getRed(side) & 0xFF;
g += c.getGreen(side) & 0xFF;
b += c.getBlue(side) & 0xFF;
}
}
r = r / blockSamples.size();
g = g / blockSamples.size();
b = b / blockSamples.size();
for (int i = 0; i < blockEffects.size(); i++) {
BlockLocation loc = blockEffects.get(i);
Block tarBlock = world.getBlock(loc.x, loc.y, loc.z);
if (tarBlock instanceof IPantableBlock) {
IPantableBlock worldColourable = (IPantableBlock) tarBlock;
int oldColour = worldColourable.getColour(world, loc.x, loc.y, loc.z, side);
byte oldPaintType = (byte) worldColourable.getPaintType(world, loc.x, loc.y, loc.z, side).getKey();
Color oldC = new Color(oldColour);
int oldR = oldC.getRed();
int oldG = oldC.getGreen();
int oldB = oldC.getBlue();
float newR = r / 100F * intensity;
newR += oldR / 100F * (100 - intensity);
newR = MathHelper.clamp_int((int) newR, 0, 255);
float newG = g / 100F * intensity;
newG += oldG / 100F * (100 - intensity);
newG = MathHelper.clamp_int((int) newG, 0, 255);
float newB = b / 100F * intensity;
newB += oldB / 100F * (100 - intensity);
newB = MathHelper.clamp_int((int) newB, 0, 255);
Color newC = new Color((int) newR, (int) newG, (int) newB);
UndoManager.blockPainted(player, world, loc.x, loc.y, loc.z, oldColour, oldPaintType, side);
((IPantableBlock) block).setColour(world, loc.x, loc.y, loc.z, newC.getRGB(), side);
}
}
}
use of riskyken.armourersWorkshop.api.common.skin.cubes.ICubeColour in project Armourers-Workshop by RiskyKen.
the class ArmourerWorldHelper method saveArmourBlockToList.
private static void saveArmourBlockToList(World world, int x, int y, int z, int ix, int iy, int iz, SkinCubeData cubeData, int index, ArrayList<CubeMarkerData> markerBlocks, ForgeDirection direction) {
Block block = world.getBlock(x, y, z);
if (!CubeRegistry.INSTANCE.isBuildingBlock(block)) {
return;
}
int meta = world.getBlockMetadata(x, y, z);
ICubeColour c = BlockUtils.getColourFromTileEntity(world, x, y, z);
byte cubeType = CubeRegistry.INSTANCE.getCubeFromBlock(block).getId();
cubeData.setCubeId(index, cubeType);
cubeData.setCubeLocation(index, (byte) ix, (byte) iy, (byte) iz);
for (int i = 0; i < 6; i++) {
cubeData.setCubeColour(index, i, c.getRed(i), c.getGreen(i), c.getBlue(i));
cubeData.setCubePaintType(index, i, c.getPaintType(i));
}
if (meta > 0) {
markerBlocks.add(new CubeMarkerData((byte) ix, (byte) iy, (byte) iz, (byte) meta));
}
}
use of riskyken.armourersWorkshop.api.common.skin.cubes.ICubeColour in project Armourers-Workshop by RiskyKen.
the class GuiMiniArmourerBuildingModel method drawBuildingCubes.
private void drawBuildingCubes(boolean fake) {
if (cubes == null) {
// return;
}
renderCubes.clear();
fakeCubeRenders = 0;
// GL11.glDisable(GL11.GL_NORMALIZE);
GL11.glDisable(GL11.GL_TEXTURE_2D);
if (fake) {
GL11.glDisable(GL11.GL_LIGHTING);
IRectangle3D guideSpace = currentSkinPartType.getGuideSpace();
for (int ix = 0; ix < guideSpace.getWidth(); ix++) {
for (int iy = 0; iy < guideSpace.getHeight(); iy++) {
for (int iz = 0; iz < guideSpace.getDepth(); iz++) {
byte x = (byte) (ix + guideSpace.getX());
byte y = (byte) (iy + guideSpace.getY());
byte z = (byte) (iz + guideSpace.getZ());
MiniCube cube = new MiniCube(CubeRegistry.INSTANCE.getCubeFormId((byte) 0));
cube.setX(x);
cube.setY(y);
cube.setZ(z);
renderCubes.add(cube);
}
}
}
fakeCubeRenders = renderCubes.size();
}
float scale = 0.0625F;
int colourId = 1;
renderCubes.addAll(cubes);
IRenderBuffer buff = RenderBridge.INSTANCE;
buff.startDrawingQuads();
for (int i = 0; i < renderCubes.size(); i++) {
MiniCube cube = renderCubes.get(i);
if (cube != null) {
if (cube.isGlowing() & !fake) {
GL11.glDisable(GL11.GL_LIGHTING);
ModRenderHelper.disableLighting();
}
ICubeColour colour = new CubeColour();
if (fake) {
colour.setColour(GuiMiniArmourerHelper.getColourFromId(colourId).getRGB(), 0);
colour.setColour(GuiMiniArmourerHelper.getColourFromId(colourId + 1).getRGB(), 1);
colour.setColour(GuiMiniArmourerHelper.getColourFromId(colourId + 2).getRGB(), 2);
colour.setColour(GuiMiniArmourerHelper.getColourFromId(colourId + 3).getRGB(), 3);
colour.setColour(GuiMiniArmourerHelper.getColourFromId(colourId + 4).getRGB(), 4);
colour.setColour(GuiMiniArmourerHelper.getColourFromId(colourId + 5).getRGB(), 5);
} else {
colour = cube.getCubeColour();
}
renderArmourBlock((byte) cube.getX(), (byte) cube.getY(), (byte) cube.getZ(), colour, scale, false);
if (cube.isGlowing() & !fake) {
ModRenderHelper.enableLighting();
GL11.glEnable(GL11.GL_LIGHTING);
}
}
colourId += 6;
}
buff.draw();
if (fake) {
GL11.glEnable(GL11.GL_LIGHTING);
}
GL11.glEnable(GL11.GL_TEXTURE_2D);
}
Aggregations