mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-12-22 19:39:24 +01:00
Fixed Energizer and Enervator not being able to in- and output
This commit is contained in:
parent
adb64232e7
commit
a6053be99e
3 changed files with 15 additions and 67 deletions
|
@ -1,47 +1,19 @@
|
|||
package ellpeck.actuallyadditions.items;
|
||||
|
||||
import cofh.api.energy.ItemEnergyContainer;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import ellpeck.actuallyadditions.util.INameableItem;
|
||||
import ellpeck.actuallyadditions.util.ItemUtil;
|
||||
import ellpeck.actuallyadditions.util.KeyUtil;
|
||||
import ellpeck.actuallyadditions.util.ModUtil;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.EnumRarity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ItemBattery extends ItemEnergyContainer implements INameableItem{
|
||||
public class ItemBattery extends ItemEnergy implements INameableItem{
|
||||
|
||||
public ItemBattery(){
|
||||
super(1000000, 10000);
|
||||
super(1000000, 10000, 1);
|
||||
this.setMaxStackSize(1);
|
||||
this.setHasSubtypes(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDurabilityForDisplay(ItemStack stack){
|
||||
double energyDif = getMaxEnergyStored(stack)-getEnergyStored(stack);
|
||||
double maxAmount = getMaxEnergyStored(stack);
|
||||
return energyDif/maxAmount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showDurabilityBar(ItemStack itemStack){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreated(ItemStack stack, World world, EntityPlayer player){
|
||||
this.setEnergy(stack, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -60,43 +32,8 @@ public class ItemBattery extends ItemEnergyContainer implements INameableItem{
|
|||
this.itemIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER + ":" + this.getName());
|
||||
}
|
||||
|
||||
public void setEnergy(ItemStack stack, int energy){
|
||||
NBTTagCompound compound = stack.getTagCompound();
|
||||
if(compound == null) compound = new NBTTagCompound();
|
||||
compound.setInteger("Energy", energy);
|
||||
stack.setTagCompound(compound);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems(Item item, CreativeTabs tabs, List list){
|
||||
ItemStack stackFull = new ItemStack(this);
|
||||
this.setEnergy(stackFull, this.getMaxEnergyStored(stackFull));
|
||||
list.add(stackFull);
|
||||
|
||||
ItemStack stackEmpty = new ItemStack(this);
|
||||
this.setEnergy(stackEmpty, 0);
|
||||
list.add(stackEmpty);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName(){
|
||||
return "itemBattery";
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld){
|
||||
ItemUtil.addInformation(this, list, 1, "");
|
||||
if(KeyUtil.isShiftPressed()){
|
||||
list.add(this.getEnergyStored(stack) + "/" + this.getMaxEnergyStored(stack) + " RF");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getShareTag(){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,13 +55,19 @@ public class TileEntityEnergizer extends TileEntityInventoryBase implements IEne
|
|||
super.readFromNBT(compound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int i, ItemStack stack){
|
||||
return i == 0 && stack.getItem() instanceof IEnergyContainerItem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int slot, ItemStack stack, int side){
|
||||
return slot == 0 && stack.getItem() instanceof IEnergyContainerItem;
|
||||
return this.isItemValidForSlot(slot, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slot, ItemStack stack, int side){
|
||||
System.out.println(stack.getItem() instanceof IEnergyContainerItem);
|
||||
return slot == 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -90,9 +90,14 @@ public class TileEntityEnervator extends TileEntityInventoryBase implements IEne
|
|||
return this.storage.getEnergyStored() * i / this.storage.getMaxEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int i, ItemStack stack){
|
||||
return i == 0 && stack.getItem() instanceof IEnergyContainerItem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int slot, ItemStack stack, int side){
|
||||
return slot == 0 && stack.getItem() instanceof IEnergyContainerItem;
|
||||
return this.isItemValidForSlot(slot, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue