fluid duct agony

This commit is contained in:
Boblet 2022-01-28 15:15:03 +01:00
parent fdcf09abfb
commit b05384f2e5
23 changed files with 381 additions and 208 deletions

View 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;
}
}

View File

@ -706,6 +706,7 @@ public class ModBlocks {
public static Block gas_duct_solid; public static Block gas_duct_solid;
public static Block gas_duct; public static Block gas_duct;
public static Block fluid_duct; public static Block fluid_duct;
public static Block fluid_duct_solid;
public static Block conveyor; 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_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"); 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 = 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"); 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"); 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, gas_duct.getUnlocalizedName());
GameRegistry.registerBlock(gas_duct_solid, gas_duct_solid.getUnlocalizedName()); GameRegistry.registerBlock(gas_duct_solid, gas_duct_solid.getUnlocalizedName());
GameRegistry.registerBlock(fluid_duct, fluid_duct.getUnlocalizedName()); GameRegistry.registerBlock(fluid_duct, fluid_duct.getUnlocalizedName());
GameRegistry.registerBlock(fluid_duct_solid, fluid_duct_solid.getUnlocalizedName());
GameRegistry.registerBlock(conveyor, conveyor.getUnlocalizedName()); GameRegistry.registerBlock(conveyor, conveyor.getUnlocalizedName());
GameRegistry.registerBlock(chain, chain.getUnlocalizedName()); GameRegistry.registerBlock(chain, chain.getUnlocalizedName());

View File

@ -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;
}
}

View File

@ -3,7 +3,8 @@ package com.hbm.interfaces;
import com.hbm.inventory.fluid.FluidType; import com.hbm.inventory.fluid.FluidType;
public interface IFluidDuct { public interface IFluidDuct {
public FluidType getType(); public FluidType getType();
public boolean setType(FluidType type);
} }

View File

@ -123,7 +123,7 @@ public class ItemFluidDuct extends Item {
world.setBlock(x, y, z, ModBlocks.fluid_duct); world.setBlock(x, y, z, ModBlocks.fluid_duct);
if(world.getTileEntity(x, y, z) instanceof TileEntityFluidDuct) { 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); world.playSoundEffect(x, y, z, "hbm:block.pipePlaced", 1.0F, 0.65F + world.rand.nextFloat() * 0.2F);

View File

@ -9,6 +9,7 @@ import com.hbm.inventory.fluid.FluidType;
import com.hbm.inventory.fluid.Fluids; import com.hbm.inventory.fluid.Fluids;
import com.hbm.items.ModItems; import com.hbm.items.ModItems;
import com.hbm.tileentity.conductor.TileEntityFluidDuct; import com.hbm.tileentity.conductor.TileEntityFluidDuct;
import com.hbm.tileentity.conductor.TileEntityFluidDuctSimple;
import com.hbm.util.I18nUtil; import com.hbm.util.I18nUtil;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
@ -83,13 +84,20 @@ public class ItemFluidIdentifier extends Item {
@Override @Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int i, float f1, float f2, float f3) { 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); TileEntity te = world.getTileEntity(x, y, z);
if(te instanceof TileEntityFluidDuct) { if(te instanceof TileEntityFluidDuctSimple) {
if(!world.isRemote) { if(!world.isRemote) {
TileEntityFluidDuct duct = (TileEntityFluidDuct) te; TileEntityFluidDuctSimple duct = (TileEntityFluidDuctSimple) te;
FluidType type = Fluids.fromID(stack.getItemDamage()); 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(); 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) { private void markDuctsRecursively(World world, int x, int y, int z, FluidType type, int maxRecursion) {
TileEntity start = world.getTileEntity(x, y, z); TileEntity start = world.getTileEntity(x, y, z);
if (!(start instanceof TileEntityFluidDuct)) return;
TileEntityFluidDuct startDuct = (TileEntityFluidDuct) start; if (!(start instanceof TileEntityFluidDuctSimple))
FluidType oldType = startDuct.type; return;
if (oldType == type) return; // prevent infinite loops
startDuct.type = type; TileEntityFluidDuctSimple startDuct = (TileEntityFluidDuctSimple) start;
FluidType oldType = startDuct.getType();
if (oldType == type)
return; // prevent infinite loops
startDuct.setType(type);
directionLoop: for (ForgeDirection direction : ForgeDirection.values()) { directionLoop: for (ForgeDirection direction : ForgeDirection.values()) {
for (int currentRecursion = 1; currentRecursion <= maxRecursion; currentRecursion++) { for (int currentRecursion = 1; currentRecursion <= maxRecursion; currentRecursion++) {
int nextX = x + direction.offsetX * currentRecursion; int nextX = x + direction.offsetX * currentRecursion;
int nextY = y + direction.offsetY * currentRecursion; int nextY = y + direction.offsetY * currentRecursion;
int nextZ = z + direction.offsetZ * currentRecursion; int nextZ = z + direction.offsetZ * currentRecursion;
TileEntity te = world.getTileEntity(nextX, nextY, nextZ); 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; TileEntityFluidDuct nextDuct = (TileEntityFluidDuct) te;
long connectionsCount = Arrays.stream(nextDuct.connections).filter(Objects::nonNull).count(); long connectionsCount = Arrays.stream(nextDuct.connections).filter(Objects::nonNull).count();
if (connectionsCount > 1) { if (connectionsCount > 1) {
markDuctsRecursively(world, nextX, nextY, nextZ, type, maxRecursion - currentRecursion); markDuctsRecursively(world, nextX, nextY, nextZ, type, maxRecursion - currentRecursion);
continue directionLoop; continue directionLoop;
} else nextDuct.type = type; } else {
} else break; nextDuct.setType(type);
}
} else {
break;
}
} }
} }
} }

View File

@ -5,6 +5,7 @@ import java.util.List;
import com.hbm.blocks.BlockDummyable; import com.hbm.blocks.BlockDummyable;
import com.hbm.lib.Library; import com.hbm.lib.Library;
import com.hbm.tileentity.conductor.TileEntityFluidDuct; import com.hbm.tileentity.conductor.TileEntityFluidDuct;
import com.hbm.tileentity.conductor.TileEntityFluidDuctSimple;
import api.hbm.energy.IEnergyConductor; import api.hbm.energy.IEnergyConductor;
import net.minecraft.block.Block; import net.minecraft.block.Block;
@ -47,10 +48,10 @@ public class ItemWandD extends Item {
player.addChatComponentMessage(new ChatComponentText("" + con.getPowerNet())); 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("" + ((TileEntityFluidDuctSimple)te).getType().getUnlocalizedName()));
player.addChatComponentMessage(new ChatComponentText("" + ((TileEntityFluidDuct)te).type.getID())); player.addChatComponentMessage(new ChatComponentText("" + ((TileEntityFluidDuctSimple)te).getType().getID()));
} }
//CellularDungeonFactory.meteor.generate(world, x, y, z, world.rand); //CellularDungeonFactory.meteor.generate(world, x, y, z, world.rand);

View File

@ -495,7 +495,7 @@ public class Library {
if(tileentity instanceof IFluidDuct) 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)) if(Library.checkUnionListForFluids(((TileEntityFluidDuct)tileentity).uoteab, that))
{ {

View File

@ -635,6 +635,7 @@ public class ClientProxy extends ServerProxy {
RenderingRegistry.registerBlockHandler(new RenderTestCable()); RenderingRegistry.registerBlockHandler(new RenderTestCable());
RenderingRegistry.registerBlockHandler(new RenderBlockCT()); RenderingRegistry.registerBlockHandler(new RenderBlockCT());
RenderingRegistry.registerBlockHandler(new RenderDetCord()); RenderingRegistry.registerBlockHandler(new RenderDetCord());
RenderingRegistry.registerBlockHandler(new RenderBlockMultipass());
RenderingRegistry.registerBlockHandler(new RenderBlockRotated(ModBlocks.charge_dynamite.getRenderType(), ResourceManager.charge_dynamite)); RenderingRegistry.registerBlockHandler(new RenderBlockRotated(ModBlocks.charge_dynamite.getRenderType(), ResourceManager.charge_dynamite));

View File

@ -27,8 +27,6 @@ public class PacketDispatcher {
wrapper.registerMessage(TEDrillSoundPacket.Handler.class, TEDrillSoundPacket.class, i++, Side.CLIENT); wrapper.registerMessage(TEDrillSoundPacket.Handler.class, TEDrillSoundPacket.class, i++, Side.CLIENT);
//Assembler cog rotation for rendering //Assembler cog rotation for rendering
wrapper.registerMessage(TEAssemblerPacket.Handler.class, TEAssemblerPacket.class, i++, Side.CLIENT); 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 //Missile type for rendering
wrapper.registerMessage(TEMissilePacket.Handler.class, TEMissilePacket.class, i++, Side.CLIENT); wrapper.registerMessage(TEMissilePacket.Handler.class, TEMissilePacket.class, i++, Side.CLIENT);
//Fluid packet for GUI //Fluid packet for GUI

View File

@ -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;
}
}
}
}

View 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();
}
}

View File

@ -12,107 +12,104 @@ import net.minecraft.world.IBlockAccess;
public class RenderChain implements ISimpleBlockRenderingHandler { public class RenderChain implements ISimpleBlockRenderingHandler {
@Override @Override
public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { } public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) {
}
@Override @Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { 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 tessellator = Tessellator.instance;
tessellator.setColorOpaque_F(1.0F, 1.0F, 1.0F); IIcon iicon = block.getIcon(world, x, y, z, 0);
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) {
double minU = (double)iicon.getMinU(); tessellator.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z));
double minV = (double)iicon.getMinV(); tessellator.setColorOpaque_F(1.0F, 1.0F, 1.0F);
double maxU = (double)iicon.getMaxU(); double d0 = (double) iicon.getMinU();
double maxV = (double)iicon.getMaxV(); double d1 = (double) iicon.getMinV();
double d8 = x; double d2 = (double) iicon.getMaxU();
double d9 = x + 1; double d3 = (double) iicon.getMaxV();
double p_147765_4_ = y; int l = world.getBlockMetadata(x, y, z);
double p_147765_8_ = 1; double scale = 0.0D;
double d10 = z + 0; double wallOffset = 0.05D;
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);
}
if (l == 5) if(l == 0) {
{
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);
tessellator.addVertexWithUV((double)x + d5, (double)(y + 0) - d4, (double)(z + 1) + d4, d0, d3); double minU = (double) iicon.getMinU();
tessellator.addVertexWithUV((double)x + d5, (double)(y + 1) + d4, (double)(z + 1) + d4, d0, d1); double minV = (double) iicon.getMinV();
tessellator.addVertexWithUV((double)x + d5, (double)(y + 1) + d4, (double)(z + 0) - d4, d2, d1); double maxU = (double) iicon.getMaxU();
tessellator.addVertexWithUV((double)x + d5, (double)(y + 0) - d4, (double)(z + 0) - d4, d2, d3); 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) if(l == 5) {
{ tessellator.addVertexWithUV((double) x + wallOffset, (double) (y + 1) + scale, (double) (z + 1) + scale, d0, d1);
tessellator.addVertexWithUV((double)(x + 1) - d5, (double)(y + 0) - d4, (double)(z + 1) + d4, d2, d3); tessellator.addVertexWithUV((double) x + wallOffset, (double) (y + 0) - scale, (double) (z + 1) + scale, d0, d3);
tessellator.addVertexWithUV((double)(x + 1) - d5, (double)(y + 1) + d4, (double)(z + 1) + d4, d2, d1); tessellator.addVertexWithUV((double) x + wallOffset, (double) (y + 0) - scale, (double) (z + 0) - scale, d2, d3);
tessellator.addVertexWithUV((double)(x + 1) - d5, (double)(y + 1) + d4, (double)(z + 0) - d4, d0, d1); tessellator.addVertexWithUV((double) x + wallOffset, (double) (y + 1) + scale, (double) (z + 0) - scale, d2, 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 == 3) 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 + 1) + d4, (double)(y + 0) - d4, (double)z + d5, d2, d3); tessellator.addVertexWithUV((double) x + wallOffset, (double) (y + 1) + scale, (double) (z + 0) - scale, d2, d1);
tessellator.addVertexWithUV((double)(x + 1) + d4, (double)(y + 1) + d4, (double)z + d5, d2, d1); tessellator.addVertexWithUV((double) x + wallOffset, (double) (y + 0) - scale, (double) (z + 0) - scale, d2, d3);
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);
}
if (l == 2) if(l == 4) {
{ tessellator.addVertexWithUV((double) (x + 1) - wallOffset, (double) (y + 0) - scale, (double) (z + 1) + scale, d2, d3);
tessellator.addVertexWithUV((double)(x + 1) + d4, (double)(y + 1) + d4, (double)(z + 1) - d5, d0, d1); tessellator.addVertexWithUV((double) (x + 1) - wallOffset, (double) (y + 1) + scale, (double) (z + 1) + scale, d2, d1);
tessellator.addVertexWithUV((double)(x + 1) + d4, (double)(y + 0) - d4, (double)(z + 1) - d5, d0, d3); tessellator.addVertexWithUV((double) (x + 1) - wallOffset, (double) (y + 1) + scale, (double) (z + 0) - scale, d0, 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 + 0) - scale, (double) (z + 0) - scale, d0, d3);
tessellator.addVertexWithUV((double)(x + 0) - d4, (double)(y + 1) + d4, (double)(z + 1) - d5, d2, d1);
tessellator.addVertexWithUV((double)(x + 1) + d4, (double)(y + 0) - d4, (double)(z + 1) - d5, d0, d3); tessellator.addVertexWithUV((double) (x + 1) - wallOffset, (double) (y + 1) + scale, (double) (z + 1) + scale, d2, d1);
tessellator.addVertexWithUV((double)(x + 1) + d4, (double)(y + 1) + d4, (double)(z + 1) - d5, d0, d1); tessellator.addVertexWithUV((double) (x + 1) - wallOffset, (double) (y + 0) - scale, (double) (z + 1) + scale, d2, d3);
tessellator.addVertexWithUV((double)(x + 0) - d4, (double)(y + 1) + d4, (double)(z + 1) - d5, d2, d1); tessellator.addVertexWithUV((double) (x + 1) - wallOffset, (double) (y + 0) - scale, (double) (z + 0) - scale, d0, d3);
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 + 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 @Override

View File

@ -28,7 +28,7 @@ public class RenderFluidDuct extends TileEntitySpecialRenderer {
{ {
if(cable.connections[i] != null) if(cable.connections[i] != null)
{ {
drawConnection(cable.connections[i], cable.type.getColor()); drawConnection(cable.connections[i], cable.getType().getColor());
} }
} }
GL11.glTranslated(-offsetX, -offsetY, -offsetZ); GL11.glTranslated(-offsetX, -offsetY, -offsetZ);

View File

@ -76,6 +76,7 @@ public class TileMappings {
put(TileEntityStructureMarker.class, "tileentity_structure_marker"); put(TileEntityStructureMarker.class, "tileentity_structure_marker");
put(TileEntityMachineMiningDrill.class, "tileentity_mining_drill"); put(TileEntityMachineMiningDrill.class, "tileentity_mining_drill");
put(TileEntityMachineAssembler.class, "tileentity_assembly_machine"); put(TileEntityMachineAssembler.class, "tileentity_assembly_machine");
put(TileEntityFluidDuctSimple.class, "tileentity_universal_duct_simple");
put(TileEntityFluidDuct.class, "tileentity_universal_duct"); put(TileEntityFluidDuct.class, "tileentity_universal_duct");
put(TileEntityMachineChemplant.class, "tileentity_chemical_plant"); put(TileEntityMachineChemplant.class, "tileentity_chemical_plant");
put(TileEntityMachineFluidTank.class, "tileentity_fluid_tank"); put(TileEntityMachineFluidTank.class, "tileentity_fluid_tank");

View File

@ -10,31 +10,25 @@ import com.hbm.inventory.fluid.FluidType;
import com.hbm.inventory.fluid.Fluids; import com.hbm.inventory.fluid.Fluids;
import com.hbm.lib.Library; import com.hbm.lib.Library;
import com.hbm.packet.PacketDispatcher; import com.hbm.packet.PacketDispatcher;
import com.hbm.packet.TEFluidPipePacket;
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint; import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.nbt.NBTTagCompound; 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.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection; 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 ForgeDirection[] connections = new ForgeDirection[6];
public FluidType type = Fluids.NONE;
public List<UnionOfTileEntitiesAndBooleansForFluids> uoteab = new ArrayList<UnionOfTileEntitiesAndBooleansForFluids>();
public TileEntityFluidDuct() { public TileEntityFluidDuct() { }
}
@Override @Override
public void updateEntity() { 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(); 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; if(Library.checkFluidConnectables(this.worldObj, xCoord - 1, yCoord, zCoord, type)) connections[5] = ForgeDirection.WEST;
else connections[5] = null; 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 @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public double getMaxRenderDistanceSquared() public double getMaxRenderDistanceSquared() {
{
return 65536.0D; return 65536.0D;
} }
@Override
public FluidType getType() {
return type;
}
} }

View File

@ -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;
}
}

View File

@ -79,4 +79,9 @@ public class TileEntityGasDuct extends TileEntity implements IFluidDuct {
public FluidType getType() { public FluidType getType() {
return type; return type;
} }
@Override
public boolean setType(FluidType type) {
return false;
}
} }

View File

@ -20,4 +20,8 @@ public class TileEntityGasDuctSolid extends TileEntity implements IFluidDuct {
return type; return type;
} }
@Override
public boolean setType(FluidType type) {
return false;
}
} }

View File

@ -78,4 +78,9 @@ public class TileEntityOilDuct extends TileEntity implements IFluidDuct {
public FluidType getType() { public FluidType getType() {
return type; return type;
} }
@Override
public boolean setType(FluidType type) {
return false;
}
} }

View File

@ -20,4 +20,8 @@ public class TileEntityOilDuctSolid extends TileEntity implements IFluidDuct {
return type; 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