Convert BlastFurnace
This commit is contained in:
parent
665b5f7569
commit
ea98e4a8a0
4 changed files with 147 additions and 200 deletions
|
@ -9,6 +9,7 @@ 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.power.EnumPowerTier;
|
||||
import reborncore.api.recipe.IRecipeCrafterProvider;
|
||||
import reborncore.api.tile.IInventoryProvider;
|
||||
|
@ -18,6 +19,7 @@ import reborncore.common.multiblock.IMultiblockPart;
|
|||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||
import reborncore.common.recipes.RecipeCrafter;
|
||||
import reborncore.common.util.Inventory;
|
||||
|
||||
import techreborn.api.Reference;
|
||||
import techreborn.api.recipe.ITileRecipeHandler;
|
||||
import techreborn.api.recipe.machines.BlastFurnaceRecipe;
|
||||
|
@ -35,36 +37,38 @@ public class TileBlastFurnace extends TilePowerAcceptor implements IWrenchable,
|
|||
public RecipeCrafter crafter;
|
||||
public int capacity = 1000;
|
||||
|
||||
private int cachedHeat;
|
||||
|
||||
public TileBlastFurnace() {
|
||||
super(ConfigTechReborn.CentrifugeTier);
|
||||
// TODO configs
|
||||
int[] inputs = new int[2];
|
||||
final int[] inputs = new int[2];
|
||||
inputs[0] = 0;
|
||||
inputs[1] = 1;
|
||||
int[] outputs = new int[2];
|
||||
final int[] outputs = new int[2];
|
||||
outputs[0] = 2;
|
||||
outputs[1] = 3;
|
||||
crafter = new RecipeCrafter(Reference.blastFurnaceRecipe, this, 2, 2, inventory, inputs, outputs);
|
||||
this.crafter = new RecipeCrafter(Reference.blastFurnaceRecipe, this, 2, 2, this.inventory, inputs, outputs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
crafter.updateEntity();
|
||||
this.crafter.updateEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) {
|
||||
public boolean wrenchCanSetFacing(final EntityPlayer entityPlayer, final EnumFacing side) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumFacing getFacing() {
|
||||
return getFacingEnum();
|
||||
return this.getFacingEnum();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wrenchCanRemove(EntityPlayer entityPlayer) {
|
||||
public boolean wrenchCanRemove(final EntityPlayer entityPlayer) {
|
||||
return entityPlayer.isSneaking();
|
||||
}
|
||||
|
||||
|
@ -74,39 +78,39 @@ public class TileBlastFurnace extends TilePowerAcceptor implements IWrenchable,
|
|||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
|
||||
public ItemStack getWrenchDrop(final EntityPlayer entityPlayer) {
|
||||
return new ItemStack(ModBlocks.INDUSTRIAL_BLAST_FURNACE, 1);
|
||||
}
|
||||
|
||||
public int getHeat() {
|
||||
for (EnumFacing direction : EnumFacing.values()) {
|
||||
TileEntity tileEntity = world.getTileEntity(new BlockPos(getPos().getX() + direction.getFrontOffsetX(),
|
||||
getPos().getY() + direction.getFrontOffsetY(), getPos().getZ() + direction.getFrontOffsetZ()));
|
||||
for (final EnumFacing direction : EnumFacing.values()) {
|
||||
final TileEntity tileEntity = this.world.getTileEntity(new BlockPos(this.getPos().getX() + direction.getFrontOffsetX(),
|
||||
this.getPos().getY() + direction.getFrontOffsetY(), this.getPos().getZ() + direction.getFrontOffsetZ()));
|
||||
if (tileEntity instanceof TileMachineCasing) {
|
||||
if (((TileMachineCasing) tileEntity).isConnected()
|
||||
&& ((TileMachineCasing) tileEntity).getMultiblockController().isAssembled()) {
|
||||
MultiBlockCasing casing = ((TileMachineCasing) tileEntity).getMultiblockController();
|
||||
Location location = new Location(getPos().getX(), getPos().getY(), getPos().getZ(), direction);
|
||||
&& ((TileMachineCasing) tileEntity).getMultiblockController().isAssembled()) {
|
||||
final MultiBlockCasing casing = ((TileMachineCasing) tileEntity).getMultiblockController();
|
||||
final Location location = new Location(this.getPos().getX(), this.getPos().getY(), this.getPos().getZ(), direction);
|
||||
location.modifyPositionFromSide(direction, 1);
|
||||
int heat = 0;
|
||||
if (world.getBlockState(new BlockPos(location.getX(), location.getY() - 1, location.getZ()))
|
||||
.getBlock() == tileEntity.getBlockType()) {
|
||||
if (this.world.getBlockState(new BlockPos(location.getX(), location.getY() - 1, location.getZ()))
|
||||
.getBlock() == tileEntity.getBlockType()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (IMultiblockPart part : casing.connectedParts) {
|
||||
BlockMachineCasing casing1 = (BlockMachineCasing) world.getBlockState(part.getPos())
|
||||
.getBlock();
|
||||
for (final IMultiblockPart part : casing.connectedParts) {
|
||||
final BlockMachineCasing casing1 = (BlockMachineCasing) this.world.getBlockState(part.getPos())
|
||||
.getBlock();
|
||||
heat += casing1
|
||||
.getHeatFromState(part.getWorld().getBlockState(part.getWorldLocation().toBlockPos()));
|
||||
.getHeatFromState(part.getWorld().getBlockState(part.getWorldLocation().toBlockPos()));
|
||||
// TODO meta fix
|
||||
}
|
||||
|
||||
if (world.getBlockState(new BlockPos(location.getX(), location.getY(), location.getZ()))
|
||||
.getBlock().getUnlocalizedName().equals("tile.lava")
|
||||
&& world
|
||||
.getBlockState(new BlockPos(location.getX(), location.getY() + 1, location.getZ()))
|
||||
.getBlock().getUnlocalizedName().equals("tile.lava")) {
|
||||
if (this.world.getBlockState(new BlockPos(location.getX(), location.getY(), location.getZ()))
|
||||
.getBlock().getUnlocalizedName().equals("tile.lava")
|
||||
&& this.world
|
||||
.getBlockState(new BlockPos(location.getX(), location.getY() + 1, location.getZ()))
|
||||
.getBlock().getUnlocalizedName().equals("tile.lava")) {
|
||||
heat += 500;
|
||||
}
|
||||
return heat;
|
||||
|
@ -117,50 +121,50 @@ public class TileBlastFurnace extends TilePowerAcceptor implements IWrenchable,
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity packet) {
|
||||
world.markBlockRangeForRenderUpdate(getPos().getX(), getPos().getY(), getPos().getZ(), getPos().getX(),
|
||||
getPos().getY(), getPos().getZ());
|
||||
readFromNBT(packet.getNbtCompound());
|
||||
public void onDataPacket(final NetworkManager net, final SPacketUpdateTileEntity packet) {
|
||||
this.world.markBlockRangeForRenderUpdate(this.getPos().getX(), this.getPos().getY(), this.getPos().getZ(), this.getPos().getX(),
|
||||
this.getPos().getY(), this.getPos().getZ());
|
||||
this.readFromNBT(packet.getNbtCompound());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tagCompound) {
|
||||
public void readFromNBT(final NBTTagCompound tagCompound) {
|
||||
super.readFromNBT(tagCompound);
|
||||
tickTime = tagCompound.getInteger("tickTime");
|
||||
this.tickTime = tagCompound.getInteger("tickTime");
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound) {
|
||||
public NBTTagCompound writeToNBT(final NBTTagCompound tagCompound) {
|
||||
super.writeToNBT(tagCompound);
|
||||
writeUpdateToNBT(tagCompound);
|
||||
this.writeUpdateToNBT(tagCompound);
|
||||
return tagCompound;
|
||||
}
|
||||
|
||||
public void writeUpdateToNBT(NBTTagCompound tagCompound) {
|
||||
tagCompound.setInteger("tickTime", tickTime);
|
||||
public void writeUpdateToNBT(final NBTTagCompound tagCompound) {
|
||||
tagCompound.setInteger("tickTime", this.tickTime);
|
||||
}
|
||||
|
||||
// ISidedInventory
|
||||
@Override
|
||||
public int[] getSlotsForFace(EnumFacing side) {
|
||||
public int[] getSlotsForFace(final EnumFacing side) {
|
||||
return side == EnumFacing.DOWN ? new int[] { 0, 1, 2, 3 } : new int[] { 0, 1, 2, 3 };
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int slotIndex, ItemStack itemStack, EnumFacing side) {
|
||||
public boolean canInsertItem(final int slotIndex, final ItemStack itemStack, final EnumFacing side) {
|
||||
if (slotIndex >= 2)
|
||||
return false;
|
||||
return isItemValidForSlot(slotIndex, itemStack);
|
||||
return this.isItemValidForSlot(slotIndex, itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slotIndex, ItemStack itemStack, EnumFacing side) {
|
||||
public boolean canExtractItem(final int slotIndex, final ItemStack itemStack, final EnumFacing side) {
|
||||
return slotIndex == 2 || slotIndex == 3;
|
||||
}
|
||||
|
||||
public int getProgressScaled(int scale) {
|
||||
if (crafter.currentTickTime != 0) {
|
||||
return crafter.currentTickTime * scale / crafter.currentNeededTicks;
|
||||
public int getProgressScaled(final int scale) {
|
||||
if (this.crafter.currentTickTime != 0) {
|
||||
return this.crafter.currentTickTime * scale / this.crafter.currentNeededTicks;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -171,12 +175,12 @@ public class TileBlastFurnace extends TilePowerAcceptor implements IWrenchable,
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canAcceptEnergy(EnumFacing direction) {
|
||||
public boolean canAcceptEnergy(final EnumFacing direction) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProvideEnergy(EnumFacing direction) {
|
||||
public boolean canProvideEnergy(final EnumFacing direction) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -196,26 +200,34 @@ public class TileBlastFurnace extends TilePowerAcceptor implements IWrenchable,
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canCraft(TileEntity tile, BlastFurnaceRecipe recipe) {
|
||||
public boolean canCraft(final TileEntity tile, final BlastFurnaceRecipe recipe) {
|
||||
if (tile instanceof TileBlastFurnace) {
|
||||
TileBlastFurnace blastFurnace = (TileBlastFurnace) tile;
|
||||
final TileBlastFurnace blastFurnace = (TileBlastFurnace) tile;
|
||||
return blastFurnace.getHeat() >= recipe.neededHeat;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCraft(TileEntity tile, BlastFurnaceRecipe recipe) {
|
||||
public boolean onCraft(final TileEntity tile, final BlastFurnaceRecipe recipe) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Inventory getInventory() {
|
||||
return inventory;
|
||||
return this.inventory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecipeCrafter getRecipeCrafter() {
|
||||
return crafter;
|
||||
return this.crafter;
|
||||
}
|
||||
|
||||
public void setHeat(final int heat) {
|
||||
this.cachedHeat = heat;
|
||||
}
|
||||
|
||||
public int getCachedHeat() {
|
||||
return this.cachedHeat;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue