2015-05-09 21:19:40 +02:00
|
|
|
package techreborn.tiles;
|
|
|
|
|
2015-06-10 14:52:54 +02:00
|
|
|
import codechicken.microblock.FaceEdgeGrid;
|
2015-05-09 21:19:40 +02:00
|
|
|
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;
|
2015-06-10 14:52:54 +02:00
|
|
|
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);
|
2015-06-10 14:52:54 +02:00
|
|
|
public 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()
|
|
|
|
{
|
2015-06-07 20:11:08 +02:00
|
|
|
return (short) getBlockMetadata();
|
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)
|
|
|
|
{
|
2015-05-10 18:06:08 +02:00
|
|
|
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";
|
|
|
|
}
|
|
|
|
|
2015-06-10 14:52:54 +02:00
|
|
|
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 < 0){
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
|
|
|
LogHelper.info("Set output to " + getOutput());
|
|
|
|
}
|
|
|
|
|
2015-05-09 21:19:40 +02:00
|
|
|
}
|