ClayLump extrudeLump(ClayLump against, EnumFacing dir) { ClayLump lump = against.copy(); Block b = FzUtil.getTraceHelper(); against.toBlockBounds(b); int wX = lump.maxX - lump.minX; int wY = lump.maxY - lump.minY; int wZ = lump.maxZ - lump.minZ; lump.maxX += wX * dir.getDirectionVec().getX(); lump.maxY += wY * dir.getDirectionVec().getY(); lump.maxZ += wZ * dir.getDirectionVec().getZ(); lump.minX += wX * dir.getDirectionVec().getX(); lump.minY += wY * dir.getDirectionVec().getY(); lump.minZ += wZ * dir.getDirectionVec().getZ(); return lump; }
public boolean isValidLump(ClayLump lump) { // check volume if (!(Core.cheat)) { int wX = lump.maxX - lump.minX; int wY = lump.maxY - lump.minY; int wZ = lump.maxZ - lump.minZ; int area = wX * wY * wZ; int max_area = 16 * 16 * 16 /* / 4 */; if (!FzConfig.stretchy_clay) { max_area /= 4; } if (area <= 0 || area > max_area) { return false; } } // check bounds final int B = 16 * 3; if (lump.minX < 0) return false; if (lump.minY < 0) return false; if (lump.minZ < 0) return false; if (lump.maxX > B) return false; if (lump.maxY > B) return false; if (lump.maxZ > B) return false; // check for free space (needs to be last, as it can mutate the world) Block block = FzUtil.getTraceHelper(); for (int dx = -1; dx <= 1; dx++) { for (int dy = -1; dy <= 1; dy++) { for (int dz = -1; dz <= 1; dz++) { AxisAlignedBB ab = new AxisAlignedBB( pos.getX() + dx, pos.getY() + dy, pos.getZ() + dz, pos.getX() + dx + 1, pos.getY() + dy + 1, pos.getZ() + dz + 1); Coord c = getCoord(); c.x += dx; c.y += dy; c.z += dz; lump.toRotatedBlockBounds(this, block); AxisAlignedBB in = block.getCollisionBoundingBox(worldObj, pos, c.getState()); if (in != null && ab.intersectsWith(in)) { // This block needs to be an Extension, or this if (c.isAir() || c.isReplacable()) { c.setId(Core.registry.legacy_factory_block); TileEntityExtension tex = new TileEntityExtension(this); c.setTE(tex); tex.getBlockClass().enforce(c); continue; } TileEntity te = c.getTE(); if (te == this) { continue; } if (te instanceof TileEntityExtension) { TileEntityExtension tex = (TileEntityExtension) te; if (tex.getParent() == this) { continue; } } // We used to not allow this. We just make a bit of noise instead. // A notification will indicate that things will be a bit messed up here. // FIXME: Let block collision boxes go outside the block (Notch hard-coded for fences) new Notice(c, "!").sendToAll(); } } } } return true; }