more rewriting of the base mod

most of this is just continued rewrites in an attempt to better the mod.
Some of the basic changes are:
removed HeatProducer / merged it with IProducer
removed Liquid from some of the interfaces name
renamed IMehcanical to IForce
moved around files
add generator from steampower to where it should be
and finally normal ctrl+shift+f formating
This commit is contained in:
Rseifert 2012-12-02 00:30:56 -05:00
parent e70f8c52c9
commit 680203f2b6
27 changed files with 1031 additions and 531 deletions

View file

@ -3,9 +3,11 @@ 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.minecraftforge.common.Configuration;
import net.minecraftforge.oredict.ShapedOreRecipe;
import universalelectricity.core.UEConfig;
import universalelectricity.prefab.network.PacketManager;
import cpw.mods.fml.common.DummyModContainer;
@ -21,13 +23,17 @@ import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;
import dark.BasicUtilities.ItemParts.basicParts;
import dark.BasicUtilities.Items.ItemGuage;
import dark.BasicUtilities.Items.ItemParts;
import dark.BasicUtilities.Items.ItemParts.basicParts;
import dark.BasicUtilities.api.Liquid;
import dark.BasicUtilities.machines.BlockMachine;
import dark.BasicUtilities.machines.BlockValve;
import dark.BasicUtilities.machines.ItemMachine;
import dark.BasicUtilities.machines.TileEntityPump;
import dark.BasicUtilities.mechanical.BlockGenerator;
import dark.BasicUtilities.mechanical.BlockRod;
import dark.BasicUtilities.mechanical.TileEntityGen;
import dark.BasicUtilities.mechanical.TileEntityRod;
import dark.BasicUtilities.pipes.BlockPipe;
import dark.BasicUtilities.pipes.ItemPipe;
@ -61,23 +67,25 @@ public class BasicUtilitiesMain extends DummyModContainer
public final static int ITEM_ID_PREFIX = 10056;
public static Block pipe = new BlockPipe(UEConfig.getBlockConfigID(
CONFIGURATION, "block Pipe", BLOCK_ID_PREFIX)).setBlockName("pipe");
CONFIGURATION, "Pipe", BLOCK_ID_PREFIX)).setBlockName("pipe");
public static Block machine = new BlockMachine(UEConfig.getBlockConfigID(
CONFIGURATION, "machine set", BLOCK_ID_PREFIX))
.setBlockName("pump");
CONFIGURATION, "MachineSetOne", BLOCK_ID_PREFIX))
.setBlockName("Pump");
public static Block valve = new BlockValve(UEConfig.getBlockConfigID(
CONFIGURATION, "valve", BLOCK_ID_PREFIX + 2)).setBlockName("valve");
CONFIGURATION, "Valve", BLOCK_ID_PREFIX + 2)).setBlockName("valve");
public static Block rod = new BlockRod(UEConfig.getBlockConfigID(
CONFIGURATION, "mechanical rod", BLOCK_ID_PREFIX + 3));
CONFIGURATION, "MechanicalRod", BLOCK_ID_PREFIX + 3));
public static Block generator = new BlockGenerator((UEConfig.getBlockConfigID(
CONFIGURATION, "UEGenerator", BLOCK_ID_PREFIX + 4)));
public static Item parts = new ItemParts(UEConfig.getItemConfigID(
CONFIGURATION, "parts", ITEM_ID_PREFIX));
CONFIGURATION, "Parts", ITEM_ID_PREFIX));
public static Item itemPipes = new ItemPipe(UEConfig.getItemConfigID(
CONFIGURATION, "item Pipe", ITEM_ID_PREFIX + 1));
CONFIGURATION, "PipeItem", ITEM_ID_PREFIX + 1));
public static Item itemTank = new ItemTank(UEConfig.getItemConfigID(
CONFIGURATION, "item tank", ITEM_ID_PREFIX + 2));
CONFIGURATION, "TankItem", ITEM_ID_PREFIX + 2));
public static Item gauge = new ItemGuage(UEConfig.getItemConfigID(
CONFIGURATION, "guage", ITEM_ID_PREFIX + 3));
CONFIGURATION, "PipeGuage", ITEM_ID_PREFIX + 3));
// mod stuff
@SidedProxy(clientSide = "dark.BasicUtilities.BPClientProxy", serverSide = "dark.BasicUtilities.BPCommonProxy")
public static BPCommonProxy proxy;
@ -91,6 +99,7 @@ public class BasicUtilitiesMain extends DummyModContainer
proxy.preInit();
GameRegistry.registerBlock(pipe);
GameRegistry.registerBlock(rod);
GameRegistry.registerBlock(generator);
GameRegistry.registerBlock(machine, ItemMachine.class);
}
@ -99,11 +108,12 @@ public class BasicUtilitiesMain extends DummyModContainer
public void Init(FMLInitializationEvent event)
{
proxy.Init();
// register
GameRegistry.registerTileEntity(TileEntityPipe.class, "pipe");
// TileEntities
GameRegistry.registerTileEntity(TileEntityPipe.class, "Pipe");
GameRegistry.registerTileEntity(TileEntityPump.class, "pump");
GameRegistry.registerTileEntity(TileEntityRod.class, "rod");
GameRegistry.registerTileEntity(TileEntityLTank.class, "ltank");
GameRegistry.registerTileEntity(TileEntityGen.class, "WattGenerator");
// Pipe Names
for (int i = 0; i < Liquid.values().length; i++)
{
@ -135,6 +145,15 @@ public class BasicUtilitiesMain extends DummyModContainer
public void PostInit(FMLPostInitializationEvent event)
{
proxy.postInit();
CraftingManager
.getInstance()
.getRecipeList()
.add(new ShapedOreRecipe(new ItemStack(this.generator, 1),
new Object[]
{ "@T@", "OVO", "@T@", 'T',
new ItemStack(BasicUtilitiesMain.rod, 1), '@',
"plateSteel", 'O', "basicCircuit", 'V',
"motor" }));
GameRegistry.addRecipe(new ItemStack(this.gauge, 1, 0), new Object[]
{
"TVT", " T ", 'V', new ItemStack(parts, 1, 7), 'T',

View file

@ -10,6 +10,7 @@ import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
import cpw.mods.fml.client.registry.RenderingRegistry;
import dark.BasicUtilities.renders.ModelGearRod;
import dark.BasicUtilities.renders.ModelGenerator;
import dark.BasicUtilities.renders.ModelPump;
public class ItemRenderHelper implements ISimpleBlockRenderingHandler {
@ -17,6 +18,7 @@ public class ItemRenderHelper implements ISimpleBlockRenderingHandler {
public static int renderID = RenderingRegistry.getNextAvailableRenderId();
private ModelPump modelPump = new ModelPump();
private ModelGearRod modelRod = new ModelGearRod();
private ModelGenerator modelGen = new ModelGenerator();
@Override
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) {
if(block.blockID == BasicUtilitiesMain.machine.blockID && metadata < 4)
@ -24,7 +26,7 @@ public class ItemRenderHelper implements ISimpleBlockRenderingHandler {
GL11.glPushMatrix();
GL11.glTranslatef((float) 0.0F, (float)1.1F, (float)0.0F);
GL11.glRotatef(180f, 0f, 0f, 1f);
GL11.glBindTexture(GL11.GL_TEXTURE_2D, FMLClientHandler.instance().getClient().renderEngine.getTexture("/textures/pumps/Pump.png"));
GL11.glBindTexture(GL11.GL_TEXTURE_2D, FMLClientHandler.instance().getClient().renderEngine.getTexture(BasicUtilitiesMain.textureFile+"pumps/Pump.png"));
modelPump.renderMain(0.0725F);
modelPump.renderC1(0.0725F);
modelPump.renderC2(0.0725F);
@ -36,10 +38,19 @@ 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("/textures/GearRod.png"));
GL11.glBindTexture(GL11.GL_TEXTURE_2D, FMLClientHandler.instance().getClient().renderEngine.getTexture(BasicUtilitiesMain.textureFile+"GearRod.png"));
modelRod.render(0.0825F,0);
GL11.glPopMatrix();
}
if(block.blockID == BasicUtilitiesMain.generator.blockID)
{
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"));
modelGen.RenderMain(0.0725F);
GL11.glPopMatrix();
}
}
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
return false;

View file

@ -1,4 +1,4 @@
package dark.BasicUtilities;
package dark.BasicUtilities.Items;
import java.util.List;
@ -8,7 +8,8 @@ import net.minecraft.src.Item;
import net.minecraft.src.ItemStack;
import net.minecraft.src.TileEntity;
import net.minecraft.src.World;
import dark.BasicUtilities.api.IMechanical;
import dark.BasicUtilities.BasicUtilitiesMain;
import dark.BasicUtilities.api.IForce;
import dark.BasicUtilities.api.Liquid;
import dark.BasicUtilities.pipes.TileEntityPipe;
import dark.BasicUtilities.tanks.TileEntityLTank;
@ -84,9 +85,9 @@ public class ItemGuage extends Item
player.sendChatToPlayer(print);
return true;
}
if(blockEntity instanceof IMechanical)
if(blockEntity instanceof IForce)
{
IMechanical rod = (IMechanical) blockEntity;
IForce rod = (IForce) blockEntity;
int steam = rod.getForce();
int pressure = rod.getAnimationPos();
String print = "Error";

View file

@ -1,7 +1,9 @@
package dark.BasicUtilities;
package dark.BasicUtilities.Items;
import java.util.List;
import dark.BasicUtilities.BasicUtilitiesMain;
import net.minecraft.src.CreativeTabs;
import net.minecraft.src.Item;
import net.minecraft.src.ItemStack;

View file

@ -2,25 +2,29 @@ package dark.BasicUtilities.api;
import net.minecraftforge.common.ForgeDirection;
public class Beam {
//might need a more complex system for this later but for now this will work
public class Beam
{
// might need a more complex system for this later but for now this will
// work
public int intensity; // Beam intensity level
public boolean light; // Can prodcue light, might use this later
public ForgeDirection movDir; // Used to find the beams current direction
public Beam()
{
this(0, false, ForgeDirection.UNKNOWN);
}
Beam(int i, boolean light, ForgeDirection dir)
{
intensity = i;
this.light = light;
movDir = dir;
}
public static int getBeamLevel(Beam beam)
{
return beam.intensity;
}
}

View file

@ -7,7 +7,7 @@ import net.minecraftforge.common.ForgeDirection;
*
*/
public interface ILiquidConsumer
public interface IConsumer
{
/**
* onRecieveLiquid

View file

@ -0,0 +1,47 @@
package dark.BasicUtilities.api;
import net.minecraftforge.common.ForgeDirection;
// mechanical
public interface IForce
{
/**
*
* @param side
* the rpm is coming from
* @return rpm that the block is running at
*/
public int getForceSide(ForgeDirection side);
public int getForce();
/**
*
* @param side
* @return if mechanical force can be outputed from this side
*/
public boolean canOutputSide(ForgeDirection side);
/**
*
* @param side
* @return if mechanical force can be inputed from this side
*/
public boolean canInputSide(ForgeDirection side);
/**
*
* @param RPM
* being applied to this machine
* @return the rpm after the load has been applied
*/
public int applyForce(int force);
/**
* not required but is handy to get animation position of some mechanical
* block
*
* @return int between 0 -7
*/
public int getAnimationPos();
}

View file

@ -1,16 +0,0 @@
package dark.BasicUtilities.api;
import net.minecraftforge.common.ForgeDirection;
public interface IHeatProducer
{
/**
* onProduceElectricity is called when a conductor is connected to the producer block in which the conductor will demand power from the producer
* block.
* @param jouls - The maximum jouls can be transfered
* @param up - The side of block in which the conductor is on
* @return jouls - Return jouls to consumer
*/
public float onProduceHeat(float jouls, ForgeDirection up);
}

View file

@ -1,36 +0,0 @@
package dark.BasicUtilities.api;
import net.minecraftforge.common.ForgeDirection;
// mechanical
public interface IMechanical {
/**
*
* @param side the rpm is coming from
* @return rpm that the block is running at
*/
public int getForceSide(ForgeDirection side);
public int getForce();
/**
*
* @param side
* @return if mechanical force can be outputed from this side
*/
public boolean canOutputSide(ForgeDirection side);
/**
*
* @param side
* @return if mechanical force can be inputed from this side
*/
public boolean canInputSide(ForgeDirection side);
/**
*
* @param RPM being applied to this machine
* @return the rpm after the load has been applied
*/
public int applyForce(int force);
/**
* not required but is handy to get animation position of some mechanical block
* @return int between 0 -7
*/
public int getAnimationPos();
}

View file

@ -7,7 +7,7 @@ import net.minecraftforge.common.ForgeDirection;
* @author DarkGuardsman
*
*/
public interface ILiquidProducer
public interface IProducer
{
/**
* onProduceLiquid

View file

@ -1,5 +1,5 @@
package dark.BasicUtilities.api;
public interface IStorageTank extends ILiquidConsumer {
public interface IStorageTank extends IConsumer {
}

View file

@ -1,63 +1,69 @@
package dark.BasicUtilities.api;
import net.minecraft.src.Block;
/**
* System too easily reference a liquid type and its info
*
* @author Rseifert
*
*/
public enum Liquid {
public enum Liquid
{
// -1 == null || unused
STEAM("Steam",false,true,-1,-1,100),
WATER("Water",false,false,Block.waterStill.blockID,Block.waterMoving.blockID,32),
LAVA("Lava",false,false,Block.lavaStill.blockID,Block.lavaMoving.blockID,20),
OIL("Oil",true,false,-1,-1,32),//BasicComponents.oilStill.blockID,BasicComponents.oilMoving.blockID),
Fuel("Fuel",true,false,-1,-1,40),
Air("Air",false,true,0,-1,100),
Methain("Methain",true,true,-1,-1,100),
BioFuel("BioFuel",true,false,-1,-1,40),
Coolent("Coolent",false,false,-1,-1,40),
NukeWaste("NukeWaste",false,false,-1,-1,20),
Ether("Ether",false,false,-1,-1,100),
DEFUALT("Empty",false,false,-1,-1,0);
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 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,int block, int Moving,int dPressure)
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
* 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];
}
if (id >= 0 && id < Liquid.values().length) { return Liquid.values()[id]; }
return DEFUALT;
}
public static Liquid getLiquidByBlock(int bBlock) {
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;
}
if (bBlock == selected.Still) { return selected; }
}
return Liquid.DEFUALT;
}

View file

@ -4,16 +4,21 @@ import net.minecraft.src.TileEntity;
import net.minecraft.src.World;
import net.minecraftforge.common.ForgeDirection;
public class MHelper {
public class MHelper
{
/**
* you will have to tell your TileEntity to trade up if liquid or down if gas. I suggest having your onRecieveLiquid
* pump liquid one block up if you block is full.
* @param entity - entity at center of search
* @return an Array containing TileEntities around the TileEntity
* Used to find all tileEntities sounding the location
* you will have to filter for select tileEntities
* @param world - the world being searched threw
* @param x
* @param y
* @param z
* @return an array of up to 6 tileEntities
*/
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);
@ -25,12 +30,21 @@ public class MHelper {
}
return list;
}
/**
* Used to help trade liquid without having to do too much work
* @param blockEntity - tile entity trading the liquid
* @param type - liquid type being traded
* @param vol - the volume to be traded
* @return the remaining untraded liquid
* will not trade to one side due to glitches, you will have
* to trade to this side using another method.
*
* @param blockEntity
* - tile entity trading the liquid
* @param type
* - liquid type being traded
* @param vol
* - the volume to be traded
* @param max
* - max volume the tank can hold
* @return the remaining liquid that was not traded away
*/
public static int shareLiquid(World world, int x, int y, int z, int vol, int max, Liquid type)
{
@ -39,18 +53,14 @@ public class MHelper {
int tCount = 1;
boolean rise = type.isGas;
if(currentVol <= 0)
{
return 0;
}
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 = ((ILiquidConsumer) first).onReceiveLiquid(type, currentVol, st);
currentVol = ((IConsumer) first).onReceiveLiquid(type, currentVol, st);
}
int vAve = currentVol;
TileEntity[] TeA = MHelper.getSourounding(world, x, y, z);
@ -75,49 +85,27 @@ public class MHelper {
if (sSide instanceof IStorageTank && ((IStorageTank) sSide).getStoredLiquid(type) < vAve)
{
int tA = vAve - Math.max((vAve - currentVol), 0);
currentVol = ((ILiquidConsumer) sSide).onReceiveLiquid(type, tA, st) -tA + currentVol;
currentVol = ((IConsumer) sSide).onReceiveLiquid(type, tA, st) - tA + currentVol;
}
}
//trades to the opposite of the first if anything is left
/**
* need to find a way to solve it just trading back the ammount on next cycle
if(currentVol > 0)
{
TileEntity last = world.getBlockTileEntity(x+st.getOpposite().offsetX, y+st.getOpposite().offsetY, z+st.getOpposite().offsetZ);
if(last instanceof IStorageTank && currentVol == max)
{
currentVol = ((ILiquidConsumer) last).onReceiveLiquid(type, max/10, st.getOpposite()) + currentVol -(max/10);
}
}
*/
return Math.max(currentVol, 0);
}
/**
*
* @param entity - entity in question
* @return 1-4 if corner 0 if not a corner
* you have to figure out which is which depending on what your using this for
* 1 should be north east 2 south east
* @param entity
* - entity in question
* @return 1-4 if corner 0 if not a corner you have to figure out which is
* which depending on what your using this for 1 should be north
* east 2 south east
*/
public static int corner(TileEntity entity)
{
TileEntity[] en = getSourounding(entity.worldObj, entity.xCoord, entity.yCoord, entity.zCoord);
if(en[4] != null && en[2] != null && en[5] == null && en[3] == null)
{
return 3;
}
if(en[2] != null && en[5] != null && en[3] == null && en[4] == null)
{
return 4;
}
if(en[5] != null && en[3] != null && en[4] == null && en[2] == null)
{
return 1;
}
if(en[3] != null && en[4] != null && en[2] == null && en[5] == null)
{
return 2;
}
if (en[4] != null && en[2] != null && en[5] == null && en[3] == null) { return 3; }
if (en[2] != null && en[5] != null && en[3] == null && en[4] == null) { return 4; }
if (en[5] != null && en[3] != null && en[4] == null && en[2] == null) { return 1; }
if (en[3] != null && en[4] != null && en[2] == null && en[5] == null) { return 2; }
return 0;

View file

@ -3,11 +3,11 @@ package dark.BasicUtilities.machines;
import net.minecraft.src.NBTTagCompound;
import net.minecraft.src.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import universalelectricity.implement.IElectricityReceiver;
import dark.BasicUtilities.api.ILiquidProducer;
import universalelectricity.core.implement.IElectricityReceiver;
import dark.BasicUtilities.api.IProducer;
import dark.BasicUtilities.api.Liquid;
public class TileEntityCondenser extends TileEntity implements ILiquidProducer, IElectricityReceiver {
public class TileEntityCondenser extends TileEntity implements IProducer, IElectricityReceiver {
int tickCount = 0;
int waterStored = 0;
int energyStored = 0;
@ -98,8 +98,8 @@ public class TileEntityCondenser extends TileEntity implements ILiquidProducer,
return 120;
}
@Override
public void onReceive(TileEntity sender, double amps, double voltage,
ForgeDirection side) {
public void onReceive(Object sender, double amps, double voltage, ForgeDirection side)
{
// TODO Auto-generated method stub
}

View file

@ -1,7 +1,5 @@
package dark.BasicUtilities.machines;
import com.google.common.io.ByteArrayDataInput;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.INetworkManager;
import net.minecraft.src.NBTTagCompound;
@ -9,17 +7,20 @@ import net.minecraft.src.Packet;
import net.minecraft.src.Packet250CustomPayload;
import net.minecraft.src.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import universalelectricity.core.Vector3;
import universalelectricity.implement.IElectricityReceiver;
import universalelectricity.prefab.TileEntityElectricityReceiver;
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.ILiquidProducer;
import dark.BasicUtilities.api.IProducer;
import dark.BasicUtilities.api.Liquid;
import dark.BasicUtilities.api.MHelper;
public class TileEntityPump extends TileEntityElectricityReceiver implements ILiquidProducer, IElectricityReceiver, IPacketReceiver
public class TileEntityPump extends TileEntityElectricityReceiver implements IProducer, IElectricityReceiver, IPacketReceiver
{
int dCount = 0;
float eStored = 0;
@ -181,10 +182,11 @@ public class TileEntityPump extends TileEntityElectricityReceiver implements ILi
}
@Override
public void onReceive(TileEntity sender, double watts, double voltage, ForgeDirection side)
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);
}

View file

@ -2,12 +2,12 @@ package dark.BasicUtilities.machines;
import net.minecraft.src.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import dark.BasicUtilities.api.ILiquidConsumer;
import dark.BasicUtilities.api.IConsumer;
import dark.BasicUtilities.api.Liquid;
import dark.BasicUtilities.api.MHelper;
import dark.BasicUtilities.pipes.TileEntityPipe;
public class TileEntityValve extends TileEntity implements ILiquidConsumer {
public class TileEntityValve extends TileEntity implements IConsumer {
Liquid type = Liquid.DEFUALT;
int liquidStored = 0;
int lMax = 1;

View file

@ -0,0 +1,69 @@
package dark.BasicUtilities.mechanical;
import java.util.ArrayList;
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) {
super("Generator", id, Material.iron);
this.setCreativeTab(CreativeTabs.tabBlock);
}
@Override
public void addCreativeItems(ArrayList itemList) {
itemList.add(new ItemStack(this, 1, 0));
}
@Override
public void onBlockPlacedBy(World world, int x, int y, int z,
EntityLiving par5EntityLiving) {
int angle = MathHelper
.floor_double((par5EntityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
world.setBlockAndMetadataWithUpdate(x, y, z, blockID, angle, true);
}
@Override
public boolean onUseWrench(World par1World, int x, int y, int z,
EntityPlayer par5EntityPlayer) {
int angle = MathHelper
.floor_double((par5EntityPlayer.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
int metadata = par1World.getBlockMetadata(x, y, z);
if (metadata < 3) {
par1World.setBlockAndMetadata(x, y, z, blockID, metadata + angle);
} else {
par1World.setBlockAndMetadata(x, y, z, blockID, 0);
}
return true;
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public int getRenderType() {
return ItemRenderHelper.renderID;
}
@Override
public TileEntity createNewTileEntity(World world) {
return new TileEntityGen();
}
}

View file

@ -0,0 +1,227 @@
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.Library.Util.MetaData;
import dark.Library.prefab.TileEntityMachine;
public class TileEntityGen extends TileEntityMachine implements IPacketReceiver, IForce, IElectricityProducer
{
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(MetaData.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;
}
}

View file

@ -6,16 +6,16 @@ import net.minecraft.src.Packet;
import net.minecraft.src.Packet250CustomPayload;
import net.minecraft.src.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import universalelectricity.core.Vector3;
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.IMechanical;
import dark.BasicUtilities.api.IForce;
public class TileEntityRod extends TileEntity implements IPacketReceiver,IMechanical {
public class TileEntityRod extends TileEntity implements IPacketReceiver,IForce {
public int pos = 0;
private int force = 0;
@ -51,23 +51,23 @@ public class TileEntityRod extends TileEntity implements IPacketReceiver,IMechan
}
if(bb instanceof TileEntityRod)
{
this.pos = ((IMechanical)bb).getAnimationPos();
this.pos = ((IForce)bb).getAnimationPos();
}
if(!worldObj.isRemote)
{
if(ff instanceof IMechanical)
if(ff instanceof IForce)
{
if(((IMechanical) ff).canInputSide(backDir))
if(((IForce) ff).canInputSide(backDir))
{
((IMechanical) ff).applyForce(aForce);
((IForce) ff).applyForce(aForce);
}
}
if(bb instanceof IMechanical)
if(bb instanceof IForce)
{
if(((IMechanical) bb).canOutputSide(frontDir))
if(((IForce) bb).canOutputSide(frontDir))
{
this.force = ((IMechanical) bb).getForce();
this.force = ((IForce) bb).getForce();
}
}else
{

View file

@ -2,14 +2,13 @@ package dark.BasicUtilities.pipes;
import java.util.Random;
import dark.BasicUtilities.BasicUtilitiesMain;
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 dark.BasicUtilities.BasicUtilitiesMain;
public class BlockPipe extends BlockContainer
{
@ -44,7 +43,7 @@ public class BlockPipe extends BlockContainer
public boolean canPlaceBlockAt(World par1World, int par2, int par3, int par4)
{
int var5 = par1World.getBlockId(par2, par3, par4);
return var5 == 0 || blocksList[var5].blockMaterial.isGroundCover();
return var5 == 0 || blocksList[var5].blockMaterial.isReplaceable();
}
@Override
public boolean canPlaceBlockOnSide(World par1World, int par2, int par3, int par4, int par5)

View file

@ -26,33 +26,43 @@ public class ItemPipe extends Item
this.setItemName("pipe");
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 + " 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() {
}
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)
{
@ -124,5 +134,4 @@ public class ItemPipe extends Item
return false;
}
}

View file

@ -7,19 +7,19 @@ import net.minecraft.src.Packet;
import net.minecraft.src.Packet250CustomPayload;
import net.minecraft.src.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import universalelectricity.core.Vector3;
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.ILiquidConsumer;
import dark.BasicUtilities.api.ILiquidProducer;
import dark.BasicUtilities.api.IConsumer;
import dark.BasicUtilities.api.IProducer;
import dark.BasicUtilities.api.Liquid;
import dark.BasicUtilities.api.MHelper;
public class TileEntityPipe extends TileEntity implements ILiquidConsumer, IPacketReceiver
public class TileEntityPipe extends TileEntity implements IConsumer, IPacketReceiver
{
protected Liquid type = Liquid.DEFUALT;
@ -64,26 +64,26 @@ public class TileEntityPipe extends TileEntity implements ILiquidConsumer, IPack
ForgeDirection dir = ForgeDirection.getOrientation(i);
if (connectedBlocks[i] instanceof ILiquidProducer)
if (connectedBlocks[i] instanceof IProducer)
{
int vol = ((ILiquidProducer) connectedBlocks[i]).onProduceLiquid(this.type, this.capacity - this.liquidStored, dir);
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 ILiquidConsumer && this.liquidStored > 0 && this.presure > 0)
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 = ((ILiquidConsumer) connectedBlocks[i]).onReceiveLiquid(this.type, Math.max(this.liquidStored, 1), dir);
int vol = ((IConsumer) connectedBlocks[i]).onReceiveLiquid(this.type, Math.max(this.liquidStored, 1), dir);
this.liquidStored += vol;
}
}
else
{
this.liquidStored = ((ILiquidConsumer) connectedBlocks[i]).onReceiveLiquid(this.type, this.liquidStored, dir);
this.liquidStored = ((IConsumer) connectedBlocks[i]).onReceiveLiquid(this.type, this.liquidStored, dir);
}
}
}
@ -107,7 +107,7 @@ public class TileEntityPipe extends TileEntity implements ILiquidConsumer, IPack
{
ForgeDirection dir = ForgeDirection.getOrientation(i);
if (connectedBlocks[i] instanceof ILiquidConsumer && ((ILiquidConsumer) connectedBlocks[i]).canRecieveLiquid(this.type, dir))
if (connectedBlocks[i] instanceof IConsumer && ((IConsumer) connectedBlocks[i]).canRecieveLiquid(this.type, dir))
{
this.connectedUnits++;
if (connectedBlocks[i] instanceof TileEntityPipe)
@ -118,12 +118,12 @@ public class TileEntityPipe extends TileEntity implements ILiquidConsumer, IPack
}
}
}
else if (connectedBlocks[i] instanceof ILiquidProducer && ((ILiquidProducer) connectedBlocks[i]).canProduceLiquid(this.type, dir))
else if (connectedBlocks[i] instanceof IProducer && ((IProducer) connectedBlocks[i]).canProduceLiquid(this.type, dir))
{
this.connectedUnits++;
if (((ILiquidProducer) connectedBlocks[i]).canProducePresure(this.type, dir) && ((ILiquidProducer) connectedBlocks[i]).presureOutput(this.type, dir) > highestPressure)
if (((IProducer) connectedBlocks[i]).canProducePresure(this.type, dir) && ((IProducer) connectedBlocks[i]).presureOutput(this.type, dir) > highestPressure)
{
highestPressure = ((ILiquidProducer) connectedBlocks[i]).presureOutput(this.type, dir);
highestPressure = ((IProducer) connectedBlocks[i]).presureOutput(this.type, dir);
}
}
else

View file

@ -0,0 +1,131 @@
// Date: 8/27/2012 3:20:21 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.Entity;
import net.minecraft.src.ModelBase;
import net.minecraft.src.ModelRenderer;
public class ModelGenerator extends ModelBase
{
//fields
ModelRenderer BasePlate;
ModelRenderer LeftConnection;
ModelRenderer RightConnection;
ModelRenderer Mid;
ModelRenderer Mid2;
ModelRenderer front;
ModelRenderer front2;
ModelRenderer front3;
ModelRenderer Mid3;
ModelRenderer FrontConnector;
public ModelGenerator()
{
textureWidth = 128;
textureHeight = 128;
BasePlate = new ModelRenderer(this, 0, 0);
BasePlate.addBox(-7F, 0F, -7F, 14, 1, 14);
BasePlate.setRotationPoint(0F, 23F, 0F);
BasePlate.setTextureSize(128, 128);
BasePlate.mirror = true;
setRotation(BasePlate, 0F, 0F, 0F);
LeftConnection = new ModelRenderer(this, 0, 112);
LeftConnection.addBox(-2F, -2F, -2F, 2, 4, 4);
LeftConnection.setRotationPoint(-6F, 16F, 0F);
LeftConnection.setTextureSize(128, 128);
LeftConnection.mirror = true;
setRotation(LeftConnection, 0F, 0F, 0F);
RightConnection = new ModelRenderer(this, 12, 112);
RightConnection.addBox(0F, -2F, -2F, 2, 4, 4);
RightConnection.setRotationPoint(6F, 16F, 0F);
RightConnection.setTextureSize(128, 128);
RightConnection.mirror = true;
setRotation(RightConnection, 0F, 0F, 0F);
Mid = new ModelRenderer(this, 0, 29);
Mid.addBox(-4F, 0F, -6F, 8, 12, 12);
Mid.setRotationPoint(0F, 10F, 0F);
Mid.setTextureSize(128, 128);
Mid.mirror = true;
setRotation(Mid, 0F, 0F, 0F);
Mid2 = new ModelRenderer(this, 0, 53);
Mid2.addBox(-6F, 0F, -6F, 12, 8, 12);
Mid2.setRotationPoint(0F, 12F, 0F);
Mid2.setTextureSize(128, 128);
Mid2.mirror = true;
setRotation(Mid2, 0F, 0F, 0F);
front = new ModelRenderer(this, 20, 15);
front.addBox(-2F, -4F, 0F, 4, 8, 1);
front.setRotationPoint(0F, 16F, -7F);
front.setTextureSize(128, 128);
front.mirror = true;
setRotation(front, 0F, 0F, 0F);
front2 = new ModelRenderer(this, 0, 24);
front2.addBox(-4F, -2F, 0F, 8, 4, 1);
front2.setRotationPoint(0F, 16F, -7F);
front2.setTextureSize(128, 128);
front2.mirror = true;
setRotation(front2, 0F, 0F, 0F);
front3 = new ModelRenderer(this, 0, 16);
front3.addBox(-3F, -3F, 0F, 6, 6, 1);
front3.setRotationPoint(0F, 16F, -7F);
front3.setTextureSize(128, 128);
front3.mirror = true;
setRotation(front3, 0F, 0F, 0F);
Mid3 = new ModelRenderer(this, 40, 29);
Mid3.addBox(-5F, -1F, -6F, 10, 10, 12);
Mid3.setRotationPoint(0F, 12F, 0F);
Mid3.setTextureSize(128, 128);
Mid3.mirror = true;
setRotation(Mid3, 0F, 0F, 0F);
FrontConnector = new ModelRenderer(this, 0, 120);
FrontConnector.addBox(-2F, 0F, -2F, 4, 4, 4);
FrontConnector.setRotationPoint(0F, 14F, -6F);
FrontConnector.setTextureSize(128, 128);
FrontConnector.mirror = true;
setRotation(FrontConnector, 0F, 0F, 0F);
}
public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5)
{
super.render(entity, f, f1, f2, f3, f4, f5);
setRotationAngles(f, f1, f2, f3, f4, f5, entity);
}
public void RenderMain(float f5)
{
BasePlate.render(f5);
Mid.render(f5);
Mid2.render(f5);
front.render(f5);
front2.render(f5);
front3.render(f5);
Mid3.render(f5);
FrontConnector.render(f5);
}
public void RenderLeft(float f5)
{
LeftConnection.render(f5);
}
public void RenderRight(float f5)
{
RightConnection.render(f5);
}
private void setRotation(ModelRenderer model, float x, float y, float z)
{
model.rotateAngleX = x;
model.rotateAngleY = y;
model.rotateAngleZ = z;
}
}

View file

@ -5,6 +5,7 @@ import net.minecraft.src.TileEntitySpecialRenderer;
import org.lwjgl.opengl.GL11;
import dark.BasicUtilities.BasicUtilitiesMain;
import dark.BasicUtilities.mechanical.TileEntityRod;
@ -17,7 +18,7 @@ public class RenderGearRod extends TileEntitySpecialRenderer
}
public void renderAModelAt(TileEntityRod tileEntity, double d, double d1, double d2, float f)
{
bindTextureByName("/textures/GearRod.png");
bindTextureByName(BasicUtilitiesMain.textureFile+"GearRod.png");
GL11.glPushMatrix();
GL11.glTranslatef((float) d + 0.5F, (float) d1 + 1.5F, (float) d2 + 0.5F);
GL11.glScalef(1.0F, -1F, -1F);

View file

@ -0,0 +1,39 @@
package dark.BasicUtilities.renders;
import net.minecraft.src.TileEntity;
import net.minecraft.src.TileEntitySpecialRenderer;
import org.lwjgl.opengl.GL11;
import dark.BasicUtilities.BasicUtilitiesMain;
public class RenderGenerator extends TileEntitySpecialRenderer
{
int type = 0;
private ModelGenerator model;
public RenderGenerator()
{
model = new ModelGenerator();
}
@Override
public void renderTileEntityAt(TileEntity tileEntity, double d, double d1, double d2, float d3) {
bindTextureByName(BasicUtilitiesMain.textureFile+"Generator.png");
GL11.glPushMatrix();
GL11.glTranslatef((float) d + 0.5F, (float) d1 + 1.5F, (float) d2 + 0.5F);
GL11.glScalef(1.0F, -1F, -1F);
int meta = tileEntity.worldObj.getBlockMetadata(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord);
switch(meta)
{
case 0:GL11.glRotatef(0f, 0f, 1f, 0f);break;
case 1:GL11.glRotatef(90f, 0f, 1f, 0f);break;
case 2:GL11.glRotatef(180f, 0f, 1f, 0f);break;
case 3:GL11.glRotatef(270f, 0f, 1f, 0f);break;
}
model.RenderMain(0.0625F);
GL11.glPopMatrix();
}
}

View file

@ -26,33 +26,43 @@ public class ItemTank extends Item
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() {
}
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)
{
@ -124,5 +134,4 @@ public class ItemTank extends Item
return false;
}
}

View file

@ -7,20 +7,22 @@ import net.minecraft.src.Packet;
import net.minecraft.src.Packet250CustomPayload;
import net.minecraft.src.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import universalelectricity.core.Vector3;
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.ILiquidProducer;
import dark.BasicUtilities.api.IProducer;
import dark.BasicUtilities.api.IStorageTank;
import dark.BasicUtilities.api.Liquid;
import dark.BasicUtilities.api.MHelper;
public class TileEntityLTank extends TileEntity implements IStorageTank,ILiquidProducer,IPacketReceiver{
public TileEntity[] cc = {null,null,null,null,null,null};
public class TileEntityLTank extends TileEntity implements IStorageTank, IProducer, IPacketReceiver
{
public TileEntity[] cc =
{ null, null, null, null, null, null };
public Liquid type = Liquid.DEFUALT;
public int LStored = 0;
public int pLStored = 0;
@ -28,6 +30,7 @@ public int LMax = 4;
private int count = 0;
private int count2 = 0;
private boolean firstUpdate = true;
public void updateEntity()
{
if (++count >= 5)
@ -41,13 +44,15 @@ public void updateEntity()
{
count2 = 0;
firstUpdate = false;
Packet packet = PacketManager.getPacket(BasicUtilitiesMain.CHANNEL, this, new Object[]{type.ordinal(),LStored});
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);
@ -77,67 +82,59 @@ public int onReceiveLiquid(Liquid type, int vol, ForgeDirection side)
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
}
else
{
TileEntity te = null;
if (this.type.isGas)
{
worldObj.getBlockTileEntity(xCoord, yCoord + 1, zCoord);
}else
}
else
{
worldObj.getBlockTileEntity(xCoord, yCoord - 1, zCoord);
}
if( te instanceof IStorageTank)
{
return ((IStorageTank)te).onReceiveLiquid(type, vol, ForgeDirection.UNKNOWN);
}
if (te instanceof IStorageTank) { return ((IStorageTank) te).onReceiveLiquid(type, vol, ForgeDirection.UNKNOWN); }
}
}
return vol;
}
@Override
public boolean canRecieveLiquid(Liquid type, ForgeDirection side) {
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;
}
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)
public int getStoredLiquid(Liquid type)
{
return LStored;
}
if (type == this.type) { return LStored; }
return 0;
}
@Override
public int getLiquidCapacity(Liquid type) {
if(type == this.type)
public int getLiquidCapacity(Liquid type)
{
return LMax;
}
if (type == this.type) { return LMax; }
return 0;
}
public Liquid getType() {
public Liquid getType()
{
// TODO Auto-generated method stub
return type;
}
@Override
public int onProduceLiquid(Liquid type, int vol, ForgeDirection side) {
public int onProduceLiquid(Liquid type, int vol, ForgeDirection side)
{
if (type == this.type && this.LStored > 1 && vol > 0)
{
// TODO correct / do math for
@ -148,63 +145,54 @@ public int onProduceLiquid(Liquid type, int vol, ForgeDirection side) {
}
@Override
public boolean canProduceLiquid(Liquid type, ForgeDirection side) {
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;
}
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) {
public boolean canProducePresure(Liquid type, ForgeDirection side)
{
if (type == this.type)
{
if(this.type.isGas && side == ForgeDirection.DOWN)
{
return true;
}
if(!this.type.isGas && side == ForgeDirection.UP)
{
return true;
}
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)
public int presureOutput(Liquid type, ForgeDirection side)
{
return this.type.defaultPresure;
}
if (type == this.type) { return this.type.defaultPresure; }
return 0;
}
@Override
public void handlePacketData(INetworkManager network, int packetType,
Packet250CustomPayload packet, EntityPlayer player,
ByteArrayDataInput data) {
ByteArrayDataInput data)
{
try
{
this.type = Liquid.getLiquid(data.readInt());
this.LStored = data.readInt();
}catch(Exception e)
}
catch (Exception e)
{
e.printStackTrace();
System.out.print("Fail reading data for Storage tank \n");
}
}
public void setType(Liquid dm) {
public void setType(Liquid dm)
{
this.type = dm;
}