Seperated pipes from mods
Seperated pipes and there related files from steam power in order to make it it's own mod. Too do so a lot of classes where edited to fit the new API. Though the code has bugs that still need fixed. Main bug: pipe only transfer if the consumer falls under the pipes max volume.
This commit is contained in:
parent
cd3ee4e4c8
commit
e3f5753b0e
18 changed files with 1202 additions and 160 deletions
|
@ -4,8 +4,6 @@ import java.util.ArrayList;
|
|||
import java.util.Random;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.src.*;
|
||||
import net.minecraft.src.eui.api.ISteamConsumer;
|
||||
import net.minecraft.src.eui.api.ISteamProducer;
|
||||
import net.minecraft.src.eui.boiler.*;
|
||||
import net.minecraft.src.eui.burner.GUIFireBox;
|
||||
import net.minecraft.src.eui.burner.TileEntityFireBox;
|
||||
|
|
|
@ -10,20 +10,17 @@ public class ItemMachine extends ItemBlock {
|
|||
setMaxDamage(0);
|
||||
setHasSubtypes(true);
|
||||
}
|
||||
@Override
|
||||
public int getMetadata(int metadata)
|
||||
{
|
||||
return metadata;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemName()
|
||||
{
|
||||
return "Machine";
|
||||
}
|
||||
|
||||
public int getPlacedBlockMetadata(int damage) {
|
||||
return damage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemNameIS(ItemStack par1ItemStack)
|
||||
{
|
||||
int var3 = par1ItemStack.getItemDamage();
|
||||
|
@ -37,6 +34,7 @@ public class ItemMachine extends ItemBlock {
|
|||
}
|
||||
return this.getItemName();
|
||||
}
|
||||
@Override
|
||||
public void addCreativeItems(ArrayList itemList) {
|
||||
|
||||
itemList.add(new ItemStack(this, 1,0));
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
package net.minecraft.src.eui;
|
||||
|
||||
import net.minecraft.src.NBTTagCompound;
|
||||
import net.minecraft.src.eui.api.IWaterProducer;
|
||||
import net.minecraft.src.eui.pipes.api.ILiquidProducer;
|
||||
import net.minecraft.src.universalelectricity.UEIConsumer;
|
||||
|
||||
public class TileEntityCondenser extends TileEntityMachine implements IWaterProducer,UEIConsumer {
|
||||
public class TileEntityCondenser extends TileEntityMachine implements ILiquidProducer,UEIConsumer {
|
||||
int tickCount = 0;
|
||||
int waterStored = 0;
|
||||
int energyStored = 0;
|
||||
@Override
|
||||
public int onProduceWater(int maxVol, int side) {
|
||||
if( maxVol > 0)
|
||||
public int onProduceLiquid(int type,int maxVol, int side) {
|
||||
/**if(type == 1)
|
||||
{
|
||||
int tradeW = Math.min(maxVol, waterStored);
|
||||
waterStored -= tradeW;
|
||||
return tradeW;
|
||||
}
|
||||
return 0;
|
||||
}**/
|
||||
return 5;
|
||||
}
|
||||
public void writeToNBT(NBTTagCompound par1NBTTagCompound)
|
||||
{
|
||||
|
@ -41,12 +41,6 @@ public class TileEntityCondenser extends TileEntityMachine implements IWaterProd
|
|||
}
|
||||
tickCount++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProduceWater(byte side) {
|
||||
// TODO Auto-generated method stub
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public int onReceiveElectricity(int watts, int voltage, byte side) {
|
||||
int rejectedElectricity = Math.max((this.waterStored + watts) - this.getElectricityCapacity(), 0);
|
||||
|
@ -83,6 +77,14 @@ public class TileEntityCondenser extends TileEntityMachine implements IWaterProd
|
|||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean canProduceLiquid(int type, byte side) {
|
||||
if(type == 1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ public class GuiBoiler extends GuiContainer
|
|||
int var10;
|
||||
if (this.boilerInventory.waterStored > 0)
|
||||
{
|
||||
var7 = boilerInventory.getStoredWater()*4 + 1;
|
||||
var7 = boilerInventory.getStoredLiquid(1)*4 + 1;
|
||||
this.drawTexturedModalRect(var5 + 29, var6 + 72 - var7, 176, 148 - var7, 23, var7);
|
||||
}
|
||||
if (this.boilerInventory.steamStored > 0)
|
||||
|
|
|
@ -4,12 +4,13 @@ import net.minecraft.src.eui.BlockMachine;
|
|||
import net.minecraft.src.eui.TileEntityMachine;
|
||||
import net.minecraft.src.eui.api.*;
|
||||
import net.minecraft.src.eui.burner.TileEntityFireBox;
|
||||
import net.minecraft.src.eui.steam.TileEntityPipe;
|
||||
import net.minecraft.src.eui.pipes.api.ILiquidConsumer;
|
||||
import net.minecraft.src.eui.pipes.api.ILiquidProducer;
|
||||
import net.minecraft.src.forge.ForgeHooks;
|
||||
import net.minecraft.src.forge.ISidedInventory;
|
||||
import net.minecraft.src.universalelectricity.UniversalElectricity;
|
||||
|
||||
public class TileEntityBoiler extends TileEntityMachine implements IInventory, ISidedInventory,ISteamProducer, IWaterConsumer
|
||||
public class TileEntityBoiler extends TileEntityMachine implements IInventory, ISidedInventory,ILiquidProducer, ILiquidConsumer
|
||||
{
|
||||
|
||||
/**
|
||||
|
@ -372,7 +373,7 @@ public class TileEntityBoiler extends TileEntityMachine implements IInventory, I
|
|||
boolean canTradeWater;
|
||||
if( i ==1)
|
||||
{
|
||||
if(this.waterStored == this.getWaterCapacity())
|
||||
if(this.waterStored == this.getLiquidCapacity(1))
|
||||
{
|
||||
canTradeWater = true;
|
||||
}
|
||||
|
@ -388,11 +389,11 @@ public class TileEntityBoiler extends TileEntityMachine implements IInventory, I
|
|||
if(canTradeWater)
|
||||
{
|
||||
int WSum = (this.waterStored + connectedConsumer.waterStored)/2;
|
||||
if(i == 0 && this.waterStored > 0 && connectedConsumer.waterStored < connectedConsumer.getWaterCapacity())
|
||||
if(i == 0 && this.waterStored > 0 && connectedConsumer.waterStored < connectedConsumer.getLiquidCapacity(1))
|
||||
{
|
||||
|
||||
int rejectedW = connectedConsumer.addwater(1);
|
||||
this.waterStored = Math.max(Math.min(this.waterStored - 1 + rejectedW, this.getWaterCapacity()), 0);
|
||||
this.waterStored = Math.max(Math.min(this.waterStored - 1 + rejectedW, this.getLiquidCapacity(1)), 0);
|
||||
}
|
||||
if(this.waterStored > connectedConsumer.waterStored)
|
||||
{
|
||||
|
@ -400,7 +401,7 @@ public class TileEntityBoiler extends TileEntityMachine implements IInventory, I
|
|||
if(transferW > 0)
|
||||
{
|
||||
int rejectedW = connectedConsumer.addwater(transferW);
|
||||
this.waterStored = Math.max(Math.min(this.waterStored - transferW + rejectedW, this.getWaterCapacity()), 0);
|
||||
this.waterStored = Math.max(Math.min(this.waterStored - transferW + rejectedW, this.getLiquidCapacity(1)), 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -479,7 +480,7 @@ public class TileEntityBoiler extends TileEntityMachine implements IInventory, I
|
|||
return rejectedElectricity;
|
||||
}
|
||||
public int addwater(int watt) {
|
||||
int rejectedElectricity = Math.max((this.waterStored + watt) - this.getWaterCapacity(), 0);
|
||||
int rejectedElectricity = Math.max((this.waterStored + watt) - this.getLiquidCapacity(1), 0);
|
||||
this.waterStored += watt - rejectedElectricity;
|
||||
return rejectedElectricity;
|
||||
}
|
||||
|
@ -500,7 +501,7 @@ public class TileEntityBoiler extends TileEntityMachine implements IInventory, I
|
|||
{
|
||||
if(this.furnaceItemStacks[0].isItemEqual(new ItemStack(Item.bucketWater,1)))
|
||||
{
|
||||
if((int)waterStored < getWaterCapacity())
|
||||
if((int)waterStored < getLiquidCapacity(1))
|
||||
{
|
||||
++waterStored;
|
||||
this.furnaceItemStacks[0] = new ItemStack(Item.bucketEmpty,1);
|
||||
|
@ -536,28 +537,6 @@ public class TileEntityBoiler extends TileEntityMachine implements IInventory, I
|
|||
{
|
||||
return 1;
|
||||
}
|
||||
@Override
|
||||
public int onReceiveWater(int vol, byte side) {
|
||||
|
||||
if(waterStored + vol < getWaterCapacity()){
|
||||
waterStored = waterStored + (int)vol;
|
||||
return 0;
|
||||
}
|
||||
return vol;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStoredWater() {
|
||||
|
||||
return this.waterStored;
|
||||
|
||||
}
|
||||
@Override
|
||||
public int getWaterCapacity() {
|
||||
return 14;
|
||||
}
|
||||
|
||||
public int precentHeated() {
|
||||
int var1;
|
||||
if(hullHeat < 100)
|
||||
|
@ -570,32 +549,70 @@ public class TileEntityBoiler extends TileEntityMachine implements IInventory, I
|
|||
}
|
||||
return var1;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean canRecieveWater(byte side) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int onProduceSteam(float maxVol, int side) {
|
||||
|
||||
if(steamStored > 0)
|
||||
public int onReceiveLiquid(int type, int vol, byte side) {
|
||||
if(type == 1)
|
||||
{
|
||||
--steamStored;
|
||||
return 1;
|
||||
int rejectedElectricity = Math.max((this.waterStored + vol) - 14, 0);
|
||||
this.waterStored = vol - rejectedElectricity;
|
||||
return rejectedElectricity;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
return vol;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProduceSteam(byte side) {
|
||||
public boolean canRecieveLiquid(int type, byte side) {
|
||||
if(type == 1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
@Override
|
||||
public int getStoredLiquid(int type) {
|
||||
if(type == 1)
|
||||
{
|
||||
return this.waterStored;
|
||||
}
|
||||
if(type == 0)
|
||||
{
|
||||
return this.steamStored;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLiquidCapacity(int type) {
|
||||
if(type ==1)
|
||||
{
|
||||
return 14;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public int onProduceLiquid(int type, int maxVol, int side) {
|
||||
if(count == 10 || count == 20)
|
||||
{
|
||||
if(type == 0)
|
||||
{
|
||||
if(steamStored > maxVol)
|
||||
{
|
||||
this.steamStored -= maxVol;
|
||||
return maxVol;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProduceLiquid(int type, byte side) {
|
||||
if(type == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
136
minecraft/net/minecraft/src/eui/pipes/BlockPipe.java
Normal file
136
minecraft/net/minecraft/src/eui/pipes/BlockPipe.java
Normal file
|
@ -0,0 +1,136 @@
|
|||
package net.minecraft.src.eui.pipes;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.src.eui.api.*;
|
||||
import net.minecraft.src.eui.pipes.api.ILiquidConsumer;
|
||||
import net.minecraft.src.eui.pipes.api.ILiquidProducer;
|
||||
import net.minecraft.src.eui.*;
|
||||
import net.minecraft.src.universalelectricity.UniversalElectricity;
|
||||
import net.minecraft.src.*;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class BlockPipe extends BlockContainer
|
||||
{
|
||||
|
||||
public BlockPipe(int id)
|
||||
{
|
||||
super(id, Material.iron);
|
||||
this.setBlockName("Pipe");
|
||||
this.setBlockBounds(0.30F, 0.30F, 0.30F, 0.70F, 0.70F, 0.70F);
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two
|
||||
* adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
|
||||
*/
|
||||
public boolean isOpaqueCube()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc)
|
||||
*/
|
||||
public boolean renderAsNormalBlock()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* The type of render function that is called for this block
|
||||
*/
|
||||
public int getRenderType()
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ID of the items to drop on destruction.
|
||||
*/
|
||||
public int idDropped(int par1, Random par2Random, int par3)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public TileEntity getBlockEntity()
|
||||
{
|
||||
return new TileEntityPipe();
|
||||
}
|
||||
|
||||
//Per tick
|
||||
public int conductorCapacity()
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called whenever the block is added into the world. Args: world, x, y, z
|
||||
*/
|
||||
@Override
|
||||
public void onBlockAdded(World world, int x, int y, int z)
|
||||
{
|
||||
super.onBlockAdded(world, x, y, z);
|
||||
|
||||
this.updateConductorTileEntity(world, x, y, z);
|
||||
}
|
||||
public static TileEntity getUEUnit(World world, int x, int y, int z, byte side,int type)
|
||||
{
|
||||
switch(side)
|
||||
{
|
||||
case 0: y -= 1; break;
|
||||
case 1: y += 1; break;
|
||||
case 2: z += 1; break;
|
||||
case 3: z -= 1; break;
|
||||
case 4: x += 1; break;
|
||||
case 5: x -= 1; break;
|
||||
}
|
||||
|
||||
//Check if the designated block is a UE Unit - producer, consumer or a conductor
|
||||
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
|
||||
TileEntity returnValue = null;
|
||||
|
||||
if(tileEntity instanceof ILiquidConsumer)
|
||||
{
|
||||
if(((ILiquidConsumer)tileEntity).canRecieveLiquid(type,UniversalElectricity.getOrientationFromSide(side, (byte)2)))
|
||||
{
|
||||
returnValue = tileEntity;
|
||||
}
|
||||
}
|
||||
|
||||
if (tileEntity instanceof ILiquidProducer)
|
||||
{
|
||||
if(((ILiquidProducer)tileEntity).canProduceLiquid(type,UniversalElectricity.getOrientationFromSide(side, (byte)2)))
|
||||
{
|
||||
returnValue = tileEntity;
|
||||
}
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
/**
|
||||
* 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 world, int x, int y, int z, int blockID)
|
||||
{
|
||||
super.onNeighborBlockChange(world, x, y, z, blockID);
|
||||
this.updateConductorTileEntity(world, x, y, z);
|
||||
}
|
||||
|
||||
public static void updateConductorTileEntity(World world, int x, int y, int z)
|
||||
{
|
||||
for(byte i = 0; i < 6; i++)
|
||||
{
|
||||
//Update the tile entity on neighboring blocks
|
||||
TileEntityPipe conductorTileEntity = (TileEntityPipe)world.getBlockTileEntity(x, y, z);
|
||||
int type = conductorTileEntity.getType();
|
||||
conductorTileEntity.addConnection(getUEUnit(world, x, y, z, i, type), i);;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
68
minecraft/net/minecraft/src/eui/pipes/ItemParts.java
Normal file
68
minecraft/net/minecraft/src/eui/pipes/ItemParts.java
Normal file
|
@ -0,0 +1,68 @@
|
|||
package net.minecraft.src.eui.pipes;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.src.Item;
|
||||
import net.minecraft.src.ItemStack;
|
||||
import net.minecraft.src.forge.ITextureProvider;
|
||||
|
||||
public class ItemParts extends Item implements ITextureProvider{
|
||||
|
||||
public ItemParts(int par1)
|
||||
{
|
||||
super(par1);
|
||||
this.setItemName("Parts");
|
||||
this.setHasSubtypes(true);
|
||||
this.setMaxDamage(0);
|
||||
this.setMaxStackSize(64);
|
||||
}
|
||||
@Override
|
||||
public int getIconFromDamage(int par1)
|
||||
{
|
||||
switch(par1)
|
||||
{
|
||||
case 0: return 7;
|
||||
case 1: return 7;
|
||||
case 2: return 8;
|
||||
}
|
||||
return this.iconIndex;
|
||||
}
|
||||
@Override
|
||||
public String getTextureFile() {
|
||||
// TODO Auto-generated method stub
|
||||
return "/eui/Items.png";
|
||||
}
|
||||
@Override
|
||||
public String getItemName()
|
||||
{
|
||||
return "parts";
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getItemNameIS(ItemStack par1ItemStack)
|
||||
{
|
||||
int var3 = par1ItemStack.getItemDamage();
|
||||
switch(var3)
|
||||
{
|
||||
case 0: return "BronzeTube";
|
||||
case 1: return "ObbyTube";
|
||||
case 2: return "Seal";
|
||||
case 3: return "IronTube";
|
||||
case 4: return "StickSeal";
|
||||
}
|
||||
return this.getItemName();
|
||||
}
|
||||
@Override
|
||||
public void addCreativeItems(ArrayList itemList)
|
||||
{
|
||||
itemList.add(new ItemStack(this, 1,0));
|
||||
itemList.add(new ItemStack(this, 1,1));
|
||||
itemList.add(new ItemStack(this, 1,2));
|
||||
itemList.add(new ItemStack(this, 1,3));
|
||||
itemList.add(new ItemStack(this, 1,4));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
137
minecraft/net/minecraft/src/eui/pipes/ItemPipe.java
Normal file
137
minecraft/net/minecraft/src/eui/pipes/ItemPipe.java
Normal file
|
@ -0,0 +1,137 @@
|
|||
package net.minecraft.src.eui.pipes;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.src.forge.*;
|
||||
import net.minecraft.src.*;
|
||||
|
||||
public class ItemPipe extends Item implements ITextureProvider
|
||||
{
|
||||
private int spawnID;
|
||||
|
||||
public ItemPipe(int id)
|
||||
{
|
||||
super(id);
|
||||
this.setMaxDamage(0);
|
||||
this.setHasSubtypes(true);
|
||||
this.setIconIndex(10);
|
||||
this.setItemName("pipe");
|
||||
}
|
||||
@Override
|
||||
public int getIconFromDamage(int par1)
|
||||
{
|
||||
switch(par1)
|
||||
{
|
||||
case 0: return 11;
|
||||
case 1: return 10;
|
||||
case 2: return 11;
|
||||
case 3: return 10;
|
||||
case 4: return 11;
|
||||
case 5: return 10;
|
||||
}
|
||||
return this.iconIndex;
|
||||
}
|
||||
@Override
|
||||
public String getItemName()
|
||||
{
|
||||
return "Pipes";
|
||||
}
|
||||
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7)
|
||||
{
|
||||
int blockID = par3World.getBlockId(par4, par5, par6);
|
||||
spawnID = mod_BasicPipes.pipeID;
|
||||
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 (par3World.canBlockBePlacedAt(this.spawnID, par4, par5, par6, false, par7))
|
||||
{
|
||||
Block var9 = Block.blocksList[this.spawnID];
|
||||
|
||||
if (par3World.setBlockWithNotify(par4, par5, par6, this.spawnID))
|
||||
{
|
||||
if (par3World.getBlockId(par4, par5, par6) == this.spawnID)
|
||||
{
|
||||
Block.blocksList[this.spawnID].onBlockPlaced(par3World, par4, par5, par6, par7);
|
||||
Block.blocksList[this.spawnID].onBlockPlacedBy(par3World, par4, par5, par6, par2EntityPlayer);
|
||||
TileEntity blockEntity = par3World.getBlockTileEntity(par4, par5, par6);
|
||||
if(blockEntity instanceof TileEntityPipe)
|
||||
{
|
||||
TileEntityPipe pipeEntity = (TileEntityPipe) blockEntity;
|
||||
int dm = par1ItemStack.getItemDamage();
|
||||
String rType = "air";
|
||||
pipeEntity.setType(dm);
|
||||
}
|
||||
}
|
||||
|
||||
--par1ItemStack.stackSize;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
public String getItemNameIS(ItemStack par1ItemStack)
|
||||
{
|
||||
int var3 = par1ItemStack.getItemDamage();
|
||||
switch(var3)
|
||||
{
|
||||
case 1: return "waterPipe";
|
||||
case 0: return "steamPipe";
|
||||
case 2: return "22";
|
||||
case 3: return "22";
|
||||
case 4: return "22";
|
||||
case 5: return "22";
|
||||
}
|
||||
return this.getItemName();
|
||||
}
|
||||
@Override
|
||||
public String getTextureFile() {
|
||||
return "/eui/Items.png";
|
||||
}
|
||||
@Override
|
||||
public void addCreativeItems(ArrayList itemList) {
|
||||
|
||||
itemList.add(new ItemStack(this, 1,0));
|
||||
itemList.add(new ItemStack(this, 1,1));
|
||||
itemList.add(new ItemStack(this, 1,2));
|
||||
itemList.add(new ItemStack(this, 1,3));
|
||||
itemList.add(new ItemStack(this, 1,4));
|
||||
itemList.add(new ItemStack(this, 1,5));
|
||||
}
|
||||
|
||||
}
|
98
minecraft/net/minecraft/src/eui/pipes/ModelPipe.java
Normal file
98
minecraft/net/minecraft/src/eui/pipes/ModelPipe.java
Normal file
|
@ -0,0 +1,98 @@
|
|||
package net.minecraft.src.eui.pipes;
|
||||
|
||||
import net.minecraft.src.*;
|
||||
|
||||
public class ModelPipe extends ModelBase
|
||||
{
|
||||
//fields
|
||||
ModelRenderer Middle;
|
||||
ModelRenderer Right;
|
||||
ModelRenderer Left;
|
||||
ModelRenderer Back;
|
||||
ModelRenderer Front;
|
||||
ModelRenderer Top;
|
||||
ModelRenderer Bottom;
|
||||
|
||||
public ModelPipe()
|
||||
{
|
||||
textureWidth = 64;
|
||||
textureHeight = 32;
|
||||
|
||||
Middle = new ModelRenderer(this, 0, 0);
|
||||
Middle.addBox(-1F, -1F, -1F, 4, 4, 4);
|
||||
Middle.setRotationPoint(-1F, 15F, -1F);
|
||||
Middle.setTextureSize(64, 32);
|
||||
Middle.mirror = true;
|
||||
setRotation(Middle, 0F, 0F, 0F);
|
||||
Right = new ModelRenderer(this, 21, 0);
|
||||
Right.addBox(0F, 0F, 0F, 6, 4, 4);
|
||||
Right.setRotationPoint(2F, 14F, -2F);
|
||||
Right.setTextureSize(64, 32);
|
||||
Right.mirror = true;
|
||||
setRotation(Right, 0F, 0F, 0F);
|
||||
Left = new ModelRenderer(this, 21, 0);
|
||||
Left.addBox(0F, 0F, 0F, 6, 4, 4);
|
||||
Left.setRotationPoint(-8F, 14F, -2F);
|
||||
Left.setTextureSize(64, 32);
|
||||
Left.mirror = true;
|
||||
setRotation(Left, 0F, 0F, 0F);
|
||||
Back = new ModelRenderer(this, 0, 11);
|
||||
Back.addBox(0F, 0F, 0F, 4, 4, 6);
|
||||
Back.setRotationPoint(-2F, 14F, 2F);
|
||||
Back.setTextureSize(64, 32);
|
||||
Back.mirror = true;
|
||||
setRotation(Back, 0F, 0F, 0F);
|
||||
Front = new ModelRenderer(this, 0, 11);
|
||||
Front.addBox(0F, 0F, 0F, 4, 4, 6);
|
||||
Front.setRotationPoint(-2F, 14F, -8F);
|
||||
Front.setTextureSize(64, 32);
|
||||
Front.mirror = true;
|
||||
setRotation(Front, 0F, 0F, 0F);
|
||||
Top = new ModelRenderer(this, 21, 11);
|
||||
Top.addBox(0F, 0F, 0F, 4, 6, 4);
|
||||
Top.setRotationPoint(-2F, 8F, -2F);
|
||||
Top.setTextureSize(64, 32);
|
||||
Top.mirror = true;
|
||||
setRotation(Top, 0F, 0F, 0F);
|
||||
Bottom = new ModelRenderer(this, 21, 11);
|
||||
Bottom.addBox(0F, 0F, 0F, 4, 6, 4);
|
||||
Bottom.setRotationPoint(-2F, 18F, -2F);
|
||||
Bottom.setTextureSize(64, 32);
|
||||
Bottom.mirror = true;
|
||||
setRotation(Bottom, 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);
|
||||
this.renderMiddle();
|
||||
this.renderBottom();
|
||||
this.renderTop();
|
||||
this.renderLeft();
|
||||
this.renderRight();
|
||||
this.renderBack();
|
||||
this.renderFront();
|
||||
}
|
||||
|
||||
public void renderMiddle() { Middle.render(0.0625F); }
|
||||
public void renderBottom() { Bottom.render(0.0625F); }
|
||||
public void renderTop() { Top.render(0.0625F); }
|
||||
public void renderLeft() { Left.render(0.0625F); }
|
||||
public void renderRight() { Right.render(0.0625F); }
|
||||
public void renderBack() { Back.render(0.0625F); }
|
||||
public void renderFront() { Front.render(0.0625F);}
|
||||
|
||||
private void setRotation(ModelRenderer model, float x, float y, float z)
|
||||
{
|
||||
model.rotateAngleX = x;
|
||||
model.rotateAngleY = y;
|
||||
model.rotateAngleZ = z;
|
||||
}
|
||||
|
||||
public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5)
|
||||
{
|
||||
super.setRotationAngles(f, f1, f2, f3, f4, f5);
|
||||
}
|
||||
|
||||
}
|
53
minecraft/net/minecraft/src/eui/pipes/RenderPipe.java
Normal file
53
minecraft/net/minecraft/src/eui/pipes/RenderPipe.java
Normal file
|
@ -0,0 +1,53 @@
|
|||
package net.minecraft.src.eui.pipes;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import net.minecraft.src.*;
|
||||
|
||||
public class RenderPipe extends TileEntitySpecialRenderer
|
||||
{
|
||||
int type = 0;
|
||||
private ModelPipe model;
|
||||
|
||||
public RenderPipe()
|
||||
{
|
||||
model = new ModelPipe();
|
||||
}
|
||||
|
||||
public void renderAModelAt(TileEntityPipe tileEntity, double d, double d1, double d2, float f)
|
||||
{
|
||||
//Texture file
|
||||
|
||||
type = tileEntity.getType();
|
||||
switch(type)
|
||||
{
|
||||
case 0: bindTextureByName("/eui/SteamPipe.png");break;
|
||||
case 1: bindTextureByName("/eui/WaterPipe.png");break;
|
||||
case 2: bindTextureByName("/eui/lavaPipe.png");break;
|
||||
case 3: bindTextureByName("/eui/oilPipe.png");break;
|
||||
case 4: bindTextureByName("/eui/fuelPipe.png");break;
|
||||
case 5: bindTextureByName("/eui/airPipe.png");break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef((float) d + 0.5F, (float) d1 + 1.5F, (float) d2 + 0.5F);
|
||||
GL11.glScalef(1.0F, -1F, -1F);
|
||||
|
||||
if(tileEntity.connectedBlocks[0] != null) model.renderBottom();
|
||||
if(tileEntity.connectedBlocks[1] != null) model.renderTop();
|
||||
if(tileEntity.connectedBlocks[2] != null) model.renderFront();
|
||||
if(tileEntity.connectedBlocks[3] != null) model.renderBack();
|
||||
if(tileEntity.connectedBlocks[4] != null) model.renderRight();
|
||||
if(tileEntity.connectedBlocks[5] != null) model.renderLeft();
|
||||
|
||||
model.renderMiddle();
|
||||
GL11.glPopMatrix();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity tileEntity, double var2, double var4, double var6, float var8) {
|
||||
this.renderAModelAt((TileEntityPipe)tileEntity, var2, var4, var6, var8);
|
||||
}
|
||||
|
||||
}
|
231
minecraft/net/minecraft/src/eui/pipes/TileEntityPipe.java
Normal file
231
minecraft/net/minecraft/src/eui/pipes/TileEntityPipe.java
Normal file
|
@ -0,0 +1,231 @@
|
|||
package net.minecraft.src.eui.pipes;
|
||||
import net.minecraft.src.NBTTagCompound;
|
||||
import net.minecraft.src.TileEntity;
|
||||
import net.minecraft.src.World;
|
||||
import net.minecraft.src.eui.pipes.api.ILiquidConsumer;
|
||||
import net.minecraft.src.eui.pipes.api.ILiquidProducer;
|
||||
import net.minecraft.src.universalelectricity.UniversalElectricity;
|
||||
import net.minecraft.src.universalelectricity.Vector3;
|
||||
|
||||
public class TileEntityPipe extends TileEntity implements ILiquidConsumer
|
||||
{
|
||||
//The amount stored in the conductor
|
||||
protected int liquidStored = 0;
|
||||
protected int type = 0;
|
||||
//The maximum amount of electricity this conductor can take
|
||||
protected int capacity = 5;
|
||||
|
||||
//Stores information on all connected blocks around this tile entity
|
||||
public TileEntity[] connectedBlocks = {null, null, null, null, null, null};
|
||||
|
||||
//Checks if this is the first the tile entity updates
|
||||
protected boolean firstUpdate = true;
|
||||
|
||||
/**
|
||||
* The tile entity of the closest electric consumer. Null if none. Use this to detect if electricity
|
||||
* should transfer
|
||||
*/
|
||||
public TileEntity closestConsumer = null;
|
||||
|
||||
/**
|
||||
* This function adds a connection between this conductor and the UE unit
|
||||
* @param tileEntity - Must be either a producer, consumer or a conductor
|
||||
* @param side - side in which the connection is coming from
|
||||
*/
|
||||
public void addConnection(TileEntity tileEntity, byte side)
|
||||
{
|
||||
if(tileEntity instanceof TileEntityPipe)
|
||||
{
|
||||
if(((TileEntityPipe)tileEntity).getType() == this.getType())
|
||||
{
|
||||
this.connectedBlocks[side] = tileEntity;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.connectedBlocks[side] = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(tileEntity instanceof ILiquidConsumer || tileEntity instanceof ILiquidProducer)
|
||||
{
|
||||
this.connectedBlocks[side] = tileEntity;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.connectedBlocks[side] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* onRecieveElectricity is called whenever a Universal Electric conductor sends a packet of electricity to the consumer (which is this block).
|
||||
* @param watts - The amount of watt this block recieved
|
||||
* @param side - The side of the block in which the electricity came from
|
||||
* @return watt - The amount of rejected power to be sent back into the conductor
|
||||
*/
|
||||
@Override
|
||||
public int onReceiveLiquid(int type,int watt, byte side)
|
||||
{
|
||||
if(type == this.type)
|
||||
{
|
||||
int rejectedElectricity = Math.max((this.getStoredLiquid(type) + watt) - this.capacity, 0);
|
||||
this.liquidStored = watt - rejectedElectricity;
|
||||
return rejectedElectricity;
|
||||
}
|
||||
return watt;
|
||||
}
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
BlockPipe.updateConductorTileEntity(this.worldObj, this.xCoord, this.yCoord, this.zCoord);
|
||||
|
||||
//Find the connected unit with the least amount of electricity and give more to them
|
||||
if(!this.worldObj.isRemote)
|
||||
{
|
||||
//Spread the electricity to neighboring blocks
|
||||
byte connectedUnits = 0;
|
||||
byte connectedConductors = 1;
|
||||
int averageElectricity = this.liquidStored;
|
||||
this.closestConsumer = null;
|
||||
|
||||
Vector3 currentPosition = new Vector3(this.xCoord, this.yCoord, this.zCoord);
|
||||
|
||||
for(byte i = 0; i < 6; i++)
|
||||
{
|
||||
if(connectedBlocks[i] != null)
|
||||
{
|
||||
if(connectedBlocks[i] instanceof ILiquidConsumer || connectedBlocks[i] instanceof ILiquidProducer)
|
||||
{
|
||||
connectedUnits ++;
|
||||
|
||||
if(connectedBlocks[i].getClass() == this.getClass())
|
||||
{
|
||||
averageElectricity += ((TileEntityPipe)connectedBlocks[i]).liquidStored;
|
||||
|
||||
TileEntity tileEntity = ((TileEntityPipe)connectedBlocks[i]).closestConsumer;
|
||||
|
||||
if(tileEntity != null)
|
||||
{
|
||||
this.closestConsumer = tileEntity;
|
||||
}
|
||||
|
||||
connectedConductors ++;
|
||||
}
|
||||
else if(connectedBlocks[i] instanceof ILiquidConsumer)
|
||||
{
|
||||
if(((ILiquidConsumer)connectedBlocks[i]).canRecieveLiquid(this.type,UniversalElectricity.getOrientationFromSide(i, (byte)2)))
|
||||
{
|
||||
this.closestConsumer = connectedBlocks[i];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
averageElectricity = averageElectricity/connectedConductors;
|
||||
if(connectedUnits > 0)
|
||||
{
|
||||
for(byte i = 0; i < 6; i++)
|
||||
{
|
||||
if(connectedBlocks[i] != null)
|
||||
{
|
||||
//Spread the electricity among the different blocks
|
||||
if(connectedBlocks[i] instanceof ILiquidConsumer && this.liquidStored > 0)
|
||||
{
|
||||
if(((ILiquidConsumer)connectedBlocks[i]).canRecieveLiquid(this.type,UniversalElectricity.getOrientationFromSide(i, (byte)2)))
|
||||
{
|
||||
int transferElectricityAmount = 0;
|
||||
ILiquidConsumer connectedConsumer = ((ILiquidConsumer)connectedBlocks[i]);
|
||||
|
||||
if(connectedBlocks[i].getClass() == this.getClass() && this.liquidStored > ((TileEntityPipe)connectedConsumer).liquidStored)
|
||||
{
|
||||
transferElectricityAmount = Math.max(Math.min(averageElectricity - ((TileEntityPipe)connectedConsumer).liquidStored, this.liquidStored), 0);
|
||||
}
|
||||
else if(!(connectedConsumer instanceof TileEntityPipe))
|
||||
{
|
||||
transferElectricityAmount = this.liquidStored;
|
||||
}
|
||||
|
||||
int rejectedElectricity = connectedConsumer.onReceiveLiquid(this.type,transferElectricityAmount, UniversalElectricity.getOrientationFromSide(i, (byte)2));
|
||||
this.liquidStored = Math.max(Math.min(this.liquidStored - transferElectricityAmount + rejectedElectricity, 5), 0);
|
||||
}
|
||||
}
|
||||
|
||||
if(connectedBlocks[i] instanceof ILiquidProducer && this.liquidStored < this.getLiquidCapacity(type))
|
||||
{
|
||||
if(((ILiquidProducer)connectedBlocks[i]).canProduceLiquid(this.type,UniversalElectricity.getOrientationFromSide(i, (byte)2)))
|
||||
{
|
||||
int gainedElectricity = ((ILiquidProducer)connectedBlocks[i]).onProduceLiquid(this.type,5-this.liquidStored, UniversalElectricity.getOrientationFromSide(i, (byte)2));
|
||||
this.onReceiveLiquid(this.type, gainedElectricity, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Return the stored electricity in this consumer. Called by conductors to spread electricity to this unit.
|
||||
*/
|
||||
@Override
|
||||
public int getStoredLiquid(int type)
|
||||
{
|
||||
if(type == this.type)
|
||||
{
|
||||
return this.liquidStored;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getLiquidCapacity(int type)
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a tile entity from NBT.
|
||||
*/
|
||||
public void readFromNBT(NBTTagCompound par1NBTTagCompound)
|
||||
{
|
||||
super.readFromNBT(par1NBTTagCompound);
|
||||
this.liquidStored = par1NBTTagCompound.getInteger("liquid");
|
||||
this.type = par1NBTTagCompound.getInteger("type");
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a tile entity to NBT.
|
||||
*/
|
||||
public void writeToNBT(NBTTagCompound par1NBTTagCompound)
|
||||
{
|
||||
super.writeToNBT(par1NBTTagCompound);
|
||||
par1NBTTagCompound.setInteger("liquid", this.liquidStored);
|
||||
par1NBTTagCompound.setInteger("type", this.type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRecieveLiquid(int type, byte side) {
|
||||
if(type == this.type)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public int getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
|
||||
public void setType(int rType) {
|
||||
this.type = rType;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
package net.minecraft.src.eui.pipes.api;
|
||||
|
||||
|
||||
public interface ILiquidConsumer
|
||||
{
|
||||
/**
|
||||
* onRecieveLiquid
|
||||
* @param vol - The amount this block received.
|
||||
* @param side - The side of the block in which the liquid came from.
|
||||
* @return vol - The amount liquid that can't be recieved
|
||||
*/
|
||||
public int onReceiveLiquid(int type, int vol, byte side);
|
||||
|
||||
/**
|
||||
* You can use this to check if a pipe can connect to this liquid consumer to properly render the graphics
|
||||
* @param side - The side in which the electricity is coming from.
|
||||
* @return Returns true or false if this consumer can receive electricity at this given tick or moment.
|
||||
*/
|
||||
public boolean canRecieveLiquid(int type, byte side);
|
||||
|
||||
/**
|
||||
* @return Return the stored liquid of type in this consumer.
|
||||
*/
|
||||
public int getStoredLiquid(int type);
|
||||
|
||||
/**
|
||||
* @return Return the maximum amount of stored liquid this consumer can get.
|
||||
*/
|
||||
public int getLiquidCapacity(int type);
|
||||
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package net.minecraft.src.eui.pipes.api;
|
||||
|
||||
/**
|
||||
* The UEIProducer interface is an interface that must be applied to all tile entities that can produce electricity.
|
||||
* @author Calclavia
|
||||
*
|
||||
*/
|
||||
public interface ILiquidProducer
|
||||
{
|
||||
/**
|
||||
* onProduceLiquid
|
||||
* block.
|
||||
* @param type - the type of liquid or gas
|
||||
* @param maxvol - The maximum vol
|
||||
* @param side - The side
|
||||
* @return vol - Return a vol of liquid type
|
||||
*/
|
||||
public int onProduceLiquid(int type, int maxVol, int side);
|
||||
|
||||
public boolean canProduceLiquid(int type, byte side);
|
||||
}
|
|
@ -1,12 +1,14 @@
|
|||
package net.minecraft.src.eui.turbine;
|
||||
import net.minecraft.src.eui.TileEntityMachine;
|
||||
import net.minecraft.src.eui.api.*;
|
||||
import net.minecraft.src.eui.pipes.api.ILiquidConsumer;
|
||||
import net.minecraft.src.eui.pipes.api.ILiquidProducer;
|
||||
import net.minecraft.src.forge.ForgeHooks;
|
||||
import net.minecraft.src.*;
|
||||
import net.minecraft.src.universalelectricity.*;
|
||||
import net.minecraft.src.forge.ISidedInventory;
|
||||
|
||||
public class TileEntityGenerator extends TileEntityMachine implements UEIProducer,ISteamConsumer,IWaterProducer, IInventory, ISidedInventory
|
||||
public class TileEntityGenerator extends TileEntityMachine implements UEIProducer,ILiquidConsumer,ILiquidProducer, IInventory, ISidedInventory
|
||||
{
|
||||
//Maximum possible generation rate of watts in SECONDS
|
||||
public int maxGenerateRate = 1000;
|
||||
|
@ -246,57 +248,6 @@ public class TileEntityGenerator extends TileEntityMachine implements UEIProduce
|
|||
public void openChest() { }
|
||||
@Override
|
||||
public void closeChest() { }
|
||||
|
||||
|
||||
@Override
|
||||
public int onReceiveSteam(int vol, byte side) {
|
||||
|
||||
|
||||
if(steamStored + vol <= 100)
|
||||
{
|
||||
steamStored = steamStored + vol;
|
||||
return 0;
|
||||
}
|
||||
return vol;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRecieveSteam(byte side) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStoredSteam() {
|
||||
|
||||
return this.steamStored;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSteamCapacity() {
|
||||
return 100;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int onProduceWater(int maxVol, int side) {
|
||||
|
||||
if(this.waterStored > 0)
|
||||
{
|
||||
--waterStored;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProduceWater(byte side) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getVolts() {
|
||||
// TODO Auto-generated method stub
|
||||
|
@ -314,4 +265,64 @@ public class TileEntityGenerator extends TileEntityMachine implements UEIProduce
|
|||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int onProduceLiquid(int type, int maxVol, int side) {
|
||||
if(type == 1)
|
||||
{
|
||||
if(this.waterStored > 0)
|
||||
{
|
||||
--waterStored;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProduceLiquid(int type, byte side) {
|
||||
if(type == 1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int onReceiveLiquid(int type, int vol, byte side) {
|
||||
if(type == 0)
|
||||
{
|
||||
int rejectedSteam = Math.max((this.steamStored + vol) - 100, 0);
|
||||
this.steamStored = vol - rejectedSteam;
|
||||
return rejectedSteam;
|
||||
}
|
||||
return vol;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRecieveLiquid(int type, byte side) {
|
||||
if(type == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStoredLiquid(int type) {
|
||||
if(type == 0)
|
||||
{
|
||||
return this.steamStored;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLiquidCapacity(int type) {
|
||||
if(type == 0)
|
||||
{
|
||||
return 100;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
82
minecraft/net/minecraft/src/mod_BasicPipes.java
Normal file
82
minecraft/net/minecraft/src/mod_BasicPipes.java
Normal file
|
@ -0,0 +1,82 @@
|
|||
package net.minecraft.src;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.src.eui.pipes.RenderPipe;
|
||||
import net.minecraft.src.forge.*;
|
||||
import net.minecraft.src.universalelectricity.*;
|
||||
import net.minecraft.src.universalelectricity.components.UniversalComponents;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
import java.io.*;
|
||||
public class mod_BasicPipes extends NetworkMod {
|
||||
static Configuration config = new Configuration((new File(Minecraft.getMinecraftDir(), "config/EUIndustry/BasicPipes.cfg")));
|
||||
public static int pipeID = configurationProperties();
|
||||
private static int partID;
|
||||
private static int ppipeID;
|
||||
public static Block pipe = new net.minecraft.src.eui.pipes.BlockPipe(pipeID).setBlockName("pipe");
|
||||
public static Item parts = new net.minecraft.src.eui.pipes.ItemParts(partID);
|
||||
public static Item itemPipes = new net.minecraft.src.eui.pipes.ItemPipe(ppipeID);
|
||||
@Override
|
||||
public String getVersion() {
|
||||
// TODO change version on each update ;/
|
||||
return "0.0.1";
|
||||
}
|
||||
public static int configurationProperties()
|
||||
{
|
||||
config.load();
|
||||
pipeID = Integer.parseInt(config.getOrCreateIntProperty("PipeBlock", Configuration.CATEGORY_BLOCK, 155).value);
|
||||
partID = Integer.parseInt(config.getOrCreateIntProperty("parts", Configuration.CATEGORY_ITEM, 23022).value);
|
||||
ppipeID = Integer.parseInt(config.getOrCreateIntProperty("pipes", Configuration.CATEGORY_ITEM, 23023).value);
|
||||
config.save();
|
||||
return pipeID;
|
||||
}
|
||||
@Override
|
||||
public void load() {
|
||||
//register
|
||||
UniversalElectricity.registerAddon(this, "0.3.1");
|
||||
MinecraftForgeClient.preloadTexture("/eui/Items.png");
|
||||
ModLoader.registerBlock(pipe);
|
||||
ModLoader.registerTileEntity(net.minecraft.src.eui.pipes.TileEntityPipe.class, "pipe", new RenderPipe());
|
||||
//Names
|
||||
|
||||
ModLoader.addName((new ItemStack(itemPipes, 1, 0)), "Steam");
|
||||
ModLoader.addName((new ItemStack(itemPipes, 1, 1)), "Water");
|
||||
ModLoader.addName((new ItemStack(itemPipes, 1, 2)), "Lava");
|
||||
ModLoader.addName((new ItemStack(itemPipes, 1, 3)), "Oil");
|
||||
ModLoader.addName((new ItemStack(itemPipes, 1, 4)), "Fuel");
|
||||
ModLoader.addName((new ItemStack(itemPipes, 1, 5)), "Air");
|
||||
ModLoader.addName((new ItemStack(parts, 1, 0)), "BronzeTube");
|
||||
ModLoader.addName((new ItemStack(parts, 1, 1)), "ObbyTube");
|
||||
ModLoader.addName((new ItemStack(parts, 1, 2)), "LeatherSeal");
|
||||
ModLoader.addName((new ItemStack(parts, 1, 3)), "ObsidianTube");
|
||||
ModLoader.addName((new ItemStack(parts, 1, 4)), "SlimeSeal");
|
||||
//Blocks
|
||||
|
||||
ModLoader.addRecipe(new ItemStack(parts, 2,0), new Object[] { "@@@", '@',
|
||||
UniversalComponents.ItemBronzeIngot});
|
||||
ModLoader.addRecipe(new ItemStack(parts, 2,1), new Object[] { "@@@", '@',
|
||||
Block.obsidian});
|
||||
ModLoader.addRecipe(new ItemStack(parts, 2,2), new Object[] { "@@","@@", '@',
|
||||
Item.leather});
|
||||
ModLoader.addRecipe(new ItemStack(parts, 2,3), new Object[] { "@@@", '@',
|
||||
Item.ingotIron});
|
||||
ModLoader.addShapelessRecipe(new ItemStack(parts, 1,4), new Object[] { new ItemStack(parts, 1,2),new ItemStack(Item.slimeBall, 1)});
|
||||
//crafting parts
|
||||
/**
|
||||
* case 0: return "steam";
|
||||
case 1: return "water";
|
||||
case 2: return "lava";
|
||||
case 3: return "oil";
|
||||
case 4: return "fuel";
|
||||
case 5: return "air";
|
||||
*/
|
||||
ModLoader.addShapelessRecipe(new ItemStack(itemPipes, 1,0), new Object[] { new ItemStack(parts, 1,0),new ItemStack(parts, 1,2)});
|
||||
ModLoader.addShapelessRecipe(new ItemStack(itemPipes, 1,1), new Object[] { new ItemStack(parts, 1,0),new ItemStack(parts, 1,2),new ItemStack(Item.dyePowder, 1,4)});
|
||||
ModLoader.addShapelessRecipe(new ItemStack(itemPipes, 1,2), new Object[] { new ItemStack(parts, 1,1)});
|
||||
ModLoader.addShapelessRecipe(new ItemStack(itemPipes, 1,3), new Object[] { new ItemStack(parts, 1,3),new ItemStack(parts, 1,4),new ItemStack(Item.dyePowder, 1,0)});
|
||||
ModLoader.addShapelessRecipe(new ItemStack(itemPipes, 1,4), new Object[] { new ItemStack(parts, 1,3),new ItemStack(parts, 1,4),new ItemStack(Item.dyePowder, 1,11)});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,8 +1,6 @@
|
|||
package net.minecraft.src;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.src.eui.*;
|
||||
import net.minecraft.src.eui.steam.RenderPipe;
|
||||
import net.minecraft.src.eui.steam.RenderPipeWater;
|
||||
import net.minecraft.src.forge.*;
|
||||
import net.minecraft.src.universalelectricity.*;
|
||||
import net.minecraft.src.universalelectricity.components.UniversalComponents;
|
||||
|
@ -24,11 +22,7 @@ public class mod_EUIndustry extends NetworkMod {
|
|||
public static int boilerHeat;
|
||||
public static int fireOutput;
|
||||
public static Block machine = new net.minecraft.src.eui.BlockMachine(BlockID).setBlockName("machine");
|
||||
public static Block pipe = new net.minecraft.src.eui.steam.BlockPipe(pipeBlockID).setBlockName("pipe");
|
||||
public static Block pipeW = new net.minecraft.src.eui.steam.BlockPipeWater(pipeBlockID2).setBlockName("pipeW");
|
||||
public static Item coalNugget = new net.minecraft.src.eui.ItemCoalFuel(coalID);
|
||||
public static Item pipeItem = new net.minecraft.src.eui.steam.ItemPipe(pipeID);
|
||||
public static Item parts = new net.minecraft.src.eui.ItemParts(partID);
|
||||
@Override
|
||||
public String getVersion() {
|
||||
// TODO change version on each update ;/
|
||||
|
@ -59,11 +53,7 @@ public class mod_EUIndustry extends NetworkMod {
|
|||
//Blocks
|
||||
//gen
|
||||
//machine
|
||||
ModLoader.registerBlock(machine,net.minecraft.src.eui.ItemMachine.class);
|
||||
ModLoader.registerBlock(pipe);
|
||||
ModLoader.registerBlock(pipeW);
|
||||
ModLoader.addName((new ItemStack(pipeItem, 1, 0)), "SteamPipe");
|
||||
ModLoader.addName((new ItemStack(pipeItem, 1, 1)), "WaterPipe");
|
||||
ModLoader.registerBlock(machine, net.minecraft.src.eui.ItemMachine.class);
|
||||
ModLoader.addName((new ItemStack(machine, 1, 0)), "CoalRefiner");
|
||||
ModLoader.addName((new ItemStack(machine, 1, 1)), "Boiler");
|
||||
ModLoader.addName((new ItemStack(machine, 1, 2)), "FireBox");
|
||||
|
@ -76,20 +66,11 @@ public class mod_EUIndustry extends NetworkMod {
|
|||
ModLoader.registerTileEntity(net.minecraft.src.eui.turbine.TileEntityGenerator.class, "generator",new UEBlockRenderer());
|
||||
ModLoader.registerTileEntity(net.minecraft.src.eui.TileEntityCondenser.class, "waterPump",new UEBlockRenderer());
|
||||
ModLoader.registerTileEntity(net.minecraft.src.eui.TileEntityNuller.class, "EUNuller",new UEBlockRenderer());
|
||||
ModLoader.registerTileEntity(net.minecraft.src.eui.steam.TileEntityPipe.class, "pipe", new RenderPipe());
|
||||
ModLoader.registerTileEntity(net.minecraft.src.eui.steam.TileEntityPipeWater.class, "pipeW", new RenderPipeWater());
|
||||
//Items
|
||||
ModLoader.addName((new ItemStack(coalNugget, 1, 0)), "CoalNuggets");
|
||||
ModLoader.addName((new ItemStack(coalNugget, 1, 1)), "CoalPellets");
|
||||
ModLoader.addName((new ItemStack(coalNugget, 1, 2)), "CoalDust");
|
||||
ModLoader.addName((new ItemStack(parts, 1, 1)), "Tank");
|
||||
ModLoader.addName((new ItemStack(parts, 1, 3)), "Valve");
|
||||
ModLoader.addName((new ItemStack(parts, 1, 4)), "Tube");
|
||||
ModLoader.addName((new ItemStack(parts, 1, 5)), "Seal");
|
||||
ModLoader.addName((new ItemStack(parts, 1, 6)), "Rivits");
|
||||
ModLoader.addName(pipeItem, "SteamPipe");
|
||||
//fuels
|
||||
ModLoader.addAllFuel((new ItemStack(coalNugget, 1, 0).itemID), 1000);
|
||||
//Crafting
|
||||
|
||||
ModLoader.addRecipe(new ItemStack(machine, 1, 0), new Object [] {"@S@", "SCW", "@S@",
|
||||
|
@ -97,7 +78,7 @@ public class mod_EUIndustry extends NetworkMod {
|
|||
'@',new ItemStack(UniversalComponents.ItemSteelPlate),
|
||||
'C',new ItemStack(UniversalComponents.ItemCircuit,1,1),
|
||||
'W',UniversalComponents.ItemCopperWire});
|
||||
ModLoader.addRecipe(new ItemStack(machine, 1, 1), new Object [] {"@T@", "OVO", "@T@",
|
||||
/**ModLoader.addRecipe(new ItemStack(machine, 1, 1), new Object [] {"@T@", "OVO", "@T@",
|
||||
'T',new ItemStack(parts, 1,1),
|
||||
'@',new ItemStack(UniversalComponents.ItemSteelPlate),
|
||||
'O',new ItemStack(parts, 1,4),
|
||||
|
@ -109,20 +90,7 @@ public class mod_EUIndustry extends NetworkMod {
|
|||
'T',new ItemStack(parts, 1,4),
|
||||
'@',new ItemStack(UniversalComponents.ItemSteelPlate),
|
||||
'P',Block.pistonBase,
|
||||
'M',new ItemStack(UniversalComponents.ItemMotor)});
|
||||
ModLoader.addShapelessRecipe(new ItemStack(pipeItem, 4), new Object[] { new ItemStack(parts, 1,6),new ItemStack(parts, 1,4),new ItemStack(UniversalComponents.ItemCopperIngot, 1)});
|
||||
ModLoader.addShapelessRecipe(new ItemStack(pipeItem, 4), new Object[] { new ItemStack(parts, 1,4),new ItemStack(Block.glass, 1),new ItemStack(UniversalComponents.ItemCopperIngot, 1)});
|
||||
//crafting parts
|
||||
ModLoader.addShapelessRecipe(new ItemStack(parts, 2,1), new Object[] { new ItemStack(UniversalComponents.ItemCopperIngot, 1),
|
||||
new ItemStack(UniversalComponents.ItemCopperIngot, 1),new ItemStack(UniversalComponents.ItemCopperIngot, 1),
|
||||
new ItemStack(UniversalComponents.ItemCopperIngot, 1), new ItemStack(parts,1,6)});
|
||||
ModLoader.addRecipe(new ItemStack(parts, 2, 3), new Object [] {" S ", "TTT", " ", 'T',
|
||||
new ItemStack(parts, 8, 4),'S',UniversalComponents.ItemSteelIngot});
|
||||
ModLoader.addRecipe(new ItemStack(parts, 8, 4), new Object [] {"@@@", " ", "@@@", '@',
|
||||
UniversalComponents.ItemBronzeIngot});
|
||||
ModLoader.addRecipe(new ItemStack(parts, 8, 5), new Object [] {"@@@", "@ @", "@@@", '@',
|
||||
Item.leather});
|
||||
ModLoader.addShapelessRecipe(new ItemStack(parts, 4,6), new Object[] { new ItemStack(UniversalComponents.ItemCopperIngot, 1)});
|
||||
'M',new ItemStack(UniversalComponents.ItemMotor)});**/
|
||||
|
||||
//smelting
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
package net.minecraft.src;
|
||||
import net.minecraft.src.eui.steam.RenderPipeWater;
|
||||
import net.minecraft.src.forge.*;
|
||||
import net.minecraft.src.universalelectricity.UEBlockRenderer;
|
||||
import net.minecraft.src.universalelectricity.UniversalElectricity;
|
||||
|
|
192
minecraft_server/net/minecraft/src/EntityCreeper.java
Normal file
192
minecraft_server/net/minecraft/src/EntityCreeper.java
Normal file
|
@ -0,0 +1,192 @@
|
|||
package net.minecraft.src;
|
||||
|
||||
public class EntityCreeper extends EntityMob
|
||||
{
|
||||
/**
|
||||
* The amount of time since the creeper was close enough to the player to ignite
|
||||
*/
|
||||
int timeSinceIgnited;
|
||||
|
||||
/**
|
||||
* Time when this creeper was last in an active state (Messed up code here, probably causes creeper animation to go
|
||||
* weird)
|
||||
*/
|
||||
int lastActiveTime;
|
||||
|
||||
public EntityCreeper(World par1World)
|
||||
{
|
||||
super(par1World);
|
||||
this.texture = "/mob/creeper.png";
|
||||
this.tasks.addTask(1, new EntityAISwimming(this));
|
||||
this.tasks.addTask(2, new EntityAICreeperSwell(this));
|
||||
this.tasks.addTask(3, new EntityAIAvoidEntity(this, EntityOcelot.class, 6.0F, 0.25F, 0.3F));
|
||||
this.tasks.addTask(4, new EntityAIAttackOnCollide(this, 0.25F, false));
|
||||
this.tasks.addTask(5, new EntityAIWander(this, 0.2F));
|
||||
this.tasks.addTask(6, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
|
||||
this.tasks.addTask(6, new EntityAILookIdle(this));
|
||||
this.targetTasks.addTask(1, new EntityAINearestAttackableTarget(this, EntityPlayer.class, 16.0F, 0, true));
|
||||
this.targetTasks.addTask(2, new EntityAIHurtByTarget(this, false));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the newer Entity AI code should be run
|
||||
*/
|
||||
public boolean isAIEnabled()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public int getMaxHealth()
|
||||
{
|
||||
return 20;
|
||||
}
|
||||
|
||||
protected void entityInit()
|
||||
{
|
||||
super.entityInit();
|
||||
this.dataWatcher.addObject(16, Byte.valueOf((byte) - 1));
|
||||
this.dataWatcher.addObject(17, Byte.valueOf((byte)0));
|
||||
}
|
||||
|
||||
/**
|
||||
* (abstract) Protected helper method to write subclass entity data to NBT.
|
||||
*/
|
||||
public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound)
|
||||
{
|
||||
super.writeEntityToNBT(par1NBTTagCompound);
|
||||
|
||||
if (this.dataWatcher.getWatchableObjectByte(17) == 1)
|
||||
{
|
||||
par1NBTTagCompound.setBoolean("powered", true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* (abstract) Protected helper method to read subclass entity data from NBT.
|
||||
*/
|
||||
public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound)
|
||||
{
|
||||
super.readEntityFromNBT(par1NBTTagCompound);
|
||||
this.dataWatcher.updateObject(17, Byte.valueOf((byte)(par1NBTTagCompound.getBoolean("powered") ? 1 : 0)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Called to update the entity's position/logic.
|
||||
*/
|
||||
public void onUpdate()
|
||||
{
|
||||
if (this.isEntityAlive())
|
||||
{
|
||||
this.lastActiveTime = this.timeSinceIgnited;
|
||||
int var1 = this.getCreeperState();
|
||||
|
||||
if (var1 > 0 && this.timeSinceIgnited == 0)
|
||||
{
|
||||
this.worldObj.playSoundAtEntity(this, "random.fuse", 1.0F, 0.5F);
|
||||
}
|
||||
|
||||
this.timeSinceIgnited += var1;
|
||||
|
||||
if (this.timeSinceIgnited < 0)
|
||||
{
|
||||
this.timeSinceIgnited = 0;
|
||||
}
|
||||
|
||||
if (this.timeSinceIgnited >= 30)
|
||||
{
|
||||
this.timeSinceIgnited = 30;
|
||||
|
||||
if (!this.worldObj.isRemote)
|
||||
{
|
||||
if (this.getPowered())
|
||||
{
|
||||
//this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, 6.0F);
|
||||
}
|
||||
else
|
||||
{
|
||||
//this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, 3.0F);
|
||||
}
|
||||
|
||||
this.setDead();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
super.onUpdate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sound this mob makes when it is hurt.
|
||||
*/
|
||||
protected String getHurtSound()
|
||||
{
|
||||
return "mob.creeper";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sound this mob makes on death.
|
||||
*/
|
||||
protected String getDeathSound()
|
||||
{
|
||||
return "mob.creeperdeath";
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the mob's health reaches 0.
|
||||
*/
|
||||
public void onDeath(DamageSource par1DamageSource)
|
||||
{
|
||||
super.onDeath(par1DamageSource);
|
||||
|
||||
if (par1DamageSource.getEntity() instanceof EntitySkeleton)
|
||||
{
|
||||
this.dropItem(Item.record13.shiftedIndex + this.rand.nextInt(10), 1);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean attackEntityAsMob(Entity par1Entity)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the creeper is powered by a lightning bolt.
|
||||
*/
|
||||
public boolean getPowered()
|
||||
{
|
||||
return this.dataWatcher.getWatchableObjectByte(17) == 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the item ID for the item the mob drops on death.
|
||||
*/
|
||||
protected int getDropItemId()
|
||||
{
|
||||
return Item.gunpowder.shiftedIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current state of creeper, -1 is idle, 1 is 'in fuse'
|
||||
*/
|
||||
public int getCreeperState()
|
||||
{
|
||||
return this.dataWatcher.getWatchableObjectByte(16);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the state of creeper, -1 to idle and 1 to be 'in fuse'
|
||||
*/
|
||||
public void setCreeperState(int par1)
|
||||
{
|
||||
this.dataWatcher.updateObject(16, Byte.valueOf((byte)par1));
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a lightning bolt hits the entity.
|
||||
*/
|
||||
public void onStruckByLightning(EntityLightningBolt par1EntityLightningBolt)
|
||||
{
|
||||
super.onStruckByLightning(par1EntityLightningBolt);
|
||||
this.dataWatcher.updateObject(17, Byte.valueOf((byte)1));
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue