Fixed blast furnace double energy tap. Closes #1273
This commit is contained in:
parent
8de19ff5e7
commit
c43077e640
2 changed files with 38 additions and 15 deletions
|
@ -37,6 +37,7 @@ public class MultiblockChecker {
|
||||||
public static final String STANDARD_CASING = "standard";
|
public static final String STANDARD_CASING = "standard";
|
||||||
public static final String REINFORCED_CASING = "reinforced";
|
public static final String REINFORCED_CASING = "reinforced";
|
||||||
public static final String ADVANCED_CASING = "advanced";
|
public static final String ADVANCED_CASING = "advanced";
|
||||||
|
public static final String CASING_ANY = "any";
|
||||||
|
|
||||||
private final World world;
|
private final World world;
|
||||||
private final BlockPos downCenter;
|
private final BlockPos downCenter;
|
||||||
|
@ -49,8 +50,11 @@ public class MultiblockChecker {
|
||||||
public boolean checkCasing(int offX, int offY, int offZ, String type) {
|
public boolean checkCasing(int offX, int offY, int offZ, String type) {
|
||||||
IBlockState block = getBlock(offX, offY, offZ);
|
IBlockState block = getBlock(offX, offY, offZ);
|
||||||
if (block.getBlock() == ModBlocks.MACHINE_CASINGS) {
|
if (block.getBlock() == ModBlocks.MACHINE_CASINGS) {
|
||||||
if (block.getValue(BlockMachineCasing.TYPE).equals(type))
|
if (type == MultiblockChecker.CASING_ANY) {
|
||||||
return true;
|
return true;
|
||||||
|
} else if (block.getValue(BlockMachineCasing.TYPE).equals(type)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,9 @@
|
||||||
|
|
||||||
package techreborn.tiles.multiblock;
|
package techreborn.tiles.multiblock;
|
||||||
|
|
||||||
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.network.NetworkManager;
|
import net.minecraft.network.NetworkManager;
|
||||||
|
@ -54,17 +56,15 @@ import techreborn.tiles.TileMachineCasing;
|
||||||
public class TileIndustrialBlastFurnace extends TilePowerAcceptor implements IToolDrop, IInventoryProvider,
|
public class TileIndustrialBlastFurnace extends TilePowerAcceptor implements IToolDrop, IInventoryProvider,
|
||||||
ITileRecipeHandler<BlastFurnaceRecipe>, IRecipeCrafterProvider, IContainerProvider {
|
ITileRecipeHandler<BlastFurnaceRecipe>, IRecipeCrafterProvider, IContainerProvider {
|
||||||
|
|
||||||
public static int euTick = 5;
|
public Inventory inventory;
|
||||||
public int tickTime;
|
|
||||||
public Inventory inventory = new Inventory(4, "TileIndustrialBlastFurnace", 64, this);
|
|
||||||
public RecipeCrafter crafter;
|
public RecipeCrafter crafter;
|
||||||
public int capacity = 1000;
|
public MultiblockChecker multiblockChecker;
|
||||||
|
|
||||||
private int cachedHeat;
|
private int cachedHeat;
|
||||||
|
|
||||||
public TileIndustrialBlastFurnace() {
|
public TileIndustrialBlastFurnace() {
|
||||||
super();
|
super();
|
||||||
// TODO configs
|
// TODO configs
|
||||||
|
this.inventory = new Inventory(4, "TileIndustrialBlastFurnace", 64, this);
|
||||||
final int[] inputs = new int[2];
|
final int[] inputs = new int[2];
|
||||||
inputs[0] = 0;
|
inputs[0] = 0;
|
||||||
inputs[1] = 1;
|
inputs[1] = 1;
|
||||||
|
@ -74,10 +74,30 @@ public class TileIndustrialBlastFurnace extends TilePowerAcceptor implements ITo
|
||||||
this.crafter = new RecipeCrafter(Reference.blastFurnaceRecipe, this, 2, 2, this.inventory, inputs, outputs);
|
this.crafter = new RecipeCrafter(Reference.blastFurnaceRecipe, this, 2, 2, this.inventory, inputs, outputs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean getMutliBlock() {
|
||||||
|
final boolean layer0 = this.multiblockChecker.checkRectY(1, 1, MultiblockChecker.CASING_ANY, MultiblockChecker.ZERO_OFFSET);
|
||||||
|
final boolean layer1 = this.multiblockChecker.checkRingY(1, 1, MultiblockChecker.CASING_ANY, new BlockPos(0, 1, 0));
|
||||||
|
final boolean layer2 = this.multiblockChecker.checkRingY(1, 1, MultiblockChecker.CASING_ANY, new BlockPos(0, 2, 0));
|
||||||
|
final boolean layer3 = this.multiblockChecker.checkRectY(1, 1, MultiblockChecker.CASING_ANY, new BlockPos(0, 3, 0));
|
||||||
|
final Block centerBlock1 = this.multiblockChecker.getBlock(0, 1, 0).getBlock();
|
||||||
|
final Block centerBlock2 = this.multiblockChecker.getBlock(0, 2, 0).getBlock();
|
||||||
|
final boolean center1 = (centerBlock1 == Blocks.AIR || centerBlock1 == Blocks.LAVA);
|
||||||
|
final boolean center2 = (centerBlock2 == Blocks.AIR || centerBlock2 == Blocks.LAVA);
|
||||||
|
return layer0 && layer1 && layer2 && layer3 && center1 && center2;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateEntity() {
|
public void update() {
|
||||||
super.updateEntity();
|
if (world.isRemote){ return; }
|
||||||
this.crafter.updateEntity();
|
|
||||||
|
if (this.multiblockChecker == null) {
|
||||||
|
final BlockPos pos = this.getPos().offset(this.getFacing().getOpposite(), 2);
|
||||||
|
this.multiblockChecker = new MultiblockChecker(this.world, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.getMutliBlock()) {
|
||||||
|
super.update();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -86,6 +106,9 @@ public class TileIndustrialBlastFurnace extends TilePowerAcceptor implements ITo
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getHeat() {
|
public int getHeat() {
|
||||||
|
if (!this.getMutliBlock()){
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
for (final EnumFacing direction : EnumFacing.values()) {
|
for (final EnumFacing direction : EnumFacing.values()) {
|
||||||
final TileEntity tileEntity = this.world.getTileEntity(new BlockPos(this.getPos().getX() + direction.getFrontOffsetX(),
|
final TileEntity tileEntity = this.world.getTileEntity(new BlockPos(this.getPos().getX() + direction.getFrontOffsetX(),
|
||||||
this.getPos().getY() + direction.getFrontOffsetY(), this.getPos().getZ() + direction.getFrontOffsetZ()));
|
this.getPos().getY() + direction.getFrontOffsetY(), this.getPos().getZ() + direction.getFrontOffsetZ()));
|
||||||
|
@ -133,20 +156,16 @@ public class TileIndustrialBlastFurnace extends TilePowerAcceptor implements ITo
|
||||||
@Override
|
@Override
|
||||||
public void readFromNBT(final NBTTagCompound tagCompound) {
|
public void readFromNBT(final NBTTagCompound tagCompound) {
|
||||||
super.readFromNBT(tagCompound);
|
super.readFromNBT(tagCompound);
|
||||||
this.tickTime = tagCompound.getInteger("tickTime");
|
this.crafter.readFromNBT(tagCompound);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NBTTagCompound writeToNBT(final NBTTagCompound tagCompound) {
|
public NBTTagCompound writeToNBT(final NBTTagCompound tagCompound) {
|
||||||
super.writeToNBT(tagCompound);
|
super.writeToNBT(tagCompound);
|
||||||
this.writeUpdateToNBT(tagCompound);
|
this.crafter.writeToNBT(tagCompound);
|
||||||
return tagCompound;
|
return tagCompound;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeUpdateToNBT(final NBTTagCompound tagCompound) {
|
|
||||||
tagCompound.setInteger("tickTime", this.tickTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ISidedInventory
|
// ISidedInventory
|
||||||
@Override
|
@Override
|
||||||
public int[] getSlotsForFace(final EnumFacing side) {
|
public int[] getSlotsForFace(final EnumFacing side) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue