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
|
||||
|
@ -43,7 +50,7 @@ public class ItemCapacitor extends ItemBase implements IBattery
|
|||
}
|
||||
|
||||
itemStack.getTagCompound().setFloat("energyStored", amount);
|
||||
itemStack.setItemDamage((int)(100 - (amount / getMaxEnergyStored(itemStack)) * 100));
|
||||
itemStack.setItemDamage((int) (100 - (amount / getMaxEnergyStored(itemStack)) * 100));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -55,7 +62,7 @@ public class ItemCapacitor extends ItemBase implements IBattery
|
|||
}
|
||||
|
||||
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
|
||||
|
|
|
@ -42,26 +42,26 @@ public class TileEntityBattery extends TileEntityBase implements IPacketReceiver
|
|||
{
|
||||
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;
|
||||
|
@ -69,33 +69,33 @@ public class TileEntityBattery extends TileEntityBase implements IPacketReceiver
|
|||
}
|
||||
}
|
||||
|
||||
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();
|
||||
IBattery battery = (IBattery) itemStack.getItem();
|
||||
|
||||
float energyNeeded = getMaxEnergyStored()-getEnergyStored();
|
||||
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();
|
||||
}
|
||||
|
@ -118,110 +118,111 @@ public class TileEntityBattery extends TileEntityBase implements IPacketReceiver
|
|||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbtTags)
|
||||
{
|
||||
super.readFromNBT(nbtTags);
|
||||
public void readFromNBT(NBTTagCompound nbtTags)
|
||||
{
|
||||
super.readFromNBT(nbtTags);
|
||||
|
||||
//Main inventory
|
||||
if(nbtTags.hasKey("Items"))
|
||||
{
|
||||
NBTTagList tagList = nbtTags.getTagList("Items");
|
||||
structure.inventory = new ArrayList<ItemStack>();
|
||||
// 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));
|
||||
}
|
||||
}
|
||||
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];
|
||||
// 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");
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
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);
|
||||
public void writeToNBT(NBTTagCompound nbtTags)
|
||||
{
|
||||
super.writeToNBT(nbtTags);
|
||||
|
||||
if(!structure.wroteInventory)
|
||||
{
|
||||
//Inventory
|
||||
if(structure.inventory != null)
|
||||
{
|
||||
NBTTagList tagList = new NBTTagList();
|
||||
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);
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
nbtTags.setTag("Items", tagList);
|
||||
}
|
||||
|
||||
//Visible inventory
|
||||
if(structure.visibleInventory != null)
|
||||
{
|
||||
NBTTagList tagList = new NBTTagList();
|
||||
// Visible inventory
|
||||
if (structure.visibleInventory != null)
|
||||
{
|
||||
NBTTagList tagList = new NBTTagList();
|
||||
|
||||
for(int slotCount = 0; slotCount < structure.visibleInventory.length; slotCount++)
|
||||
{
|
||||
if(slotCount > 0)
|
||||
{
|
||||
slotCount++;
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
if (getStackInSlot(slotCount) != null)
|
||||
{
|
||||
NBTTagCompound tagCompound = new NBTTagCompound();
|
||||
tagCompound.setByte("Slot", (byte) slotCount);
|
||||
getStackInSlot(slotCount).writeToNBT(tagCompound);
|
||||
tagList.appendTag(tagCompound);
|
||||
}
|
||||
}
|
||||
|
||||
nbtTags.setTag("VisibleItems", tagList);
|
||||
}
|
||||
nbtTags.setTag("VisibleItems", tagList);
|
||||
}
|
||||
|
||||
structure.wroteInventory = true;
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
@ -235,23 +236,23 @@ public class TileEntityBattery extends TileEntityBase implements IPacketReceiver
|
|||
{
|
||||
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();
|
||||
IBattery battery = (IBattery) itemStack.getItem();
|
||||
|
||||
float needed = amount-added;
|
||||
float itemAdd = Math.min(battery.getMaxEnergyStored(itemStack)-battery.getEnergyStored(itemStack), needed);
|
||||
float needed = amount - added;
|
||||
float itemAdd = Math.min(battery.getMaxEnergyStored(itemStack) - battery.getEnergyStored(itemStack), needed);
|
||||
|
||||
if(doAdd)
|
||||
if (doAdd)
|
||||
{
|
||||
battery.setEnergyStored(itemStack, battery.getEnergyStored(itemStack) + itemAdd);
|
||||
}
|
||||
|
||||
added += itemAdd;
|
||||
|
||||
if(amount == added)
|
||||
if (amount == added)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
@ -270,23 +271,23 @@ public class TileEntityBattery extends TileEntityBase implements IPacketReceiver
|
|||
|
||||
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();
|
||||
IBattery battery = (IBattery) itemStack.getItem();
|
||||
|
||||
float needed = amount-removed;
|
||||
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;
|
||||
}
|
||||
|
@ -298,7 +299,7 @@ public class TileEntityBattery extends TileEntityBase implements IPacketReceiver
|
|||
|
||||
public float getMaxEnergyStored()
|
||||
{
|
||||
if(!worldObj.isRemote)
|
||||
if (!worldObj.isRemote)
|
||||
{
|
||||
float max = 0;
|
||||
|
||||
|
@ -315,14 +316,15 @@ 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;
|
||||
|
||||
|
@ -339,7 +341,8 @@ public class TileEntityBattery extends TileEntityBase implements IPacketReceiver
|
|||
|
||||
return energy;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
return clientEnergy;
|
||||
}
|
||||
}
|
||||
|
@ -347,7 +350,8 @@ public class TileEntityBattery extends TileEntityBase implements IPacketReceiver
|
|||
@Override
|
||||
public void handle(ByteArrayDataInput input)
|
||||
{
|
||||
try {
|
||||
try
|
||||
{
|
||||
structure.isMultiblock = input.readBoolean();
|
||||
|
||||
clientEnergy = input.readFloat();
|
||||
|
@ -357,7 +361,10 @@ public class TileEntityBattery extends TileEntityBase implements IPacketReceiver
|
|||
structure.height = input.readInt();
|
||||
structure.length = input.readInt();
|
||||
structure.width = input.readInt();
|
||||
} catch(Exception e) {}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -385,52 +392,56 @@ 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)
|
||||
{
|
||||
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
|
||||
|
@ -442,31 +453,34 @@ public class TileEntityBattery extends TileEntityBase implements IPacketReceiver
|
|||
@Override
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -495,10 +509,14 @@ public class TileEntityBattery extends TileEntityBase implements IPacketReceiver
|
|||
}
|
||||
|
||||
@Override
|
||||
public void openChest() {}
|
||||
public void openChest()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeChest() {}
|
||||
public void closeChest()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int i, ItemStack itemstack)
|
||||
|
@ -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