Revert "Minor clean up"

This reverts commit 428b187722.
This commit is contained in:
Calclavia 2014-02-01 11:55:55 +08:00
parent 428b187722
commit 39d73b5634
67 changed files with 1089 additions and 1051 deletions

View file

@ -7,56 +7,48 @@ import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler; import net.minecraftforge.fluids.IFluidHandler;
import universalelectricity.api.net.INodeNetwork; import universalelectricity.api.net.INodeNetwork;
/** /** Interface version of the fluid network.
* Interface version of the fluid network.
* *
* @author DarkGuardsman * @author DarkGuardsman */
*/
public interface IFluidNetwork extends INodeNetwork<IFluidNetwork, IFluidConnector, IFluidHandler> public interface IFluidNetwork extends INodeNetwork<IFluidNetwork, IFluidConnector, IFluidHandler>
{ {
/** Called to build the network when something changes such as addition of a pipe */ /** Called to build the network when something changes such as addition of a pipe */
@Override @Override
void reconstruct(); void reconstruct();
/** /** Called to add fluid into the network
* Called to add fluid into the network *
* * @param source - part that is receiving the fluid for the network
* @param source - part that is receiving the fluid for the network * @param from - direction of this connection
* @param from - direction of this connection * @param resource - fluid stack that is being filled into the network
* @param resource - fluid stack that is being filled into the network * @param doFill - true causes the action to be taken, false simulates the action
* @param doFill - true causes the action to be taken, false simulates the action * @return amount of fluid filled into the network */
* @return amount of fluid filled into the network int fill(IFluidConnector source, ForgeDirection from, FluidStack resource, boolean doFill);
*/
int fill(IFluidConnector source, ForgeDirection from, FluidStack resource, boolean doFill);
/** /** Called to remove fluid from a network, not supported by all networks
* Called to remove fluid from a network, not supported by all networks *
* * @param source - part that is receiving the fluid for the network
* @param source - part that is receiving the fluid for the network * @param from - direction of this connection
* @param from - direction of this connection * @param resource - fluid stack that is being filled into the network
* @param resource - fluid stack that is being filled into the network * @param doDrain - true causes the action to be taken, false simulates the action
* @param doDrain - true causes the action to be taken, false simulates the action * @return FluidStack that contains the fluid drained from the network */
* @return FluidStack that contains the fluid drained from the network FluidStack drain(IFluidConnector source, ForgeDirection from, FluidStack resource, boolean doDrain);
*/
FluidStack drain(IFluidConnector source, ForgeDirection from, FluidStack resource, boolean doDrain);
/** /** Called to remove fluid from a network, not supported by all networks
* Called to remove fluid from a network, not supported by all networks *
* * @param source - part that is receiving the fluid for the network
* @param source - part that is receiving the fluid for the network * @param from - direction of this connection
* @param from - direction of this connection * @param resource - fluid stack that is being filled into the network
* @param resource - fluid stack that is being filled into the network * @param doDrain - true causes the action to be taken, false simulates the action
* @param doDrain - true causes the action to be taken, false simulates the action * @return FluidStack that contains the fluid drained from the network */
* @return FluidStack that contains the fluid drained from the network FluidStack drain(IFluidConnector source, ForgeDirection from, int resource, boolean doDrain);
*/
FluidStack drain(IFluidConnector source, ForgeDirection from, int resource, boolean doDrain);
/** Fluid tank that represents the entire network */ /** Fluid tank that represents the entire network */
FluidTank getTank(); FluidTank getTank();
/** Information about the network's tank */ /** Information about the network's tank */
FluidTankInfo[] getTankInfo(); FluidTankInfo[] getTankInfo();
int getPressure(); int getPressure();
} }

View file

@ -13,7 +13,7 @@ public interface IFluidPipe extends IFluidConnector, IPressureInput
* @return amount in pascals. * @return amount in pascals.
*/ */
int getMaxPressure(); int getMaxPressure();
int getPressure(); int getPressure();
/** /**

View file

@ -1,11 +1,14 @@
package resonantinduction.archaic.firebox; package resonantinduction.archaic.firebox;
import java.util.List;
import java.util.Random; import java.util.Random;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.DamageSource; import net.minecraft.util.DamageSource;
import net.minecraft.util.Icon; import net.minecraft.util.Icon;

View file

@ -9,7 +9,9 @@ import net.minecraft.item.crafting.FurnaceRecipes;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.packet.Packet; import net.minecraft.network.packet.Packet;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import resonantinduction.core.ResonantInduction; import resonantinduction.core.ResonantInduction;
import universalelectricity.api.energy.EnergyStorageHandler;
import calclavia.lib.network.IPacketReceiver; import calclavia.lib.network.IPacketReceiver;
import calclavia.lib.network.IPacketSender; import calclavia.lib.network.IPacketSender;
import calclavia.lib.network.PacketHandler; import calclavia.lib.network.PacketHandler;

View file

@ -14,8 +14,8 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList; import net.minecraft.nbt.NBTTagList;
import resonantinduction.core.Reference; import resonantinduction.core.Reference;
import resonantinduction.core.Settings;
import resonantinduction.core.TabRI; import resonantinduction.core.TabRI;
import resonantinduction.core.Settings;
public class ItemImprint extends Item public class ItemImprint extends Item
{ {

View file

@ -1,5 +1,6 @@
package resonantinduction.archaic.process; package resonantinduction.archaic.process;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
@ -8,10 +9,17 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Icon; import net.minecraft.util.Icon;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import resonantinduction.api.recipe.MachineRecipes;
import resonantinduction.api.recipe.MachineRecipes.RecipeType;
import resonantinduction.archaic.crate.TileCrate;
import resonantinduction.core.Reference; import resonantinduction.core.Reference;
import resonantinduction.core.prefab.block.BlockRI; import resonantinduction.core.prefab.block.BlockRI;
import universalelectricity.api.vector.Vector2;
import universalelectricity.api.vector.Vector3; import universalelectricity.api.vector.Vector3;
import universalelectricity.api.vector.VectorWorld;
import calclavia.lib.utility.inventory.InventoryUtility; import calclavia.lib.utility.inventory.InventoryUtility;
import codechicken.multipart.ControlKeyModifer;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;

View file

@ -2,6 +2,7 @@ package resonantinduction.archaic.process;
import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import resonantinduction.core.render.RenderItemOverlayTile; import resonantinduction.core.render.RenderItemOverlayTile;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;

View file

@ -20,7 +20,6 @@ public class TileMillstone extends TileExternalInventory implements IPacketRecei
{ {
private int grindCount = 0; private int grindCount = 0;
@Override
public void onInventoryChanged() public void onInventoryChanged()
{ {
grindCount = 0; grindCount = 0;

View file

@ -17,7 +17,7 @@ public class SoundHandler
{ {
public static final SoundHandler INSTANCE = new SoundHandler(); public static final SoundHandler INSTANCE = new SoundHandler();
public static final String[] SOUND_FILES = { "hammer.ogg", "grinder1.ogg", "grinder2.ogg", "grinder3.ogg", "grinder4.ogg", "electricshock1.ogg", "electricshock2.ogg", "electricshock3.ogg", "electricshock4.ogg", "electricshock5.ogg", "electricshock6.ogg", "electricshock7.ogg", "conveyor.ogg" }; public static final String[] SOUND_FILES = { "hammer.ogg", "grinder1.ogg", "grinder2.ogg", "grinder3.ogg", "grinder4.ogg", "electricshock1.ogg", "electricshock2.ogg", "electricshock3.ogg", "electricshock4.ogg", "electricshock5.ogg", "electricshock6.ogg", "electricshock7.ogg" , "conveyor.ogg" };
@ForgeSubscribe @ForgeSubscribe
public void loadSoundEvents(SoundLoadEvent event) public void loadSoundEvents(SoundLoadEvent event)

View file

@ -6,6 +6,7 @@ import net.minecraft.util.Icon;
import net.minecraftforge.client.event.TextureStitchEvent; import net.minecraftforge.client.event.TextureStitchEvent;
import net.minecraftforge.event.ForgeSubscribe; import net.minecraftforge.event.ForgeSubscribe;
import resonantinduction.core.Reference; import resonantinduction.core.Reference;
import resonantinduction.core.ResonantInduction;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
@ -36,6 +37,6 @@ public class FluidEventHandler
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void textureHook(TextureStitchEvent.Post event) public void textureHook(TextureStitchEvent.Post event)
{ {
// ResonantInduction.fluidMixture.setIcons(fluidIconMap.get(Reference.PREFIX + "mixture")); //ResonantInduction.fluidMixture.setIcons(fluidIconMap.get(Reference.PREFIX + "mixture"));
} }
} }

View file

@ -3,13 +3,15 @@
*/ */
package resonantinduction.core.handler; package resonantinduction.core.handler;
import calclavia.components.tool.ToolMode;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.event.Event.Result;
import net.minecraftforge.event.ForgeSubscribe;
import universalelectricity.api.vector.VectorWorld; import universalelectricity.api.vector.VectorWorld;
import calclavia.components.tool.ToolMode;
import codechicken.multipart.ControlKeyModifer; import codechicken.multipart.ControlKeyModifer;
/** /**
@ -50,7 +52,7 @@ public class ToolModeLink extends ToolMode
((ILinkable) tile).onLink(player, this.getLink(stack)); ((ILinkable) tile).onLink(player, this.getLink(stack));
} }
} }
return true; return true;
} }

View file

@ -6,34 +6,32 @@ package resonantinduction.core.prefab.block;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraftforge.common.Configuration; import net.minecraftforge.common.Configuration;
import resonantinduction.core.Reference; import resonantinduction.core.Reference;
import resonantinduction.core.Settings;
import resonantinduction.core.TabRI; import resonantinduction.core.TabRI;
import resonantinduction.core.Settings;
import universalelectricity.api.UniversalElectricity; import universalelectricity.api.UniversalElectricity;
import calclavia.lib.prefab.block.BlockSidedIO; import calclavia.lib.prefab.block.BlockSidedIO;
/** /** Blocks that have specific sided input and output should extend this.
* Blocks that have specific sided input and output should extend this.
* *
* @author Calclavia * @author Calclavia */
*/
public class BlockIOBase extends BlockSidedIO public class BlockIOBase extends BlockSidedIO
{ {
public BlockIOBase(String name) public BlockIOBase(String name)
{ {
this(name, Settings.getNextBlockID()); this(name, Settings.getNextBlockID());
} }
public BlockIOBase(String name, int id) public BlockIOBase(String name, int id)
{ {
this(name, id, UniversalElectricity.machine); this(name, id, UniversalElectricity.machine);
} }
public BlockIOBase(String name, int id, Material material) public BlockIOBase(String name, int id, Material material)
{ {
super(Settings.CONFIGURATION.get(Configuration.CATEGORY_BLOCK, name, id).getInt(id), material); super(Settings.CONFIGURATION.get(Configuration.CATEGORY_BLOCK, name, id).getInt(id), material);
this.setCreativeTab(TabRI.CORE); this.setCreativeTab(TabRI.CORE);
this.setUnlocalizedName(Reference.PREFIX + name); this.setUnlocalizedName(Reference.PREFIX + name);
this.setTextureName(Reference.PREFIX + name); this.setTextureName(Reference.PREFIX + name);
this.setHardness(1f); this.setHardness(1f);
} }
} }

View file

@ -4,8 +4,8 @@ import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraftforge.common.Configuration; import net.minecraftforge.common.Configuration;
import resonantinduction.core.Reference; import resonantinduction.core.Reference;
import resonantinduction.core.Settings;
import resonantinduction.core.TabRI; import resonantinduction.core.TabRI;
import resonantinduction.core.Settings;
import universalelectricity.api.UniversalElectricity; import universalelectricity.api.UniversalElectricity;
import calclavia.lib.prefab.block.BlockTile; import calclavia.lib.prefab.block.BlockTile;
import codechicken.multipart.ControlKeyModifer; import codechicken.multipart.ControlKeyModifer;

View file

@ -3,8 +3,8 @@ package resonantinduction.core.prefab.block;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraftforge.common.Configuration; import net.minecraftforge.common.Configuration;
import resonantinduction.core.Reference; import resonantinduction.core.Reference;
import resonantinduction.core.Settings;
import resonantinduction.core.TabRI; import resonantinduction.core.TabRI;
import resonantinduction.core.Settings;
import universalelectricity.api.UniversalElectricity; import universalelectricity.api.UniversalElectricity;
import calclavia.lib.prefab.block.BlockRotatable; import calclavia.lib.prefab.block.BlockRotatable;
import codechicken.multipart.ControlKeyModifer; import codechicken.multipart.ControlKeyModifer;

View file

@ -3,8 +3,8 @@ package resonantinduction.core.prefab.item;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraftforge.common.Configuration; import net.minecraftforge.common.Configuration;
import resonantinduction.core.Reference; import resonantinduction.core.Reference;
import resonantinduction.core.Settings;
import resonantinduction.core.TabRI; import resonantinduction.core.TabRI;
import resonantinduction.core.Settings;
/** @author Calclavia */ /** @author Calclavia */
public class ItemRI extends Item public class ItemRI extends Item

View file

@ -2,8 +2,8 @@ package resonantinduction.core.prefab.part;
import net.minecraftforge.common.Configuration; import net.minecraftforge.common.Configuration;
import resonantinduction.core.Reference; import resonantinduction.core.Reference;
import resonantinduction.core.Settings;
import resonantinduction.core.TabRI; import resonantinduction.core.TabRI;
import resonantinduction.core.Settings;
import codechicken.multipart.JItemMultiPart; import codechicken.multipart.JItemMultiPart;
/** /**

View file

@ -50,7 +50,7 @@ public class PacketMultiPart extends PacketType
int y = data.readInt(); int y = data.readInt();
int z = data.readInt(); int z = data.readInt();
TileEntity tileEntity = player.worldObj.getBlockTileEntity(x, y, z); TileEntity tileEntity = player.worldObj.getBlockTileEntity(x, y, z);
if (tileEntity instanceof TileMultipart) if (tileEntity instanceof TileMultipart)
{ {
TMultiPart part = ((TileMultipart) tileEntity).partMap(data.readInt()); TMultiPart part = ((TileMultipart) tileEntity).partMap(data.readInt());

View file

@ -13,135 +13,133 @@ import calclavia.lib.prefab.tile.TileElectrical;
import com.google.common.io.ByteArrayDataInput; import com.google.common.io.ByteArrayDataInput;
/** /** Prefab for general machines
* Prefab for general machines
* *
* @author Darkguardsman * @author Darkguardsman */
*/
public class TileMachine extends TileElectrical implements IPacketReceiverWithID public class TileMachine extends TileElectrical implements IPacketReceiverWithID
{ {
/** Is the machine functioning normally */ /** Is the machine functioning normally */
protected boolean functioning = false; protected boolean functioning = false;
/** Prev state of function of last update */ /** Prev state of function of last update */
protected boolean prevFunctioning = false; protected boolean prevFunctioning = false;
protected long joulesPerTick = 0; protected long joulesPerTick = 0;
public static final int IS_RUN_PACKET_ID = 0; public static final int IS_RUN_PACKET_ID = 0;
public static final int NBT_PACKET_ID = 1; public static final int NBT_PACKET_ID = 1;
public static final int ENERGY_PACKET_ID = 2; public static final int ENERGY_PACKET_ID = 2;
@Override @Override
public void updateEntity() public void updateEntity()
{ {
super.updateEntity(); super.updateEntity();
if (!this.worldObj.isRemote) if (!this.worldObj.isRemote)
{ {
this.prevFunctioning = this.functioning; this.prevFunctioning = this.functioning;
this.functioning = this.isFunctioning(); this.functioning = this.isFunctioning();
if (prevFunctioning != this.functioning) if (prevFunctioning != this.functioning)
{ {
this.sendRunningPacket(); this.sendRunningPacket();
} }
if (this.isFunctioning()) if(this.isFunctioning())
{ {
this.consumePower(true); this.consumePower(true);
} }
} }
} }
public boolean consumePower(boolean doConsume) public boolean consumePower(boolean doConsume)
{ {
return this.consumePower(this.joulesPerTick, doConsume); return this.consumePower(this.joulesPerTick, doConsume);
} }
public boolean consumePower(long joules, boolean doConsume) public boolean consumePower(long joules, boolean doConsume)
{ {
return this.energy.extractEnergy(joules, doConsume) >= joules; return this.energy.extractEnergy(joules, doConsume) >= joules;
} }
/** Can this tile function, or run threw normal processes */ /** Can this tile function, or run threw normal processes */
public boolean canFunction() public boolean canFunction()
{ {
return this.consumePower(false); return this.consumePower(false);
} }
/** Called too see if the machine is functioning, server side it redirects to canFunction */ /** Called too see if the machine is functioning, server side it redirects to canFunction */
public boolean isFunctioning() public boolean isFunctioning()
{ {
if (this.worldObj.isRemote) if (this.worldObj.isRemote)
{ {
return this.functioning; return this.functioning;
} }
else else
{ {
return this.canFunction(); return this.canFunction();
} }
} }
@Override @Override
public boolean onReceivePacket(int id, ByteArrayDataInput data, EntityPlayer player, Object... extra) public boolean onReceivePacket(int id, ByteArrayDataInput data, EntityPlayer player, Object... extra)
{ {
try try
{ {
if (this.worldObj.isRemote) if (this.worldObj.isRemote)
{ {
if (id == IS_RUN_PACKET_ID) if (id == IS_RUN_PACKET_ID)
{ {
this.functioning = data.readBoolean(); this.functioning = data.readBoolean();
return true; return true;
} }
if (id == NBT_PACKET_ID) if (id == NBT_PACKET_ID)
{ {
this.readFromNBT(PacketHandler.readNBTTagCompound(data)); this.readFromNBT(PacketHandler.readNBTTagCompound(data));
return true; return true;
} }
if (id == ENERGY_PACKET_ID) if (id == ENERGY_PACKET_ID)
{ {
this.energy.readFromNBT(PacketHandler.readNBTTagCompound(data)); this.energy.readFromNBT(PacketHandler.readNBTTagCompound(data));
return true; return true;
} }
} }
} }
catch (IOException e) catch (IOException e)
{ {
e.printStackTrace(); e.printStackTrace();
} }
return false; return false;
} }
/** Sends the tileEntity save data to the client */ /** Sends the tileEntity save data to the client */
public void sendNBTPacket() public void sendNBTPacket()
{ {
if (!this.worldObj.isRemote) if (!this.worldObj.isRemote)
{ {
NBTTagCompound tag = new NBTTagCompound(); NBTTagCompound tag = new NBTTagCompound();
this.writeToNBT(tag); this.writeToNBT(tag);
PacketHandler.sendPacketToClients(ResonantInduction.PACKET_TILE.getPacket(this, NBT_PACKET_ID, this, tag), worldObj, new Vector3(this), 64); PacketHandler.sendPacketToClients(ResonantInduction.PACKET_TILE.getPacket(this, NBT_PACKET_ID, this, tag), worldObj, new Vector3(this), 64);
} }
} }
/** Sends a simple true/false am running power update */ /** Sends a simple true/false am running power update */
public void sendRunningPacket() public void sendRunningPacket()
{ {
if (!this.worldObj.isRemote) if (!this.worldObj.isRemote)
{ {
PacketHandler.sendPacketToClients(ResonantInduction.PACKET_TILE.getPacket(this, IS_RUN_PACKET_ID, this, this.functioning), worldObj, new Vector3(this), 64); PacketHandler.sendPacketToClients(ResonantInduction.PACKET_TILE.getPacket(this, IS_RUN_PACKET_ID, this, this.functioning), worldObj, new Vector3(this), 64);
} }
} }
public void sendPowerPacket() public void sendPowerPacket()
{ {
if (!this.worldObj.isRemote) if (!this.worldObj.isRemote)
{ {
PacketHandler.sendPacketToClients(ResonantInduction.PACKET_TILE.getPacket(this, ENERGY_PACKET_ID, this, this.energy.writeToNBT(new NBTTagCompound())), worldObj, new Vector3(this), 64); PacketHandler.sendPacketToClients(ResonantInduction.PACKET_TILE.getPacket(this, ENERGY_PACKET_ID, this, this.energy.writeToNBT(new NBTTagCompound())), worldObj, new Vector3(this), 64);
} }
} }
@Override @Override
public Packet getDescriptionPacket() public Packet getDescriptionPacket()
{ {
return ResonantInduction.PACKET_TILE.getPacket(this, this.functioning); return ResonantInduction.PACKET_TILE.getPacket(this, this.functioning);
} }
} }

View file

@ -21,6 +21,7 @@ import org.lwjgl.opengl.GL11;
import universalelectricity.api.vector.Vector3; import universalelectricity.api.vector.Vector3;
import calclavia.lib.render.RenderUtility; import calclavia.lib.render.RenderUtility;
import calclavia.lib.utility.WorldUtility; import calclavia.lib.utility.WorldUtility;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;

View file

@ -15,6 +15,7 @@ import resonantinduction.mechanical.gear.ItemGear;
import resonantinduction.mechanical.gear.ItemGearShaft; import resonantinduction.mechanical.gear.ItemGearShaft;
import resonantinduction.mechanical.gear.RenderGear; import resonantinduction.mechanical.gear.RenderGear;
import resonantinduction.mechanical.gear.RenderGearShaft; import resonantinduction.mechanical.gear.RenderGearShaft;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
@ -58,7 +59,7 @@ public class RenderRIItem implements IItemRenderer
} }
else if (item.getItem() instanceof ItemMultimeter) else if (item.getItem() instanceof ItemMultimeter)
{ {
RenderMultimeter.render(); RenderMultimeter.INSTANCE.render();
} }
else if (item.getItem() instanceof ItemTransformer) else if (item.getItem() instanceof ItemTransformer)
{ {

View file

@ -5,9 +5,13 @@ import java.util.Random;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityFallingSand;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
import resonantinduction.core.Reference; import resonantinduction.core.Reference;
@ -42,7 +46,7 @@ public class BlockDust extends BlockRI
if (tileEntity instanceof TileMaterial) if (tileEntity instanceof TileMaterial)
{ {
((TileMaterial) tileEntity).name = ItemOreResource.getMaterialFromStack(itemStack); ((TileMaterial) tileEntity).name = ((ItemOreResource) itemStack.getItem()).getMaterialFromStack(itemStack);
} }
} }
@ -143,7 +147,7 @@ public class BlockDust extends BlockRI
{ {
int l = par1World.getBlockMetadata(par2, par3, par4) & 7; int l = par1World.getBlockMetadata(par2, par3, par4) & 7;
float f = 0.125F; float f = 0.125F;
return AxisAlignedBB.getAABBPool().getAABB(par2 + this.minX, par3 + this.minY, par4 + this.minZ, par2 + this.maxX, par3 + l * f, par4 + this.maxZ); return AxisAlignedBB.getAABBPool().getAABB((double) par2 + this.minX, (double) par3 + this.minY, (double) par4 + this.minZ, (double) par2 + this.maxX, (double) ((float) par3 + (float) l * f), (double) par4 + this.maxZ);
} }
/** /**
@ -193,7 +197,7 @@ public class BlockDust extends BlockRI
protected void setBlockBoundsForDepth(int par1) protected void setBlockBoundsForDepth(int par1)
{ {
int j = par1 & 7; int j = par1 & 7;
float f = 2 * (1 + j) / 16.0F; float f = (float) (2 * (1 + j)) / 16.0F;
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, f, 1.0F); this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, f, 1.0F);
} }

View file

@ -1,14 +1,18 @@
package resonantinduction.core.resource; package resonantinduction.core.resource;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.packet.Packet;
import resonantinduction.core.ResonantInduction; import resonantinduction.core.ResonantInduction;
import calclavia.lib.network.IPacketReceiver;
import calclavia.lib.prefab.tile.TileAdvanced;
import com.google.common.io.ByteArrayDataInput; import com.google.common.io.ByteArrayDataInput;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.packet.Packet;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockAccess;
import calclavia.lib.network.IPacketReceiver;
import calclavia.lib.prefab.tile.TileAdvanced;
/** /**
* A tile that stores the material name. * A tile that stores the material name.
* *

View file

@ -1,6 +1,9 @@
package resonantinduction.core.resource.fluid; package resonantinduction.core.resource.fluid;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.Configuration; import net.minecraftforge.common.Configuration;
@ -9,8 +12,10 @@ import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import resonantinduction.core.Reference; import resonantinduction.core.Reference;
import resonantinduction.core.ResonantInduction;
import resonantinduction.core.Settings; import resonantinduction.core.Settings;
import resonantinduction.core.resource.ResourceGenerator; import resonantinduction.core.resource.ResourceGenerator;
import resonantinduction.core.resource.TileMaterial;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;

View file

@ -3,6 +3,8 @@ package resonantinduction.core.resource.fluid;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import com.google.common.io.ByteArrayDataInput;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
@ -15,9 +17,6 @@ import resonantinduction.core.ResonantInduction;
import resonantinduction.core.resource.ResourceGenerator; import resonantinduction.core.resource.ResourceGenerator;
import calclavia.lib.network.IPacketReceiver; import calclavia.lib.network.IPacketReceiver;
import calclavia.lib.prefab.tile.TileAdvanced; import calclavia.lib.prefab.tile.TileAdvanced;
import com.google.common.io.ByteArrayDataInput;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;

View file

@ -6,6 +6,7 @@ import net.minecraft.block.Block;
import net.minecraft.creativetab.CreativeTabs; import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.oredict.OreDictionary; import net.minecraftforge.oredict.OreDictionary;
@ -19,6 +20,7 @@ import resonantinduction.core.resource.TileMaterial;
import universalelectricity.api.vector.Vector3; import universalelectricity.api.vector.Vector3;
import calclavia.lib.utility.LanguageUtility; import calclavia.lib.utility.LanguageUtility;
import calclavia.lib.utility.inventory.InventoryUtility; import calclavia.lib.utility.inventory.InventoryUtility;
import calclavia.lib.utility.nbt.NBTUtility;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
@ -90,7 +92,7 @@ public class ItemOreResource extends ItemRI
if (k1 <= 6 && world.checkNoEntityCollision(block.getCollisionBoundingBoxFromPool(world, x, y, z)) && world.setBlockMetadataWithNotify(x, y, z, k1 + 1 | j1 & -8, 2)) if (k1 <= 6 && world.checkNoEntityCollision(block.getCollisionBoundingBoxFromPool(world, x, y, z)) && world.setBlockMetadataWithNotify(x, y, z, k1 + 1 | j1 & -8, 2))
{ {
world.playSoundEffect(x + 0.5F, y + 0.5F, z + 0.5F, block.stepSound.getPlaceSound(), (block.stepSound.getVolume() + 1.0F) / 2.0F, block.stepSound.getPitch() * 0.8F); world.playSoundEffect((double) ((float) x + 0.5F), (double) ((float) y + 0.5F), (double) ((float) z + 0.5F), block.stepSound.getPlaceSound(), (block.stepSound.getVolume() + 1.0F) / 2.0F, block.stepSound.getPitch() * 0.8F);
--stack.stackSize; --stack.stackSize;
return true; return true;
} }
@ -135,7 +137,7 @@ public class ItemOreResource extends ItemRI
if (placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, k1)) if (placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, k1))
{ {
world.playSoundEffect(x + 0.5F, y + 0.5F, z + 0.5F, block.stepSound.getPlaceSound(), (block.stepSound.getVolume() + 1.0F) / 2.0F, block.stepSound.getPitch() * 0.8F); world.playSoundEffect((double) ((float) x + 0.5F), (double) ((float) y + 0.5F), (double) ((float) z + 0.5F), block.stepSound.getPlaceSound(), (block.stepSound.getVolume() + 1.0F) / 2.0F, block.stepSound.getPitch() * 0.8F);
--stack.stackSize; --stack.stackSize;
} }

View file

@ -13,102 +13,108 @@ import resonantinduction.core.prefab.item.ItemRI;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
/** /** A meta data item containing parts of various crafting recipes. These parts do not do anything but
* A meta data item containing parts of various crafting recipes. These parts do not do anything but
* allow new crafting recipes to be created. * allow new crafting recipes to be created.
* *
* @author DarkGuardsman * @author DarkGuardsman */
*/
public class ItemParts extends ItemRI public class ItemParts extends ItemRI
{ {
public ItemParts() public ItemParts()
{ {
super("DMParts", Settings.getNextItemID()); super("DMParts", Settings.getNextItemID());
this.setHasSubtypes(true); this.setHasSubtypes(true);
this.setMaxDamage(0); this.setMaxDamage(0);
this.setMaxStackSize(64); this.setMaxStackSize(64);
this.setCreativeTab(CreativeTabs.tabMaterials); this.setCreativeTab(CreativeTabs.tabMaterials);
} }
@Override @Override
public String getUnlocalizedName(ItemStack itemStack) public String getUnlocalizedName(ItemStack itemStack)
{ {
if (itemStack != null && itemStack.getItemDamage() < Parts.values().length) if (itemStack != null && itemStack.getItemDamage() < Parts.values().length)
{ {
return "item." + Parts.values()[itemStack.getItemDamage()].name; return "item." + Parts.values()[itemStack.getItemDamage()].name;
} }
return super.getUnlocalizedName(); return super.getUnlocalizedName();
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public Icon getIconFromDamage(int meta) public Icon getIconFromDamage(int meta)
{ {
if (meta < Parts.values().length) if (meta < Parts.values().length)
{ {
return Parts.values()[meta].icon; return Parts.values()[meta].icon;
} }
return this.itemIcon; return this.itemIcon;
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void registerIcons(IconRegister iconRegister) public void registerIcons(IconRegister iconRegister)
{ {
super.registerIcons(iconRegister); super.registerIcons(iconRegister);
for (Parts part : Parts.values()) for (Parts part : Parts.values())
{ {
part.icon = iconRegister.registerIcon(Reference.PREFIX + "part." + part.name); part.icon = iconRegister.registerIcon(Reference.PREFIX + "part." + part.name);
} }
} }
@Override @Override
public int getMetadata(int meta) public int getMetadata(int meta)
{ {
return meta; return meta;
} }
@Override @Override
public void getSubItems(int blockID, CreativeTabs tab, List itemStackList) public void getSubItems(int blockID, CreativeTabs tab, List itemStackList)
{ {
for (Parts part : Parts.values()) for (Parts part : Parts.values())
{ {
if (part.show) if (part.show)
{ {
itemStackList.add(new ItemStack(this, 1, part.ordinal())); itemStackList.add(new ItemStack(this, 1, part.ordinal()));
} }
} }
} }
public static enum Parts public static enum Parts
{ {
Seal("leatherSeal"), GasSeal("gasSeal"), Tank("unfinishedTank"), Valve("valvePart"), Seal("leatherSeal"),
MiningIcon("miningIcon", false), CircuitBasic("circuitBasic"), GasSeal("gasSeal"),
CircuitAdvanced("circuitAdvanced"), CircuitElite("circuitElite"), Motor("motor"), Tank("unfinishedTank"),
IC("ic_chip"), COIL("coilCopper"), LASER("diodeLaser"); Valve("valvePart"),
MiningIcon("miningIcon", false),
CircuitBasic("circuitBasic"),
CircuitAdvanced("circuitAdvanced"),
CircuitElite("circuitElite"),
Motor("motor"),
IC("ic_chip"),
COIL("coilCopper"),
LASER("diodeLaser");
public String name; public String name;
public Icon icon; public Icon icon;
boolean show = true; boolean show = true;
private Parts(String name) private Parts(String name)
{ {
this.name = name; this.name = name;
} }
private Parts(String name, boolean show) private Parts(String name, boolean show)
{ {
this(name); this(name);
this.show = show; this.show = show;
} }
} }
public void loadOreNames() public void loadOreNames()
{ {
for (Parts part : Parts.values()) for (Parts part : Parts.values())
{ {
OreDictionary.registerOre(part.name, new ItemStack(this, 1, part.ordinal())); OreDictionary.registerOre(part.name, new ItemStack(this, 1, part.ordinal()));
} }
} }
} }

View file

@ -8,17 +8,22 @@ import net.minecraft.block.Block;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityFurnace;
import net.minecraftforge.oredict.OreDictionary; import net.minecraftforge.oredict.OreDictionary;
import net.minecraftforge.oredict.ShapedOreRecipe; import net.minecraftforge.oredict.ShapedOreRecipe;
import net.minecraftforge.oredict.ShapelessOreRecipe; import net.minecraftforge.oredict.ShapelessOreRecipe;
import resonantinduction.core.Reference; import resonantinduction.core.Reference;
import resonantinduction.core.ResonantInduction; import resonantinduction.core.ResonantInduction;
import resonantinduction.core.Settings;
import resonantinduction.core.TabRI; import resonantinduction.core.TabRI;
import resonantinduction.core.Settings;
import resonantinduction.electrical.battery.BlockBattery; import resonantinduction.electrical.battery.BlockBattery;
import resonantinduction.electrical.battery.ItemBlockBattery; import resonantinduction.electrical.battery.ItemBlockBattery;
import resonantinduction.electrical.battery.TileBattery; import resonantinduction.electrical.battery.TileBattery;
import resonantinduction.electrical.encoder.BlockEncoder;
import resonantinduction.electrical.encoder.ItemDisk; import resonantinduction.electrical.encoder.ItemDisk;
import resonantinduction.electrical.encoder.TileEncoder;
import resonantinduction.electrical.furnace.BlockAdvancedFurnace;
import resonantinduction.electrical.furnace.TileAdvancedFurnace;
import resonantinduction.electrical.generator.BlockGenerator; import resonantinduction.electrical.generator.BlockGenerator;
import resonantinduction.electrical.generator.TileGenerator; import resonantinduction.electrical.generator.TileGenerator;
import resonantinduction.electrical.generator.solar.BlockSolarPanel; import resonantinduction.electrical.generator.solar.BlockSolarPanel;

View file

@ -69,7 +69,7 @@ public class BlockArmbot extends BlockRI implements IBlockInfo
((TileArmbot) tileEntity).dropHeldObject(); ((TileArmbot) tileEntity).dropHeldObject();
CalclaviaLoader.blockMulti.destroyMultiBlockStructure((TileArmbot) tileEntity); CalclaviaLoader.blockMulti.destroyMultiBlockStructure((TileArmbot) tileEntity);
} }
this.dropBlockAsItem_do(world, x, y, z, new ItemStack(this)); this.dropBlockAsItem_do(world, x, y, z, new ItemStack(this));
super.breakBlock(world, x, y, z, par5, par6); super.breakBlock(world, x, y, z, par5, par6);
} }

View file

@ -20,7 +20,7 @@ public class BatteryNetwork extends Network<BatteryNetwork, TileBattery>
/** /**
* Apply energy loss. * Apply energy loss.
*/ */
double percentageLoss = Math.max(0, (1 - (getConnectors().size() * 6 / 100d))); double percentageLoss = Math.max(0, (1 - ((double) (getConnectors().size() * 6) / 100d)));
long energyLoss = (long) (percentageLoss * 100); long energyLoss = (long) (percentageLoss * 100);
totalEnergy -= energyLoss; totalEnergy -= energyLoss;
@ -37,7 +37,7 @@ public class BatteryNetwork extends Network<BatteryNetwork, TileBattery>
if (battery != firstNode && !Arrays.asList(exclusion).contains(battery)) if (battery != firstNode && !Arrays.asList(exclusion).contains(battery))
{ {
double percentage = ((double) battery.energy.getEnergyCapacity() / (double) totalCapacity); double percentage = ((double) battery.energy.getEnergyCapacity() / (double) totalCapacity);
long energyForBattery = Math.round(totalEnergy * percentage); long energyForBattery = (long) Math.round(totalEnergy * percentage);
battery.energy.setEnergy(energyForBattery); battery.energy.setEnergy(energyForBattery);
remainingEnergy -= energyForBattery; remainingEnergy -= energyForBattery;
} }

View file

@ -52,10 +52,10 @@ public class BlockBattery extends BlockIOBase implements ITileEntityProvider
{ {
ItemBlockBattery itemBlock = (ItemBlockBattery) itemStack.getItem(); ItemBlockBattery itemBlock = (ItemBlockBattery) itemStack.getItem();
TileBattery battery = (TileBattery) world.getBlockTileEntity(x, y, z); TileBattery battery = (TileBattery) world.getBlockTileEntity(x, y, z);
battery.energy.setCapacity(TileBattery.getEnergyForTier(ItemBlockBattery.getTier(itemStack))); battery.energy.setCapacity(TileBattery.getEnergyForTier(itemBlock.getTier(itemStack)));
battery.energy.setEnergy(itemBlock.getEnergy(itemStack)); battery.energy.setEnergy(itemBlock.getEnergy(itemStack));
battery.updateStructure(); battery.updateStructure();
world.setBlockMetadataWithNotify(x, y, z, ItemBlockBattery.getTier(itemStack), 3); world.setBlockMetadataWithNotify(x, y, z, itemBlock.getTier(itemStack), 3);
} }
} }
@ -96,7 +96,7 @@ public class BlockBattery extends BlockIOBase implements ITileEntityProvider
{ {
TileBattery battery = (TileBattery) world.getBlockTileEntity(x, y, z); TileBattery battery = (TileBattery) world.getBlockTileEntity(x, y, z);
ItemBlockBattery itemBlock = (ItemBlockBattery) itemStack.getItem(); ItemBlockBattery itemBlock = (ItemBlockBattery) itemStack.getItem();
ItemBlockBattery.setTier(itemStack, (byte) metadata); itemBlock.setTier(itemStack, (byte) metadata);
itemBlock.setEnergy(itemStack, battery.energy.getEnergy()); itemBlock.setEnergy(itemStack, battery.energy.getEnergy());
} }

View file

@ -137,7 +137,7 @@ public class TileBattery extends TileElectrical implements IConnector<BatteryNet
{ {
ArrayList data = new ArrayList(); ArrayList data = new ArrayList();
data.add(energy.getEnergy()); data.add(energy.getEnergy());
data.add(ioMap); data.add((short) ioMap);
return data; return data;
} }

View file

@ -24,210 +24,210 @@ import cpw.mods.fml.common.network.PacketDispatcher;
public class TileEncoder extends TileExternalInventory implements ISidedInventory, IPacketReceiver public class TileEncoder extends TileExternalInventory implements ISidedInventory, IPacketReceiver
{ {
private ItemStack disk; private ItemStack disk;
private IInventoryWatcher watcher; private IInventoryWatcher watcher;
public static final int PROGRAM_PACKET_ID = 0; public static final int PROGRAM_PACKET_ID = 0;
public static final int PROGRAM_CHANGE_PACKET_ID = 1; public static final int PROGRAM_CHANGE_PACKET_ID = 1;
public static final int REMOVE_TASK_PACKET_ID = 2; public static final int REMOVE_TASK_PACKET_ID = 2;
public static final int NEW_TASK_PACKET_ID = 3; public static final int NEW_TASK_PACKET_ID = 3;
protected IProgram program; protected IProgram program;
@Override @Override
public void initiate() public void initiate()
{ {
super.initiate(); super.initiate();
if (!this.worldObj.isRemote) if (!this.worldObj.isRemote)
{ {
program = new Program(); program = new Program();
program.setTaskAt(0, 0, new TaskRotateTo()); program.setTaskAt(0, 0, new TaskRotateTo());
} }
} }
@Override @Override
public void onInventoryChanged() public void onInventoryChanged()
{ {
super.onInventoryChanged(); super.onInventoryChanged();
if (watcher != null) if (watcher != null)
{ {
watcher.inventoryChanged(); watcher.inventoryChanged();
} }
} }
@Override @Override
public String getInvName() public String getInvName()
{ {
return "Encoder"; return "Encoder";
} }
@Override @Override
public int getInventoryStackLimit() public int getInventoryStackLimit()
{ {
return 1; return 1;
} }
public void setWatcher(IInventoryWatcher watcher) public void setWatcher(IInventoryWatcher watcher)
{ {
this.watcher = watcher; this.watcher = watcher;
} }
public IInventoryWatcher getWatcher() public IInventoryWatcher getWatcher()
{ {
return this.watcher; return this.watcher;
} }
@Override @Override
public void writeToNBT(NBTTagCompound nbt) public void writeToNBT(NBTTagCompound nbt)
{ {
super.writeToNBT(nbt); super.writeToNBT(nbt);
if (this.disk != null) if (this.disk != null)
{ {
NBTTagCompound diskNBT = new NBTTagCompound(); NBTTagCompound diskNBT = new NBTTagCompound();
this.disk.writeToNBT(diskNBT); this.disk.writeToNBT(diskNBT);
nbt.setCompoundTag("disk", diskNBT); nbt.setCompoundTag("disk", diskNBT);
} }
} }
@Override @Override
public void readFromNBT(NBTTagCompound nbt) public void readFromNBT(NBTTagCompound nbt)
{ {
super.readFromNBT(nbt); super.readFromNBT(nbt);
NBTTagCompound diskNBT = nbt.getCompoundTag("disk"); NBTTagCompound diskNBT = nbt.getCompoundTag("disk");
if (diskNBT != null) if (diskNBT != null)
{ {
this.disk = ItemStack.loadItemStackFromNBT(diskNBT); this.disk = ItemStack.loadItemStackFromNBT(diskNBT);
} }
} }
@Override @Override
public void onReceivePacket(ByteArrayDataInput data, EntityPlayer player, Object... extra) public void onReceivePacket(ByteArrayDataInput data, EntityPlayer player, Object... extra)
{ {
try try
{ {
int readInt = data.readInt(); int readInt = data.readInt();
if (readInt == PROGRAM_PACKET_ID) if (readInt == PROGRAM_PACKET_ID)
{ {
if (data.readBoolean()) if (data.readBoolean())
{ {
Program program = new Program(); Program program = new Program();
program.load(PacketHandler.readNBTTagCompound(data)); program.load(PacketHandler.readNBTTagCompound(data));
this.program = program; this.program = program;
} }
else else
{ {
this.program = null; this.program = null;
} }
} }
else if (readInt == PROGRAM_CHANGE_PACKET_ID) else if (readInt == PROGRAM_CHANGE_PACKET_ID)
{ {
ITask task = TaskRegistry.getCommand(data.readUTF()); ITask task = TaskRegistry.getCommand(data.readUTF());
task.setPosition(data.readInt(), data.readInt()); task.setPosition(data.readInt(), data.readInt());
task.load(PacketHandler.readNBTTagCompound(data)); task.load(PacketHandler.readNBTTagCompound(data));
this.getProgram().setTaskAt(task.getCol(), task.getRow(), task); this.getProgram().setTaskAt(task.getCol(), task.getRow(), task);
this.sendGUIPacket(); this.sendGUIPacket();
} }
else if (readInt == NEW_TASK_PACKET_ID) else if (readInt == NEW_TASK_PACKET_ID)
{ {
ITask task = TaskRegistry.getCommand(data.readUTF()); ITask task = TaskRegistry.getCommand(data.readUTF());
task.setPosition(data.readInt(), data.readInt()); task.setPosition(data.readInt(), data.readInt());
task.load(PacketHandler.readNBTTagCompound(data)); task.load(PacketHandler.readNBTTagCompound(data));
this.getProgram().insertTask(task.getCol(), task.getRow(), task); this.getProgram().insertTask(task.getCol(), task.getRow(), task);
this.sendGUIPacket(); this.sendGUIPacket();
} }
else if (readInt == REMOVE_TASK_PACKET_ID) else if (readInt == REMOVE_TASK_PACKET_ID)
{ {
this.getProgram().setTaskAt(data.readInt(), data.readInt(), null); this.getProgram().setTaskAt(data.readInt(), data.readInt(), null);
this.sendGUIPacket(); this.sendGUIPacket();
} }
} }
catch (IOException e) catch (IOException e)
{ {
e.printStackTrace(); e.printStackTrace();
} }
} }
private void sendGUIPacket() private void sendGUIPacket()
{ {
// TODO Auto-generated method stub // TODO Auto-generated method stub
}
} @Override
public Packet getDescriptionPacket()
{
NBTTagCompound tag = new NBTTagCompound();
boolean exists = this.program != null;
if (exists)
{
this.program.save(tag);
}
return ResonantInduction.PACKET_TILE.getPacket(this, TileEncoder.PROGRAM_PACKET_ID, this, exists, tag);
@Override }
public Packet getDescriptionPacket()
{
NBTTagCompound tag = new NBTTagCompound();
boolean exists = this.program != null;
if (exists)
{
this.program.save(tag);
}
return ResonantInduction.PACKET_TILE.getPacket(this, TileEncoder.PROGRAM_PACKET_ID, this, exists, tag);
} public void removeTask(Vector2 vec)
{
if (vec != null)
{
if (this.worldObj.isRemote)
{
PacketDispatcher.sendPacketToServer(ResonantInduction.PACKET_TILE.getPacket(this, TileEncoder.REMOVE_TASK_PACKET_ID, this, vec.intX(), vec.intY()));
}
else
{
this.program.setTaskAt(vec.intX(), vec.intY(), null);
}
}
}
public void removeTask(Vector2 vec) public void updateTask(ITask editTask)
{ {
if (vec != null)
{
if (this.worldObj.isRemote)
{
PacketDispatcher.sendPacketToServer(ResonantInduction.PACKET_TILE.getPacket(this, TileEncoder.REMOVE_TASK_PACKET_ID, this, vec.intX(), vec.intY()));
}
else
{
this.program.setTaskAt(vec.intX(), vec.intY(), null);
}
}
}
public void updateTask(ITask editTask) if (editTask != null)
{ {
if (this.worldObj.isRemote)
{
NBTTagCompound nbt = new NBTTagCompound();
editTask.save(nbt);
PacketDispatcher.sendPacketToServer(ResonantInduction.PACKET_TILE.getPacket(this, PROGRAM_CHANGE_PACKET_ID, this, editTask.getMethodName(), editTask.getCol(), editTask.getRow(), nbt));
}
else
{
this.program.setTaskAt(editTask.getCol(), editTask.getRow(), editTask);
}
}
if (editTask != null) }
{
if (this.worldObj.isRemote)
{
NBTTagCompound nbt = new NBTTagCompound();
editTask.save(nbt);
PacketDispatcher.sendPacketToServer(ResonantInduction.PACKET_TILE.getPacket(this, PROGRAM_CHANGE_PACKET_ID, this, editTask.getMethodName(), editTask.getCol(), editTask.getRow(), nbt));
}
else
{
this.program.setTaskAt(editTask.getCol(), editTask.getRow(), editTask);
}
}
} public void insertTask(ITask editTask)
{
if (editTask != null)
{
if (this.worldObj.isRemote)
{
NBTTagCompound nbt = new NBTTagCompound();
editTask.save(nbt);
PacketDispatcher.sendPacketToServer(ResonantInduction.PACKET_TILE.getPacket(this, NEW_TASK_PACKET_ID, this, editTask.getMethodName(), editTask.getCol(), editTask.getRow(), nbt));
}
else
{
this.program.insertTask(editTask.getCol(), editTask.getRow(), editTask);
}
}
public void insertTask(ITask editTask) }
{
if (editTask != null)
{
if (this.worldObj.isRemote)
{
NBTTagCompound nbt = new NBTTagCompound();
editTask.save(nbt);
PacketDispatcher.sendPacketToServer(ResonantInduction.PACKET_TILE.getPacket(this, NEW_TASK_PACKET_ID, this, editTask.getMethodName(), editTask.getCol(), editTask.getRow(), nbt));
}
else
{
this.program.insertTask(editTask.getCol(), editTask.getRow(), editTask);
}
}
} public IProgram getProgram()
{
public IProgram getProgram() if (this.program == null)
{ {
if (this.program == null) this.program = new Program();
{ }
this.program = new Program(); return this.program;
} }
return this.program;
}
} }

View file

@ -4,6 +4,9 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World; import net.minecraft.world.World;
import resonantinduction.core.Reference; import resonantinduction.core.Reference;
import resonantinduction.core.prefab.block.BlockRI; import resonantinduction.core.prefab.block.BlockRI;
import resonantinduction.core.render.RIBlockRenderingHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockThermopile extends BlockRI public class BlockThermopile extends BlockRI
{ {

View file

@ -3,7 +3,9 @@ package resonantinduction.electrical.multimeter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
/** /**
* Graph for the multimeter * Graph for the multimeter

View file

@ -16,7 +16,6 @@ public class GraphF extends Graph<Float>
queue += value; queue += value;
} }
@Override
public void doneQueue() public void doneQueue()
{ {
super.doneQueue(); super.doneQueue();
@ -29,7 +28,6 @@ public class GraphF extends Graph<Float>
return 0f; return 0f;
} }
@Override
public void load(NBTTagCompound nbt) public void load(NBTTagCompound nbt)
{ {
super.load(nbt); super.load(nbt);
@ -43,7 +41,6 @@ public class GraphF extends Graph<Float>
} }
} }
@Override
public NBTTagCompound save() public NBTTagCompound save()
{ {
NBTTagCompound nbt = new NBTTagCompound(); NBTTagCompound nbt = new NBTTagCompound();

View file

@ -16,7 +16,6 @@ public class GraphL extends Graph<Long>
queue += value; queue += value;
} }
@Override
public void doneQueue() public void doneQueue()
{ {
super.doneQueue(); super.doneQueue();
@ -29,7 +28,6 @@ public class GraphL extends Graph<Long>
return 0L; return 0L;
} }
@Override
public void load(NBTTagCompound nbt) public void load(NBTTagCompound nbt)
{ {
super.load(nbt); super.load(nbt);
@ -42,7 +40,6 @@ public class GraphL extends Graph<Long>
} }
} }
@Override
public NBTTagCompound save() public NBTTagCompound save()
{ {
NBTTagCompound nbt = new NBTTagCompound(); NBTTagCompound nbt = new NBTTagCompound();

View file

@ -14,8 +14,10 @@ import resonantinduction.electrical.wire.EnumWireMaterial;
import calclavia.lib.utility.LanguageUtility; import calclavia.lib.utility.LanguageUtility;
import codechicken.lib.vec.BlockCoord; import codechicken.lib.vec.BlockCoord;
import codechicken.lib.vec.Vector3; import codechicken.lib.vec.Vector3;
import codechicken.multipart.ControlKeyModifer;
import codechicken.multipart.MultiPartRegistry; import codechicken.multipart.MultiPartRegistry;
import codechicken.multipart.TMultiPart; import codechicken.multipart.TMultiPart;
import codechicken.multipart.TileMultipart;
public class ItemMultimeter extends ItemMultipartBase public class ItemMultimeter extends ItemMultipartBase
{ {

View file

@ -29,7 +29,7 @@ public class ItemTransformer extends ItemMultipartBase
if (part != null) if (part != null)
{ {
int l = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3; int l = MathHelper.floor_double((double) (player.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
int facing = l == 0 ? 2 : (l == 1 ? 5 : (l == 2 ? 3 : (l == 3 ? 4 : 0))); int facing = l == 0 ? 2 : (l == 1 ? 5 : (l == 2 ? 3 : (l == 3 ? 4 : 0)));
part.preparePlacement(side, facing); part.preparePlacement(side, facing);
} }

View file

@ -14,8 +14,8 @@ import net.minecraftforge.common.ForgeDirection;
import org.lwjgl.input.Keyboard; import org.lwjgl.input.Keyboard;
import resonantinduction.core.Reference; import resonantinduction.core.Reference;
import resonantinduction.core.Settings;
import resonantinduction.core.TabRI; import resonantinduction.core.TabRI;
import resonantinduction.core.Settings;
import resonantinduction.core.Utility; import resonantinduction.core.Utility;
import resonantinduction.electrical.wire.flat.PartFlatWire; import resonantinduction.electrical.wire.flat.PartFlatWire;
import resonantinduction.electrical.wire.flat.RenderFlatWire; import resonantinduction.electrical.wire.flat.RenderFlatWire;

View file

@ -382,8 +382,8 @@ public class PartFlatWire extends PartAdvancedWire implements TFacePart, JNormal
{ {
// We found a wire! Merge networks! // We found a wire! Merge networks!
this.connections[absDir] = tp; this.connections[absDir] = tp;
if (tp instanceof PartFlatWire) if(tp instanceof PartFlatWire)
{ {
this.getNetwork().merge(((PartFlatWire) tp).getNetwork()); this.getNetwork().merge(((PartFlatWire) tp).getNetwork());
} }

View file

@ -283,7 +283,7 @@ public class PartFramedWire extends PartAdvancedWire implements TSlottedPart, JN
{ {
getNetwork().getConnectors().remove(this); getNetwork().getConnectors().remove(this);
super.bind(t); super.bind(t);
getNetwork().getConnectors().add(this); getNetwork().getConnectors().add((IConductor) this);
} }
else else
{ {
@ -372,7 +372,7 @@ public class PartFramedWire extends PartAdvancedWire implements TSlottedPart, JN
try try
{ {
this.getNetwork().removeConnector(this); this.getNetwork().removeConnector(this);
this.getNetwork().split(this); this.getNetwork().split((IConductor) this);
} }
catch (NullPointerException e) catch (NullPointerException e)
{ {

View file

@ -113,7 +113,7 @@ public class TraitConductor extends TileMultipart implements IConductor
} }
} }
} }
if (partMap(PartMap.CENTER.ordinal()) instanceof IConductor) if (partMap(PartMap.CENTER.ordinal()) instanceof IConductor)
{ {
return ((IConductor) partMap(PartMap.CENTER.ordinal())).onReceiveEnergy(from, receive, doReceive); return ((IConductor) partMap(PartMap.CENTER.ordinal())).onReceiveEnergy(from, receive, doReceive);

View file

@ -112,7 +112,7 @@ public class TraitEnergyHandler extends TileMultipart implements IEnergyHandler
@Override @Override
public boolean canInterface(ForgeDirection from) public boolean canInterface(ForgeDirection from)
{ {
if (partMap(from.ordinal()) == null) if (this.partMap(from.ordinal()) == null)
{ {
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
{ {

View file

@ -223,7 +223,6 @@ public class TileConveyorBelt extends TileMechanical implements IBelt, IRotatabl
return from != getDirection() || from != getDirection().getOpposite(); return from != getDirection() || from != getDirection().getOpposite();
} }
@Override
public void refresh() public void refresh()
{ {
boolean didRefresh = false; boolean didRefresh = false;
@ -270,7 +269,7 @@ public class TileConveyorBelt extends TileMechanical implements IBelt, IRotatabl
} }
else if (tile instanceof IMechanical) else if (tile instanceof IMechanical)
{ {
IMechanical mechanical = ((IMechanical) tile).getInstance(dir.getOpposite()); IMechanical mechanical = (IMechanical) ((IMechanical) tile).getInstance(dir.getOpposite());
if (mechanical != null) if (mechanical != null)
{ {

View file

@ -72,7 +72,6 @@ public abstract class FluidNetwork extends NodeNetwork<IFluidNetwork, IFluidConn
this.distributeConnectors(); this.distributeConnectors();
} }
@Override
public void reconstructConnector(IFluidConnector connector) public void reconstructConnector(IFluidConnector connector)
{ {
FluidTank tank = connector.getInternalTank(); FluidTank tank = connector.getInternalTank();

View file

@ -13,151 +13,149 @@ import resonantinduction.api.fluid.IFluidNetwork;
import resonantinduction.api.fluid.IFluidPipe; import resonantinduction.api.fluid.IFluidPipe;
import calclavia.lib.utility.FluidUtility; import calclavia.lib.utility.FluidUtility;
/** /** The network for pipe fluid transfer. getNodes() is NOT used.
* The network for pipe fluid transfer. getNodes() is NOT used.
* *
* @author DarkGuardsman * @author DarkGuardsman */
*/
public class PipeNetwork extends FluidNetwork public class PipeNetwork extends FluidNetwork
{ {
public HashMap<IFluidHandler, EnumSet<ForgeDirection>> sideMap = new HashMap<IFluidHandler, EnumSet<ForgeDirection>>(); public HashMap<IFluidHandler, EnumSet<ForgeDirection>> sideMap = new HashMap<IFluidHandler, EnumSet<ForgeDirection>>();
public HashMap<IFluidHandler, IFluidConnector> connectionMap = new HashMap<IFluidHandler, IFluidConnector>(); public HashMap<IFluidHandler, IFluidConnector> connectionMap = new HashMap<IFluidHandler, IFluidConnector>();
public int maxFlowRate = 0; public int maxFlowRate = 0;
public int maxPressure = 0; public int maxPressure = 0;
public int currentPressure = 0; public int currentPressure = 0;
public int currentFlowRate = 0; public int currentFlowRate = 0;
@Override @Override
public void update() public void update()
{ {
/* /*
* Slight delay to allow visual effect to take place before draining the pipe's internal * Slight delay to allow visual effect to take place before draining the pipe's internal
* tank * tank
*/ */
FluidStack stack = this.getTank().getFluid().copy(); FluidStack stack = this.getTank().getFluid().copy();
int count = this.sideMap.size(); int count = this.sideMap.size();
Iterator<Entry<IFluidHandler, EnumSet<ForgeDirection>>> it = new HashMap<IFluidHandler, EnumSet<ForgeDirection>>(sideMap).entrySet().iterator(); Iterator<Entry<IFluidHandler, EnumSet<ForgeDirection>>> it = new HashMap<IFluidHandler, EnumSet<ForgeDirection>>(sideMap).entrySet().iterator();
while (it.hasNext()) while (it.hasNext())
{ {
Entry<IFluidHandler, EnumSet<ForgeDirection>> entry = it.next(); Entry<IFluidHandler, EnumSet<ForgeDirection>> entry = it.next();
int sideCount = entry.getValue().size(); int sideCount = entry.getValue().size();
for (ForgeDirection dir : entry.getValue()) for (ForgeDirection dir : entry.getValue())
{ {
int volPer = (stack.amount / count); int volPer = (stack.amount / count);
int volPerSide = (volPer / sideCount); int volPerSide = (volPer / sideCount);
IFluidHandler handler = entry.getKey(); IFluidHandler handler = entry.getKey();
/* /*
* Don't input to tanks from the sides where the pipe is extraction mode. This * Don't input to tanks from the sides where the pipe is extraction mode. This
* prevents feed-back loops. * prevents feed-back loops.
*/ */
if (connectionMap.get(handler).canFlow()) if (connectionMap.get(handler).canFlow())
{ {
stack.amount -= handler.fill(dir, FluidUtility.getStack(stack, Math.min(volPerSide, this.maxFlowRate)), true); stack.amount -= handler.fill(dir, FluidUtility.getStack(stack, Math.min(volPerSide, this.maxFlowRate)), true);
} }
if (sideCount > 1) if (sideCount > 1)
--sideCount; --sideCount;
if (volPer <= 0) if (volPer <= 0)
break; break;
} }
if (count > 1) if (count > 1)
count--; count--;
if (stack == null || stack.amount <= 0) if (stack == null || stack.amount <= 0)
{ {
stack = null; stack = null;
break; break;
} }
} }
this.getTank().setFluid(stack); this.getTank().setFluid(stack);
// TODO check for change before rebuilding // TODO check for change before rebuilding
this.reconstructTankInfo(); this.reconstructTankInfo();
} }
@Override @Override
public boolean canUpdate() public boolean canUpdate()
{ {
return getTank().getFluidAmount() > 0 && sideMap.size() > 0 && getConnectors().size() > 0; return getTank().getFluidAmount() > 0 && sideMap.size() > 0 && getConnectors().size() > 0;
} }
@Override @Override
public boolean continueUpdate() public boolean continueUpdate()
{ {
return canUpdate(); return canUpdate();
} }
@Override @Override
public void reconstruct() public void reconstruct()
{ {
this.sideMap.clear(); this.sideMap.clear();
this.maxFlowRate = Integer.MAX_VALUE; this.maxFlowRate = Integer.MAX_VALUE;
this.maxPressure = Integer.MAX_VALUE; this.maxPressure = Integer.MAX_VALUE;
super.reconstruct(); super.reconstruct();
} }
@Override @Override
public void reconstructConnector(IFluidConnector connector) public void reconstructConnector(IFluidConnector connector)
{ {
super.reconstructConnector(connector); super.reconstructConnector(connector);
if (connector instanceof IFluidPipe) if (connector instanceof IFluidPipe)
{ {
if (((IFluidPipe) connector).getMaxFlowRate() < this.maxFlowRate) if (((IFluidPipe) connector).getMaxFlowRate() < this.maxFlowRate)
this.maxFlowRate = ((IFluidPipe) connector).getMaxFlowRate(); this.maxFlowRate = ((IFluidPipe) connector).getMaxFlowRate();
if (((IFluidPipe) connector).getMaxPressure() < this.maxPressure) if (((IFluidPipe) connector).getMaxPressure() < this.maxPressure)
this.maxPressure = ((IFluidPipe) connector).getMaxPressure(); this.maxPressure = ((IFluidPipe) connector).getMaxPressure();
} }
for (int i = 0; i < 6; i++) for (int i = 0; i < 6; i++)
{ {
if (connector.getConnections()[i] instanceof IFluidHandler && !(connector.getConnections()[i] instanceof IFluidPipe)) if (connector.getConnections()[i] instanceof IFluidHandler && !(connector.getConnections()[i] instanceof IFluidPipe))
{ {
EnumSet<ForgeDirection> set = this.sideMap.get(connector.getConnections()[i]); EnumSet<ForgeDirection> set = this.sideMap.get(connector.getConnections()[i]);
if (set == null) if (set == null)
{ {
set = EnumSet.noneOf(ForgeDirection.class); set = EnumSet.noneOf(ForgeDirection.class);
} }
set.add(ForgeDirection.getOrientation(i).getOpposite()); set.add(ForgeDirection.getOrientation(i).getOpposite());
sideMap.put((IFluidHandler) connector.getConnections()[i], set); sideMap.put((IFluidHandler) connector.getConnections()[i], set);
connectionMap.put((IFluidHandler) connector.getConnections()[i], connector); connectionMap.put((IFluidHandler) connector.getConnections()[i], connector);
} }
} }
} }
@Override @Override
public FluidStack drain(IFluidConnector source, ForgeDirection from, FluidStack resource, boolean doDrain) public FluidStack drain(IFluidConnector source, ForgeDirection from, FluidStack resource, boolean doDrain)
{ {
return null; return null;
} }
@Override @Override
public FluidStack drain(IFluidConnector source, ForgeDirection from, int resource, boolean doDrain) public FluidStack drain(IFluidConnector source, ForgeDirection from, int resource, boolean doDrain)
{ {
return null; return null;
} }
@Override @Override
public Class getConnectorClass() public Class getConnectorClass()
{ {
return IFluidPipe.class; return IFluidPipe.class;
} }
@Override @Override
public IFluidNetwork newInstance() public IFluidNetwork newInstance()
{ {
return new PipeNetwork(); return new PipeNetwork();
} }
@Override @Override
public int getPressure() public int getPressure()
{ {
return this.currentPressure; return this.currentPressure;
} }
} }

View file

@ -27,210 +27,210 @@ import cpw.mods.fml.relauncher.SideOnly;
public class PartPipe extends PartFramedConnection<EnumPipeMaterial, IFluidPipe, IFluidNetwork> implements IFluidPipe, TSlottedPart, JNormalOcclusion, IHollowConnect, JIconHitEffects public class PartPipe extends PartFramedConnection<EnumPipeMaterial, IFluidPipe, IFluidNetwork> implements IFluidPipe, TSlottedPart, JNormalOcclusion, IHollowConnect, JIconHitEffects
{ {
protected FluidTank tank = new FluidTank(1 * FluidContainerRegistry.BUCKET_VOLUME); protected FluidTank tank = new FluidTank(1 * FluidContainerRegistry.BUCKET_VOLUME);
private boolean isExtracting = false; private boolean isExtracting = false;
public PartPipe() public PartPipe()
{ {
super(); super();
material = EnumPipeMaterial.COPPER; material = EnumPipeMaterial.COPPER;
} }
public PartPipe(int typeID) public PartPipe(int typeID)
{ {
material = EnumPipeMaterial.values()[typeID]; material = EnumPipeMaterial.values()[typeID];
} }
@Override @Override
public String getType() public String getType()
{ {
return "resonant_induction_pipe"; return "resonant_induction_pipe";
} }
@Override @Override
public void update() public void update()
{ {
if (!world().isRemote) if (!world().isRemote)
{ {
if (isExtracting && getNetwork().getTank().getFluidAmount() < getNetwork().getTank().getCapacity()) if (isExtracting && getNetwork().getTank().getFluidAmount() < getNetwork().getTank().getCapacity())
{ {
for (int i = 0; i < this.getConnections().length; i++) for (int i = 0; i < this.getConnections().length; i++)
{ {
Object obj = this.getConnections()[i]; Object obj = this.getConnections()[i];
if (obj instanceof IFluidHandler) if (obj instanceof IFluidHandler)
{ {
FluidStack drain = ((IFluidHandler) obj).drain(ForgeDirection.getOrientation(i).getOpposite(), getMaxFlowRate(), true); FluidStack drain = ((IFluidHandler) obj).drain(ForgeDirection.getOrientation(i).getOpposite(), getMaxFlowRate(), true);
fill(null, drain, true); fill(null, drain, true);
} }
} }
} }
} }
} }
@Override @Override
public boolean activate(EntityPlayer player, MovingObjectPosition part, ItemStack item) public boolean activate(EntityPlayer player, MovingObjectPosition part, ItemStack item)
{ {
if (BlockAdvanced.isUsableWrench(player, player.getCurrentEquippedItem(), x(), y(), z())) if (BlockAdvanced.isUsableWrench(player, player.getCurrentEquippedItem(), x(), y(), z()))
{ {
if (!world().isRemote) if (!world().isRemote)
{ {
isExtracting = !isExtracting; isExtracting = !isExtracting;
player.addChatMessage("Pipe extraction mode: " + isExtracting); player.addChatMessage("Pipe extraction mode: " + isExtracting);
BlockAdvanced.damageWrench(player, player.getCurrentEquippedItem(), x(), y(), z()); BlockAdvanced.damageWrench(player, player.getCurrentEquippedItem(), x(), y(), z());
} }
return true; return true;
} }
return super.activate(player, part, item); return super.activate(player, part, item);
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void renderDynamic(codechicken.lib.vec.Vector3 pos, float frame, int pass) public void renderDynamic(codechicken.lib.vec.Vector3 pos, float frame, int pass)
{ {
RenderPipe.INSTANCE.render(this, pos.x, pos.y, pos.z, frame); RenderPipe.INSTANCE.render(this, pos.x, pos.y, pos.z, frame);
} }
@Override @Override
public void setMaterial(int i) public void setMaterial(int i)
{ {
setMaterial(EnumPipeMaterial.values()[i]); setMaterial(EnumPipeMaterial.values()[i]);
} }
@Override @Override
protected ItemStack getItem() protected ItemStack getItem()
{ {
return new ItemStack(Mechanical.itemPipe); return new ItemStack(Mechanical.itemPipe);
} }
/** Fluid network methods. */ /** Fluid network methods. */
@Override @Override
public IFluidNetwork getNetwork() public IFluidNetwork getNetwork()
{ {
if (this.network == null) if (this.network == null)
{ {
this.network = new PipeNetwork(); this.network = new PipeNetwork();
this.network.addConnector(this); this.network.addConnector(this);
} }
return this.network; return this.network;
} }
@Override @Override
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) public int fill(ForgeDirection from, FluidStack resource, boolean doFill)
{ {
return getNetwork().fill(this, from, resource, doFill); return getNetwork().fill(this, from, resource, doFill);
} }
@Override @Override
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain)
{ {
return null; return null;
} }
@Override @Override
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain)
{ {
return null; return null;
} }
@Override @Override
public boolean canFill(ForgeDirection from, Fluid fluid) public boolean canFill(ForgeDirection from, Fluid fluid)
{ {
return true; return true;
} }
@Override @Override
public boolean canDrain(ForgeDirection from, Fluid fluid) public boolean canDrain(ForgeDirection from, Fluid fluid)
{ {
return true; return true;
} }
@Override @Override
public FluidTankInfo[] getTankInfo(ForgeDirection from) public FluidTankInfo[] getTankInfo(ForgeDirection from)
{ {
return this.getNetwork().getTankInfo(); return this.getNetwork().getTankInfo();
} }
@Override @Override
public void onFluidChanged() public void onFluidChanged()
{ {
} }
@Override @Override
public FluidTank getInternalTank() public FluidTank getInternalTank()
{ {
if (this.tank == null) if (this.tank == null)
{ {
this.tank = new FluidTank(FluidContainerRegistry.BUCKET_VOLUME); this.tank = new FluidTank(FluidContainerRegistry.BUCKET_VOLUME);
} }
return this.tank; return this.tank;
} }
@Override @Override
protected boolean canConnectTo(TileEntity tile) protected boolean canConnectTo(TileEntity tile)
{ {
return tile instanceof IFluidHandler; return tile instanceof IFluidHandler;
} }
@Override @Override
protected IFluidPipe getConnector(TileEntity tile) protected IFluidPipe getConnector(TileEntity tile)
{ {
return tile instanceof IFluidPipe ? (IFluidPipe) tile : null; return tile instanceof IFluidPipe ? (IFluidPipe) tile : null;
} }
@Override @Override
public int getPressureIn(ForgeDirection side) public int getPressureIn(ForgeDirection side)
{ {
return 0; return 0;
} }
@Override @Override
public int getPressure() public int getPressure()
{ {
if (this.getNetwork() != null) if(this.getNetwork() != null)
{ {
return this.getNetwork().getPressure(); return this.getNetwork().getPressure();
} }
return 0; return 0;
} }
@Override @Override
public void onWrongPressure(ForgeDirection side, int pressure) public void onWrongPressure(ForgeDirection side, int pressure)
{ {
} }
@Override @Override
public int getMaxPressure() public int getMaxPressure()
{ {
return 1000; return 1000;
} }
@Override @Override
public int getMaxFlowRate() public int getMaxFlowRate()
{ {
return FluidContainerRegistry.BUCKET_VOLUME; return FluidContainerRegistry.BUCKET_VOLUME;
} }
@Override @Override
public void save(NBTTagCompound nbt) public void save(NBTTagCompound nbt)
{ {
super.save(nbt); super.save(nbt);
nbt.setBoolean("isExtracting", isExtracting); nbt.setBoolean("isExtracting", isExtracting);
} }
@Override @Override
public void load(NBTTagCompound nbt) public void load(NBTTagCompound nbt)
{ {
super.load(nbt); super.load(nbt);
isExtracting = nbt.getBoolean("isExtracting"); isExtracting = nbt.getBoolean("isExtracting");
} }
@Override @Override
public boolean canFlow() public boolean canFlow()
{ {
return !isExtracting; return !isExtracting;
} }
} }

View file

@ -9,79 +9,76 @@ import resonantinduction.api.fluid.IFluidConnector;
import resonantinduction.api.fluid.IFluidNetwork; import resonantinduction.api.fluid.IFluidNetwork;
import resonantinduction.mechanical.fluid.network.FluidNetwork; import resonantinduction.mechanical.fluid.network.FluidNetwork;
/** /** Network that handles connected tanks
* Network that handles connected tanks
* *
* @author DarkGuardsman * @author DarkGuardsman */
*/
public class TankNetwork extends FluidNetwork public class TankNetwork extends FluidNetwork
{ {
@Override @Override
public void distributeConnectors() public void distributeConnectors()
{ {
FluidStack fillStack = this.getTank().getFluid(); FluidStack fillStack = this.getTank().getFluid();
int lowestY = 255, highestY = 0; int lowestY = 255, highestY = 0;
if (fillStack == null || fillStack.getFluid().isGaseous()) if (fillStack == null || fillStack.getFluid().isGaseous())
{ {
super.distributeConnectors(); super.distributeConnectors();
} }
else if (this.getConnectors().size() > 0) else if (this.getConnectors().size() > 0)
{ {
fillStack = fillStack.copy(); fillStack = fillStack.copy();
for (IFluidConnector connector : this.getConnectors()) for (IFluidConnector connector : this.getConnectors())
{ {
connector.getInternalTank().setFluid(null); connector.getInternalTank().setFluid(null);
connector.onFluidChanged(); connector.onFluidChanged();
if (connector instanceof TileEntity && ((TileEntity) connector).yCoord < lowestY) if (connector instanceof TileEntity && ((TileEntity) connector).yCoord < lowestY)
{ {
lowestY = ((TileEntity) connector).yCoord; lowestY = ((TileEntity) connector).yCoord;
} }
if (connector instanceof TileEntity && ((TileEntity) connector).yCoord > highestY) if (connector instanceof TileEntity && ((TileEntity) connector).yCoord > highestY)
{ {
highestY = ((TileEntity) connector).yCoord; highestY = ((TileEntity) connector).yCoord;
} }
} }
// TODO Add path finder to prevent filling when tanks are only connected at the top // TODO Add path finder to prevent filling when tanks are only connected at the top
for (int y = lowestY; y <= highestY; y++) for (int y = lowestY; y <= highestY; y++)
{ {
Set<IFluidConnector> parts = new LinkedHashSet<IFluidConnector>(); Set<IFluidConnector> parts = new LinkedHashSet<IFluidConnector>();
for (IFluidConnector part : this.getConnectors()) for (IFluidConnector part : this.getConnectors())
{ {
if (part instanceof IFluidConnector && ((TileEntity) part).yCoord == y) if (part instanceof IFluidConnector && ((TileEntity) part).yCoord == y)
{ {
parts.add(part); parts.add(part);
} }
} }
if (!parts.isEmpty()) if (!parts.isEmpty())
{ {
this.fillTankSet(fillStack, parts); this.fillTankSet(fillStack, parts);
} }
if (fillStack == null || fillStack.amount <= 0) if (fillStack == null || fillStack.amount <= 0)
{ {
break; break;
} }
} }
} }
} }
@Override @Override
public IFluidNetwork newInstance() public IFluidNetwork newInstance()
{ {
return new TankNetwork(); return new TankNetwork();
} }
@Override @Override
public int getPressure() public int getPressure()
{ {
// TODO implement a compression system that would cause a tank to build up pressure greater //TODO implement a compression system that would cause a tank to build up pressure greater than normal ATM
// than normal ATM return 0;
return 0; }
}
} }

View file

@ -14,7 +14,6 @@ public class GearMultiBlockHandler extends MultiBlockHandler<PartGear>
super(wrapper); super(wrapper);
} }
@Override
public PartGear getWrapperAt(Vector3 position) public PartGear getWrapperAt(Vector3 position)
{ {
TileEntity tile = position.getTileEntity(self.getWorld()); TileEntity tile = position.getTileEntity(self.getWorld());

View file

@ -10,6 +10,7 @@ import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ForgeDirection;
import resonantinduction.core.Settings; import resonantinduction.core.Settings;
import resonantinduction.core.prefab.part.ItemMultipartBase; import resonantinduction.core.prefab.part.ItemMultipartBase;
import resonantinduction.electrical.wire.EnumWireMaterial;
import codechicken.lib.vec.BlockCoord; import codechicken.lib.vec.BlockCoord;
import codechicken.lib.vec.Vector3; import codechicken.lib.vec.Vector3;
import codechicken.multipart.ControlKeyModifer; import codechicken.multipart.ControlKeyModifer;

View file

@ -104,7 +104,6 @@ public class PartGear extends PartMechanical implements IMechanical, IMultiBlock
getMultiBlock().update(); getMultiBlock().update();
} }
@Override
public void checkClientUpdate() public void checkClientUpdate()
{ {
if (getMultiBlock().isPrimary()) if (getMultiBlock().isPrimary())
@ -150,7 +149,6 @@ public class PartGear extends PartMechanical implements IMechanical, IMultiBlock
/** /**
* Refresh should be called sparingly. * Refresh should be called sparingly.
*/ */
@Override
public void refresh() public void refresh()
{ {
connections = new Object[6]; connections = new Object[6];
@ -217,7 +215,7 @@ public class PartGear extends PartMechanical implements IMechanical, IMultiBlock
if (connections[checkDir.ordinal()] == null && checkTile instanceof IMechanical) if (connections[checkDir.ordinal()] == null && checkTile instanceof IMechanical)
{ {
IMechanical instance = ((IMechanical) checkTile).getInstance(placementSide); IMechanical instance = (IMechanical) ((IMechanical) checkTile).getInstance(placementSide);
if (instance != null && instance != this && instance.canConnect(checkDir.getOpposite(), this) && !(instance instanceof PartGearShaft)) if (instance != null && instance != this && instance.canConnect(checkDir.getOpposite(), this) && !(instance instanceof PartGearShaft))
{ {

View file

@ -1,5 +1,6 @@
package resonantinduction.mechanical.gear; package resonantinduction.mechanical.gear;
import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
@ -12,6 +13,7 @@ import resonantinduction.mechanical.network.IMechanical;
import resonantinduction.mechanical.network.PartMechanical; import resonantinduction.mechanical.network.PartMechanical;
import codechicken.lib.raytracer.IndexedCuboid6; import codechicken.lib.raytracer.IndexedCuboid6;
import codechicken.lib.vec.Cuboid6; import codechicken.lib.vec.Cuboid6;
import codechicken.lib.vec.Rotation;
import codechicken.lib.vec.Vector3; import codechicken.lib.vec.Vector3;
import codechicken.multipart.PartMap; import codechicken.multipart.PartMap;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
@ -38,7 +40,6 @@ public class PartGearShaft extends PartMechanical
sides[6] = new IndexedCuboid6(6, new Cuboid6(0.36, 0.36, 0.36, 0.64, 0.64, 0.64)); sides[6] = new IndexedCuboid6(6, new Cuboid6(0.36, 0.36, 0.36, 0.64, 0.64, 0.64));
} }
@Override
public void preparePlacement(int side, int itemDamage) public void preparePlacement(int side, int itemDamage)
{ {
ForgeDirection dir = ForgeDirection.getOrientation((byte) (side ^ 1)); ForgeDirection dir = ForgeDirection.getOrientation((byte) (side ^ 1));
@ -62,7 +63,6 @@ public class PartGearShaft extends PartMechanical
/** /**
* Refresh should be called sparingly. * Refresh should be called sparingly.
*/ */
@Override
public void refresh() public void refresh()
{ {
connections = new Object[6]; connections = new Object[6];
@ -95,7 +95,7 @@ public class PartGearShaft extends PartMechanical
if (checkTile instanceof IMechanical) if (checkTile instanceof IMechanical)
{ {
IMechanical instance = ((IMechanical) checkTile).getInstance(checkDir.getOpposite()); IMechanical instance = (IMechanical) ((IMechanical) checkTile).getInstance(checkDir.getOpposite());
// Only connect to shafts outside of this block space. // Only connect to shafts outside of this block space.
if (instance != null && instance != this && instance instanceof PartGearShaft && instance.canConnect(checkDir.getOpposite(), this)) if (instance != null && instance != this && instance instanceof PartGearShaft && instance.canConnect(checkDir.getOpposite(), this))

View file

@ -2,6 +2,7 @@ package resonantinduction.mechanical.gear;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.AdvancedModelLoader; import net.minecraftforge.client.model.AdvancedModelLoader;
import net.minecraftforge.client.model.IModelCustom; import net.minecraftforge.client.model.IModelCustom;
@ -9,6 +10,7 @@ import org.lwjgl.opengl.GL11;
import resonantinduction.core.Reference; import resonantinduction.core.Reference;
import calclavia.lib.render.RenderUtility; import calclavia.lib.render.RenderUtility;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;

View file

@ -11,6 +11,7 @@ import org.lwjgl.opengl.GL11;
import resonantinduction.core.Reference; import resonantinduction.core.Reference;
import calclavia.lib.render.RenderUtility; import calclavia.lib.render.RenderUtility;
import calclavia.lib.utility.WorldUtility;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;

View file

@ -3,81 +3,81 @@ package resonantinduction.mechanical.motor;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World; import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import resonantinduction.core.Reference; import resonantinduction.core.Reference;
import resonantinduction.core.prefab.block.BlockRIRotatable; import resonantinduction.core.prefab.block.BlockRIRotatable;
import resonantinduction.core.render.RIBlockRenderingHandler; import resonantinduction.core.render.RIBlockRenderingHandler;
import resonantinduction.electrical.generator.TileGenerator; import resonantinduction.electrical.generator.TileGenerator;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockFluidMotor extends BlockRIRotatable public class BlockFluidMotor extends BlockRIRotatable
{ {
public BlockFluidMotor() public BlockFluidMotor()
{ {
super("FluidMotor"); super("FluidMotor");
setTextureName(Reference.PREFIX + "material_steel"); setTextureName(Reference.PREFIX + "material_steel");
rotationMask = Byte.parseByte("111111", 2); rotationMask = Byte.parseByte("111111", 2);
} }
@Override @Override
public boolean onSneakMachineActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float hitX, float hitY, float hitZ) public boolean onSneakMachineActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float hitX, float hitY, float hitZ)
{ {
TileEntity tileEntity = world.getBlockTileEntity(x, y, z); TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
if (tileEntity instanceof TileGenerator) if (tileEntity instanceof TileGenerator)
{ {
if (!world.isRemote) if (!world.isRemote)
{ {
((TileGenerator) tileEntity).isInversed = !((TileGenerator) tileEntity).isInversed; ((TileGenerator) tileEntity).isInversed = !((TileGenerator) tileEntity).isInversed;
entityPlayer.addChatMessage("Generator now producing " + (((TileGenerator) tileEntity).isInversed ? "mechanical" : "electrical") + " energy."); entityPlayer.addChatMessage("Generator now producing " + (((TileGenerator) tileEntity).isInversed ? "mechanical" : "electrical") + " energy.");
} }
return true; return true;
} }
return false; return false;
} }
@Override @Override
public boolean onSneakUseWrench(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float hitX, float hitY, float hitZ) public boolean onSneakUseWrench(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float hitX, float hitY, float hitZ)
{ {
TileEntity tileEntity = world.getBlockTileEntity(x, y, z); TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
if (tileEntity instanceof TileGenerator) if (tileEntity instanceof TileGenerator)
{ {
if (!world.isRemote) if (!world.isRemote)
{ {
entityPlayer.addChatMessage("Generator torque ratio: " + ((TileGenerator) tileEntity).toggleRatio()); entityPlayer.addChatMessage("Generator torque ratio: " + ((TileGenerator) tileEntity).toggleRatio());
} }
return true; return true;
} }
return false; return false;
} }
@Override @Override
public TileEntity createNewTileEntity(World world) public TileEntity createNewTileEntity(World world)
{ {
return new TileGenerator(); return new TileGenerator();
} }
@Override @Override
public boolean isOpaqueCube() public boolean isOpaqueCube()
{ {
return false; return false;
} }
@Override @Override
public boolean renderAsNormalBlock() public boolean renderAsNormalBlock()
{ {
return false; return false;
} }
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
@Override @Override
public int getRenderType() public int getRenderType()
{ {
return RIBlockRenderingHandler.ID; return RIBlockRenderingHandler.ID;
} }
} }

View file

@ -13,91 +13,91 @@ import calclavia.lib.prefab.tile.TileAdvanced;
public class TileFluidMotor extends TileAdvanced implements IFluidHandler, IRotatable public class TileFluidMotor extends TileAdvanced implements IFluidHandler, IRotatable
{ {
ForgeDirection facing = ForgeDirection.UNKNOWN; ForgeDirection facing = ForgeDirection.UNKNOWN;
boolean input = true; boolean input = true;
final int maxFlow = 1000; final int maxFlow = 1000;
int volFilled = 0; int volFilled = 0;
int averageVol = 0; int averageVol = 0;
@Override @Override
public void updateEntity() public void updateEntity()
{ {
super.updateEntity(); super.updateEntity();
} }
@Override @Override
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) public int fill(ForgeDirection from, FluidStack resource, boolean doFill)
{ {
if (from == getDirection().getOpposite()) if (from == getDirection().getOpposite())
{ {
TileEntity tileOut = new Vector3(this).translate(from.getOpposite()).getTileEntity(this.worldObj); TileEntity tileOut = new Vector3(this).translate(from.getOpposite()).getTileEntity(this.worldObj);
TileEntity tileIn = new Vector3(this).translate(from).getTileEntity(this.worldObj); TileEntity tileIn = new Vector3(this).translate(from).getTileEntity(this.worldObj);
if (tileIn instanceof IFluidPipe && tileOut instanceof IFluidPipe) if (tileIn instanceof IFluidPipe && tileOut instanceof IFluidPipe)
{ {
if (((IFluidPipe) tileIn).getPressure() <= ((IFluidPipe) tileOut).getPressure()) if (((IFluidPipe) tileIn).getPressure() <= ((IFluidPipe) tileOut).getPressure())
{ {
return 0; return 0;
} }
} }
if (tileOut instanceof IFluidHandler && !(tileOut instanceof TileFluidMotor)) if (tileOut instanceof IFluidHandler && !(tileOut instanceof TileFluidMotor))
{ {
// TODO pass fluid on to the other side of the motor and get average flow rate //TODO pass fluid on to the other side of the motor and get average flow rate
} }
} }
return 0; return 0;
} }
@Override @Override
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain)
{ {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return null; return null;
} }
@Override @Override
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain)
{ {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return null; return null;
} }
@Override @Override
public boolean canFill(ForgeDirection from, Fluid fluid) public boolean canFill(ForgeDirection from, Fluid fluid)
{ {
return !input && from == this.getDirection().getOpposite(); return !input && from == this.getDirection().getOpposite();
} }
@Override @Override
public boolean canDrain(ForgeDirection from, Fluid fluid) public boolean canDrain(ForgeDirection from, Fluid fluid)
{ {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return false; return false;
} }
@Override @Override
public FluidTankInfo[] getTankInfo(ForgeDirection from) public FluidTankInfo[] getTankInfo(ForgeDirection from)
{ {
if (from == getDirection().getOpposite()) if (from == getDirection().getOpposite())
{ {
TileEntity tile = new Vector3(this).translate(from.getOpposite()).getTileEntity(this.worldObj); TileEntity tile = new Vector3(this).translate(from.getOpposite()).getTileEntity(this.worldObj);
if (tile instanceof IFluidHandler && !(tile instanceof TileFluidMotor)) if (tile instanceof IFluidHandler && !(tile instanceof TileFluidMotor))
{ {
return ((IFluidHandler) tile).getTankInfo(from); return ((IFluidHandler) tile).getTankInfo(from);
} }
} }
return new FluidTankInfo[1]; return new FluidTankInfo[1];
} }
@Override @Override
public ForgeDirection getDirection() public ForgeDirection getDirection()
{ {
return ForgeDirection.getOrientation(this.worldObj.getBlockMetadata(xCoord, yCoord, zCoord)); return ForgeDirection.getOrientation(this.worldObj.getBlockMetadata(xCoord, yCoord, zCoord));
} }
@Override @Override
public void setDirection(ForgeDirection direction) public void setDirection(ForgeDirection direction)
{ {
this.worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, direction.ordinal(), 3); this.worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, direction.ordinal(), 3);
} }
} }

View file

@ -23,7 +23,6 @@ public interface IMechanical extends IConnector<IMechanicalNetwork>
public boolean inverseRotation(ForgeDirection dir, IMechanical with); public boolean inverseRotation(ForgeDirection dir, IMechanical with);
@Override
public IMechanical getInstance(ForgeDirection dir); public IMechanical getInstance(ForgeDirection dir);
/** /**

View file

@ -7,6 +7,7 @@ import java.util.LinkedHashMap;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ForgeDirection;
import resonantinduction.mechanical.gear.PartGearShaft;
import universalelectricity.api.net.IUpdate; import universalelectricity.api.net.IUpdate;
import universalelectricity.core.net.Network; import universalelectricity.core.net.Network;
import universalelectricity.core.net.NetworkTickHandler; import universalelectricity.core.net.NetworkTickHandler;
@ -135,7 +136,7 @@ public class MechanicalNetwork extends Network<IMechanicalNetwork, IMechanical>
if (deltaTime > 1) if (deltaTime > 1)
{ {
rotation = (float) (((velocity) * (deltaTime / 1000d) + rotation) % (2 * Math.PI)); rotation = (float) (((velocity) * ((double) deltaTime / 1000d) + rotation) % (2 * Math.PI));
lastRotateTime = System.currentTimeMillis(); lastRotateTime = System.currentTimeMillis();
} }

View file

@ -53,13 +53,13 @@ public class PacketNetwork<C extends IConnector> extends PacketType
int y = data.readInt(); int y = data.readInt();
int z = data.readInt(); int z = data.readInt();
TileEntity tileEntity = player.worldObj.getBlockTileEntity(x, y, z); TileEntity tileEntity = player.worldObj.getBlockTileEntity(x, y, z);
System.out.println(tileEntity + " rec: " + new Vector3(x, y, z)); System.out.println(tileEntity+" rec: "+new Vector3(x,y,z));
// TODO: Somehow this would receive the wrong coordinate once in a while... //TODO: Somehow this would receive the wrong coordinate once in a while...
if (tileEntity != null && connectorClass.isAssignableFrom(tileEntity.getClass())) if (tileEntity != null && connectorClass.isAssignableFrom(tileEntity.getClass()))
{ {
C instance = (C) ((C) tileEntity).getInstance(ForgeDirection.getOrientation(data.readInt())); C instance = (C) ((C) tileEntity).getInstance(ForgeDirection.getOrientation(data.readInt()));
Object network = instance.getNetwork(); Object network = instance.getNetwork();
if (network instanceof IPacketReceiver) if (network instanceof IPacketReceiver)
{ {
((IPacketReceiver) network).onReceivePacket(data, player, instance); ((IPacketReceiver) network).onReceivePacket(data, player, instance);

View file

@ -1,6 +1,7 @@
package resonantinduction.mechanical.network; package resonantinduction.mechanical.network;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
@ -10,6 +11,11 @@ import net.minecraft.util.MovingObjectPosition;
import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ForgeDirection;
import codechicken.lib.data.MCDataInput; import codechicken.lib.data.MCDataInput;
import codechicken.lib.data.MCDataOutput; import codechicken.lib.data.MCDataOutput;
import codechicken.lib.vec.Cuboid6;
import codechicken.lib.vec.Rotation;
import codechicken.lib.vec.Transformation;
import codechicken.lib.vec.Vector3;
import codechicken.microblock.FaceMicroClass;
import codechicken.multipart.JCuboidPart; import codechicken.multipart.JCuboidPart;
import codechicken.multipart.JNormalOcclusion; import codechicken.multipart.JNormalOcclusion;
import codechicken.multipart.TFacePart; import codechicken.multipart.TFacePart;

View file

@ -1,5 +1,7 @@
package resonantinduction.mechanical.network; package resonantinduction.mechanical.network;
import com.google.common.io.ByteArrayDataInput;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
@ -11,8 +13,6 @@ import calclavia.lib.network.IPacketReceiver;
import calclavia.lib.network.PacketHandler; import calclavia.lib.network.PacketHandler;
import calclavia.lib.prefab.tile.TileAdvanced; import calclavia.lib.prefab.tile.TileAdvanced;
import com.google.common.io.ByteArrayDataInput;
public abstract class TileMechanical extends TileAdvanced implements IMechanical, IPacketReceiver public abstract class TileMechanical extends TileAdvanced implements IMechanical, IPacketReceiver
{ {
/** The mechanical connections this connector has made */ /** The mechanical connections this connector has made */

View file

@ -55,50 +55,50 @@ public class BlockFilter extends BlockRI implements ITileEntityProvider
* Leak the fluid down. * Leak the fluid down.
*/ */
/* /*
* BlockFluidMixture fluidBlock = (BlockFluidMixture) BlockFluidMixture fluidBlock = (BlockFluidMixture) ResonantInduction.blockFluidMixture;
* ResonantInduction.blockFluidMixture; int amount = fluidBlock.getQuantaValue(world, x, y, z);
* int amount = fluidBlock.getQuantaValue(world, x, y, z);
* /** /**
* All fluid is filtered out, spawn all the items. * All fluid is filtered out, spawn all the items.
* if (amount <= 1) *
* { if (amount <= 1)
* System.out.println("filter dropped"); {
* for (ItemStack itemStack : ((TileFluidMixture) tileAbove).items) System.out.println("filter dropped");
* { for (ItemStack itemStack : ((TileFluidMixture) tileAbove).items)
* for (Resource resoure : MachineRecipes.INSTANCE.getOutput(RecipeType.MIXER, {
* itemStack)) for (Resource resoure : MachineRecipes.INSTANCE.getOutput(RecipeType.MIXER, itemStack))
* { {
* InventoryUtility.dropItemStack(world, checkAbove.clone().add(0.5), InventoryUtility.dropItemStack(world, checkAbove.clone().add(0.5), resoure.getItemStack().copy());
* resoure.getItemStack().copy()); }
* } }
* } }
* }
* int remaining = amount - 1; int remaining = amount - 1;
* /**
/**
* Remove liquid from top. * Remove liquid from top.
* if (remaining > 0) *
* { if (remaining > 0)
* fluidBlock.setQuanta(world, checkAbove.intX(), checkAbove.intY(), {
* checkAbove.intZ(), remaining); fluidBlock.setQuanta(world, checkAbove.intX(), checkAbove.intY(), checkAbove.intZ(), remaining);
* world.scheduleBlockUpdate(x, y, z, blockID, 20); world.scheduleBlockUpdate(x, y, z, blockID, 20);
* } }
* else else
* { {
* checkAbove.setBlock(world, 0); checkAbove.setBlock(world, 0);
* } }
* /**
/**
* Add liquid to bottom. * Add liquid to bottom.
* if (checkBelow.getBlockID(world) == ResonantInduction.blockFluidMixture.blockID) *
* { if (checkBelow.getBlockID(world) == ResonantInduction.blockFluidMixture.blockID)
* fluidBlock.setQuanta(world, checkBelow.intX(), checkBelow.intY(), {
* checkBelow.intZ(), fluidBlock.getQuantaValue(world, checkBelow.intX(), fluidBlock.setQuanta(world, checkBelow.intX(), checkBelow.intY(), checkBelow.intZ(), fluidBlock.getQuantaValue(world, checkBelow.intX(), checkBelow.intY(), checkBelow.intZ()) + 1);
* checkBelow.intY(), checkBelow.intZ()) + 1); }
* } else
* else {
* { checkBelow.setBlock(world, Block.waterStill.blockID, 3);
* checkBelow.setBlock(world, Block.waterStill.blockID, 3); }*/
* }
*/
} }
} }
} }

View file

@ -1,12 +1,14 @@
package resonantinduction.mechanical.process; package resonantinduction.mechanical.process;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.ForgeDirection;
import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.ArrayUtils;
import com.google.common.io.ByteArrayDataInput;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.ForgeDirection;
import resonantinduction.api.recipe.MachineRecipes; import resonantinduction.api.recipe.MachineRecipes;
import resonantinduction.api.recipe.MachineRecipes.RecipeType; import resonantinduction.api.recipe.MachineRecipes.RecipeType;
import resonantinduction.api.recipe.RecipeUtils.Resource; import resonantinduction.api.recipe.RecipeUtils.Resource;

View file

@ -13,6 +13,7 @@ import net.minecraftforge.common.ForgeDirection;
import resonantinduction.api.recipe.MachineRecipes; import resonantinduction.api.recipe.MachineRecipes;
import resonantinduction.api.recipe.MachineRecipes.RecipeType; import resonantinduction.api.recipe.MachineRecipes.RecipeType;
import resonantinduction.core.Reference; import resonantinduction.core.Reference;
import resonantinduction.core.ResonantInduction;
import resonantinduction.core.resource.fluid.TileFluidMixture; import resonantinduction.core.resource.fluid.TileFluidMixture;
import resonantinduction.mechanical.fluid.tank.TileTank; import resonantinduction.mechanical.fluid.tank.TileTank;
import resonantinduction.mechanical.network.TileMechanical; import resonantinduction.mechanical.network.TileMechanical;

View file

@ -7,7 +7,9 @@ import resonantinduction.core.Reference;
import resonantinduction.core.Settings; import resonantinduction.core.Settings;
import resonantinduction.core.TabRI; import resonantinduction.core.TabRI;
import resonantinduction.core.render.RIBlockRenderingHandler; import resonantinduction.core.render.RIBlockRenderingHandler;
import resonantinduction.mechanical.network.IMechanical;
import calclavia.lib.prefab.turbine.BlockTurbine; import calclavia.lib.prefab.turbine.BlockTurbine;
import calclavia.lib.prefab.turbine.TileTurbine;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;

View file

@ -2,6 +2,7 @@ package resonantinduction.mechanical.turbine;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.AdvancedModelLoader; import net.minecraftforge.client.model.AdvancedModelLoader;
import net.minecraftforge.client.model.IModelCustom; import net.minecraftforge.client.model.IModelCustom;
@ -34,7 +35,7 @@ public class RenderWindTurbine extends TileEntitySpecialRenderer
{ {
RenderUtility.rotateBlockBasedOnDirectionUp(tile.getDirection()); RenderUtility.rotateBlockBasedOnDirectionUp(tile.getDirection());
} }
GL11.glRotatef((float) Math.toDegrees(tile.rotation), 0, 1, 0); GL11.glRotatef((float) Math.toDegrees(tile.rotation), 0, 1, 0);
/** /**

View file

@ -64,7 +64,7 @@ public class TileWindTurbine extends TileTurbine implements IMechanical
{ {
BiomeGenBase biome = worldObj.getBiomeGenForCoords(xCoord, zCoord); BiomeGenBase biome = worldObj.getBiomeGenForCoords(xCoord, zCoord);
boolean hasBonus = biome instanceof BiomeGenOcean || biome instanceof BiomeGenPlains || biome == BiomeGenBase.river; boolean hasBonus = biome instanceof BiomeGenOcean || biome instanceof BiomeGenPlains || biome == BiomeGenBase.river;
return (long) (worldObj.canBlockSeeTheSky(xCoord, yCoord + 4, zCoord) ? (((float) yCoord + 4) / 256) * 5 : 0) + (hasBonus ? 10 : 0); return (long) (worldObj.canBlockSeeTheSky(xCoord, yCoord + 4, zCoord) ? (((float) yCoord + 4) / (float) 256) * 5 : 0) + (hasBonus ? 10 : 0);
} }
@Override @Override