diff --git a/src/main/java/cr0s/warpdrive/WarpDrive.java b/src/main/java/cr0s/warpdrive/WarpDrive.java index 68e9ab2b..7132d8f0 100644 --- a/src/main/java/cr0s/warpdrive/WarpDrive.java +++ b/src/main/java/cr0s/warpdrive/WarpDrive.java @@ -1,15 +1,10 @@ package cr0s.warpdrive; -import cr0s.warpdrive.block.breathing.BlockAirGeneratorTiered; -import cr0s.warpdrive.block.breathing.BlockAirFlow; -import cr0s.warpdrive.block.breathing.BlockAirGenerator; import cr0s.warpdrive.block.BlockChunkLoader; import cr0s.warpdrive.block.BlockLaser; import cr0s.warpdrive.block.BlockLaserMedium; import cr0s.warpdrive.block.ItemBlockAbstractBase; import cr0s.warpdrive.block.TileEntityAbstractChunkLoading; -import cr0s.warpdrive.block.breathing.BlockAirSource; -import cr0s.warpdrive.block.breathing.TileEntityAirGenerator; import cr0s.warpdrive.block.TileEntityChunkLoader; import cr0s.warpdrive.block.TileEntityLaser; import cr0s.warpdrive.block.TileEntityLaserMedium; @@ -23,6 +18,12 @@ import cr0s.warpdrive.block.atomic.BlockVoidShellGlass; import cr0s.warpdrive.block.atomic.BlockVoidShellPlain; import cr0s.warpdrive.block.atomic.TileEntityAcceleratorControlPoint; import cr0s.warpdrive.block.atomic.TileEntityParticlesInjector; +import cr0s.warpdrive.block.breathing.BlockAirFlow; +import cr0s.warpdrive.block.breathing.BlockAirGenerator; +import cr0s.warpdrive.block.breathing.BlockAirGeneratorTiered; +import cr0s.warpdrive.block.breathing.BlockAirShield; +import cr0s.warpdrive.block.breathing.BlockAirSource; +import cr0s.warpdrive.block.breathing.TileEntityAirGenerator; import cr0s.warpdrive.block.breathing.TileEntityAirGeneratorTiered; import cr0s.warpdrive.block.building.BlockShipScanner; import cr0s.warpdrive.block.building.TileEntityShipScanner; @@ -59,6 +60,7 @@ import cr0s.warpdrive.block.forcefield.TileEntityForceField; import cr0s.warpdrive.block.forcefield.TileEntityForceFieldProjector; import cr0s.warpdrive.block.forcefield.TileEntityForceFieldRelay; import cr0s.warpdrive.block.hull.BlockHullGlass; +import cr0s.warpdrive.block.hull.BlockHullOmnipanel; import cr0s.warpdrive.block.hull.BlockHullPlain; import cr0s.warpdrive.block.hull.BlockHullSlab; import cr0s.warpdrive.block.hull.BlockHullStairs; @@ -126,6 +128,7 @@ import cr0s.warpdrive.item.ItemWarpArmor; import cr0s.warpdrive.network.PacketHandler; import cr0s.warpdrive.render.ClientCameraHandler; import cr0s.warpdrive.render.RenderBlockForceField; +import cr0s.warpdrive.render.RenderBlockOmnipanel; import cr0s.warpdrive.render.RenderBlockStandard; import cr0s.warpdrive.render.RenderOverlayAir; import cr0s.warpdrive.render.RenderOverlayCamera; @@ -212,6 +215,7 @@ public class WarpDrive implements LoadingCallback { public static Block blockAir; public static Block blockAirFlow; public static Block blockAirSource; + public static Block blockAirShield; public static Block blockGas; public static Block blockIridium; public static Block blockHighlyAdvancedMachine; @@ -232,6 +236,7 @@ public class WarpDrive implements LoadingCallback { public static BlockDecorative blockDecorative; public static Block[][] blockHulls_plain; public static Block[] blockHulls_glass; + public static Block[] blockHulls_omnipanel; public static Block[][] blockHulls_stairs; public static Block[][] blockHulls_slab; public static Block blockSiren; @@ -304,6 +309,9 @@ public class WarpDrive implements LoadingCallback { RenderBlockForceField.renderId = RenderingRegistry.getNextAvailableRenderId(); RenderingRegistry.registerBlockHandler(RenderBlockForceField.instance); + + RenderBlockOmnipanel.renderId = RenderingRegistry.getNextAvailableRenderId(); + RenderingRegistry.registerBlockHandler(RenderBlockOmnipanel.instance); } } @@ -357,10 +365,12 @@ public class WarpDrive implements LoadingCallback { blockAir = new BlockAir(); blockAirFlow = new BlockAirFlow(); blockAirSource = new BlockAirSource(); + blockAirShield = new BlockAirShield(); GameRegistry.registerBlock(blockAir, ItemBlockAbstractBase.class, "blockAir"); GameRegistry.registerBlock(blockAirFlow, ItemBlockAbstractBase.class, "blockAirFlow"); GameRegistry.registerBlock(blockAirSource, ItemBlockAbstractBase.class, "blockAirSource"); + GameRegistry.registerBlock(blockAirShield, ItemBlockAbstractBase.class, "blockAirShield"); // GAS BLOCK blockGas = new BlockGas(); @@ -566,6 +576,7 @@ public class WarpDrive implements LoadingCallback { // HULL BLOCKS blockHulls_plain = new Block[3][EnumHullPlainType.length]; blockHulls_glass = new Block[3]; + blockHulls_omnipanel = new Block[3]; blockHulls_stairs = new Block[3][16]; blockHulls_slab = new Block[3][16]; @@ -577,6 +588,8 @@ public class WarpDrive implements LoadingCallback { } blockHulls_glass[index] = new BlockHullGlass(tier); GameRegistry.registerBlock(blockHulls_glass[index], ItemBlockHull.class, "blockHull" + tier + "_glass"); + blockHulls_omnipanel[index] = new BlockHullOmnipanel(tier); + GameRegistry.registerBlock(blockHulls_omnipanel[index], ItemBlockHull.class, "blockHull" + tier + "_omnipanel"); for (int woolColor = 0; woolColor <= 15; woolColor++) { blockHulls_stairs[index][woolColor] = new BlockHullStairs(blockHulls_plain[index][0], woolColor, tier); GameRegistry.registerBlock(blockHulls_stairs[index][woolColor], ItemBlockHull.class, "blockHull" + tier + "_stairs_" + ItemDye.field_150923_a[BlockColored.func_150031_c(woolColor)]); diff --git a/src/main/java/cr0s/warpdrive/block/BlockAbstractOmnipanel.java b/src/main/java/cr0s/warpdrive/block/BlockAbstractOmnipanel.java new file mode 100644 index 00000000..3bc7987e --- /dev/null +++ b/src/main/java/cr0s/warpdrive/block/BlockAbstractOmnipanel.java @@ -0,0 +1,246 @@ +package cr0s.warpdrive.block; + +import cr0s.warpdrive.render.RenderBlockOmnipanel; + +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockPane; +import net.minecraft.block.material.Material; +import net.minecraft.entity.Entity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraftforge.common.util.ForgeDirection; + +public abstract class BlockAbstractOmnipanel extends BlockAbstractBase { + + public static final float CENTER_MIN = 7.0F / 16.0F; + public static final float CENTER_MAX = 9.0F / 16.0F; + + public BlockAbstractOmnipanel(Material material) { + super(material); + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public int getRenderType() { + return RenderBlockOmnipanel.renderId; + } + + @Override + public int getRenderBlockPass() { + return 1; + } + + @SideOnly(Side.CLIENT) + @Override + public boolean shouldSideBeRendered(IBlockAccess blockAccess, int x, int y, int z, int side) { + return blockAccess.getBlock(x, y, z) != this && super.shouldSideBeRendered(blockAccess, x, y, z, side); + } + + @Override + public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB axisAlignedBB, List list, Entity entity) { + // get direct connections + final int maskConnectY_neg = getConnectionMask(world, x, y - 1, z, ForgeDirection.DOWN); + final int maskConnectY_pos = getConnectionMask(world, x, y + 1, z, ForgeDirection.UP); + final int maskConnectZ_neg = getConnectionMask(world, x, y, z - 1, ForgeDirection.NORTH); + final int maskConnectZ_pos = getConnectionMask(world, x, y, z + 1, ForgeDirection.SOUTH); + final int maskConnectX_neg = getConnectionMask(world, x - 1, y, z, ForgeDirection.WEST); + final int maskConnectX_pos = getConnectionMask(world, x + 1, y, z, ForgeDirection.EAST); + + final boolean canConnectY_neg = maskConnectY_neg > 0; + final boolean canConnectY_pos = maskConnectY_pos > 0; + final boolean canConnectZ_neg = maskConnectZ_neg > 0; + final boolean canConnectZ_pos = maskConnectZ_pos > 0; + final boolean canConnectX_neg = maskConnectX_neg > 0; + final boolean canConnectX_pos = maskConnectX_pos > 0; + final boolean canConnectNone = !canConnectY_neg && !canConnectY_pos && !canConnectZ_neg && !canConnectZ_pos && !canConnectX_neg && !canConnectX_pos; + + // get diagonal connections + final boolean canConnectXn_Y_neg = (maskConnectX_neg > 1 && maskConnectY_neg > 1) || getConnectionMask(world, x - 1, y - 1, z, ForgeDirection.DOWN ) > 0; + final boolean canConnectXn_Y_pos = (maskConnectX_neg > 1 && maskConnectY_pos > 1) || getConnectionMask(world, x - 1, y + 1, z, ForgeDirection.UP ) > 0; + final boolean canConnectXn_Z_neg = (maskConnectX_neg > 1 && maskConnectZ_neg > 1) || getConnectionMask(world, x - 1, y, z - 1, ForgeDirection.NORTH) > 0; + final boolean canConnectXn_Z_pos = (maskConnectX_neg > 1 && maskConnectZ_pos > 1) || getConnectionMask(world, x - 1, y, z + 1, ForgeDirection.SOUTH) > 0; + final boolean canConnectZn_Y_neg = (maskConnectZ_neg > 1 && maskConnectY_neg > 1) || getConnectionMask(world, x, y - 1, z - 1, ForgeDirection.DOWN ) > 0; + final boolean canConnectZn_Y_pos = (maskConnectZ_neg > 1 && maskConnectY_pos > 1) || getConnectionMask(world, x, y + 1, z - 1, ForgeDirection.UP ) > 0; + + final boolean canConnectXp_Y_neg = (maskConnectX_pos > 1 && maskConnectY_neg > 1) || getConnectionMask(world, x + 1, y - 1, z, ForgeDirection.DOWN ) > 0; + final boolean canConnectXp_Y_pos = (maskConnectX_pos > 1 && maskConnectY_pos > 1) || getConnectionMask(world, x + 1, y + 1, z, ForgeDirection.UP ) > 0; + final boolean canConnectXp_Z_neg = (maskConnectX_pos > 1 && maskConnectZ_neg > 1) || getConnectionMask(world, x + 1, y, z - 1, ForgeDirection.NORTH) > 0; + final boolean canConnectXp_Z_pos = (maskConnectX_pos > 1 && maskConnectZ_pos > 1) || getConnectionMask(world, x + 1, y, z + 1, ForgeDirection.SOUTH) > 0; + final boolean canConnectZp_Y_neg = (maskConnectZ_pos > 1 && maskConnectY_neg > 1) || getConnectionMask(world, x, y - 1, z + 1, ForgeDirection.DOWN ) > 0; + final boolean canConnectZp_Y_pos = (maskConnectZ_pos > 1 && maskConnectY_pos > 1) || getConnectionMask(world, x, y + 1, z + 1, ForgeDirection.UP ) > 0; + + // get panels + final boolean hasXnYn = canConnectNone || (canConnectX_neg && canConnectY_neg && canConnectXn_Y_neg); + final boolean hasXpYn = canConnectNone || (canConnectX_pos && canConnectY_neg && canConnectXp_Y_neg); + final boolean hasXnYp = canConnectNone || (canConnectX_neg && canConnectY_pos && canConnectXn_Y_pos); + final boolean hasXpYp = canConnectNone || (canConnectX_pos && canConnectY_pos && canConnectXp_Y_pos); + + final boolean hasXnZn = canConnectNone || (canConnectX_neg && canConnectZ_neg && canConnectXn_Z_neg); + final boolean hasXpZn = canConnectNone || (canConnectX_pos && canConnectZ_neg && canConnectXp_Z_neg); + final boolean hasXnZp = canConnectNone || (canConnectX_neg && canConnectZ_pos && canConnectXn_Z_pos); + final boolean hasXpZp = canConnectNone || (canConnectX_pos && canConnectZ_pos && canConnectXp_Z_pos); + + final boolean hasZnYn = canConnectNone || (canConnectZ_neg && canConnectY_neg && canConnectZn_Y_neg); + final boolean hasZpYn = canConnectNone || (canConnectZ_pos && canConnectY_neg && canConnectZp_Y_neg); + final boolean hasZnYp = canConnectNone || (canConnectZ_neg && canConnectY_pos && canConnectZn_Y_pos); + final boolean hasZpYp = canConnectNone || (canConnectZ_pos && canConnectY_pos && canConnectZp_Y_pos); + + {// z plane + if (hasXnYn) { + setBlockBounds(0.0F, 0.0F, CENTER_MIN, CENTER_MAX, CENTER_MAX, CENTER_MAX); + super.addCollisionBoxesToList(world, x, y, z, axisAlignedBB, list, entity); + } + + if (hasXpYn) { + setBlockBounds(CENTER_MIN, 0.0F, CENTER_MIN, 1.0F, CENTER_MAX, CENTER_MAX); + super.addCollisionBoxesToList(world, x, y, z, axisAlignedBB, list, entity); + } + + if (hasXnYp) { + setBlockBounds(0.0F, CENTER_MIN, CENTER_MIN, CENTER_MAX, 1.0F, CENTER_MAX); + super.addCollisionBoxesToList(world, x, y, z, axisAlignedBB, list, entity); + } + + if (hasXpYp) { + setBlockBounds(CENTER_MIN, CENTER_MIN, CENTER_MIN, 1.0F, 1.0F, CENTER_MAX); + super.addCollisionBoxesToList(world, x, y, z, axisAlignedBB, list, entity); + } + } + + {// x plane + if (hasZnYn) { + setBlockBounds(CENTER_MIN, 0.0F, 0.0F, CENTER_MAX, CENTER_MAX, CENTER_MAX); + super.addCollisionBoxesToList(world, x, y, z, axisAlignedBB, list, entity); + } + + if (hasZpYn) { + setBlockBounds(CENTER_MIN, 0.0F, CENTER_MIN, CENTER_MAX, CENTER_MAX, 1.0F); + super.addCollisionBoxesToList(world, x, y, z, axisAlignedBB, list, entity); + } + + if (hasZnYp) { + setBlockBounds(CENTER_MIN, CENTER_MIN, 0.0F, CENTER_MAX, 1.0F, CENTER_MAX); + super.addCollisionBoxesToList(world, x, y, z, axisAlignedBB, list, entity); + } + + if (hasZpYp) { + setBlockBounds(CENTER_MIN, CENTER_MIN, CENTER_MIN, CENTER_MAX, 1.0F, 1.0F); + super.addCollisionBoxesToList(world, x, y, z, axisAlignedBB, list, entity); + } + } + + {// z plane + if (hasXnZn) { + setBlockBounds(0.0F, CENTER_MIN, 0.0F, CENTER_MAX, CENTER_MAX, CENTER_MAX); + super.addCollisionBoxesToList(world, x, y, z, axisAlignedBB, list, entity); + } + + if (hasXpZn) { + setBlockBounds(CENTER_MIN, CENTER_MIN, 0.0F, 1.0F, CENTER_MAX, CENTER_MAX); + super.addCollisionBoxesToList(world, x, y, z, axisAlignedBB, list, entity); + } + + if (hasXnZp) { + setBlockBounds(0.0F, CENTER_MIN, CENTER_MIN, CENTER_MAX, CENTER_MAX, 1.0F); + super.addCollisionBoxesToList(world, x, y, z, axisAlignedBB, list, entity); + } + + if (hasXpZp) { + setBlockBounds(CENTER_MIN, CENTER_MIN, CENTER_MIN, 1.0F, CENTER_MAX, 1.0F); + super.addCollisionBoxesToList(world, x, y, z, axisAlignedBB, list, entity); + } + } + + // central nodes + if (canConnectY_neg && !hasXnYn && !hasXpYn && !hasZnYn && !hasZpYn) { + setBlockBounds(CENTER_MIN, 0.0F, CENTER_MIN, CENTER_MAX, CENTER_MAX, CENTER_MAX); + super.addCollisionBoxesToList(world, x, y, z, axisAlignedBB, list, entity); + } + if (canConnectY_pos && !hasXnYp && !hasXpYp && !hasZnYp && !hasZpYp) { + setBlockBounds(CENTER_MIN, CENTER_MIN, CENTER_MIN, CENTER_MAX, 1.0F, CENTER_MAX); + super.addCollisionBoxesToList(world, x, y, z, axisAlignedBB, list, entity); + } + if (canConnectZ_neg && !hasXnZn && !hasXpZn && !hasZnYn && !hasZnYp) { + setBlockBounds(CENTER_MIN, CENTER_MIN, 0.0F, CENTER_MAX, CENTER_MAX, CENTER_MAX); + super.addCollisionBoxesToList(world, x, y, z, axisAlignedBB, list, entity); + } + if (canConnectZ_pos && !hasXnZp && !hasXpZp && !hasZpYn && !hasZpYp) { + setBlockBounds(CENTER_MIN, CENTER_MIN, CENTER_MIN, CENTER_MAX, CENTER_MAX, 1.0F); + super.addCollisionBoxesToList(world, x, y, z, axisAlignedBB, list, entity); + } + if (canConnectX_neg && !hasXnYn && !hasXnYp && !hasXnZn && !hasXnZp) { + setBlockBounds(0.0F, CENTER_MIN, CENTER_MIN, CENTER_MAX, CENTER_MAX, CENTER_MAX); + super.addCollisionBoxesToList(world, x, y, z, axisAlignedBB, list, entity); + } + if (canConnectX_pos && !hasXpYn && !hasXpYp && !hasXpZn && !hasXpZp) { + setBlockBounds(CENTER_MIN, CENTER_MIN, CENTER_MIN, 1.0F, CENTER_MAX, CENTER_MAX); + super.addCollisionBoxesToList(world, x, y, z, axisAlignedBB, list, entity); + } + } + + @Override + public void setBlockBoundsForItemRender() { + setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + } + + @Override + public void setBlockBoundsBasedOnState(IBlockAccess blockAccess, int x, int y, int z) { + // get direct connections + final int maskConnectY_neg = getConnectionMask(blockAccess, x, y - 1, z, ForgeDirection.DOWN); + final int maskConnectY_pos = getConnectionMask(blockAccess, x, y + 1, z, ForgeDirection.UP); + final int maskConnectZ_neg = getConnectionMask(blockAccess, x, y, z - 1, ForgeDirection.NORTH); + final int maskConnectZ_pos = getConnectionMask(blockAccess, x, y, z + 1, ForgeDirection.SOUTH); + final int maskConnectX_neg = getConnectionMask(blockAccess, x - 1, y, z, ForgeDirection.WEST); + final int maskConnectX_pos = getConnectionMask(blockAccess, x + 1, y, z, ForgeDirection.EAST); + + final boolean canConnectY_neg = maskConnectY_neg > 0; + final boolean canConnectY_pos = maskConnectY_pos > 0; + final boolean canConnectZ_neg = maskConnectZ_neg > 0; + final boolean canConnectZ_pos = maskConnectZ_pos > 0; + final boolean canConnectX_neg = maskConnectX_neg > 0; + final boolean canConnectX_pos = maskConnectX_pos > 0; + final boolean canConnectNone = !canConnectY_neg && !canConnectY_pos && !canConnectZ_neg && !canConnectZ_pos && !canConnectX_neg && !canConnectX_pos; + + // x axis + final float xMin = canConnectNone || canConnectX_neg ? 0.0F : CENTER_MIN; + final float xMax = canConnectNone || canConnectX_pos ? 1.0F : CENTER_MAX; + + // y axis + final float yMin = canConnectNone || canConnectY_neg ? 0.0F : CENTER_MIN; + final float yMax = canConnectNone || canConnectY_pos ? 1.0F : CENTER_MAX; + + // z axis + final float zMin = canConnectNone || canConnectZ_neg ? 0.0F : CENTER_MIN; + final float zMax = canConnectNone || canConnectZ_pos ? 1.0F : CENTER_MAX; + + setBlockBounds(xMin, yMin, zMin, xMax, yMax, zMax); + } + + @Override + protected boolean canSilkHarvest() + { + return true; + } + + public int getConnectionMask(IBlockAccess world, int x, int y, int z, ForgeDirection forgeDirection) { + final Block block = world.getBlock(x, y, z); + return (block.func_149730_j() || block == this || block.getMaterial() == Material.glass || block instanceof BlockPane ? 1 : 0) + + (block.isSideSolid(world, x, y, z, forgeDirection.getOpposite()) ? 2 : 0); + } +} \ No newline at end of file diff --git a/src/main/java/cr0s/warpdrive/block/breathing/BlockAirShield.java b/src/main/java/cr0s/warpdrive/block/breathing/BlockAirShield.java new file mode 100644 index 00000000..ff9ea9e5 --- /dev/null +++ b/src/main/java/cr0s/warpdrive/block/breathing/BlockAirShield.java @@ -0,0 +1,64 @@ +package cr0s.warpdrive.block.breathing; + +import cr0s.warpdrive.block.BlockAbstractOmnipanel; + +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class BlockAirShield extends BlockAbstractOmnipanel { + + public BlockAirShield() { + super(Material.cloth); + setBlockName("warpdrive.breathing.air_shield"); + } + + @SideOnly(Side.CLIENT) + @Override + public void registerBlockIcons(final IIconRegister iconRegister) { + blockIcon = iconRegister.registerIcon("warpdrive:breathing/air_shield"); + } + + @Override + public int damageDropped(final int metadata) { + return metadata; + } + + @Override + public int getRenderColor(final int metadata) { + switch (metadata) { + case 1: + return 0xFF5A02; // orange + case 5: + return 0x90E801; // lime green + case 6: + return 0xFB0680; // pink + case 9: + default: + return 0x0FD7FF; // SciFi cyan + case 10: + return 0x5D1072; // purple + } + } + + @Override + public int colorMultiplier(final IBlockAccess blockAccess, final int x, final int y, final int z) { + final int metadata = blockAccess.getBlockMetadata(x, y, z); + return getRenderColor(metadata); + } + + @Override + public AxisAlignedBB getCollisionBoundingBoxFromPool(final World world, final int x, final int y, final int z) { + return null; + } + + @Override + public boolean canCollideCheck(final int metadata, final boolean hitIfLiquid) { + return !hitIfLiquid; + } +} \ No newline at end of file diff --git a/src/main/java/cr0s/warpdrive/block/hull/BlockHullOmnipanel.java b/src/main/java/cr0s/warpdrive/block/hull/BlockHullOmnipanel.java new file mode 100644 index 00000000..7937fd3d --- /dev/null +++ b/src/main/java/cr0s/warpdrive/block/hull/BlockHullOmnipanel.java @@ -0,0 +1,111 @@ +package cr0s.warpdrive.block.hull; + +import cr0s.warpdrive.WarpDrive; +import cr0s.warpdrive.api.IDamageReceiver; +import cr0s.warpdrive.block.BlockAbstractOmnipanel; +import cr0s.warpdrive.config.WarpDriveConfig; +import cr0s.warpdrive.data.Vector3; + +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.block.material.MapColor; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemDye; +import net.minecraft.item.ItemStack; +import net.minecraft.util.DamageSource; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class BlockHullOmnipanel extends BlockAbstractOmnipanel implements IDamageReceiver { + + @SideOnly(Side.CLIENT) + private IIcon[] icons; + + final byte tier; + + public BlockHullOmnipanel(final byte tier) { + super(Material.glass); + this.tier = tier; + setHardness(WarpDriveConfig.HULL_HARDNESS[tier - 1]); + setResistance(WarpDriveConfig.HULL_BLAST_RESISTANCE[tier - 1] * 5 / 3); + setStepSound(Block.soundTypeGlass); + setBlockName("warpdrive.hull" + tier + ".omnipanel."); + setBlockTextureName("warpdrive:hull/glass"); + setLightLevel(10.0F / 15.0F); + } + + @Override + public int getMobilityFlag() { + return 2; + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(final int side, final int metadata) { + return icons[metadata % 16]; + } + + @Override + public int damageDropped(final int metadata) { + return metadata; + } + + public static String getDyeColorName(final int metadata) { + return ItemDye.field_150921_b[~metadata & 15]; + } + + @Override + @SideOnly(Side.CLIENT) + public void getSubBlocks(Item item, CreativeTabs creativeTab, List list) { + for (int i = 0; i < 16; ++i) { + list.add(new ItemStack(item, 1, i)); + } + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister iconRegister) { + icons = new IIcon[16]; + + for (int i = 0; i < 16; i++) { + icons[i] = iconRegister.registerIcon(getTextureName() + "_" + getDyeColorName(i)); + } + } + + @Override + public MapColor getMapColor(int metadata) { + return MapColor.getMapColorForBlockColored(metadata); + } + + @Override + public byte getTier(ItemStack itemStack) { + return tier; + } + + @Override + public float getBlockHardness(World world, int x, int y, int z, DamageSource damageSource, int damageParameter, Vector3 damageDirection, int damageLevel) { + // TODO: adjust hardness to damage type/color + return WarpDriveConfig.HULL_HARDNESS[tier - 1]; + } + + @Override + public int applyDamage(World world, int x, int y, int z, DamageSource damageSource, int damageParameter, Vector3 damageDirection, int damageLevel) { + if (damageLevel <= 0) { + return 0; + } + if (tier == 1) { + world.setBlockToAir(x, y, z); + } else { + int metadata = world.getBlockMetadata(x, y, z); + world.setBlock(x, y, z, WarpDrive.blockHulls_omnipanel[tier - 2], metadata, 2); + } + return 0; + } +} \ No newline at end of file diff --git a/src/main/java/cr0s/warpdrive/data/StateAir.java b/src/main/java/cr0s/warpdrive/data/StateAir.java index 7f21669b..23770fd3 100644 --- a/src/main/java/cr0s/warpdrive/data/StateAir.java +++ b/src/main/java/cr0s/warpdrive/data/StateAir.java @@ -2,6 +2,7 @@ package cr0s.warpdrive.data; import cr0s.warpdrive.Commons; import cr0s.warpdrive.WarpDrive; +import cr0s.warpdrive.block.BlockAbstractOmnipanel; import cr0s.warpdrive.block.breathing.BlockAirFlow; import cr0s.warpdrive.block.breathing.BlockAirSource; import cr0s.warpdrive.config.WarpDriveConfig; @@ -214,6 +215,9 @@ public class StateAir { } else if (block.isNormalCube()) { typeBlock = BLOCK_SEALER; + } else if (block instanceof BlockAbstractOmnipanel) { + typeBlock = BLOCK_SEALER; + } else if (block instanceof BlockStaticLiquid || block instanceof BlockDynamicLiquid) {// vanilla liquid (water & lava sources or flowing) // metadata = 0 for source, 8/9 for vertical flow // 2 superposed sources would still be 0, so we can't use metadata. Instead, we're testing explicitly the block above diff --git a/src/main/java/cr0s/warpdrive/render/RenderBlockOmnipanel.java b/src/main/java/cr0s/warpdrive/render/RenderBlockOmnipanel.java new file mode 100644 index 00000000..d8370872 --- /dev/null +++ b/src/main/java/cr0s/warpdrive/render/RenderBlockOmnipanel.java @@ -0,0 +1,568 @@ +package cr0s.warpdrive.render; + +import cr0s.warpdrive.block.BlockAbstractOmnipanel; + +import net.minecraft.block.Block; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; + +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; + +import net.minecraftforge.common.util.ForgeDirection; + +public class RenderBlockOmnipanel implements ISimpleBlockRenderingHandler { + + public static int renderId = 0; + public static RenderBlockOmnipanel instance = new RenderBlockOmnipanel(); + + @Override + public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { + // not supposed to happen + } + + @Override + public boolean renderWorldBlock(IBlockAccess blockAccess, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { + final Tessellator tessellator = Tessellator.instance; + tessellator.setBrightness(block.getMixedBrightnessForBlock(blockAccess, x, y, z)); + + // apply coloring + final int colorMultiplier = block.colorMultiplier(blockAccess, x, y, z); + final float fRed = (float) (colorMultiplier >> 16 & 255) / 255.0F; + final float fGreen = (float) (colorMultiplier >> 8 & 255) / 255.0F; + final float fBlue = (float) (colorMultiplier & 255) / 255.0F; + tessellator.setColorOpaque_F(fRed, fGreen, fBlue); + + // get icon + final int metadata = blockAccess.getBlockMetadata(x, y, z); + final IIcon icon = block.getIcon(0, metadata); + + // pre-compute coordinates + final double dX_min = (double) x; + final double dX_max = x + 1; + final double dY_min = y + 0.0D; + final double dY_max = y + 1.0D; + final double dZ_min = (double) z; + final double dZ_max = z + 1; + final double dX_neg = x + BlockAbstractOmnipanel.CENTER_MIN; + final double dX_pos = x + BlockAbstractOmnipanel.CENTER_MAX; + final double dY_neg = y + BlockAbstractOmnipanel.CENTER_MIN; + final double dY_pos = y + BlockAbstractOmnipanel.CENTER_MAX; + final double dZ_neg = z + BlockAbstractOmnipanel.CENTER_MIN; + final double dZ_pos = z + BlockAbstractOmnipanel.CENTER_MAX; + + final double dU_min = icon.getMinU(); + final double dU_neg = icon.getInterpolatedU(7.0D); + final double dU_pos = icon.getInterpolatedU(9.0D); + final double dU_max = icon.getMaxU(); + + final double dV_min = icon.getMinV(); + final double dV_neg = icon.getInterpolatedV(7.0D); + final double dV_pos = icon.getInterpolatedV(9.0D); + final double dV_max = icon.getMaxV(); + + // get direct connections + BlockAbstractOmnipanel blockAbstractOmnipanel = (BlockAbstractOmnipanel) block; + final int maskConnectY_neg = blockAbstractOmnipanel.getConnectionMask(blockAccess, x, y - 1, z, ForgeDirection.DOWN); + final int maskConnectY_pos = blockAbstractOmnipanel.getConnectionMask(blockAccess, x, y + 1, z, ForgeDirection.UP); + final int maskConnectZ_neg = blockAbstractOmnipanel.getConnectionMask(blockAccess, x, y, z - 1, ForgeDirection.NORTH); + final int maskConnectZ_pos = blockAbstractOmnipanel.getConnectionMask(blockAccess, x, y, z + 1, ForgeDirection.SOUTH); + final int maskConnectX_neg = blockAbstractOmnipanel.getConnectionMask(blockAccess, x - 1, y, z, ForgeDirection.WEST); + final int maskConnectX_pos = blockAbstractOmnipanel.getConnectionMask(blockAccess, x + 1, y, z, ForgeDirection.EAST); + + final boolean canConnectY_neg = maskConnectY_neg > 0; + final boolean canConnectY_pos = maskConnectY_pos > 0; + final boolean canConnectZ_neg = maskConnectZ_neg > 0; + final boolean canConnectZ_pos = maskConnectZ_pos > 0; + final boolean canConnectX_neg = maskConnectX_neg > 0; + final boolean canConnectX_pos = maskConnectX_pos > 0; + final boolean canConnectNone = !canConnectY_neg && !canConnectY_pos && !canConnectZ_neg && !canConnectZ_pos && !canConnectX_neg && !canConnectX_pos; + + // get diagonal connections + final boolean canConnectXn_Y_neg = (maskConnectX_neg > 1 && maskConnectY_neg > 1) || blockAbstractOmnipanel.getConnectionMask(blockAccess, x - 1, y - 1, z, ForgeDirection.DOWN ) > 0; + final boolean canConnectXn_Y_pos = (maskConnectX_neg > 1 && maskConnectY_pos > 1) || blockAbstractOmnipanel.getConnectionMask(blockAccess, x - 1, y + 1, z, ForgeDirection.UP ) > 0; + final boolean canConnectXn_Z_neg = (maskConnectX_neg > 1 && maskConnectZ_neg > 1) || blockAbstractOmnipanel.getConnectionMask(blockAccess, x - 1, y, z - 1, ForgeDirection.NORTH) > 0; + final boolean canConnectXn_Z_pos = (maskConnectX_neg > 1 && maskConnectZ_pos > 1) || blockAbstractOmnipanel.getConnectionMask(blockAccess, x - 1, y, z + 1, ForgeDirection.SOUTH) > 0; + final boolean canConnectZn_Y_neg = (maskConnectZ_neg > 1 && maskConnectY_neg > 1) || blockAbstractOmnipanel.getConnectionMask(blockAccess, x, y - 1, z - 1, ForgeDirection.DOWN ) > 0; + final boolean canConnectZn_Y_pos = (maskConnectZ_neg > 1 && maskConnectY_pos > 1) || blockAbstractOmnipanel.getConnectionMask(blockAccess, x, y + 1, z - 1, ForgeDirection.UP ) > 0; + + final boolean canConnectXp_Y_neg = (maskConnectX_pos > 1 && maskConnectY_neg > 1) || blockAbstractOmnipanel.getConnectionMask(blockAccess, x + 1, y - 1, z, ForgeDirection.DOWN ) > 0; + final boolean canConnectXp_Y_pos = (maskConnectX_pos > 1 && maskConnectY_pos > 1) || blockAbstractOmnipanel.getConnectionMask(blockAccess, x + 1, y + 1, z, ForgeDirection.UP ) > 0; + final boolean canConnectXp_Z_neg = (maskConnectX_pos > 1 && maskConnectZ_neg > 1) || blockAbstractOmnipanel.getConnectionMask(blockAccess, x + 1, y, z - 1, ForgeDirection.NORTH) > 0; + final boolean canConnectXp_Z_pos = (maskConnectX_pos > 1 && maskConnectZ_pos > 1) || blockAbstractOmnipanel.getConnectionMask(blockAccess, x + 1, y, z + 1, ForgeDirection.SOUTH) > 0; + final boolean canConnectZp_Y_neg = (maskConnectZ_pos > 1 && maskConnectY_neg > 1) || blockAbstractOmnipanel.getConnectionMask(blockAccess, x, y - 1, z + 1, ForgeDirection.DOWN ) > 0; + final boolean canConnectZp_Y_pos = (maskConnectZ_pos > 1 && maskConnectY_pos > 1) || blockAbstractOmnipanel.getConnectionMask(blockAccess, x, y + 1, z + 1, ForgeDirection.UP ) > 0; + + // get panels + final boolean hasXnYn = canConnectNone || (canConnectX_neg && canConnectY_neg && canConnectXn_Y_neg); + final boolean hasXpYn = canConnectNone || (canConnectX_pos && canConnectY_neg && canConnectXp_Y_neg); + final boolean hasXnYp = canConnectNone || (canConnectX_neg && canConnectY_pos && canConnectXn_Y_pos); + final boolean hasXpYp = canConnectNone || (canConnectX_pos && canConnectY_pos && canConnectXp_Y_pos); + + final boolean hasXnZn = canConnectNone || (canConnectX_neg && canConnectZ_neg && canConnectXn_Z_neg); + final boolean hasXpZn = canConnectNone || (canConnectX_pos && canConnectZ_neg && canConnectXp_Z_neg); + final boolean hasXnZp = canConnectNone || (canConnectX_neg && canConnectZ_pos && canConnectXn_Z_pos); + final boolean hasXpZp = canConnectNone || (canConnectX_pos && canConnectZ_pos && canConnectXp_Z_pos); + + final boolean hasZnYn = canConnectNone || (canConnectZ_neg && canConnectY_neg && canConnectZn_Y_neg); + final boolean hasZpYn = canConnectNone || (canConnectZ_pos && canConnectY_neg && canConnectZp_Y_neg); + final boolean hasZnYp = canConnectNone || (canConnectZ_neg && canConnectY_pos && canConnectZn_Y_pos); + final boolean hasZpYp = canConnectNone || (canConnectZ_pos && canConnectY_pos && canConnectZp_Y_pos); + + {// z plane + if (hasXnYn) { + tessellator.addVertexWithUV(dX_neg, dY_neg, dZ_neg, dU_neg, dV_pos); + tessellator.addVertexWithUV(dX_neg, dY_min, dZ_neg, dU_neg, dV_max); + tessellator.addVertexWithUV(dX_min, dY_min, dZ_neg, dU_min, dV_max); + tessellator.addVertexWithUV(dX_min, dY_neg, dZ_neg, dU_min, dV_pos); + + tessellator.addVertexWithUV(dX_min, dY_neg, dZ_pos, dU_min, dV_pos); + tessellator.addVertexWithUV(dX_min, dY_min, dZ_pos, dU_min, dV_max); + tessellator.addVertexWithUV(dX_neg, dY_min, dZ_pos, dU_neg, dV_max); + tessellator.addVertexWithUV(dX_neg, dY_neg, dZ_pos, dU_neg, dV_pos); + } else { + if (canConnectX_neg) { + tessellator.addVertexWithUV(dX_neg, dY_neg, dZ_neg, dU_neg, dV_pos); + tessellator.addVertexWithUV(dX_neg, dY_neg, dZ_pos, dU_neg, dV_neg); + tessellator.addVertexWithUV(dX_min, dY_neg, dZ_pos, dU_min, dV_neg); + tessellator.addVertexWithUV(dX_min, dY_neg, dZ_neg, dU_min, dV_pos); + } + if (canConnectY_neg) { + tessellator.addVertexWithUV(dX_neg, dY_neg, dZ_neg, dU_neg, dV_pos); + tessellator.addVertexWithUV(dX_neg, dY_min, dZ_neg, dU_neg, dV_max); + tessellator.addVertexWithUV(dX_neg, dY_min, dZ_pos, dU_pos, dV_max); + tessellator.addVertexWithUV(dX_neg, dY_neg, dZ_pos, dU_pos, dV_pos); + } + } + + if (hasXpYn) { + tessellator.addVertexWithUV(dX_max, dY_neg, dZ_neg, dU_max, dV_pos); + tessellator.addVertexWithUV(dX_max, dY_min, dZ_neg, dU_max, dV_max); + tessellator.addVertexWithUV(dX_pos, dY_min, dZ_neg, dU_pos, dV_max); + tessellator.addVertexWithUV(dX_pos, dY_neg, dZ_neg, dU_pos, dV_pos); + + tessellator.addVertexWithUV(dX_pos, dY_neg, dZ_pos, dU_pos, dV_pos); + tessellator.addVertexWithUV(dX_pos, dY_min, dZ_pos, dU_pos, dV_max); + tessellator.addVertexWithUV(dX_max, dY_min, dZ_pos, dU_max, dV_max); + tessellator.addVertexWithUV(dX_max, dY_neg, dZ_pos, dU_max, dV_pos); + } else { + if (canConnectX_pos) { + tessellator.addVertexWithUV(dX_max, dY_neg, dZ_neg, dU_max, dV_pos); + tessellator.addVertexWithUV(dX_max, dY_neg, dZ_pos, dU_max, dV_neg); + tessellator.addVertexWithUV(dX_pos, dY_neg, dZ_pos, dU_pos, dV_neg); + tessellator.addVertexWithUV(dX_pos, dY_neg, dZ_neg, dU_pos, dV_pos); + } + if (canConnectY_neg) { + tessellator.addVertexWithUV(dX_pos, dY_neg, dZ_pos, dU_pos, dV_pos); + tessellator.addVertexWithUV(dX_pos, dY_min, dZ_pos, dU_pos, dV_max); + tessellator.addVertexWithUV(dX_pos, dY_min, dZ_neg, dU_neg, dV_max); + tessellator.addVertexWithUV(dX_pos, dY_neg, dZ_neg, dU_neg, dV_pos); + } + } + + if (hasXnYp) { + tessellator.addVertexWithUV(dX_neg, dY_max, dZ_neg, dU_neg, dV_min); + tessellator.addVertexWithUV(dX_neg, dY_pos, dZ_neg, dU_neg, dV_neg); + tessellator.addVertexWithUV(dX_min, dY_pos, dZ_neg, dU_min, dV_neg); + tessellator.addVertexWithUV(dX_min, dY_max, dZ_neg, dU_min, dV_min); + + tessellator.addVertexWithUV(dX_min, dY_max, dZ_pos, dU_min, dV_min); + tessellator.addVertexWithUV(dX_min, dY_pos, dZ_pos, dU_min, dV_neg); + tessellator.addVertexWithUV(dX_neg, dY_pos, dZ_pos, dU_neg, dV_neg); + tessellator.addVertexWithUV(dX_neg, dY_max, dZ_pos, dU_neg, dV_min); + } else { + if (canConnectX_neg) { + tessellator.addVertexWithUV(dX_neg, dY_pos, dZ_pos, dU_neg, dV_neg); + tessellator.addVertexWithUV(dX_neg, dY_pos, dZ_neg, dU_neg, dV_pos); + tessellator.addVertexWithUV(dX_min, dY_pos, dZ_neg, dU_min, dV_pos); + tessellator.addVertexWithUV(dX_min, dY_pos, dZ_pos, dU_min, dV_neg); + } + if (canConnectY_pos) { + tessellator.addVertexWithUV(dX_neg, dY_pos, dZ_pos, dU_pos, dV_neg); + tessellator.addVertexWithUV(dX_neg, dY_max, dZ_pos, dU_pos, dV_min); + tessellator.addVertexWithUV(dX_neg, dY_max, dZ_neg, dU_neg, dV_min); + tessellator.addVertexWithUV(dX_neg, dY_pos, dZ_neg, dU_neg, dV_neg); + } + } + + if (hasXpYp) { + tessellator.addVertexWithUV(dX_max, dY_max, dZ_neg, dU_max, dV_min); + tessellator.addVertexWithUV(dX_max, dY_pos, dZ_neg, dU_max, dV_neg); + tessellator.addVertexWithUV(dX_pos, dY_pos, dZ_neg, dU_pos, dV_neg); + tessellator.addVertexWithUV(dX_pos, dY_max, dZ_neg, dU_pos, dV_min); + + tessellator.addVertexWithUV(dX_pos, dY_max, dZ_pos, dU_pos, dV_min); + tessellator.addVertexWithUV(dX_pos, dY_pos, dZ_pos, dU_pos, dV_neg); + tessellator.addVertexWithUV(dX_max, dY_pos, dZ_pos, dU_max, dV_neg); + tessellator.addVertexWithUV(dX_max, dY_max, dZ_pos, dU_max, dV_min); + } else { + if (canConnectX_pos) { + tessellator.addVertexWithUV(dX_pos, dY_pos, dZ_neg, dU_pos, dV_pos); + tessellator.addVertexWithUV(dX_pos, dY_pos, dZ_pos, dU_pos, dV_neg); + tessellator.addVertexWithUV(dX_max, dY_pos, dZ_pos, dU_max, dV_neg); + tessellator.addVertexWithUV(dX_max, dY_pos, dZ_neg, dU_max, dV_pos); + } + if (canConnectY_pos) { + tessellator.addVertexWithUV(dX_pos, dY_pos, dZ_neg, dU_neg, dV_neg); + tessellator.addVertexWithUV(dX_pos, dY_max, dZ_neg, dU_neg, dV_min); + tessellator.addVertexWithUV(dX_pos, dY_max, dZ_pos, dU_pos, dV_min); + tessellator.addVertexWithUV(dX_pos, dY_pos, dZ_pos, dU_pos, dV_neg); + } + } + } + + {// x plane + if (hasZnYn) { + tessellator.addVertexWithUV(dX_neg, dY_neg, dZ_min, dU_min, dV_pos); + tessellator.addVertexWithUV(dX_neg, dY_min, dZ_min, dU_min, dV_max); + tessellator.addVertexWithUV(dX_neg, dY_min, dZ_neg, dU_neg, dV_max); + tessellator.addVertexWithUV(dX_neg, dY_neg, dZ_neg, dU_neg, dV_pos); + + tessellator.addVertexWithUV(dX_pos, dY_neg, dZ_neg, dU_neg, dV_pos); + tessellator.addVertexWithUV(dX_pos, dY_min, dZ_neg, dU_neg, dV_max); + tessellator.addVertexWithUV(dX_pos, dY_min, dZ_min, dU_min, dV_max); + tessellator.addVertexWithUV(dX_pos, dY_neg, dZ_min, dU_min, dV_pos); + } else { + if (canConnectZ_neg) { + tessellator.addVertexWithUV(dX_neg, dY_neg, dZ_min, dU_neg, dV_max); + tessellator.addVertexWithUV(dX_pos, dY_neg, dZ_min, dU_pos, dV_max); + tessellator.addVertexWithUV(dX_pos, dY_neg, dZ_neg, dU_pos, dV_pos); + tessellator.addVertexWithUV(dX_neg, dY_neg, dZ_neg, dU_neg, dV_pos); + } + if (canConnectY_neg) { + tessellator.addVertexWithUV(dX_pos, dY_neg, dZ_neg, dU_pos, dV_pos); + tessellator.addVertexWithUV(dX_pos, dY_min, dZ_neg, dU_pos, dV_max); + tessellator.addVertexWithUV(dX_neg, dY_min, dZ_neg, dU_neg, dV_max); + tessellator.addVertexWithUV(dX_neg, dY_neg, dZ_neg, dU_neg, dV_pos); + } + } + + if (hasZpYn) { + tessellator.addVertexWithUV(dX_neg, dY_neg, dZ_pos, dU_pos, dV_pos); + tessellator.addVertexWithUV(dX_neg, dY_min, dZ_pos, dU_pos, dV_max); + tessellator.addVertexWithUV(dX_neg, dY_min, dZ_max, dU_max, dV_max); + tessellator.addVertexWithUV(dX_neg, dY_neg, dZ_max, dU_max, dV_pos); + + tessellator.addVertexWithUV(dX_pos, dY_neg, dZ_max, dU_max, dV_pos); + tessellator.addVertexWithUV(dX_pos, dY_min, dZ_max, dU_max, dV_max); + tessellator.addVertexWithUV(dX_pos, dY_min, dZ_pos, dU_pos, dV_max); + tessellator.addVertexWithUV(dX_pos, dY_neg, dZ_pos, dU_pos, dV_pos); + } else { + if (canConnectZ_pos) { + tessellator.addVertexWithUV(dX_neg, dY_neg, dZ_pos, dU_neg, dV_neg); + tessellator.addVertexWithUV(dX_pos, dY_neg, dZ_pos, dU_pos, dV_neg); + tessellator.addVertexWithUV(dX_pos, dY_neg, dZ_max, dU_pos, dV_min); + tessellator.addVertexWithUV(dX_neg, dY_neg, dZ_max, dU_neg, dV_min); + } + if (canConnectY_neg) { + tessellator.addVertexWithUV(dX_neg, dY_neg, dZ_pos, dU_neg, dV_pos); + tessellator.addVertexWithUV(dX_neg, dY_min, dZ_pos, dU_neg, dV_max); + tessellator.addVertexWithUV(dX_pos, dY_min, dZ_pos, dU_pos, dV_max); + tessellator.addVertexWithUV(dX_pos, dY_neg, dZ_pos, dU_pos, dV_pos); + } + } + + if (hasZnYp) { + tessellator.addVertexWithUV(dX_neg, dY_max, dZ_min, dU_min, dV_min); + tessellator.addVertexWithUV(dX_neg, dY_pos, dZ_min, dU_min, dV_neg); + tessellator.addVertexWithUV(dX_neg, dY_pos, dZ_neg, dU_neg, dV_neg); + tessellator.addVertexWithUV(dX_neg, dY_max, dZ_neg, dU_neg, dV_min); + + tessellator.addVertexWithUV(dX_pos, dY_max, dZ_neg, dU_neg, dV_min); + tessellator.addVertexWithUV(dX_pos, dY_pos, dZ_neg, dU_neg, dV_neg); + tessellator.addVertexWithUV(dX_pos, dY_pos, dZ_min, dU_min, dV_neg); + tessellator.addVertexWithUV(dX_pos, dY_max, dZ_min, dU_min, dV_min); + } else { + if (canConnectZ_neg) { + tessellator.addVertexWithUV(dX_pos, dY_pos, dZ_min, dU_pos, dV_max); + tessellator.addVertexWithUV(dX_neg, dY_pos, dZ_min, dU_neg, dV_max); + tessellator.addVertexWithUV(dX_neg, dY_pos, dZ_neg, dU_neg, dV_pos); + tessellator.addVertexWithUV(dX_pos, dY_pos, dZ_neg, dU_pos, dV_pos); + } + if (canConnectY_pos) { + tessellator.addVertexWithUV(dX_neg, dY_pos, dZ_neg, dU_neg, dV_neg); + tessellator.addVertexWithUV(dX_neg, dY_max, dZ_neg, dU_neg, dV_min); + tessellator.addVertexWithUV(dX_pos, dY_max, dZ_neg, dU_pos, dV_min); + tessellator.addVertexWithUV(dX_pos, dY_pos, dZ_neg, dU_pos, dV_neg); + } + } + + if (hasZpYp) { + tessellator.addVertexWithUV(dX_neg, dY_max, dZ_pos, dU_pos, dV_min); + tessellator.addVertexWithUV(dX_neg, dY_pos, dZ_pos, dU_pos, dV_neg); + tessellator.addVertexWithUV(dX_neg, dY_pos, dZ_max, dU_max, dV_neg); + tessellator.addVertexWithUV(dX_neg, dY_max, dZ_max, dU_max, dV_min); + + tessellator.addVertexWithUV(dX_pos, dY_max, dZ_max, dU_max, dV_min); + tessellator.addVertexWithUV(dX_pos, dY_pos, dZ_max, dU_max, dV_neg); + tessellator.addVertexWithUV(dX_pos, dY_pos, dZ_pos, dU_pos, dV_neg); + tessellator.addVertexWithUV(dX_pos, dY_max, dZ_pos, dU_pos, dV_min); + } else { + if (canConnectZ_pos) { + tessellator.addVertexWithUV(dX_neg, dY_pos, dZ_max, dU_neg, dV_min); + tessellator.addVertexWithUV(dX_pos, dY_pos, dZ_max, dU_pos, dV_min); + tessellator.addVertexWithUV(dX_pos, dY_pos, dZ_pos, dU_pos, dV_neg); + tessellator.addVertexWithUV(dX_neg, dY_pos, dZ_pos, dU_neg, dV_neg); + } + if (canConnectY_pos) { + tessellator.addVertexWithUV(dX_pos, dY_pos, dZ_pos, dU_pos, dV_neg); + tessellator.addVertexWithUV(dX_pos, dY_max, dZ_pos, dU_pos, dV_min); + tessellator.addVertexWithUV(dX_neg, dY_max, dZ_pos, dU_neg, dV_min); + tessellator.addVertexWithUV(dX_neg, dY_pos, dZ_pos, dU_neg, dV_neg); + } + } + } + + {// z plane + if (hasXnZn) { + tessellator.addVertexWithUV(dX_min, dY_neg, dZ_neg, dU_min, dV_pos); + tessellator.addVertexWithUV(dX_min, dY_neg, dZ_min, dU_min, dV_max); + tessellator.addVertexWithUV(dX_neg, dY_neg, dZ_min, dU_neg, dV_max); + tessellator.addVertexWithUV(dX_neg, dY_neg, dZ_neg, dU_neg, dV_pos); + + tessellator.addVertexWithUV(dX_neg, dY_pos, dZ_neg, dU_neg, dV_pos); + tessellator.addVertexWithUV(dX_neg, dY_pos, dZ_min, dU_neg, dV_max); + tessellator.addVertexWithUV(dX_min, dY_pos, dZ_min, dU_min, dV_max); + tessellator.addVertexWithUV(dX_min, dY_pos, dZ_neg, dU_min, dV_pos); + } else { + if (canConnectX_neg) { + tessellator.addVertexWithUV(dX_min, dY_neg, dZ_neg, dU_min, dV_pos); + tessellator.addVertexWithUV(dX_min, dY_pos, dZ_neg, dU_min, dV_neg); + tessellator.addVertexWithUV(dX_neg, dY_pos, dZ_neg, dU_neg, dV_neg); + tessellator.addVertexWithUV(dX_neg, dY_neg, dZ_neg, dU_neg, dV_pos); + } + if (canConnectZ_neg) { + tessellator.addVertexWithUV(dX_neg, dY_pos, dZ_neg, dU_neg, dV_neg); + tessellator.addVertexWithUV(dX_neg, dY_pos, dZ_min, dU_min, dV_neg); + tessellator.addVertexWithUV(dX_neg, dY_neg, dZ_min, dU_min, dV_pos); + tessellator.addVertexWithUV(dX_neg, dY_neg, dZ_neg, dU_neg, dV_pos); + } + } + + if (hasXpZn) { + tessellator.addVertexWithUV(dX_pos, dY_neg, dZ_neg, dU_pos, dV_pos); + tessellator.addVertexWithUV(dX_pos, dY_neg, dZ_min, dU_pos, dV_max); + tessellator.addVertexWithUV(dX_max, dY_neg, dZ_min, dU_max, dV_max); + tessellator.addVertexWithUV(dX_max, dY_neg, dZ_neg, dU_max, dV_pos); + + tessellator.addVertexWithUV(dX_max, dY_pos, dZ_neg, dU_max, dV_pos); + tessellator.addVertexWithUV(dX_max, dY_pos, dZ_min, dU_max, dV_max); + tessellator.addVertexWithUV(dX_pos, dY_pos, dZ_min, dU_pos, dV_max); + tessellator.addVertexWithUV(dX_pos, dY_pos, dZ_neg, dU_pos, dV_pos); + } else { + if (canConnectX_pos) { + tessellator.addVertexWithUV(dX_pos, dY_neg, dZ_neg, dU_pos, dV_pos); + tessellator.addVertexWithUV(dX_pos, dY_pos, dZ_neg, dU_pos, dV_neg); + tessellator.addVertexWithUV(dX_max, dY_pos, dZ_neg, dU_max, dV_neg); + tessellator.addVertexWithUV(dX_max, dY_neg, dZ_neg, dU_max, dV_pos); + } + if (canConnectZ_neg) { + tessellator.addVertexWithUV(dX_pos, dY_neg, dZ_neg, dU_neg, dV_pos); + tessellator.addVertexWithUV(dX_pos, dY_neg, dZ_min, dU_min, dV_pos); + tessellator.addVertexWithUV(dX_pos, dY_pos, dZ_min, dU_min, dV_neg); + tessellator.addVertexWithUV(dX_pos, dY_pos, dZ_neg, dU_neg, dV_neg); + } + } + + if (hasXnZp) { + tessellator.addVertexWithUV(dX_min, dY_neg, dZ_max, dU_min, dV_min); + tessellator.addVertexWithUV(dX_min, dY_neg, dZ_pos, dU_min, dV_neg); + tessellator.addVertexWithUV(dX_neg, dY_neg, dZ_pos, dU_neg, dV_neg); + tessellator.addVertexWithUV(dX_neg, dY_neg, dZ_max, dU_neg, dV_min); + + tessellator.addVertexWithUV(dX_neg, dY_pos, dZ_max, dU_neg, dV_min); + tessellator.addVertexWithUV(dX_neg, dY_pos, dZ_pos, dU_neg, dV_neg); + tessellator.addVertexWithUV(dX_min, dY_pos, dZ_pos, dU_min, dV_neg); + tessellator.addVertexWithUV(dX_min, dY_pos, dZ_max, dU_min, dV_min); + } else { + if (canConnectX_neg) { + tessellator.addVertexWithUV(dX_min, dY_pos, dZ_pos, dU_min, dV_neg); + tessellator.addVertexWithUV(dX_min, dY_neg, dZ_pos, dU_min, dV_pos); + tessellator.addVertexWithUV(dX_neg, dY_neg, dZ_pos, dU_neg, dV_pos); + tessellator.addVertexWithUV(dX_neg, dY_pos, dZ_pos, dU_neg, dV_neg); + } + if (canConnectZ_pos) { + tessellator.addVertexWithUV(dX_neg, dY_neg, dZ_pos, dU_pos, dV_pos); + tessellator.addVertexWithUV(dX_neg, dY_neg, dZ_max, dU_max, dV_pos); + tessellator.addVertexWithUV(dX_neg, dY_pos, dZ_max, dU_max, dV_neg); + tessellator.addVertexWithUV(dX_neg, dY_pos, dZ_pos, dU_pos, dV_neg); + } + } + + if (hasXpZp) { + tessellator.addVertexWithUV(dX_pos, dY_neg, dZ_max, dU_pos, dV_min); + tessellator.addVertexWithUV(dX_pos, dY_neg, dZ_pos, dU_pos, dV_neg); + tessellator.addVertexWithUV(dX_max, dY_neg, dZ_pos, dU_max, dV_neg); + tessellator.addVertexWithUV(dX_max, dY_neg, dZ_max, dU_max, dV_min); + + tessellator.addVertexWithUV(dX_max, dY_pos, dZ_max, dU_max, dV_min); + tessellator.addVertexWithUV(dX_max, dY_pos, dZ_pos, dU_max, dV_neg); + tessellator.addVertexWithUV(dX_pos, dY_pos, dZ_pos, dU_pos, dV_neg); + tessellator.addVertexWithUV(dX_pos, dY_pos, dZ_max, dU_pos, dV_min); + } else { + if (canConnectX_pos) { + tessellator.addVertexWithUV(dX_max, dY_neg, dZ_pos, dU_max, dV_pos); + tessellator.addVertexWithUV(dX_max, dY_pos, dZ_pos, dU_max, dV_neg); + tessellator.addVertexWithUV(dX_pos, dY_pos, dZ_pos, dU_pos, dV_neg); + tessellator.addVertexWithUV(dX_pos, dY_neg, dZ_pos, dU_pos, dV_pos); + } + if (canConnectZ_pos) { + tessellator.addVertexWithUV(dX_pos, dY_pos, dZ_pos, dU_pos, dV_neg); + tessellator.addVertexWithUV(dX_pos, dY_pos, dZ_max, dU_max, dV_neg); + tessellator.addVertexWithUV(dX_pos, dY_neg, dZ_max, dU_max, dV_pos); + tessellator.addVertexWithUV(dX_pos, dY_neg, dZ_pos, dU_pos, dV_pos); + } + } + } + + if (canConnectNone) { + // x min + tessellator.addVertexWithUV(dX_min, dY_max, dZ_neg, dU_neg, dV_min); + tessellator.addVertexWithUV(dX_min, dY_min, dZ_neg, dU_neg, dV_max); + tessellator.addVertexWithUV(dX_min, dY_min, dZ_pos, dU_pos, dV_max); + tessellator.addVertexWithUV(dX_min, dY_max, dZ_pos, dU_pos, dV_min); + + tessellator.addVertexWithUV(dX_min, dY_pos, dZ_max, dU_max, dV_neg); + tessellator.addVertexWithUV(dX_min, dY_pos, dZ_pos, dU_pos, dV_neg); + tessellator.addVertexWithUV(dX_min, dY_neg, dZ_pos, dU_pos, dV_pos); + tessellator.addVertexWithUV(dX_min, dY_neg, dZ_max, dU_max, dV_pos); + + tessellator.addVertexWithUV(dX_min, dY_pos, dZ_neg, dU_neg, dV_neg); + tessellator.addVertexWithUV(dX_min, dY_pos, dZ_min, dU_min, dV_neg); + tessellator.addVertexWithUV(dX_min, dY_neg, dZ_min, dU_min, dV_pos); + tessellator.addVertexWithUV(dX_min, dY_neg, dZ_neg, dU_neg, dV_pos); + + // x max + tessellator.addVertexWithUV(dX_max, dY_max, dZ_pos, dU_pos, dV_min); + tessellator.addVertexWithUV(dX_max, dY_min, dZ_pos, dU_pos, dV_max); + tessellator.addVertexWithUV(dX_max, dY_min, dZ_neg, dU_neg, dV_max); + tessellator.addVertexWithUV(dX_max, dY_max, dZ_neg, dU_neg, dV_min); + + tessellator.addVertexWithUV(dX_max, dY_neg, dZ_max, dU_max, dV_pos); + tessellator.addVertexWithUV(dX_max, dY_neg, dZ_pos, dU_pos, dV_pos); + tessellator.addVertexWithUV(dX_max, dY_pos, dZ_pos, dU_pos, dV_neg); + tessellator.addVertexWithUV(dX_max, dY_pos, dZ_max, dU_max, dV_neg); + + tessellator.addVertexWithUV(dX_max, dY_neg, dZ_neg, dU_neg, dV_pos); + tessellator.addVertexWithUV(dX_max, dY_neg, dZ_min, dU_min, dV_pos); + tessellator.addVertexWithUV(dX_max, dY_pos, dZ_min, dU_min, dV_neg); + tessellator.addVertexWithUV(dX_max, dY_pos, dZ_neg, dU_neg, dV_neg); + + // z min + tessellator.addVertexWithUV(dX_pos, dY_max, dZ_min, dU_pos, dV_min); + tessellator.addVertexWithUV(dX_pos, dY_min, dZ_min, dU_pos, dV_max); + tessellator.addVertexWithUV(dX_neg, dY_min, dZ_min, dU_neg, dV_max); + tessellator.addVertexWithUV(dX_neg, dY_max, dZ_min, dU_neg, dV_min); + + tessellator.addVertexWithUV(dX_neg, dY_pos, dZ_min, dU_neg, dV_neg); + tessellator.addVertexWithUV(dX_neg, dY_neg, dZ_min, dU_neg, dV_pos); + tessellator.addVertexWithUV(dX_min, dY_neg, dZ_min, dU_min, dV_pos); + tessellator.addVertexWithUV(dX_min, dY_pos, dZ_min, dU_min, dV_neg); + + tessellator.addVertexWithUV(dX_max, dY_pos, dZ_min, dU_max, dV_neg); + tessellator.addVertexWithUV(dX_max, dY_neg, dZ_min, dU_max, dV_pos); + tessellator.addVertexWithUV(dX_pos, dY_neg, dZ_min, dU_pos, dV_pos); + tessellator.addVertexWithUV(dX_pos, dY_pos, dZ_min, dU_pos, dV_neg); + + // z max + tessellator.addVertexWithUV(dX_neg, dY_max, dZ_max, dU_neg, dV_min); + tessellator.addVertexWithUV(dX_neg, dY_min, dZ_max, dU_neg, dV_max); + tessellator.addVertexWithUV(dX_pos, dY_min, dZ_max, dU_pos, dV_max); + tessellator.addVertexWithUV(dX_pos, dY_max, dZ_max, dU_pos, dV_min); + + tessellator.addVertexWithUV(dX_min, dY_pos, dZ_max, dU_min, dV_neg); + tessellator.addVertexWithUV(dX_min, dY_neg, dZ_max, dU_min, dV_pos); + tessellator.addVertexWithUV(dX_neg, dY_neg, dZ_max, dU_neg, dV_pos); + tessellator.addVertexWithUV(dX_neg, dY_pos, dZ_max, dU_neg, dV_neg); + + tessellator.addVertexWithUV(dX_pos, dY_pos, dZ_max, dU_pos, dV_neg); + tessellator.addVertexWithUV(dX_pos, dY_neg, dZ_max, dU_pos, dV_pos); + tessellator.addVertexWithUV(dX_max, dY_neg, dZ_max, dU_max, dV_pos); + tessellator.addVertexWithUV(dX_max, dY_pos, dZ_max, dU_max, dV_neg); + + // y min + tessellator.addVertexWithUV(dX_neg, dY_min, dZ_max, dU_neg, dV_min); + tessellator.addVertexWithUV(dX_neg, dY_min, dZ_min, dU_neg, dV_max); + tessellator.addVertexWithUV(dX_pos, dY_min, dZ_min, dU_pos, dV_max); + tessellator.addVertexWithUV(dX_pos, dY_min, dZ_max, dU_pos, dV_min); + + tessellator.addVertexWithUV(dX_min, dY_min, dZ_pos, dU_min, dV_neg); + tessellator.addVertexWithUV(dX_min, dY_min, dZ_neg, dU_min, dV_pos); + tessellator.addVertexWithUV(dX_neg, dY_min, dZ_neg, dU_neg, dV_pos); + tessellator.addVertexWithUV(dX_neg, dY_min, dZ_pos, dU_neg, dV_neg); + + tessellator.addVertexWithUV(dX_pos, dY_min, dZ_pos, dU_pos, dV_neg); + tessellator.addVertexWithUV(dX_pos, dY_min, dZ_neg, dU_pos, dV_pos); + tessellator.addVertexWithUV(dX_max, dY_min, dZ_neg, dU_max, dV_pos); + tessellator.addVertexWithUV(dX_max, dY_min, dZ_pos, dU_max, dV_neg); + + // y max + tessellator.addVertexWithUV(dX_pos, dY_max, dZ_max, dU_pos, dV_min); + tessellator.addVertexWithUV(dX_pos, dY_max, dZ_min, dU_pos, dV_max); + tessellator.addVertexWithUV(dX_neg, dY_max, dZ_min, dU_neg, dV_max); + tessellator.addVertexWithUV(dX_neg, dY_max, dZ_max, dU_neg, dV_min); + + tessellator.addVertexWithUV(dX_neg, dY_max, dZ_pos, dU_neg, dV_neg); + tessellator.addVertexWithUV(dX_neg, dY_max, dZ_neg, dU_neg, dV_pos); + tessellator.addVertexWithUV(dX_min, dY_max, dZ_neg, dU_min, dV_pos); + tessellator.addVertexWithUV(dX_min, dY_max, dZ_pos, dU_min, dV_neg); + + tessellator.addVertexWithUV(dX_max, dY_max, dZ_pos, dU_max, dV_neg); + tessellator.addVertexWithUV(dX_max, dY_max, dZ_neg, dU_max, dV_pos); + tessellator.addVertexWithUV(dX_pos, dY_max, dZ_neg, dU_pos, dV_pos); + tessellator.addVertexWithUV(dX_pos, dY_max, dZ_pos, dU_pos, dV_neg); + } else { + + // center cube + if (!canConnectY_neg) { + tessellator.addVertexWithUV(dX_neg, dY_neg, dZ_neg, dU_neg, dV_pos); + tessellator.addVertexWithUV(dX_pos, dY_neg, dZ_neg, dU_neg, dV_neg); + tessellator.addVertexWithUV(dX_pos, dY_neg, dZ_pos, dU_pos, dV_neg); + tessellator.addVertexWithUV(dX_neg, dY_neg, dZ_pos, dU_pos, dV_pos); + } + if (!canConnectY_pos) { + tessellator.addVertexWithUV(dX_neg, dY_pos, dZ_pos, dU_pos, dV_pos); + tessellator.addVertexWithUV(dX_pos, dY_pos, dZ_pos, dU_pos, dV_neg); + tessellator.addVertexWithUV(dX_pos, dY_pos, dZ_neg, dU_neg, dV_neg); + tessellator.addVertexWithUV(dX_neg, dY_pos, dZ_neg, dU_neg, dV_pos); + } + if (!canConnectZ_neg) { + tessellator.addVertexWithUV(dX_neg, dY_neg, dZ_neg, dU_neg, dV_pos); + tessellator.addVertexWithUV(dX_neg, dY_pos, dZ_neg, dU_neg, dV_neg); + tessellator.addVertexWithUV(dX_pos, dY_pos, dZ_neg, dU_pos, dV_neg); + tessellator.addVertexWithUV(dX_pos, dY_neg, dZ_neg, dU_pos, dV_pos); + } + if (!canConnectZ_pos) { + tessellator.addVertexWithUV(dX_pos, dY_neg, dZ_pos, dU_pos, dV_pos); + tessellator.addVertexWithUV(dX_pos, dY_pos, dZ_pos, dU_pos, dV_neg); + tessellator.addVertexWithUV(dX_neg, dY_pos, dZ_pos, dU_neg, dV_neg); + tessellator.addVertexWithUV(dX_neg, dY_neg, dZ_pos, dU_neg, dV_pos); + } + if (!canConnectX_neg) { + tessellator.addVertexWithUV(dX_neg, dY_neg, dZ_neg, dU_neg, dV_pos); + tessellator.addVertexWithUV(dX_neg, dY_neg, dZ_pos, dU_neg, dV_neg); + tessellator.addVertexWithUV(dX_neg, dY_pos, dZ_pos, dU_pos, dV_neg); + tessellator.addVertexWithUV(dX_neg, dY_pos, dZ_neg, dU_pos, dV_pos); + } + if (!canConnectX_pos) { + tessellator.addVertexWithUV(dX_pos, dY_pos, dZ_neg, dU_pos, dV_pos); + tessellator.addVertexWithUV(dX_pos, dY_pos, dZ_pos, dU_pos, dV_neg); + tessellator.addVertexWithUV(dX_pos, dY_neg, dZ_pos, dU_neg, dV_neg); + tessellator.addVertexWithUV(dX_pos, dY_neg, dZ_neg, dU_neg, dV_pos); + } + } + + return true; + } + + @Override + public boolean shouldRender3DInInventory(int modelId) { + return false; + } + + @Override + public int getRenderId() { + return renderId; + } +}