Added infinite capacitors

This commit is contained in:
Calclavia 2013-08-25 17:31:27 +08:00
parent 258a479d38
commit d3bcfd9a0a
8 changed files with 128 additions and 21 deletions

View file

@ -18,4 +18,5 @@ tile.resonantinduction\:wire.superconductor.name=Superconductor Wire
## Items
item.resonantinduction\:quantumEntangler.name=Quantum Entangler
item.resonantinduction\:capacitor.name=Capacitor Cell
item.resonantinduction\:infiniteCapacitor.name=Infinite Capacitor Cell
item.resonantinduction\:linker.name=Electrostatic Linker

View file

@ -257,12 +257,12 @@ public class ResonantInduction
GameRegistry.addRecipe(new ShapedOreRecipe(blockEMContractor, " I ", "GCG", "WWW", 'W', UniversalRecipes.PRIMARY_METAL, 'C', emptyCapacitor, 'G', UniversalRecipes.SECONDARY_METAL, 'I', UniversalRecipes.PRIMARY_METAL));
/** Wires **/
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockWire, 1, EnumWireMaterial.COPPER.ordinal()), "MMM", 'M', "ingotCopper"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockWire, 1, EnumWireMaterial.TIN.ordinal()), "MMM", 'M', "ingotTin"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockWire, 1, EnumWireMaterial.IRON.ordinal()), "MMM", 'M', Item.ingotIron));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockWire, 1, EnumWireMaterial.ALUMINUM.ordinal()), "MMM", 'M', "ingotAluminum"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockWire, 1, EnumWireMaterial.SILVER.ordinal()), "MMM", 'M', "ingotSilver"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockWire, 1, EnumWireMaterial.SUPERCONDUCTOR.ordinal()), "MMM", 'M', "ingotSuperconductor"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockWire, 3, EnumWireMaterial.COPPER.ordinal()), "MMM", 'M', "ingotCopper"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockWire, 3, EnumWireMaterial.TIN.ordinal()), "MMM", 'M', "ingotTin"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockWire, 3, EnumWireMaterial.IRON.ordinal()), "MMM", 'M', Item.ingotIron));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockWire, 3, EnumWireMaterial.ALUMINUM.ordinal()), "MMM", 'M', "ingotAluminum"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockWire, 3, EnumWireMaterial.SILVER.ordinal()), "MMM", 'M', "ingotSilver"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockWire, 3, EnumWireMaterial.SUPERCONDUCTOR.ordinal()), "MMM", 'M', "ingotSuperconductor"));
/** Wire Compatiblity **/
if (Loader.isModLoaded("IC2"))

View file

@ -0,0 +1,12 @@
package resonantinduction.api;
import universalelectricity.core.item.IItemElectric;
/**
* @author Calclavia
*
*/
public interface ICapacitor extends IItemElectric
{
}

View file

@ -12,10 +12,10 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import resonantinduction.ResonantInduction;
import resonantinduction.api.ICapacitor;
import resonantinduction.base.BlockBase;
import resonantinduction.base.ListUtil;
import resonantinduction.render.BlockRenderingHandler;
import universalelectricity.core.item.IItemElectric;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@ -72,7 +72,7 @@ public class BlockBattery extends BlockBase implements ITileEntityProvider
{
if (entityPlayer.getCurrentEquippedItem() != null)
{
if (entityPlayer.getCurrentEquippedItem().getItem() instanceof IItemElectric)
if (entityPlayer.getCurrentEquippedItem().getItem() instanceof ICapacitor)
{
if (side != 0 && side != 1)
{

View file

@ -7,6 +7,7 @@ import net.minecraft.item.ItemStack;
import net.minecraftforge.common.Configuration;
import resonantinduction.ResonantInduction;
import resonantinduction.TabRI;
import resonantinduction.api.ICapacitor;
import universalelectricity.compatibility.ItemUniversalElectric;
/**
@ -15,7 +16,7 @@ import universalelectricity.compatibility.ItemUniversalElectric;
* @author Calclavia
*
*/
public class ItemCapacitor extends ItemUniversalElectric
public class ItemCapacitor extends ItemUniversalElectric implements ICapacitor
{
public ItemCapacitor(int id)
{

View file

@ -0,0 +1,84 @@
/**
*
*/
package resonantinduction.battery;
import java.util.List;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.Configuration;
import resonantinduction.ResonantInduction;
import resonantinduction.TabRI;
import universalelectricity.compatibility.ItemUniversalElectric;
import universalelectricity.core.electricity.ElectricityDisplay;
import universalelectricity.core.electricity.ElectricityDisplay.ElectricUnit;
import universalelectricity.core.item.ElectricItemHelper;
/**
* Stores power.
*
* @author Calclavia
*
*/
public class ItemInfiniteCapacitor extends ItemUniversalElectric
{
public ItemInfiniteCapacitor(int id)
{
super(ResonantInduction.CONFIGURATION.get(Configuration.CATEGORY_ITEM, "infiniteCapacitor", id).getInt(id));
this.setCreativeTab(TabRI.INSTANCE);
this.setUnlocalizedName(ResonantInduction.PREFIX + "infiniteCapacitor");
this.func_111206_d(ResonantInduction.PREFIX + "capacitor");
this.setMaxStackSize(1);
this.setMaxDamage(100);
}
@Override
public void addInformation(ItemStack itemStack, EntityPlayer entityPlayer, List list, boolean par4)
{
list.add("Infinite");
}
@Override
public float recharge(ItemStack itemStack, float energy, boolean doReceive)
{
return energy;
}
@Override
public float discharge(ItemStack itemStack, float energy, boolean doTransfer)
{
return energy;
}
@Override
public void setElectricity(ItemStack itemStack, float joules)
{
}
@Override
public float getTransfer(ItemStack itemStack)
{
return Float.POSITIVE_INFINITY;
}
@Override
public float getElectricityStored(ItemStack itemStack)
{
return Float.POSITIVE_INFINITY;
}
@Override
public float getMaxElectricityStored(ItemStack theItem)
{
return Float.POSITIVE_INFINITY;
}
@Override
public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List)
{
par3List.add(new ItemStack(this));
}
}

View file

@ -17,6 +17,7 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraftforge.common.ForgeDirection;
import resonantinduction.PacketHandler;
import resonantinduction.api.ICapacitor;
import resonantinduction.base.IPacketReceiver;
import resonantinduction.base.ListUtil;
import universalelectricity.compatibility.TileEntityUniversalElectrical;
@ -66,10 +67,13 @@ public class TileEntityBattery extends TileEntityUniversalElectrical implements
{
if (structure.inventory.size() < structure.getMaxCells())
{
structure.inventory.add(structure.visibleInventory[0]);
structure.visibleInventory[0] = null;
structure.sortInventory();
updateAllClients();
if (structure.visibleInventory[0].getItem() instanceof ICapacitor)
{
structure.inventory.add(structure.visibleInventory[0]);
structure.visibleInventory[0] = null;
structure.sortInventory();
updateAllClients();
}
}
}
@ -79,10 +83,9 @@ public class TileEntityBattery extends TileEntityUniversalElectrical implements
IItemElectric battery = (IItemElectric) itemStack.getItem();
float energyStored = getMaxEnergyStored();
float batteryNeeded = battery.getMaxElectricityStored(itemStack) - battery.getElectricityStored(itemStack);
float batteryNeeded = battery.recharge(itemStack, provideElectricity(this.transferThreshold, false).getWatts(), false);
float toGive = Math.min(energyStored, Math.min(battery.getTransfer(itemStack), batteryNeeded));
battery.setElectricity(itemStack, battery.getElectricityStored(itemStack) + provideElectricity(toGive, true).getWatts());
battery.recharge(itemStack, provideElectricity(toGive, true).getWatts(), true);
}
if (structure.visibleInventory[2] != null)
@ -92,9 +95,8 @@ public class TileEntityBattery extends TileEntityUniversalElectrical implements
float energyNeeded = getMaxEnergyStored() - getEnergyStored();
float batteryStored = battery.getElectricityStored(itemStack);
float toReceive = Math.min(energyNeeded, Math.min(battery.getTransfer(itemStack), batteryStored));
battery.setElectricity(itemStack, battery.getElectricityStored(itemStack) - receiveElectricity(toReceive, true));
float toReceive = Math.min(energyNeeded, Math.min(this.transferThreshold, Math.min(battery.getTransfer(itemStack), batteryStored)));
battery.discharge(itemStack, receiveElectricity(toReceive, true), true);
}
if (prevStructure != structure)

View file

@ -608,9 +608,16 @@ public class TileEntityTesla extends TileEntityUniversalElectrical implements IT
}
@Override
public EnumSet<ForgeDirection> getOutputDirections()
public EnumSet<ForgeDirection> getInputDirections()
{
return EnumSet.allOf(ForgeDirection.class);
EnumSet input = EnumSet.allOf(ForgeDirection.class);
input.remove(ForgeDirection.DOWN);
return input;
}
@Override
public EnumSet<ForgeDirection> getOutputDirections()
{
return EnumSet.of(ForgeDirection.DOWN);
}
}