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;
}
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;
}
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;
}
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;
}
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);
}
}
}
}
}
}
Aggregations