Search in sources :

Example 1 with IPantableBlock

use of riskyken.armourersWorkshop.api.common.painting.IPantableBlock 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);
    }
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) ICubeColour(riskyken.armourersWorkshop.api.common.skin.cubes.ICubeColour) IPantableBlock(riskyken.armourersWorkshop.api.common.painting.IPantableBlock)

Example 2 with IPantableBlock

use of riskyken.armourersWorkshop.api.common.painting.IPantableBlock in project Armourers-Workshop by RiskyKen.

the class PlayerUndoData method undoLast.

@SuppressWarnings("deprecation")
private void undoLast(World world) {
    if (undos.size() < 1) {
        return;
    }
    UndoData undoData = undos.get(undos.size() - 1);
    if (world.provider.dimensionId != undoData.dimensionId) {
        return;
    }
    Block block = world.getBlock(undoData.blockX, undoData.blockY, undoData.blockZ);
    if (block instanceof IPantableBlock) {
        Color c = new Color(undoData.rgb[0] & 0xFF, undoData.rgb[1] & 0xFF, undoData.rgb[2] & 0xFF);
        int rgb = c.getRGB();
        IPantableBlock worldColourable = (IPantableBlock) block;
        worldColourable.setColour(world, undoData.blockX, undoData.blockY, undoData.blockZ, rgb, undoData.side);
        worldColourable.setPaintType(world, undoData.blockX, undoData.blockY, undoData.blockZ, PaintType.getPaintTypeFormSKey(undoData.paintType), undoData.side);
    }
    undos.remove(undos.size() - 1);
}
Also used : Color(java.awt.Color) Block(net.minecraft.block.Block) IPantableBlock(riskyken.armourersWorkshop.api.common.painting.IPantableBlock) IPantableBlock(riskyken.armourersWorkshop.api.common.painting.IPantableBlock)

Example 3 with IPantableBlock

use of riskyken.armourersWorkshop.api.common.painting.IPantableBlock in project Armourers-Workshop by RiskyKen.

the class TileEntityArmourer method applyToolToBlocks.

private void applyToolToBlocks(IBlockPainter tool, World world, ItemStack stack, EntityPlayer player) {
    if (skinType != null) {
        ArrayList<BlockLocation> paintableCubes = ArmourerWorldHelper.getListOfPaintableCubes(worldObj, xCoord, yCoord + getHeightOffset(), zCoord, skinType);
        for (int i = 0; i < paintableCubes.size(); i++) {
            BlockLocation bl = paintableCubes.get(i);
            IPantableBlock pBlock = (IPantableBlock) worldObj.getBlock(bl.x, bl.y, bl.z);
            Block block = world.getBlock(bl.x, bl.y, bl.z);
            if (block instanceof IPantableBlock) {
                for (int side = 0; side < 6; side++) {
                    tool.usedOnBlockSide(stack, player, world, bl, block, side);
                }
            }
        }
    }
}
Also used : Block(net.minecraft.block.Block) IPantableBlock(riskyken.armourersWorkshop.api.common.painting.IPantableBlock) BlockLocation(riskyken.armourersWorkshop.common.blocks.BlockLocation) IPantableBlock(riskyken.armourersWorkshop.api.common.painting.IPantableBlock)

Example 4 with IPantableBlock

use of riskyken.armourersWorkshop.api.common.painting.IPantableBlock 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);
        }
    }
}
Also used : Color(java.awt.Color) ICubeColour(riskyken.armourersWorkshop.api.common.skin.cubes.ICubeColour) Block(net.minecraft.block.Block) IPantableBlock(riskyken.armourersWorkshop.api.common.painting.IPantableBlock) BlockLocation(riskyken.armourersWorkshop.common.blocks.BlockLocation) IPantableBlock(riskyken.armourersWorkshop.api.common.painting.IPantableBlock)

Example 5 with IPantableBlock

use of riskyken.armourersWorkshop.api.common.painting.IPantableBlock in project Armourers-Workshop by RiskyKen.

the class ItemColourNoiseTool method onItemUse.

@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
    Block block = world.getBlock(x, y, z);
    if (!player.isSneaking() & block instanceof IPantableBlock) {
        if (!world.isRemote) {
            UndoManager.begin(player);
        }
        if ((Boolean) ToolOptions.FULL_BLOCK_MODE.readFromNBT(stack.getTagCompound())) {
            for (int i = 0; i < 6; i++) {
                usedOnBlockSide(stack, player, world, new BlockLocation(x, y, z), block, i);
            }
        } else {
            usedOnBlockSide(stack, player, world, new BlockLocation(x, y, z), block, side);
        }
        if (!world.isRemote) {
            UndoManager.end(player);
            world.playSoundEffect(x + 0.5D, y + 0.5D, z + 0.5D, LibSounds.BURN, 1.0F, 1.0F);
        }
        return true;
    }
    if (block == ModBlocks.armourerBrain & player.isSneaking()) {
        if (!world.isRemote) {
            TileEntity te = world.getTileEntity(x, y, z);
            if (te != null && te instanceof TileEntityArmourer) {
                ((TileEntityArmourer) te).toolUsedOnArmourer(this, world, stack, player);
            }
        }
        return true;
    }
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityArmourer(riskyken.armourersWorkshop.common.tileentities.TileEntityArmourer) MessageClientToolPaintBlock(riskyken.armourersWorkshop.common.network.messages.client.MessageClientToolPaintBlock) Block(net.minecraft.block.Block) IPantableBlock(riskyken.armourersWorkshop.api.common.painting.IPantableBlock) BlockLocation(riskyken.armourersWorkshop.common.blocks.BlockLocation) IPantableBlock(riskyken.armourersWorkshop.api.common.painting.IPantableBlock)

Aggregations

IPantableBlock (riskyken.armourersWorkshop.api.common.painting.IPantableBlock)22 Block (net.minecraft.block.Block)14 PaintType (riskyken.armourersWorkshop.common.painting.PaintType)12 MessageClientToolPaintBlock (riskyken.armourersWorkshop.common.network.messages.client.MessageClientToolPaintBlock)10 TileEntity (net.minecraft.tileentity.TileEntity)9 BlockLocation (riskyken.armourersWorkshop.common.blocks.BlockLocation)9 Color (java.awt.Color)8 TileEntityArmourer (riskyken.armourersWorkshop.common.tileentities.TileEntityArmourer)8 IPantable (riskyken.armourersWorkshop.api.common.painting.IPantable)4 ICubeColour (riskyken.armourersWorkshop.api.common.skin.cubes.ICubeColour)2 Tessellator (net.minecraft.client.renderer.Tessellator)1 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1 World (net.minecraft.world.World)1 BlockBoundingBox (riskyken.armourersWorkshop.common.blocks.BlockBoundingBox)1 BlockMannequin (riskyken.armourersWorkshop.common.blocks.BlockMannequin)1 MessageClientGuiToolOptionUpdate (riskyken.armourersWorkshop.common.network.messages.client.MessageClientGuiToolOptionUpdate)1 TileEntityMannequin (riskyken.armourersWorkshop.common.tileentities.TileEntityMannequin)1