Added colored pipes
This commit is contained in:
parent
d28bbbdeb4
commit
dad66a5f62
4 changed files with 80 additions and 50 deletions
|
@ -256,14 +256,11 @@ public class PartFramedWire extends PartFramedConnection<EnumWireMaterial, ICond
|
||||||
@Override
|
@Override
|
||||||
protected boolean canConnectTo(TileEntity tile, ForgeDirection side)
|
protected boolean canConnectTo(TileEntity tile, ForgeDirection side)
|
||||||
{
|
{
|
||||||
return tile instanceof IConductor || canConnectToObj(tile, side);
|
Object obj = tile instanceof TileMultipart ? ((TileMultipart) tile).partMap(ForgeDirection.UNKNOWN.ordinal()) : tile;
|
||||||
}
|
|
||||||
|
|
||||||
protected boolean canConnectToObj(Object obj, ForgeDirection dir)
|
if (obj instanceof PartFramedWire)
|
||||||
{
|
{
|
||||||
if (obj != null && (obj.getClass().isAssignableFrom(this.getClass()) || this.getClass().isAssignableFrom(obj.getClass())))
|
PartFramedWire wire = (PartFramedWire) obj;
|
||||||
{
|
|
||||||
PartAdvancedWire wire = (PartAdvancedWire) obj;
|
|
||||||
|
|
||||||
if (this.getMaterial() == wire.getMaterial())
|
if (this.getMaterial() == wire.getMaterial())
|
||||||
{
|
{
|
||||||
|
@ -274,15 +271,13 @@ public class PartFramedWire extends PartFramedConnection<EnumWireMaterial, ICond
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else if (!(obj instanceof IConductor))
|
|
||||||
{
|
|
||||||
return CompatibilityModule.canConnect(obj, dir.getOpposite(), this);
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return CompatibilityModule.canConnect(obj, side.getOpposite(), this);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IConductor getConnector(TileEntity tile)
|
public IConductor getConnector(TileEntity tile)
|
||||||
{
|
{
|
||||||
|
|
|
@ -25,6 +25,7 @@ import codechicken.lib.vec.Translation;
|
||||||
import codechicken.microblock.IHollowConnect;
|
import codechicken.microblock.IHollowConnect;
|
||||||
import codechicken.multipart.JNormalOcclusion;
|
import codechicken.multipart.JNormalOcclusion;
|
||||||
import codechicken.multipart.TSlottedPart;
|
import codechicken.multipart.TSlottedPart;
|
||||||
|
import codechicken.multipart.TileMultipart;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
|
@ -34,15 +35,16 @@ public class PartPipe extends PartFramedConnection<EnumPipeMaterial, IFluidPipe,
|
||||||
private int pressure;
|
private int pressure;
|
||||||
private boolean markPacket = true;
|
private boolean markPacket = true;
|
||||||
|
|
||||||
public PartPipe()
|
|
||||||
{
|
|
||||||
super();
|
|
||||||
material = EnumPipeMaterial.COPPER;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PartPipe(int typeID)
|
public PartPipe(int typeID)
|
||||||
{
|
{
|
||||||
|
super();
|
||||||
material = EnumPipeMaterial.values()[typeID];
|
material = EnumPipeMaterial.values()[typeID];
|
||||||
|
requiresInsulation = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PartPipe()
|
||||||
|
{
|
||||||
|
this(EnumPipeMaterial.COPPER.ordinal());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -67,13 +69,13 @@ public class PartPipe extends PartFramedConnection<EnumPipeMaterial, IFluidPipe,
|
||||||
{
|
{
|
||||||
NBTTagCompound nbt = new NBTTagCompound();
|
NBTTagCompound nbt = new NBTTagCompound();
|
||||||
tank.writeToNBT(nbt);
|
tank.writeToNBT(nbt);
|
||||||
tile().getWriteStream(this).writeByte(1).writeNBTTagCompound(nbt);
|
tile().getWriteStream(this).writeByte(3).writeNBTTagCompound(nbt);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(MCDataInput packet, int packetID)
|
public void read(MCDataInput packet, int packetID)
|
||||||
{
|
{
|
||||||
if (packetID == 1)
|
if (packetID == 3)
|
||||||
{
|
{
|
||||||
tank = new FluidTank(FluidContainerRegistry.BUCKET_VOLUME);
|
tank = new FluidTank(FluidContainerRegistry.BUCKET_VOLUME);
|
||||||
tank.readFromNBT(packet.readNBTTagCompound());
|
tank.readFromNBT(packet.readNBTTagCompound());
|
||||||
|
@ -198,7 +200,19 @@ public class PartPipe extends PartFramedConnection<EnumPipeMaterial, IFluidPipe,
|
||||||
@Override
|
@Override
|
||||||
protected boolean canConnectTo(TileEntity tile, ForgeDirection dir)
|
protected boolean canConnectTo(TileEntity tile, ForgeDirection dir)
|
||||||
{
|
{
|
||||||
return tile instanceof IFluidHandler;// && (((IFluidHandler) tile).canFill(dir.getOpposite(), null) || ((IFluidHandler) tile).canDrain(dir.getOpposite(), null));
|
Object obj = tile instanceof TileMultipart ? ((TileMultipart) tile).partMap(ForgeDirection.UNKNOWN.ordinal()) : tile;
|
||||||
|
|
||||||
|
if (obj instanceof PartPipe)
|
||||||
|
{
|
||||||
|
if (this.getMaterial() == ((PartPipe) obj).getMaterial())
|
||||||
|
{
|
||||||
|
return getColor() == ((PartPipe) obj).getColor() || (getColor() == DEFAULT_COLOR || ((PartPipe) obj).getColor() == DEFAULT_COLOR);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return tile instanceof IFluidHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -2,6 +2,7 @@ package resonantinduction.mechanical.fluid.pipe;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
|
|
||||||
|
import net.minecraft.item.ItemDye;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
import net.minecraftforge.common.ForgeDirection;
|
||||||
|
@ -9,6 +10,8 @@ import net.minecraftforge.fluids.FluidStack;
|
||||||
|
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
|
import codechicken.lib.colour.Colour;
|
||||||
|
import codechicken.lib.colour.ColourARGB;
|
||||||
import resonantinduction.core.Reference;
|
import resonantinduction.core.Reference;
|
||||||
import resonantinduction.core.render.RenderFluidHelper;
|
import resonantinduction.core.render.RenderFluidHelper;
|
||||||
import calclavia.lib.render.RenderUtility;
|
import calclavia.lib.render.RenderUtility;
|
||||||
|
@ -30,6 +33,17 @@ public class RenderPipe implements ISimpleItemRenderer
|
||||||
GL11.glPushMatrix();
|
GL11.glPushMatrix();
|
||||||
GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F);
|
GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F);
|
||||||
GL11.glScalef(1.0F, -1F, -1F);
|
GL11.glScalef(1.0F, -1F, -1F);
|
||||||
|
|
||||||
|
if (part.getColor() > 0)
|
||||||
|
{
|
||||||
|
Color insulationColour = new Color(ItemDye.dyeColors[part.getColor()]);
|
||||||
|
GL11.glColor4f(insulationColour.getRed() / 255f, insulationColour.getGreen() / 255f, insulationColour.getBlue() / 255f, 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GL11.glColor4f(1, 1, 1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
render(0, part.getAllCurrentConnections());
|
render(0, part.getAllCurrentConnections());
|
||||||
GL11.glPopMatrix();
|
GL11.glPopMatrix();
|
||||||
|
|
||||||
|
|
|
@ -7,11 +7,13 @@ import java.util.List;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockColored;
|
import net.minecraft.block.BlockColored;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemShears;
|
import net.minecraft.item.ItemShears;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.util.MovingObjectPosition;
|
import net.minecraft.util.MovingObjectPosition;
|
||||||
import resonantinduction.core.MultipartUtility;
|
import resonantinduction.core.MultipartUtility;
|
||||||
|
import resonantinduction.electrical.charger.PartCharger;
|
||||||
import codechicken.lib.data.MCDataInput;
|
import codechicken.lib.data.MCDataInput;
|
||||||
import codechicken.lib.data.MCDataOutput;
|
import codechicken.lib.data.MCDataOutput;
|
||||||
|
|
||||||
|
@ -26,6 +28,7 @@ public abstract class PartColorableMaterial<M extends Enum> extends PartAdvanced
|
||||||
|
|
||||||
public M material;
|
public M material;
|
||||||
public boolean isInsulated = false;
|
public boolean isInsulated = false;
|
||||||
|
public boolean requiresInsulation = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Material Methods
|
* Material Methods
|
||||||
|
@ -90,18 +93,19 @@ public abstract class PartColorableMaterial<M extends Enum> extends PartAdvanced
|
||||||
*/
|
*/
|
||||||
public int getColor()
|
public int getColor()
|
||||||
{
|
{
|
||||||
return this.isInsulated ? this.color : -1;
|
return isInsulated || !requiresInsulation ? color : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setColor(int dye)
|
public void setColor(int dye)
|
||||||
{
|
{
|
||||||
if (this.isInsulated)
|
if (isInsulated || !requiresInsulation)
|
||||||
{
|
{
|
||||||
this.color = dye;
|
this.color = dye;
|
||||||
|
|
||||||
if (!this.world().isRemote)
|
if (!world().isRemote)
|
||||||
{
|
{
|
||||||
tile().notifyPartChange(this);
|
tile().notifyPartChange(this);
|
||||||
|
onPartChanged(this);
|
||||||
this.sendColorUpdate();
|
this.sendColorUpdate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -122,9 +126,9 @@ public abstract class PartColorableMaterial<M extends Enum> extends PartAdvanced
|
||||||
{
|
{
|
||||||
int dyeColor = MultipartUtility.isDye(itemStack);
|
int dyeColor = MultipartUtility.isDye(itemStack);
|
||||||
|
|
||||||
if (dyeColor != -1 && this.isInsulated())
|
if (dyeColor != -1 && (isInsulated() || !requiresInsulation))
|
||||||
{
|
{
|
||||||
if (!player.capabilities.isCreativeMode)
|
if (!player.capabilities.isCreativeMode && requiresInsulation)
|
||||||
{
|
{
|
||||||
player.inventory.decrStackSize(player.inventory.currentItem, 1);
|
player.inventory.decrStackSize(player.inventory.currentItem, 1);
|
||||||
}
|
}
|
||||||
|
@ -132,7 +136,9 @@ public abstract class PartColorableMaterial<M extends Enum> extends PartAdvanced
|
||||||
this.setColor(dyeColor);
|
this.setColor(dyeColor);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (itemStack.itemID == Block.cloth.blockID)
|
else if (requiresInsulation)
|
||||||
|
{
|
||||||
|
if (itemStack.itemID == Block.cloth.blockID)
|
||||||
{
|
{
|
||||||
if (this.isInsulated())
|
if (this.isInsulated())
|
||||||
{
|
{
|
||||||
|
@ -163,6 +169,7 @@ public abstract class PartColorableMaterial<M extends Enum> extends PartAdvanced
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setInsulated(false);
|
this.setInsulated(false);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -176,7 +183,7 @@ public abstract class PartColorableMaterial<M extends Enum> extends PartAdvanced
|
||||||
List<ItemStack> drops = new ArrayList<ItemStack>();
|
List<ItemStack> drops = new ArrayList<ItemStack>();
|
||||||
drops.add(getItem());
|
drops.add(getItem());
|
||||||
|
|
||||||
if (this.isInsulated)
|
if (requiresInsulation && isInsulated)
|
||||||
{
|
{
|
||||||
drops.add(new ItemStack(Block.cloth, 1, BlockColored.getBlockFromDye(color)));
|
drops.add(new ItemStack(Block.cloth, 1, BlockColored.getBlockFromDye(color)));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue