Fixed the BlastFurnace
This commit is contained in:
parent
29398d50dd
commit
462aa20710
4 changed files with 76 additions and 17 deletions
|
@ -33,7 +33,7 @@ public class BlastFurnaceRecipe extends BaseRecipe {
|
||||||
public boolean canCraft(TileEntity tile) {
|
public boolean canCraft(TileEntity tile) {
|
||||||
if(tile instanceof TileBlastFurnace){
|
if(tile instanceof TileBlastFurnace){
|
||||||
TileBlastFurnace blastFurnace = (TileBlastFurnace) tile;
|
TileBlastFurnace blastFurnace = (TileBlastFurnace) tile;
|
||||||
return blastFurnace.getHeat() >- neededHeat;
|
return blastFurnace.getHeat() >= neededHeat;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,19 @@
|
||||||
package techreborn.client.container;
|
package techreborn.client.container;
|
||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.inventory.ICrafting;
|
||||||
import net.minecraft.inventory.Slot;
|
import net.minecraft.inventory.Slot;
|
||||||
import techreborn.client.SlotOutput;
|
import techreborn.client.SlotOutput;
|
||||||
import techreborn.tiles.TileBlastFurnace;
|
import techreborn.tiles.TileBlastFurnace;
|
||||||
|
|
||||||
public class ContainerBlastFurnace extends TechRebornContainer {
|
public class ContainerBlastFurnace extends ContainerCrafting {
|
||||||
|
|
||||||
EntityPlayer player;
|
EntityPlayer player;
|
||||||
|
|
||||||
TileBlastFurnace tile;
|
TileBlastFurnace tile;
|
||||||
|
|
||||||
|
public int heat;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canInteractWith(EntityPlayer player)
|
public boolean canInteractWith(EntityPlayer player)
|
||||||
{
|
{
|
||||||
|
@ -22,7 +25,8 @@ public class ContainerBlastFurnace extends TechRebornContainer {
|
||||||
public ContainerBlastFurnace(TileBlastFurnace tileblastfurnace,
|
public ContainerBlastFurnace(TileBlastFurnace tileblastfurnace,
|
||||||
EntityPlayer player)
|
EntityPlayer player)
|
||||||
{
|
{
|
||||||
tile = tileblastfurnace;
|
super(tileblastfurnace.crafter);
|
||||||
|
tile = tileblastfurnace;
|
||||||
this.player = player;
|
this.player = player;
|
||||||
|
|
||||||
// input
|
// input
|
||||||
|
@ -50,4 +54,28 @@ public class ContainerBlastFurnace extends TechRebornContainer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void detectAndSendChanges() {
|
||||||
|
super.detectAndSendChanges();
|
||||||
|
for (int i = 0; i < this.crafters.size(); i++) {
|
||||||
|
ICrafting icrafting = (ICrafting)this.crafters.get(i);
|
||||||
|
if(this.heat != tile.getHeat()){
|
||||||
|
icrafting.sendProgressBarUpdate(this, 10, tile.getHeat());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addCraftingToCrafters(ICrafting crafting) {
|
||||||
|
super.addCraftingToCrafters(crafting);
|
||||||
|
crafting.sendProgressBarUpdate(this, 10, tile.getHeat());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateProgressBar(int id, int value) {
|
||||||
|
if(id == 10){
|
||||||
|
this.heat = value;
|
||||||
|
}
|
||||||
|
super.updateProgressBar(id, value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,9 @@ public class GuiBlastFurnace extends GuiContainer {
|
||||||
|
|
||||||
private static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/industrial_blast_furnace.png");
|
private static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/industrial_blast_furnace.png");
|
||||||
|
|
||||||
TileBlastFurnace blastfurnace;
|
TileBlastFurnace blastfurnace;
|
||||||
|
|
||||||
|
ContainerBlastFurnace containerBlastFurnace;
|
||||||
|
|
||||||
public GuiBlastFurnace(EntityPlayer player, TileBlastFurnace tileblastfurnace)
|
public GuiBlastFurnace(EntityPlayer player, TileBlastFurnace tileblastfurnace)
|
||||||
{
|
{
|
||||||
|
@ -23,6 +25,7 @@ public class GuiBlastFurnace extends GuiContainer {
|
||||||
this.xSize = 176;
|
this.xSize = 176;
|
||||||
this.ySize = 167;
|
this.ySize = 167;
|
||||||
blastfurnace = tileblastfurnace;
|
blastfurnace = tileblastfurnace;
|
||||||
|
this.containerBlastFurnace = (ContainerBlastFurnace) this.inventorySlots;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -40,12 +43,24 @@ public class GuiBlastFurnace extends GuiContainer {
|
||||||
int l = (this.height - this.ySize) / 2;
|
int l = (this.height - this.ySize) / 2;
|
||||||
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
|
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
|
||||||
|
|
||||||
if(blastfurnace.getHeat() == 0)
|
if(containerBlastFurnace.heat == 0)
|
||||||
{
|
{
|
||||||
GuiDraw.drawTooltipBox(k + 30, l + 50 + 12 - 0, 114, 10);
|
GuiDraw.drawTooltipBox(k + 30, l + 50 + 12 - 0, 114, 10);
|
||||||
this.fontRendererObj.drawString(ModInfo.MISSING_MULTIBLOCK, k + 38, l + 52 + 12 - 0, -1);
|
this.fontRendererObj.drawString(ModInfo.MISSING_MULTIBLOCK, k + 38, l + 52 + 12 - 0, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int j = 0;
|
||||||
|
this.mc.getTextureManager().bindTexture(texture);
|
||||||
|
j = blastfurnace.getProgressScaled(24);
|
||||||
|
if(j > 0) {
|
||||||
|
this.drawTexturedModalRect(k + 64, l + 37, 176, 14, j + 1, 16);
|
||||||
|
}
|
||||||
|
|
||||||
|
j = blastfurnace.getEnergyScaled(12);
|
||||||
|
if(j > 0) {
|
||||||
|
this.drawTexturedModalRect(k + 9, l + 36 + 12 - j, 176, 12 - j, 14, j + 2);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_)
|
protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_)
|
||||||
|
@ -53,7 +68,9 @@ public class GuiBlastFurnace extends GuiContainer {
|
||||||
super.drawGuiContainerForegroundLayer(p_146979_1_, p_146979_2_);
|
super.drawGuiContainerForegroundLayer(p_146979_1_, p_146979_2_);
|
||||||
String name = StatCollector.translateToLocal("tile.techreborn.blastfurnace.name");
|
String name = StatCollector.translateToLocal("tile.techreborn.blastfurnace.name");
|
||||||
this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6, 4210752);
|
this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6, 4210752);
|
||||||
this.fontRendererObj.drawString("Current Heat: " +blastfurnace.getHeat(), 40, 60, 4210752);
|
if(containerBlastFurnace.heat != 0){
|
||||||
|
this.fontRendererObj.drawString("Current Heat: " + containerBlastFurnace.heat, 40, 60, 4210752);
|
||||||
|
}
|
||||||
this.fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, this.ySize - 96 + 2, 4210752);
|
this.fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, this.ySize - 96 + 2, 4210752);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ public class TileBlastFurnace extends TileMachineBase implements IWrenchable, II
|
||||||
|
|
||||||
public TileBlastFurnace() {
|
public TileBlastFurnace() {
|
||||||
//TODO configs
|
//TODO configs
|
||||||
energy = new BasicSink(this, 1000,ConfigTechReborn.CentrifugeTier);
|
energy = new BasicSink(this, 10000,ConfigTechReborn.CentrifugeTier);
|
||||||
int[] inputs = new int[2];
|
int[] inputs = new int[2];
|
||||||
inputs[0] = 0;
|
inputs[0] = 0;
|
||||||
inputs[1] = 1;
|
inputs[1] = 1;
|
||||||
|
@ -86,16 +86,18 @@ public class TileBlastFurnace extends TileMachineBase implements IWrenchable, II
|
||||||
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
|
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
|
||||||
TileEntity tileEntity = worldObj.getTileEntity(xCoord + direction.offsetX, yCoord + direction.offsetY, zCoord + direction.offsetZ);
|
TileEntity tileEntity = worldObj.getTileEntity(xCoord + direction.offsetX, yCoord + direction.offsetY, zCoord + direction.offsetZ);
|
||||||
if (tileEntity instanceof TileMachineCasing) {
|
if (tileEntity instanceof TileMachineCasing) {
|
||||||
if ((tileEntity.getBlockType() instanceof BlockMachineCasing)) {
|
if(((TileMachineCasing) tileEntity).isConnected()){
|
||||||
int heat;
|
if ((tileEntity.getBlockType() instanceof BlockMachineCasing)) {
|
||||||
heat = BlockMachineCasing.getHeatFromMeta(tileEntity.getBlockMetadata());
|
int heat;
|
||||||
Location location = new Location(xCoord, yCoord, zCoord, direction);
|
heat = BlockMachineCasing.getHeatFromMeta(tileEntity.getBlockMetadata());
|
||||||
location.modifyPositionFromSide(direction, 1);
|
Location location = new Location(xCoord, yCoord, zCoord, direction);
|
||||||
if (worldObj.getBlock(location.getX(), location.getY(), location.getZ()).getUnlocalizedName().equals("tile.lava")) {
|
location.modifyPositionFromSide(direction, 1);
|
||||||
heat += 500;
|
if (worldObj.getBlock(location.getX(), location.getY(), location.getZ()).getUnlocalizedName().equals("tile.lava")) {
|
||||||
}
|
heat += 500;
|
||||||
return heat;
|
}
|
||||||
}
|
return heat;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -323,5 +325,17 @@ public class TileBlastFurnace extends TileMachineBase implements IWrenchable, II
|
||||||
return slotIndex == 2 || slotIndex == 3;
|
return slotIndex == 2 || slotIndex == 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getProgressScaled(int scale) {
|
||||||
|
if(crafter.currentTickTime != 0) {
|
||||||
|
return crafter.currentTickTime * scale / crafter.currentNeededTicks;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getEnergyScaled(int scale) {
|
||||||
|
return (int)energy.getEnergyStored() * scale / energy.getCapacity();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue