mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
fluid duct agony
This commit is contained in:
parent
fdcf09abfb
commit
b05384f2e5
18
src/main/java/com/hbm/blocks/IBlockMultiPass.java
Normal file
18
src/main/java/com/hbm/blocks/IBlockMultiPass.java
Normal file
@ -0,0 +1,18 @@
|
||||
package com.hbm.blocks;
|
||||
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
public interface IBlockMultiPass {
|
||||
|
||||
public int getPasses();
|
||||
|
||||
public int getColorFromPass(IBlockAccess world, int x, int y, int z, boolean inv);
|
||||
|
||||
public static int renderID = RenderingRegistry.getNextAvailableRenderId();
|
||||
public static int getRenderType() {
|
||||
return renderID;
|
||||
}
|
||||
|
||||
}
|
||||
@ -706,6 +706,7 @@ public class ModBlocks {
|
||||
public static Block gas_duct_solid;
|
||||
public static Block gas_duct;
|
||||
public static Block fluid_duct;
|
||||
public static Block fluid_duct_solid;
|
||||
|
||||
public static Block conveyor;
|
||||
|
||||
@ -1800,6 +1801,7 @@ public class ModBlocks {
|
||||
gas_duct_solid = new GasDuctSolid(Material.iron).setBlockName("gas_duct_solid").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":gas_duct_solid");
|
||||
gas_duct = new BlockGasDuct(Material.iron).setBlockName("gas_duct").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":gas_duct_icon");
|
||||
fluid_duct = new BlockFluidDuct(Material.iron).setBlockName("fluid_duct").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":fluid_duct_icon");
|
||||
fluid_duct_solid = new BlockFluidDuctSolid(Material.iron).setBlockName("fluid_duct_solid").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":fluid_duct_solid");
|
||||
conveyor = new BlockConveyor(Material.iron).setBlockName("conveyor").setHardness(0.0F).setResistance(2.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":conveyor");
|
||||
|
||||
chain = new BlockChain(Material.iron).setBlockName("dungeon_chain").setHardness(0.25F).setResistance(2.0F).setCreativeTab(MainRegistry.blockTab).setBlockTextureName(RefStrings.MODID + ":chain");
|
||||
@ -2880,6 +2882,7 @@ public class ModBlocks {
|
||||
GameRegistry.registerBlock(gas_duct, gas_duct.getUnlocalizedName());
|
||||
GameRegistry.registerBlock(gas_duct_solid, gas_duct_solid.getUnlocalizedName());
|
||||
GameRegistry.registerBlock(fluid_duct, fluid_duct.getUnlocalizedName());
|
||||
GameRegistry.registerBlock(fluid_duct_solid, fluid_duct_solid.getUnlocalizedName());
|
||||
GameRegistry.registerBlock(conveyor, conveyor.getUnlocalizedName());
|
||||
GameRegistry.registerBlock(chain, chain.getUnlocalizedName());
|
||||
|
||||
|
||||
@ -0,0 +1,71 @@
|
||||
package com.hbm.blocks.network;
|
||||
|
||||
import com.hbm.blocks.IBlockMultiPass;
|
||||
import com.hbm.inventory.fluid.Fluids;
|
||||
import com.hbm.render.block.RenderBlockMultipass;
|
||||
import com.hbm.tileentity.conductor.TileEntityFluidDuctSimple;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockFluidDuctSolid extends BlockContainer implements IBlockMultiPass {
|
||||
|
||||
public BlockFluidDuctSolid(Material mat) {
|
||||
super(mat);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int meta) {
|
||||
return new TileEntityFluidDuctSimple();
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IIcon overlay;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister p_149651_1_) {
|
||||
this.blockIcon = p_149651_1_.registerIcon(this.getTextureName());
|
||||
this.overlay = p_149651_1_.registerIcon(this.getTextureName() + "_overlay");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPasses() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int side, int meta) {
|
||||
return RenderBlockMultipass.currentPass == 0 ? this.blockIcon : this.overlay;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType(){
|
||||
return IBlockMultiPass.getRenderType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColorFromPass(IBlockAccess world, int x, int y, int z, boolean inv) {
|
||||
|
||||
if(RenderBlockMultipass.currentPass == 0)
|
||||
return 0xffffff;
|
||||
|
||||
if(inv)
|
||||
return Fluids.NONE.getColor();
|
||||
|
||||
TileEntityFluidDuctSimple te = (TileEntityFluidDuctSimple) world.getTileEntity(x, y, z);
|
||||
|
||||
if(te != null) {
|
||||
return te.getType().getColor();
|
||||
}
|
||||
|
||||
return 0xffffff;
|
||||
}
|
||||
}
|
||||
@ -3,7 +3,8 @@ package com.hbm.interfaces;
|
||||
import com.hbm.inventory.fluid.FluidType;
|
||||
|
||||
public interface IFluidDuct {
|
||||
|
||||
|
||||
public FluidType getType();
|
||||
public boolean setType(FluidType type);
|
||||
|
||||
}
|
||||
|
||||
@ -123,7 +123,7 @@ public class ItemFluidDuct extends Item {
|
||||
world.setBlock(x, y, z, ModBlocks.fluid_duct);
|
||||
|
||||
if(world.getTileEntity(x, y, z) instanceof TileEntityFluidDuct) {
|
||||
((TileEntityFluidDuct) world.getTileEntity(x, y, z)).type = Fluids.fromID(stack.getItemDamage());
|
||||
((TileEntityFluidDuct) world.getTileEntity(x, y, z)).setType(Fluids.fromID(stack.getItemDamage()));
|
||||
}
|
||||
|
||||
world.playSoundEffect(x, y, z, "hbm:block.pipePlaced", 1.0F, 0.65F + world.rand.nextFloat() * 0.2F);
|
||||
|
||||
@ -9,6 +9,7 @@ import com.hbm.inventory.fluid.FluidType;
|
||||
import com.hbm.inventory.fluid.Fluids;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.tileentity.conductor.TileEntityFluidDuct;
|
||||
import com.hbm.tileentity.conductor.TileEntityFluidDuctSimple;
|
||||
import com.hbm.util.I18nUtil;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
@ -83,13 +84,20 @@ public class ItemFluidIdentifier extends Item {
|
||||
@Override
|
||||
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int i, float f1, float f2, float f3) {
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
if(te instanceof TileEntityFluidDuct) {
|
||||
if(te instanceof TileEntityFluidDuctSimple) {
|
||||
|
||||
if(!world.isRemote) {
|
||||
TileEntityFluidDuct duct = (TileEntityFluidDuct) te;
|
||||
TileEntityFluidDuctSimple duct = (TileEntityFluidDuctSimple) te;
|
||||
FluidType type = Fluids.fromID(stack.getItemDamage());
|
||||
if (player.isSneaking()) markDuctsRecursively(world, x, y, z, type);
|
||||
else duct.type = type;
|
||||
|
||||
if (player.isSneaking()) {
|
||||
markDuctsRecursively(world, x, y, z, type);
|
||||
} else {
|
||||
duct.setType(type);
|
||||
}
|
||||
}
|
||||
|
||||
world.markBlockForUpdate(x, y, z);
|
||||
|
||||
player.swingItem();
|
||||
}
|
||||
@ -102,27 +110,40 @@ public class ItemFluidIdentifier extends Item {
|
||||
|
||||
private void markDuctsRecursively(World world, int x, int y, int z, FluidType type, int maxRecursion) {
|
||||
TileEntity start = world.getTileEntity(x, y, z);
|
||||
if (!(start instanceof TileEntityFluidDuct)) return;
|
||||
TileEntityFluidDuct startDuct = (TileEntityFluidDuct) start;
|
||||
FluidType oldType = startDuct.type;
|
||||
if (oldType == type) return; // prevent infinite loops
|
||||
startDuct.type = type;
|
||||
|
||||
if (!(start instanceof TileEntityFluidDuctSimple))
|
||||
return;
|
||||
|
||||
TileEntityFluidDuctSimple startDuct = (TileEntityFluidDuctSimple) start;
|
||||
FluidType oldType = startDuct.getType();
|
||||
|
||||
if (oldType == type)
|
||||
return; // prevent infinite loops
|
||||
|
||||
startDuct.setType(type);
|
||||
|
||||
directionLoop: for (ForgeDirection direction : ForgeDirection.values()) {
|
||||
for (int currentRecursion = 1; currentRecursion <= maxRecursion; currentRecursion++) {
|
||||
|
||||
int nextX = x + direction.offsetX * currentRecursion;
|
||||
int nextY = y + direction.offsetY * currentRecursion;
|
||||
int nextZ = z + direction.offsetZ * currentRecursion;
|
||||
|
||||
TileEntity te = world.getTileEntity(nextX, nextY, nextZ);
|
||||
if (te instanceof IFluidDuct && ((IFluidDuct) te).getType() == oldType) {
|
||||
if (te instanceof TileEntityFluidDuctSimple && ((TileEntityFluidDuctSimple) te).getType() == oldType) {
|
||||
|
||||
TileEntityFluidDuct nextDuct = (TileEntityFluidDuct) te;
|
||||
long connectionsCount = Arrays.stream(nextDuct.connections).filter(Objects::nonNull).count();
|
||||
|
||||
if (connectionsCount > 1) {
|
||||
markDuctsRecursively(world, nextX, nextY, nextZ, type, maxRecursion - currentRecursion);
|
||||
continue directionLoop;
|
||||
} else nextDuct.type = type;
|
||||
} else break;
|
||||
} else {
|
||||
nextDuct.setType(type);
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,6 +5,7 @@ import java.util.List;
|
||||
import com.hbm.blocks.BlockDummyable;
|
||||
import com.hbm.lib.Library;
|
||||
import com.hbm.tileentity.conductor.TileEntityFluidDuct;
|
||||
import com.hbm.tileentity.conductor.TileEntityFluidDuctSimple;
|
||||
|
||||
import api.hbm.energy.IEnergyConductor;
|
||||
import net.minecraft.block.Block;
|
||||
@ -47,10 +48,10 @@ public class ItemWandD extends Item {
|
||||
player.addChatComponentMessage(new ChatComponentText("" + con.getPowerNet()));
|
||||
}*/
|
||||
|
||||
if(te instanceof TileEntityFluidDuct) {
|
||||
if(te instanceof TileEntityFluidDuctSimple) {
|
||||
|
||||
player.addChatComponentMessage(new ChatComponentText("" + ((TileEntityFluidDuct)te).type.getUnlocalizedName()));
|
||||
player.addChatComponentMessage(new ChatComponentText("" + ((TileEntityFluidDuct)te).type.getID()));
|
||||
player.addChatComponentMessage(new ChatComponentText("" + ((TileEntityFluidDuctSimple)te).getType().getUnlocalizedName()));
|
||||
player.addChatComponentMessage(new ChatComponentText("" + ((TileEntityFluidDuctSimple)te).getType().getID()));
|
||||
}
|
||||
|
||||
//CellularDungeonFactory.meteor.generate(world, x, y, z, world.rand);
|
||||
|
||||
@ -495,7 +495,7 @@ public class Library {
|
||||
|
||||
if(tileentity instanceof IFluidDuct)
|
||||
{
|
||||
if(tileentity instanceof TileEntityFluidDuct && ((TileEntityFluidDuct)tileentity).type.name().equals(type.name()))
|
||||
if(tileentity instanceof TileEntityFluidDuct && ((TileEntityFluidDuct)tileentity).getType() == type)
|
||||
{
|
||||
if(Library.checkUnionListForFluids(((TileEntityFluidDuct)tileentity).uoteab, that))
|
||||
{
|
||||
|
||||
@ -635,6 +635,7 @@ public class ClientProxy extends ServerProxy {
|
||||
RenderingRegistry.registerBlockHandler(new RenderTestCable());
|
||||
RenderingRegistry.registerBlockHandler(new RenderBlockCT());
|
||||
RenderingRegistry.registerBlockHandler(new RenderDetCord());
|
||||
RenderingRegistry.registerBlockHandler(new RenderBlockMultipass());
|
||||
|
||||
RenderingRegistry.registerBlockHandler(new RenderBlockRotated(ModBlocks.charge_dynamite.getRenderType(), ResourceManager.charge_dynamite));
|
||||
|
||||
|
||||
@ -27,8 +27,6 @@ public class PacketDispatcher {
|
||||
wrapper.registerMessage(TEDrillSoundPacket.Handler.class, TEDrillSoundPacket.class, i++, Side.CLIENT);
|
||||
//Assembler cog rotation for rendering
|
||||
wrapper.registerMessage(TEAssemblerPacket.Handler.class, TEAssemblerPacket.class, i++, Side.CLIENT);
|
||||
//Fluid type for pipe rendering
|
||||
wrapper.registerMessage(TEFluidPipePacket.Handler.class, TEFluidPipePacket.class, i++, Side.CLIENT);
|
||||
//Missile type for rendering
|
||||
wrapper.registerMessage(TEMissilePacket.Handler.class, TEMissilePacket.class, i++, Side.CLIENT);
|
||||
//Fluid packet for GUI
|
||||
|
||||
@ -1,68 +0,0 @@
|
||||
package com.hbm.packet;
|
||||
|
||||
import com.hbm.inventory.fluid.FluidType;
|
||||
import com.hbm.inventory.fluid.Fluids;
|
||||
import com.hbm.tileentity.conductor.TileEntityFluidDuct;
|
||||
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class TEFluidPipePacket implements IMessage {
|
||||
|
||||
int x;
|
||||
int y;
|
||||
int z;
|
||||
FluidType type;
|
||||
|
||||
public TEFluidPipePacket()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public TEFluidPipePacket(int x, int y, int z, FluidType type)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
x = buf.readInt();
|
||||
y = buf.readInt();
|
||||
z = buf.readInt();
|
||||
type = Fluids.fromID(buf.readInt());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
buf.writeInt(x);
|
||||
buf.writeInt(y);
|
||||
buf.writeInt(z);
|
||||
buf.writeInt(type.getID());
|
||||
}
|
||||
|
||||
public static class Handler implements IMessageHandler<TEFluidPipePacket, IMessage> {
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(TEFluidPipePacket m, MessageContext ctx) {
|
||||
try {
|
||||
TileEntity te = Minecraft.getMinecraft().theWorld.getTileEntity(m.x, m.y, m.z);
|
||||
|
||||
if (te != null && te instanceof TileEntityFluidDuct) {
|
||||
|
||||
TileEntityFluidDuct duct = (TileEntityFluidDuct) te;
|
||||
duct.type = m.type;
|
||||
}
|
||||
return null;
|
||||
} catch(Exception ex) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
68
src/main/java/com/hbm/render/block/RenderBlockMultipass.java
Normal file
68
src/main/java/com/hbm/render/block/RenderBlockMultipass.java
Normal file
@ -0,0 +1,68 @@
|
||||
package com.hbm.render.block;
|
||||
|
||||
import com.hbm.blocks.IBlockMultiPass;
|
||||
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
public class RenderBlockMultipass implements ISimpleBlockRenderingHandler {
|
||||
|
||||
/**
|
||||
* First I wanted to pass the current render pass in the methods for getting color and icon, but the later one would have to work with
|
||||
* texture overrides which would either break sided textures or force me to implement renderStandardBlock myself, so that's a big nono.
|
||||
* So I made a static variable for the current render pass so that Block.getIcon could use it while still minding sides. Great, I put it
|
||||
* into IBlockMultiPass because that's the only logical place I could put it since I intend to use IBlockMultiPass for more rendering
|
||||
* handlers than just this one and BOOM, primitive fields in interfaces are implicitly final. Why? Because "functionality in interfaces
|
||||
* bad", or so the HeckOverflow people are trying to tell me. Mh-hm, holding a single static value is "functionality" now, and functionality
|
||||
* in interfaces is very very bad in a language that allows interfaces to define a default behavior that is LITERALLY FULLY FUNCTIONAL
|
||||
* METHODS. Statistically speaking I, the individual, should be wrong and many people who - supposedly - know what they're talking about
|
||||
* should be right, but if you ask me there's something off about this whole ordeal. I don't know.
|
||||
*/
|
||||
public static int currentPass = 0;
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { }
|
||||
|
||||
@Override
|
||||
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
|
||||
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
|
||||
tessellator.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z));
|
||||
|
||||
if(!(block instanceof IBlockMultiPass)) {
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
return true;
|
||||
}
|
||||
|
||||
IBlockMultiPass multi = (IBlockMultiPass) block;
|
||||
renderer.setRenderBounds(0.0, 0.0, 0.0, 1.0, 1.0, 1.0);
|
||||
|
||||
int passes = multi.getPasses();
|
||||
|
||||
for(int i = 0; i < passes; i++) {
|
||||
currentPass = i;
|
||||
System.out.println(multi.getColorFromPass(world, x, y, z, false));
|
||||
tessellator.setColorOpaque_I(multi.getColorFromPass(world, x, y, z, false));
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
|
||||
currentPass = 0;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender3DInInventory(int modelId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderId() {
|
||||
return IBlockMultiPass.getRenderType();
|
||||
}
|
||||
}
|
||||
@ -12,107 +12,104 @@ import net.minecraft.world.IBlockAccess;
|
||||
public class RenderChain implements ISimpleBlockRenderingHandler {
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { }
|
||||
public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
|
||||
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
IIcon iicon = block.getIcon(world, x, y, z, 0);
|
||||
|
||||
tessellator.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z));
|
||||
tessellator.setColorOpaque_F(1.0F, 1.0F, 1.0F);
|
||||
double d0 = (double)iicon.getMinU();
|
||||
double d1 = (double)iicon.getMinV();
|
||||
double d2 = (double)iicon.getMaxU();
|
||||
double d3 = (double)iicon.getMaxV();
|
||||
int l = world.getBlockMetadata(x, y, z);
|
||||
double d4 = 0.0D;
|
||||
double d5 = 0.05D;
|
||||
|
||||
if(l == 0) {
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
IIcon iicon = block.getIcon(world, x, y, z, 0);
|
||||
|
||||
double minU = (double)iicon.getMinU();
|
||||
double minV = (double)iicon.getMinV();
|
||||
double maxU = (double)iicon.getMaxU();
|
||||
double maxV = (double)iicon.getMaxV();
|
||||
double d8 = x;
|
||||
double d9 = x + 1;
|
||||
double p_147765_4_ = y;
|
||||
double p_147765_8_ = 1;
|
||||
double d10 = z + 0;
|
||||
double d11 = z + 1;
|
||||
tessellator.addVertexWithUV(d8, p_147765_4_ + (double)p_147765_8_, d10, minU, minV);
|
||||
tessellator.addVertexWithUV(d8, p_147765_4_ + 0.0D, d10, minU, maxV);
|
||||
tessellator.addVertexWithUV(d9, p_147765_4_ + 0.0D, d11, maxU, maxV);
|
||||
tessellator.addVertexWithUV(d9, p_147765_4_ + (double)p_147765_8_, d11, maxU, minV);
|
||||
tessellator.addVertexWithUV(d9, p_147765_4_ + (double)p_147765_8_, d11, minU, minV);
|
||||
tessellator.addVertexWithUV(d9, p_147765_4_ + 0.0D, d11, minU, maxV);
|
||||
tessellator.addVertexWithUV(d8, p_147765_4_ + 0.0D, d10, maxU, maxV);
|
||||
tessellator.addVertexWithUV(d8, p_147765_4_ + (double)p_147765_8_, d10, maxU, minV);
|
||||
tessellator.addVertexWithUV(d8, p_147765_4_ + (double)p_147765_8_, d11, minU, minV);
|
||||
tessellator.addVertexWithUV(d8, p_147765_4_ + 0.0D, d11, minU, maxV);
|
||||
tessellator.addVertexWithUV(d9, p_147765_4_ + 0.0D, d10, maxU, maxV);
|
||||
tessellator.addVertexWithUV(d9, p_147765_4_ + (double)p_147765_8_, d10, maxU, minV);
|
||||
tessellator.addVertexWithUV(d9, p_147765_4_ + (double)p_147765_8_, d10, minU, minV);
|
||||
tessellator.addVertexWithUV(d9, p_147765_4_ + 0.0D, d10, minU, maxV);
|
||||
tessellator.addVertexWithUV(d8, p_147765_4_ + 0.0D, d11, maxU, maxV);
|
||||
tessellator.addVertexWithUV(d8, p_147765_4_ + (double)p_147765_8_, d11, maxU, minV);
|
||||
}
|
||||
tessellator.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z));
|
||||
tessellator.setColorOpaque_F(1.0F, 1.0F, 1.0F);
|
||||
double d0 = (double) iicon.getMinU();
|
||||
double d1 = (double) iicon.getMinV();
|
||||
double d2 = (double) iicon.getMaxU();
|
||||
double d3 = (double) iicon.getMaxV();
|
||||
int l = world.getBlockMetadata(x, y, z);
|
||||
double scale = 0.0D;
|
||||
double wallOffset = 0.05D;
|
||||
|
||||
if (l == 5)
|
||||
{
|
||||
tessellator.addVertexWithUV((double)x + d5, (double)(y + 1) + d4, (double)(z + 1) + d4, d0, d1);
|
||||
tessellator.addVertexWithUV((double)x + d5, (double)(y + 0) - d4, (double)(z + 1) + d4, d0, d3);
|
||||
tessellator.addVertexWithUV((double)x + d5, (double)(y + 0) - d4, (double)(z + 0) - d4, d2, d3);
|
||||
tessellator.addVertexWithUV((double)x + d5, (double)(y + 1) + d4, (double)(z + 0) - d4, d2, d1);
|
||||
if(l == 0) {
|
||||
|
||||
tessellator.addVertexWithUV((double)x + d5, (double)(y + 0) - d4, (double)(z + 1) + d4, d0, d3);
|
||||
tessellator.addVertexWithUV((double)x + d5, (double)(y + 1) + d4, (double)(z + 1) + d4, d0, d1);
|
||||
tessellator.addVertexWithUV((double)x + d5, (double)(y + 1) + d4, (double)(z + 0) - d4, d2, d1);
|
||||
tessellator.addVertexWithUV((double)x + d5, (double)(y + 0) - d4, (double)(z + 0) - d4, d2, d3);
|
||||
}
|
||||
double minU = (double) iicon.getMinU();
|
||||
double minV = (double) iicon.getMinV();
|
||||
double maxU = (double) iicon.getMaxU();
|
||||
double maxV = (double) iicon.getMaxV();
|
||||
double minX = x;
|
||||
double maxX = x + 1;
|
||||
double minY = y;
|
||||
double ySize = 1;
|
||||
double minZ = z + 0;
|
||||
double maxZ = z + 1;
|
||||
tessellator.addVertexWithUV(minX, minY + (double) ySize, minZ, minU, minV);
|
||||
tessellator.addVertexWithUV(minX, minY + 0.0D, minZ, minU, maxV);
|
||||
tessellator.addVertexWithUV(maxX, minY + 0.0D, maxZ, maxU, maxV);
|
||||
tessellator.addVertexWithUV(maxX, minY + (double) ySize, maxZ, maxU, minV);
|
||||
tessellator.addVertexWithUV(maxX, minY + (double) ySize, maxZ, minU, minV);
|
||||
tessellator.addVertexWithUV(maxX, minY + 0.0D, maxZ, minU, maxV);
|
||||
tessellator.addVertexWithUV(minX, minY + 0.0D, minZ, maxU, maxV);
|
||||
tessellator.addVertexWithUV(minX, minY + (double) ySize, minZ, maxU, minV);
|
||||
tessellator.addVertexWithUV(minX, minY + (double) ySize, maxZ, minU, minV);
|
||||
tessellator.addVertexWithUV(minX, minY + 0.0D, maxZ, minU, maxV);
|
||||
tessellator.addVertexWithUV(maxX, minY + 0.0D, minZ, maxU, maxV);
|
||||
tessellator.addVertexWithUV(maxX, minY + (double) ySize, minZ, maxU, minV);
|
||||
tessellator.addVertexWithUV(maxX, minY + (double) ySize, minZ, minU, minV);
|
||||
tessellator.addVertexWithUV(maxX, minY + 0.0D, minZ, minU, maxV);
|
||||
tessellator.addVertexWithUV(minX, minY + 0.0D, maxZ, maxU, maxV);
|
||||
tessellator.addVertexWithUV(minX, minY + (double) ySize, maxZ, maxU, minV);
|
||||
}
|
||||
|
||||
if (l == 4)
|
||||
{
|
||||
tessellator.addVertexWithUV((double)(x + 1) - d5, (double)(y + 0) - d4, (double)(z + 1) + d4, d2, d3);
|
||||
tessellator.addVertexWithUV((double)(x + 1) - d5, (double)(y + 1) + d4, (double)(z + 1) + d4, d2, d1);
|
||||
tessellator.addVertexWithUV((double)(x + 1) - d5, (double)(y + 1) + d4, (double)(z + 0) - d4, d0, d1);
|
||||
tessellator.addVertexWithUV((double)(x + 1) - d5, (double)(y + 0) - d4, (double)(z + 0) - d4, d0, d3);
|
||||
|
||||
tessellator.addVertexWithUV((double)(x + 1) - d5, (double)(y + 1) + d4, (double)(z + 1) + d4, d2, d1);
|
||||
tessellator.addVertexWithUV((double)(x + 1) - d5, (double)(y + 0) - d4, (double)(z + 1) + d4, d2, d3);
|
||||
tessellator.addVertexWithUV((double)(x + 1) - d5, (double)(y + 0) - d4, (double)(z + 0) - d4, d0, d3);
|
||||
tessellator.addVertexWithUV((double)(x + 1) - d5, (double)(y + 1) + d4, (double)(z + 0) - d4, d0, d1);
|
||||
}
|
||||
if(l == 5) {
|
||||
tessellator.addVertexWithUV((double) x + wallOffset, (double) (y + 1) + scale, (double) (z + 1) + scale, d0, d1);
|
||||
tessellator.addVertexWithUV((double) x + wallOffset, (double) (y + 0) - scale, (double) (z + 1) + scale, d0, d3);
|
||||
tessellator.addVertexWithUV((double) x + wallOffset, (double) (y + 0) - scale, (double) (z + 0) - scale, d2, d3);
|
||||
tessellator.addVertexWithUV((double) x + wallOffset, (double) (y + 1) + scale, (double) (z + 0) - scale, d2, d1);
|
||||
|
||||
if (l == 3)
|
||||
{
|
||||
tessellator.addVertexWithUV((double)(x + 1) + d4, (double)(y + 0) - d4, (double)z + d5, d2, d3);
|
||||
tessellator.addVertexWithUV((double)(x + 1) + d4, (double)(y + 1) + d4, (double)z + d5, d2, d1);
|
||||
tessellator.addVertexWithUV((double)(x + 0) - d4, (double)(y + 1) + d4, (double)z + d5, d0, d1);
|
||||
tessellator.addVertexWithUV((double)(x + 0) - d4, (double)(y + 0) - d4, (double)z + d5, d0, d3);
|
||||
|
||||
tessellator.addVertexWithUV((double)(x + 1) + d4, (double)(y + 1) + d4, (double)z + d5, d2, d1);
|
||||
tessellator.addVertexWithUV((double)(x + 1) + d4, (double)(y + 0) - d4, (double)z + d5, d2, d3);
|
||||
tessellator.addVertexWithUV((double)(x + 0) - d4, (double)(y + 0) - d4, (double)z + d5, d0, d3);
|
||||
tessellator.addVertexWithUV((double)(x + 0) - d4, (double)(y + 1) + d4, (double)z + d5, d0, d1);
|
||||
}
|
||||
tessellator.addVertexWithUV((double) x + wallOffset, (double) (y + 0) - scale, (double) (z + 1) + scale, d0, d3);
|
||||
tessellator.addVertexWithUV((double) x + wallOffset, (double) (y + 1) + scale, (double) (z + 1) + scale, d0, d1);
|
||||
tessellator.addVertexWithUV((double) x + wallOffset, (double) (y + 1) + scale, (double) (z + 0) - scale, d2, d1);
|
||||
tessellator.addVertexWithUV((double) x + wallOffset, (double) (y + 0) - scale, (double) (z + 0) - scale, d2, d3);
|
||||
}
|
||||
|
||||
if (l == 2)
|
||||
{
|
||||
tessellator.addVertexWithUV((double)(x + 1) + d4, (double)(y + 1) + d4, (double)(z + 1) - d5, d0, d1);
|
||||
tessellator.addVertexWithUV((double)(x + 1) + d4, (double)(y + 0) - d4, (double)(z + 1) - d5, d0, d3);
|
||||
tessellator.addVertexWithUV((double)(x + 0) - d4, (double)(y + 0) - d4, (double)(z + 1) - d5, d2, d3);
|
||||
tessellator.addVertexWithUV((double)(x + 0) - d4, (double)(y + 1) + d4, (double)(z + 1) - d5, d2, d1);
|
||||
if(l == 4) {
|
||||
tessellator.addVertexWithUV((double) (x + 1) - wallOffset, (double) (y + 0) - scale, (double) (z + 1) + scale, d2, d3);
|
||||
tessellator.addVertexWithUV((double) (x + 1) - wallOffset, (double) (y + 1) + scale, (double) (z + 1) + scale, d2, d1);
|
||||
tessellator.addVertexWithUV((double) (x + 1) - wallOffset, (double) (y + 1) + scale, (double) (z + 0) - scale, d0, d1);
|
||||
tessellator.addVertexWithUV((double) (x + 1) - wallOffset, (double) (y + 0) - scale, (double) (z + 0) - scale, d0, d3);
|
||||
|
||||
tessellator.addVertexWithUV((double)(x + 1) + d4, (double)(y + 0) - d4, (double)(z + 1) - d5, d0, d3);
|
||||
tessellator.addVertexWithUV((double)(x + 1) + d4, (double)(y + 1) + d4, (double)(z + 1) - d5, d0, d1);
|
||||
tessellator.addVertexWithUV((double)(x + 0) - d4, (double)(y + 1) + d4, (double)(z + 1) - d5, d2, d1);
|
||||
tessellator.addVertexWithUV((double)(x + 0) - d4, (double)(y + 0) - d4, (double)(z + 1) - d5, d2, d3);
|
||||
}
|
||||
tessellator.addVertexWithUV((double) (x + 1) - wallOffset, (double) (y + 1) + scale, (double) (z + 1) + scale, d2, d1);
|
||||
tessellator.addVertexWithUV((double) (x + 1) - wallOffset, (double) (y + 0) - scale, (double) (z + 1) + scale, d2, d3);
|
||||
tessellator.addVertexWithUV((double) (x + 1) - wallOffset, (double) (y + 0) - scale, (double) (z + 0) - scale, d0, d3);
|
||||
tessellator.addVertexWithUV((double) (x + 1) - wallOffset, (double) (y + 1) + scale, (double) (z + 0) - scale, d0, d1);
|
||||
}
|
||||
|
||||
return true;
|
||||
if(l == 3) {
|
||||
tessellator.addVertexWithUV((double) (x + 1) + scale, (double) (y + 0) - scale, (double) z + wallOffset, d2, d3);
|
||||
tessellator.addVertexWithUV((double) (x + 1) + scale, (double) (y + 1) + scale, (double) z + wallOffset, d2, d1);
|
||||
tessellator.addVertexWithUV((double) (x + 0) - scale, (double) (y + 1) + scale, (double) z + wallOffset, d0, d1);
|
||||
tessellator.addVertexWithUV((double) (x + 0) - scale, (double) (y + 0) - scale, (double) z + wallOffset, d0, d3);
|
||||
|
||||
tessellator.addVertexWithUV((double) (x + 1) + scale, (double) (y + 1) + scale, (double) z + wallOffset, d2, d1);
|
||||
tessellator.addVertexWithUV((double) (x + 1) + scale, (double) (y + 0) - scale, (double) z + wallOffset, d2, d3);
|
||||
tessellator.addVertexWithUV((double) (x + 0) - scale, (double) (y + 0) - scale, (double) z + wallOffset, d0, d3);
|
||||
tessellator.addVertexWithUV((double) (x + 0) - scale, (double) (y + 1) + scale, (double) z + wallOffset, d0, d1);
|
||||
}
|
||||
|
||||
if(l == 2) {
|
||||
tessellator.addVertexWithUV((double) (x + 1) + scale, (double) (y + 1) + scale, (double) (z + 1) - wallOffset, d0, d1);
|
||||
tessellator.addVertexWithUV((double) (x + 1) + scale, (double) (y + 0) - scale, (double) (z + 1) - wallOffset, d0, d3);
|
||||
tessellator.addVertexWithUV((double) (x + 0) - scale, (double) (y + 0) - scale, (double) (z + 1) - wallOffset, d2, d3);
|
||||
tessellator.addVertexWithUV((double) (x + 0) - scale, (double) (y + 1) + scale, (double) (z + 1) - wallOffset, d2, d1);
|
||||
|
||||
tessellator.addVertexWithUV((double) (x + 1) + scale, (double) (y + 0) - scale, (double) (z + 1) - wallOffset, d0, d3);
|
||||
tessellator.addVertexWithUV((double) (x + 1) + scale, (double) (y + 1) + scale, (double) (z + 1) - wallOffset, d0, d1);
|
||||
tessellator.addVertexWithUV((double) (x + 0) - scale, (double) (y + 1) + scale, (double) (z + 1) - wallOffset, d2, d1);
|
||||
tessellator.addVertexWithUV((double) (x + 0) - scale, (double) (y + 0) - scale, (double) (z + 1) - wallOffset, d2, d3);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -28,7 +28,7 @@ public class RenderFluidDuct extends TileEntitySpecialRenderer {
|
||||
{
|
||||
if(cable.connections[i] != null)
|
||||
{
|
||||
drawConnection(cable.connections[i], cable.type.getColor());
|
||||
drawConnection(cable.connections[i], cable.getType().getColor());
|
||||
}
|
||||
}
|
||||
GL11.glTranslated(-offsetX, -offsetY, -offsetZ);
|
||||
|
||||
@ -76,6 +76,7 @@ public class TileMappings {
|
||||
put(TileEntityStructureMarker.class, "tileentity_structure_marker");
|
||||
put(TileEntityMachineMiningDrill.class, "tileentity_mining_drill");
|
||||
put(TileEntityMachineAssembler.class, "tileentity_assembly_machine");
|
||||
put(TileEntityFluidDuctSimple.class, "tileentity_universal_duct_simple");
|
||||
put(TileEntityFluidDuct.class, "tileentity_universal_duct");
|
||||
put(TileEntityMachineChemplant.class, "tileentity_chemical_plant");
|
||||
put(TileEntityMachineFluidTank.class, "tileentity_fluid_tank");
|
||||
|
||||
@ -10,31 +10,25 @@ import com.hbm.inventory.fluid.FluidType;
|
||||
import com.hbm.inventory.fluid.Fluids;
|
||||
import com.hbm.lib.Library;
|
||||
import com.hbm.packet.PacketDispatcher;
|
||||
import com.hbm.packet.TEFluidPipePacket;
|
||||
|
||||
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class TileEntityFluidDuct extends TileEntity implements IFluidDuct {
|
||||
public class TileEntityFluidDuct extends TileEntityFluidDuctSimple {
|
||||
|
||||
public ForgeDirection[] connections = new ForgeDirection[6];
|
||||
public FluidType type = Fluids.NONE;
|
||||
public List<UnionOfTileEntitiesAndBooleansForFluids> uoteab = new ArrayList<UnionOfTileEntitiesAndBooleansForFluids>();
|
||||
|
||||
public TileEntityFluidDuct() {
|
||||
|
||||
}
|
||||
public TileEntityFluidDuct() { }
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
|
||||
if(!worldObj.isRemote)
|
||||
PacketDispatcher.wrapper.sendToAllAround(new TEFluidPipePacket(xCoord, yCoord, zCoord, type), new TargetPoint(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, 25));
|
||||
|
||||
this.updateConnections();
|
||||
}
|
||||
|
||||
@ -57,28 +51,10 @@ public class TileEntityFluidDuct extends TileEntity implements IFluidDuct {
|
||||
if(Library.checkFluidConnectables(this.worldObj, xCoord - 1, yCoord, zCoord, type)) connections[5] = ForgeDirection.WEST;
|
||||
else connections[5] = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
type = Fluids.fromID(nbt.getInteger("fluid"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
super.writeToNBT(nbt);
|
||||
nbt.setInteger("fluid", type.getID());
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public double getMaxRenderDistanceSquared()
|
||||
{
|
||||
public double getMaxRenderDistanceSquared() {
|
||||
return 65536.0D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidType getType() {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,67 @@
|
||||
package com.hbm.tileentity.conductor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.hbm.calc.UnionOfTileEntitiesAndBooleansForFluids;
|
||||
import com.hbm.interfaces.IFluidDuct;
|
||||
import com.hbm.inventory.fluid.FluidType;
|
||||
import com.hbm.inventory.fluid.Fluids;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.WorldServer;
|
||||
|
||||
public class TileEntityFluidDuctSimple extends TileEntity implements IFluidDuct {
|
||||
|
||||
protected FluidType type = Fluids.NONE;
|
||||
public List<UnionOfTileEntitiesAndBooleansForFluids> uoteab = new ArrayList<UnionOfTileEntitiesAndBooleansForFluids>();
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket() {
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
this.writeToNBT(nbt);
|
||||
return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 0, nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
|
||||
this.readFromNBT(pkt.func_148857_g());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
type = Fluids.fromID(nbt.getInteger("fluid"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
super.writeToNBT(nbt);
|
||||
nbt.setInteger("fluid", type.getID());
|
||||
}
|
||||
|
||||
public boolean setType(FluidType type) {
|
||||
|
||||
if(this.type == type)
|
||||
return true;
|
||||
|
||||
this.type = type;
|
||||
this.markDirty();
|
||||
|
||||
if(worldObj instanceof WorldServer) {
|
||||
WorldServer world = (WorldServer) worldObj;
|
||||
world.getPlayerManager().markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidType getType() {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
@ -79,4 +79,9 @@ public class TileEntityGasDuct extends TileEntity implements IFluidDuct {
|
||||
public FluidType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setType(FluidType type) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -20,4 +20,8 @@ public class TileEntityGasDuctSolid extends TileEntity implements IFluidDuct {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setType(FluidType type) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -78,4 +78,9 @@ public class TileEntityOilDuct extends TileEntity implements IFluidDuct {
|
||||
public FluidType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setType(FluidType type) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -20,4 +20,8 @@ public class TileEntityOilDuctSolid extends TileEntity implements IFluidDuct {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setType(FluidType type) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 348 B |
Binary file not shown.
|
After Width: | Height: | Size: 126 B |
Loading…
x
Reference in New Issue
Block a user