Added configs. Some work on #1469
This commit is contained in:
parent
49e93a460f
commit
799386b872
4 changed files with 151 additions and 148 deletions
|
@ -32,6 +32,7 @@ import reborncore.api.recipe.IRecipeCrafterProvider;
|
||||||
import reborncore.api.tile.IInventoryProvider;
|
import reborncore.api.tile.IInventoryProvider;
|
||||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||||
import reborncore.common.recipes.RecipeCrafter;
|
import reborncore.common.recipes.RecipeCrafter;
|
||||||
|
import reborncore.common.registration.impl.ConfigRegistry;
|
||||||
import reborncore.common.util.Inventory;
|
import reborncore.common.util.Inventory;
|
||||||
import techreborn.api.Reference;
|
import techreborn.api.Reference;
|
||||||
import techreborn.client.container.IContainerProvider;
|
import techreborn.client.container.IContainerProvider;
|
||||||
|
@ -39,37 +40,22 @@ import techreborn.client.container.builder.BuiltContainer;
|
||||||
import techreborn.client.container.builder.ContainerBuilder;
|
import techreborn.client.container.builder.ContainerBuilder;
|
||||||
import techreborn.init.ModBlocks;
|
import techreborn.init.ModBlocks;
|
||||||
|
|
||||||
public class TileCompressor extends TilePowerAcceptor implements IToolDrop, IInventoryProvider, IRecipeCrafterProvider, IContainerProvider {
|
public class TileCompressor extends TilePowerAcceptor
|
||||||
|
implements IToolDrop, IInventoryProvider, IContainerProvider, IRecipeCrafterProvider {
|
||||||
|
|
||||||
|
@ConfigRegistry(config = "machines", category = "compressor", key = "CompressorInput", comment = "Compressor Max Input (Value in EU)")
|
||||||
|
public static int maxInput = 32;
|
||||||
|
@ConfigRegistry(config = "machines", category = "compressor", key = "CompressorMaxEnergy", comment = "Compressor Max Energy (Value in EU)")
|
||||||
|
public static int maxEnergy = 1000;
|
||||||
|
|
||||||
public Inventory inventory = new Inventory(3, "TileCompressor", 64, this);
|
public Inventory inventory = new Inventory(3, "TileCompressor", 64, this);
|
||||||
|
|
||||||
public RecipeCrafter crafter;
|
public RecipeCrafter crafter;
|
||||||
|
|
||||||
public int capacity = 1000;
|
|
||||||
|
|
||||||
public TileCompressor() {
|
public TileCompressor() {
|
||||||
super();
|
super();
|
||||||
final int[] inputs = new int[] { 0 };
|
final int[] inputs = new int[] { 0 };
|
||||||
final int[] outputs = new int[] { 1 };
|
final int[] outputs = new int[] { 1 };
|
||||||
this.crafter = new RecipeCrafter(Reference.COMPRESSOR_RECIPE, this, 2, 1, this.inventory, inputs, outputs);
|
this.crafter = new RecipeCrafter(Reference.COMPRESSOR_RECIPE, this, 2, 1, this.inventory, inputs, outputs);
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void update() {
|
|
||||||
if (!this.world.isRemote) {
|
|
||||||
super.update();
|
|
||||||
this.charge(2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ItemStack getToolDrop(final EntityPlayer entityPlayer) {
|
|
||||||
return new ItemStack(ModBlocks.COMPRESSOR, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isComplete() {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getProgressScaled(final int scale) {
|
public int getProgressScaled(final int scale) {
|
||||||
|
@ -79,9 +65,18 @@ public class TileCompressor extends TilePowerAcceptor implements IToolDrop, IInv
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TilePowerAcceptor
|
||||||
|
@Override
|
||||||
|
public void update() {
|
||||||
|
if (!this.world.isRemote) {
|
||||||
|
super.update();
|
||||||
|
this.charge(2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxPower() {
|
public double getBaseMaxPower() {
|
||||||
return this.capacity;
|
return maxEnergy;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -101,23 +96,32 @@ public class TileCompressor extends TilePowerAcceptor implements IToolDrop, IInv
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxInput() {
|
public double getBaseMaxInput() {
|
||||||
return 32;
|
return maxInput;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IToolDrop
|
||||||
|
@Override
|
||||||
|
public ItemStack getToolDrop(final EntityPlayer entityPlayer) {
|
||||||
|
return new ItemStack(ModBlocks.COMPRESSOR, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// IInventoryProvider
|
||||||
@Override
|
@Override
|
||||||
public Inventory getInventory() {
|
public Inventory getInventory() {
|
||||||
return this.inventory;
|
return this.inventory;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
// IContainerProvider
|
||||||
public RecipeCrafter getRecipeCrafter() {
|
|
||||||
return this.crafter;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BuiltContainer createContainer(final EntityPlayer player) {
|
public BuiltContainer createContainer(final EntityPlayer player) {
|
||||||
return new ContainerBuilder("compressor").player(player.inventory).inventory().hotbar().addInventory()
|
return new ContainerBuilder("compressor").player(player.inventory).inventory().hotbar().addInventory()
|
||||||
.tile(this).slot(0, 55, 45).outputSlot(1, 101, 45).energySlot(2, 8, 72).syncEnergyValue()
|
.tile(this).slot(0, 55, 45).outputSlot(1, 101, 45).energySlot(2, 8, 72).syncEnergyValue()
|
||||||
.syncCrafterValue().addInventory().create(this);
|
.syncCrafterValue().addInventory().create(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IRecipeCrafterProvider
|
||||||
|
@Override
|
||||||
|
public RecipeCrafter getRecipeCrafter() {
|
||||||
|
return this.crafter;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@ import reborncore.api.IToolDrop;
|
||||||
import reborncore.api.tile.IInventoryProvider;
|
import reborncore.api.tile.IInventoryProvider;
|
||||||
import reborncore.common.blocks.BlockMachineBase;
|
import reborncore.common.blocks.BlockMachineBase;
|
||||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||||
|
import reborncore.common.registration.impl.ConfigRegistry;
|
||||||
import reborncore.common.util.Inventory;
|
import reborncore.common.util.Inventory;
|
||||||
import techreborn.client.container.IContainerProvider;
|
import techreborn.client.container.IContainerProvider;
|
||||||
import techreborn.client.container.builder.BuiltContainer;
|
import techreborn.client.container.builder.BuiltContainer;
|
||||||
|
@ -42,8 +43,12 @@ import techreborn.init.ModBlocks;
|
||||||
public class TileElectricFurnace extends TilePowerAcceptor
|
public class TileElectricFurnace extends TilePowerAcceptor
|
||||||
implements IToolDrop, IInventoryProvider, IContainerProvider {
|
implements IToolDrop, IInventoryProvider, IContainerProvider {
|
||||||
|
|
||||||
|
@ConfigRegistry(config = "machines", category = "electric_furnace", key = "ElectricFurnaceInput", comment = "Electric Furnace Max Input (Value in EU)")
|
||||||
|
public static int maxInput = 32;
|
||||||
|
@ConfigRegistry(config = "machines", category = "electric_furnace", key = "ElectricFurnaceMaxEnergy", comment = "Electric Furnace Max Energy (Value in EU)")
|
||||||
|
public static int maxEnergy = 1000;
|
||||||
|
|
||||||
public Inventory inventory = new Inventory(3, "TileElectricFurnace", 64, this);
|
public Inventory inventory = new Inventory(3, "TileElectricFurnace", 64, this);
|
||||||
public int capacity = 1000;
|
|
||||||
public int progress;
|
public int progress;
|
||||||
public int fuelScale = 100;
|
public int fuelScale = 100;
|
||||||
public int cost = 6;
|
public int cost = 6;
|
||||||
|
@ -59,39 +64,6 @@ public class TileElectricFurnace extends TilePowerAcceptor
|
||||||
return this.progress * scale / this.fuelScale;
|
return this.progress * scale / this.fuelScale;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void update() {
|
|
||||||
if (world.isRemote){ return; }
|
|
||||||
|
|
||||||
super.update();
|
|
||||||
this.charge(2);
|
|
||||||
|
|
||||||
final boolean burning = this.isBurning();
|
|
||||||
boolean updateInventory = false;
|
|
||||||
if (this.isBurning() && this.canSmelt()) {
|
|
||||||
this.updateState();
|
|
||||||
if(canUseEnergy(this.cost)){
|
|
||||||
this.useEnergy(this.cost);
|
|
||||||
this.progress++;
|
|
||||||
if (this.progress >= Math.max((int) (fuelScale * (1.0 - getSpeedMultiplier())), 2)) {
|
|
||||||
this.progress = 0;
|
|
||||||
this.cookItems();
|
|
||||||
updateInventory = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.progress = 0;
|
|
||||||
this.updateState();
|
|
||||||
}
|
|
||||||
if (burning != this.isBurning()) {
|
|
||||||
updateInventory = true;
|
|
||||||
}
|
|
||||||
if (updateInventory) {
|
|
||||||
this.markDirty();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void cookItems() {
|
public void cookItems() {
|
||||||
if (this.canSmelt()) {
|
if (this.canSmelt()) {
|
||||||
final ItemStack itemstack = FurnaceRecipes.instance().getSmeltingResult(this.getStackInSlot(this.input1));
|
final ItemStack itemstack = FurnaceRecipes.instance().getSmeltingResult(this.getStackInSlot(this.input1));
|
||||||
|
@ -138,7 +110,8 @@ public class TileElectricFurnace extends TilePowerAcceptor
|
||||||
|
|
||||||
public void updateState() {
|
public void updateState() {
|
||||||
if (wasBurning != (this.progress > 0)) {
|
if (wasBurning != (this.progress > 0)) {
|
||||||
//skips updating the block state for 1 tick, to prevent the machine from turning on/off rapidly causing fps drops
|
// skips updating the block state for 1 tick, to prevent the machine from
|
||||||
|
// turning on/off rapidly causing fps drops
|
||||||
if (wasBurning && this.progress == 0 && canSmelt()) {
|
if (wasBurning && this.progress == 0 && canSmelt()) {
|
||||||
wasBurning = true;
|
wasBurning = true;
|
||||||
return;
|
return;
|
||||||
|
@ -154,23 +127,53 @@ public class TileElectricFurnace extends TilePowerAcceptor
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public int getBurnTime() {
|
||||||
public EnumFacing getFacing() {
|
return this.progress;
|
||||||
return this.getFacingEnum();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void setBurnTime(final int burnTime) {
|
||||||
public ItemStack getToolDrop(final EntityPlayer entityPlayer) {
|
this.progress = burnTime;
|
||||||
return new ItemStack(ModBlocks.ELECTRIC_FURNACE, 1);
|
}
|
||||||
|
|
||||||
|
// TilePowerAcceptor
|
||||||
|
@Override
|
||||||
|
public void update() {
|
||||||
|
if (world.isRemote) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
super.update();
|
||||||
|
this.charge(2);
|
||||||
|
|
||||||
|
final boolean burning = this.isBurning();
|
||||||
|
boolean updateInventory = false;
|
||||||
|
if (this.isBurning() && this.canSmelt()) {
|
||||||
|
this.updateState();
|
||||||
|
if (canUseEnergy(this.cost)) {
|
||||||
|
this.useEnergy(this.cost);
|
||||||
|
this.progress++;
|
||||||
|
if (this.progress >= Math.max((int) (fuelScale * (1.0 - getSpeedMultiplier())), 2)) {
|
||||||
|
this.progress = 0;
|
||||||
|
this.cookItems();
|
||||||
|
updateInventory = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.progress = 0;
|
||||||
|
this.updateState();
|
||||||
|
}
|
||||||
|
if (burning != this.isBurning()) {
|
||||||
|
updateInventory = true;
|
||||||
|
}
|
||||||
|
if (updateInventory) {
|
||||||
|
this.markDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isComplete() {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxPower() {
|
public double getBaseMaxPower() {
|
||||||
return this.capacity;
|
return maxEnergy;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -190,31 +193,26 @@ public class TileElectricFurnace extends TilePowerAcceptor
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxInput() {
|
public double getBaseMaxInput() {
|
||||||
return 32;
|
return maxInput;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IToolDrop
|
||||||
|
@Override
|
||||||
|
public ItemStack getToolDrop(final EntityPlayer entityPlayer) {
|
||||||
|
return new ItemStack(ModBlocks.ELECTRIC_FURNACE, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// IInventoryProvider
|
||||||
@Override
|
@Override
|
||||||
public Inventory getInventory() {
|
public Inventory getInventory() {
|
||||||
return this.inventory;
|
return this.inventory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getBurnTime() {
|
// IContainerProvider
|
||||||
return this.progress;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBurnTime(final int burnTime) {
|
|
||||||
this.progress = burnTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BuiltContainer createContainer(final EntityPlayer player) {
|
public BuiltContainer createContainer(final EntityPlayer player) {
|
||||||
return new ContainerBuilder("electricfurnace").player(player.inventory).inventory().hotbar().addInventory()
|
return new ContainerBuilder("electricfurnace").player(player.inventory).inventory().hotbar().addInventory()
|
||||||
.tile(this).slot(0, 55, 45).outputSlot(1, 101, 45).energySlot(2, 8, 72).syncEnergyValue()
|
.tile(this).slot(0, 55, 45).outputSlot(1, 101, 45).energySlot(2, 8, 72).syncEnergyValue()
|
||||||
.syncIntegerValue(this::getBurnTime, this::setBurnTime).addInventory().create(this);
|
.syncIntegerValue(this::getBurnTime, this::setBurnTime).addInventory().create(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canBeUpgraded() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@ import reborncore.api.recipe.IRecipeCrafterProvider;
|
||||||
import reborncore.api.tile.IInventoryProvider;
|
import reborncore.api.tile.IInventoryProvider;
|
||||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||||
import reborncore.common.recipes.RecipeCrafter;
|
import reborncore.common.recipes.RecipeCrafter;
|
||||||
|
import reborncore.common.registration.impl.ConfigRegistry;
|
||||||
import reborncore.common.util.Inventory;
|
import reborncore.common.util.Inventory;
|
||||||
import techreborn.api.Reference;
|
import techreborn.api.Reference;
|
||||||
import techreborn.client.container.IContainerProvider;
|
import techreborn.client.container.IContainerProvider;
|
||||||
|
@ -41,14 +42,16 @@ import techreborn.client.container.builder.ContainerBuilder;
|
||||||
import techreborn.init.ModBlocks;
|
import techreborn.init.ModBlocks;
|
||||||
|
|
||||||
public class TileExtractor extends TilePowerAcceptor
|
public class TileExtractor extends TilePowerAcceptor
|
||||||
implements IToolDrop, IInventoryProvider, IRecipeCrafterProvider, IContainerProvider {
|
implements IToolDrop, IInventoryProvider, IContainerProvider, IRecipeCrafterProvider {
|
||||||
|
|
||||||
|
@ConfigRegistry(config = "machines", category = "extractor", key = "ExtractorInput", comment = "Extractor Max Input (Value in EU)")
|
||||||
|
public static int maxInput = 32;
|
||||||
|
@ConfigRegistry(config = "machines", category = "extractor", key = "ExtractorMaxEnergy", comment = "Extractor Max Energy (Value in EU)")
|
||||||
|
public static int maxEnergy = 1000;
|
||||||
|
|
||||||
public Inventory inventory = new Inventory(3, "TileExtractor", 64, this);
|
public Inventory inventory = new Inventory(3, "TileExtractor", 64, this);
|
||||||
|
|
||||||
public RecipeCrafter crafter;
|
public RecipeCrafter crafter;
|
||||||
|
|
||||||
public int capacity = 1000;
|
|
||||||
|
|
||||||
public TileExtractor() {
|
public TileExtractor() {
|
||||||
super();
|
super();
|
||||||
final int[] inputs = new int[1];
|
final int[] inputs = new int[1];
|
||||||
|
@ -58,6 +61,13 @@ public class TileExtractor extends TilePowerAcceptor
|
||||||
this.crafter = new RecipeCrafter(Reference.EXTRACTOR_RECIPE, this, 2, 1, this.inventory, inputs, outputs);
|
this.crafter = new RecipeCrafter(Reference.EXTRACTOR_RECIPE, this, 2, 1, this.inventory, inputs, outputs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getProgressScaled(final int scale) {
|
||||||
|
if (this.crafter.currentTickTime != 0) {
|
||||||
|
return this.crafter.currentTickTime * scale / this.crafter.currentNeededTicks;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update() {
|
public void update() {
|
||||||
if (!this.world.isRemote) {
|
if (!this.world.isRemote) {
|
||||||
|
@ -66,15 +76,6 @@ public class TileExtractor extends TilePowerAcceptor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ItemStack getToolDrop(final EntityPlayer entityPlayer) {
|
|
||||||
return new ItemStack(ModBlocks.EXTRACTOR, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isComplete() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readFromNBT(final NBTTagCompound tagCompound) {
|
public void readFromNBT(final NBTTagCompound tagCompound) {
|
||||||
super.readFromNBT(tagCompound);
|
super.readFromNBT(tagCompound);
|
||||||
|
@ -88,16 +89,9 @@ public class TileExtractor extends TilePowerAcceptor
|
||||||
return tagCompound;
|
return tagCompound;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getProgressScaled(final int scale) {
|
|
||||||
if (this.crafter.currentTickTime != 0) {
|
|
||||||
return this.crafter.currentTickTime * scale / this.crafter.currentNeededTicks;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxPower() {
|
public double getBaseMaxPower() {
|
||||||
return this.capacity;
|
return maxEnergy;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -117,19 +111,22 @@ public class TileExtractor extends TilePowerAcceptor
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxInput() {
|
public double getBaseMaxInput() {
|
||||||
return 32;
|
return maxInput;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IToolDrop
|
||||||
|
@Override
|
||||||
|
public ItemStack getToolDrop(final EntityPlayer entityPlayer) {
|
||||||
|
return new ItemStack(ModBlocks.EXTRACTOR, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// IInventoryProvider
|
||||||
@Override
|
@Override
|
||||||
public Inventory getInventory() {
|
public Inventory getInventory() {
|
||||||
return this.inventory;
|
return this.inventory;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
// IContainerProvider
|
||||||
public RecipeCrafter getRecipeCrafter() {
|
|
||||||
return this.crafter;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BuiltContainer createContainer(final EntityPlayer player) {
|
public BuiltContainer createContainer(final EntityPlayer player) {
|
||||||
return new ContainerBuilder("extractor").player(player.inventory).inventory().hotbar().addInventory().tile(this)
|
return new ContainerBuilder("extractor").player(player.inventory).inventory().hotbar().addInventory().tile(this)
|
||||||
|
@ -137,4 +134,9 @@ public class TileExtractor extends TilePowerAcceptor
|
||||||
.addInventory().create(this);
|
.addInventory().create(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IRecipeCrafterProvider
|
||||||
|
@Override
|
||||||
|
public RecipeCrafter getRecipeCrafter() {
|
||||||
|
return this.crafter;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@ import reborncore.api.recipe.IRecipeCrafterProvider;
|
||||||
import reborncore.api.tile.IInventoryProvider;
|
import reborncore.api.tile.IInventoryProvider;
|
||||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||||
import reborncore.common.recipes.RecipeCrafter;
|
import reborncore.common.recipes.RecipeCrafter;
|
||||||
|
import reborncore.common.registration.impl.ConfigRegistry;
|
||||||
import reborncore.common.util.Inventory;
|
import reborncore.common.util.Inventory;
|
||||||
import techreborn.api.Reference;
|
import techreborn.api.Reference;
|
||||||
import techreborn.client.container.IContainerProvider;
|
import techreborn.client.container.IContainerProvider;
|
||||||
|
@ -41,14 +42,16 @@ import techreborn.client.container.builder.ContainerBuilder;
|
||||||
import techreborn.init.ModBlocks;
|
import techreborn.init.ModBlocks;
|
||||||
|
|
||||||
public class TileGrinder extends TilePowerAcceptor
|
public class TileGrinder extends TilePowerAcceptor
|
||||||
implements IToolDrop, IInventoryProvider, IRecipeCrafterProvider, IContainerProvider {
|
implements IToolDrop, IInventoryProvider, IContainerProvider, IRecipeCrafterProvider {
|
||||||
|
|
||||||
|
@ConfigRegistry(config = "machines", category = "grinder", key = "GrinderInput", comment = "Grinder Max Input (Value in EU)")
|
||||||
|
public static int maxInput = 32;
|
||||||
|
@ConfigRegistry(config = "machines", category = "grinder", key = "GrinderMaxEnergy", comment = "Grinder Max Energy (Value in EU)")
|
||||||
|
public static int maxEnergy = 1000;
|
||||||
|
|
||||||
public Inventory inventory = new Inventory(3, "TileGrinder", 64, this);
|
public Inventory inventory = new Inventory(3, "TileGrinder", 64, this);
|
||||||
|
|
||||||
public RecipeCrafter crafter;
|
public RecipeCrafter crafter;
|
||||||
|
|
||||||
public int capacity = 1000;
|
|
||||||
|
|
||||||
public TileGrinder() {
|
public TileGrinder() {
|
||||||
super();
|
super();
|
||||||
final int[] inputs = new int[1];
|
final int[] inputs = new int[1];
|
||||||
|
@ -58,6 +61,14 @@ public class TileGrinder extends TilePowerAcceptor
|
||||||
this.crafter = new RecipeCrafter(Reference.GRINDER_RECIPE, this, 2, 1, this.inventory, inputs, outputs);
|
this.crafter = new RecipeCrafter(Reference.GRINDER_RECIPE, this, 2, 1, this.inventory, inputs, outputs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getProgressScaled(final int scale) {
|
||||||
|
if (this.crafter.currentTickTime != 0 && this.crafter.currentNeededTicks != 0) {
|
||||||
|
return this.crafter.currentTickTime * scale / this.crafter.currentNeededTicks;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TilePowerAcceptor
|
||||||
@Override
|
@Override
|
||||||
public void update() {
|
public void update() {
|
||||||
if (!this.world.isRemote) {
|
if (!this.world.isRemote) {
|
||||||
|
@ -66,15 +77,6 @@ public class TileGrinder extends TilePowerAcceptor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ItemStack getToolDrop(final EntityPlayer entityPlayer) {
|
|
||||||
return new ItemStack(ModBlocks.GRINDER, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isComplete() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readFromNBT(final NBTTagCompound tagCompound) {
|
public void readFromNBT(final NBTTagCompound tagCompound) {
|
||||||
super.readFromNBT(tagCompound);
|
super.readFromNBT(tagCompound);
|
||||||
|
@ -89,16 +91,9 @@ public class TileGrinder extends TilePowerAcceptor
|
||||||
return tagCompound;
|
return tagCompound;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getProgressScaled(final int scale) {
|
|
||||||
if (this.crafter.currentTickTime != 0 && this.crafter.currentNeededTicks != 0) {
|
|
||||||
return this.crafter.currentTickTime * scale / this.crafter.currentNeededTicks;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxPower() {
|
public double getBaseMaxPower() {
|
||||||
return this.capacity;
|
return maxEnergy;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -118,19 +113,22 @@ public class TileGrinder extends TilePowerAcceptor
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxInput() {
|
public double getBaseMaxInput() {
|
||||||
return 32;
|
return maxInput;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IToolDrop
|
||||||
|
@Override
|
||||||
|
public ItemStack getToolDrop(final EntityPlayer entityPlayer) {
|
||||||
|
return new ItemStack(ModBlocks.GRINDER, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// IInventoryProvider
|
||||||
@Override
|
@Override
|
||||||
public Inventory getInventory() {
|
public Inventory getInventory() {
|
||||||
return this.inventory;
|
return this.inventory;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
// IContainerProvider
|
||||||
public RecipeCrafter getRecipeCrafter() {
|
|
||||||
return this.crafter;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BuiltContainer createContainer(final EntityPlayer player) {
|
public BuiltContainer createContainer(final EntityPlayer player) {
|
||||||
return new ContainerBuilder("grinder").player(player.inventory).inventory().hotbar().addInventory().tile(this)
|
return new ContainerBuilder("grinder").player(player.inventory).inventory().hotbar().addInventory().tile(this)
|
||||||
|
@ -138,8 +136,9 @@ public class TileGrinder extends TilePowerAcceptor
|
||||||
.addInventory().create(this);
|
.addInventory().create(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IRecipeCrafterProvider
|
||||||
@Override
|
@Override
|
||||||
public boolean canBeUpgraded() {
|
public RecipeCrafter getRecipeCrafter() {
|
||||||
return true;
|
return this.crafter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue