Updated to UE 3.1.0
This commit is contained in:
parent
dac6912b3c
commit
dd37a14a0c
|
@ -177,7 +177,7 @@ public class TileEngineeringTable extends TileAdvanced implements IPacketReceive
|
|||
|
||||
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
TileEntity tile = new Vector3(this).modifyPositionFromSide(dir).getTileEntity(worldObj);
|
||||
TileEntity tile = new Vector3(this).translate(dir).getTileEntity(worldObj);
|
||||
|
||||
if (tile instanceof IInventory)
|
||||
{
|
||||
|
@ -222,7 +222,7 @@ public class TileEngineeringTable extends TileAdvanced implements IPacketReceive
|
|||
|
||||
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
TileEntity tile = new Vector3(this).modifyPositionFromSide(dir).getTileEntity(worldObj);
|
||||
TileEntity tile = new Vector3(this).translate(dir).getTileEntity(worldObj);
|
||||
|
||||
if (tile instanceof IInventory)
|
||||
{
|
||||
|
@ -489,7 +489,7 @@ public class TileEngineeringTable extends TileAdvanced implements IPacketReceive
|
|||
|
||||
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
TileEntity tile = new Vector3(this).modifyPositionFromSide(dir).getTileEntity(worldObj);
|
||||
TileEntity tile = new Vector3(this).translate(dir).getTileEntity(worldObj);
|
||||
|
||||
if (tile instanceof IInventory)
|
||||
{
|
||||
|
|
|
@ -188,9 +188,9 @@ public class TileFirebox extends TileElectricalInventory implements IPacketRecei
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnect(ForgeDirection direction)
|
||||
public boolean canConnect(ForgeDirection direction, Object obj)
|
||||
{
|
||||
return isElectrical() && super.canConnect(direction);
|
||||
return isElectrical() && super.canConnect(direction, obj);
|
||||
}
|
||||
|
||||
public boolean isElectrical()
|
||||
|
|
|
@ -75,7 +75,7 @@ public class BlockImprinter extends BlockTile
|
|||
if (te instanceof TileImprinter)
|
||||
{
|
||||
TileImprinter tile = (TileImprinter) te;
|
||||
int idOnTop = ((VectorWorld) new VectorWorld(world, x, y, z).modifyPositionFromSide(ForgeDirection.getOrientation(1))).getBlockID();
|
||||
int idOnTop = ((VectorWorld) new VectorWorld(world, x, y, z).translate(ForgeDirection.getOrientation(1))).getBlockID();
|
||||
|
||||
if (Block.pistonMoving.blockID == blockID)
|
||||
{
|
||||
|
|
|
@ -2,10 +2,10 @@ dir.development=./
|
|||
dir.mcp=${dir.development}forge/mcp
|
||||
version.minecraft=1.6.4
|
||||
version.forge=9.11.1.964
|
||||
version.universalelectricity=3.0.+
|
||||
version.universalelectricity=3.1.+
|
||||
version.calclaviacore=1.1.+
|
||||
version.cclib=1.0.0.50
|
||||
version.fmp=1.0.0.235
|
||||
version.cclib=1.0.0.61
|
||||
version.fmp=1.0.0.244
|
||||
version.mod.major=0
|
||||
version.mod.minor=3
|
||||
version.mod.revis=1
|
|
@ -18,118 +18,116 @@ import com.google.common.io.ByteArrayDataInput;
|
|||
/** @author Darkguardsman */
|
||||
public class TileCharger extends TileExternalInventory implements IRotatable, IEnergyInterface, IPacketReceiverWithID
|
||||
{
|
||||
public ChargerMode currentMode = ChargerMode.SINGLE;
|
||||
private long lastPacket = 0;
|
||||
public ChargerMode currentMode = ChargerMode.SINGLE;
|
||||
private long lastPacket = 0;
|
||||
|
||||
public static enum ChargerMode
|
||||
{
|
||||
SINGLE(1),
|
||||
DUAL(2),
|
||||
MULTI(4);
|
||||
public final int limit;
|
||||
public static enum ChargerMode
|
||||
{
|
||||
SINGLE(1), DUAL(2), MULTI(4);
|
||||
public final int limit;
|
||||
|
||||
private ChargerMode(int limit)
|
||||
{
|
||||
this.limit = limit;
|
||||
}
|
||||
}
|
||||
private ChargerMode(int limit)
|
||||
{
|
||||
this.limit = limit;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUpdate()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean canUpdate()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ForgeDirection getDirection()
|
||||
{
|
||||
return ForgeDirection.getOrientation(this.worldObj.getBlockMetadata(xCoord, yCoord, zCoord));
|
||||
}
|
||||
@Override
|
||||
public ForgeDirection getDirection()
|
||||
{
|
||||
return ForgeDirection.getOrientation(this.worldObj.getBlockMetadata(xCoord, yCoord, zCoord));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDirection(ForgeDirection direction)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
@Override
|
||||
public void setDirection(ForgeDirection direction)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnect(ForgeDirection direction)
|
||||
{
|
||||
return direction == this.getDirection().getOpposite();
|
||||
}
|
||||
@Override
|
||||
public boolean canConnect(ForgeDirection direction, Object obj)
|
||||
{
|
||||
return obj instanceof IEnergyInterface && direction == this.getDirection().getOpposite();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long onReceiveEnergy(ForgeDirection from, long receive, boolean doReceive)
|
||||
{
|
||||
long energyUsed = 0;
|
||||
long energyLeft = receive;
|
||||
for (int i = 0; i < this.getSizeInventory(); i++)
|
||||
{
|
||||
long input = CompatibilityModule.chargeItem(this.getStackInSlot(i), energyLeft, true);
|
||||
energyUsed += input;
|
||||
energyLeft -= input;
|
||||
if (energyLeft <= 0)
|
||||
break;
|
||||
}
|
||||
if (energyUsed > 0 && System.currentTimeMillis() - this.lastPacket >= 50)
|
||||
{
|
||||
this.lastPacket = System.currentTimeMillis();
|
||||
this.worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
return energyUsed;
|
||||
}
|
||||
@Override
|
||||
public long onReceiveEnergy(ForgeDirection from, long receive, boolean doReceive)
|
||||
{
|
||||
long energyUsed = 0;
|
||||
long energyLeft = receive;
|
||||
for (int i = 0; i < this.getSizeInventory(); i++)
|
||||
{
|
||||
long input = CompatibilityModule.chargeItem(this.getStackInSlot(i), energyLeft, true);
|
||||
energyUsed += input;
|
||||
energyLeft -= input;
|
||||
if (energyLeft <= 0)
|
||||
break;
|
||||
}
|
||||
if (energyUsed > 0 && System.currentTimeMillis() - this.lastPacket >= 50)
|
||||
{
|
||||
this.lastPacket = System.currentTimeMillis();
|
||||
this.worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
return energyUsed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long onExtractEnergy(ForgeDirection from, long extract, boolean doExtract)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public long onExtractEnergy(ForgeDirection from, long extract, boolean doExtract)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket()
|
||||
{
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
this.writeToNBT(nbt);
|
||||
return ResonantInduction.PACKET_TILE.getPacketWithID(0, this, nbt);
|
||||
}
|
||||
@Override
|
||||
public Packet getDescriptionPacket()
|
||||
{
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
this.writeToNBT(nbt);
|
||||
return ResonantInduction.PACKET_TILE.getPacketWithID(0, this, nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onReceivePacket(int id, ByteArrayDataInput data, EntityPlayer player, Object... extra)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (id == 0)
|
||||
{
|
||||
this.readFromNBT(PacketHandler.readNBTTagCompound(data));
|
||||
return true;
|
||||
}
|
||||
else if (id == 1)
|
||||
{
|
||||
@Override
|
||||
public boolean onReceivePacket(int id, ByteArrayDataInput data, EntityPlayer player, Object... extra)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (id == 0)
|
||||
{
|
||||
this.readFromNBT(PacketHandler.readNBTTagCompound(data));
|
||||
return true;
|
||||
}
|
||||
else if (id == 1)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt)
|
||||
{
|
||||
this.currentMode = ChargerMode.values()[nbt.getInteger("chargerMode")];
|
||||
this.inventory = new ExternalInventory(this, this.currentMode.limit);
|
||||
super.readFromNBT(nbt);
|
||||
}
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt)
|
||||
{
|
||||
this.currentMode = ChargerMode.values()[nbt.getInteger("chargerMode")];
|
||||
this.inventory = new ExternalInventory(this, this.currentMode.limit);
|
||||
super.readFromNBT(nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt)
|
||||
{
|
||||
super.writeToNBT(nbt);
|
||||
nbt.setInteger("chargerMode", this.currentMode.ordinal());
|
||||
}
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt)
|
||||
{
|
||||
super.writeToNBT(nbt);
|
||||
nbt.setInteger("chargerMode", this.currentMode.ordinal());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,134 +0,0 @@
|
|||
package resonantinduction.electrical.furnace;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockFurnace;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
/**
|
||||
* @author Calclavia
|
||||
*
|
||||
*/
|
||||
public class BlockAdvancedFurnace extends BlockFurnace
|
||||
{
|
||||
@SideOnly(Side.CLIENT)
|
||||
private Icon furnaceIconTop;
|
||||
@SideOnly(Side.CLIENT)
|
||||
private Icon furnaceIconFront;
|
||||
@SideOnly(Side.CLIENT)
|
||||
private Icon furnaceIconFrontBurn;
|
||||
|
||||
protected BlockAdvancedFurnace(int id, boolean isBurning)
|
||||
{
|
||||
super(id, isBurning);
|
||||
this.setHardness(3.5F);
|
||||
this.setStepSound(soundStoneFootstep);
|
||||
this.setUnlocalizedName("furnace");
|
||||
|
||||
if (isBurning)
|
||||
{
|
||||
this.setLightValue(0.875F);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setCreativeTab(CreativeTabs.tabDecorations);
|
||||
}
|
||||
}
|
||||
|
||||
public static BlockAdvancedFurnace createNew(boolean isBurning)
|
||||
{
|
||||
int id = Block.furnaceIdle.blockID;
|
||||
|
||||
if (isBurning)
|
||||
{
|
||||
id = Block.furnaceBurning.blockID;
|
||||
}
|
||||
|
||||
Block.blocksList[id] = null;
|
||||
Item.itemsList[id] = null;
|
||||
return new BlockAdvancedFurnace(id, isBurning);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
this.blockIcon = par1IconRegister.registerIcon("furnace_side");
|
||||
this.furnaceIconFront = par1IconRegister.registerIcon("furnace_front_off");
|
||||
this.furnaceIconFrontBurn = par1IconRegister.registerIcon("furnace_front_on");
|
||||
this.furnaceIconTop = par1IconRegister.registerIcon("furnace_top");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getBlockTexture(IBlockAccess access, int x, int y, int z, int side)
|
||||
{
|
||||
TileEntity tileEntity = access.getBlockTileEntity(x, y, z);
|
||||
int meta = access.getBlockMetadata(x, y, z);
|
||||
|
||||
if (((TileAdvancedFurnace) tileEntity).isBurning())
|
||||
{
|
||||
return side == 1 ? this.furnaceIconTop : (side == 0 ? this.furnaceIconTop : (side != meta ? this.blockIcon : this.furnaceIconFrontBurn));
|
||||
}
|
||||
else
|
||||
{
|
||||
return side == 1 ? this.furnaceIconTop : (side == 0 ? this.furnaceIconTop : (side != meta ? this.blockIcon : this.furnaceIconFront));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getIcon(int side, int meta)
|
||||
{
|
||||
return side == 1 ? this.furnaceIconTop : (side == 0 ? this.furnaceIconTop : (side != 3 ? this.blockIcon : this.furnaceIconFront));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void randomDisplayTick(World world, int x, int y, int z, Random par5Random)
|
||||
{
|
||||
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
|
||||
|
||||
if (((TileAdvancedFurnace) tileEntity).isBurning())
|
||||
{
|
||||
int l = world.getBlockMetadata(x, y, z);
|
||||
float f = x + 0.5F;
|
||||
float f1 = y + 0.0F + par5Random.nextFloat() * 6.0F / 16.0F;
|
||||
float f2 = z + 0.5F;
|
||||
float f3 = 0.52F;
|
||||
float f4 = par5Random.nextFloat() * 0.6F - 0.3F;
|
||||
|
||||
if (l == 4)
|
||||
{
|
||||
world.spawnParticle("smoke", f - f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle("flame", f - f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
else if (l == 5)
|
||||
{
|
||||
world.spawnParticle("smoke", f + f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle("flame", f + f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
else if (l == 2)
|
||||
{
|
||||
world.spawnParticle("smoke", f + f4, f1, f2 - f3, 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle("flame", f + f4, f1, f2 - f3, 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
else if (l == 3)
|
||||
{
|
||||
world.spawnParticle("smoke", f + f4, f1, f2 + f3, 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle("flame", f + f4, f1, f2 + f3, 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World par1World)
|
||||
{
|
||||
return new TileAdvancedFurnace();
|
||||
}
|
||||
}
|
|
@ -1,203 +0,0 @@
|
|||
package resonantinduction.electrical.furnace;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.FurnaceRecipes;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityFurnace;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import resonantinduction.core.ResonantInduction;
|
||||
import resonantinduction.core.Settings;
|
||||
import universalelectricity.api.CompatibilityModule;
|
||||
import universalelectricity.api.UniversalClass;
|
||||
import universalelectricity.api.energy.EnergyStorageHandler;
|
||||
import universalelectricity.api.energy.IEnergyContainer;
|
||||
import universalelectricity.api.energy.IEnergyInterface;
|
||||
import universalelectricity.api.vector.Vector3;
|
||||
import calclavia.lib.network.IPacketReceiver;
|
||||
import calclavia.lib.network.IPacketSender;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
||||
/**
|
||||
* Meant to replace the furnace class.
|
||||
*
|
||||
* @author Calclavia
|
||||
*
|
||||
*/
|
||||
@UniversalClass
|
||||
public class TileAdvancedFurnace extends TileEntityFurnace implements IEnergyInterface, IEnergyContainer, IPacketSender, IPacketReceiver
|
||||
{
|
||||
private static final float WATTAGE = 5;
|
||||
|
||||
private EnergyStorageHandler energy = new EnergyStorageHandler(Settings.FURNACE_WATTAGE * 5);
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
/**
|
||||
* Producing energy from coal.
|
||||
*/
|
||||
if (TileEntityFurnace.getItemBurnTime(this.getStackInSlot(1)) > 0)
|
||||
{
|
||||
boolean doBlockStateUpdate = this.furnaceBurnTime > 0;
|
||||
|
||||
if (!this.energy.isFull() && this.furnaceBurnTime == 0)
|
||||
{
|
||||
int burnTime = TileEntityFurnace.getItemBurnTime(this.getStackInSlot(1));
|
||||
this.decrStackSize(1, 1);
|
||||
this.furnaceBurnTime = burnTime;
|
||||
}
|
||||
|
||||
if (this.furnaceBurnTime > 0)
|
||||
{
|
||||
this.energy.receiveEnergy(Settings.FURNACE_WATTAGE / 20, true);
|
||||
this.furnaceBurnTime--;
|
||||
}
|
||||
|
||||
if (doBlockStateUpdate != this.furnaceBurnTime > 0)
|
||||
{
|
||||
this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
|
||||
}
|
||||
|
||||
this.produce();
|
||||
}
|
||||
|
||||
/**
|
||||
* Consuming energy for smelting
|
||||
*/
|
||||
if (this.canSmelt())
|
||||
{
|
||||
if (this.energy.checkExtract(Settings.FURNACE_WATTAGE / 20))
|
||||
{
|
||||
this.furnaceCookTime++;
|
||||
|
||||
if (this.furnaceCookTime == 200)
|
||||
{
|
||||
this.furnaceCookTime = 0;
|
||||
this.smeltItem();
|
||||
}
|
||||
|
||||
this.energy.extractEnergy(Settings.FURNACE_WATTAGE / 20, true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.furnaceCookTime = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private void produce()
|
||||
{
|
||||
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
if (this.energy.getEnergy() > 0)
|
||||
{
|
||||
TileEntity tileEntity = new Vector3(this).modifyPositionFromSide(direction).getTileEntity(this.worldObj);
|
||||
|
||||
if (tileEntity != null)
|
||||
{
|
||||
long used = CompatibilityModule.receiveEnergy(tileEntity, direction.getOpposite(), this.energy.extractEnergy(this.energy.getEnergy(), false), true);
|
||||
this.energy.extractEnergy(used, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnect(ForgeDirection direction)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean canSmelt()
|
||||
{
|
||||
if (this.getStackInSlot(0) == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemStack itemstack = FurnaceRecipes.smelting().getSmeltingResult(this.getStackInSlot(0));
|
||||
if (itemstack == null)
|
||||
return false;
|
||||
if (this.getStackInSlot(2) == null)
|
||||
return true;
|
||||
if (!this.getStackInSlot(2).isItemEqual(itemstack))
|
||||
return false;
|
||||
int result = getStackInSlot(2).stackSize + itemstack.stackSize;
|
||||
return (result <= getInventoryStackLimit() && result <= itemstack.getMaxStackSize());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public long onReceiveEnergy(ForgeDirection from, long receive, boolean doReceive)
|
||||
{
|
||||
if (this.canSmelt() && this.getStackInSlot(1) == null && this.furnaceBurnTime == 0)
|
||||
{
|
||||
return this.energy.receiveEnergy(receive, doReceive);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long onExtractEnergy(ForgeDirection from, long request, boolean doProvide)
|
||||
{
|
||||
return this.energy.extractEnergy(request, doProvide);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnergy(ForgeDirection from, long energy)
|
||||
{
|
||||
this.energy.setEnergy(energy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEnergy(ForgeDirection from)
|
||||
{
|
||||
return this.energy.getEnergy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEnergyCapacity(ForgeDirection from)
|
||||
{
|
||||
return this.energy.getEnergyCapacity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket()
|
||||
{
|
||||
return ResonantInduction.PACKET_TILE.getPacket(this, this.getPacketData(0).toArray());
|
||||
}
|
||||
|
||||
/**
|
||||
* 1 - Description Packet
|
||||
* 2 - Energy Update
|
||||
* 3 - Tesla Beam
|
||||
*/
|
||||
@Override
|
||||
public ArrayList getPacketData(int type)
|
||||
{
|
||||
ArrayList data = new ArrayList();
|
||||
data.add(this.furnaceBurnTime);
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceivePacket(ByteArrayDataInput data, EntityPlayer player, Object... extra)
|
||||
{
|
||||
try
|
||||
{
|
||||
this.furnaceBurnTime = data.readInt();
|
||||
this.worldObj.markBlockForRenderUpdate(this.xCoord, this.yCoord, this.zCoord);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -36,7 +36,7 @@ public class PathfinderEMContractor extends PathfinderAStar
|
|||
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
Vector3 neighbor = currentNode.clone().modifyPositionFromSide(ForgeDirection.getOrientation(i));
|
||||
Vector3 neighbor = currentNode.clone().translate(ForgeDirection.getOrientation(i));
|
||||
|
||||
if (TileLevitator.canBePath(world, neighbor))
|
||||
{
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package resonantinduction.electrical.multimeter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -572,9 +569,9 @@ public class PartMultimeter extends JCuboidPart implements IConnector<Multimeter
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnect(ForgeDirection direction)
|
||||
public boolean canConnect(ForgeDirection direction, Object obj)
|
||||
{
|
||||
return true;
|
||||
return obj instanceof PartMultimeter;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -285,9 +285,9 @@ public class TileTesla extends TileElectrical implements IMultiBlockStructure<Ti
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnect(ForgeDirection direction)
|
||||
public boolean canConnect(ForgeDirection direction, Object obj)
|
||||
{
|
||||
return super.canConnect(direction) && this.getMultiBlock().isPrimary();
|
||||
return super.canConnect(direction, obj) && this.getMultiBlock().isPrimary();
|
||||
}
|
||||
|
||||
public void sendPacket(int type)
|
||||
|
|
|
@ -181,9 +181,9 @@ public class PartTransformer extends JCuboidPart implements JNormalOcclusion, TF
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnect(ForgeDirection direction)
|
||||
public boolean canConnect(ForgeDirection direction, Object obj)
|
||||
{
|
||||
return direction.ordinal() == Rotation.rotateSide(placementSide.ordinal(), facing) || direction.ordinal() == Rotation.rotateSide(placementSide.ordinal(), Rotation.rotateSide(facing, 2));
|
||||
return obj instanceof IEnergyInterface && direction.ordinal() == Rotation.rotateSide(placementSide.ordinal(), facing) || direction.ordinal() == Rotation.rotateSide(placementSide.ordinal(), Rotation.rotateSide(facing, 2));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -26,6 +26,11 @@ import codechicken.multipart.TMultiPart;
|
|||
* @author Calclavia
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* TODO: Combind with PartFramedConnection
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract class PartAdvancedWire extends PartConductor
|
||||
{
|
||||
public static final int DEFAULT_COLOR = 15;
|
||||
|
@ -81,7 +86,7 @@ public abstract class PartAdvancedWire extends PartConductor
|
|||
}
|
||||
else if (!(obj instanceof IConductor))
|
||||
{
|
||||
return CompatibilityModule.canConnect(obj, dir.getOpposite());
|
||||
return CompatibilityModule.canConnect(obj, dir.getOpposite(), this);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
|
@ -73,9 +73,9 @@ public abstract class PartConductor extends PartAdvanced implements IConductor
|
|||
* EXTERNAL USE Can this wire be connected by another block?
|
||||
*/
|
||||
@Override
|
||||
public boolean canConnect(ForgeDirection direction)
|
||||
public boolean canConnect(ForgeDirection direction, Object source)
|
||||
{
|
||||
Vector3 connectPos = new Vector3(tile()).modifyPositionFromSide(direction);
|
||||
Vector3 connectPos = new Vector3(tile()).translate(direction);
|
||||
TileEntity connectTile = connectPos.getTileEntity(world());
|
||||
|
||||
if (connectTile instanceof IConductor)
|
||||
|
@ -101,7 +101,7 @@ public abstract class PartConductor extends PartAdvanced implements IConductor
|
|||
{
|
||||
ForgeDirection side = ForgeDirection.getOrientation(i);
|
||||
|
||||
if (this.canConnect(side))
|
||||
if (this.canConnect(side, this))
|
||||
{
|
||||
TileEntity tileEntity = VectorHelper.getTileEntityFromSide(world(), new Vector3(tile()), side);
|
||||
connections[i] = tileEntity;
|
||||
|
|
|
@ -301,7 +301,7 @@ public class PartFramedWire extends PartAdvancedWire implements TSlottedPart, JN
|
|||
|
||||
if (tile instanceof IConductor)
|
||||
{
|
||||
notPrevented &= ((IConductor) tile).canConnect(side.getOpposite());
|
||||
notPrevented &= ((IConductor) tile).canConnect(side.getOpposite(), this);
|
||||
}
|
||||
|
||||
return notPrevented;
|
||||
|
@ -346,7 +346,7 @@ public class PartFramedWire extends PartAdvancedWire implements TSlottedPart, JN
|
|||
{
|
||||
TileEntity tileEntity = VectorHelper.getTileEntityFromSide(world(), new Vector3(tile()), side);
|
||||
|
||||
if (CompatibilityModule.canConnect(tileEntity, side.getOpposite()) && canConnectBothSides(tileEntity, side))
|
||||
if (CompatibilityModule.canConnect(tileEntity, side.getOpposite(), this) && canConnectBothSides(tileEntity, side))
|
||||
{
|
||||
connections |= 1 << side.ordinal();
|
||||
}
|
||||
|
@ -384,7 +384,7 @@ public class PartFramedWire extends PartAdvancedWire implements TSlottedPart, JN
|
|||
{
|
||||
if (connectionMapContainsSide(possibleWireConnections, side))
|
||||
{
|
||||
TileEntity tileEntity = VectorHelper.getConnectorFromSide(world(), new Vector3(tile()), side);
|
||||
TileEntity tileEntity = VectorHelper.getConnectorFromSide(world(), new Vector3(tile()), side, this);
|
||||
|
||||
if (tileEntity instanceof IConductor)
|
||||
{
|
||||
|
@ -439,16 +439,21 @@ public class PartFramedWire extends PartAdvancedWire implements TSlottedPart, JN
|
|||
* Shouldn't need to be overridden. Override connectionPrevented instead
|
||||
*/
|
||||
@Override
|
||||
public boolean canConnect(ForgeDirection direction)
|
||||
public boolean canConnect(ForgeDirection direction, Object obj)
|
||||
{
|
||||
if (world().isBlockIndirectlyGettingPowered(x(), y(), z()))
|
||||
if (obj instanceof PartFramedWire)
|
||||
{
|
||||
return false;
|
||||
if (world().isBlockIndirectlyGettingPowered(x(), y(), z()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Vector3 connectPos = new Vector3(tile()).translate(direction);
|
||||
TileEntity connectTile = connectPos.getTileEntity(world());
|
||||
return !isConnectionPrevented(connectTile, direction);
|
||||
}
|
||||
|
||||
Vector3 connectPos = new Vector3(tile()).translate(direction);
|
||||
TileEntity connectTile = connectPos.getTileEntity(world());
|
||||
return !isConnectionPrevented(connectTile, direction);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -82,11 +82,11 @@ public class TraitConductor extends TileMultipart implements IConductor
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnect(ForgeDirection direction)
|
||||
public boolean canConnect(ForgeDirection direction, Object source)
|
||||
{
|
||||
for (IConductor conductor : this.ueInterfaces)
|
||||
{
|
||||
if (conductor.canConnect(direction.getOpposite()))
|
||||
if (conductor.canConnect(direction.getOpposite(), source))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -71,13 +71,13 @@ public class TileManipulator extends TileFilterable implements IRotatable, IMani
|
|||
Vector3 inputPosition = new Vector3(this);
|
||||
/** output location up */
|
||||
Vector3 outputUp = new Vector3(this);
|
||||
outputUp.modifyPositionFromSide(ForgeDirection.UP);
|
||||
outputUp.translate(ForgeDirection.UP);
|
||||
/** output location down */
|
||||
Vector3 outputDown = new Vector3(this);
|
||||
outputDown.modifyPositionFromSide(ForgeDirection.DOWN);
|
||||
outputDown.translate(ForgeDirection.DOWN);
|
||||
/** output location facing */
|
||||
Vector3 outputPosition = new Vector3(this);
|
||||
outputPosition.modifyPositionFromSide(this.getDirection().getOpposite());
|
||||
outputPosition.translate(this.getDirection().getOpposite());
|
||||
|
||||
/** Prevents manipulators from spamming and duping items. */
|
||||
if (outputPosition.getTileEntity(this.worldObj) instanceof TileManipulator)
|
||||
|
@ -132,13 +132,13 @@ public class TileManipulator extends TileFilterable implements IRotatable, IMani
|
|||
{
|
||||
this.isRedstonePowered = false;
|
||||
/** input location up */
|
||||
Vector3 inputUp = new Vector3(this).modifyPositionFromSide(ForgeDirection.UP);
|
||||
Vector3 inputUp = new Vector3(this).translate(ForgeDirection.UP);
|
||||
/** input location down */
|
||||
Vector3 inputDown = new Vector3(this).modifyPositionFromSide(ForgeDirection.DOWN);
|
||||
Vector3 inputDown = new Vector3(this).translate(ForgeDirection.DOWN);
|
||||
/** input location facing */
|
||||
Vector3 inputPosition = new Vector3(this).modifyPositionFromSide(this.getDirection().getOpposite());
|
||||
Vector3 inputPosition = new Vector3(this).translate(this.getDirection().getOpposite());
|
||||
/** output location facing */
|
||||
Vector3 outputPosition = new Vector3(this).modifyPositionFromSide(this.getDirection());
|
||||
Vector3 outputPosition = new Vector3(this).translate(this.getDirection());
|
||||
|
||||
ItemStack itemStack = invHelper().tryGrabFromPosition(inputUp, ForgeDirection.UP, 1);
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ public class TileRejector extends TileFilterable implements IPacketReceiverWithI
|
|||
this.firePiston = false;
|
||||
|
||||
Vector3 searchPosition = new Vector3(this);
|
||||
searchPosition.modifyPositionFromSide(this.getDirection());
|
||||
searchPosition.translate(this.getDirection());
|
||||
TileEntity tileEntity = searchPosition.getTileEntity(this.worldObj);
|
||||
|
||||
try
|
||||
|
|
|
@ -71,13 +71,13 @@ public class TileSorter extends TileFilterable implements IRotatable, IManipulat
|
|||
Vector3 inputPosition = new Vector3(this);
|
||||
/** output location up */
|
||||
Vector3 outputUp = new Vector3(this);
|
||||
outputUp.modifyPositionFromSide(ForgeDirection.UP);
|
||||
outputUp.translate(ForgeDirection.UP);
|
||||
/** output location down */
|
||||
Vector3 outputDown = new Vector3(this);
|
||||
outputDown.modifyPositionFromSide(ForgeDirection.DOWN);
|
||||
outputDown.translate(ForgeDirection.DOWN);
|
||||
/** output location facing */
|
||||
Vector3 outputPosition = new Vector3(this);
|
||||
outputPosition.modifyPositionFromSide(this.getDirection().getOpposite());
|
||||
outputPosition.translate(this.getDirection().getOpposite());
|
||||
|
||||
/** Prevents manipulators from spamming and duping items. */
|
||||
if (outputPosition.getTileEntity(this.worldObj) instanceof TileSorter)
|
||||
|
@ -132,13 +132,13 @@ public class TileSorter extends TileFilterable implements IRotatable, IManipulat
|
|||
{
|
||||
this.isRedstonePowered = false;
|
||||
/** input location up */
|
||||
Vector3 inputUp = new Vector3(this).modifyPositionFromSide(ForgeDirection.UP);
|
||||
Vector3 inputUp = new Vector3(this).translate(ForgeDirection.UP);
|
||||
/** input location down */
|
||||
Vector3 inputDown = new Vector3(this).modifyPositionFromSide(ForgeDirection.DOWN);
|
||||
Vector3 inputDown = new Vector3(this).translate(ForgeDirection.DOWN);
|
||||
/** input location facing */
|
||||
Vector3 inputPosition = new Vector3(this).modifyPositionFromSide(this.getDirection().getOpposite());
|
||||
Vector3 inputPosition = new Vector3(this).translate(this.getDirection().getOpposite());
|
||||
/** output location facing */
|
||||
Vector3 outputPosition = new Vector3(this).modifyPositionFromSide(this.getDirection());
|
||||
Vector3 outputPosition = new Vector3(this).translate(this.getDirection());
|
||||
|
||||
ItemStack itemStack = invHelper().tryGrabFromPosition(inputUp, ForgeDirection.UP, 1);
|
||||
|
||||
|
|
|
@ -254,13 +254,6 @@ public abstract class PartMechanical extends JCuboidPart implements JNormalOcclu
|
|||
this.network = network;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean canConnect(ForgeDirection direction)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getAngularVelocity()
|
||||
{
|
||||
|
|
|
@ -88,13 +88,6 @@ public abstract class TileMechanical extends TileAdvanced implements IMechanical
|
|||
return 0.95f;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean canConnect(ForgeDirection direction)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] getConnections()
|
||||
{
|
||||
|
|
|
@ -55,12 +55,6 @@ public class TraitMechanical extends TileMultipart implements IMechanical
|
|||
this.mechanicalInterfaces.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnect(ForgeDirection from)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] getConnections()
|
||||
{
|
||||
|
|
|
@ -11,11 +11,6 @@ import calclavia.lib.prefab.turbine.TileTurbine;
|
|||
|
||||
public class TileMechanicalTurbine extends TileTurbine implements IMechanical
|
||||
{
|
||||
@Override
|
||||
public boolean canConnect(ForgeDirection direction)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mechanical Methods
|
||||
|
@ -105,17 +100,19 @@ public class TileMechanicalTurbine extends TileTurbine implements IMechanical
|
|||
@Override
|
||||
public boolean canConnect(ForgeDirection from, Object source)
|
||||
{
|
||||
/**
|
||||
* Face to face stick connection.
|
||||
*/
|
||||
TileEntity sourceTile = getPosition().translate(from).getTileEntity(getWorld());
|
||||
|
||||
if (sourceTile instanceof IMechanical)
|
||||
if (source instanceof IMechanical)
|
||||
{
|
||||
IMechanical sourceInstance = ((IMechanical) sourceTile).getInstance(from.getOpposite());
|
||||
return sourceInstance == source && from == getDirection().getOpposite();
|
||||
}
|
||||
/**
|
||||
* Face to face stick connection.
|
||||
*/
|
||||
TileEntity sourceTile = getPosition().translate(from).getTileEntity(getWorld());
|
||||
|
||||
if (sourceTile instanceof IMechanical)
|
||||
{
|
||||
IMechanical sourceInstance = ((IMechanical) sourceTile).getInstance(from.getOpposite());
|
||||
return sourceInstance == source && from == getDirection().getOpposite();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -126,7 +126,7 @@ public class LaserEvent extends Event
|
|||
int meta = vec.getBlockID(world);
|
||||
Block block = Block.blocksList[id];
|
||||
|
||||
Vector3 faceVec = vec.clone().modifyPositionFromSide(side);
|
||||
Vector3 faceVec = vec.clone().translate(side);
|
||||
int id2 = faceVec.getBlockID(world);
|
||||
Block block2 = Block.blocksList[id2];
|
||||
|
||||
|
@ -207,7 +207,7 @@ public class LaserEvent extends Event
|
|||
try
|
||||
{
|
||||
|
||||
Block blockBellow = Block.blocksList[vec.clone().modifyPositionFromSide(ForgeDirection.DOWN).getBlockID(world)];
|
||||
Block blockBellow = Block.blocksList[vec.clone().translate(ForgeDirection.DOWN).getBlockID(world)];
|
||||
if (block != null)
|
||||
{
|
||||
if (block.blockID == Block.tnt.blockID)
|
||||
|
|
|
@ -26,14 +26,5 @@ public interface IMechanical extends IConnector<IMechanicalNetwork>
|
|||
@Override
|
||||
public IMechanical getInstance(ForgeDirection dir);
|
||||
|
||||
/**
|
||||
* Can this components connect with the other?
|
||||
*
|
||||
* @param from - The direction the connection is coming from relative to this block.
|
||||
* @param source - The object trying to connect
|
||||
* @return
|
||||
*/
|
||||
public boolean canConnect(ForgeDirection from, Object sourcen);
|
||||
|
||||
public Vector3 getPosition();
|
||||
}
|
||||
|
|
|
@ -30,282 +30,286 @@ import com.google.common.io.ByteArrayDataInput;
|
|||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
/** A prefab class for tiles that use the fluid network.
|
||||
/**
|
||||
* A prefab class for tiles that use the fluid network.
|
||||
*
|
||||
* @author DarkGuardsman */
|
||||
* @author DarkGuardsman
|
||||
*/
|
||||
public abstract class TileFluidNetwork extends TileAdvanced implements IFluidConnector, IPacketReceiverWithID, IInformation
|
||||
{
|
||||
protected FluidTank tank;
|
||||
protected Object[] connectedBlocks = new Object[6];
|
||||
protected int colorID = 0;
|
||||
protected FluidTank tank;
|
||||
protected Object[] connectedBlocks = new Object[6];
|
||||
protected int colorID = 0;
|
||||
|
||||
/** Copy of the tank's content last time it updated */
|
||||
protected FluidStack prevStack = null;
|
||||
/** Copy of the tank's content last time it updated */
|
||||
protected FluidStack prevStack = null;
|
||||
|
||||
/** Network used to link all parts together */
|
||||
protected IFluidNetwork network;
|
||||
/** Network used to link all parts together */
|
||||
protected IFluidNetwork network;
|
||||
|
||||
public static final int PACKET_DESCRIPTION = 0;
|
||||
public static final int PACKET_RENDER = 1;
|
||||
public static final int PACKET_TANK = 2;
|
||||
public static final int PACKET_DESCRIPTION = 0;
|
||||
public static final int PACKET_RENDER = 1;
|
||||
public static final int PACKET_TANK = 2;
|
||||
|
||||
/** Bitmask that handles connections for the renderer **/
|
||||
public byte renderSides = 0;
|
||||
/** Bitmask that handles connections for the renderer **/
|
||||
public byte renderSides = 0;
|
||||
|
||||
@Override
|
||||
public void initiate()
|
||||
{
|
||||
super.initiate();
|
||||
refresh();
|
||||
getNetwork().reconstruct();
|
||||
}
|
||||
@Override
|
||||
public void initiate()
|
||||
{
|
||||
super.initiate();
|
||||
refresh();
|
||||
getNetwork().reconstruct();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate()
|
||||
{
|
||||
this.getNetwork().split(this);
|
||||
super.invalidate();
|
||||
}
|
||||
@Override
|
||||
public void invalidate()
|
||||
{
|
||||
this.getNetwork().split(this);
|
||||
super.invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(ForgeDirection from, FluidStack resource, boolean doFill)
|
||||
{
|
||||
return this.getNetwork().fill(this, from, resource, doFill);
|
||||
}
|
||||
@Override
|
||||
public int fill(ForgeDirection from, FluidStack resource, boolean doFill)
|
||||
{
|
||||
return this.getNetwork().fill(this, from, resource, doFill);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain)
|
||||
{
|
||||
return this.getNetwork().drain(this, from, resource, doDrain);
|
||||
}
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain)
|
||||
{
|
||||
return this.getNetwork().drain(this, from, resource, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain)
|
||||
{
|
||||
return this.getNetwork().drain(this, from, maxDrain, doDrain);
|
||||
}
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain)
|
||||
{
|
||||
return this.getNetwork().drain(this, from, maxDrain, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill(ForgeDirection from, Fluid fluid)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean canFill(ForgeDirection from, Fluid fluid)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(ForgeDirection from, Fluid fluid)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean canDrain(ForgeDirection from, Fluid fluid)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo(ForgeDirection from)
|
||||
{
|
||||
return this.getNetwork().getTankInfo();
|
||||
}
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo(ForgeDirection from)
|
||||
{
|
||||
return this.getNetwork().getTankInfo();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] getConnections()
|
||||
{
|
||||
return this.connectedBlocks;
|
||||
}
|
||||
@Override
|
||||
public Object[] getConnections()
|
||||
{
|
||||
return this.connectedBlocks;
|
||||
}
|
||||
|
||||
public void refresh()
|
||||
{
|
||||
if (this.worldObj != null && !this.worldObj.isRemote)
|
||||
{
|
||||
byte previousConnections = renderSides;
|
||||
this.connectedBlocks = new Object[6];
|
||||
this.renderSides = 0;
|
||||
public void refresh()
|
||||
{
|
||||
if (this.worldObj != null && !this.worldObj.isRemote)
|
||||
{
|
||||
byte previousConnections = renderSides;
|
||||
this.connectedBlocks = new Object[6];
|
||||
this.renderSides = 0;
|
||||
|
||||
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
this.validateConnectionSide(new Vector3(this).modifyPositionFromSide(dir).getTileEntity(this.worldObj), dir);
|
||||
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
this.validateConnectionSide(new Vector3(this).translate(dir).getTileEntity(this.worldObj), dir);
|
||||
|
||||
}
|
||||
/** Only send packet updates if visuallyConnected changed. */
|
||||
if (previousConnections != renderSides)
|
||||
{
|
||||
this.sendRenderUpdate();
|
||||
this.getNetwork().reconstruct();
|
||||
}
|
||||
}
|
||||
}
|
||||
/** Only send packet updates if visuallyConnected changed. */
|
||||
if (previousConnections != renderSides)
|
||||
{
|
||||
this.sendRenderUpdate();
|
||||
this.getNetwork().reconstruct();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/** Checks to make sure the connection is valid to the tileEntity
|
||||
*
|
||||
* @param tileEntity - the tileEntity being checked
|
||||
* @param side - side the connection is too */
|
||||
public void validateConnectionSide(TileEntity tileEntity, ForgeDirection side)
|
||||
{
|
||||
if (!this.worldObj.isRemote)
|
||||
{
|
||||
if (tileEntity instanceof IFluidConnector)
|
||||
{
|
||||
this.getNetwork().merge(((IFluidConnector) tileEntity).getNetwork());
|
||||
this.setRenderSide(side, true);
|
||||
connectedBlocks[side.ordinal()] = tileEntity;
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Checks to make sure the connection is valid to the tileEntity
|
||||
*
|
||||
* @param tileEntity - the tileEntity being checked
|
||||
* @param side - side the connection is too
|
||||
*/
|
||||
public void validateConnectionSide(TileEntity tileEntity, ForgeDirection side)
|
||||
{
|
||||
if (!this.worldObj.isRemote)
|
||||
{
|
||||
if (tileEntity instanceof IFluidConnector)
|
||||
{
|
||||
this.getNetwork().merge(((IFluidConnector) tileEntity).getNetwork());
|
||||
this.setRenderSide(side, true);
|
||||
connectedBlocks[side.ordinal()] = tileEntity;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setRenderSide(ForgeDirection direction, boolean doRender)
|
||||
{
|
||||
if (doRender)
|
||||
{
|
||||
renderSides = (byte) (renderSides | (1 << direction.ordinal()));
|
||||
}
|
||||
else
|
||||
{
|
||||
renderSides = (byte) (renderSides & ~(1 << direction.ordinal()));
|
||||
public void setRenderSide(ForgeDirection direction, boolean doRender)
|
||||
{
|
||||
if (doRender)
|
||||
{
|
||||
renderSides = (byte) (renderSides | (1 << direction.ordinal()));
|
||||
}
|
||||
else
|
||||
{
|
||||
renderSides = (byte) (renderSides & ~(1 << direction.ordinal()));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canRenderSide(ForgeDirection direction)
|
||||
{
|
||||
return (renderSides & (1 << direction.ordinal())) != 0;
|
||||
}
|
||||
public boolean canRenderSide(ForgeDirection direction)
|
||||
{
|
||||
return (renderSides & (1 << direction.ordinal())) != 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt)
|
||||
{
|
||||
super.readFromNBT(nbt);
|
||||
this.colorID = nbt.getInteger("subID");
|
||||
if (nbt.hasKey("stored"))
|
||||
{
|
||||
NBTTagCompound tag = nbt.getCompoundTag("stored");
|
||||
String name = tag.getString("LiquidName");
|
||||
int amount = nbt.getInteger("Amount");
|
||||
Fluid fluid = FluidRegistry.getFluid(name);
|
||||
if (fluid != null)
|
||||
{
|
||||
FluidStack liquid = new FluidStack(fluid, amount);
|
||||
this.getInternalTank().setFluid(liquid);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.getInternalTank().readFromNBT(nbt.getCompoundTag("FluidTank"));
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt)
|
||||
{
|
||||
super.readFromNBT(nbt);
|
||||
this.colorID = nbt.getInteger("subID");
|
||||
if (nbt.hasKey("stored"))
|
||||
{
|
||||
NBTTagCompound tag = nbt.getCompoundTag("stored");
|
||||
String name = tag.getString("LiquidName");
|
||||
int amount = nbt.getInteger("Amount");
|
||||
Fluid fluid = FluidRegistry.getFluid(name);
|
||||
if (fluid != null)
|
||||
{
|
||||
FluidStack liquid = new FluidStack(fluid, amount);
|
||||
this.getInternalTank().setFluid(liquid);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.getInternalTank().readFromNBT(nbt.getCompoundTag("FluidTank"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt)
|
||||
{
|
||||
super.writeToNBT(nbt);
|
||||
nbt.setInteger("subID", this.colorID);
|
||||
nbt.setCompoundTag("FluidTank", this.getInternalTank().writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt)
|
||||
{
|
||||
super.writeToNBT(nbt);
|
||||
nbt.setInteger("subID", this.colorID);
|
||||
nbt.setCompoundTag("FluidTank", this.getInternalTank().writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onReceivePacket(int id, ByteArrayDataInput data, EntityPlayer player, Object... extra)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (this.worldObj.isRemote)
|
||||
{
|
||||
if (id == PACKET_DESCRIPTION)
|
||||
{
|
||||
this.colorID = data.readInt();
|
||||
this.renderSides = data.readByte();
|
||||
this.tank = new FluidTank(data.readInt());
|
||||
this.getInternalTank().readFromNBT(PacketHandler.readNBTTagCompound(data));
|
||||
return true;
|
||||
}
|
||||
else if (id == PACKET_RENDER)
|
||||
{
|
||||
this.colorID = data.readInt();
|
||||
this.renderSides = data.readByte();
|
||||
return true;
|
||||
}
|
||||
else if (id == PACKET_TANK)
|
||||
{
|
||||
this.tank = new FluidTank(data.readInt()).readFromNBT(PacketHandler.readNBTTagCompound(data));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean onReceivePacket(int id, ByteArrayDataInput data, EntityPlayer player, Object... extra)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (this.worldObj.isRemote)
|
||||
{
|
||||
if (id == PACKET_DESCRIPTION)
|
||||
{
|
||||
this.colorID = data.readInt();
|
||||
this.renderSides = data.readByte();
|
||||
this.tank = new FluidTank(data.readInt());
|
||||
this.getInternalTank().readFromNBT(PacketHandler.readNBTTagCompound(data));
|
||||
return true;
|
||||
}
|
||||
else if (id == PACKET_RENDER)
|
||||
{
|
||||
this.colorID = data.readInt();
|
||||
this.renderSides = data.readByte();
|
||||
return true;
|
||||
}
|
||||
else if (id == PACKET_TANK)
|
||||
{
|
||||
this.tank = new FluidTank(data.readInt()).readFromNBT(PacketHandler.readNBTTagCompound(data));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket()
|
||||
{
|
||||
return ResonantInduction.PACKET_TILE.getPacketWithID(PACKET_DESCRIPTION, this, this.colorID, this.renderSides, this.getInternalTank().getCapacity(), this.getInternalTank().writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
@Override
|
||||
public Packet getDescriptionPacket()
|
||||
{
|
||||
return ResonantInduction.PACKET_TILE.getPacketWithID(PACKET_DESCRIPTION, this, this.colorID, this.renderSides, this.getInternalTank().getCapacity(), this.getInternalTank().writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
|
||||
public void sendRenderUpdate()
|
||||
{
|
||||
PacketHandler.sendPacketToClients(ResonantInduction.PACKET_TILE.getPacketWithID(PACKET_RENDER, this, this.colorID, this.renderSides));
|
||||
}
|
||||
public void sendRenderUpdate()
|
||||
{
|
||||
PacketHandler.sendPacketToClients(ResonantInduction.PACKET_TILE.getPacketWithID(PACKET_RENDER, this, this.colorID, this.renderSides));
|
||||
}
|
||||
|
||||
public void sendTankUpdate()
|
||||
{
|
||||
PacketHandler.sendPacketToClients(ResonantInduction.PACKET_TILE.getPacketWithID(PACKET_TANK, this, getInternalTank().getCapacity(), getInternalTank().writeToNBT(new NBTTagCompound())), this.worldObj, new Vector3(this), 60);
|
||||
}
|
||||
public void sendTankUpdate()
|
||||
{
|
||||
PacketHandler.sendPacketToClients(ResonantInduction.PACKET_TILE.getPacketWithID(PACKET_TANK, this, getInternalTank().getCapacity(), getInternalTank().writeToNBT(new NBTTagCompound())), this.worldObj, new Vector3(this), 60);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFluidChanged()
|
||||
{
|
||||
if (!worldObj.isRemote)
|
||||
{
|
||||
if (!FluidUtility.matchExact(prevStack, this.getInternalTank().getFluid()))
|
||||
{
|
||||
sendTankUpdate();
|
||||
}
|
||||
@Override
|
||||
public void onFluidChanged()
|
||||
{
|
||||
if (!worldObj.isRemote)
|
||||
{
|
||||
if (!FluidUtility.matchExact(prevStack, this.getInternalTank().getFluid()))
|
||||
{
|
||||
sendTankUpdate();
|
||||
}
|
||||
|
||||
prevStack = tank.getFluid();
|
||||
}
|
||||
}
|
||||
prevStack = tank.getFluid();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public AxisAlignedBB getRenderBoundingBox()
|
||||
{
|
||||
return AxisAlignedBB.getAABBPool().getAABB(this.xCoord, this.yCoord, this.zCoord, this.xCoord + 1, this.yCoord + 1, this.zCoord + 1);
|
||||
}
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public AxisAlignedBB getRenderBoundingBox()
|
||||
{
|
||||
return AxisAlignedBB.getAABBPool().getAABB(this.xCoord, this.yCoord, this.zCoord, this.xCoord + 1, this.yCoord + 1, this.zCoord + 1);
|
||||
}
|
||||
|
||||
public int getSubID()
|
||||
{
|
||||
return this.colorID;
|
||||
}
|
||||
public int getSubID()
|
||||
{
|
||||
return this.colorID;
|
||||
}
|
||||
|
||||
public void setSubID(int id)
|
||||
{
|
||||
this.colorID = id;
|
||||
}
|
||||
public void setSubID(int id)
|
||||
{
|
||||
this.colorID = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnect(ForgeDirection direction)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean canConnect(ForgeDirection direction, Object obj)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTank getInternalTank()
|
||||
{
|
||||
if (this.tank == null)
|
||||
{
|
||||
this.tank = new FluidTank(FluidContainerRegistry.BUCKET_VOLUME);
|
||||
}
|
||||
return this.tank;
|
||||
}
|
||||
@Override
|
||||
public FluidTank getInternalTank()
|
||||
{
|
||||
if (this.tank == null)
|
||||
{
|
||||
this.tank = new FluidTank(FluidContainerRegistry.BUCKET_VOLUME);
|
||||
}
|
||||
return this.tank;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getInformation(List<String> info)
|
||||
{
|
||||
info.add(this.getNetwork().toString());
|
||||
}
|
||||
@Override
|
||||
public void getInformation(List<String> info)
|
||||
{
|
||||
info.add(this.getNetwork().toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFluidConnector getInstance(ForgeDirection from)
|
||||
{
|
||||
return this;
|
||||
}
|
||||
@Override
|
||||
public IFluidConnector getInstance(ForgeDirection from)
|
||||
{
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -223,7 +223,7 @@ public abstract class PartFramedConnection<M extends Enum, C extends IConnector<
|
|||
|
||||
if (getConnector(tile) != null)
|
||||
{
|
||||
notPrevented &= getConnector(tile).canConnect(side.getOpposite());
|
||||
notPrevented &= getConnector(tile).canConnect(side.getOpposite(), this);
|
||||
}
|
||||
|
||||
return notPrevented;
|
||||
|
@ -298,7 +298,7 @@ public abstract class PartFramedConnection<M extends Enum, C extends IConnector<
|
|||
{
|
||||
if (connectionMapContainsSide(possibleWireConnections, side))
|
||||
{
|
||||
TileEntity tileEntity = VectorHelper.getConnectorFromSide(world(), new Vector3(tile()), side);
|
||||
TileEntity tileEntity = VectorHelper.getConnectorFromSide(world(), new Vector3(tile()), side, this);
|
||||
|
||||
if (getConnector(tileEntity) != null)
|
||||
{
|
||||
|
@ -353,7 +353,7 @@ public abstract class PartFramedConnection<M extends Enum, C extends IConnector<
|
|||
* Shouldn't need to be overridden. Override connectionPrevented instead
|
||||
*/
|
||||
@Override
|
||||
public boolean canConnect(ForgeDirection direction)
|
||||
public boolean canConnect(ForgeDirection direction, Object source)
|
||||
{
|
||||
Vector3 connectPos = new Vector3(tile()).translate(direction);
|
||||
TileEntity connectTile = connectPos.getTileEntity(world());
|
||||
|
|
Loading…
Reference in a new issue