Refactoring for multi-block machines.

This commit is contained in:
drcrazy 2018-04-02 17:50:15 +03:00
parent 54ee781bc7
commit adc4879ec5
6 changed files with 59 additions and 412 deletions

View file

@ -27,14 +27,7 @@ package techreborn.tiles.multiblock;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import reborncore.api.IToolDrop;
import reborncore.api.recipe.IRecipeCrafterProvider;
import reborncore.api.tile.IInventoryProvider;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.recipes.RecipeCrafter;
import reborncore.common.registration.RebornRegistry;
import reborncore.common.registration.impl.ConfigRegistry;
@ -45,24 +38,23 @@ import techreborn.client.container.builder.BuiltContainer;
import techreborn.client.container.builder.ContainerBuilder;
import techreborn.init.ModBlocks;
import techreborn.lib.ModInfo;
import techreborn.tiles.TileGenericMachine;
@RebornRegistry(modID = ModInfo.MOD_ID)
public class TileDistillationTower extends TilePowerAcceptor
implements IToolDrop, IRecipeCrafterProvider, IInventoryProvider, IContainerProvider {
public class TileDistillationTower extends TileGenericMachine implements IContainerProvider {
@ConfigRegistry(config = "machines", category = "distillation_tower", key = "DistillationTowerMaxInput", comment = "Distillation Tower Max Input (Value in EU)")
public static int maxInput = 128;
@ConfigRegistry(config = "machines", category = "distillation_tower", key = "DistillationTowerMaxEnergy", comment = "Distillation Tower Max Energy (Value in EU)")
public static int maxEnergy = 10000;
public static int maxEnergy = 10_000;
public Inventory inventory = new Inventory(11, "TileDistillationTower", 64, this);
public MultiblockChecker multiblockChecker;
public RecipeCrafter crafter;
public TileDistillationTower() {
super();
super("DistillationTower", maxInput, maxEnergy, ModBlocks.DISTILLATION_TOWER, 6);
final int[] inputs = new int[] { 0, 1 };
final int[] outputs = new int[] { 2, 3, 4, 5 };
this.inventory = new Inventory(7, "TileDistillationTower", 64, this);
this.crafter = new RecipeCrafter(Reference.DISTILLATION_TOWER_RECIPE, this, 2, 4, this.inventory, inputs, outputs);
}
@ -81,13 +73,7 @@ public class TileDistillationTower extends TilePowerAcceptor
return layer0 && layer1 && layer2 && layer3 && center1 && center2;
}
public int getProgressScaled(final int scale) {
if (this.crafter.currentTickTime != 0) {
return this.crafter.currentTickTime * scale / this.crafter.currentNeededTicks;
}
return 0;
}
// TileGenericMachine
@Override
public void update() {
if (this.multiblockChecker == null) {
@ -95,57 +81,11 @@ public class TileDistillationTower extends TilePowerAcceptor
this.multiblockChecker = new MultiblockChecker(this.world, pos);
}
if (world.isRemote){ return; }
if (this.getMutliBlock()) {
if (!world.isRemote && getMutliBlock()){
super.update();
this.charge(6);
}
}
@Override
public boolean canAcceptEnergy(EnumFacing direction) {
return true;
}
@Override
public boolean canProvideEnergy(EnumFacing direction) {
return false;
}
@Override
public double getBaseMaxPower() {
return maxEnergy;
}
@Override
public double getBaseMaxOutput() {
return 0;
}
@Override
public double getBaseMaxInput() {
return maxInput;
}
// IToolDrop
@Override
public ItemStack getToolDrop(EntityPlayer p0) {
return new ItemStack(ModBlocks.DISTILLATION_TOWER, 1);
}
// IRecipeCrafterProvider
@Override
public RecipeCrafter getRecipeCrafter() {
return this.crafter;
}
// IInventoryProvider
@Override
public IInventory getInventory() {
return this.inventory;
}
// IContainerProvider
@Override
public BuiltContainer createContainer(final EntityPlayer player) {
@ -154,5 +94,4 @@ public class TileDistillationTower extends TilePowerAcceptor
.outputSlot(4, 119, 37).outputSlot(5, 139, 37).energySlot(6, 8, 72).syncEnergyValue().syncCrafterValue()
.addInventory().create(this);
}
}

View file

@ -25,13 +25,7 @@
package techreborn.tiles.multiblock;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import reborncore.api.IToolDrop;
import reborncore.api.recipe.IRecipeCrafterProvider;
import reborncore.api.tile.IInventoryProvider;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.recipes.RecipeCrafter;
import reborncore.common.registration.RebornRegistry;
import reborncore.common.registration.impl.ConfigRegistry;
@ -42,34 +36,26 @@ import techreborn.client.container.builder.BuiltContainer;
import techreborn.client.container.builder.ContainerBuilder;
import techreborn.init.ModBlocks;
import techreborn.lib.ModInfo;
import techreborn.tiles.TileGenericMachine;
@RebornRegistry(modID = ModInfo.MOD_ID)
public class TileImplosionCompressor extends TilePowerAcceptor
implements IToolDrop, IInventoryProvider, IContainerProvider, IRecipeCrafterProvider {
public class TileImplosionCompressor extends TileGenericMachine implements IContainerProvider {
@ConfigRegistry(config = "machines", category = "implosion_compressor", key = "ImplosionCompressorMaxInput", comment = "Implosion Compressor Max Input (Value in EU)")
public static int maxInput = 64;
@ConfigRegistry(config = "machines", category = "implosion_compressor", key = "ImplosionCompressorMaxEnergy", comment = "Implosion Compressor Max Energy (Value in EU)")
public static int maxEnergy = 64_000;
public Inventory inventory = new Inventory(5, "TileImplosionCompressor", 64, this);
public RecipeCrafter crafter;
public MultiblockChecker multiblockChecker;
public TileImplosionCompressor() {
super();
super("ImplosionCompressor", maxInput, maxEnergy, ModBlocks.IMPLOSION_COMPRESSOR, 4);
final int[] inputs = new int[] { 0, 1 };
final int[] outputs = new int[] { 2, 3 };
this.inventory = new Inventory(5, "TileImplosionCompressor", 64, this);
this.crafter = new RecipeCrafter(Reference.IMPLOSION_COMPRESSOR_RECIPE, this, 2, 2, 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;
}
public boolean getMutliBlock() {
final boolean down = this.multiblockChecker.checkRectY(1, 1, MultiblockChecker.REINFORCED_CASING, MultiblockChecker.ZERO_OFFSET);
final boolean up = this.multiblockChecker.checkRectY(1, 1, MultiblockChecker.REINFORCED_CASING, new BlockPos(0, 2, 0));
@ -77,41 +63,19 @@ public class TileImplosionCompressor extends TilePowerAcceptor
return down && chamber && up;
}
// TilePowerAcceptor
// TileGenericMachine
@Override
public void update() {
if (this.world.isRemote) { return; }
if (this.getMutliBlock()) {
if (this.multiblockChecker == null) {
final BlockPos pos = this.getPos().offset(this.getFacing().getOpposite(), 2);
this.multiblockChecker = new MultiblockChecker(this.world, pos);
}
if (!world.isRemote && getMutliBlock()){
super.update();
this.charge(4);
}
}
@Override
public double getBaseMaxPower() {
return maxEnergy;
}
@Override
public boolean canAcceptEnergy(final EnumFacing direction) {
return true;
}
@Override
public boolean canProvideEnergy(final EnumFacing direction) {
return false;
}
@Override
public double getBaseMaxOutput() {
return 0;
}
@Override
public double getBaseMaxInput() {
return maxInput;
}
// TileEntity
@Override
public void validate() {
@ -119,18 +83,6 @@ public class TileImplosionCompressor extends TilePowerAcceptor
this.multiblockChecker = new MultiblockChecker(this.world, this.getPos().down(3));
}
// IToolDrop
@Override
public ItemStack getToolDrop(final EntityPlayer entityPlayer) {
return new ItemStack(ModBlocks.IMPLOSION_COMPRESSOR, 1);
}
// IInventoryProvider
@Override
public Inventory getInventory() {
return this.inventory;
}
// IContainerProvider
@Override
public BuiltContainer createContainer(final EntityPlayer player) {
@ -138,10 +90,4 @@ public class TileImplosionCompressor extends TilePowerAcceptor
.tile(this).slot(0, 50, 27).slot(1, 50, 47).outputSlot(2, 92, 36).outputSlot(3, 110, 36)
.energySlot(4, 8, 72).syncEnergyValue().syncCrafterValue().addInventory().create(this);
}
// IRecipeCrafterProvider
@Override
public RecipeCrafter getRecipeCrafter() {
return this.crafter;
}
}

View file

@ -27,17 +27,12 @@ package techreborn.tiles.multiblock;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.play.server.SPacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import reborncore.api.IToolDrop;
import reborncore.api.recipe.IRecipeCrafterProvider;
import reborncore.api.tile.IInventoryProvider;
import reborncore.common.multiblock.IMultiblockPart;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.recipes.RecipeCrafter;
import reborncore.common.registration.RebornRegistry;
import reborncore.common.registration.impl.ConfigRegistry;
@ -52,27 +47,25 @@ import techreborn.client.container.builder.ContainerBuilder;
import techreborn.init.ModBlocks;
import techreborn.lib.ModInfo;
import techreborn.multiblocks.MultiBlockCasing;
import techreborn.tiles.TileGenericMachine;
import techreborn.tiles.TileMachineCasing;
@RebornRegistry(modID = ModInfo.MOD_ID)
public class TileIndustrialBlastFurnace extends TilePowerAcceptor
implements IToolDrop, IInventoryProvider, IContainerProvider, IRecipeCrafterProvider, ITileRecipeHandler<BlastFurnaceRecipe> {
public class TileIndustrialBlastFurnace extends TileGenericMachine implements IContainerProvider, ITileRecipeHandler<BlastFurnaceRecipe> {
@ConfigRegistry(config = "machines", category = "industrial_furnace", key = "IndustrialFurnaceMaxInput", comment = "Industrial Blast Furnace Max Input (Value in EU)")
public static int maxInput = 128;
@ConfigRegistry(config = "machines", category = "industrial_furnace", key = "IndustrialFurnaceMaxEnergy", comment = "Industrial Blast Furnace Max Energy (Value in EU)")
public static int maxEnergy = 10_000;
public Inventory inventory;
public RecipeCrafter crafter;
public MultiblockChecker multiblockChecker;
private int cachedHeat;
public TileIndustrialBlastFurnace() {
super();
this.inventory = new Inventory(5, "TileIndustrialBlastFurnace", 64, this);
super("IndustrialBlastFurnace", maxInput, maxEnergy, ModBlocks.INDUSTRIAL_BLAST_FURNACE, 4);
final int[] inputs = new int[] { 0, 1 };
final int[] outputs = new int[] { 2, 3 };
this.inventory = new Inventory(5, "TileIndustrialBlastFurnace", 64, this);
this.crafter = new RecipeCrafter(Reference.BLAST_FURNACE_RECIPE, this, 2, 2, this.inventory, inputs, outputs);
}
@ -102,7 +95,6 @@ public class TileIndustrialBlastFurnace extends TilePowerAcceptor
final BlockMachineCasing casing1 = (BlockMachineCasing) this.world.getBlockState(part.getPos())
.getBlock();
heat += casing1.getHeatFromState(this.world.getBlockState(part.getPos()));
// TODO meta fix
}
if (this.world.getBlockState(location.offset(EnumFacing.UP, 1)).getBlock().getUnlocalizedName()
@ -130,13 +122,6 @@ public class TileIndustrialBlastFurnace extends TilePowerAcceptor
return layer0 && layer1 && layer2 && layer3 && center1 && center2;
}
public int getProgressScaled(final int scale) {
if (this.crafter.currentTickTime != 0) {
return this.crafter.currentTickTime * scale / this.crafter.currentNeededTicks;
}
return 0;
}
public void setHeat(final int heat) {
this.cachedHeat = heat;
}
@ -145,47 +130,19 @@ public class TileIndustrialBlastFurnace extends TilePowerAcceptor
return this.cachedHeat;
}
// TilePowerAcceptor
// TileGenericMachine
@Override
public void update() {
if (world.isRemote){ return; }
if (this.multiblockChecker == null) {
final BlockPos pos = this.getPos().offset(this.getFacing().getOpposite(), 2);
this.multiblockChecker = new MultiblockChecker(this.world, pos);
}
if (this.getMutliBlock()) {
if (!world.isRemote && getMutliBlock()){
super.update();
this.charge(4);
}
}
@Override
public double getBaseMaxPower() {
return maxEnergy;
}
@Override
public boolean canAcceptEnergy(final EnumFacing direction) {
return true;
}
@Override
public boolean canProvideEnergy(final EnumFacing direction) {
return false;
}
@Override
public double getBaseMaxOutput() {
return 0;
}
@Override
public double getBaseMaxInput() {
return maxInput;
}
// TileLegacyMachineBase
@Override
public void onDataPacket(final NetworkManager net, final SPacketUpdateTileEntity packet) {
@ -194,18 +151,6 @@ public class TileIndustrialBlastFurnace extends TilePowerAcceptor
this.readFromNBT(packet.getNbtCompound());
}
// IToolDrop
@Override
public ItemStack getToolDrop(final EntityPlayer entityPlayer) {
return new ItemStack(ModBlocks.INDUSTRIAL_BLAST_FURNACE, 1);
}
// IInventoryProvider
@Override
public Inventory getInventory() {
return this.inventory;
}
// IContainerProvider
@Override
public BuiltContainer createContainer(final EntityPlayer player) {
@ -215,12 +160,6 @@ public class TileIndustrialBlastFurnace extends TilePowerAcceptor
.syncIntegerValue(this::getHeat, this::setHeat).addInventory().create(this);
}
// IRecipeCrafterProvider
@Override
public RecipeCrafter getRecipeCrafter() {
return this.crafter;
}
// ITileRecipeHandler
@Override
public boolean canCraft(final TileEntity tile, final BlastFurnaceRecipe recipe) {

View file

@ -37,10 +37,6 @@ import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidBlock;
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
import reborncore.api.IToolDrop;
import reborncore.api.recipe.IRecipeCrafterProvider;
import reborncore.api.tile.IInventoryProvider;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.recipes.RecipeCrafter;
import reborncore.common.registration.RebornRegistry;
import reborncore.common.registration.impl.ConfigRegistry;
@ -55,32 +51,29 @@ import techreborn.client.container.builder.BuiltContainer;
import techreborn.client.container.builder.ContainerBuilder;
import techreborn.init.ModBlocks;
import techreborn.lib.ModInfo;
import techreborn.tiles.TileGenericMachine;
@RebornRegistry(modID = ModInfo.MOD_ID)
public class TileIndustrialGrinder extends TilePowerAcceptor
implements IToolDrop, IInventoryProvider, IContainerProvider, IRecipeCrafterProvider, ITileRecipeHandler<IndustrialGrinderRecipe> {
public class TileIndustrialGrinder extends TileGenericMachine implements IContainerProvider, ITileRecipeHandler<IndustrialGrinderRecipe> {
@ConfigRegistry(config = "machines", category = "industrial_grinder", key = "IndustrialGrinderMaxInput", comment = "Industrial Grinder Max Input (Value in EU)")
public static int maxInput = 128;
@ConfigRegistry(config = "machines", category = "industrial_grinder", key = "IndustrialGrinderMaxEnergy", comment = "Industrial Grinder Max Energy (Value in EU)")
public static int maxEnergy = 10_000;
public static final int TANK_CAPACITY = 16000;
public Inventory inventory;
public static final int TANK_CAPACITY = 16_000;
public Tank tank;
public RecipeCrafter crafter;
public MultiblockChecker multiblockChecker;
int ticksSinceLastChange;
public TileIndustrialGrinder() {
super();
this.tank = new Tank("TileIndustrialGrinder", TileIndustrialGrinder.TANK_CAPACITY, this);
this.inventory = new Inventory(8, "TileIndustrialGrinder", 64, this);
this.ticksSinceLastChange = 0;
super("IndustrialGrinder", maxInput, maxEnergy, ModBlocks.INDUSTRIAL_GRINDER, 7);
final int[] inputs = new int[] { 0, 1 };
final int[] outputs = new int[] {2, 3, 4, 5};
this.crafter = new RecipeCrafter(Reference.INDUSTRIAL_GRINDER_RECIPE, this, 1, 4, this.inventory, inputs,
outputs);
this.inventory = new Inventory(8, "TileIndustrialGrinder", 64, this);
this.crafter = new RecipeCrafter(Reference.INDUSTRIAL_GRINDER_RECIPE, this, 1, 4, this.inventory, inputs, outputs);
this.tank = new Tank("TileIndustrialGrinder", TileIndustrialGrinder.TANK_CAPACITY, this);
this.ticksSinceLastChange = 0;
}
public boolean getMutliBlock() {
@ -99,17 +92,9 @@ public class TileIndustrialGrinder extends TilePowerAcceptor
return down && center && blade && up;
}
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() {
super.update();
if (this.multiblockChecker == null) {
final BlockPos pos = this.getPos().offset(this.getFacing().getOpposite(), 2).down();
this.multiblockChecker = new MultiblockChecker(this.world, pos);
@ -125,38 +110,13 @@ public class TileIndustrialGrinder extends TilePowerAcceptor
this.ticksSinceLastChange = 0;
}
if (!world.isRemote && this.getMutliBlock()) {
this.charge(7);
if (!world.isRemote && getMutliBlock()) {
super.update();
}
tank.compareAndUpdate();
}
@Override
public double getBaseMaxPower() {
return maxEnergy;
}
@Override
public boolean canAcceptEnergy(final EnumFacing direction) {
return true;
}
@Override
public boolean canProvideEnergy(final EnumFacing direction) {
return false;
}
@Override
public double getBaseMaxOutput() {
return 0;
}
@Override
public double getBaseMaxInput() {
return maxInput;
}
@Override
public void readFromNBT(final NBTTagCompound tagCompound) {
super.readFromNBT(tagCompound);
@ -201,18 +161,6 @@ public class TileIndustrialGrinder extends TilePowerAcceptor
return true;
}
// IToolDrop
@Override
public ItemStack getToolDrop(final EntityPlayer entityPlayer) {
return new ItemStack(ModBlocks.INDUSTRIAL_GRINDER, 1);
}
// IInventoryProvider
@Override
public Inventory getInventory() {
return this.inventory;
}
// IContainerProvider
@Override
public BuiltContainer createContainer(final EntityPlayer player) {
@ -223,12 +171,6 @@ public class TileIndustrialGrinder extends TilePowerAcceptor
.syncEnergyValue().syncCrafterValue().addInventory().create(this);
}
// IRecipeCrafterProvider
@Override
public RecipeCrafter getRecipeCrafter() {
return this.crafter;
}
// ITileRecipeHandler
@Override
public boolean canCraft(final TileEntity tile, final IndustrialGrinderRecipe recipe) {

View file

@ -37,10 +37,6 @@ import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidBlock;
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
import reborncore.api.IToolDrop;
import reborncore.api.recipe.IRecipeCrafterProvider;
import reborncore.api.tile.IInventoryProvider;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.recipes.RecipeCrafter;
import reborncore.common.registration.RebornRegistry;
import reborncore.common.registration.impl.ConfigRegistry;
@ -55,32 +51,29 @@ import techreborn.client.container.builder.BuiltContainer;
import techreborn.client.container.builder.ContainerBuilder;
import techreborn.init.ModBlocks;
import techreborn.lib.ModInfo;
import techreborn.tiles.TileGenericMachine;
@RebornRegistry(modID = ModInfo.MOD_ID)
public class TileIndustrialSawmill extends TilePowerAcceptor
implements IToolDrop, IInventoryProvider, IContainerProvider, IRecipeCrafterProvider, ITileRecipeHandler<IndustrialSawmillRecipe> {
public class TileIndustrialSawmill extends TileGenericMachine implements IContainerProvider, ITileRecipeHandler<IndustrialSawmillRecipe> {
@ConfigRegistry(config = "machines", category = "industrial_sawmill", key = "IndustrialSawmillMaxInput", comment = "Industrial Sawmill Max Input (Value in EU)")
public static int maxInput = 128;
@ConfigRegistry(config = "machines", category = "industrial_sawmill", key = "IndustrialSawmillMaxEnergy", comment = "Industrial Sawmill Max Energy (Value in EU)")
public static int maxEnergy = 10_000;
public static final int TANK_CAPACITY = 16000;
public Inventory inventory;
public static final int TANK_CAPACITY = 16_000;
public Tank tank;
public RecipeCrafter crafter;
public MultiblockChecker multiblockChecker;
int ticksSinceLastChange;
public TileIndustrialSawmill() {
super();
this.tank = new Tank("TileSawmill", TileIndustrialSawmill.TANK_CAPACITY, this);
this.inventory = new Inventory(7, "TileSawmill", 64, this);
this.ticksSinceLastChange = 0;
super("IndustrialSawmill", maxInput, maxEnergy, ModBlocks.INDUSTRIAL_SAWMILL, 6);
final int[] inputs = new int[] { 0, 1 };
final int[] outputs = new int[] { 2, 3, 4 };
this.crafter = new RecipeCrafter(Reference.INDUSTRIAL_SAWMILL_RECIPE, this, 1, 3, this.inventory, inputs,
outputs);
this.inventory = new Inventory(7, "TileSawmill", 64, this);
this.crafter = new RecipeCrafter(Reference.INDUSTRIAL_SAWMILL_RECIPE, this, 1, 3, this.inventory, inputs, outputs);
this.tank = new Tank("TileSawmill", TileIndustrialSawmill.TANK_CAPACITY, this);
this.ticksSinceLastChange = 0;
}
public boolean getMutliBlock() {
@ -99,17 +92,9 @@ public class TileIndustrialSawmill extends TilePowerAcceptor
return down && center && blade && up;
}
public int getProgressScaled(final int scale) {
if (this.crafter.currentTickTime != 0) {
return this.crafter.currentTickTime * scale / this.crafter.currentNeededTicks;
}
return 0;
}
// TilePowerAcceptor
// TileGenericMachine
@Override
public void update() {
super.update();
if (this.multiblockChecker == null) {
final BlockPos pos = this.getPos().offset(this.getFacing().getOpposite(), 2).down();
this.multiblockChecker = new MultiblockChecker(this.world, pos);
@ -125,38 +110,13 @@ public class TileIndustrialSawmill extends TilePowerAcceptor
this.ticksSinceLastChange = 0;
}
if (!world.isRemote && this.getMutliBlock()) {
this.charge(6);
if (!world.isRemote && getMutliBlock()) {
super.update();
}
tank.compareAndUpdate();
}
@Override
public double getBaseMaxPower() {
return maxEnergy;
}
@Override
public boolean canAcceptEnergy(final EnumFacing direction) {
return true;
}
@Override
public boolean canProvideEnergy(final EnumFacing direction) {
return false;
}
@Override
public double getBaseMaxOutput() {
return 0;
}
@Override
public double getBaseMaxInput() {
return maxInput;
}
@Override
public void readFromNBT(final NBTTagCompound tagCompound) {
super.readFromNBT(tagCompound);
@ -202,18 +162,6 @@ public class TileIndustrialSawmill extends TilePowerAcceptor
return true;
}
// IToolDrop
@Override
public ItemStack getToolDrop(final EntityPlayer entityPlayer) {
return new ItemStack(ModBlocks.INDUSTRIAL_SAWMILL, 1);
}
// IInventoryProvider
@Override
public Inventory getInventory() {
return this.inventory;
}
// IContainerProvider
@Override
public BuiltContainer createContainer(final EntityPlayer player) {
@ -223,12 +171,6 @@ public class TileIndustrialSawmill extends TilePowerAcceptor
.addInventory().create(this);
}
// IRecipeCrafterProvider
@Override
public RecipeCrafter getRecipeCrafter() {
return this.crafter;
}
// ITileRecipeHandler
@Override
public boolean canCraft(TileEntity tile, IndustrialSawmillRecipe recipe) {

View file

@ -25,12 +25,6 @@
package techreborn.tiles.multiblock;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import reborncore.api.IToolDrop;
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;
@ -39,24 +33,22 @@ import techreborn.client.container.IContainerProvider;
import techreborn.client.container.builder.BuiltContainer;
import techreborn.client.container.builder.ContainerBuilder;
import techreborn.init.ModBlocks;
import techreborn.tiles.TileGenericMachine;
public class TileVacuumFreezer extends TilePowerAcceptor
implements IToolDrop, IInventoryProvider, IContainerProvider, IRecipeCrafterProvider {
public class TileVacuumFreezer extends TileGenericMachine implements IContainerProvider {
@ConfigRegistry(config = "machines", category = "vacuumfreezer", key = "VacuumFreezerInput", comment = "Vacuum Freezer Max Input (Value in EU)")
public static int maxInput = 64;
@ConfigRegistry(config = "machines", category = "vacuumfreezer", key = "VacuumFreezerMaxEnergy", comment = "Vacuum Freezer Max Energy (Value in EU)")
public static int maxEnergy = 64000;
public static int maxEnergy = 64_000;
public Inventory inventory = new Inventory(3, "TileVacuumFreezer", 64, this);
public RecipeCrafter crafter;
public MultiblockChecker multiblockChecker;
public TileVacuumFreezer() {
super();
super("VacuumFreezer", maxInput, maxEnergy, ModBlocks.VACUUM_FREEZER, 2);
final int[] inputs = new int[] { 0 };
final int[] outputs = new int[] { 1 };
this.inventory = new Inventory(3, "TileVacuumFreezer", 64, this);
this.crafter = new RecipeCrafter(Reference.VACUUM_FREEZER_RECIPE, this, 2, 1, this.inventory, inputs, outputs);
}
@ -64,48 +56,14 @@ public class TileVacuumFreezer extends TilePowerAcceptor
return this.multiblockChecker.checkRectY(1, 1, MultiblockChecker.REINFORCED_CASING, MultiblockChecker.ZERO_OFFSET);
}
public int getProgressScaled(final int scale) {
if (this.crafter.currentTickTime != 0) {
return this.crafter.currentTickTime * scale / this.crafter.currentNeededTicks;
}
return 0;
}
// TilePowerAcceptor
// TileGenericMachine
@Override
public void update() {
if (world.isRemote){ return; }
if (this.getMultiBlock()) {
if (!world.isRemote && getMultiBlock()) {
super.update();
this.charge(2);
}
}
@Override
public double getBaseMaxPower() {
return maxEnergy;
}
@Override
public boolean canAcceptEnergy(final EnumFacing direction) {
return true;
}
@Override
public boolean canProvideEnergy(final EnumFacing direction) {
return false;
}
@Override
public double getBaseMaxOutput() {
return 0;
}
@Override
public double getBaseMaxInput() {
return maxInput;
}
// TileEntity
@Override
public void validate() {
@ -113,18 +71,6 @@ public class TileVacuumFreezer extends TilePowerAcceptor
this.multiblockChecker = new MultiblockChecker(this.world, this.getPos().down());
}
// IToolDrop
@Override
public ItemStack getToolDrop(final EntityPlayer entityPlayer) {
return new ItemStack(ModBlocks.VACUUM_FREEZER, 1);
}
// IInventoryProvider
@Override
public Inventory getInventory() {
return this.inventory;
}
// IContainerProvider
@Override
public BuiltContainer createContainer(final EntityPlayer player) {
@ -132,11 +78,4 @@ public class TileVacuumFreezer extends TilePowerAcceptor
.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;
}
}