where do i begin
I've made a mess of changes since last upload. Main big change is change in forge file formate that merged minecraft and common folder. The other is the complete rewrite to Forge Liquid api. So far only the pump, boiler, and pipe are converted to the new system. The pipe will actual not fully work with most machines since it can't drain liquids out of machines. In future update there will be a block to do this called a pipe pump. Other than those changes nothing much is diffrent.
This commit is contained in:
parent
a688f25511
commit
494d98bb05
56 changed files with 1858 additions and 2043 deletions
|
@ -1,39 +0,0 @@
|
|||
package dark.BasicUtilities.api;
|
||||
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
/**
|
||||
* Based off of Calclavia's old wire API
|
||||
* @author DarkGuardsman
|
||||
*
|
||||
*/
|
||||
|
||||
public interface IConsumer
|
||||
{
|
||||
/**
|
||||
* onRecieveLiquid
|
||||
* @param vol - The amount this block received.
|
||||
* @param side - The side of the block in which the liquid came from.
|
||||
* @parm type - The type of liquid being received
|
||||
* @return vol - The amount liquid that can't be recieved
|
||||
*/
|
||||
public int onReceiveLiquid(Liquid type, int vol, ForgeDirection side);
|
||||
|
||||
/**
|
||||
* You can use this to check if a pipe can connect to this liquid consumer to properly render the graphics
|
||||
* @param forgeDirection - The side in which the volume is coming from.
|
||||
* @parm type - The type of liquid
|
||||
* @return Returns true or false if this consumer can receive a volume at this given tick or moment.
|
||||
*/
|
||||
public boolean canRecieveLiquid(Liquid type, ForgeDirection forgeDirection);
|
||||
|
||||
/**
|
||||
* @return Return the stored liquid of type in this consumer.
|
||||
*/
|
||||
public int getStoredLiquid(Liquid type);
|
||||
|
||||
/**
|
||||
* @return Return the maximum amount of stored liquid this consumer can get.
|
||||
*/
|
||||
public int getLiquidCapacity(Liquid type);
|
||||
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
package dark.BasicUtilities.api;
|
||||
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
/**
|
||||
* Based off of Calclavia's old wire API
|
||||
* @author DarkGuardsman
|
||||
*
|
||||
*/
|
||||
public interface IProducer
|
||||
{
|
||||
/**
|
||||
* onProduceLiquid
|
||||
* block.
|
||||
* @param type - the type of liquid
|
||||
* @param maxvol - The maximum vol or requested volume
|
||||
* @param side - The side
|
||||
* @return vol - Return a vol of liquid type that is produced
|
||||
*/
|
||||
public int onProduceLiquid(Liquid type, int maxVol, ForgeDirection side);
|
||||
/**
|
||||
* canProduceLiquid
|
||||
* block.
|
||||
* @param type - the type of liquid
|
||||
* @param side - The side
|
||||
* @return boolean - True if can, false if can't produce liquid of type or on that side
|
||||
* Also used for connection rules of pipes'
|
||||
*/
|
||||
public boolean canProduceLiquid(Liquid type, ForgeDirection side);
|
||||
public boolean canProducePresure(Liquid type, ForgeDirection side);
|
||||
/**
|
||||
*
|
||||
* @param type - liquid type
|
||||
* @param side - side this of presure
|
||||
* @return pressure that is used to output liquid on
|
||||
*/
|
||||
public int presureOutput(Liquid type, ForgeDirection side);
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
package dark.BasicUtilities.api;
|
||||
|
||||
public interface IStorageTank extends IConsumer {
|
||||
|
||||
}
|
|
@ -1,70 +0,0 @@
|
|||
package dark.BasicUtilities.api;
|
||||
|
||||
import net.minecraft.src.Block;
|
||||
|
||||
/**
|
||||
* System too easily reference a liquid type and its info
|
||||
*
|
||||
* @author Rseifert
|
||||
*
|
||||
*/
|
||||
public enum Liquid
|
||||
{
|
||||
// -1 == null || unused
|
||||
STEAM("Steam", false, true, true, -1, -1, 100),
|
||||
WATER("Water", false, false, true, Block.waterStill.blockID, Block.waterMoving.blockID, 32),
|
||||
LAVA("Lava", false, false, true, Block.lavaStill.blockID, Block.lavaMoving.blockID, 20),
|
||||
OIL("Oil", true, false, true, -1, -1, 32), // BasicComponents.oilStill.blockID,BasicComponents.oilMoving.blockID),
|
||||
Fuel("Fuel", true, false, true, -1, -1, 40),
|
||||
Air("Air", false, true, false, 0, -1, 100),
|
||||
Methain("Methain", true, true, false, -1, -1, 100),
|
||||
BioFuel("BioFuel", true, false, false, -1, -1, 40),
|
||||
Coolent("Coolent", false, false, false, -1, -1, 40),
|
||||
NukeWaste("NukeWaste", false, false, false, -1, -1, 20),
|
||||
Ether("Ether", false, false, false, -1, -1, 100),
|
||||
HEAT("HEAT", false, false, false, -1, -1, -1),
|
||||
DEFUALT("Empty", false, false, false, -1, -1, 0);
|
||||
public final boolean flamable;// can it catch on fire, not used but might be
|
||||
public final boolean isGas;// is it a gas, used to find if it floats
|
||||
public final boolean showMenu;
|
||||
public final int Still;// if there is a block of still liquid linked to this
|
||||
public final int Moving;// if there is a block of moving liquid linked to
|
||||
// this
|
||||
public final String lName;// Default name for the liquid
|
||||
public final int defaultPresure;// default pressure output of the liquid
|
||||
|
||||
private Liquid(String name, boolean flame, boolean gas, boolean show, int block, int Moving, int dPressure)
|
||||
{
|
||||
this.flamable = flame;
|
||||
this.showMenu = show;
|
||||
this.isGas = gas;
|
||||
this.Still = block;
|
||||
this.Moving = Moving;
|
||||
this.lName = name;
|
||||
this.defaultPresure = dPressure;
|
||||
}
|
||||
|
||||
/**
|
||||
* Only use this if you are converting from the old system Or have a special
|
||||
* need for it
|
||||
*
|
||||
* @param id
|
||||
* of liquid
|
||||
* @return Liquid Object
|
||||
*/
|
||||
public static Liquid getLiquid(int id)
|
||||
{
|
||||
if (id >= 0 && id < Liquid.values().length) { return Liquid.values()[id]; }
|
||||
return DEFUALT;
|
||||
}
|
||||
|
||||
public static Liquid getLiquidByBlock(int bBlock)
|
||||
{
|
||||
for (int i = 0; i < Liquid.values().length; i++)
|
||||
{
|
||||
Liquid selected = Liquid.getLiquid(i);
|
||||
if (bBlock == selected.Still) { return selected; }
|
||||
}
|
||||
return Liquid.DEFUALT;
|
||||
}
|
||||
}
|
|
@ -1,110 +0,0 @@
|
|||
package dark.BasicUtilities.machines;
|
||||
|
||||
import net.minecraft.src.NBTTagCompound;
|
||||
import net.minecraft.src.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import universalelectricity.core.implement.IElectricityReceiver;
|
||||
import dark.BasicUtilities.api.IProducer;
|
||||
import dark.BasicUtilities.api.Liquid;
|
||||
|
||||
public class TileEntityCondenser extends TileEntity implements IProducer, IElectricityReceiver {
|
||||
int tickCount = 0;
|
||||
int waterStored = 0;
|
||||
int energyStored = 0;
|
||||
@Override
|
||||
public int onProduceLiquid(Liquid type,int maxVol, ForgeDirection side) {
|
||||
if(type == Liquid.WATER)
|
||||
{
|
||||
int tradeW = Math.min(maxVol, waterStored);
|
||||
waterStored -= tradeW;
|
||||
return tradeW;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
public void writeToNBT(NBTTagCompound par1NBTTagCompound)
|
||||
{
|
||||
super.writeToNBT(par1NBTTagCompound);
|
||||
par1NBTTagCompound.setInteger("energyStored", (int)this.energyStored);
|
||||
par1NBTTagCompound.setInteger("waterStored", (int)this.waterStored);
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound par1NBTTagCompound)
|
||||
{
|
||||
super.readFromNBT(par1NBTTagCompound);
|
||||
this.energyStored = par1NBTTagCompound.getInteger("energyStored");
|
||||
this.waterStored = par1NBTTagCompound.getInteger("waterStored");
|
||||
}
|
||||
public void updateEntity()
|
||||
{
|
||||
if(energyStored > 100 && waterStored < 3)
|
||||
{
|
||||
energyStored -= 100;
|
||||
waterStored += 1;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public boolean canProduceLiquid(Liquid type, ForgeDirection side) {
|
||||
if(type == Liquid.WATER)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public void onDisable(int duration) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
@Override
|
||||
public boolean isDisabled() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public double wattRequest() {
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canReceiveFromSide(ForgeDirection side) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public int presureOutput(Liquid type, ForgeDirection side) {
|
||||
if(type == Liquid.WATER)
|
||||
{
|
||||
return 32;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public boolean canProducePresure(Liquid type, ForgeDirection side) {
|
||||
if(type == Liquid.WATER)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean canConnect(ForgeDirection side) {
|
||||
// TODO Auto-generated method stub
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public double getVoltage() {
|
||||
// TODO Auto-generated method stub
|
||||
return 120;
|
||||
}
|
||||
@Override
|
||||
public void onReceive(Object sender, double amps, double voltage, ForgeDirection side)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,237 +0,0 @@
|
|||
package dark.BasicUtilities.machines;
|
||||
|
||||
import net.minecraft.src.EntityPlayer;
|
||||
import net.minecraft.src.INetworkManager;
|
||||
import net.minecraft.src.NBTTagCompound;
|
||||
import net.minecraft.src.Packet;
|
||||
import net.minecraft.src.Packet250CustomPayload;
|
||||
import net.minecraft.src.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import universalelectricity.core.implement.IElectricityReceiver;
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
import universalelectricity.prefab.network.IPacketReceiver;
|
||||
import universalelectricity.prefab.network.PacketManager;
|
||||
import universalelectricity.prefab.tile.TileEntityElectricityReceiver;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
||||
import dark.BasicUtilities.BasicUtilitiesMain;
|
||||
import dark.BasicUtilities.api.IProducer;
|
||||
import dark.BasicUtilities.api.Liquid;
|
||||
import dark.BasicUtilities.api.MHelper;
|
||||
|
||||
public class TileEntityPump extends TileEntityElectricityReceiver implements IProducer, IElectricityReceiver, IPacketReceiver
|
||||
{
|
||||
int dCount = 0;
|
||||
float eStored = 0;
|
||||
float eMax = 2000;
|
||||
int lStored = 0;
|
||||
int wMax = 10;
|
||||
public Liquid type = Liquid.DEFUALT;
|
||||
public TileEntity[] connectedBlocks =
|
||||
{ null, null, null, null, null, null };
|
||||
|
||||
private int count = 0;
|
||||
private int count2 = 0;
|
||||
|
||||
protected boolean firstUpdate = true;
|
||||
|
||||
@Override
|
||||
public void onDisable(int duration)
|
||||
{
|
||||
dCount = duration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDisabled()
|
||||
{
|
||||
if (dCount <= 0) { return false; }
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
super.updateEntity();
|
||||
if (count++ >= 20)
|
||||
{
|
||||
count = 0;
|
||||
connectedBlocks = MHelper.getSourounding(worldObj, xCoord, yCoord, zCoord);
|
||||
|
||||
eStored += 200; // TODO remove after testing
|
||||
if (!worldObj.isRemote)
|
||||
{
|
||||
if (firstUpdate || count2++ >= 5)
|
||||
{
|
||||
int bBlock = worldObj.getBlockId(xCoord, yCoord - 1, zCoord);
|
||||
Liquid bellow = Liquid.getLiquidByBlock(bBlock);
|
||||
|
||||
if (bellow != null && this.lStored <= 0) // TODO correct for full
|
||||
// pump
|
||||
{
|
||||
this.type = bellow;
|
||||
}
|
||||
count2 = 0;
|
||||
firstUpdate = false;
|
||||
Packet packet = PacketManager.getPacket(BasicUtilitiesMain.CHANNEL, this, this.type.ordinal());
|
||||
PacketManager.sendPacketToClients(packet, worldObj, Vector3.get(this), 60);
|
||||
}
|
||||
|
||||
this.drainBlock(new Vector3(xCoord, yCoord - 1, zCoord));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* drains the block or in other words removes it
|
||||
*
|
||||
* @param loc
|
||||
* @return true if the block was drained
|
||||
*/
|
||||
public boolean drainBlock(Vector3 loc)
|
||||
{
|
||||
int bBlock = worldObj.getBlockId(loc.intX(), loc.intY(), loc.intZ());
|
||||
Liquid bellow = Liquid.getLiquidByBlock(bBlock);
|
||||
if (bBlock == type.Still && this.eStored >= 200 && this.lStored < this.wMax)
|
||||
{
|
||||
eStored -= 200;
|
||||
lStored += 1;
|
||||
worldObj.setBlockAndMetadataWithNotify(xCoord, yCoord - 1, zCoord, 0, 0);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to find the farthest source from the center location
|
||||
*
|
||||
* @param loc
|
||||
* - center of search bounds
|
||||
* @param maxRange
|
||||
* - max search range
|
||||
* @param liquid
|
||||
* - liquid being searched for, if has no block registered to it
|
||||
* returns null
|
||||
*/
|
||||
public Vector3 findDistanceSource(Vector3 loc, int maxRange, Liquid liquid)
|
||||
{
|
||||
// TODO create a way to scan the outer bounds
|
||||
// looking for a source of x liquid
|
||||
if (liquid.Still != 0 && liquid.Still != -1)
|
||||
{
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canReceiveFromSide(ForgeDirection side)
|
||||
{
|
||||
if (side != ForgeDirection.DOWN) { return true; }
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int onProduceLiquid(Liquid type, int maxVol, ForgeDirection side)
|
||||
{
|
||||
if (type == this.type && lStored > 0 && maxVol > 0)
|
||||
{
|
||||
lStored -= 1;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProduceLiquid(Liquid type, ForgeDirection side)
|
||||
{
|
||||
int meta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord);
|
||||
int facing = 0;
|
||||
switch (meta)
|
||||
{
|
||||
case 0:
|
||||
facing = 2;
|
||||
break;
|
||||
case 1:
|
||||
facing = 5;
|
||||
break;
|
||||
case 2:
|
||||
facing = 3;
|
||||
break;
|
||||
case 3:
|
||||
facing = 4;
|
||||
break;
|
||||
}
|
||||
|
||||
if (type == this.type && side != ForgeDirection.DOWN && side != ForgeDirection.UP && side != ForgeDirection.getOrientation(facing).getOpposite()) { return true; }
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int presureOutput(Liquid type, ForgeDirection side)
|
||||
{
|
||||
if (type == this.type) { return type.defaultPresure; }
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProducePresure(Liquid type, ForgeDirection side)
|
||||
{
|
||||
if (type == this.type) { return true; }
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceive(Object sender, double amps, double voltage, ForgeDirection side)
|
||||
{
|
||||
if (wattRequest() > 0 && canConnect(side))
|
||||
{
|
||||
double watts =(amps * voltage);
|
||||
float rejectedElectricity = (float) Math.max((this.eStored + watts) - this.eMax, 0.0);
|
||||
this.eStored = (float) Math.max(this.eStored + watts - rejectedElectricity, 0.0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public double wattRequest()
|
||||
{
|
||||
return Math.max(eMax - eStored, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacketData(INetworkManager network, int packetType, Packet250CustomPayload packet, EntityPlayer player, ByteArrayDataInput data)
|
||||
{
|
||||
try
|
||||
{
|
||||
this.type = (Liquid.getLiquid(data.readInt()));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a tile entity from NBT.
|
||||
*/
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound par1NBTTagCompound)
|
||||
{
|
||||
super.readFromNBT(par1NBTTagCompound);
|
||||
this.lStored = par1NBTTagCompound.getInteger("liquid");
|
||||
this.type = Liquid.getLiquid(par1NBTTagCompound.getInteger("type"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a tile entity to NBT.
|
||||
*/
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound par1NBTTagCompound)
|
||||
{
|
||||
super.writeToNBT(par1NBTTagCompound);
|
||||
par1NBTTagCompound.setInteger("liquid", this.lStored);
|
||||
par1NBTTagCompound.setInteger("type", this.type.ordinal());
|
||||
}
|
||||
}
|
|
@ -1,234 +0,0 @@
|
|||
package dark.BasicUtilities.mechanical;
|
||||
|
||||
import net.minecraft.src.EntityPlayer;
|
||||
import net.minecraft.src.INetworkManager;
|
||||
import net.minecraft.src.Packet250CustomPayload;
|
||||
import net.minecraft.src.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import universalelectricity.core.electricity.ElectricityManager;
|
||||
import universalelectricity.core.implement.IConductor;
|
||||
import universalelectricity.core.implement.IElectricityProducer;
|
||||
import universalelectricity.prefab.network.IPacketReceiver;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
||||
import dark.BasicUtilities.BasicUtilitiesMain;
|
||||
import dark.BasicUtilities.api.IForce;
|
||||
import dark.BasicUtilities.api.IReadOut;
|
||||
import dark.Library.Util.MetaGroupingHelper;
|
||||
import dark.Library.prefab.TileEntityMachine;
|
||||
|
||||
public class TileEntityGen extends TileEntityMachine implements IPacketReceiver, IForce, IElectricityProducer,IReadOut
|
||||
{
|
||||
ForgeDirection facing = ForgeDirection.DOWN;
|
||||
|
||||
public int force = 0;// current total force
|
||||
public int aForce = 0;// force this unit can apply
|
||||
public int pos = 0;// current pos of rotation max of 8
|
||||
public int disableTicks = 0;// time disabled
|
||||
public double genAmmount = 0;// watt output of machine
|
||||
public int tCount = 0;
|
||||
|
||||
IConductor[] wires =
|
||||
{ null, null, null, null, null, null };
|
||||
|
||||
public boolean needUpdate()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
this.genAmmount = force / this.getVoltage();
|
||||
int wireCount = 0;
|
||||
|
||||
facing = ForgeDirection.getOrientation(MetaGroupingHelper.getMeta(worldObj.getBlockMetadata(xCoord, yCoord, zCoord))).getOpposite();
|
||||
|
||||
if (!this.isDisabled())
|
||||
{
|
||||
this.doAnimation();
|
||||
if (worldObj.isRemote)
|
||||
{
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
ForgeDirection side = ForgeDirection.UNKNOWN;
|
||||
switch (i)
|
||||
{
|
||||
case 0:
|
||||
side = ForgeDirection.UP;
|
||||
break;
|
||||
// case 1: side = ForgeDirection.DOWN;break;
|
||||
case 2:
|
||||
side = ForgeDirection.NORTH;
|
||||
break;
|
||||
case 3:
|
||||
side = ForgeDirection.EAST;
|
||||
break;
|
||||
case 4:
|
||||
side = ForgeDirection.SOUTH;
|
||||
break;
|
||||
case 5:
|
||||
side = ForgeDirection.WEST;
|
||||
break;
|
||||
}
|
||||
// update number of connected wires to limit watt output per wire
|
||||
if (side != facing && side != facing.getOpposite())
|
||||
{
|
||||
TileEntity tileEntity = worldObj.getBlockTileEntity(xCoord + side.offsetX, yCoord + side.offsetY, zCoord + side.offsetZ);
|
||||
|
||||
if (tileEntity instanceof IConductor)
|
||||
{
|
||||
if (ElectricityManager.instance.getElectricityRequired(((IConductor) tileEntity).getNetwork()) > 0)
|
||||
{
|
||||
this.wires[i] = (IConductor) tileEntity;
|
||||
wireCount++;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.wires[i] = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.wires[i] = null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
// apply watts as requested to all wires connected
|
||||
for (int side = 0; side < 6; side++)
|
||||
{
|
||||
if (wires[side] instanceof IConductor)
|
||||
{
|
||||
double max = wires[side].getMaxAmps();
|
||||
ElectricityManager.instance.produceElectricity(this, wires[side], Math.min(genAmmount / wireCount, max), this.getVoltage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
super.updateEntity();
|
||||
}
|
||||
|
||||
/**
|
||||
* does the basic animation for the model
|
||||
*/
|
||||
public void doAnimation()
|
||||
{
|
||||
if (worldObj.isRemote)
|
||||
{
|
||||
this.pos += 1;
|
||||
if (pos >= 8 || pos < 0)
|
||||
{
|
||||
pos = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------
|
||||
// Data handling
|
||||
// ------------------------------
|
||||
@Override
|
||||
public void handlePacketData(INetworkManager network, int packetType, Packet250CustomPayload packet, EntityPlayer player, ByteArrayDataInput data)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] getSendData()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getChannel()
|
||||
{
|
||||
return BasicUtilitiesMain.CHANNEL;
|
||||
}
|
||||
|
||||
// ------------------------------
|
||||
// Mechanics
|
||||
// ------------------------------
|
||||
@Override
|
||||
public int getForceSide(ForgeDirection side)
|
||||
{
|
||||
if (side == facing.getOpposite()) { return aForce; }
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getForce()
|
||||
{
|
||||
return this.force;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canOutputSide(ForgeDirection side)
|
||||
{
|
||||
if (side == facing.getOpposite()) { return true; }
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInputSide(ForgeDirection side)
|
||||
{
|
||||
if (side == facing) { return true; }
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int applyForce(int force)
|
||||
{
|
||||
this.force = force;
|
||||
return force;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAnimationPos()
|
||||
{
|
||||
return pos;
|
||||
}
|
||||
|
||||
// ------------------------------
|
||||
// Electric
|
||||
// ------------------------------
|
||||
@Override
|
||||
public void onDisable(int duration)
|
||||
{
|
||||
this.disableTicks = duration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDisabled()
|
||||
{
|
||||
if (disableTicks-- <= 0) { return false; }
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getVoltage()
|
||||
{
|
||||
return 120;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnect(ForgeDirection side)
|
||||
{
|
||||
if (side != ForgeDirection.DOWN && side != facing && side != facing.getOpposite()) { return true; }
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMeterReading(EntityPlayer user, ForgeDirection side)
|
||||
{
|
||||
return this.force+"N Input "+this.genAmmount+"W output";
|
||||
}
|
||||
|
||||
}
|
|
@ -1,235 +0,0 @@
|
|||
package dark.BasicUtilities.pipes;
|
||||
|
||||
import net.minecraft.src.EntityPlayer;
|
||||
import net.minecraft.src.INetworkManager;
|
||||
import net.minecraft.src.NBTTagCompound;
|
||||
import net.minecraft.src.Packet;
|
||||
import net.minecraft.src.Packet250CustomPayload;
|
||||
import net.minecraft.src.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
import universalelectricity.prefab.network.IPacketReceiver;
|
||||
import universalelectricity.prefab.network.PacketManager;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
||||
import dark.BasicUtilities.BasicUtilitiesMain;
|
||||
import dark.BasicUtilities.api.IConsumer;
|
||||
import dark.BasicUtilities.api.IProducer;
|
||||
import dark.BasicUtilities.api.IReadOut;
|
||||
import dark.BasicUtilities.api.Liquid;
|
||||
import dark.BasicUtilities.api.MHelper;
|
||||
|
||||
public class TileEntityPipe extends TileEntity implements IConsumer, IPacketReceiver,IReadOut
|
||||
{
|
||||
protected Liquid type = Liquid.DEFUALT;
|
||||
|
||||
public int capacity = 2;
|
||||
public int presure = 0;
|
||||
public int connectedUnits = 0;
|
||||
public int liquidStored = 0;
|
||||
private int count = 0;
|
||||
private int count2 = 0;
|
||||
|
||||
protected boolean firstUpdate = true;
|
||||
|
||||
public TileEntity[] connectedBlocks =
|
||||
{ null, null, null, null, null, null };
|
||||
|
||||
public int getPressure()
|
||||
{
|
||||
return this.presure;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
if (++count >= 5)
|
||||
{
|
||||
count = 0;
|
||||
this.connectedBlocks = MHelper.getSourounding(worldObj, xCoord, yCoord, zCoord);
|
||||
this.updatePressure();
|
||||
|
||||
if (!worldObj.isRemote)
|
||||
{
|
||||
if (firstUpdate || count2++ >= 5)
|
||||
{
|
||||
count2 = 0;
|
||||
firstUpdate = false;
|
||||
Packet packet = PacketManager.getPacket(BasicUtilitiesMain.CHANNEL, this, this.type.ordinal());
|
||||
PacketManager.sendPacketToClients(packet, worldObj, Vector3.get(this), 60);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(i);
|
||||
|
||||
if (connectedBlocks[i] instanceof IProducer)
|
||||
{
|
||||
int vol = ((IProducer) connectedBlocks[i]).onProduceLiquid(this.type, this.capacity - this.liquidStored, dir);
|
||||
this.liquidStored = Math.min(this.liquidStored + vol,
|
||||
this.capacity);
|
||||
}
|
||||
if (connectedBlocks[i] instanceof IConsumer && this.liquidStored > 0 && this.presure > 0)
|
||||
{
|
||||
if (connectedBlocks[i] instanceof TileEntityPipe)
|
||||
{
|
||||
if (((TileEntityPipe) connectedBlocks[i]).presure < this.presure)
|
||||
{
|
||||
this.liquidStored--;
|
||||
int vol = ((IConsumer) connectedBlocks[i]).onReceiveLiquid(this.type, Math.max(this.liquidStored, 1), dir);
|
||||
this.liquidStored += vol;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.liquidStored = ((IConsumer) connectedBlocks[i]).onReceiveLiquid(this.type, this.liquidStored, dir);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* used to cause the pipes pressure to update depending on what is connected
|
||||
* to it
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public void updatePressure()
|
||||
{
|
||||
int highestPressure = 0;
|
||||
this.connectedUnits = 0;
|
||||
this.presure = 0;
|
||||
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(i);
|
||||
|
||||
if (connectedBlocks[i] instanceof IConsumer && ((IConsumer) connectedBlocks[i]).canRecieveLiquid(this.type, dir))
|
||||
{
|
||||
this.connectedUnits++;
|
||||
if (connectedBlocks[i] instanceof TileEntityPipe)
|
||||
{
|
||||
if (((TileEntityPipe) connectedBlocks[i]).getPressure() > highestPressure)
|
||||
{
|
||||
highestPressure = ((TileEntityPipe) connectedBlocks[i]).getPressure();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (connectedBlocks[i] instanceof IProducer && ((IProducer) connectedBlocks[i]).canProduceLiquid(this.type, dir))
|
||||
{
|
||||
this.connectedUnits++;
|
||||
if (((IProducer) connectedBlocks[i]).canProducePresure(this.type, dir) && ((IProducer) connectedBlocks[i]).presureOutput(this.type, dir) > highestPressure)
|
||||
{
|
||||
highestPressure = ((IProducer) connectedBlocks[i]).presureOutput(this.type, dir);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
connectedBlocks[i] = null;
|
||||
}
|
||||
}
|
||||
this.presure = highestPressure - 1;
|
||||
}
|
||||
|
||||
// ---------------
|
||||
// liquid stuff
|
||||
// ---------------
|
||||
@Override
|
||||
public int onReceiveLiquid(Liquid type, int vol, ForgeDirection side)
|
||||
{
|
||||
if (type == this.type)
|
||||
{
|
||||
int rejectedVolume = Math.max((this.getStoredLiquid(type) + vol) - this.capacity, 0);
|
||||
this.liquidStored = Math.min(Math.max((liquidStored + vol - rejectedVolume), 0), this.capacity);
|
||||
return Math.abs(rejectedVolume);
|
||||
}
|
||||
return vol;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Return the stored volume in this pipe.
|
||||
*/
|
||||
@Override
|
||||
public int getStoredLiquid(Liquid type)
|
||||
{
|
||||
if (type == this.type) { return this.liquidStored; }
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLiquidCapacity(Liquid type)
|
||||
{
|
||||
if (type == this.type) { return this.capacity; }
|
||||
return 0;
|
||||
}
|
||||
|
||||
// find wether or not this side of X block can recieve X liquid type. Also
|
||||
// use to determine connection of a pipe
|
||||
@Override
|
||||
public boolean canRecieveLiquid(Liquid type, ForgeDirection side)
|
||||
{
|
||||
if (type == this.type) { return true; }
|
||||
return false;
|
||||
}
|
||||
|
||||
// returns liquid type
|
||||
public Liquid getType()
|
||||
{
|
||||
return this.type;
|
||||
}
|
||||
|
||||
// used by the item to set the liquid type on spawn
|
||||
public void setType(Liquid rType)
|
||||
{
|
||||
this.type = rType;
|
||||
}
|
||||
|
||||
// ---------------------
|
||||
// data
|
||||
// --------------------
|
||||
@Override
|
||||
public void handlePacketData(INetworkManager network, int packetType, Packet250CustomPayload packet, EntityPlayer player, ByteArrayDataInput data)
|
||||
{
|
||||
try
|
||||
{
|
||||
this.setType(Liquid.getLiquid(data.readInt()));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a tile entity from NBT.
|
||||
*/
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound par1NBTTagCompound)
|
||||
{
|
||||
super.readFromNBT(par1NBTTagCompound);
|
||||
this.liquidStored = par1NBTTagCompound.getInteger("liquid");
|
||||
this.type = Liquid.getLiquid(par1NBTTagCompound.getInteger("type"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a tile entity to NBT.
|
||||
*/
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound par1NBTTagCompound)
|
||||
{
|
||||
super.writeToNBT(par1NBTTagCompound);
|
||||
par1NBTTagCompound.setInteger("liquid", this.liquidStored);
|
||||
par1NBTTagCompound.setInteger("type", this.type.ordinal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMeterReading(EntityPlayer user, ForgeDirection side)
|
||||
{
|
||||
return this.liquidStored+" "+this.type.name()+" @ "+this.presure+"PSI";
|
||||
}
|
||||
}
|
|
@ -1,419 +0,0 @@
|
|||
// Date: 10/8/2012 7:31:40 PM
|
||||
// Template version 1.1
|
||||
// Java generated by Techne
|
||||
// Keep in mind that you still need to fill in some blanks
|
||||
// - ZeuX
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
package dark.BasicUtilities.renders;
|
||||
|
||||
import net.minecraft.src.ModelBase;
|
||||
import net.minecraft.src.ModelRenderer;
|
||||
import dark.BasicUtilities.pipes.TileEntityPipe;
|
||||
import dark.BasicUtilities.tanks.TileEntityLTank;
|
||||
|
||||
public class ModelLiquidTank extends ModelBase
|
||||
{
|
||||
//fields
|
||||
ModelRenderer Mid;
|
||||
ModelRenderer Corner;
|
||||
ModelRenderer Corner2;
|
||||
ModelRenderer Corner3;
|
||||
ModelRenderer Corner4;
|
||||
ModelRenderer C8;
|
||||
ModelRenderer C7;
|
||||
ModelRenderer C6;
|
||||
ModelRenderer C5;
|
||||
ModelRenderer C4;
|
||||
ModelRenderer C;
|
||||
ModelRenderer C3;
|
||||
ModelRenderer C2;
|
||||
ModelRenderer GuageT;
|
||||
ModelRenderer GuageB;
|
||||
ModelRenderer Guage;
|
||||
ModelRenderer GuageR;
|
||||
ModelRenderer GuageGlass;
|
||||
ModelRenderer GuageL;
|
||||
|
||||
ModelRenderer GuageT2;
|
||||
ModelRenderer GuageB2;
|
||||
ModelRenderer Guage2;
|
||||
ModelRenderer GuageR2;
|
||||
ModelRenderer GuageGlass2;
|
||||
ModelRenderer GuageL2;
|
||||
|
||||
ModelRenderer GuageT3;
|
||||
ModelRenderer GuageB3;
|
||||
ModelRenderer Guage3;
|
||||
ModelRenderer GuageR3;
|
||||
ModelRenderer GuageGlass3;
|
||||
ModelRenderer GuageL3;
|
||||
|
||||
ModelRenderer GuageT4;
|
||||
ModelRenderer GuageB4;
|
||||
ModelRenderer Guage4;
|
||||
ModelRenderer GuageR4;
|
||||
ModelRenderer GuageGlass4;
|
||||
ModelRenderer GuageL4;
|
||||
|
||||
ModelRenderer CCBottom;
|
||||
ModelRenderer CCRight;
|
||||
ModelRenderer CCLeft;
|
||||
ModelRenderer CCFront;
|
||||
ModelRenderer CCBack;
|
||||
ModelRenderer CCTop;
|
||||
|
||||
public ModelLiquidTank()
|
||||
{
|
||||
textureWidth = 128;
|
||||
textureHeight = 128;
|
||||
|
||||
Mid = new ModelRenderer(this, 0, 50);
|
||||
Mid.addBox(-6F, 0F, -6F, 12, 14, 12);
|
||||
Mid.setRotationPoint(0F, 9F, 0F);
|
||||
Mid.setTextureSize(128, 128);
|
||||
Mid.mirror = true;
|
||||
setRotation(Mid, 0F, 0F, 0F);
|
||||
Corner = new ModelRenderer(this, 0, 30);
|
||||
Corner.addBox(-1F, 0F, -1F, 2, 16, 2);
|
||||
Corner.setRotationPoint(-7F, 8F, 7F);
|
||||
Corner.setTextureSize(128, 128);
|
||||
Corner.mirror = true;
|
||||
setRotation(Corner, 0F, 0F, 0F);
|
||||
Corner2 = new ModelRenderer(this, 0, 30);
|
||||
Corner2.addBox(-1F, 0F, -1F, 2, 16, 2);
|
||||
Corner2.setRotationPoint(-7F, 8F, -7F);
|
||||
Corner2.setTextureSize(128, 128);
|
||||
Corner2.mirror = true;
|
||||
setRotation(Corner2, 0F, 0F, 0F);
|
||||
Corner3 = new ModelRenderer(this, 0, 30);
|
||||
Corner3.addBox(-1F, 0F, -1F, 2, 16, 2);
|
||||
Corner3.setRotationPoint(7F, 8F, -7F);
|
||||
Corner3.setTextureSize(128, 128);
|
||||
Corner3.mirror = true;
|
||||
setRotation(Corner3, 0F, 0F, 0F);
|
||||
Corner4 = new ModelRenderer(this, 0, 30);
|
||||
Corner4.addBox(-1F, 0F, -1F, 2, 16, 2);
|
||||
Corner4.setRotationPoint(7F, 8F, 7F);
|
||||
Corner4.setTextureSize(128, 128);
|
||||
Corner4.mirror = true;
|
||||
setRotation(Corner4, 0F, 0F, 0F);
|
||||
C8 = new ModelRenderer(this, 9, 35);
|
||||
C8.addBox(-1F, 0F, -1F, 2, 2, 12);
|
||||
C8.setRotationPoint(6F, 22F, -5F);
|
||||
C8.setTextureSize(128, 128);
|
||||
C8.mirror = true;
|
||||
setRotation(C8, 0F, 0F, 0F);
|
||||
C7 = new ModelRenderer(this, 9, 35);
|
||||
C7.addBox(-1F, 0F, -1F, 2, 2, 12);
|
||||
C7.setRotationPoint(-6F, 8F, -5F);
|
||||
C7.setTextureSize(128, 128);
|
||||
C7.mirror = true;
|
||||
setRotation(C7, 0F, 0F, 0F);
|
||||
C6 = new ModelRenderer(this, 9, 35);
|
||||
C6.addBox(-1F, 0F, -1F, 2, 2, 12);
|
||||
C6.setRotationPoint(6F, 8F, -5F);
|
||||
C6.setTextureSize(128, 128);
|
||||
C6.mirror = true;
|
||||
setRotation(C6, 0F, 0F, 0F);
|
||||
C5 = new ModelRenderer(this, 9, 30);
|
||||
C5.addBox(-1F, 0F, -1F, 12, 2, 2);
|
||||
C5.setRotationPoint(-5F, 8F, 6F);
|
||||
C5.setTextureSize(128, 128);
|
||||
C5.mirror = true;
|
||||
setRotation(C5, 0F, 0F, 0F);
|
||||
C4 = new ModelRenderer(this, 9, 35);
|
||||
C4.addBox(-1F, 0F, -1F, 2, 2, 12);
|
||||
C4.setRotationPoint(-6F, 22F, -5F);
|
||||
C4.setTextureSize(128, 128);
|
||||
C4.mirror = true;
|
||||
setRotation(C4, 0F, 0F, 0F);
|
||||
C = new ModelRenderer(this, 9, 30);
|
||||
C.addBox(-1F, 0F, -1F, 12, 2, 2);
|
||||
C.setRotationPoint(-5F, 22F, 6F);
|
||||
C.setTextureSize(128, 128);
|
||||
C.mirror = true;
|
||||
setRotation(C, 0F, 0F, 0F);
|
||||
C3 = new ModelRenderer(this, 9, 30);
|
||||
C3.addBox(-1F, 0F, -1F, 12, 2, 2);
|
||||
C3.setRotationPoint(-5F, 8F, -6F);
|
||||
C3.setTextureSize(128, 128);
|
||||
C3.mirror = true;
|
||||
setRotation(C3, 0F, 0F, 0F);
|
||||
C2 = new ModelRenderer(this, 9, 30);
|
||||
C2.addBox(-1F, 0F, -1F, 12, 2, 2);
|
||||
C2.setRotationPoint(-5F, 22F, -6F);
|
||||
C2.setTextureSize(128, 128);
|
||||
C2.mirror = true;
|
||||
setRotation(C2, 0F, 0F, 0F);
|
||||
//G1--------------------------------------
|
||||
GuageT = new ModelRenderer(this, 54, 42);
|
||||
GuageT.addBox(-1F, -1F, 0F, 2, 1, 2);
|
||||
GuageT.setRotationPoint(0F, 12F, -8F);
|
||||
GuageT.setTextureSize(128, 128);
|
||||
GuageT.mirror = true;
|
||||
setRotation(GuageT, 0F, 0F, 0F);
|
||||
GuageB = new ModelRenderer(this, 54, 42);
|
||||
GuageB.addBox(-1F, 8F, 0F, 2, 1, 2);
|
||||
GuageB.setRotationPoint(0F, 12F, -8F);
|
||||
GuageB.setTextureSize(128, 128);
|
||||
GuageB.mirror = true;
|
||||
setRotation(GuageB, 0F, 0F, 0F);
|
||||
Guage = new ModelRenderer(this, 54, 32);
|
||||
Guage.addBox(-1F, 0F, 0F, 2, 8, 1);
|
||||
Guage.setRotationPoint(0F, 12F, -7F);
|
||||
Guage.setTextureSize(128, 128);
|
||||
Guage.mirror = true;
|
||||
setRotation(Guage, 0F, 0F, 0F);
|
||||
GuageR = new ModelRenderer(this, 44, 32);
|
||||
GuageR.addBox(1F, -1F, -1F, 2, 10, 2);
|
||||
GuageR.setRotationPoint(0F, 12F, -7F);
|
||||
GuageR.setTextureSize(128, 128);
|
||||
GuageR.mirror = true;
|
||||
setRotation(GuageR, 0F, 0F, 0F);
|
||||
GuageGlass = new ModelRenderer(this, 60, 32);
|
||||
GuageGlass.addBox(-1F, 0F, 0F, 2, 8, 1);
|
||||
GuageGlass.setRotationPoint(0F, 12F, -8F);
|
||||
GuageGlass.setTextureSize(128, 128);
|
||||
GuageGlass.mirror = true;
|
||||
setRotation(GuageGlass, 0F, 0F, 0F);
|
||||
GuageL = new ModelRenderer(this, 44, 32);
|
||||
GuageL.addBox(-3F, -1F, -1F, 2, 10, 2);
|
||||
GuageL.setRotationPoint(0F, 12F, -7F);
|
||||
GuageL.setTextureSize(128, 128);
|
||||
GuageL.mirror = true;
|
||||
setRotation(GuageL, 0F, 0F, 0F);
|
||||
//G2----------------------------------
|
||||
GuageT2 = new ModelRenderer(this, 54, 42);
|
||||
GuageT2.addBox(-1F, -1F, 0F, 2, 1, 2);
|
||||
GuageT2.setRotationPoint(-8F, 12F, 0F);
|
||||
GuageT2.setTextureSize(128, 128);
|
||||
GuageT2.mirror = true;
|
||||
setRotation(GuageT2, 0F, 1.570796F, 0F);
|
||||
GuageB2 = new ModelRenderer(this, 54, 42);
|
||||
GuageB2.addBox(-1F, 8F, 0F, 2, 1, 2);
|
||||
GuageB2.setRotationPoint(-8F, 12F, 0F);
|
||||
GuageB2.setTextureSize(128, 128);
|
||||
GuageB2.mirror = true;
|
||||
setRotation(GuageB2, 0F, 1.570796F, 0F);
|
||||
Guage2 = new ModelRenderer(this, 54, 32);
|
||||
Guage2.addBox(-1F, 0F, 0F, 2, 8, 1);
|
||||
Guage2.setRotationPoint(-7F, 12F, 0F);
|
||||
Guage2.setTextureSize(128, 128);
|
||||
Guage2.mirror = true;
|
||||
setRotation(Guage2, 0F, 1.570796F, 0F);
|
||||
GuageR2 = new ModelRenderer(this, 44, 32);
|
||||
GuageR2.addBox(1F, -1F, -1F, 2, 10, 2);
|
||||
GuageR2.setRotationPoint(-7F, 12F, 0F);
|
||||
GuageR2.setTextureSize(128, 128);
|
||||
GuageR2.mirror = true;
|
||||
setRotation(GuageR2, 0F, 1.570796F, 0F);
|
||||
GuageGlass2 = new ModelRenderer(this, 60, 32);
|
||||
GuageGlass2.addBox(-1F, 0F, 0F, 2, 8, 1);
|
||||
GuageGlass2.setRotationPoint(-8F, 12F, 0F);
|
||||
GuageGlass2.setTextureSize(128, 128);
|
||||
GuageGlass2.mirror = true;
|
||||
setRotation(GuageGlass2, 0F, 1.570796F, 0F);
|
||||
GuageL2 = new ModelRenderer(this, 44, 32);
|
||||
GuageL2.addBox(-3F, -1F, -1F, 2, 10, 2);
|
||||
GuageL2.setRotationPoint(-7F, 12F, 0F);
|
||||
GuageL2.setTextureSize(128, 128);
|
||||
GuageL2.mirror = true;
|
||||
setRotation(GuageL2, 0F, 1.570796F, 0F);
|
||||
//G3--------------------------------------
|
||||
GuageT3 = new ModelRenderer(this, 54, 42);
|
||||
GuageT3.addBox(-1F, -1F, 0F, 2, 1, 2);
|
||||
GuageT3.setRotationPoint(0F, 12F, 8F);
|
||||
GuageT3.setTextureSize(128, 128);
|
||||
GuageT3.mirror = true;
|
||||
setRotation(GuageT3, 0F, 3.141593F, 0F);
|
||||
GuageB3 = new ModelRenderer(this, 54, 42);
|
||||
GuageB3.addBox(-1F, 8F, 0F, 2, 1, 2);
|
||||
GuageB3.setRotationPoint(0F, 12F, 8F);
|
||||
GuageB3.setTextureSize(128, 128);
|
||||
GuageB3.mirror = true;
|
||||
setRotation(GuageB3, 0F, 3.141593F, 0F);
|
||||
Guage3 = new ModelRenderer(this, 54, 32);
|
||||
Guage3.addBox(-1F, 0F, 0F, 2, 8, 1);
|
||||
Guage3.setRotationPoint(0F, 12F, 7F);
|
||||
Guage3.setTextureSize(128, 128);
|
||||
Guage3.mirror = true;
|
||||
setRotation(Guage3, 0F, 3.141593F, 0F);
|
||||
GuageR3 = new ModelRenderer(this, 44, 32);
|
||||
GuageR3.addBox(1F, -1F, -1F, 2, 10, 2);
|
||||
GuageR3.setRotationPoint(0F, 12F, 7F);
|
||||
GuageR3.setTextureSize(128, 128);
|
||||
GuageR3.mirror = true;
|
||||
setRotation(GuageR3, 0F, 3.141593F, 0F);
|
||||
GuageGlass3 = new ModelRenderer(this, 60, 32);
|
||||
GuageGlass3.addBox(-1F, 0F, 0F, 2, 8, 1);
|
||||
GuageGlass3.setRotationPoint(0F, 12F, 8F);
|
||||
GuageGlass3.setTextureSize(128, 128);
|
||||
GuageGlass3.mirror = true;
|
||||
setRotation(GuageGlass3, 0F, 3.141593F, 0F);
|
||||
GuageL3 = new ModelRenderer(this, 44, 32);
|
||||
GuageL3.addBox(-3F, -1F, -1F, 2, 10, 2);
|
||||
GuageL3.setRotationPoint(0F, 12F, 7F);
|
||||
GuageL3.setTextureSize(128, 128);
|
||||
GuageL3.mirror = true;
|
||||
setRotation(GuageL3, 0F, 3.141593F, 0F);
|
||||
//G4-------------------------------
|
||||
GuageT4 = new ModelRenderer(this, 54, 42);
|
||||
GuageT4.addBox(-1F, -1F, 0F, 2, 1, 2);
|
||||
GuageT4.setRotationPoint(8F, 12F, 0F);
|
||||
GuageT4.setTextureSize(128, 128);
|
||||
GuageT4.mirror = true;
|
||||
setRotation(GuageT4, 0F, -1.570796F, 0F);
|
||||
GuageB4 = new ModelRenderer(this, 54, 42);
|
||||
GuageB4.addBox(-1F, 8F, 0F, 2, 1, 2);
|
||||
GuageB4.setRotationPoint(8F, 12F, 0F);
|
||||
GuageB4.setTextureSize(128, 128);
|
||||
GuageB4.mirror = true;
|
||||
setRotation(GuageB4, 0F, -1.570796F, 0F);
|
||||
Guage4 = new ModelRenderer(this, 54, 32);
|
||||
Guage4.addBox(-1F, 0F, 0F, 2, 8, 1);
|
||||
Guage4.setRotationPoint(7F, 12F, 0F);
|
||||
Guage4.setTextureSize(128, 128);
|
||||
Guage4.mirror = true;
|
||||
setRotation(Guage4, 0F, -1.570796F, 0F);
|
||||
GuageR4 = new ModelRenderer(this, 44, 32);
|
||||
GuageR4.addBox(1F, -1F, -1F, 2, 10, 2);
|
||||
GuageR4.setRotationPoint(7F, 12F, 0F);
|
||||
GuageR4.setTextureSize(128, 128);
|
||||
GuageR4.mirror = true;
|
||||
setRotation(GuageR4, 0F, -1.570796F, 0F);
|
||||
GuageGlass4 = new ModelRenderer(this, 60, 32);
|
||||
GuageGlass4.addBox(-1F, 0F, 0F, 2, 8, 1);
|
||||
GuageGlass4.setRotationPoint(8F, 12F, 0F);
|
||||
GuageGlass4.setTextureSize(128, 128);
|
||||
GuageGlass4.mirror = true;
|
||||
setRotation(GuageGlass4, 0F, -1.570796F, 0F);
|
||||
GuageL4 = new ModelRenderer(this, 44, 32);
|
||||
GuageL4.addBox(-3F, -1F, -1F, 2, 10, 2);
|
||||
GuageL4.setRotationPoint(7F, 12F, 0F);
|
||||
GuageL4.setTextureSize(128, 128);
|
||||
GuageL4.mirror = true;
|
||||
setRotation(GuageL4, 0F, -1.570796F, 0F);
|
||||
//Pipe Connectors
|
||||
CCBottom = new ModelRenderer(this, 0, 0);
|
||||
CCBottom.addBox(-3F, -9F, -3F, 6, 1, 6);
|
||||
CCBottom.setRotationPoint(0F, 15F, 0F);
|
||||
CCBottom.setTextureSize(128, 128);
|
||||
CCBottom.mirror = true;
|
||||
setRotation(CCBottom, 3.141593F, 0F, 0F);
|
||||
CCRight = new ModelRenderer(this, 0, 0);
|
||||
CCRight.addBox(-3F, -8F, -3F, 6, 2, 6);
|
||||
CCRight.setRotationPoint(0F, 15F, 0F);
|
||||
CCRight.setTextureSize(128, 128);
|
||||
CCRight.mirror = true;
|
||||
setRotation(CCRight, 0F, 0F, -1.570796F);
|
||||
CCLeft = new ModelRenderer(this, 0, 0);
|
||||
CCLeft.addBox(-3F, -8F, -3F, 6, 2, 6);
|
||||
CCLeft.setRotationPoint(0F, 15F, 0F);
|
||||
CCLeft.setTextureSize(128, 128);
|
||||
CCLeft.mirror = true;
|
||||
setRotation(CCLeft, 0F, 0F, 1.570796F);
|
||||
CCFront = new ModelRenderer(this, 0, 0);
|
||||
CCFront.addBox(-3F, -8F, -3F, 6, 2, 6);
|
||||
CCFront.setRotationPoint(0F, 15F, 0F);
|
||||
CCFront.setTextureSize(128, 128);
|
||||
CCFront.mirror = true;
|
||||
setRotation(CCFront, 1.570796F, 0F, 0F);
|
||||
CCBack = new ModelRenderer(this, 0, 0);
|
||||
CCBack.addBox(-3F, -8F, -3F, 6, 2, 6);
|
||||
CCBack.setRotationPoint(0F, 15F, 0F);
|
||||
CCBack.setTextureSize(128, 128);
|
||||
CCBack.mirror = true;
|
||||
setRotation(CCBack, -1.570796F, 0F, 0F);
|
||||
CCTop = new ModelRenderer(this, 0, 0);
|
||||
CCTop.addBox(-3F, -7F, -3F, 6, 1, 6);
|
||||
CCTop.setRotationPoint(0F, 15F, 0F);
|
||||
CCTop.setTextureSize(128, 128);
|
||||
CCTop.mirror = true;
|
||||
setRotation(CCTop, 0F, 0F, 0F);
|
||||
}
|
||||
|
||||
public void renderMain(TileEntityLTank te ,float f5)
|
||||
{
|
||||
//render regardless of sides
|
||||
Mid.render(f5);
|
||||
Corner.render(f5);
|
||||
Corner2.render(f5);
|
||||
Corner3.render(f5);
|
||||
Corner4.render(f5);
|
||||
C8.render(f5);
|
||||
C7.render(f5);
|
||||
C6.render(f5);
|
||||
C5.render(f5);
|
||||
C4.render(f5);
|
||||
C.render(f5);
|
||||
C3.render(f5);
|
||||
C2.render(f5);
|
||||
CCTop.render(f5);CCBottom.render(f5);
|
||||
//Front
|
||||
if(te.cc[2] instanceof TileEntityPipe)
|
||||
{
|
||||
CCFront.render(f5);
|
||||
}else
|
||||
{
|
||||
GuageT.render(f5);
|
||||
GuageB.render(f5);
|
||||
Guage.render(f5);
|
||||
GuageR.render(f5);
|
||||
GuageGlass.render(f5);
|
||||
GuageL.render(f5);
|
||||
}
|
||||
//back
|
||||
if(te.cc[3] instanceof TileEntityPipe)
|
||||
{
|
||||
CCBack.render(f5);
|
||||
}else
|
||||
{
|
||||
GuageT3.render(f5);
|
||||
Guage3.render(f5);
|
||||
Guage3.render(f5);
|
||||
GuageR3.render(f5);
|
||||
GuageGlass3.render(f5);
|
||||
GuageL3.render(f5);
|
||||
}
|
||||
//right
|
||||
if(te.cc[4] instanceof TileEntityPipe)
|
||||
{
|
||||
CCRight.render(f5);
|
||||
}else
|
||||
{
|
||||
GuageT4.render(f5);
|
||||
Guage4.render(f5);
|
||||
Guage4.render(f5);
|
||||
GuageR4.render(f5);
|
||||
GuageGlass4.render(f5);
|
||||
GuageL4.render(f5);
|
||||
}
|
||||
//left
|
||||
if(te.cc[5] instanceof TileEntityPipe)
|
||||
{
|
||||
CCLeft.render(f5);
|
||||
}else
|
||||
{
|
||||
GuageT2.render(f5);
|
||||
Guage2.render(f5);
|
||||
Guage2.render(f5);
|
||||
GuageR2.render(f5);
|
||||
GuageGlass2.render(f5);
|
||||
GuageL2.render(f5);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void setRotation(ModelRenderer model, float x, float y, float z)
|
||||
{
|
||||
model.rotateAngleX = x;
|
||||
model.rotateAngleY = y;
|
||||
model.rotateAngleZ = z;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,65 +0,0 @@
|
|||
package dark.BasicUtilities.renders;
|
||||
|
||||
import net.minecraft.src.TileEntity;
|
||||
import net.minecraft.src.TileEntitySpecialRenderer;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import dark.BasicUtilities.BasicUtilitiesMain;
|
||||
import dark.BasicUtilities.api.Liquid;
|
||||
import dark.BasicUtilities.api.MHelper;
|
||||
import dark.BasicUtilities.tanks.TileEntityLTank;
|
||||
|
||||
|
||||
public class RenderLTank extends TileEntitySpecialRenderer
|
||||
{
|
||||
private Liquid type = Liquid.DEFUALT;
|
||||
private ModelLiquidTank model;
|
||||
private ModelLiquidTankCorner modelC;
|
||||
private int pos = 0;
|
||||
|
||||
public RenderLTank()
|
||||
{
|
||||
model = new ModelLiquidTank();
|
||||
modelC = new ModelLiquidTankCorner();
|
||||
}
|
||||
|
||||
public void renderAModelAt(TileEntityLTank te, double d, double d1, double d2, float f)
|
||||
{
|
||||
type = te.getType();
|
||||
pos = Math.min(te.getStoredLiquid(type),4);
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef((float) d + 0.5F, (float) d1 + 1.5F, (float) d2 + 0.5F);
|
||||
GL11.glScalef(1.0F, -1F, -1F);
|
||||
if(MHelper.corner(te) > 0)
|
||||
{
|
||||
bindTextureByName(BasicUtilitiesMain.textureFile+"tanks/LiquidTankCorner.png");
|
||||
int corner = MHelper.corner(te);
|
||||
switch(corner)
|
||||
{
|
||||
case 2: GL11.glRotatef(270f, 0f, 1f, 0f);break;
|
||||
case 3: GL11.glRotatef(0f, 0f, 1f, 0f);break;
|
||||
case 4: GL11.glRotatef(90f, 0f, 1f, 0f);break;
|
||||
case 1: GL11.glRotatef(180f, 0f, 1f, 0f);break;
|
||||
}
|
||||
modelC.render(0.0625F);
|
||||
}
|
||||
else
|
||||
{
|
||||
switch(type.ordinal())
|
||||
{
|
||||
//case 0: bindTextureByName(BasicPipesMain.textureFile+"/pipes/SixSteamPipe.png");break;
|
||||
default:bindTextureByName(BasicUtilitiesMain.textureFile+"tanks/LiquidTank"+pos+".png"); break;
|
||||
}
|
||||
model.renderMain(te, 0.0625F);
|
||||
}
|
||||
GL11.glPopMatrix();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity tileEntity, double var2, double var4, double var6, float var8) {
|
||||
this.renderAModelAt((TileEntityLTank)tileEntity, var2, var4, var6, var8);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,137 +0,0 @@
|
|||
package dark.BasicUtilities.tanks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.src.Block;
|
||||
import net.minecraft.src.CreativeTabs;
|
||||
import net.minecraft.src.EntityPlayer;
|
||||
import net.minecraft.src.Item;
|
||||
import net.minecraft.src.ItemStack;
|
||||
import net.minecraft.src.TileEntity;
|
||||
import net.minecraft.src.World;
|
||||
import dark.BasicUtilities.BasicUtilitiesMain;
|
||||
import dark.BasicUtilities.api.Liquid;
|
||||
|
||||
public class ItemTank extends Item
|
||||
{
|
||||
int index = 64;// 64 + 2 rows alloted to pipes
|
||||
private int spawnID;
|
||||
|
||||
public ItemTank(int id)
|
||||
{
|
||||
super(id);
|
||||
this.setMaxDamage(0);
|
||||
this.setHasSubtypes(true);
|
||||
this.setIconIndex(10);
|
||||
this.setItemName("tank");
|
||||
this.setCreativeTab(CreativeTabs.tabRedstone);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIconFromDamage(int par1)
|
||||
{
|
||||
|
||||
return par1 + index;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemNameIS(ItemStack itemstack)
|
||||
{
|
||||
return itemstack.getItemDamage() < Liquid.values().length ? Liquid.getLiquid(itemstack.getItemDamage()).lName + " Tank" : "unknown";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List)
|
||||
{
|
||||
for (int i = 0; i < Liquid.values().length; i++)
|
||||
{
|
||||
if (Liquid.getLiquid(i).showMenu)
|
||||
{
|
||||
par3List.add(new ItemStack(this, 1, i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String getTextureFile()
|
||||
{
|
||||
return BasicUtilitiesMain.ITEM_PNG;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemName()
|
||||
{
|
||||
return "Pipes";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
|
||||
{
|
||||
int blockID = par3World.getBlockId(par4, par5, par6);
|
||||
spawnID = BasicUtilitiesMain.machine.blockID;
|
||||
if (blockID == Block.snow.blockID)
|
||||
{
|
||||
par7 = 1;
|
||||
}
|
||||
else if (blockID != Block.vine.blockID && blockID != Block.tallGrass.blockID && blockID != Block.deadBush.blockID)
|
||||
{
|
||||
if (par7 == 0)
|
||||
{
|
||||
--par5;
|
||||
}
|
||||
|
||||
if (par7 == 1)
|
||||
{
|
||||
++par5;
|
||||
}
|
||||
|
||||
if (par7 == 2)
|
||||
{
|
||||
--par6;
|
||||
}
|
||||
|
||||
if (par7 == 3)
|
||||
{
|
||||
++par6;
|
||||
}
|
||||
|
||||
if (par7 == 4)
|
||||
{
|
||||
--par4;
|
||||
}
|
||||
|
||||
if (par7 == 5)
|
||||
{
|
||||
++par4;
|
||||
}
|
||||
}
|
||||
|
||||
if (BasicUtilitiesMain.pipe.canPlaceBlockAt(par3World, par4, par5, par6))
|
||||
{
|
||||
Block var9 = Block.blocksList[this.spawnID];
|
||||
par3World.editingBlocks = true;
|
||||
if (par3World.setBlockAndMetadataWithNotify(par4, par5, par6, var9.blockID, 5))
|
||||
{
|
||||
if (par3World.getBlockId(par4, par5, par6) == var9.blockID)
|
||||
{
|
||||
|
||||
Block.blocksList[this.spawnID].onBlockAdded(par3World, par4, par5, par6);
|
||||
Block.blocksList[this.spawnID].onBlockPlacedBy(par3World, par4, par5, par6, par2EntityPlayer);
|
||||
TileEntity blockEntity = par3World.getBlockTileEntity(par4, par5, par6);
|
||||
if (blockEntity instanceof TileEntityLTank)
|
||||
{
|
||||
TileEntityLTank pipeEntity = (TileEntityLTank) blockEntity;
|
||||
Liquid dm = Liquid.getLiquid(par1ItemStack.getItemDamage());
|
||||
pipeEntity.setType(dm);
|
||||
}
|
||||
}
|
||||
|
||||
--par1ItemStack.stackSize;
|
||||
par3World.editingBlocks = false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
par3World.editingBlocks = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,205 +0,0 @@
|
|||
package dark.BasicUtilities.tanks;
|
||||
|
||||
import net.minecraft.src.EntityPlayer;
|
||||
import net.minecraft.src.INetworkManager;
|
||||
import net.minecraft.src.NBTTagCompound;
|
||||
import net.minecraft.src.Packet;
|
||||
import net.minecraft.src.Packet250CustomPayload;
|
||||
import net.minecraft.src.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
import universalelectricity.prefab.network.IPacketReceiver;
|
||||
import universalelectricity.prefab.network.PacketManager;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
||||
import dark.BasicUtilities.BasicUtilitiesMain;
|
||||
import dark.BasicUtilities.api.IProducer;
|
||||
import dark.BasicUtilities.api.IReadOut;
|
||||
import dark.BasicUtilities.api.IStorageTank;
|
||||
import dark.BasicUtilities.api.Liquid;
|
||||
import dark.BasicUtilities.api.MHelper;
|
||||
|
||||
public class TileEntityLTank extends TileEntity implements IStorageTank, IProducer, IPacketReceiver,IReadOut
|
||||
{
|
||||
public TileEntity[] cc =
|
||||
{ null, null, null, null, null, null };
|
||||
public Liquid type = Liquid.DEFUALT;
|
||||
public int LStored = 0;
|
||||
public int pLStored = 0;
|
||||
public int LMax = 4;
|
||||
private int count = 0;
|
||||
private int count2 = 0;
|
||||
private boolean firstUpdate = true;
|
||||
|
||||
public void updateEntity()
|
||||
{
|
||||
if (++count >= 5)
|
||||
{
|
||||
count = 0;
|
||||
this.cc = MHelper.getSourounding(worldObj, xCoord, yCoord, zCoord);
|
||||
if (!worldObj.isRemote)
|
||||
{
|
||||
MHelper.shareLiquid(worldObj, xCoord, yCoord, zCoord, this.LStored, this.getLiquidCapacity(type), type);
|
||||
if (firstUpdate || (this.LStored != pLStored) || count2 >= 100)
|
||||
{
|
||||
count2 = 0;
|
||||
firstUpdate = false;
|
||||
Packet packet = PacketManager.getPacket(BasicUtilitiesMain.CHANNEL, this, new Object[]
|
||||
{ type.ordinal(), LStored });
|
||||
PacketManager.sendPacketToClients(packet, worldObj, Vector3.get(this), 20);
|
||||
}
|
||||
this.pLStored = this.LStored;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void writeToNBT(NBTTagCompound nbt)
|
||||
{
|
||||
super.writeToNBT(nbt);
|
||||
nbt.setInteger("Vol", this.LStored);
|
||||
nbt.setInteger("type", this.type.ordinal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt)
|
||||
{
|
||||
super.readFromNBT(nbt);
|
||||
this.LStored = nbt.getInteger("Vol");
|
||||
this.type = Liquid.getLiquid(nbt.getInteger("type"));
|
||||
}
|
||||
|
||||
// --------------------
|
||||
// Liquid stuff
|
||||
// ------------------------------------
|
||||
@Override
|
||||
public int onReceiveLiquid(Liquid type, int vol, ForgeDirection side)
|
||||
{
|
||||
|
||||
if (type == this.type)
|
||||
{
|
||||
if (this.LStored < this.getLiquidCapacity(this.type))
|
||||
{
|
||||
int rejectedVolume = Math.max((this.getStoredLiquid(type) + vol) - this.LMax, 0);
|
||||
this.LStored = Math.min(Math.max((LStored + vol - rejectedVolume), 0), this.LMax);
|
||||
return rejectedVolume;
|
||||
}
|
||||
else
|
||||
{
|
||||
TileEntity te = null;
|
||||
if (this.type.isGas)
|
||||
{
|
||||
worldObj.getBlockTileEntity(xCoord, yCoord + 1, zCoord);
|
||||
}
|
||||
else
|
||||
{
|
||||
worldObj.getBlockTileEntity(xCoord, yCoord - 1, zCoord);
|
||||
}
|
||||
if (te instanceof IStorageTank) { return ((IStorageTank) te).onReceiveLiquid(type, vol, ForgeDirection.UNKNOWN); }
|
||||
}
|
||||
}
|
||||
return vol;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRecieveLiquid(Liquid type, ForgeDirection side)
|
||||
{
|
||||
if (type == this.type)
|
||||
{
|
||||
if (this.type.isGas && side == ForgeDirection.UP) { return false; }
|
||||
if (!this.type.isGas && side == ForgeDirection.DOWN) { return false; }
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStoredLiquid(Liquid type)
|
||||
{
|
||||
if (type == this.type) { return LStored; }
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLiquidCapacity(Liquid type)
|
||||
{
|
||||
if (type == this.type) { return LMax; }
|
||||
return 0;
|
||||
}
|
||||
|
||||
public Liquid getType()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int onProduceLiquid(Liquid type, int vol, ForgeDirection side)
|
||||
{
|
||||
if (type == this.type && this.LStored > 1 && vol > 0)
|
||||
{
|
||||
// TODO correct / do math for
|
||||
LStored--;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProduceLiquid(Liquid type, ForgeDirection side)
|
||||
{
|
||||
if (type == this.type)
|
||||
{
|
||||
if (this.type.isGas && side == ForgeDirection.UP) { return true; }
|
||||
if (!this.type.isGas && side == ForgeDirection.DOWN) { return true; }
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProducePresure(Liquid type, ForgeDirection side)
|
||||
{
|
||||
if (type == this.type)
|
||||
{
|
||||
if (this.type.isGas && side == ForgeDirection.UP) { return true; }
|
||||
if (!this.type.isGas && side == ForgeDirection.DOWN) { return true; }
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int presureOutput(Liquid type, ForgeDirection side)
|
||||
{
|
||||
if (type == this.type) { return this.type.defaultPresure; }
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacketData(INetworkManager network, int packetType,
|
||||
Packet250CustomPayload packet, EntityPlayer player,
|
||||
ByteArrayDataInput data)
|
||||
{
|
||||
try
|
||||
{
|
||||
this.type = Liquid.getLiquid(data.readInt());
|
||||
this.LStored = data.readInt();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
System.out.print("Fail reading data for Storage tank \n");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setType(Liquid dm)
|
||||
{
|
||||
this.type = dm;
|
||||
|
||||
}
|
||||
@Override
|
||||
public String getMeterReading(EntityPlayer user, ForgeDirection side)
|
||||
{
|
||||
return this.LStored+" "+"/"+this.LMax+" "+this.type.name()+" Stored";
|
||||
}
|
||||
}
|
|
@ -1,14 +1,13 @@
|
|||
package dark.BasicUtilities;
|
||||
|
||||
import cpw.mods.fml.client.registry.ClientRegistry;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
import dark.BasicUtilities.machines.TileEntityPump;
|
||||
import dark.BasicUtilities.mechanical.TileEntityRod;
|
||||
import dark.BasicUtilities.pipes.TileEntityPipe;
|
||||
import dark.BasicUtilities.renders.RenderGearRod;
|
||||
import dark.BasicUtilities.renders.RenderLTank;
|
||||
import dark.BasicUtilities.renders.RenderPipe;
|
||||
import dark.BasicUtilities.renders.RenderPump;
|
||||
import dark.BasicUtilities.tanks.TileEntityLTank;
|
||||
|
||||
public class BPClientProxy extends BPCommonProxy
|
||||
{
|
||||
|
@ -23,7 +22,8 @@ public class BPClientProxy extends BPCommonProxy
|
|||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityPipe.class, new RenderPipe());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityPump.class, new RenderPump());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityRod.class, new RenderGearRod());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityLTank.class, new RenderLTank());
|
||||
//ClientRegistry.bindTileEntitySpecialRenderer(TileEntityLTank.class, new RenderLTank());
|
||||
RenderingRegistry.registerBlockHandler(new ItemRenderHelper());
|
||||
}
|
||||
@Override
|
||||
public void postInit()
|
|
@ -1,7 +1,7 @@
|
|||
package dark.BasicUtilities;
|
||||
|
||||
import net.minecraft.src.EntityPlayer;
|
||||
import net.minecraft.src.World;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.common.network.IGuiHandler;
|
||||
|
||||
public class BPCommonProxy implements IGuiHandler {
|
|
@ -2,13 +2,17 @@ package dark.BasicUtilities;
|
|||
|
||||
import java.io.File;
|
||||
|
||||
import net.minecraft.src.Block;
|
||||
import net.minecraft.src.CraftingManager;
|
||||
import net.minecraft.src.Item;
|
||||
import net.minecraft.src.ItemStack;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraftforge.common.Configuration;
|
||||
import net.minecraftforge.liquids.LiquidContainerData;
|
||||
import net.minecraftforge.liquids.LiquidContainerRegistry;
|
||||
import net.minecraftforge.liquids.LiquidDictionary;
|
||||
import net.minecraftforge.liquids.LiquidStack;
|
||||
import net.minecraftforge.oredict.ShapedOreRecipe;
|
||||
import universalelectricity.core.UEConfig;
|
||||
import universalelectricity.core.UniversalElectricity;
|
||||
import universalelectricity.prefab.network.PacketManager;
|
||||
import cpw.mods.fml.common.DummyModContainer;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
|
@ -25,7 +29,10 @@ import cpw.mods.fml.common.registry.GameRegistry;
|
|||
import cpw.mods.fml.common.registry.LanguageRegistry;
|
||||
import dark.BasicUtilities.Items.ItemGuage;
|
||||
import dark.BasicUtilities.Items.ItemParts;
|
||||
import dark.BasicUtilities.Items.ItemParts.basicParts;
|
||||
import dark.BasicUtilities.Liquids.BlockOilFlowing;
|
||||
import dark.BasicUtilities.Liquids.BlockOilStill;
|
||||
import dark.BasicUtilities.Liquids.BlockSteam;
|
||||
import dark.BasicUtilities.Liquids.ItemOilBucket;
|
||||
import dark.BasicUtilities.api.Liquid;
|
||||
import dark.BasicUtilities.machines.BlockMachine;
|
||||
import dark.BasicUtilities.machines.BlockValve;
|
||||
|
@ -38,8 +45,6 @@ import dark.BasicUtilities.mechanical.TileEntityRod;
|
|||
import dark.BasicUtilities.pipes.BlockPipe;
|
||||
import dark.BasicUtilities.pipes.ItemPipe;
|
||||
import dark.BasicUtilities.pipes.TileEntityPipe;
|
||||
import dark.BasicUtilities.tanks.ItemTank;
|
||||
import dark.BasicUtilities.tanks.TileEntityLTank;
|
||||
|
||||
/**
|
||||
* Used in the creation of a new mod class
|
||||
|
@ -63,29 +68,28 @@ public class BasicUtilitiesMain extends DummyModContainer
|
|||
public static final Configuration CONFIGURATION = new Configuration(
|
||||
new File(Loader.instance().getConfigDir(), NAME + ".cfg"));
|
||||
// Block and Item vars
|
||||
public final static int BLOCK_ID_PREFIX = 2056;
|
||||
public final static int BLOCK_ID_PREFIX = 3000;
|
||||
public final static int LIQUID_ID_PREFIX = 200;
|
||||
public final static int ITEM_ID_PREFIX = 10056;
|
||||
|
||||
public static Block pipe = new BlockPipe(UEConfig.getBlockConfigID(
|
||||
CONFIGURATION, "Pipe", BLOCK_ID_PREFIX)).setBlockName("pipe");
|
||||
public static Block machine = new BlockMachine(UEConfig.getBlockConfigID(
|
||||
CONFIGURATION, "MachineSetOne", BLOCK_ID_PREFIX))
|
||||
.setBlockName("Pump");
|
||||
public static Block valve = new BlockValve(UEConfig.getBlockConfigID(
|
||||
CONFIGURATION, "Valve", BLOCK_ID_PREFIX + 2)).setBlockName("valve");
|
||||
public static Block rod = new BlockRod(UEConfig.getBlockConfigID(
|
||||
CONFIGURATION, "MechanicalRod", BLOCK_ID_PREFIX + 3));
|
||||
public static Block generator = new BlockGenerator((UEConfig.getBlockConfigID(
|
||||
CONFIGURATION, "UEGenerator", BLOCK_ID_PREFIX + 4)));
|
||||
public static Block pipe = new BlockPipe(UniversalElectricity.CONFIGURATION.getBlock("Pipe", BLOCK_ID_PREFIX).getInt());
|
||||
public static Block machine = new BlockMachine(UniversalElectricity.CONFIGURATION.getBlock("MachineSetOne", BLOCK_ID_PREFIX + 1).getInt());
|
||||
public static Block valve = new BlockValve(UniversalElectricity.CONFIGURATION.getBlock("Valve", BLOCK_ID_PREFIX + 2).getInt());
|
||||
public static Block rod = new BlockRod(UniversalElectricity.CONFIGURATION.getBlock("MechanicalRod", BLOCK_ID_PREFIX + 3).getInt());
|
||||
public static Block generator = new BlockGenerator((UniversalElectricity.CONFIGURATION.getBlock("UEGenerator", BLOCK_ID_PREFIX + 4).getInt()));
|
||||
|
||||
public static Item parts = new ItemParts(UEConfig.getItemConfigID(
|
||||
CONFIGURATION, "Parts", ITEM_ID_PREFIX));
|
||||
public static Item itemPipes = new ItemPipe(UEConfig.getItemConfigID(
|
||||
CONFIGURATION, "PipeItem", ITEM_ID_PREFIX + 1));
|
||||
public static Item itemTank = new ItemTank(UEConfig.getItemConfigID(
|
||||
CONFIGURATION, "TankItem", ITEM_ID_PREFIX + 2));
|
||||
public static Item gauge = new ItemGuage(UEConfig.getItemConfigID(
|
||||
CONFIGURATION, "PipeGuage", ITEM_ID_PREFIX + 3));
|
||||
public static Block SteamBlock = new BlockSteam(UniversalElectricity.CONFIGURATION.getBlock("SteamBlock", LIQUID_ID_PREFIX).getInt());
|
||||
|
||||
public static Block oilMoving = new BlockOilFlowing(UniversalElectricity.CONFIGURATION.getBlock("Oil_FlowingBU", LIQUID_ID_PREFIX + 1).getInt());
|
||||
public static Block oilStill = new BlockOilStill(UniversalElectricity.CONFIGURATION.getBlock("Oil_StillBU", LIQUID_ID_PREFIX + 2).getInt());
|
||||
|
||||
public static LiquidStack Steam = LiquidDictionary.getOrCreateLiquid("Steam", new LiquidStack(SteamBlock, LiquidContainerRegistry.BUCKET_VOLUME));
|
||||
|
||||
public static Item parts = new ItemParts(UniversalElectricity.CONFIGURATION.getItem("Parts", ITEM_ID_PREFIX).getInt());
|
||||
public static Item itemPipes = new ItemPipe(UniversalElectricity.CONFIGURATION.getItem("PipeItem", ITEM_ID_PREFIX + 1).getInt());
|
||||
// public static Item itemTank = new ItemTank(UniversalElectricity.CONFIGURATION.getItem("TankItem", ITEM_ID_PREFIX + 2).getInt());
|
||||
public static Item gauge = new ItemGuage(UniversalElectricity.CONFIGURATION.getItem("PipeGuage", ITEM_ID_PREFIX + 3).getInt());
|
||||
public static Item itemOilBucket = new ItemOilBucket(UniversalElectricity.CONFIGURATION.getItem("Oil Bucket", ITEM_ID_PREFIX + 4).getInt(), 4);
|
||||
// mod stuff
|
||||
@SidedProxy(clientSide = "dark.BasicUtilities.BPClientProxy", serverSide = "dark.BasicUtilities.BPCommonProxy")
|
||||
public static BPCommonProxy proxy;
|
||||
|
@ -97,10 +101,12 @@ public class BasicUtilitiesMain extends DummyModContainer
|
|||
{
|
||||
instance = this;
|
||||
proxy.preInit();
|
||||
GameRegistry.registerBlock(pipe);
|
||||
GameRegistry.registerBlock(rod);
|
||||
GameRegistry.registerBlock(generator);
|
||||
GameRegistry.registerBlock(machine, ItemMachine.class);
|
||||
GameRegistry.registerBlock(pipe, "multi pipe");
|
||||
GameRegistry.registerBlock(rod, "mech rod");
|
||||
GameRegistry.registerBlock(generator, "EU Generator");
|
||||
GameRegistry.registerBlock(machine, ItemMachine.class, "Machines");
|
||||
GameRegistry.registerBlock(SteamBlock, "steam");
|
||||
LiquidContainerRegistry.registerLiquid(new LiquidContainerData(new LiquidStack(oilStill, LiquidContainerRegistry.BUCKET_VOLUME), new ItemStack(itemOilBucket), new ItemStack(Item.bucketEmpty)));
|
||||
|
||||
}
|
||||
|
||||
|
@ -112,20 +118,20 @@ public class BasicUtilitiesMain extends DummyModContainer
|
|||
GameRegistry.registerTileEntity(TileEntityPipe.class, "Pipe");
|
||||
GameRegistry.registerTileEntity(TileEntityPump.class, "pump");
|
||||
GameRegistry.registerTileEntity(TileEntityRod.class, "rod");
|
||||
GameRegistry.registerTileEntity(TileEntityLTank.class, "ltank");
|
||||
// GameRegistry.registerTileEntity(TileEntityLTank.class, "ltank");
|
||||
GameRegistry.registerTileEntity(TileEntityGen.class, "WattGenerator");
|
||||
// Pipe Names
|
||||
for (int i = 0; i < Liquid.values().length; i++)
|
||||
{
|
||||
LanguageRegistry.addName((new ItemStack(itemPipes, 1, i)),
|
||||
Liquid.getLiquid(i).lName + " Pipe");
|
||||
Liquid.getLiquid(i).displayerName + " Pipe");
|
||||
}
|
||||
// liquid tank names
|
||||
/** liquid tank names
|
||||
for (int i = 0; i < Liquid.values().length; i++)
|
||||
{
|
||||
LanguageRegistry.addName((new ItemStack(itemTank, 1, i)),
|
||||
Liquid.getLiquid(i).lName + " Tank");
|
||||
}
|
||||
Liquid.getLiquid(i).displayerName + " Tank");
|
||||
}*/
|
||||
for (int i = 0; i < ItemParts.basicParts.values().length; i++)
|
||||
{
|
||||
LanguageRegistry.addName((new ItemStack(parts, 1, i)),
|
||||
|
@ -218,6 +224,7 @@ public class BasicUtilitiesMain extends DummyModContainer
|
|||
GameRegistry.addRecipe(new ItemStack(parts, 1, 6), new Object[]
|
||||
{
|
||||
" @ ", "@ @", " @ ", '@', Item.ingotIron });// tank
|
||||
/**
|
||||
GameRegistry.addShapelessRecipe(new ItemStack(itemTank, 1, 0),
|
||||
new Object[]
|
||||
{ new ItemStack(parts, 1, 6),
|
||||
|
@ -247,6 +254,7 @@ public class BasicUtilitiesMain extends DummyModContainer
|
|||
new ItemStack(parts, 1, basicParts.Tank.ordinal()),
|
||||
new ItemStack(parts, 1, 4),
|
||||
new ItemStack(Item.dyePowder, 1, 11) });
|
||||
*/
|
||||
GameRegistry.addShapelessRecipe(new ItemStack(itemPipes, 1, 0),
|
||||
new Object[]
|
||||
{ new ItemStack(parts, 1, 1),
|
|
@ -1,8 +1,8 @@
|
|||
package dark.BasicUtilities;
|
||||
|
||||
import net.minecraft.src.Block;
|
||||
import net.minecraft.src.IBlockAccess;
|
||||
import net.minecraft.src.RenderBlocks;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
|
@ -38,7 +38,7 @@ public class ItemRenderHelper implements ISimpleBlockRenderingHandler {
|
|||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef((float) 0.0F, (float)1.5F, (float)0.0F);
|
||||
GL11.glRotatef(180f, 0f, 0f, 1f);
|
||||
GL11.glBindTexture(GL11.GL_TEXTURE_2D, FMLClientHandler.instance().getClient().renderEngine.getTexture(BasicUtilitiesMain.textureFile+"GearRod.png"));
|
||||
GL11.glBindTexture(GL11.GL_TEXTURE_2D, FMLClientHandler.instance().getClient().renderEngine.getTexture(BasicUtilitiesMain.textureFile+"mechanical/GearRod.png"));
|
||||
modelRod.render(0.0825F,0);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ public class ItemRenderHelper implements ISimpleBlockRenderingHandler {
|
|||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef((float) 0.0F, (float)1.3F, (float)0.0F);
|
||||
GL11.glRotatef(180f, 0f, 0f, 1f);
|
||||
GL11.glBindTexture(GL11.GL_TEXTURE_2D, FMLClientHandler.instance().getClient().renderEngine.getTexture(BasicUtilitiesMain.textureFile+"Generator.png"));
|
||||
GL11.glBindTexture(GL11.GL_TEXTURE_2D, FMLClientHandler.instance().getClient().renderEngine.getTexture(BasicUtilitiesMain.textureFile+"mechanical/Generator.png"));
|
||||
modelGen.RenderMain(0.0725F);
|
||||
GL11.glPopMatrix();
|
||||
}
|
|
@ -2,19 +2,15 @@ package dark.BasicUtilities.Items;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.src.CreativeTabs;
|
||||
import net.minecraft.src.EntityPlayer;
|
||||
import net.minecraft.src.Item;
|
||||
import net.minecraft.src.ItemStack;
|
||||
import net.minecraft.src.TileEntity;
|
||||
import net.minecraft.src.World;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import dark.BasicUtilities.BasicUtilitiesMain;
|
||||
import dark.BasicUtilities.api.IForce;
|
||||
import dark.BasicUtilities.api.IReadOut;
|
||||
import dark.BasicUtilities.api.Liquid;
|
||||
import dark.BasicUtilities.pipes.TileEntityPipe;
|
||||
import dark.BasicUtilities.tanks.TileEntityLTank;
|
||||
|
||||
public class ItemGuage extends Item
|
||||
{
|
|
@ -2,12 +2,11 @@ package dark.BasicUtilities.Items;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import dark.BasicUtilities.BasicUtilitiesMain;
|
||||
|
||||
import net.minecraft.src.CreativeTabs;
|
||||
import net.minecraft.src.Item;
|
||||
import net.minecraft.src.ItemStack;
|
||||
|
||||
public class ItemParts extends Item
|
||||
{
|
||||
public enum basicParts
|
496
minecraft/dark/BasicUtilities/Liquids/BlockOilFlowing.java
Normal file
496
minecraft/dark/BasicUtilities/Liquids/BlockOilFlowing.java
Normal file
|
@ -0,0 +1,496 @@
|
|||
package dark.BasicUtilities.Liquids;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import dark.BasicUtilities.BasicUtilitiesMain;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockFluid;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.liquids.ILiquid;
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
|
||||
/**
|
||||
* @author Cammygames This class contains the block for oil
|
||||
*
|
||||
*/
|
||||
public class BlockOilFlowing extends BlockFluid implements ILiquid
|
||||
{
|
||||
|
||||
/**
|
||||
* Number of horizontally adjacent liquid source blocks. Diagonal doesn't count. Only source
|
||||
* blocks of the same liquid as the block using the field are counted.
|
||||
*/
|
||||
int numAdjacentSources = 0;
|
||||
|
||||
/**
|
||||
* Indicates whether the flow direction is optimal. Each array index corresponds to one of the
|
||||
* four cardinal directions.
|
||||
*/
|
||||
boolean[] isOptimalFlowDirection = new boolean[4];
|
||||
|
||||
/**
|
||||
* The estimated cost to flow in a given direction from the current point. Each array index
|
||||
* corresponds to one of the four cardinal directions.
|
||||
*/
|
||||
int[] flowCost = new int[4];
|
||||
|
||||
public BlockOilFlowing(int id)
|
||||
{
|
||||
super(id, Material.water);
|
||||
this.setHardness(80F);
|
||||
this.setLightOpacity(0);
|
||||
this.setRequiresSelfNotify();
|
||||
this.disableStats();
|
||||
this.setBlockName("oilMoving");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockAdded(World par1World, int x, int y, int z)
|
||||
{
|
||||
super.onBlockAdded(par1World, x, y, z);
|
||||
|
||||
for (byte i = 0; i < 6; i++)
|
||||
{
|
||||
Vector3 neighborPosition = new Vector3(x, y, z);
|
||||
neighborPosition.modifyPositionFromSide(ForgeDirection.getOrientation(i));
|
||||
|
||||
int neighborBlockID = par1World.getBlockId(neighborPosition.intX(), neighborPosition.intY(), neighborPosition.intZ());
|
||||
|
||||
if (neighborBlockID == Block.fire.blockID || neighborBlockID == Block.lavaMoving.blockID || neighborBlockID == Block.lavaStill.blockID)
|
||||
{
|
||||
par1World.setBlockWithNotify(x, y, z, Block.fire.blockID);
|
||||
par1World.playSoundEffect((double) ((float) x + 0.5F), (double) ((float) y + 0.5F), (double) ((float) z + 0.5F), "random.fizz", 0.5F, 2.6F + (par1World.rand.nextFloat() - par1World.rand.nextFloat()) * 0.8F);
|
||||
par1World.spawnParticle("largesmoke", (double) x + Math.random(), (double) y + 1.2D, (double) z + Math.random(), 0.0D, 0.0D, 0.0D);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (par1World.getBlockId(x, y, z) == this.blockID)
|
||||
{
|
||||
par1World.scheduleBlockUpdate(x, y, z, this.blockID, this.tickRate());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange(World par1World, int x, int y, int z, int blockID)
|
||||
{
|
||||
super.onNeighborBlockChange(par1World, x, y, z, blockID);
|
||||
|
||||
if (blockID == Block.fire.blockID || blockID == Block.lavaMoving.blockID || blockID == Block.lavaStill.blockID)
|
||||
{
|
||||
par1World.setBlockWithNotify(x, y, z, Block.fire.blockID);
|
||||
par1World.playSoundEffect((double) ((float) x + 0.5F), (double) ((float) y + 0.5F), (double) ((float) z + 0.5F), "random.fizz", 0.5F, 2.6F + (par1World.rand.nextFloat() - par1World.rand.nextFloat()) * 0.8F);
|
||||
par1World.spawnParticle("largesmoke", (double) x + Math.random(), (double) y + 1.2D, (double) z + Math.random(), 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the flow for the BlockFlowing object.
|
||||
*/
|
||||
private void updateFlow(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
int var5 = par1World.getBlockMetadata(par2, par3, par4);
|
||||
par1World.setBlockAndMetadata(par2, par3, par4, this.blockID + 1, var5);
|
||||
par1World.markBlockRangeForRenderUpdate(par2, par3, par4, par2, par3, par4);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the color of the water
|
||||
*/
|
||||
@Override
|
||||
public int colorMultiplier(IBlockAccess par1IBlockAccess, int x, int y, int z)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ticks the block if it's been scheduled
|
||||
*/
|
||||
@Override
|
||||
public void updateTick(World par1World, int x, int y, int z, Random par5Random)
|
||||
{
|
||||
int var6 = this.getFlowDecay(par1World, x, y, z);
|
||||
byte var7 = 1;
|
||||
boolean var8 = true;
|
||||
int var10;
|
||||
|
||||
if (var6 > 0)
|
||||
{
|
||||
byte var9 = -100;
|
||||
this.numAdjacentSources = 0;
|
||||
int var12 = this.getSmallestFlowDecay(par1World, x - 1, y, z, var9);
|
||||
var12 = this.getSmallestFlowDecay(par1World, x + 1, y, z, var12);
|
||||
var12 = this.getSmallestFlowDecay(par1World, x, y, z - 1, var12);
|
||||
var12 = this.getSmallestFlowDecay(par1World, x, y, z + 1, var12);
|
||||
var10 = var12 + var7;
|
||||
|
||||
if (var10 >= 8 || var12 < 0)
|
||||
{
|
||||
var10 = -1;
|
||||
}
|
||||
|
||||
if (this.getFlowDecay(par1World, x, y + 1, z) >= 0)
|
||||
{
|
||||
int var11 = this.getFlowDecay(par1World, x, y + 1, z);
|
||||
|
||||
if (var11 >= 8)
|
||||
{
|
||||
var10 = var11;
|
||||
}
|
||||
else
|
||||
{
|
||||
var10 = var11 + 8;
|
||||
}
|
||||
}
|
||||
// Used to turn a flowing source with
|
||||
// two solid sources into a solid
|
||||
// source
|
||||
/**
|
||||
* if (this.numAdjacentSources >= 2 && this.blockMaterial == Material.water) { if
|
||||
* (par1World.getBlockMaterial(x, y - 1, z).isSolid()) { var10 = 0; } else if
|
||||
* (par1World.getBlockMaterial(x, y - 1, z) == this.blockMaterial &&
|
||||
* par1World.getBlockMetadata(x, y, z) == 0) { var10 = 0; } }
|
||||
**/
|
||||
if (var10 == var6)
|
||||
{
|
||||
if (var8)
|
||||
{
|
||||
this.updateFlow(par1World, x, y, z);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var6 = var10;
|
||||
|
||||
if (var10 < 0)
|
||||
{
|
||||
// updates block
|
||||
par1World.setBlockWithNotify(x, y, z, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
par1World.setBlockMetadataWithNotify(x, y, z, var10);
|
||||
par1World.scheduleBlockUpdate(x, y, z, this.blockID, this.tickRate());
|
||||
par1World.notifyBlocksOfNeighborChange(x, y, z, this.blockID);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.updateFlow(par1World, x, y, z);
|
||||
}
|
||||
|
||||
if (this.liquidCanDisplaceBlock(par1World, x, y - 1, z))
|
||||
{
|
||||
if (var6 >= 8)
|
||||
{
|
||||
this.flowIntoBlock(par1World, x, y - 1, z, var6);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.flowIntoBlock(par1World, x, y - 1, z, var6 + 8);
|
||||
}
|
||||
}
|
||||
else if (var6 >= 0 && (var6 == 0 || this.blockBlocksFlow(par1World, x, y - 1, z)))
|
||||
{
|
||||
boolean[] var13 = this.getOptimalFlowDirections(par1World, x, y, z);
|
||||
var10 = var6 + var7;
|
||||
|
||||
if (var6 >= 8)
|
||||
{
|
||||
var10 = 1;
|
||||
}
|
||||
|
||||
if (var10 >= 8) { return; }
|
||||
|
||||
if (var13[0])
|
||||
{
|
||||
this.flowIntoBlock(par1World, x - 1, y, z, var10);
|
||||
}
|
||||
|
||||
if (var13[1])
|
||||
{
|
||||
this.flowIntoBlock(par1World, x + 1, y, z, var10);
|
||||
}
|
||||
|
||||
if (var13[2])
|
||||
{
|
||||
this.flowIntoBlock(par1World, x, y, z - 1, var10);
|
||||
}
|
||||
|
||||
if (var13[3])
|
||||
{
|
||||
this.flowIntoBlock(par1World, x, y, z + 1, var10);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* flowIntoBlock(World world, int x, int y, int z, int newFlowDecay) - Flows into the block at
|
||||
* the coordinates and changes the block type to the liquid.
|
||||
*/
|
||||
private void flowIntoBlock(World par1World, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
if (this.liquidCanDisplaceBlock(par1World, par2, par3, par4))
|
||||
{
|
||||
int var6 = par1World.getBlockId(par2, par3, par4);
|
||||
|
||||
if (var6 > 0)
|
||||
{
|
||||
if (this.blockMaterial == Material.lava)
|
||||
{
|
||||
this.triggerLavaMixEffects(par1World, par2, par3, par4);
|
||||
}
|
||||
else
|
||||
{
|
||||
Block.blocksList[var6].dropBlockAsItem(par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0);
|
||||
}
|
||||
}
|
||||
|
||||
par1World.setBlockAndMetadataWithNotify(par2, par3, par4, this.blockID, par5);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* calculateFlowCost(World world, int x, int y, int z, int accumulatedCost, int
|
||||
* previousDirectionOfFlow) - Used to determine the path of least resistance, this method
|
||||
* returns the lowest possible flow cost for the direction of flow indicated. Each necessary
|
||||
* horizontal flow adds to the flow cost.
|
||||
*/
|
||||
private int calculateFlowCost(World par1World, int par2, int par3, int par4, int par5, int par6)
|
||||
{
|
||||
int var7 = 1000;
|
||||
|
||||
for (int var8 = 0; var8 < 4; ++var8)
|
||||
{
|
||||
if ((var8 != 0 || par6 != 1) && (var8 != 1 || par6 != 0) && (var8 != 2 || par6 != 3) && (var8 != 3 || par6 != 2))
|
||||
{
|
||||
int var9 = par2;
|
||||
int var11 = par4;
|
||||
|
||||
if (var8 == 0)
|
||||
{
|
||||
var9 = par2 - 1;
|
||||
}
|
||||
|
||||
if (var8 == 1)
|
||||
{
|
||||
++var9;
|
||||
}
|
||||
|
||||
if (var8 == 2)
|
||||
{
|
||||
var11 = par4 - 1;
|
||||
}
|
||||
|
||||
if (var8 == 3)
|
||||
{
|
||||
++var11;
|
||||
}
|
||||
|
||||
if (!this.blockBlocksFlow(par1World, var9, par3, var11) && (par1World.getBlockMaterial(var9, par3, var11) != this.blockMaterial || par1World.getBlockMetadata(var9, par3, var11) != 0))
|
||||
{
|
||||
if (!this.blockBlocksFlow(par1World, var9, par3 - 1, var11)) { return par5; }
|
||||
|
||||
if (par5 < 4)
|
||||
{
|
||||
int var12 = this.calculateFlowCost(par1World, var9, par3, var11, par5 + 1, var8);
|
||||
|
||||
if (var12 < var7)
|
||||
{
|
||||
var7 = var12;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return var7;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a boolean array indicating which flow directions are optimal based on each
|
||||
* direction's calculated flow cost. Each array index corresponds to one of the four cardinal
|
||||
* directions. A value of true indicates the direction is optimal.
|
||||
*/
|
||||
private boolean[] getOptimalFlowDirections(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
int var5;
|
||||
int var6;
|
||||
|
||||
for (var5 = 0; var5 < 4; ++var5)
|
||||
{
|
||||
this.flowCost[var5] = 1000;
|
||||
var6 = par2;
|
||||
int var8 = par4;
|
||||
|
||||
if (var5 == 0)
|
||||
{
|
||||
var6 = par2 - 1;
|
||||
}
|
||||
|
||||
if (var5 == 1)
|
||||
{
|
||||
++var6;
|
||||
}
|
||||
|
||||
if (var5 == 2)
|
||||
{
|
||||
var8 = par4 - 1;
|
||||
}
|
||||
|
||||
if (var5 == 3)
|
||||
{
|
||||
++var8;
|
||||
}
|
||||
|
||||
if (!this.blockBlocksFlow(par1World, var6, par3, var8) && (par1World.getBlockMaterial(var6, par3, var8) != this.blockMaterial || par1World.getBlockMetadata(var6, par3, var8) != 0))
|
||||
{
|
||||
if (this.blockBlocksFlow(par1World, var6, par3 - 1, var8))
|
||||
{
|
||||
this.flowCost[var5] = this.calculateFlowCost(par1World, var6, par3, var8, 1, var5);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.flowCost[var5] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var5 = this.flowCost[0];
|
||||
|
||||
for (var6 = 1; var6 < 4; ++var6)
|
||||
{
|
||||
if (this.flowCost[var6] < var5)
|
||||
{
|
||||
var5 = this.flowCost[var6];
|
||||
}
|
||||
}
|
||||
|
||||
for (var6 = 0; var6 < 4; ++var6)
|
||||
{
|
||||
this.isOptimalFlowDirection[var6] = this.flowCost[var6] == var5;
|
||||
}
|
||||
|
||||
return this.isOptimalFlowDirection;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderBlockPass()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if block at coords blocks fluids
|
||||
*/
|
||||
private boolean blockBlocksFlow(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
int var5 = par1World.getBlockId(par2, par3, par4);
|
||||
|
||||
if (var5 != Block.doorWood.blockID && var5 != Block.doorSteel.blockID && var5 != Block.signPost.blockID && var5 != Block.ladder.blockID && var5 != Block.reed.blockID)
|
||||
{
|
||||
if (var5 == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Material var6 = Block.blocksList[var5].blockMaterial;
|
||||
return var6 == Material.portal ? true : var6.blocksMovement();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* getSmallestFlowDecay(World world, intx, int y, int z, int currentSmallestFlowDecay) - Looks
|
||||
* up the flow decay at the coordinates given and returns the smaller of this value or the
|
||||
* provided currentSmallestFlowDecay. If one value is valid and the other isn't, the valid value
|
||||
* will be returned. Valid values are >= 0. Flow decay is the amount that a liquid has
|
||||
* dissipated. 0 indicates a source block.
|
||||
*/
|
||||
protected int getSmallestFlowDecay(World par1World, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
int var6 = this.getFlowDecay(par1World, par2, par3, par4);
|
||||
|
||||
if (var6 < 0)
|
||||
{
|
||||
return par5;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (var6 == 0)
|
||||
{
|
||||
++this.numAdjacentSources;
|
||||
}
|
||||
|
||||
if (var6 >= 8)
|
||||
{
|
||||
var6 = 0;
|
||||
}
|
||||
|
||||
return par5 >= 0 && var6 >= par5 ? par5 : var6;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the block at the coordinates can be displaced by the liquid.
|
||||
*/
|
||||
private boolean liquidCanDisplaceBlock(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
Material var5 = par1World.getBlockMaterial(par2, par3, par4);
|
||||
return var5 == this.blockMaterial ? false : (var5 == Material.lava ? false : !this.blockBlocksFlow(par1World, par2, par3, par4));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int stillLiquidId()
|
||||
{
|
||||
return BasicUtilitiesMain.oilStill.blockID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMetaSensitive()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int stillLiquidMeta()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlockReplaceable(World world, int i, int j, int k)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Triggered whenever an entity collides with this block (enters into the block). Args: world,
|
||||
* x, y, z, entity
|
||||
*/
|
||||
@Override
|
||||
public void onEntityCollidedWithBlock(World par1World, int x, int y, int z, Entity par5Entity)
|
||||
{
|
||||
if (par5Entity instanceof EntityLiving)
|
||||
{
|
||||
if (par5Entity.isInsideOfMaterial(this.blockMaterial))
|
||||
{
|
||||
((EntityLiving) par5Entity).addPotionEffect(new PotionEffect(Potion.blindness.id, 20, 2));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
145
minecraft/dark/BasicUtilities/Liquids/BlockOilStill.java
Normal file
145
minecraft/dark/BasicUtilities/Liquids/BlockOilStill.java
Normal file
|
@ -0,0 +1,145 @@
|
|||
package dark.BasicUtilities.Liquids;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockStationary;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.liquids.ILiquid;
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
|
||||
/**
|
||||
* The still version of oil.
|
||||
*
|
||||
* @author Cammygames
|
||||
*
|
||||
*/
|
||||
public class BlockOilStill extends BlockStationary implements ILiquid
|
||||
{
|
||||
public BlockOilStill(int id)
|
||||
{
|
||||
super(id, Material.water);
|
||||
this.setHardness(80F);
|
||||
this.setLightOpacity(0);
|
||||
this.setRequiresSelfNotify();
|
||||
this.disableStats();
|
||||
this.setBlockName("oilStill");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockAdded(World par1World, int x, int y, int z)
|
||||
{
|
||||
super.onBlockAdded(par1World, x, y, z);
|
||||
|
||||
for (byte i = 0; i < 6; i++)
|
||||
{
|
||||
Vector3 neighborPosition = new Vector3(x, y, z);
|
||||
neighborPosition.modifyPositionFromSide(ForgeDirection.getOrientation(i));
|
||||
|
||||
int neighborBlockID = par1World.getBlockId(neighborPosition.intX(), neighborPosition.intY(), neighborPosition.intZ());
|
||||
|
||||
if (neighborBlockID == Block.fire.blockID || neighborBlockID == Block.lavaMoving.blockID || neighborBlockID == Block.lavaStill.blockID)
|
||||
{
|
||||
par1World.setBlockWithNotify(x, y, z, Block.fire.blockID);
|
||||
par1World.playSoundEffect((double) ((float) x + 0.5F), (double) ((float) y + 0.5F), (double) ((float) z + 0.5F), "random.fizz", 0.5F, 2.6F + (par1World.rand.nextFloat() - par1World.rand.nextFloat()) * 0.8F);
|
||||
par1World.spawnParticle("largesmoke", (double) x + Math.random(), (double) y + 1.2D, (double) z + Math.random(), 0.0D, 0.0D, 0.0D);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed
|
||||
* (coordinates passed are their own) Args: x, y, z, neighbor blockID
|
||||
*/
|
||||
@Override
|
||||
public void onNeighborBlockChange(World par1World, int x, int y, int z, int neighborBlockID)
|
||||
{
|
||||
super.onNeighborBlockChange(par1World, x, y, z, neighborBlockID);
|
||||
|
||||
if (par1World.getBlockId(x, y, z) == this.blockID)
|
||||
{
|
||||
this.setNotStationary(par1World, x, y, z);
|
||||
}
|
||||
else if (neighborBlockID == Block.fire.blockID || neighborBlockID == Block.lavaMoving.blockID || neighborBlockID == Block.lavaStill.blockID)
|
||||
{
|
||||
par1World.setBlockWithNotify(x, y, z, Block.fire.blockID);
|
||||
par1World.playSoundEffect((double) ((float) x + 0.5F), (double) ((float) y + 0.5F), (double) ((float) z + 0.5F), "random.fizz", 0.5F, 2.6F + (par1World.rand.nextFloat() - par1World.rand.nextFloat()) * 0.8F);
|
||||
par1World.spawnParticle("largesmoke", (double) x + Math.random(), (double) y + 1.2D, (double) z + Math.random(), 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the block ID to that of an updating fluid.
|
||||
*/
|
||||
private void setNotStationary(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
int var5 = par1World.getBlockMetadata(par2, par3, par4);
|
||||
par1World.editingBlocks = true;
|
||||
par1World.setBlockAndMetadata(par2, par3, par4, this.blockID - 1, var5);
|
||||
par1World.markBlockRangeForRenderUpdate(par2, par3, par4, par2, par3, par4);
|
||||
par1World.scheduleBlockUpdate(par2, par3, par4, this.blockID - 1, this.tickRate());
|
||||
par1World.editingBlocks = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if the block is flammable.
|
||||
*/
|
||||
private boolean isFlammable(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
return par1World.getBlockMaterial(par2, par3, par4).getCanBurn();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int stillLiquidId()
|
||||
{
|
||||
return this.blockID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMetaSensitive()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int stillLiquidMeta()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderBlockPass()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int colorMultiplier(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
|
||||
{
|
||||
// TODO fix this so your oil is not so
|
||||
// dark
|
||||
return 0x11111110;
|
||||
}
|
||||
|
||||
/**
|
||||
* Triggered whenever an entity collides with this block (enters into the block). Args: world,
|
||||
* x, y, z, entity
|
||||
*/
|
||||
@Override
|
||||
public void onEntityCollidedWithBlock(World par1World, int x, int y, int z, Entity par5Entity)
|
||||
{
|
||||
if (par5Entity instanceof EntityLiving)
|
||||
{
|
||||
if (par5Entity.isInsideOfMaterial(this.blockMaterial))
|
||||
{
|
||||
((EntityLiving) par5Entity).addPotionEffect(new PotionEffect(Potion.blindness.id, 20, 2));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
34
minecraft/dark/BasicUtilities/Liquids/BlockSteam.java
Normal file
34
minecraft/dark/BasicUtilities/Liquids/BlockSteam.java
Normal file
|
@ -0,0 +1,34 @@
|
|||
package dark.BasicUtilities.Liquids;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraftforge.liquids.ILiquid;
|
||||
|
||||
public class BlockSteam extends Block implements ILiquid
|
||||
{
|
||||
public static int blockID;
|
||||
public BlockSteam(int par1)
|
||||
{
|
||||
super(par1, Material.air);
|
||||
blockID = par1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int stillLiquidId()
|
||||
{
|
||||
return blockID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMetaSensitive()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int stillLiquidMeta()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
50
minecraft/dark/BasicUtilities/Liquids/ItemOilBucket.java
Normal file
50
minecraft/dark/BasicUtilities/Liquids/ItemOilBucket.java
Normal file
|
@ -0,0 +1,50 @@
|
|||
package dark.BasicUtilities.Liquids;
|
||||
|
||||
import dark.BasicUtilities.BasicUtilitiesMain;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBucket;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.event.Event.Result;
|
||||
import net.minecraftforge.event.ForgeSubscribe;
|
||||
import net.minecraftforge.event.entity.player.FillBucketEvent;
|
||||
import universalelectricity.prefab.UETab;
|
||||
|
||||
public class ItemOilBucket extends ItemBucket
|
||||
{
|
||||
public ItemOilBucket(int id, int texture)
|
||||
{
|
||||
super(id, BasicUtilitiesMain.oilMoving.blockID);
|
||||
this.setIconIndex(texture);
|
||||
this.setCreativeTab(UETab.INSTANCE);
|
||||
this.setContainerItem(Item.bucketEmpty);
|
||||
this.setItemName("bucketOil");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTextureFile()
|
||||
{
|
||||
return BasicUtilitiesMain.ITEM_PNG;
|
||||
}
|
||||
|
||||
@ForgeSubscribe
|
||||
public void onBucketFill(FillBucketEvent event)
|
||||
{
|
||||
if (event.current.itemID == Item.bucketEmpty.shiftedIndex)
|
||||
{
|
||||
World worldObj = event.world;
|
||||
MovingObjectPosition position = event.target;
|
||||
|
||||
int blockID = worldObj.getBlockId(position.blockX, position.blockY, position.blockZ);
|
||||
|
||||
if ((blockID == BasicUtilitiesMain.oilStill.blockID || blockID == BasicUtilitiesMain.oilMoving.blockID) && worldObj.getBlockMetadata(position.blockX, position.blockY, position.blockZ) == 0)
|
||||
{
|
||||
worldObj.setBlockWithNotify(position.blockX, position.blockY, position.blockZ, 0);
|
||||
event.result = new ItemStack(BasicUtilitiesMain.itemOilBucket);
|
||||
event.current.stackSize--;
|
||||
event.setResult(Result.ALLOW);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
17
minecraft/dark/BasicUtilities/api/IHeatCreator.java
Normal file
17
minecraft/dark/BasicUtilities/api/IHeatCreator.java
Normal file
|
@ -0,0 +1,17 @@
|
|||
package dark.BasicUtilities.api;
|
||||
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
public interface IHeatCreator
|
||||
{
|
||||
/**
|
||||
* @param dir - direction
|
||||
* @return Can create heat in this direction
|
||||
*/
|
||||
public boolean canCreatHeat(ForgeDirection dir);
|
||||
/**
|
||||
* @param dir - direction
|
||||
* @return ammount of heat created in joules
|
||||
*/
|
||||
public int createHeat(ForgeDirection dir);
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
package dark.BasicUtilities.api;
|
||||
|
||||
import net.minecraft.src.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
public interface IReadOut
|
22
minecraft/dark/BasicUtilities/api/ITankOutputer.java
Normal file
22
minecraft/dark/BasicUtilities/api/ITankOutputer.java
Normal file
|
@ -0,0 +1,22 @@
|
|||
package dark.BasicUtilities.api;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.liquids.ITankContainer;
|
||||
|
||||
public interface ITankOutputer extends ITankContainer
|
||||
{
|
||||
/**
|
||||
* @param type - Liquid type
|
||||
* @param dir - direction pressure is being request to output
|
||||
* @return pressure if can output for the type or direction
|
||||
*/
|
||||
public int presureOutput(Liquid type, ForgeDirection dir);
|
||||
/**
|
||||
* Quick way to check if the TE will output pressure
|
||||
* @param type - Liquid type
|
||||
* @param dir - direction
|
||||
* @return
|
||||
*/
|
||||
public boolean canPressureToo(Liquid type, ForgeDirection dir);
|
||||
}
|
86
minecraft/dark/BasicUtilities/api/Liquid.java
Normal file
86
minecraft/dark/BasicUtilities/api/Liquid.java
Normal file
|
@ -0,0 +1,86 @@
|
|||
package dark.BasicUtilities.api;
|
||||
|
||||
import dark.BasicUtilities.BasicUtilitiesMain;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockSand;
|
||||
import net.minecraftforge.liquids.LiquidDictionary;
|
||||
import net.minecraftforge.liquids.LiquidStack;
|
||||
|
||||
/**
|
||||
* System too easily reference a liquid type and its info
|
||||
*
|
||||
* @author Rseifert
|
||||
*
|
||||
*/
|
||||
public enum Liquid
|
||||
{
|
||||
// -1 == null || unused
|
||||
STEAM("Steam", LiquidDictionary.getOrCreateLiquid("steam", new LiquidStack(BasicUtilitiesMain.SteamBlock, 1)), true, 100),
|
||||
WATER("Water", LiquidDictionary.getOrCreateLiquid("water", new LiquidStack(Block.waterStill, 1)), false, 32),
|
||||
LAVA("Lava", LiquidDictionary.getOrCreateLiquid("lava", new LiquidStack(Block.lavaStill, 1)), false, 20),
|
||||
OIL("Oil", LiquidDictionary.getOrCreateLiquid("oil", new LiquidStack(BasicUtilitiesMain.oilStill, 1)), true, 32),
|
||||
Fuel("Fuel", LiquidDictionary.getOrCreateLiquid("oil", new LiquidStack(BasicUtilitiesMain.oilStill, 1)), false, 40),
|
||||
DEFUALT("Empty", LiquidDictionary.getOrCreateLiquid("air", new LiquidStack(0, 1)), false, 0);
|
||||
|
||||
public final boolean doesFlaot;
|
||||
public final String displayerName;
|
||||
public final int defaultPresure;
|
||||
public final LiquidStack liquid;
|
||||
|
||||
private Liquid(String name, LiquidStack stack, boolean gas, int dPressure)
|
||||
{
|
||||
this.displayerName = name;
|
||||
this.liquid = stack;
|
||||
this.doesFlaot = gas;
|
||||
this.defaultPresure = dPressure;
|
||||
}
|
||||
|
||||
public static LiquidStack getStack(Liquid type, int vol)
|
||||
{
|
||||
return new LiquidStack(type.liquid.itemID, vol, type.liquid.itemMeta);
|
||||
}
|
||||
|
||||
/**
|
||||
* Only use this if you are converting from the old system Or have a special
|
||||
* need for it
|
||||
*
|
||||
* @param id
|
||||
* of liquid
|
||||
* @return Liquid Object
|
||||
*/
|
||||
public static Liquid getLiquid(int id)
|
||||
{
|
||||
if (id >= 0 && id < Liquid.values().length) { return Liquid.values()[id]; }
|
||||
return DEFUALT;
|
||||
}
|
||||
|
||||
/**
|
||||
* get the liquid type by its block ID
|
||||
*
|
||||
* @param bBlock
|
||||
* @return
|
||||
*/
|
||||
public static Liquid getLiquidByBlock(int bBlock)
|
||||
{
|
||||
for (int i = 0; i < Liquid.values().length - 1; i++)
|
||||
{
|
||||
Liquid selected = Liquid.getLiquid(i);
|
||||
if (bBlock == selected.liquid.itemID) { return selected; }
|
||||
}
|
||||
return Liquid.DEFUALT;
|
||||
}
|
||||
/**
|
||||
* Used to compare a liquidStack to a liquid type
|
||||
* @param stack
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
public static boolean isStackEqual(LiquidStack stack, Liquid type)
|
||||
{
|
||||
if(type.liquid.itemID == stack.itemID && type.liquid.itemMeta == stack.itemMeta)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -1,14 +1,14 @@
|
|||
package dark.BasicUtilities.api;
|
||||
|
||||
import net.minecraft.src.TileEntity;
|
||||
import net.minecraft.src.World;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
public class MHelper
|
||||
{
|
||||
/**
|
||||
* Used to find all tileEntities sounding the location
|
||||
* you will have to filter for select tileEntities
|
||||
* you will have to filter for selective tileEntities
|
||||
* @param world - the world being searched threw
|
||||
* @param x
|
||||
* @param y
|
||||
|
@ -17,8 +17,7 @@ public class MHelper
|
|||
*/
|
||||
public static TileEntity[] getSourounding(World world, int x, int y, int z)
|
||||
{
|
||||
TileEntity[] list = new TileEntity[]
|
||||
{ null, null, null, null, null, null };
|
||||
TileEntity[] list = new TileEntity[] { null, null, null, null, null, null };
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
ForgeDirection d = ForgeDirection.getOrientation(i);
|
||||
|
@ -46,49 +45,11 @@ public class MHelper
|
|||
* - max volume the tank can hold
|
||||
* @return the remaining liquid that was not traded away
|
||||
*/
|
||||
@Deprecated
|
||||
public static int shareLiquid(World world, int x, int y, int z, int vol, int max, Liquid type)
|
||||
{
|
||||
TileEntity ent = world.getBlockTileEntity(x, y, z);
|
||||
int currentVol = vol;
|
||||
|
||||
int tCount = 1;
|
||||
boolean rise = type.isGas;
|
||||
if (currentVol <= 0) { return 0; }
|
||||
|
||||
ForgeDirection st = ForgeDirection.getOrientation(rise ? 1 : 0);
|
||||
TileEntity first = world.getBlockTileEntity(x + st.offsetX, y + st.offsetY, z + st.offsetZ);
|
||||
// trades to the first, bottom for liquid, top for gas
|
||||
if (first instanceof IStorageTank && currentVol > 0 && ((IStorageTank) first).getStoredLiquid(type) < ((IStorageTank) first).getLiquidCapacity(type))
|
||||
{
|
||||
currentVol = ((IConsumer) first).onReceiveLiquid(type, currentVol, st);
|
||||
}
|
||||
int vAve = currentVol;
|
||||
TileEntity[] TeA = MHelper.getSourounding(world, x, y, z);
|
||||
for (int i = 2; i < 6; i++)
|
||||
{
|
||||
if (TeA[i] instanceof IStorageTank)
|
||||
{
|
||||
vAve += ((IStorageTank) TeA[i]).getStoredLiquid(type);
|
||||
tCount++;
|
||||
}
|
||||
}
|
||||
vAve = (int) (vAve / tCount);
|
||||
// trades to side if anything is left
|
||||
for (int i = 2; i < 6; i++)
|
||||
{
|
||||
ForgeDirection side = ForgeDirection.getOrientation(i);
|
||||
TileEntity sSide = world.getBlockTileEntity(x + side.offsetX, y + side.offsetY, z + side.offsetZ);
|
||||
if (currentVol <= 0 || currentVol <= vAve)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (sSide instanceof IStorageTank && ((IStorageTank) sSide).getStoredLiquid(type) < vAve)
|
||||
{
|
||||
int tA = vAve - Math.max((vAve - currentVol), 0);
|
||||
currentVol = ((IConsumer) sSide).onReceiveLiquid(type, tA, st) - tA + currentVol;
|
||||
}
|
||||
}
|
||||
return Math.max(currentVol, 0);
|
||||
return vol;
|
||||
}
|
||||
|
||||
/**
|
|
@ -1,9 +1,9 @@
|
|||
package dark.BasicUtilities.creative;
|
||||
|
||||
import net.minecraft.src.BlockContainer;
|
||||
import net.minecraft.src.Material;
|
||||
import net.minecraft.src.TileEntity;
|
||||
import net.minecraft.src.World;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
* A block that can only be accessed from the
|
|
@ -1,12 +1,11 @@
|
|||
package dark.BasicUtilities.machines;
|
||||
|
||||
import net.minecraft.src.BlockContainer;
|
||||
import net.minecraft.src.CreativeTabs;
|
||||
import net.minecraft.src.Material;
|
||||
import net.minecraft.src.TileEntity;
|
||||
import net.minecraft.src.World;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import dark.BasicUtilities.ItemRenderHelper;
|
||||
import dark.BasicUtilities.tanks.TileEntityLTank;
|
||||
|
||||
public class BlockMachine extends BlockContainer
|
||||
{
|
||||
|
@ -55,11 +54,11 @@ public class BlockMachine extends BlockContainer
|
|||
}
|
||||
if(meta == 4)
|
||||
{
|
||||
return new TileEntityCondenser();
|
||||
//return new TileEntityCondenser();
|
||||
}
|
||||
if(meta == 5)
|
||||
{
|
||||
return new TileEntityLTank();
|
||||
//return new TileEntityLTank();
|
||||
}
|
||||
return null;
|
||||
}
|
|
@ -2,14 +2,13 @@ package dark.BasicUtilities.machines;
|
|||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import dark.BasicUtilities.BasicUtilitiesMain;
|
||||
|
||||
import net.minecraft.src.CreativeTabs;
|
||||
import net.minecraft.src.EntityPlayer;
|
||||
import net.minecraft.src.Material;
|
||||
import net.minecraft.src.TileEntity;
|
||||
import net.minecraft.src.World;
|
||||
|
||||
public class BlockValve extends universalelectricity.prefab.BlockMachine
|
||||
{
|
||||
|
|
@ -2,17 +2,16 @@ package dark.BasicUtilities.machines;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import dark.BasicUtilities.BasicUtilitiesMain;
|
||||
|
||||
import net.minecraft.src.Block;
|
||||
import net.minecraft.src.CreativeTabs;
|
||||
import net.minecraft.src.EntityPlayer;
|
||||
import net.minecraft.src.ItemBlock;
|
||||
import net.minecraft.src.ItemStack;
|
||||
import net.minecraft.src.MathHelper;
|
||||
import net.minecraft.src.TileEntity;
|
||||
import net.minecraft.src.World;
|
||||
|
||||
public class ItemMachine extends ItemBlock
|
||||
{
|
||||
int index = 26;
|
|
@ -2,17 +2,16 @@ package dark.BasicUtilities.machines;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import dark.BasicUtilities.BasicUtilitiesMain;
|
||||
|
||||
import net.minecraft.src.Block;
|
||||
import net.minecraft.src.CreativeTabs;
|
||||
import net.minecraft.src.EntityPlayer;
|
||||
import net.minecraft.src.ItemBlock;
|
||||
import net.minecraft.src.ItemStack;
|
||||
import net.minecraft.src.MathHelper;
|
||||
import net.minecraft.src.TileEntity;
|
||||
import net.minecraft.src.World;
|
||||
|
||||
public class ItemValve extends ItemBlock
|
||||
{
|
||||
int index = 26;
|
282
minecraft/dark/BasicUtilities/machines/TileEntityPump.java
Normal file
282
minecraft/dark/BasicUtilities/machines/TileEntityPump.java
Normal file
|
@ -0,0 +1,282 @@
|
|||
package dark.BasicUtilities.machines;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.INetworkManager;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.network.packet.Packet250CustomPayload;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.liquids.ILiquidTank;
|
||||
import net.minecraftforge.liquids.ITankContainer;
|
||||
import net.minecraftforge.liquids.LiquidContainerRegistry;
|
||||
import net.minecraftforge.liquids.LiquidStack;
|
||||
import net.minecraftforge.liquids.LiquidTank;
|
||||
import universalelectricity.core.electricity.ElectricityConnections;
|
||||
import universalelectricity.core.electricity.ElectricityNetwork;
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
import universalelectricity.prefab.network.IPacketReceiver;
|
||||
import universalelectricity.prefab.network.PacketManager;
|
||||
import universalelectricity.prefab.tile.TileEntityElectricityReceiver;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
||||
import dark.BasicUtilities.BasicUtilitiesMain;
|
||||
import dark.BasicUtilities.api.IReadOut;
|
||||
import dark.BasicUtilities.api.ITankOutputer;
|
||||
import dark.BasicUtilities.api.Liquid;
|
||||
|
||||
public class TileEntityPump extends TileEntityElectricityReceiver implements IPacketReceiver, IReadOut, ITankOutputer
|
||||
{
|
||||
|
||||
double percentPumped = 0.0;
|
||||
double WATTS_PER_TICK = 400;
|
||||
double joulesReceived = 0;
|
||||
int wMax = LiquidContainerRegistry.BUCKET_VOLUME * 2;
|
||||
int disableTimer = 0;
|
||||
int count = 0;
|
||||
|
||||
public Liquid type = Liquid.DEFUALT;
|
||||
public LiquidTank tank = new LiquidTank(wMax);
|
||||
|
||||
@Override
|
||||
public void initiate()
|
||||
{
|
||||
ElectricityConnections.registerConnector(this, EnumSet.of(ForgeDirection.getOrientation(this.getBlockMetadata() + 2)));
|
||||
this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, BasicUtilitiesMain.machine.blockID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable(int duration)
|
||||
{
|
||||
disableTimer = duration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDisabled()
|
||||
{
|
||||
if (disableTimer <= 0) { return false; }
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
super.updateEntity();
|
||||
|
||||
if (!this.worldObj.isRemote)
|
||||
{
|
||||
if (count-- <= 0)
|
||||
{
|
||||
int bBlock = worldObj.getBlockId(xCoord, yCoord - 1, zCoord);
|
||||
Liquid bellow = Liquid.getLiquidByBlock(bBlock);
|
||||
if (bellow != null)
|
||||
{
|
||||
if (this.type != bellow && bellow != Liquid.DEFUALT)
|
||||
{
|
||||
this.tank.setLiquid(Liquid.getStack(bellow, 0));
|
||||
}
|
||||
this.type = bellow;
|
||||
}
|
||||
count = 40;
|
||||
}
|
||||
|
||||
LiquidStack stack = tank.getLiquid();
|
||||
|
||||
if (stack != null)
|
||||
{
|
||||
|
||||
if (stack.amount >= 0)
|
||||
{
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(i);
|
||||
TileEntity tile = worldObj.getBlockTileEntity(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ);
|
||||
|
||||
if (tile instanceof ITankContainer)
|
||||
{
|
||||
int moved = ((ITankContainer) tile).fill(dir.getOpposite(), stack, true);
|
||||
tank.drain(moved, true);
|
||||
if (stack.amount <= 0) break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ForgeDirection inputDirection = ForgeDirection.getOrientation(this.getBlockMetadata() + 2);
|
||||
TileEntity inputTile = Vector3.getTileEntityFromSide(this.worldObj, new Vector3(this), inputDirection);
|
||||
|
||||
ElectricityNetwork network = ElectricityNetwork.getNetworkFromTileEntity(inputTile, inputDirection);
|
||||
|
||||
if (network != null)
|
||||
{
|
||||
if (this.canPump())
|
||||
{
|
||||
network.startRequesting(this, WATTS_PER_TICK / this.getVoltage(), this.getVoltage());
|
||||
this.joulesReceived = Math.max(Math.min(this.joulesReceived + network.consumeElectricity(this).getWatts(), WATTS_PER_TICK), 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
network.stopRequesting(this);
|
||||
}
|
||||
}
|
||||
if (this.joulesReceived >= this.WATTS_PER_TICK - 50 && this.canPump())
|
||||
{
|
||||
|
||||
joulesReceived -= this.WATTS_PER_TICK;
|
||||
if (percentPumped++ == 20)
|
||||
{
|
||||
this.drainBlock(new Vector3(xCoord, yCoord - 1, zCoord));
|
||||
percentPumped = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.worldObj.isRemote)
|
||||
{
|
||||
if (this.ticks % 10 == 0)
|
||||
{
|
||||
Packet packet = PacketManager.getPacket(BasicUtilitiesMain.CHANNEL, this, this.type.ordinal());
|
||||
PacketManager.sendPacketToClients(packet, worldObj, new Vector3(this), 60);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canPump()
|
||||
{
|
||||
//if (this.tank.getLiquid() == null) return false;
|
||||
if (this.tank.getLiquid() != null && this.tank.getLiquid().amount >= this.wMax) return false;
|
||||
if (this.isDisabled()) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* drains the block or in other words removes it
|
||||
*
|
||||
* @param loc
|
||||
* @return true if the block was drained
|
||||
*/
|
||||
public boolean drainBlock(Vector3 loc)
|
||||
{
|
||||
int bBlock = worldObj.getBlockId(loc.intX(), loc.intY(), loc.intZ());
|
||||
Liquid bellow = Liquid.getLiquidByBlock(bBlock);
|
||||
if (bBlock == type.liquid.itemID)
|
||||
{
|
||||
int f = this.tank.fill(Liquid.getStack(this.type, LiquidContainerRegistry.BUCKET_VOLUME), true);
|
||||
if (f > 0) worldObj.setBlockWithNotify(loc.intX(), loc.intY(), loc.intZ(), 0);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacketData(INetworkManager network, int packetType, Packet250CustomPayload packet, EntityPlayer player, ByteArrayDataInput data)
|
||||
{
|
||||
try
|
||||
{
|
||||
this.type = (Liquid.getLiquid(data.readInt()));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a tile entity from NBT.
|
||||
*/
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound par1NBTTagCompound)
|
||||
{
|
||||
super.readFromNBT(par1NBTTagCompound);
|
||||
int stored = par1NBTTagCompound.getInteger("liquid");
|
||||
this.type = Liquid.getLiquid(par1NBTTagCompound.getInteger("type"));
|
||||
this.tank.setLiquid(Liquid.getStack(this.type, stored));
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a tile entity to NBT.
|
||||
*/
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound par1NBTTagCompound)
|
||||
{
|
||||
super.writeToNBT(par1NBTTagCompound);
|
||||
int s = 1;
|
||||
if (this.tank.getLiquid() != null) s = this.tank.getLiquid().amount;
|
||||
par1NBTTagCompound.setInteger("liquid", s);
|
||||
par1NBTTagCompound.setInteger("type", this.type.ordinal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMeterReading(EntityPlayer user, ForgeDirection side)
|
||||
{
|
||||
int liquid = 0;
|
||||
if (this.tank.getLiquid() != null)
|
||||
{
|
||||
liquid = (this.tank.getLiquid().amount / LiquidContainerRegistry.BUCKET_VOLUME);
|
||||
}
|
||||
else
|
||||
{
|
||||
liquid = -10;
|
||||
}
|
||||
return liquid + "" + type.displayerName + " " + this.joulesReceived + "W " + this.percentPumped + "/20";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(ForgeDirection from, LiquidStack resource, boolean doFill)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(int tankIndex, LiquidStack resource, boolean doFill)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LiquidStack drain(ForgeDirection from, int maxDrain, boolean doDrain)
|
||||
{
|
||||
return drain(0, maxDrain, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LiquidStack drain(int tankIndex, int maxDrain, boolean doDrain)
|
||||
{
|
||||
if (tankIndex == 0)
|
||||
return tank.drain(maxDrain, doDrain);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILiquidTank[] getTanks(ForgeDirection direction)
|
||||
{
|
||||
return new ILiquidTank[]
|
||||
{ tank };
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILiquidTank getTank(ForgeDirection direction, LiquidStack type)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int presureOutput(Liquid type, ForgeDirection dir)
|
||||
{
|
||||
if (type == this.type) return type.defaultPresure;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPressureToo(Liquid type, ForgeDirection dir)
|
||||
{
|
||||
if (type == this.type) return true;
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -1,13 +1,11 @@
|
|||
package dark.BasicUtilities.machines;
|
||||
|
||||
import net.minecraft.src.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import dark.BasicUtilities.api.IConsumer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import dark.BasicUtilities.api.Liquid;
|
||||
import dark.BasicUtilities.api.MHelper;
|
||||
import dark.BasicUtilities.pipes.TileEntityPipe;
|
||||
|
||||
public class TileEntityValve extends TileEntity implements IConsumer {
|
||||
public class TileEntityValve extends TileEntity{
|
||||
Liquid type = Liquid.DEFUALT;
|
||||
int liquidStored = 0;
|
||||
int lMax = 1;
|
||||
|
@ -70,40 +68,6 @@ boolean on = false;
|
|||
tickCount = 0;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public int onReceiveLiquid(Liquid type, int vol, ForgeDirection side) {
|
||||
if(this.type == Liquid.DEFUALT)
|
||||
{
|
||||
this.type = type;
|
||||
}
|
||||
return vol;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRecieveLiquid(Liquid type, ForgeDirection forgeDirection) {
|
||||
if(type == this.type)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStoredLiquid(Liquid type) {
|
||||
if(type == this.type)
|
||||
{
|
||||
return liquidStored;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLiquidCapacity(Liquid type) {
|
||||
if(type == this.type)
|
||||
{
|
||||
return lMax;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
|
@ -2,17 +2,16 @@ package dark.BasicUtilities.mechanical;
|
|||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import dark.BasicUtilities.ItemRenderHelper;
|
||||
|
||||
import net.minecraft.src.CreativeTabs;
|
||||
import net.minecraft.src.EntityLiving;
|
||||
import net.minecraft.src.EntityPlayer;
|
||||
import net.minecraft.src.ItemStack;
|
||||
import net.minecraft.src.Material;
|
||||
import net.minecraft.src.MathHelper;
|
||||
import net.minecraft.src.TileEntity;
|
||||
import net.minecraft.src.World;
|
||||
|
||||
public class BlockGenerator extends universalelectricity.prefab.BlockMachine {
|
||||
|
||||
public BlockGenerator(int id) {
|
||||
|
@ -34,8 +33,8 @@ public class BlockGenerator extends universalelectricity.prefab.BlockMachine {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean onUseWrench(World par1World, int x, int y, int z,
|
||||
EntityPlayer par5EntityPlayer) {
|
||||
public boolean onUseWrench(World par1World, int x, int y, int z, EntityPlayer par5EntityPlayer, int side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
int angle = MathHelper
|
||||
.floor_double((par5EntityPlayer.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
|
||||
int metadata = par1World.getBlockMetadata(x, y, z);
|
|
@ -1,12 +1,12 @@
|
|||
package dark.BasicUtilities.mechanical;
|
||||
|
||||
import net.minecraft.src.CreativeTabs;
|
||||
import net.minecraft.src.EntityLiving;
|
||||
import net.minecraft.src.EntityPlayer;
|
||||
import net.minecraft.src.Material;
|
||||
import net.minecraft.src.MathHelper;
|
||||
import net.minecraft.src.TileEntity;
|
||||
import net.minecraft.src.World;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import dark.BasicUtilities.ItemRenderHelper;
|
||||
|
||||
|
@ -39,7 +39,7 @@ public class BlockRod extends universalelectricity.prefab.BlockMachine {
|
|||
world.setBlockAndMetadataWithUpdate(i, j, k,blockID, meta, true);
|
||||
}
|
||||
@Override
|
||||
public boolean onUseWrench(World world, int x, int y, int z, EntityPlayer par5EntityPlayer)
|
||||
public boolean onUseWrench(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if(meta >= 5)
|
212
minecraft/dark/BasicUtilities/mechanical/TileEntityGen.java
Normal file
212
minecraft/dark/BasicUtilities/mechanical/TileEntityGen.java
Normal file
|
@ -0,0 +1,212 @@
|
|||
package dark.BasicUtilities.mechanical;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.network.INetworkManager;
|
||||
import net.minecraft.network.packet.Packet250CustomPayload;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import universalelectricity.core.electricity.ElectricityConnections;
|
||||
import universalelectricity.core.electricity.ElectricityNetwork;
|
||||
import universalelectricity.core.implement.IConductor;
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
import universalelectricity.prefab.network.IPacketReceiver;
|
||||
import universalelectricity.prefab.tile.TileEntityElectricityProducer;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
||||
import dark.BasicUtilities.BasicUtilitiesMain;
|
||||
import dark.BasicUtilities.api.IForce;
|
||||
import dark.BasicUtilities.api.IReadOut;
|
||||
import dark.BasicUtilities.api.MHelper;
|
||||
|
||||
public class TileEntityGen extends TileEntityElectricityProducer implements IPacketReceiver, IForce, IReadOut
|
||||
{
|
||||
ForgeDirection facing = ForgeDirection.DOWN;
|
||||
|
||||
public int force = 0;// current total force
|
||||
public int aForce = 0;// force this unit can apply
|
||||
public int pos = 0;// current pos of rotation max of 8
|
||||
public int disableTicks = 0;// time disabled
|
||||
public double genAmmount = 0;// watt output of machine
|
||||
public int tCount = 0;
|
||||
|
||||
IConductor[] wires =
|
||||
{ null, null, null, null, null, null };
|
||||
|
||||
public boolean needUpdate()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public void initiate()
|
||||
{
|
||||
ElectricityConnections.registerConnector(this, EnumSet.of(ForgeDirection.UP));
|
||||
ElectricityConnections.registerConnector(this, EnumSet.of(ForgeDirection.DOWN));
|
||||
this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, BasicUtilitiesMain.generator.blockID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
this.genAmmount = force / this.getVoltage();
|
||||
|
||||
int wireCount = 0;
|
||||
TileEntity[] ents = MHelper.getSourounding(worldObj, xCoord, yCoord, zCoord);
|
||||
this.wires = new IConductor[6];
|
||||
for (int i = 0; i < ents.length; i++)
|
||||
{
|
||||
if (ents[i] instanceof IConductor)
|
||||
{
|
||||
this.wires[i] = (IConductor) ents[i];
|
||||
wireCount++;
|
||||
}
|
||||
}
|
||||
if (!this.worldObj.isRemote)
|
||||
{
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
//TODO set up for other sides
|
||||
if (i == 0 || i == 1)
|
||||
{
|
||||
ForgeDirection outputDirection = ForgeDirection.getOrientation(i);
|
||||
TileEntity outputTile = Vector3.getConnectorFromSide(this.worldObj, new Vector3(this.xCoord, this.yCoord, this.zCoord), outputDirection);
|
||||
|
||||
ElectricityNetwork network = ElectricityNetwork.getNetworkFromTileEntity(outputTile, outputDirection);
|
||||
this.outputEnergy(network, wires[i], outputTile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
super.updateEntity();
|
||||
}
|
||||
|
||||
public void outputEnergy(ElectricityNetwork network, IConductor connectedElectricUnit, TileEntity outputTile)
|
||||
{
|
||||
if (network != null)
|
||||
{
|
||||
if (network.getRequest().getWatts() > 0)
|
||||
{
|
||||
connectedElectricUnit = (IConductor) outputTile;
|
||||
}
|
||||
else
|
||||
{
|
||||
connectedElectricUnit = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
connectedElectricUnit = null;
|
||||
}
|
||||
|
||||
if (connectedElectricUnit != null)
|
||||
{
|
||||
if (this.genAmmount > 0)
|
||||
{
|
||||
connectedElectricUnit.getNetwork().startProducing(this, (this.genAmmount / this.getVoltage()) / 20, this.getVoltage());
|
||||
}
|
||||
else
|
||||
{
|
||||
connectedElectricUnit.getNetwork().stopProducing(this);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* does the basic animation for the model
|
||||
*/
|
||||
public void doAnimation()
|
||||
{
|
||||
if (worldObj.isRemote)
|
||||
{
|
||||
this.pos += 1;
|
||||
if (pos >= 8 || pos < 0)
|
||||
{
|
||||
pos = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------
|
||||
// Data handling
|
||||
// ------------------------------
|
||||
@Override
|
||||
public void handlePacketData(INetworkManager network, int packetType, Packet250CustomPayload packet, EntityPlayer player, ByteArrayDataInput data)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
// ------------------------------
|
||||
// Mechanics
|
||||
// ------------------------------
|
||||
@Override
|
||||
public int getForceSide(ForgeDirection side)
|
||||
{
|
||||
if (side == facing.getOpposite()) { return aForce; }
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getForce()
|
||||
{
|
||||
return this.force;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canOutputSide(ForgeDirection side)
|
||||
{
|
||||
if (side == facing.getOpposite()) { return true; }
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInputSide(ForgeDirection side)
|
||||
{
|
||||
if (side == facing) { return true; }
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int applyForce(int force)
|
||||
{
|
||||
this.force = force;
|
||||
return force;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAnimationPos()
|
||||
{
|
||||
return pos;
|
||||
}
|
||||
|
||||
// ------------------------------
|
||||
// Electric
|
||||
// ------------------------------
|
||||
@Override
|
||||
public void onDisable(int duration)
|
||||
{
|
||||
this.disableTicks = duration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDisabled()
|
||||
{
|
||||
if (disableTicks-- <= 0) { return false; }
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getVoltage()
|
||||
{
|
||||
return 120;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMeterReading(EntityPlayer user, ForgeDirection side)
|
||||
{
|
||||
return this.force + "N Input " + this.genAmmount + "W output";
|
||||
}
|
||||
|
||||
}
|
|
@ -1,10 +1,10 @@
|
|||
package dark.BasicUtilities.mechanical;
|
||||
|
||||
import net.minecraft.src.EntityPlayer;
|
||||
import net.minecraft.src.INetworkManager;
|
||||
import net.minecraft.src.Packet;
|
||||
import net.minecraft.src.Packet250CustomPayload;
|
||||
import net.minecraft.src.TileEntity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.network.INetworkManager;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.network.packet.Packet250CustomPayload;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
import universalelectricity.prefab.network.IPacketReceiver;
|
|
@ -2,12 +2,12 @@ package dark.BasicUtilities.pipes;
|
|||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.src.BlockContainer;
|
||||
import net.minecraft.src.EntityItem;
|
||||
import net.minecraft.src.ItemStack;
|
||||
import net.minecraft.src.Material;
|
||||
import net.minecraft.src.TileEntity;
|
||||
import net.minecraft.src.World;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import dark.BasicUtilities.BasicUtilitiesMain;
|
||||
|
||||
public class BlockPipe extends BlockContainer
|
|
@ -2,13 +2,13 @@ package dark.BasicUtilities.pipes;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.src.Block;
|
||||
import net.minecraft.src.CreativeTabs;
|
||||
import net.minecraft.src.EntityPlayer;
|
||||
import net.minecraft.src.Item;
|
||||
import net.minecraft.src.ItemStack;
|
||||
import net.minecraft.src.TileEntity;
|
||||
import net.minecraft.src.World;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import dark.BasicUtilities.BasicUtilitiesMain;
|
||||
import dark.BasicUtilities.api.Liquid;
|
||||
|
||||
|
@ -37,20 +37,17 @@ public class ItemPipe extends Item
|
|||
@Override
|
||||
public String getItemNameIS(ItemStack itemstack)
|
||||
{
|
||||
return itemstack.getItemDamage() < Liquid.values().length ? Liquid.getLiquid(itemstack.getItemDamage()).lName + " Pipe" : "Empty Pipe";
|
||||
return itemstack.getItemDamage() < Liquid.values().length ? Liquid.getLiquid(itemstack.getItemDamage()).displayerName + " Pipe" : "Empty Pipe";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List)
|
||||
{
|
||||
for (int i = 0; i < Liquid.values().length; i++)
|
||||
{
|
||||
if (Liquid.getLiquid(i).showMenu)
|
||||
{
|
||||
par3List.add(new ItemStack(this, 1, i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String getTextureFile()
|
||||
{
|
270
minecraft/dark/BasicUtilities/pipes/TileEntityPipe.java
Normal file
270
minecraft/dark/BasicUtilities/pipes/TileEntityPipe.java
Normal file
|
@ -0,0 +1,270 @@
|
|||
package dark.BasicUtilities.pipes;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.INetworkManager;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.network.packet.Packet250CustomPayload;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.liquids.ILiquidTank;
|
||||
import net.minecraftforge.liquids.ITankContainer;
|
||||
import net.minecraftforge.liquids.LiquidContainerRegistry;
|
||||
import net.minecraftforge.liquids.LiquidStack;
|
||||
import net.minecraftforge.liquids.LiquidTank;
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
import universalelectricity.prefab.network.IPacketReceiver;
|
||||
import universalelectricity.prefab.network.PacketManager;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
|
||||
import dark.BasicUtilities.BasicUtilitiesMain;
|
||||
import dark.BasicUtilities.api.IReadOut;
|
||||
import dark.BasicUtilities.api.ITankOutputer;
|
||||
import dark.BasicUtilities.api.Liquid;
|
||||
import dark.BasicUtilities.api.MHelper;
|
||||
|
||||
public class TileEntityPipe extends TileEntity implements ITankContainer, IPacketReceiver, IReadOut
|
||||
{
|
||||
protected Liquid type = Liquid.DEFUALT;
|
||||
private int count = 20;
|
||||
private int count2, presure = 0;
|
||||
|
||||
protected boolean firstUpdate = true;
|
||||
|
||||
public TileEntity[] connectedBlocks = { null, null, null, null, null, null };
|
||||
public LiquidTank stored = new LiquidTank(LiquidContainerRegistry.BUCKET_VOLUME * 3);
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
if (++count >= 40)
|
||||
{
|
||||
count = 0;
|
||||
this.connectedBlocks = MHelper.getSourounding(worldObj, xCoord, yCoord, zCoord);
|
||||
for (int e = 0; e < 6; e++)
|
||||
{
|
||||
if (connectedBlocks[e] instanceof ITankContainer)
|
||||
{
|
||||
if (connectedBlocks[e] instanceof TileEntityPipe && ((TileEntityPipe) connectedBlocks[e]).type != this.type)
|
||||
{
|
||||
connectedBlocks[e] = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
connectedBlocks[e] = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!worldObj.isRemote)
|
||||
{
|
||||
this.updatePressure();
|
||||
if (count2-- <= 0)
|
||||
{
|
||||
count2 = 5;
|
||||
firstUpdate = false;
|
||||
Packet packet = PacketManager.getPacket(BasicUtilitiesMain.CHANNEL, this, this.type.ordinal());
|
||||
PacketManager.sendPacketToClients(packet, worldObj, new Vector3(this), 60);
|
||||
}
|
||||
|
||||
LiquidStack stack = stored.getLiquid();
|
||||
if (stack != null && stack.amount >= 0)
|
||||
{
|
||||
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(i);
|
||||
int moved = 0;
|
||||
if (connectedBlocks[i] instanceof ITankContainer)
|
||||
{
|
||||
if (connectedBlocks[i] instanceof TileEntityPipe)
|
||||
{
|
||||
if (((TileEntityPipe) connectedBlocks[i]).presure < this.presure)
|
||||
{
|
||||
moved = ((TileEntityPipe) connectedBlocks[i]).stored.fill(stack, true);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
moved = ((ITankContainer) connectedBlocks[i]).fill(dir.getOpposite(), stack, true);
|
||||
}
|
||||
}
|
||||
stored.drain(moved, true);
|
||||
// FMLLog.warning("Moved "+moved+ " "+ i);
|
||||
if (stack.amount <= 0)
|
||||
{
|
||||
FMLLog.warning("Empty");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// returns liquid type
|
||||
public Liquid getType()
|
||||
{
|
||||
return this.type;
|
||||
}
|
||||
|
||||
// used by the item to set the liquid type on spawn
|
||||
public void setType(Liquid rType)
|
||||
{
|
||||
this.type = rType;
|
||||
}
|
||||
|
||||
// ---------------------
|
||||
// data
|
||||
// --------------------
|
||||
@Override
|
||||
public void handlePacketData(INetworkManager network, int packetType, Packet250CustomPayload packet, EntityPlayer player, ByteArrayDataInput data)
|
||||
{
|
||||
try
|
||||
{
|
||||
this.setType(Liquid.getLiquid(data.readInt()));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a tile entity from NBT.
|
||||
*/
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound par1NBTTagCompound)
|
||||
{
|
||||
super.readFromNBT(par1NBTTagCompound);
|
||||
this.type = Liquid.getLiquid(par1NBTTagCompound.getInteger("type"));
|
||||
int vol = par1NBTTagCompound.getInteger("liquid");
|
||||
this.stored.setLiquid(Liquid.getStack(type, vol));
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a tile entity to NBT.
|
||||
*/
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound par1NBTTagCompound)
|
||||
{
|
||||
super.writeToNBT(par1NBTTagCompound);
|
||||
int s = 0;
|
||||
LiquidStack stack = this.stored.getLiquid();
|
||||
if (stack != null) s = stack.amount;
|
||||
par1NBTTagCompound.setInteger("liquid", s);
|
||||
par1NBTTagCompound.setInteger("type", this.type.ordinal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMeterReading(EntityPlayer user, ForgeDirection side)
|
||||
{
|
||||
String output = "";
|
||||
LiquidStack stack = stored.getLiquid();
|
||||
if (stack != null) output += (stack.amount / LiquidContainerRegistry.BUCKET_VOLUME) + " " + this.type.displayerName;
|
||||
output += " @" + this.presure + "psi";
|
||||
if (stack != null) return output;
|
||||
|
||||
return "Error";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(ForgeDirection from, LiquidStack resource, boolean doFill)
|
||||
{
|
||||
LiquidStack stack = stored.getLiquid();
|
||||
if (stack != null && Liquid.isStackEqual(resource, this.type)) return fill(0, resource, doFill);
|
||||
if (stack == null) stored.setLiquid(Liquid.getStack(this.type, 0));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(int tankIndex, LiquidStack resource, boolean doFill)
|
||||
{
|
||||
if (tankIndex != 0 || resource == null)
|
||||
return 0;
|
||||
|
||||
return stored.fill(resource, doFill);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LiquidStack drain(ForgeDirection from, int maxDrain, boolean doDrain)
|
||||
{
|
||||
return drain(0, maxDrain, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LiquidStack drain(int tankIndex, int maxDrain, boolean doDrain)
|
||||
{
|
||||
return stored.drain(maxDrain, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILiquidTank[] getTanks(ForgeDirection direction)
|
||||
{
|
||||
return new ILiquidTank[]
|
||||
{ this.stored };
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILiquidTank getTank(ForgeDirection direction, LiquidStack type)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to determan pipe connection rules
|
||||
*/
|
||||
public boolean canConntect(TileEntity entity)
|
||||
{
|
||||
if (entity instanceof TileEntityPipe)
|
||||
{
|
||||
if (((TileEntityPipe) entity).type == this.type && this.type != Liquid.DEFUALT) { return true; }
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* used to cause the pipes pressure to update depending on what is connected
|
||||
* to it
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public void updatePressure()
|
||||
{
|
||||
int highestPressure = 0;
|
||||
this.presure = 0;
|
||||
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(i);
|
||||
|
||||
if (connectedBlocks[i] instanceof TileEntityPipe && ((TileEntityPipe) connectedBlocks[i]).canConntect(this))
|
||||
{
|
||||
if (((TileEntityPipe) connectedBlocks[i]).getPressure() > highestPressure)
|
||||
{
|
||||
highestPressure = ((TileEntityPipe) connectedBlocks[i]).getPressure();
|
||||
}
|
||||
}
|
||||
if (connectedBlocks[i] instanceof ITankOutputer && ((ITankOutputer) connectedBlocks[i]).canPressureToo(this.type, dir))
|
||||
{
|
||||
|
||||
int p = ((ITankOutputer) connectedBlocks[i]).presureOutput(this.type, dir);
|
||||
if (p > highestPressure) highestPressure = p;
|
||||
}
|
||||
}
|
||||
this.presure = highestPressure - 1;
|
||||
}
|
||||
|
||||
public int getPressure()
|
||||
{
|
||||
return this.presure;
|
||||
}
|
||||
}
|
73
minecraft/dark/BasicUtilities/pipes/TileEntityPumpPipe.java
Normal file
73
minecraft/dark/BasicUtilities/pipes/TileEntityPumpPipe.java
Normal file
|
@ -0,0 +1,73 @@
|
|||
package dark.BasicUtilities.pipes;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.liquids.ILiquidTank;
|
||||
import net.minecraftforge.liquids.LiquidStack;
|
||||
import dark.BasicUtilities.api.ITankOutputer;
|
||||
import dark.BasicUtilities.api.Liquid;
|
||||
|
||||
public class TileEntityPumpPipe extends TileEntity implements ITankOutputer
|
||||
{
|
||||
private ForgeDirection input;
|
||||
private Liquid outputType = Liquid.DEFUALT;
|
||||
|
||||
@Override
|
||||
public int fill(ForgeDirection from, LiquidStack resource, boolean doFill)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(int tankIndex, LiquidStack resource, boolean doFill)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LiquidStack drain(ForgeDirection from, int maxDrain, boolean doDrain)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LiquidStack drain(int tankIndex, int maxDrain, boolean doDrain)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILiquidTank[] getTanks(ForgeDirection direction)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILiquidTank getTank(ForgeDirection direction, LiquidStack type)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public int presureOutput(Liquid type, ForgeDirection dir)
|
||||
{
|
||||
if(dir != this.input.getOpposite() && type == this.outputType)
|
||||
{
|
||||
return type.defaultPresure;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPressureToo(Liquid type, ForgeDirection dir)
|
||||
{
|
||||
if(type == this.outputType && dir != this.input.getOpposite()) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
|
@ -11,8 +11,8 @@
|
|||
|
||||
package dark.BasicUtilities.renders;
|
||||
|
||||
import net.minecraft.src.ModelBase;
|
||||
import net.minecraft.src.ModelRenderer;
|
||||
import net.minecraft.client.model.ModelBase;
|
||||
import net.minecraft.client.model.ModelRenderer;
|
||||
|
||||
public class ModelGearRod extends ModelBase
|
||||
{
|
|
@ -11,9 +11,9 @@
|
|||
|
||||
package dark.BasicUtilities.renders;
|
||||
|
||||
import net.minecraft.src.Entity;
|
||||
import net.minecraft.src.ModelBase;
|
||||
import net.minecraft.src.ModelRenderer;
|
||||
import net.minecraft.client.model.ModelBase;
|
||||
import net.minecraft.client.model.ModelRenderer;
|
||||
import net.minecraft.entity.Entity;
|
||||
|
||||
public class ModelGenerator extends ModelBase
|
||||
{
|
|
@ -11,9 +11,8 @@
|
|||
|
||||
package dark.BasicUtilities.renders;
|
||||
|
||||
import net.minecraft.src.Entity;
|
||||
import net.minecraft.src.ModelBase;
|
||||
import net.minecraft.src.ModelRenderer;
|
||||
import net.minecraft.client.model.ModelBase;
|
||||
import net.minecraft.client.model.ModelRenderer;
|
||||
|
||||
public class ModelLargePipe extends ModelBase
|
||||
{
|
|
@ -1,7 +1,7 @@
|
|||
package dark.BasicUtilities.renders;
|
||||
|
||||
import net.minecraft.src.ModelBase;
|
||||
import net.minecraft.src.ModelRenderer;
|
||||
import net.minecraft.client.model.ModelBase;
|
||||
import net.minecraft.client.model.ModelRenderer;
|
||||
|
||||
public class ModelLiquidTankCorner extends ModelBase
|
||||
{
|
|
@ -1,6 +1,8 @@
|
|||
package dark.BasicUtilities.renders;
|
||||
|
||||
import net.minecraft.src.*;
|
||||
import net.minecraft.client.model.ModelBase;
|
||||
import net.minecraft.client.model.ModelRenderer;
|
||||
import net.minecraft.entity.Entity;
|
||||
|
||||
public class ModelPipe extends ModelBase
|
||||
{
|
|
@ -11,9 +11,9 @@
|
|||
|
||||
package dark.BasicUtilities.renders;
|
||||
|
||||
import net.minecraft.src.Entity;
|
||||
import net.minecraft.src.ModelBase;
|
||||
import net.minecraft.src.ModelRenderer;
|
||||
import net.minecraft.client.model.ModelBase;
|
||||
import net.minecraft.client.model.ModelRenderer;
|
||||
import net.minecraft.entity.Entity;
|
||||
|
||||
public class ModelPump extends ModelBase
|
||||
{
|
|
@ -1,7 +1,7 @@
|
|||
package dark.BasicUtilities.renders;
|
||||
|
||||
import net.minecraft.src.TileEntity;
|
||||
import net.minecraft.src.TileEntitySpecialRenderer;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
|
@ -18,7 +18,7 @@ public class RenderGearRod extends TileEntitySpecialRenderer
|
|||
}
|
||||
public void renderAModelAt(TileEntityRod tileEntity, double d, double d1, double d2, float f)
|
||||
{
|
||||
bindTextureByName(BasicUtilitiesMain.textureFile+"GearRod.png");
|
||||
bindTextureByName(BasicUtilitiesMain.textureFile+"mechanical/GearRod.png");
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef((float) d + 0.5F, (float) d1 + 1.5F, (float) d2 + 0.5F);
|
||||
GL11.glScalef(1.0F, -1F, -1F);
|
|
@ -1,7 +1,7 @@
|
|||
package dark.BasicUtilities.renders;
|
||||
|
||||
import net.minecraft.src.TileEntity;
|
||||
import net.minecraft.src.TileEntitySpecialRenderer;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
|
@ -20,7 +20,7 @@ public class RenderGenerator extends TileEntitySpecialRenderer
|
|||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity tileEntity, double d, double d1, double d2, float d3) {
|
||||
bindTextureByName(BasicUtilitiesMain.textureFile+"Generator.png");
|
||||
bindTextureByName(BasicUtilitiesMain.textureFile+"mechanical/Generator.png");
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef((float) d + 0.5F, (float) d1 + 1.5F, (float) d2 + 0.5F);
|
||||
GL11.glScalef(1.0F, -1F, -1F);
|
|
@ -1,8 +1,8 @@
|
|||
package dark.BasicUtilities.renders;
|
||||
|
||||
import net.minecraft.src.ModelBase;
|
||||
import net.minecraft.src.TileEntity;
|
||||
import net.minecraft.src.TileEntitySpecialRenderer;
|
||||
import net.minecraft.client.model.ModelBase;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
package dark.BasicUtilities.renders;
|
||||
|
||||
import net.minecraft.src.TileEntity;
|
||||
import net.minecraft.src.TileEntitySpecialRenderer;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
1
minecraft/dark/OhYesThereIsSomethingMissing.txt
Normal file
1
minecraft/dark/OhYesThereIsSomethingMissing.txt
Normal file
|
@ -0,0 +1 @@
|
|||
Yes i did leave out a bit of code called the dark Library. I will not include this in any of my githubs so good lucky downloading src and getting it too work without my permission.
|
Loading…
Reference in a new issue