Merge branch 'power' into builder

This commit is contained in:
CovertJaguar 2013-07-04 03:22:41 -07:00
commit 93409516b1
15 changed files with 144 additions and 247 deletions

View file

@ -0,0 +1,24 @@
/*
* Copyright (c) SpaceToad, 2011-2012
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.api.power;
import net.minecraftforge.common.ForgeDirection;
/**
* Essentially only used for Wooden Power Pipe connection rules.
*
* This Tile Entity interface allows you to indicate that a block can emit power
* from a specific side.
*
* @author CovertJaguar <http://www.railcraft.info/>
*/
public interface IPowerEmitter {
public boolean canEmitPowerFrom(ForgeDirection side);
}

View file

@ -11,11 +11,37 @@ import buildcraft.api.power.PowerHandler.PowerReceiver;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ForgeDirection;
/**
* This interface should be implemented by any Tile Entity that wishes to be
* able to receive power.
*
* @author CovertJaguar <http://www.railcraft.info/>
*/
public interface IPowerReceptor { public interface IPowerReceptor {
/**
* Get the PowerReceiver for this side of the block. You can return the same
* PowerReceiver for all sides or one for each side.
*
* You should NOT return null to this method unless you mean to NEVER
* receive power from that side. Returning null, after previous returning a
* PowerReceiver, will most likely cause pipe connections to derp out and
* engines to eventually explode.
*
* @param side
* @return
*/
public PowerReceiver getPowerReceiver(ForgeDirection side); public PowerReceiver getPowerReceiver(ForgeDirection side);
/**
* Call back from the PowerHandler that is called when the stored power
* exceeds the activation power.
*
* It can be triggered by update() calls or power modification calls.
*
* @param workProvider
*/
public void doWork(PowerHandler workProvider); public void doWork(PowerHandler workProvider);
public World getWorldObj(); public World getWorldObj();
} }

View file

@ -80,7 +80,7 @@ public final class PowerHandler {
private final SafeTimeTracker doWorkTracker = new SafeTimeTracker(); private final SafeTimeTracker doWorkTracker = new SafeTimeTracker();
private final SafeTimeTracker sourcesTracker = new SafeTimeTracker(); private final SafeTimeTracker sourcesTracker = new SafeTimeTracker();
private final SafeTimeTracker perditionTracker = new SafeTimeTracker(); private final SafeTimeTracker perditionTracker = new SafeTimeTracker();
public final int[] powerSources = {0, 0, 0, 0, 0, 0}; public final int[] powerSources = new int[6];
public final IPowerReceptor receptor; public final IPowerReceptor receptor;
private PerditionCalculator perdition; private PerditionCalculator perdition;
private final PowerReceiver receiver; private final PowerReceiver receiver;

View file

@ -1,12 +1,10 @@
/** /**
* Copyright (c) SpaceToad, 2011 * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com
* http://www.mod-buildcraft.com
* *
* BuildCraft is distributed under the terms of the Minecraft Mod Public * BuildCraft is distributed under the terms of the Minecraft Mod Public License
* License 1.0, or MMPL. Please check the contents of the license located in * 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt * http://www.mod-buildcraft.com/MMPL-1.0.txt
*/ */
package buildcraft.core; package buildcraft.core;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
@ -21,12 +19,11 @@ public class EntityBlock extends Entity {
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public Icon texture; public Icon texture;
public float shadowSize = 0; public float shadowSize = 0;
public float rotationX = 0; public float rotationX = 0;
public float rotationY = 0; public float rotationY = 0;
public float rotationZ = 0; public float rotationZ = 0;
public double iSize, jSize, kSize; public double iSize, jSize, kSize;
private int brightness = -1;
public EntityBlock(World world) { public EntityBlock(World world) {
super(world); super(world);
@ -68,28 +65,31 @@ public class EntityBlock extends Entity {
setPosition(posX + d, posY + d1, posZ + d2); setPosition(posX + d, posY + d1, posZ + d2);
} }
public void setBrightness(int brightness) {
this.brightness = brightness;
}
@Override @Override
protected void entityInit() { protected void entityInit() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
} }
@Override @Override
protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { protected void readEntityFromNBT(NBTTagCompound data) {
iSize = nbttagcompound.getDouble("iSize"); iSize = data.getDouble("iSize");
jSize = nbttagcompound.getDouble("jSize"); jSize = data.getDouble("jSize");
kSize = nbttagcompound.getDouble("kSize"); kSize = data.getDouble("kSize");
} }
@Override @Override
protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { protected void writeEntityToNBT(NBTTagCompound data) {
nbttagcompound.setDouble("iSize", iSize); data.setDouble("iSize", iSize);
nbttagcompound.setDouble("jSize", jSize); data.setDouble("jSize", jSize);
nbttagcompound.setDouble("kSize", kSize); data.setDouble("kSize", kSize);
} }
@Override @Override
public int getBrightnessForRender(float par1) { public int getBrightnessForRender(float par1) {
return 210; return brightness > 0 ? brightness : super.getBrightnessForRender(par1);
} }
} }

View file

@ -330,6 +330,7 @@ public class Utils {
} }
EntityBlock block = CoreProxy.proxy.newEntityBlock(world, i, j, k, iSize, jSize, kSize, kind); EntityBlock block = CoreProxy.proxy.newEntityBlock(world, i, j, k, iSize, jSize, kSize, kind);
block.setBrightness(210);
world.spawnEntityInWorld(block); world.spawnEntityInWorld(block);

View file

@ -19,6 +19,7 @@ import buildcraft.BuildCraftEnergy;
import buildcraft.api.core.Position; import buildcraft.api.core.Position;
import buildcraft.api.gates.IOverrideDefaultTriggers; import buildcraft.api.gates.IOverrideDefaultTriggers;
import buildcraft.api.gates.ITrigger; import buildcraft.api.gates.ITrigger;
import buildcraft.api.power.IPowerEmitter;
import buildcraft.api.power.IPowerReceptor; import buildcraft.api.power.IPowerReceptor;
import buildcraft.api.power.PowerHandler; import buildcraft.api.power.PowerHandler;
import buildcraft.api.power.PowerHandler.PowerReceiver; import buildcraft.api.power.PowerHandler.PowerReceiver;
@ -35,7 +36,7 @@ import net.minecraft.inventory.ICrafting;
import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagFloat; import net.minecraft.nbt.NBTTagFloat;
public abstract class TileEngine extends TileBuildCraft implements IPowerReceptor, IInventory, IOverrideDefaultTriggers, IPipeConnection { public abstract class TileEngine extends TileBuildCraft implements IPowerReceptor, IPowerEmitter, IInventory, IOverrideDefaultTriggers, IPipeConnection {
public enum EnergyStage { public enum EnergyStage {
@ -495,6 +496,11 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
return with != orientation; return with != orientation;
} }
@Override
public boolean canEmitPowerFrom(ForgeDirection side) {
return side == orientation;
}
public void checkRedstonePower() { public void checkRedstonePower() {
isRedstonePowered = worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord); isRedstonePowered = worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord);
} }

View file

@ -40,7 +40,7 @@ public class GuiHandler implements IGuiHandler {
switch (ID) { switch (ID) {
case GuiIds.PIPE_DIAMOND: case GuiIds.PIPE_DIAMOND:
return new ContainerDiamondPipe(player.inventory, (PipeLogicDiamond) pipe.pipe.logic); return new ContainerDiamondPipe(player.inventory, ((PipeLogicDiamond) pipe.pipe.logic).getFilters());
case GuiIds.PIPE_EMERALD_ITEM: case GuiIds.PIPE_EMERALD_ITEM:
return new ContainerEmeraldPipe(player.inventory, (IInventory) pipe.pipe); return new ContainerEmeraldPipe(player.inventory, (IInventory) pipe.pipe);

View file

@ -13,6 +13,7 @@ import net.minecraftforge.common.ForgeDirection;
import buildcraft.BuildCraftCore; import buildcraft.BuildCraftCore;
import buildcraft.api.core.SafeTimeTracker; import buildcraft.api.core.SafeTimeTracker;
import buildcraft.api.gates.ITrigger; import buildcraft.api.gates.ITrigger;
import buildcraft.api.power.IPowerEmitter;
import buildcraft.api.power.IPowerReceptor; import buildcraft.api.power.IPowerReceptor;
import buildcraft.api.power.PowerHandler.PowerReceiver; import buildcraft.api.power.PowerHandler.PowerReceiver;
import buildcraft.api.power.PowerHandler.Type; import buildcraft.api.power.PowerHandler.Type;
@ -76,9 +77,13 @@ public class PipeTransportPower extends PipeTransport {
if (tile instanceof IPowerReceptor) { if (tile instanceof IPowerReceptor) {
IPowerReceptor receptor = (IPowerReceptor) tile; IPowerReceptor receptor = (IPowerReceptor) tile;
PowerReceiver receiver = receptor.getPowerReceiver(side.getOpposite()); PowerReceiver receiver = receptor.getPowerReceiver(side.getOpposite());
if (receiver == null) if (receiver != null && receiver.getType().canReceiveFromPipes())
return false; return true;
if (container.pipe instanceof PipePowerWood || receiver.getType().canReceiveFromPipes()) }
if (container.pipe instanceof PipePowerWood && tile instanceof IPowerEmitter) {
IPowerEmitter emitter = (IPowerEmitter) tile;
if (emitter.canEmitPowerFrom(side.getOpposite()))
return true; return true;
} }
@ -141,7 +146,12 @@ public class PipeTransportPower extends PipeTransport {
if (j != i && powerQuery[j] > 0) { if (j != i && powerQuery[j] > 0) {
float watts = 0.0F; float watts = 0.0F;
if (tiles[j] instanceof TileGenericPipe) { PowerReceiver prov = getReceiverOnSide(ForgeDirection.VALID_DIRECTIONS[j]);
if (prov != null && prov.powerRequest() > 0) {
watts = (internalPower[i] / totalPowerQuery) * powerQuery[j];
watts = prov.receiveEnergy(Type.PIPE, watts, ForgeDirection.VALID_DIRECTIONS[j].getOpposite());
internalPower[i] -= watts;
} else if (tiles[j] instanceof TileGenericPipe) {
watts = (internalPower[i] / totalPowerQuery) * powerQuery[j]; watts = (internalPower[i] / totalPowerQuery) * powerQuery[j];
TileGenericPipe nearbyTile = (TileGenericPipe) tiles[j]; TileGenericPipe nearbyTile = (TileGenericPipe) tiles[j];
@ -149,15 +159,6 @@ public class PipeTransportPower extends PipeTransport {
watts = nearbyTransport.receiveEnergy(ForgeDirection.VALID_DIRECTIONS[j].getOpposite(), watts); watts = nearbyTransport.receiveEnergy(ForgeDirection.VALID_DIRECTIONS[j].getOpposite(), watts);
internalPower[i] -= watts; internalPower[i] -= watts;
} else if (tiles[j] instanceof IPowerReceptor) {
IPowerReceptor pow = (IPowerReceptor) tiles[j];
PowerReceiver prov = pow.getPowerReceiver(ForgeDirection.VALID_DIRECTIONS[j].getOpposite());
if (prov != null && prov.getType().canReceiveFromPipes() && prov.powerRequest() > 0) {
watts = (internalPower[i] / totalPowerQuery) * powerQuery[j];
watts = prov.receiveEnergy(Type.PIPE, watts, ForgeDirection.VALID_DIRECTIONS[j].getOpposite());
internalPower[i] -= watts;
}
} }
displayPower[j] += watts; displayPower[j] += watts;
@ -183,18 +184,15 @@ public class PipeTransportPower extends PipeTransport {
overload = OVERLOAD_TICKS; overload = OVERLOAD_TICKS;
} }
// Compute the tiles requesting energy that are not pipes // Compute the tiles requesting energy that are not power pipes
for (int i = 0; i < 6; ++i) { for (int i = 0; i < 6; ++i) {
if (tiles[i] instanceof IPowerReceptor && !(tiles[i] instanceof TileGenericPipe)) { PowerReceiver prov = getReceiverOnSide(ForgeDirection.VALID_DIRECTIONS[i]);
IPowerReceptor receptor = (IPowerReceptor) tiles[i]; if (prov != null) {
PowerReceiver prov = receptor.getPowerReceiver(ForgeDirection.VALID_DIRECTIONS[i].getOpposite()); float request = prov.powerRequest();
if (prov != null && prov.getType().canReceiveFromPipes()) {
float request = prov.powerRequest();
if (request > 0) { if (request > 0) {
requestEnergy(ForgeDirection.VALID_DIRECTIONS[i], request); requestEnergy(ForgeDirection.VALID_DIRECTIONS[i], request);
}
} }
} }
} }
@ -251,6 +249,19 @@ public class PipeTransportPower extends PipeTransport {
} }
private PowerReceiver getReceiverOnSide(ForgeDirection side) {
TileEntity tile = tiles[side.ordinal()];
if (!(tile instanceof IPowerReceptor))
return null;
IPowerReceptor receptor = (IPowerReceptor) tile;
PowerReceiver receiver = receptor.getPowerReceiver(side.getOpposite());
if (receiver == null)
return null;
if (!receiver.getType().canReceiveFromPipes())
return null;
return receiver;
}
public boolean isOverloaded() { public boolean isOverloaded() {
return overload >= OVERLOAD_TICKS; return overload >= OVERLOAD_TICKS;
} }
@ -279,6 +290,11 @@ public class PipeTransportPower extends PipeTransport {
} }
} }
/**
* Do NOT ever call this from outside Buildcraft unless you are a pipe mod.
* It is NOT part of the API. All power input MUST go through designated
* input pipes, such as Wooden Power Pipes.
*/
public float receiveEnergy(ForgeDirection from, float val) { public float receiveEnergy(ForgeDirection from, float val) {
step(); step();
if (this.container.pipe instanceof IPipeTransportPowerHook) { if (this.container.pipe instanceof IPipeTransportPowerHook) {

View file

@ -32,7 +32,7 @@ public class GuiDiamondPipe extends GuiBuildCraft {
@Override @Override
protected void drawGuiContainerForegroundLayer(int par1, int par2) { protected void drawGuiContainerForegroundLayer(int par1, int par2) {
fontRenderer.drawString(filterInventory.getInvName(), getCenteredOffset(filterInventory.getInvName()), 6, 0x404040); fontRenderer.drawString(filterInventory.getFilters().getInvName(), getCenteredOffset(filterInventory.getFilters().getInvName()), 6, 0x404040);
fontRenderer.drawString(StringUtils.localize("gui.inventory"), 8, ySize - 97, 0x404040); fontRenderer.drawString(StringUtils.localize("gui.inventory"), 8, ySize - 97, 0x404040);
} }

View file

@ -32,7 +32,7 @@ public class GuiEmeraldPipe extends GuiBuildCraft {
@Override @Override
protected void drawGuiContainerForegroundLayer(int par1, int par2) { protected void drawGuiContainerForegroundLayer(int par1, int par2) {
fontRenderer.drawString(filterInventory.getInvName(), getCenteredOffset(filterInventory.getInvName()), 6, 0x404040); fontRenderer.drawString(filterInventory.getFilters().getInvName(), getCenteredOffset(filterInventory.getFilters().getInvName()), 6, 0x404040);
fontRenderer.drawString(StringUtils.localize("gui.inventory"), 8, ySize - 93, 0x404040); fontRenderer.drawString(StringUtils.localize("gui.inventory"), 8, ySize - 93, 0x404040);
} }

View file

@ -322,7 +322,7 @@ public class PacketHandlerTransport implements IPacketHandler {
if (!(pipe.pipe.logic instanceof PipeLogicDiamond)) if (!(pipe.pipe.logic instanceof PipeLogicDiamond))
return; return;
((PipeLogicDiamond) pipe.pipe.logic).setInventorySlotContents(packet.slot, packet.stack); ((PipeLogicDiamond) pipe.pipe.logic).getFilters().setInventorySlotContents(packet.slot, packet.stack);
} }
/** /**
@ -339,7 +339,7 @@ public class PacketHandlerTransport implements IPacketHandler {
if (!(pipe.pipe instanceof PipeItemsEmerald)) if (!(pipe.pipe instanceof PipeItemsEmerald))
return; return;
((PipeItemsEmerald) pipe.pipe).setInventorySlotContents(packet.slot, packet.stack); ((PipeItemsEmerald) pipe.pipe).getFilters().setInventorySlotContents(packet.slot, packet.stack);
} }
/** /**

View file

@ -70,7 +70,7 @@ public class PipeItemsDiamond extends Pipe implements IPipeTransportItemsHook, I
// no breaks here. // no breaks here.
PipeLogicDiamond diamondLogic = (PipeLogicDiamond) logic; PipeLogicDiamond diamondLogic = (PipeLogicDiamond) logic;
for (int slot = 0; slot < 9; ++slot) { for (int slot = 0; slot < 9; ++slot) {
ItemStack stack = diamondLogic.getStackInSlot(dir.ordinal() * 9 + slot); ItemStack stack = diamondLogic.getFilters().getStackInSlot(dir.ordinal() * 9 + slot);
if (stack != null) { if (stack != null) {
foundFilter = true; foundFilter = true;

View file

@ -32,9 +32,9 @@ import buildcraft.transport.BlockGenericPipe;
import buildcraft.transport.PipeIconProvider; import buildcraft.transport.PipeIconProvider;
import buildcraft.transport.PipeTransportItems; import buildcraft.transport.PipeTransportItems;
public class PipeItemsEmerald extends PipeItemsWood implements ISpecialInventory, IClientState { public class PipeItemsEmerald extends PipeItemsWood implements IClientState {
private SimpleInventory filters = new SimpleInventory(9, "items", 1); private SimpleInventory filters = new SimpleInventory(9, "Filters", 1);
private int currentFilter = 0; private int currentFilter = 0;
protected PipeItemsEmerald(int itemID, PipeTransportItems transport) { protected PipeItemsEmerald(int itemID, PipeTransportItems transport) {
@ -208,92 +208,8 @@ public class PipeItemsEmerald extends PipeItemsWood implements ISpecialInventory
readFromNBT((NBTTagCompound) nbt); readFromNBT((NBTTagCompound) nbt);
} }
} }
/* ISPECIALINVENTORY */ public IInventory getFilters(){
@Override return filters;
public int addItem(ItemStack stack, boolean doAdd, ForgeDirection from) {
return 0;
}
@Override
public ItemStack[] extractItem(boolean doRemove, ForgeDirection from, int maxItemCount) {
return new ItemStack[0];
}
/* IINVENTORY IMPLEMENTATION */
@Override
public int getSizeInventory() {
return filters.getSizeInventory();
}
@Override
public ItemStack getStackInSlot(int i) {
return filters.getStackInSlot(i);
}
@Override
public String getInvName() {
return "Filters";
}
@Override
public int getInventoryStackLimit() {
return filters.getInventoryStackLimit();
}
@Override
public ItemStack getStackInSlotOnClosing(int i) {
return filters.getStackInSlotOnClosing(i);
}
@Override
public void onInventoryChanged() {
filters.onInventoryChanged();
}
@Override
public boolean isUseableByPlayer(EntityPlayer var1) {
return worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) == container;
}
@Override
public void openChest() {
}
@Override
public void closeChest() {
}
@Override
public ItemStack decrStackSize(int i, int j) {
ItemStack stack = filters.decrStackSize(i, j);
if (CoreProxy.proxy.isSimulating(worldObj)) {
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
return stack;
}
@Override
public void setInventorySlotContents(int i, ItemStack itemstack) {
filters.setInventorySlotContents(i, itemstack);
if (CoreProxy.proxy.isSimulating(worldObj)) {
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
}
@Override
public boolean isInvNameLocalized() {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean isStackValidForSlot(int i, ItemStack itemstack) {
// TODO Auto-generated method stub
return false;
} }
} }

View file

@ -1,29 +1,25 @@
/** /**
* Copyright (c) SpaceToad, 2011 * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com
* http://www.mod-buildcraft.com
* *
* BuildCraft is distributed under the terms of the Minecraft Mod Public * BuildCraft is distributed under the terms of the Minecraft Mod Public License
* License 1.0, or MMPL. Please check the contents of the license located in * 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt * http://www.mod-buildcraft.com/MMPL-1.0.txt
*/ */
package buildcraft.transport.pipes; package buildcraft.transport.pipes;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.ForgeDirection;
import buildcraft.BuildCraftTransport; import buildcraft.BuildCraftTransport;
import buildcraft.api.inventory.ISpecialInventory;
import buildcraft.core.GuiIds; import buildcraft.core.GuiIds;
import buildcraft.core.proxy.CoreProxy; import buildcraft.core.proxy.CoreProxy;
import buildcraft.core.inventory.SimpleInventory; import buildcraft.core.inventory.SimpleInventory;
import buildcraft.transport.BlockGenericPipe; import buildcraft.transport.BlockGenericPipe;
import net.minecraft.inventory.IInventory;
public class PipeLogicDiamond extends PipeLogic implements ISpecialInventory { public class PipeLogicDiamond extends PipeLogic {
private SimpleInventory filters = new SimpleInventory(54, "items", 1); private SimpleInventory filters = new SimpleInventory(54, "Filters", 1);
/* PIPE LOGIC */ /* PIPE LOGIC */
@Override @Override
@ -57,94 +53,7 @@ public class PipeLogicDiamond extends PipeLogic implements ISpecialInventory {
filters.writeToNBT(nbttagcompound); filters.writeToNBT(nbttagcompound);
} }
/* ISPECIALINVENTORY */ public IInventory getFilters() {
@Override return filters;
public int addItem(ItemStack stack, boolean doAdd, ForgeDirection from) {
return 0;
} }
@Override
public ItemStack[] extractItem(boolean doRemove, ForgeDirection from, int maxItemCount) {
return new ItemStack[0];
}
/* IINVENTORY IMPLEMENTATION */
@Override
public int getSizeInventory() {
return filters.getSizeInventory();
}
@Override
public ItemStack getStackInSlot(int i) {
return filters.getStackInSlot(i);
}
@Override
public String getInvName() {
return "Filters";
}
@Override
public int getInventoryStackLimit() {
return filters.getInventoryStackLimit();
}
@Override
public ItemStack getStackInSlotOnClosing(int i) {
return filters.getStackInSlotOnClosing(i);
}
@Override
public void onInventoryChanged() {
filters.onInventoryChanged();
}
@Override
public boolean isUseableByPlayer(EntityPlayer var1) {
return worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) == container;
}
@Override
public void openChest() {
}
@Override
public void closeChest() {
}
@Override
public ItemStack decrStackSize(int i, int j) {
ItemStack stack = filters.decrStackSize(i, j);
if (CoreProxy.proxy.isSimulating(worldObj)) {
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
return stack;
}
@Override
public void setInventorySlotContents(int i, ItemStack itemstack) {
filters.setInventorySlotContents(i, itemstack);
if (CoreProxy.proxy.isSimulating(worldObj)) {
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
}
@Override
public boolean isInvNameLocalized()
{
// TODO Auto-generated method stub
return false;
}
@Override
public boolean isStackValidForSlot(int i, ItemStack itemstack)
{
// TODO Auto-generated method stub
return false;
}
} }

View file

@ -50,16 +50,7 @@ public class PipePowerWood extends Pipe implements IPowerReceptor {
@Override @Override
public int getIconIndex(ForgeDirection direction) { public int getIconIndex(ForgeDirection direction) {
if (direction == ForgeDirection.UNKNOWN) return standardIconIndex;
return standardIconIndex;
else {
int metadata = worldObj.getBlockMetadata(xCoord, yCoord, zCoord);
if (metadata == direction.ordinal())
return solidIconIndex;
else
return standardIconIndex;
}
} }
@Override @Override
@ -94,8 +85,10 @@ public class PipePowerWood extends Pipe implements IPowerReceptor {
} }
} }
if (sources <= 0) if (sources <= 0) {
powerHandler.useEnergy(5, 5, true);
return; return;
}
float energyToRemove; float energyToRemove;
@ -139,6 +132,9 @@ public class PipePowerWood extends Pipe implements IPowerReceptor {
public void writeToNBT(NBTTagCompound data) { public void writeToNBT(NBTTagCompound data) {
super.writeToNBT(data); super.writeToNBT(data);
powerHandler.writeToNBT(data); powerHandler.writeToNBT(data);
for (int i = 0; i < ForgeDirection.VALID_DIRECTIONS.length; i++) {
data.setBoolean("powerSources[" + i + "]", powerSources[i]);
}
} }
@Override @Override
@ -146,5 +142,8 @@ public class PipePowerWood extends Pipe implements IPowerReceptor {
super.readFromNBT(data); super.readFromNBT(data);
powerHandler.readFromNBT(data); powerHandler.readFromNBT(data);
initPowerProvider(); initPowerProvider();
for (int i = 0; i < ForgeDirection.VALID_DIRECTIONS.length; i++) {
powerSources[i] = data.getBoolean("powerSources[" + i + "]");
}
} }
} }