Merge branch 'master' of https://github.com/calclavia/Resonant-Induction
This commit is contained in:
commit
daa52ba109
5 changed files with 303 additions and 235 deletions
|
@ -2,6 +2,6 @@ dir.development=./
|
|||
dir.mcp=${dir.development}forge/mcp
|
||||
version.minecraft=1.6.2
|
||||
version.mod.major=0
|
||||
version.mod.minor=0
|
||||
version.mod.revis=1
|
||||
version.mod.minor=1
|
||||
version.mod.revis=0
|
||||
version.universalelectricity=2.0.0
|
|
@ -91,7 +91,7 @@ public class ResonantInduction
|
|||
* Settings
|
||||
*/
|
||||
public static final Configuration CONFIGURATION = new Configuration(new File(Loader.instance().getConfigDir(), NAME + ".cfg"));
|
||||
public static float POWER_PER_COAL = 8;
|
||||
public static float POWER_PER_COAL = 5;
|
||||
public static boolean SOUND_FXS = true;
|
||||
|
||||
/** Block ID by Jyzarc */
|
||||
|
|
|
@ -9,6 +9,7 @@ import net.minecraft.creativetab.CreativeTabs;
|
|||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import resonantinduction.api.IBattery;
|
||||
import resonantinduction.base.ItemBase;
|
||||
|
||||
|
@ -31,7 +32,13 @@ public class ItemCapacitor extends ItemBase implements IBattery
|
|||
public void addInformation(ItemStack itemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
double energyStored = this.getEnergyStored(itemStack);
|
||||
par3List.add("Energy: " + (int)energyStored + " KJ");
|
||||
par3List.add("Energy: " + (int) energyStored + "/" + (int) this.getMaxEnergyStored(itemStack) + " KJ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreated(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
|
||||
{
|
||||
this.setEnergyStored(par1ItemStack, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -41,9 +48,9 @@ public class ItemCapacitor extends ItemBase implements IBattery
|
|||
{
|
||||
itemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
|
||||
itemStack.getTagCompound().setFloat("energyStored", amount);
|
||||
itemStack.setItemDamage((int)(100 - (amount / getMaxEnergyStored(itemStack)) * 100));
|
||||
itemStack.setItemDamage((int) (100 - (amount / getMaxEnergyStored(itemStack)) * 100));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -53,10 +60,10 @@ public class ItemCapacitor extends ItemBase implements IBattery
|
|||
{
|
||||
itemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
|
||||
float amount = itemStack.getTagCompound().getFloat("energyStored");
|
||||
itemStack.setItemDamage((int)(100 - (amount / getMaxEnergyStored(itemStack)) * 100));
|
||||
|
||||
itemStack.setItemDamage((int) (100 - (amount / getMaxEnergyStored(itemStack)) * 100));
|
||||
|
||||
return amount;
|
||||
}
|
||||
|
||||
|
@ -69,7 +76,7 @@ public class ItemCapacitor extends ItemBase implements IBattery
|
|||
@Override
|
||||
public float getMaxEnergyStored(ItemStack itemStack)
|
||||
{
|
||||
return 10;
|
||||
return 20;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -30,9 +30,9 @@ import com.google.common.io.ByteArrayDataInput;
|
|||
public class TileEntityBattery extends TileEntityBase implements IPacketReceiver, IInventory, ITesla
|
||||
{
|
||||
public SynchronizedBatteryData structure = SynchronizedBatteryData.getBase(this);
|
||||
|
||||
|
||||
public SynchronizedBatteryData prevStructure;
|
||||
|
||||
|
||||
public float clientEnergy;
|
||||
public int clientCells;
|
||||
public float clientMaxEnergy;
|
||||
|
@ -41,267 +41,268 @@ public class TileEntityBattery extends TileEntityBase implements IPacketReceiver
|
|||
public void updateEntity()
|
||||
{
|
||||
ticks++;
|
||||
|
||||
if(ticks == 1)
|
||||
|
||||
if (ticks == 1)
|
||||
{
|
||||
TeslaGrid.instance().register(this);
|
||||
}
|
||||
|
||||
if(!worldObj.isRemote)
|
||||
|
||||
if (!worldObj.isRemote)
|
||||
{
|
||||
if(playersUsing.size() > 0)
|
||||
if (playersUsing.size() > 0)
|
||||
{
|
||||
PacketHandler.sendTileEntityPacketToClients(this, getNetworkedData(new ArrayList()).toArray());
|
||||
}
|
||||
|
||||
if(ticks == 5 && !structure.isMultiblock)
|
||||
|
||||
if (ticks == 5 && !structure.isMultiblock)
|
||||
{
|
||||
update();
|
||||
}
|
||||
|
||||
if(structure.visibleInventory[0] != null)
|
||||
|
||||
if (structure.visibleInventory[0] != null)
|
||||
{
|
||||
if(structure.inventory.size() < structure.getMaxCells())
|
||||
if (structure.inventory.size() < structure.getMaxCells())
|
||||
{
|
||||
structure.inventory.add(structure.visibleInventory[0]);
|
||||
structure.visibleInventory[0] = null;
|
||||
structure.sortInventory();
|
||||
}
|
||||
}
|
||||
|
||||
if(structure.visibleInventory[1] != null)
|
||||
|
||||
if (structure.visibleInventory[1] != null)
|
||||
{
|
||||
ItemStack itemStack = structure.visibleInventory[1];
|
||||
IBattery battery = (IBattery)itemStack.getItem();
|
||||
|
||||
IBattery battery = (IBattery) itemStack.getItem();
|
||||
|
||||
float energyStored = getMaxEnergyStored();
|
||||
float batteryNeeded = battery.getMaxEnergyStored(itemStack)-battery.getEnergyStored(itemStack);
|
||||
float batteryNeeded = battery.getMaxEnergyStored(itemStack) - battery.getEnergyStored(itemStack);
|
||||
float toGive = Math.min(energyStored, Math.min(battery.getTransfer(itemStack), batteryNeeded));
|
||||
|
||||
|
||||
battery.setEnergyStored(itemStack, battery.getEnergyStored(itemStack) + removeEnergy(toGive, true));
|
||||
}
|
||||
|
||||
if(structure.visibleInventory[2] != null)
|
||||
|
||||
if (structure.visibleInventory[2] != null)
|
||||
{
|
||||
ItemStack itemStack = structure.visibleInventory[2];
|
||||
IBattery battery = (IBattery)itemStack.getItem();
|
||||
|
||||
float energyNeeded = getMaxEnergyStored()-getEnergyStored();
|
||||
IBattery battery = (IBattery) itemStack.getItem();
|
||||
|
||||
float energyNeeded = getMaxEnergyStored() - getEnergyStored();
|
||||
float batteryStored = battery.getEnergyStored(itemStack);
|
||||
float toReceive = Math.min(energyNeeded, Math.min(battery.getTransfer(itemStack), batteryStored));
|
||||
|
||||
|
||||
battery.setEnergyStored(itemStack, battery.getEnergyStored(itemStack) - addEnergy(toReceive, true));
|
||||
}
|
||||
|
||||
if(prevStructure != structure)
|
||||
|
||||
if (prevStructure != structure)
|
||||
{
|
||||
for(EntityPlayer player : playersUsing)
|
||||
for (EntityPlayer player : playersUsing)
|
||||
{
|
||||
player.closeScreen();
|
||||
}
|
||||
|
||||
|
||||
PacketHandler.sendTileEntityPacketToClients(this, getNetworkedData(new ArrayList()).toArray());
|
||||
}
|
||||
|
||||
|
||||
prevStructure = structure;
|
||||
|
||||
|
||||
structure.wroteInventory = false;
|
||||
structure.didTick = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void invalidate()
|
||||
{
|
||||
TeslaGrid.instance().unregister(this);
|
||||
super.invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbtTags)
|
||||
{
|
||||
super.readFromNBT(nbtTags);
|
||||
|
||||
//Main inventory
|
||||
if(nbtTags.hasKey("Items"))
|
||||
{
|
||||
NBTTagList tagList = nbtTags.getTagList("Items");
|
||||
structure.inventory = new ArrayList<ItemStack>();
|
||||
|
||||
for(int tagCount = 0; tagCount < tagList.tagCount(); tagCount++)
|
||||
{
|
||||
NBTTagCompound tagCompound = (NBTTagCompound)tagList.tagAt(tagCount);
|
||||
int slotID = tagCompound.getInteger("Slot");
|
||||
structure.inventory.add(slotID, ItemStack.loadItemStackFromNBT(tagCompound));
|
||||
}
|
||||
}
|
||||
|
||||
//Visible inventory
|
||||
if(nbtTags.hasKey("VisibleItems"))
|
||||
{
|
||||
NBTTagList tagList = nbtTags.getTagList("VisibleItems");
|
||||
structure.visibleInventory = new ItemStack[3];
|
||||
|
||||
for(int tagCount = 0; tagCount < tagList.tagCount(); tagCount++)
|
||||
{
|
||||
NBTTagCompound tagCompound = (NBTTagCompound)tagList.tagAt(tagCount);
|
||||
byte slotID = tagCompound.getByte("Slot");
|
||||
|
||||
if(slotID >= 0 && slotID < structure.visibleInventory.length)
|
||||
{
|
||||
if(slotID == 0)
|
||||
{
|
||||
setInventorySlotContents(slotID, ItemStack.loadItemStackFromNBT(tagCompound));
|
||||
}
|
||||
else {
|
||||
setInventorySlotContents(slotID+1, ItemStack.loadItemStackFromNBT(tagCompound));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbtTags)
|
||||
{
|
||||
super.writeToNBT(nbtTags);
|
||||
|
||||
if(!structure.wroteInventory)
|
||||
{
|
||||
//Inventory
|
||||
if(structure.inventory != null)
|
||||
{
|
||||
NBTTagList tagList = new NBTTagList();
|
||||
|
||||
for(int slotCount = 0; slotCount < structure.inventory.size(); slotCount++)
|
||||
{
|
||||
if(structure.inventory.get(slotCount) != null)
|
||||
{
|
||||
NBTTagCompound tagCompound = new NBTTagCompound();
|
||||
tagCompound.setInteger("Slot", slotCount);
|
||||
structure.inventory.get(slotCount).writeToNBT(tagCompound);
|
||||
tagList.appendTag(tagCompound);
|
||||
}
|
||||
}
|
||||
|
||||
nbtTags.setTag("Items", tagList);
|
||||
}
|
||||
|
||||
//Visible inventory
|
||||
if(structure.visibleInventory != null)
|
||||
{
|
||||
NBTTagList tagList = new NBTTagList();
|
||||
|
||||
for(int slotCount = 0; slotCount < structure.visibleInventory.length; slotCount++)
|
||||
{
|
||||
if(slotCount > 0)
|
||||
{
|
||||
slotCount++;
|
||||
}
|
||||
|
||||
if(getStackInSlot(slotCount) != null)
|
||||
{
|
||||
NBTTagCompound tagCompound = new NBTTagCompound();
|
||||
tagCompound.setByte("Slot", (byte)slotCount);
|
||||
getStackInSlot(slotCount).writeToNBT(tagCompound);
|
||||
tagList.appendTag(tagCompound);
|
||||
}
|
||||
}
|
||||
|
||||
nbtTags.setTag("VisibleItems", tagList);
|
||||
}
|
||||
|
||||
structure.wroteInventory = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound nbtTags)
|
||||
{
|
||||
super.readFromNBT(nbtTags);
|
||||
|
||||
// Main inventory
|
||||
if (nbtTags.hasKey("Items"))
|
||||
{
|
||||
NBTTagList tagList = nbtTags.getTagList("Items");
|
||||
structure.inventory = new ArrayList<ItemStack>();
|
||||
|
||||
for (int tagCount = 0; tagCount < tagList.tagCount(); tagCount++)
|
||||
{
|
||||
NBTTagCompound tagCompound = (NBTTagCompound) tagList.tagAt(tagCount);
|
||||
int slotID = tagCompound.getInteger("Slot");
|
||||
structure.inventory.add(slotID, ItemStack.loadItemStackFromNBT(tagCompound));
|
||||
}
|
||||
}
|
||||
|
||||
// Visible inventory
|
||||
if (nbtTags.hasKey("VisibleItems"))
|
||||
{
|
||||
NBTTagList tagList = nbtTags.getTagList("VisibleItems");
|
||||
structure.visibleInventory = new ItemStack[3];
|
||||
|
||||
for (int tagCount = 0; tagCount < tagList.tagCount(); tagCount++)
|
||||
{
|
||||
NBTTagCompound tagCompound = (NBTTagCompound) tagList.tagAt(tagCount);
|
||||
byte slotID = tagCompound.getByte("Slot");
|
||||
|
||||
if (slotID >= 0 && slotID < structure.visibleInventory.length)
|
||||
{
|
||||
if (slotID == 0)
|
||||
{
|
||||
setInventorySlotContents(slotID, ItemStack.loadItemStackFromNBT(tagCompound));
|
||||
}
|
||||
else
|
||||
{
|
||||
setInventorySlotContents(slotID + 1, ItemStack.loadItemStackFromNBT(tagCompound));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbtTags)
|
||||
{
|
||||
super.writeToNBT(nbtTags);
|
||||
|
||||
if (!structure.wroteInventory)
|
||||
{
|
||||
// Inventory
|
||||
if (structure.inventory != null)
|
||||
{
|
||||
NBTTagList tagList = new NBTTagList();
|
||||
|
||||
for (int slotCount = 0; slotCount < structure.inventory.size(); slotCount++)
|
||||
{
|
||||
if (structure.inventory.get(slotCount) != null)
|
||||
{
|
||||
NBTTagCompound tagCompound = new NBTTagCompound();
|
||||
tagCompound.setInteger("Slot", slotCount);
|
||||
structure.inventory.get(slotCount).writeToNBT(tagCompound);
|
||||
tagList.appendTag(tagCompound);
|
||||
}
|
||||
}
|
||||
|
||||
nbtTags.setTag("Items", tagList);
|
||||
}
|
||||
|
||||
// Visible inventory
|
||||
if (structure.visibleInventory != null)
|
||||
{
|
||||
NBTTagList tagList = new NBTTagList();
|
||||
|
||||
for (int slotCount = 0; slotCount < structure.visibleInventory.length; slotCount++)
|
||||
{
|
||||
if (slotCount > 0)
|
||||
{
|
||||
slotCount++;
|
||||
}
|
||||
|
||||
if (getStackInSlot(slotCount) != null)
|
||||
{
|
||||
NBTTagCompound tagCompound = new NBTTagCompound();
|
||||
tagCompound.setByte("Slot", (byte) slotCount);
|
||||
getStackInSlot(slotCount).writeToNBT(tagCompound);
|
||||
tagList.appendTag(tagCompound);
|
||||
}
|
||||
}
|
||||
|
||||
nbtTags.setTag("VisibleItems", tagList);
|
||||
}
|
||||
|
||||
structure.wroteInventory = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void update()
|
||||
{
|
||||
if(!worldObj.isRemote && (structure == null || !structure.didTick))
|
||||
if (!worldObj.isRemote && (structure == null || !structure.didTick))
|
||||
{
|
||||
new BatteryUpdateProtocol(this).updateBatteries();
|
||||
|
||||
if(structure != null)
|
||||
|
||||
if (structure != null)
|
||||
{
|
||||
structure.didTick = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return added energy
|
||||
*/
|
||||
public float addEnergy(float amount, boolean doAdd)
|
||||
{
|
||||
float added = 0;
|
||||
|
||||
for(ItemStack itemStack : structure.inventory)
|
||||
|
||||
for (ItemStack itemStack : structure.inventory)
|
||||
{
|
||||
if(itemStack.getItem() instanceof IBattery)
|
||||
if (itemStack.getItem() instanceof IBattery)
|
||||
{
|
||||
IBattery battery = (IBattery)itemStack.getItem();
|
||||
|
||||
float needed = amount-added;
|
||||
float itemAdd = Math.min(battery.getMaxEnergyStored(itemStack)-battery.getEnergyStored(itemStack), needed);
|
||||
|
||||
if(doAdd)
|
||||
IBattery battery = (IBattery) itemStack.getItem();
|
||||
|
||||
float needed = amount - added;
|
||||
float itemAdd = Math.min(battery.getMaxEnergyStored(itemStack) - battery.getEnergyStored(itemStack), needed);
|
||||
|
||||
if (doAdd)
|
||||
{
|
||||
battery.setEnergyStored(itemStack, battery.getEnergyStored(itemStack) + itemAdd);
|
||||
}
|
||||
|
||||
|
||||
added += itemAdd;
|
||||
|
||||
if(amount == added)
|
||||
|
||||
if (amount == added)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return added;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return removed energy
|
||||
*/
|
||||
public float removeEnergy(float amount, boolean doRemove)
|
||||
{
|
||||
List<ItemStack> inverse = ListUtil.inverse(structure.inventory);
|
||||
|
||||
|
||||
float removed = 0;
|
||||
|
||||
for(ItemStack itemStack : inverse)
|
||||
|
||||
for (ItemStack itemStack : inverse)
|
||||
{
|
||||
if(itemStack.getItem() instanceof IBattery)
|
||||
if (itemStack.getItem() instanceof IBattery)
|
||||
{
|
||||
IBattery battery = (IBattery)itemStack.getItem();
|
||||
|
||||
float needed = amount-removed;
|
||||
IBattery battery = (IBattery) itemStack.getItem();
|
||||
|
||||
float needed = amount - removed;
|
||||
float itemRemove = Math.min(battery.getEnergyStored(itemStack), needed);
|
||||
|
||||
if(doRemove)
|
||||
|
||||
if (doRemove)
|
||||
{
|
||||
battery.setEnergyStored(itemStack, battery.getEnergyStored(itemStack) - itemRemove);
|
||||
}
|
||||
|
||||
|
||||
removed += itemRemove;
|
||||
|
||||
if(amount == removed)
|
||||
|
||||
if (amount == removed)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return removed;
|
||||
}
|
||||
|
||||
public float getMaxEnergyStored()
|
||||
{
|
||||
if(!worldObj.isRemote)
|
||||
if (!worldObj.isRemote)
|
||||
{
|
||||
float max = 0;
|
||||
|
||||
|
||||
for (ItemStack itemStack : structure.inventory)
|
||||
{
|
||||
if (itemStack != null)
|
||||
|
@ -312,20 +313,21 @@ public class TileEntityBattery extends TileEntityBase implements IPacketReceiver
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return max;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
return clientMaxEnergy;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public float getEnergyStored()
|
||||
{
|
||||
if(!worldObj.isRemote)
|
||||
if (!worldObj.isRemote)
|
||||
{
|
||||
float energy = 0;
|
||||
|
||||
|
||||
for (ItemStack itemStack : structure.inventory)
|
||||
{
|
||||
if (itemStack != null)
|
||||
|
@ -336,48 +338,53 @@ public class TileEntityBattery extends TileEntityBase implements IPacketReceiver
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return energy;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
return clientEnergy;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(ByteArrayDataInput input)
|
||||
public void handle(ByteArrayDataInput input)
|
||||
{
|
||||
try {
|
||||
try
|
||||
{
|
||||
structure.isMultiblock = input.readBoolean();
|
||||
|
||||
|
||||
clientEnergy = input.readFloat();
|
||||
clientCells = input.readInt();
|
||||
clientMaxEnergy = input.readFloat();
|
||||
|
||||
|
||||
structure.height = input.readInt();
|
||||
structure.length = input.readInt();
|
||||
structure.width = input.readInt();
|
||||
} catch(Exception e) {}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList getNetworkedData(ArrayList data)
|
||||
{
|
||||
data.add(structure.isMultiblock);
|
||||
|
||||
|
||||
data.add(getEnergyStored());
|
||||
data.add(structure.inventory.size());
|
||||
data.add(getMaxEnergyStored());
|
||||
|
||||
|
||||
data.add(structure.height);
|
||||
data.add(structure.length);
|
||||
data.add(structure.width);
|
||||
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory()
|
||||
public int getSizeInventory()
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
@ -385,88 +392,95 @@ public class TileEntityBattery extends TileEntityBase implements IPacketReceiver
|
|||
@Override
|
||||
public ItemStack getStackInSlot(int i)
|
||||
{
|
||||
if(i == 0)
|
||||
if (i == 0)
|
||||
{
|
||||
return structure.visibleInventory[0];
|
||||
}
|
||||
else if(i == 1)
|
||||
else if (i == 1)
|
||||
{
|
||||
if(!worldObj.isRemote)
|
||||
if (!worldObj.isRemote)
|
||||
{
|
||||
return ListUtil.getTop(structure.inventory);
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
return structure.tempStack;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return structure.visibleInventory[i-1];
|
||||
else
|
||||
{
|
||||
return structure.visibleInventory[i - 1];
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int slotID, int amount)
|
||||
public ItemStack decrStackSize(int slotID, int amount)
|
||||
{
|
||||
if(getStackInSlot(slotID) != null)
|
||||
{
|
||||
ItemStack tempStack;
|
||||
if (getStackInSlot(slotID) != null)
|
||||
{
|
||||
ItemStack tempStack;
|
||||
|
||||
if(getStackInSlot(slotID).stackSize <= amount)
|
||||
{
|
||||
tempStack = getStackInSlot(slotID);
|
||||
setInventorySlotContents(slotID, null);
|
||||
return tempStack;
|
||||
}
|
||||
else {
|
||||
tempStack = getStackInSlot(slotID).splitStack(amount);
|
||||
if (getStackInSlot(slotID).stackSize <= amount)
|
||||
{
|
||||
tempStack = getStackInSlot(slotID);
|
||||
setInventorySlotContents(slotID, null);
|
||||
return tempStack;
|
||||
}
|
||||
else
|
||||
{
|
||||
tempStack = getStackInSlot(slotID).splitStack(amount);
|
||||
|
||||
if(getStackInSlot(slotID).stackSize == 0)
|
||||
{
|
||||
setInventorySlotContents(slotID, null);
|
||||
}
|
||||
if (getStackInSlot(slotID).stackSize == 0)
|
||||
{
|
||||
setInventorySlotContents(slotID, null);
|
||||
}
|
||||
|
||||
return tempStack;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
return tempStack;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int i)
|
||||
public ItemStack getStackInSlotOnClosing(int i)
|
||||
{
|
||||
return getStackInSlot(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int i, ItemStack itemstack)
|
||||
public void setInventorySlotContents(int i, ItemStack itemstack)
|
||||
{
|
||||
if(i == 0)
|
||||
if (i == 0)
|
||||
{
|
||||
structure.visibleInventory[0] = itemstack;
|
||||
}
|
||||
else if(i == 1)
|
||||
else if (i == 1)
|
||||
{
|
||||
if(itemstack == null)
|
||||
if (itemstack == null)
|
||||
{
|
||||
if(!worldObj.isRemote)
|
||||
if (!worldObj.isRemote)
|
||||
{
|
||||
structure.inventory.remove(ListUtil.getTop(structure.inventory));
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
structure.tempStack = null;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(worldObj.isRemote)
|
||||
else
|
||||
{
|
||||
if (worldObj.isRemote)
|
||||
{
|
||||
structure.tempStack = itemstack;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
structure.visibleInventory[i-1] = itemstack;
|
||||
else
|
||||
{
|
||||
structure.visibleInventory[i - 1] = itemstack;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -477,37 +491,41 @@ public class TileEntityBattery extends TileEntityBase implements IPacketReceiver
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isInvNameLocalized()
|
||||
public boolean isInvNameLocalized()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit()
|
||||
public int getInventoryStackLimit()
|
||||
{
|
||||
return 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer entityplayer)
|
||||
public boolean isUseableByPlayer(EntityPlayer entityplayer)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openChest() {}
|
||||
public void openChest()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeChest() {}
|
||||
public void closeChest()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int i, ItemStack itemstack)
|
||||
public boolean isItemValidForSlot(int i, ItemStack itemstack)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float transfer(float transferEnergy, boolean doTransfer)
|
||||
public float transfer(float transferEnergy, boolean doTransfer)
|
||||
{
|
||||
return addEnergy(transferEnergy, doTransfer);
|
||||
}
|
||||
|
@ -515,6 +533,6 @@ public class TileEntityBattery extends TileEntityBase implements IPacketReceiver
|
|||
@Override
|
||||
public boolean canReceive(TileEntity transferTile)
|
||||
{
|
||||
return true;
|
||||
return this.getMaxEnergyStored() - this.getEnergyStored() > 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,9 @@ package resonantinduction.multimeter;
|
|||
import net.minecraft.block.ITileEntityProvider;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
@ -29,9 +32,49 @@ public class BlockMultimeter extends BlockBase implements ITileEntityProvider
|
|||
this.func_111022_d(ResonantInduction.PREFIX + "machine");
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MovingObjectPosition collisionRayTrace(World par1World, int par2, int par3, int par4, Vec3 par5Vec3, Vec3 par6Vec3)
|
||||
{
|
||||
int metadata = par1World.getBlockMetadata(par2, par3, par4) & 7;
|
||||
float thickness = 0.15f;
|
||||
System.out.println(metadata);
|
||||
if (metadata == 0)
|
||||
{
|
||||
this.setBlockBounds(0, 0, 0, 1, thickness, 1);
|
||||
}
|
||||
else if (metadata == 1)
|
||||
{
|
||||
this.setBlockBounds(0, 1 - thickness, 0, 1, 1, 1);
|
||||
}
|
||||
else if (metadata == 2)
|
||||
{
|
||||
this.setBlockBounds(0, 0, 0, 1, 1, thickness);
|
||||
}
|
||||
else if (metadata == 3)
|
||||
{
|
||||
this.setBlockBounds(0, 0, 1 - thickness, 1, 1, 1);
|
||||
}
|
||||
else if (metadata == 4)
|
||||
{
|
||||
this.setBlockBounds(0, 0, 0, thickness, 1, 1);
|
||||
}
|
||||
else if (metadata == 5)
|
||||
{
|
||||
this.setBlockBounds(1 - thickness, 0, 0, 1, 1, 1);
|
||||
}
|
||||
|
||||
return super.collisionRayTrace(par1World, par2, par3, par4, par5Vec3, par6Vec3);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a block is placed using its ItemBlock. Args: World, X, Y, Z, side, hitX, hitY,
|
||||
* hitZ, block metadata
|
||||
* hi@OverridetZ, block metadata
|
||||
*/
|
||||
public int onBlockPlaced(World par1World, int par2, int par3, int par4, int side, float hitX, float hitY, float hitZ, int metadata)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue