TechReborn/src/main/java/techreborn/tiles/TileAesu.java

119 lines
2.2 KiB
Java
Raw Normal View History

2015-05-09 21:19:40 +02:00
package techreborn.tiles;
import ic2.api.tile.IWrenchable;
2015-05-10 22:02:57 +02:00
import ic2.core.block.wiring.TileEntityElectricBlock;
2015-05-09 21:19:40 +02:00
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import techreborn.init.ModBlocks;
import techreborn.util.Inventory;
import techreborn.util.LogHelper;
import java.lang.reflect.Field;
2015-05-09 21:19:40 +02:00
2015-05-10 22:02:57 +02:00
public class TileAesu extends TileEntityElectricBlock implements IWrenchable {
2015-05-09 21:19:40 +02:00
2015-05-10 22:02:57 +02:00
public static final int MAX_OUTPUT = 8192;
public static final int MAX_STORAGE = 1000000000; //One billion!
2015-05-09 21:19:40 +02:00
public Inventory inventory = new Inventory(2, "TileAesu", 64);
private int OUTPUT = 64; //The current output
2015-05-09 21:19:40 +02:00
public TileAesu()
{
2015-05-10 22:02:57 +02:00
super(5, TileAesu.MAX_OUTPUT, TileAesu.MAX_STORAGE);
2015-05-09 21:19:40 +02:00
}
@Override
public void updateEntity()
{
super.updateEntity();
}
@Override
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side)
{
2015-06-07 20:11:08 +02:00
return true;
2015-05-09 21:19:40 +02:00
}
@Override
public short getFacing()
{
return super.getFacing();
2015-05-09 21:19:40 +02:00
}
@Override
public void setFacing(short facing)
{
2015-06-07 20:11:08 +02:00
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, facing, 2);
2015-06-10 14:54:46 +02:00
super.setFacing(facing);
2015-06-07 20:11:08 +02:00
}
2015-05-09 21:19:40 +02:00
@Override
public boolean wrenchCanRemove(EntityPlayer entityPlayer)
{
if (entityPlayer.isSneaking())
{
return true;
}
return false;
2015-05-09 21:19:40 +02:00
}
@Override
public float getWrenchDropRate()
{
return 1.0F;
}
@Override
public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
{
2015-05-09 21:47:05 +02:00
return new ItemStack(ModBlocks.Aesu, 1);
2015-05-09 21:19:40 +02:00
}
public boolean isComplete()
{
return false;
}
2015-05-10 22:02:57 +02:00
@Override
public String getInventoryName()
{
return "AESU";
}
public void handleGuiInputFromClient(int id){
if(id == 0){
OUTPUT += 256;
}
if(id == 1){
OUTPUT += 64;
}
if(id == 2){
OUTPUT -= 64;
}
if(id == 3){
OUTPUT -= 256;
}
if(OUTPUT > MAX_OUTPUT){
OUTPUT = MAX_OUTPUT;
}
if(OUTPUT <= -1){
OUTPUT = 0;
}
//TODO make a better way and not use reflection for this.
try {
Field field = getClass().getSuperclass().getDeclaredField("output");
field.setAccessible(true);
field.set(this, OUTPUT);
} catch (NoSuchFieldException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
2015-06-10 19:36:07 +02:00
LogHelper.debug("Set output to " + getOutput());
}
2015-05-09 21:19:40 +02:00
}