Search in sources :

Example 1 with TileEntityBoundingBox

use of riskyken.armourersWorkshop.common.tileentities.TileEntityBoundingBox in project Armourers-Workshop by RiskyKen.

the class BlockBoundingBox method removedByPlayer.

@Override
public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean willHarvest) {
    if (world.isRemote) {
        return true;
    }
    TileEntity tileEntity = world.getTileEntity(x, y, z);
    if (tileEntity != null && tileEntity instanceof TileEntityBoundingBox) {
        if (((TileEntityBoundingBox) tileEntity).isParentValid()) {
            tileEntity.markDirty();
            world.markBlockForUpdate(x, y, z);
            return false;
        } else {
            world.setBlockToAir(x, y, z);
            return true;
        }
    }
    world.setBlockToAir(x, y, z);
    return true;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityBoundingBox(riskyken.armourersWorkshop.common.tileentities.TileEntityBoundingBox)

Example 2 with TileEntityBoundingBox

use of riskyken.armourersWorkshop.common.tileentities.TileEntityBoundingBox in project Armourers-Workshop by RiskyKen.

the class BlockBoundingBox method setColour.

@Override
public boolean setColour(IBlockAccess world, int x, int y, int z, int colour, int side) {
    ForgeDirection sideBlock = ForgeDirection.getOrientation(side);
    if (world.getBlock(x + sideBlock.offsetX, y + sideBlock.offsetY, z + sideBlock.offsetZ) == this) {
        return false;
    }
    TileEntity te = world.getTileEntity(x, y, z);
    if (te != null && te instanceof TileEntityBoundingBox) {
        TileEntityArmourer parent = ((TileEntityBoundingBox) te).getParent();
        if (((TileEntityBoundingBox) te).getSkinPart() instanceof ISkinPartTypeTextured) {
            if (parent != null) {
                ISkinType skinType = parent.getSkinType();
                Point texturePoint = SkinTextureHelper.getTextureLocationFromWorldBlock((TileEntityBoundingBox) te, side);
                int oldColour = parent.getPaintData(texturePoint.x, texturePoint.y);
                int paintType = BitwiseUtils.getUByteFromInt(oldColour, 0);
                int newColour = BitwiseUtils.setUByteToInt(colour, 0, paintType);
                parent.updatePaintData(texturePoint.x, texturePoint.y, newColour);
                return true;
            }
        }
    }
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) ISkinType(riskyken.armourersWorkshop.api.common.skin.type.ISkinType) TileEntityArmourer(riskyken.armourersWorkshop.common.tileentities.TileEntityArmourer) TileEntityBoundingBox(riskyken.armourersWorkshop.common.tileentities.TileEntityBoundingBox) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) ISkinPartTypeTextured(riskyken.armourersWorkshop.api.common.skin.type.ISkinPartTypeTextured) Point(java.awt.Point) Point(java.awt.Point)

Example 3 with TileEntityBoundingBox

use of riskyken.armourersWorkshop.common.tileentities.TileEntityBoundingBox in project Armourers-Workshop by RiskyKen.

the class BlockBoundingBox method getColour.

@Override
public int getColour(IBlockAccess world, int x, int y, int z, int side) {
    ForgeDirection sideBlock = ForgeDirection.getOrientation(side);
    if (world.getBlock(x + sideBlock.offsetX, y + sideBlock.offsetY, z + sideBlock.offsetZ) == this) {
        return 0x00FFFFFF;
    }
    TileEntity te = world.getTileEntity(x, y, z);
    if (te != null && te instanceof TileEntityBoundingBox) {
        TileEntityArmourer parent = ((TileEntityBoundingBox) te).getParent();
        if (parent != null) {
            if (((TileEntityBoundingBox) te).getSkinPart() instanceof ISkinPartTypeTextured) {
                Point texturePoint = SkinTextureHelper.getTextureLocationFromWorldBlock((TileEntityBoundingBox) te, side);
                int colour = parent.getPaintData(texturePoint.x, texturePoint.y);
                int paintType = BitwiseUtils.getUByteFromInt(colour, 0);
                if (paintType != 0) {
                    return colour;
                } else {
                    if (te.getWorldObj().isRemote) {
                        PlayerTexture playerTexture = ClientProxy.playerTextureDownloader.getPlayerTexture(parent.getTexture());
                        BufferedImage playerSkin = SkinHelper.getBufferedImageSkin(playerTexture.getResourceLocation());
                        if (playerSkin != null) {
                            colour = playerSkin.getRGB(texturePoint.x, texturePoint.y);
                            return colour;
                        }
                    }
                }
            }
        }
    }
    return 0x00FFFFFF;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityArmourer(riskyken.armourersWorkshop.common.tileentities.TileEntityArmourer) PlayerTexture(riskyken.armourersWorkshop.client.texture.PlayerTexture) TileEntityBoundingBox(riskyken.armourersWorkshop.common.tileentities.TileEntityBoundingBox) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) ISkinPartTypeTextured(riskyken.armourersWorkshop.api.common.skin.type.ISkinPartTypeTextured) Point(java.awt.Point) Point(java.awt.Point) BufferedImage(java.awt.image.BufferedImage)

Example 4 with TileEntityBoundingBox

use of riskyken.armourersWorkshop.common.tileentities.TileEntityBoundingBox in project Armourers-Workshop by RiskyKen.

the class BlockBoundingBox method getPaintType.

@Override
public PaintType getPaintType(IBlockAccess world, int x, int y, int z, int side) {
    ForgeDirection sideBlock = ForgeDirection.getOrientation(side);
    if (world.getBlock(x + sideBlock.offsetX, y + sideBlock.offsetY, z + sideBlock.offsetZ) == this) {
        return PaintType.NORMAL;
    }
    TileEntity te = world.getTileEntity(x, y, z);
    if (te != null && te instanceof TileEntityBoundingBox) {
        TileEntityArmourer parent = ((TileEntityBoundingBox) te).getParent();
        if (parent != null) {
            if (((TileEntityBoundingBox) te).getSkinPart() instanceof ISkinPartTypeTextured) {
                Point texturePoint = SkinTextureHelper.getTextureLocationFromWorldBlock((TileEntityBoundingBox) te, side);
                int colour = parent.getPaintData(texturePoint.x, texturePoint.y);
                return PaintType.getPaintTypeFromColour(colour);
            }
        }
    }
    return PaintType.NORMAL;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityArmourer(riskyken.armourersWorkshop.common.tileentities.TileEntityArmourer) TileEntityBoundingBox(riskyken.armourersWorkshop.common.tileentities.TileEntityBoundingBox) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) ISkinPartTypeTextured(riskyken.armourersWorkshop.api.common.skin.type.ISkinPartTypeTextured) Point(java.awt.Point) Point(java.awt.Point)

Example 5 with TileEntityBoundingBox

use of riskyken.armourersWorkshop.common.tileentities.TileEntityBoundingBox in project Armourers-Workshop by RiskyKen.

the class ArmourerWorldHelper method createBoundingBoxesForSkinPart.

private static void createBoundingBoxesForSkinPart(World world, int x, int y, int z, int parentX, int parentY, int parentZ, ISkinPartType skinPart) {
    IRectangle3D buildSpace = skinPart.getBuildingSpace();
    IRectangle3D guideSpace = skinPart.getGuideSpace();
    IPoint3D offset = skinPart.getOffset();
    if (guideSpace == null) {
        return;
    }
    for (int ix = 0; ix < guideSpace.getWidth(); ix++) {
        for (int iy = 0; iy < guideSpace.getHeight(); iy++) {
            for (int iz = 0; iz < guideSpace.getDepth(); iz++) {
                int xTar = x + ix + -offset.getX() + guideSpace.getX();
                int yTar = y + iy + -offset.getY() + guideSpace.getY() - buildSpace.getY();
                int zTar = z + iz + offset.getZ() + guideSpace.getZ();
                // TODO Set skinPart to left and right legs for skirt.
                ISkinPartType guidePart = skinPart;
                byte guideX = (byte) ix;
                byte guideY = (byte) iy;
                byte guideZ = (byte) iz;
                if (world.isAirBlock(xTar, yTar, zTar)) {
                    world.setBlock(xTar, yTar, zTar, ModBlocks.boundingBox);
                    TileEntity te = null;
                    te = world.getTileEntity(xTar, yTar, zTar);
                    if (te != null && te instanceof TileEntityBoundingBox) {
                        ((TileEntityBoundingBox) te).setParent(parentX, parentY, parentZ, guideX, guideY, guideZ, guidePart);
                    } else {
                        te = new TileEntityBoundingBox(parentX, parentY, parentZ, guideX, guideY, guideZ, guidePart);
                        world.setTileEntity(xTar, yTar, zTar, te);
                    }
                }
            }
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) ISkinPartType(riskyken.armourersWorkshop.api.common.skin.type.ISkinPartType) IPoint3D(riskyken.armourersWorkshop.api.common.IPoint3D) IRectangle3D(riskyken.armourersWorkshop.api.common.IRectangle3D) TileEntityBoundingBox(riskyken.armourersWorkshop.common.tileentities.TileEntityBoundingBox)

Aggregations

TileEntity (net.minecraft.tileentity.TileEntity)7 TileEntityBoundingBox (riskyken.armourersWorkshop.common.tileentities.TileEntityBoundingBox)7 Point (java.awt.Point)5 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)5 ISkinPartTypeTextured (riskyken.armourersWorkshop.api.common.skin.type.ISkinPartTypeTextured)5 TileEntityArmourer (riskyken.armourersWorkshop.common.tileentities.TileEntityArmourer)5 ISkinType (riskyken.armourersWorkshop.api.common.skin.type.ISkinType)2 BufferedImage (java.awt.image.BufferedImage)1 IPoint3D (riskyken.armourersWorkshop.api.common.IPoint3D)1 IRectangle3D (riskyken.armourersWorkshop.api.common.IRectangle3D)1 ISkinPartType (riskyken.armourersWorkshop.api.common.skin.type.ISkinPartType)1 PlayerTexture (riskyken.armourersWorkshop.client.texture.PlayerTexture)1