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.common.powerSystem.TilePowerAcceptor;
|
||||
import reborncore.common.recipes.RecipeCrafter;
|
||||
import reborncore.common.registration.impl.ConfigRegistry;
|
||||
import reborncore.common.util.Inventory;
|
||||
import techreborn.api.Reference;
|
||||
import techreborn.client.container.IContainerProvider;
|
||||
|
@ -39,22 +40,32 @@ import techreborn.client.container.builder.BuiltContainer;
|
|||
import techreborn.client.container.builder.ContainerBuilder;
|
||||
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 RecipeCrafter crafter;
|
||||
|
||||
public int capacity = 1000;
|
||||
|
||||
public TileCompressor() {
|
||||
super();
|
||||
final int[] inputs = new int[] { 0 };
|
||||
final int[] outputs = new int[] { 1 };
|
||||
this.crafter = new RecipeCrafter(Reference.COMPRESSOR_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;
|
||||
}
|
||||
|
||||
// TilePowerAcceptor
|
||||
@Override
|
||||
public void update() {
|
||||
if (!this.world.isRemote) {
|
||||
|
@ -63,25 +74,9 @@ public class TileCompressor extends TilePowerAcceptor implements IToolDrop, IInv
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getToolDrop(final EntityPlayer entityPlayer) {
|
||||
return new ItemStack(ModBlocks.COMPRESSOR, 1);
|
||||
}
|
||||
|
||||
public boolean isComplete() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getProgressScaled(final int scale) {
|
||||
if (this.crafter.currentTickTime != 0) {
|
||||
return this.crafter.currentTickTime * scale / this.crafter.currentNeededTicks;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBaseMaxPower() {
|
||||
return this.capacity;
|
||||
return maxEnergy;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -101,23 +96,32 @@ public class TileCompressor extends TilePowerAcceptor implements IToolDrop, IInv
|
|||
|
||||
@Override
|
||||
public double getBaseMaxInput() {
|
||||
return 32;
|
||||
return maxInput;
|
||||
}
|
||||
|
||||
|
||||
// IToolDrop
|
||||
@Override
|
||||
public ItemStack getToolDrop(final EntityPlayer entityPlayer) {
|
||||
return new ItemStack(ModBlocks.COMPRESSOR, 1);
|
||||
}
|
||||
|
||||
// IInventoryProvider
|
||||
@Override
|
||||
public Inventory getInventory() {
|
||||
return this.inventory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecipeCrafter getRecipeCrafter() {
|
||||
return this.crafter;
|
||||
}
|
||||
|
||||
// IContainerProvider
|
||||
@Override
|
||||
public BuiltContainer createContainer(final EntityPlayer player) {
|
||||
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()
|
||||
.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.common.blocks.BlockMachineBase;
|
||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||
import reborncore.common.registration.impl.ConfigRegistry;
|
||||
import reborncore.common.util.Inventory;
|
||||
import techreborn.client.container.IContainerProvider;
|
||||
import techreborn.client.container.builder.BuiltContainer;
|
||||
|
@ -40,10 +41,14 @@ import techreborn.client.container.builder.ContainerBuilder;
|
|||
import techreborn.init.ModBlocks;
|
||||
|
||||
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 int capacity = 1000;
|
||||
public int progress;
|
||||
public int fuelScale = 100;
|
||||
public int cost = 6;
|
||||
|
@ -59,39 +64,6 @@ public class TileElectricFurnace extends TilePowerAcceptor
|
|||
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() {
|
||||
if (this.canSmelt()) {
|
||||
final ItemStack itemstack = FurnaceRecipes.instance().getSmeltingResult(this.getStackInSlot(this.input1));
|
||||
|
@ -137,9 +109,10 @@ public class TileElectricFurnace extends TilePowerAcceptor
|
|||
}
|
||||
|
||||
public void updateState() {
|
||||
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
|
||||
if(wasBurning && this.progress == 0 && canSmelt()){
|
||||
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
|
||||
if (wasBurning && this.progress == 0 && canSmelt()) {
|
||||
wasBurning = true;
|
||||
return;
|
||||
}
|
||||
|
@ -154,23 +127,53 @@ public class TileElectricFurnace extends TilePowerAcceptor
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumFacing getFacing() {
|
||||
return this.getFacingEnum();
|
||||
public int getBurnTime() {
|
||||
return this.progress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getToolDrop(final EntityPlayer entityPlayer) {
|
||||
return new ItemStack(ModBlocks.ELECTRIC_FURNACE, 1);
|
||||
public void setBurnTime(final int burnTime) {
|
||||
this.progress = burnTime;
|
||||
}
|
||||
|
||||
public boolean isComplete() {
|
||||
return false;
|
||||
// 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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBaseMaxPower() {
|
||||
return this.capacity;
|
||||
return maxEnergy;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -190,31 +193,26 @@ public class TileElectricFurnace extends TilePowerAcceptor
|
|||
|
||||
@Override
|
||||
public double getBaseMaxInput() {
|
||||
return 32;
|
||||
return maxInput;
|
||||
}
|
||||
|
||||
// IToolDrop
|
||||
@Override
|
||||
public ItemStack getToolDrop(final EntityPlayer entityPlayer) {
|
||||
return new ItemStack(ModBlocks.ELECTRIC_FURNACE, 1);
|
||||
}
|
||||
|
||||
// IInventoryProvider
|
||||
@Override
|
||||
public Inventory getInventory() {
|
||||
return this.inventory;
|
||||
}
|
||||
|
||||
public int getBurnTime() {
|
||||
return this.progress;
|
||||
}
|
||||
|
||||
public void setBurnTime(final int burnTime) {
|
||||
this.progress = burnTime;
|
||||
}
|
||||
|
||||
// IContainerProvider
|
||||
@Override
|
||||
public BuiltContainer createContainer(final EntityPlayer player) {
|
||||
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()
|
||||
.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.common.powerSystem.TilePowerAcceptor;
|
||||
import reborncore.common.recipes.RecipeCrafter;
|
||||
import reborncore.common.registration.impl.ConfigRegistry;
|
||||
import reborncore.common.util.Inventory;
|
||||
import techreborn.api.Reference;
|
||||
import techreborn.client.container.IContainerProvider;
|
||||
|
@ -41,14 +42,16 @@ import techreborn.client.container.builder.ContainerBuilder;
|
|||
import techreborn.init.ModBlocks;
|
||||
|
||||
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 RecipeCrafter crafter;
|
||||
|
||||
public int capacity = 1000;
|
||||
|
||||
public TileExtractor() {
|
||||
super();
|
||||
final int[] inputs = new int[1];
|
||||
|
@ -57,6 +60,13 @@ public class TileExtractor extends TilePowerAcceptor
|
|||
outputs[0] = 1;
|
||||
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
|
||||
public void update() {
|
||||
|
@ -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
|
||||
public void readFromNBT(final NBTTagCompound tagCompound) {
|
||||
super.readFromNBT(tagCompound);
|
||||
|
@ -88,16 +89,9 @@ public class TileExtractor extends TilePowerAcceptor
|
|||
return tagCompound;
|
||||
}
|
||||
|
||||
public int getProgressScaled(final int scale) {
|
||||
if (this.crafter.currentTickTime != 0) {
|
||||
return this.crafter.currentTickTime * scale / this.crafter.currentNeededTicks;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBaseMaxPower() {
|
||||
return this.capacity;
|
||||
return maxEnergy;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -117,24 +111,32 @@ public class TileExtractor extends TilePowerAcceptor
|
|||
|
||||
@Override
|
||||
public double getBaseMaxInput() {
|
||||
return 32;
|
||||
return maxInput;
|
||||
}
|
||||
|
||||
// IToolDrop
|
||||
@Override
|
||||
public ItemStack getToolDrop(final EntityPlayer entityPlayer) {
|
||||
return new ItemStack(ModBlocks.EXTRACTOR, 1);
|
||||
}
|
||||
|
||||
// IInventoryProvider
|
||||
@Override
|
||||
public Inventory getInventory() {
|
||||
return this.inventory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecipeCrafter getRecipeCrafter() {
|
||||
return this.crafter;
|
||||
}
|
||||
|
||||
// IContainerProvider
|
||||
@Override
|
||||
public BuiltContainer createContainer(final EntityPlayer player) {
|
||||
return new ContainerBuilder("extractor").player(player.inventory).inventory().hotbar().addInventory().tile(this)
|
||||
.slot(0, 55, 45).outputSlot(1, 101, 45).energySlot(2, 8, 72).syncEnergyValue().syncCrafterValue()
|
||||
.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.common.powerSystem.TilePowerAcceptor;
|
||||
import reborncore.common.recipes.RecipeCrafter;
|
||||
import reborncore.common.registration.impl.ConfigRegistry;
|
||||
import reborncore.common.util.Inventory;
|
||||
import techreborn.api.Reference;
|
||||
import techreborn.client.container.IContainerProvider;
|
||||
|
@ -41,14 +42,16 @@ import techreborn.client.container.builder.ContainerBuilder;
|
|||
import techreborn.init.ModBlocks;
|
||||
|
||||
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 RecipeCrafter crafter;
|
||||
|
||||
public int capacity = 1000;
|
||||
|
||||
public TileGrinder() {
|
||||
super();
|
||||
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);
|
||||
}
|
||||
|
||||
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
|
||||
public void update() {
|
||||
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
|
||||
public void readFromNBT(final NBTTagCompound tagCompound) {
|
||||
super.readFromNBT(tagCompound);
|
||||
|
@ -89,16 +91,9 @@ public class TileGrinder extends TilePowerAcceptor
|
|||
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
|
||||
public double getBaseMaxPower() {
|
||||
return this.capacity;
|
||||
return maxEnergy;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -118,19 +113,22 @@ public class TileGrinder extends TilePowerAcceptor
|
|||
|
||||
@Override
|
||||
public double getBaseMaxInput() {
|
||||
return 32;
|
||||
return maxInput;
|
||||
}
|
||||
|
||||
// IToolDrop
|
||||
@Override
|
||||
public ItemStack getToolDrop(final EntityPlayer entityPlayer) {
|
||||
return new ItemStack(ModBlocks.GRINDER, 1);
|
||||
}
|
||||
|
||||
// IInventoryProvider
|
||||
@Override
|
||||
public Inventory getInventory() {
|
||||
return this.inventory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecipeCrafter getRecipeCrafter() {
|
||||
return this.crafter;
|
||||
}
|
||||
|
||||
// IContainerProvider
|
||||
@Override
|
||||
public BuiltContainer createContainer(final EntityPlayer player) {
|
||||
return new ContainerBuilder("grinder").player(player.inventory).inventory().hotbar().addInventory().tile(this)
|
||||
|
@ -138,8 +136,9 @@ public class TileGrinder extends TilePowerAcceptor
|
|||
.addInventory().create(this);
|
||||
}
|
||||
|
||||
// IRecipeCrafterProvider
|
||||
@Override
|
||||
public boolean canBeUpgraded() {
|
||||
return true;
|
||||
public RecipeCrafter getRecipeCrafter() {
|
||||
return this.crafter;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue