use of riskyken.armourersWorkshop.common.blocks.BlockSkinnable in project Armourers-Workshop by RiskyKen.
the class TileEntitySkinnable method setBoundsOnBlock.
public void setBoundsOnBlock(Block block, int xOffset, int yOffset, int zOffset) {
if (haveBlockBounds) {
// TODO change before release!!!
// block.setBlockBounds(minX, minY, minZ, maxX, maxY, maxZ);
// return;
}
if (block != null && !(block instanceof BlockSkinnable)) {
ModLogger.log(Level.ERROR, String.format("Tile entity at X:%d Y:%d Z:%d has an invalid block.", xOffset, yOffset, zOffset));
if (worldObj != null) {
worldObj.removeTileEntity(xOffset, yOffset, zOffset);
}
return;
}
if (hasSkin()) {
BlockSkinnable blockSkinnable = (BlockSkinnable) block;
Skin skin = null;
skin = getSkin(skinPointer);
if (skin != null) {
ForgeDirection dir = blockSkinnable.getFacingDirection(getBlockMetadata());
float[] bounds = getBlockBounds(skin, xOffset, yOffset, zOffset, dir);
if (bounds != null) {
minX = bounds[0];
minY = bounds[1];
minZ = bounds[2];
maxX = bounds[3];
maxY = bounds[4];
maxZ = bounds[5];
haveBlockBounds = true;
block.setBlockBounds(minX, minY, minZ, maxX, maxY, maxZ);
}
return;
}
}
if (haveBlockBounds) {
block.setBlockBounds(minX, minY, minZ, maxX, maxY, maxZ);
} else {
block.setBlockBounds(0F, 0F, 0F, 1F, 1F, 1F);
}
}
use of riskyken.armourersWorkshop.common.blocks.BlockSkinnable in project Armourers-Workshop by RiskyKen.
the class RenderBlockSkinnable method renderTileEntityAt.
@Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTickTime) {
if (!(tileEntity instanceof TileEntitySkinnableChild)) {
renderList.add(new RenderLast(tileEntity, x, y, z));
}
if (ConfigHandlerClient.showSkinBlockBounds) {
if (!(tileEntity.getBlockType() instanceof BlockSkinnable)) {
return;
}
BlockSkinnable block = (BlockSkinnable) tileEntity.getBlockType();
block.setBlockBoundsBasedOnState(tileEntity.getWorldObj(), tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord);
double minX = block.getBlockBoundsMinX();
double minY = block.getBlockBoundsMinY();
double minZ = block.getBlockBoundsMinZ();
double maxX = block.getBlockBoundsMaxX();
double maxY = block.getBlockBoundsMaxY();
double maxZ = block.getBlockBoundsMaxZ();
float f1 = 0.002F;
AxisAlignedBB aabb = AxisAlignedBB.getBoundingBox(minX, minY, minZ, maxX, maxY, maxZ);
aabb.offset(x, y, z);
GL11.glEnable(GL11.GL_BLEND);
GL11.glDisable(GL11.GL_LIGHTING);
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
GL11.glColor4f(0.0F, 1.0F, 0.0F, 0.4F);
GL11.glLineWidth(1.0F);
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glDepthMask(false);
RenderGlobal.drawOutlinedBoundingBox(aabb.contract(f1, f1, f1), -1);
GL11.glDepthMask(true);
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_BLEND);
}
if (ConfigHandlerClient.showSkinRenderBounds) {
if ((tileEntity instanceof TileEntitySkinnableChild)) {
return;
}
float f1 = 0.002F;
AxisAlignedBB aabb = tileEntity.getRenderBoundingBox().copy();
aabb.offset(x - tileEntity.xCoord, y - tileEntity.yCoord, z - tileEntity.zCoord);
GL11.glEnable(GL11.GL_BLEND);
GL11.glDisable(GL11.GL_LIGHTING);
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
GL11.glColor4f(1.0F, 1.0F, 0.0F, 0.4F);
GL11.glLineWidth(1.0F);
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glDepthMask(false);
RenderGlobal.drawOutlinedBoundingBox(aabb.contract(f1, f1, f1), -1);
GL11.glDepthMask(true);
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_BLEND);
}
}
use of riskyken.armourersWorkshop.common.blocks.BlockSkinnable in project Armourers-Workshop by RiskyKen.
the class ItemLinkingTool method onItemUseFirst.
@Override
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
if (world.isRemote) {
return false;
}
if (!world.isRemote) {
if (!hasLinkLocation(stack)) {
Block block = world.getBlock(x, y, z);
if (!(block instanceof BlockSkinnable)) {
setLinkLocation(stack, new BlockLocation(x, y, z));
player.addChatMessage(new ChatComponentTranslation("chat.armourersworkshop:linkingTool.start", (Object) null));
return true;
} else {
player.addChatMessage(new ChatComponentTranslation("chat.armourersworkshop:linkingTool.linkedToSkinnable", (Object) null));
return true;
}
} else {
BlockLocation loc = getLinkLocation(stack);
Block block = world.getBlock(x, y, z);
if (block instanceof BlockSkinnable) {
TileEntity te = world.getTileEntity(x, y, z);
if (te != null && te instanceof TileEntitySkinnable) {
((TileEntitySkinnable) te).getParent().setLinkedBlock(loc);
player.addChatMessage(new ChatComponentTranslation("chat.armourersworkshop:linkingTool.finish", (Object) null));
removeLinkLocation(stack);
return true;
}
}
}
removeLinkLocation(stack);
player.addChatMessage(new ChatComponentTranslation("chat.armourersworkshop:linkingTool.fail", (Object) null));
}
return true;
}
use of riskyken.armourersWorkshop.common.blocks.BlockSkinnable in project Armourers-Workshop by RiskyKen.
the class ItemSkin method placeSkinAtLocation.
private boolean placeSkinAtLocation(World world, EntityPlayer player, int side, ItemStack stack, int x, int y, int z, SkinPointer skinPointer) {
if (!canPlaceSkinAtLocation(world, player, side, stack, x, y, z, skinPointer)) {
return false;
}
ForgeDirection dir = UtilPlayer.getDirectionSide(player).getOpposite();
Skin skin = SkinUtils.getSkinDetectSide(stack, false, true);
if (skin == null) {
return false;
}
BlockSkinnable targetBlock = (BlockSkinnable) ModBlocks.skinnable;
if (SkinProperties.PROP_BLOCK_GLOWING.getValue(skin.getProperties())) {
targetBlock = (BlockSkinnable) ModBlocks.skinnableGlowing;
}
int meta = targetBlock.convertDirectionToMetadata(dir);
boolean multiblock = SkinProperties.PROP_BLOCK_MULTIBLOCK.getValue(skin.getProperties());
ArrayList<BlockLocation> relatedBlocks = new ArrayList<BlockLocation>();
if (multiblock) {
if (!canPlaceChildren(world, player, side, stack, x, y, z, skin, skinPointer, relatedBlocks)) {
return false;
}
placeChildren(world, player, side, x, y, z, skin, skinPointer, relatedBlocks);
}
world.setBlock(x, y, z, targetBlock, meta, 2);
world.setTileEntity(x, y, z, ((ITileEntityProvider) targetBlock).createNewTileEntity(world, 0));
TileEntitySkinnable te = (TileEntitySkinnable) world.getTileEntity(x, y, z);
te.setSkinPointer(skin, skinPointer);
targetBlock.onBlockPlacedBy(world, x, y, z, player, stack);
targetBlock.onPostBlockPlaced(world, x, y, z, meta);
te.setRelatedBlocks(relatedBlocks);
// targetBlock.setFacingDirection(world, x, y, z, dir);
stack.stackSize--;
world.playSoundEffect((float) x + 0.5F, (float) y + 0.5F, (float) z + 0.5F, "dig.stone", 1, 1);
return true;
}
use of riskyken.armourersWorkshop.common.blocks.BlockSkinnable in project Armourers-Workshop by RiskyKen.
the class ItemSkin method placeChild.
private void placeChild(World world, EntityPlayer player, int side, int x, int y, int z, int ix, int iy, int iz, Skin skin, SkinPointer skinPointer, ArrayList<BlockLocation> relatedBlocks) {
ForgeDirection dir = UtilPlayer.getDirectionSide(player).getOpposite();
BlockSkinnable targetBlock = (BlockSkinnable) ModBlocks.skinnableChild;
int meta = targetBlock.convertDirectionToMetadata(dir);
if (SkinProperties.PROP_BLOCK_GLOWING.getValue(skin.getProperties())) {
targetBlock = (BlockSkinnable) ModBlocks.skinnableChildGlowing;
}
float[] bounds = TileEntitySkinnable.getBlockBounds(skin, -ix + 2, iy, iz, dir);
if (bounds != null) {
int childX = x;
int childY = y;
int childZ = z;
childX += ix - 1 - dir.offsetX * 1;
childY += iy;
childZ += iz - 1 - dir.offsetZ * 1;
world.setBlock(childX, childY, childZ, targetBlock, meta, 2);
world.setTileEntity(childX, childY, childZ, targetBlock.createTileEntity(world, meta));
TileEntitySkinnableChild te = (TileEntitySkinnableChild) world.getTileEntity(childX, childY, childZ);
te.setSkinPointer(skin, skinPointer);
te.setParentLocation(x, y, z);
te.setRelatedBlocks(relatedBlocks);
}
}
Aggregations