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

155 lines
3.9 KiB
Java
Raw Normal View History

package techreborn.tiles;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
2015-11-23 15:45:16 +01:00
import net.minecraft.util.EnumFacing;
import reborncore.api.power.EnumPowerTier;
2016-04-11 18:23:57 +02:00
import reborncore.api.recipe.IRecipeCrafterProvider;
import reborncore.api.tile.IInventoryProvider;
2016-10-08 21:46:16 +02:00
import reborncore.common.IWrenchable;
import reborncore.common.powerSystem.TilePowerAcceptor;
2016-04-11 18:23:57 +02:00
import reborncore.common.recipes.RecipeCrafter;
import reborncore.common.util.Inventory;
2016-04-03 15:07:45 +02:00
import techreborn.api.Reference;
import techreborn.client.container.IContainerProvider;
import techreborn.client.container.builder.BuiltContainer;
import techreborn.client.container.builder.ContainerBuilder;
import techreborn.init.ModBlocks;
public class TileAssemblingMachine extends TilePowerAcceptor
implements IWrenchable, ISidedInventory, IInventoryProvider, IRecipeCrafterProvider, IContainerProvider {
2016-03-25 10:47:34 +01:00
public int tickTime;
public Inventory inventory = new Inventory(8, "TileAssemblingMachine", 64, this);
public RecipeCrafter crafter;
2016-10-08 21:46:16 +02:00
public TileAssemblingMachine() {
super(2);
2016-03-25 10:47:34 +01:00
// Input slots
final int[] inputs = new int[2];
2016-03-25 10:47:34 +01:00
inputs[0] = 0;
inputs[1] = 1;
final int[] outputs = new int[1];
2016-03-25 10:47:34 +01:00
outputs[0] = 2;
this.crafter = new RecipeCrafter(Reference.assemblingMachineRecipe, this, 2, 2, this.inventory, inputs, outputs);
2016-03-25 10:47:34 +01:00
}
@Override
2016-10-08 21:46:16 +02:00
public void updateEntity() {
super.updateEntity();
this.charge(3);
2016-03-25 10:47:34 +01:00
}
@Override
public boolean wrenchCanSetFacing(final EntityPlayer entityPlayer, final EnumFacing side) {
2016-03-25 10:47:34 +01:00
return false;
}
@Override
2016-10-08 21:46:16 +02:00
public EnumFacing getFacing() {
return this.getFacingEnum();
2016-03-25 10:47:34 +01:00
}
@Override
public boolean wrenchCanRemove(final EntityPlayer entityPlayer) {
return entityPlayer.isSneaking();
2016-03-25 10:47:34 +01:00
}
@Override
2016-10-08 21:46:16 +02:00
public float getWrenchDropRate() {
2016-03-25 10:47:34 +01:00
return 1.0F;
}
@Override
public ItemStack getWrenchDrop(final EntityPlayer entityPlayer) {
return new ItemStack(ModBlocks.ASSEMBLY_MACHINE, 1);
2016-03-25 10:47:34 +01:00
}
2016-10-08 21:46:16 +02:00
public boolean isComplete() {
return false;
}
// @Override
// public void addWailaInfo(List<String> info)
// {
// super.addWailaInfo(info);
// info.add("Power Stored " + energy.getEnergyStored() +" EU");
// if(crafter.currentRecipe !=null){
// info.add("Power Usage " + crafter.currentRecipe.euPerTick() + " EU/t");
// }
// }
public int getProgressScaled(final int scale) {
if (this.crafter.currentTickTime != 0) {
return this.crafter.currentTickTime * scale / this.crafter.currentNeededTicks;
2016-03-25 10:47:34 +01:00
}
return 0;
}
@Override
2016-10-08 21:46:16 +02:00
public double getMaxPower() {
return 10000;
}
@Override
public boolean canAcceptEnergy(final EnumFacing direction) {
return true;
}
@Override
public boolean canProvideEnergy(final EnumFacing direction) {
return false;
}
@Override
2016-10-08 21:46:16 +02:00
public double getMaxOutput() {
return 0;
}
@Override
2016-10-08 21:46:16 +02:00
public double getMaxInput() {
return 128;
2016-03-25 10:47:34 +01:00
}
@Override
2016-10-08 21:46:16 +02:00
public EnumPowerTier getTier() {
return EnumPowerTier.LOW;
2016-03-25 10:47:34 +01:00
}
@Override
2016-04-11 18:23:57 +02:00
public Inventory getInventory() {
return this.inventory;
2016-03-25 10:47:34 +01:00
}
@Override
2016-04-11 18:23:57 +02:00
public RecipeCrafter getRecipeCrafter() {
return this.crafter;
2016-03-25 10:47:34 +01:00
}
2016-10-08 21:46:16 +02:00
@Override
public int[] getSlotsForFace(final EnumFacing side) {
2016-10-08 21:46:16 +02:00
return new int[] { 0, 1, 2 };
}
2016-07-27 12:51:03 +02:00
2016-10-08 21:46:16 +02:00
@Override
public boolean canInsertItem(final int index, final ItemStack itemStackIn, final EnumFacing direction) {
2016-10-08 21:46:16 +02:00
return index == 0 || index == 1;
}
2016-07-27 12:51:03 +02:00
2016-10-08 21:46:16 +02:00
@Override
public boolean canExtractItem(final int index, final ItemStack stack, final EnumFacing direction) {
2016-10-08 21:46:16 +02:00
return index == 2;
}
2016-07-27 12:51:03 +02:00
@Override
public BuiltContainer createContainer(final EntityPlayer player) {
return new ContainerBuilder("assemblingmachine").player(player.inventory).inventory(8, 84).hotbar(8, 142)
.addInventory().tile(this).slot(0, 47, 17).slot(1, 65, 17).outputSlot(2, 116, 35).energySlot(3, 56, 53)
.upgradeSlot(4, 152, 8).upgradeSlot(5, 152, 26).upgradeSlot(6, 152, 44).upgradeSlot(7, 152, 62)
.syncEnergyValue().syncCrafterValue().addInventory().create();
}
}