Merge pull request #641 from Adam29Adam29/master
Electric Furnace Rework
@ -34,6 +34,8 @@ public class MachineElectricFurnace extends BlockContainer {
|
|||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
private IIcon iconFront;
|
private IIcon iconFront;
|
||||||
|
private IIcon iconTop;
|
||||||
|
private IIcon iconBottom;
|
||||||
|
|
||||||
public MachineElectricFurnace(boolean blockState) {
|
public MachineElectricFurnace(boolean blockState) {
|
||||||
super(Material.iron);
|
super(Material.iron);
|
||||||
@ -45,7 +47,9 @@ public class MachineElectricFurnace extends BlockContainer {
|
|||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public void registerBlockIcons(IIconRegister iconRegister) {
|
public void registerBlockIcons(IIconRegister iconRegister) {
|
||||||
this.iconFront = iconRegister.registerIcon(RefStrings.MODID + (this.isActive ? ":machine_electric_furnace_front_on" : ":machine_electric_furnace_front_off"));
|
this.iconFront = iconRegister.registerIcon(RefStrings.MODID + (this.isActive ? ":machine_electric_furnace_front_on" : ":machine_electric_furnace_front_off"));
|
||||||
this.blockIcon = iconRegister.registerIcon(RefStrings.MODID + ":machine_electric_furnace");
|
this.blockIcon = iconRegister.registerIcon(RefStrings.MODID + ":machine_electric_furnace_side");
|
||||||
|
this.iconTop = iconRegister.registerIcon(RefStrings.MODID + ":machine_electric_furnace_top");
|
||||||
|
this.iconBottom = iconRegister.registerIcon(RefStrings.MODID + ":machine_electric_furnace_bottom");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -53,7 +57,7 @@ public class MachineElectricFurnace extends BlockContainer {
|
|||||||
public IIcon getIcon(int side, int metadata) {
|
public IIcon getIcon(int side, int metadata) {
|
||||||
//Reactivate in case of emergency
|
//Reactivate in case of emergency
|
||||||
//return metadata == 0 && side == 3 ? this.iconFront : (side == metadata ? this.iconFront : this.iconTop);
|
//return metadata == 0 && side == 3 ? this.iconFront : (side == metadata ? this.iconFront : this.iconTop);
|
||||||
return metadata == 0 && side == 3 ? this.iconFront : (side == metadata ? this.iconFront : this.blockIcon);
|
return metadata == 0 && side == 3 ? this.iconFront : (side == metadata ? this.iconFront : side == 0 ? this.iconBottom : side == 1 ? this.iconTop : this.blockIcon);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -262,6 +266,5 @@ public class MachineElectricFurnace extends BlockContainer {
|
|||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public Item getItem(World p_149694_1_, int p_149694_2_, int p_149694_3_, int p_149694_4_)
|
public Item getItem(World p_149694_1_, int p_149694_2_, int p_149694_3_, int p_149694_4_)
|
||||||
{
|
{
|
||||||
return Item.getItemFromBlock(ModBlocks.machine_electric_furnace_off);
|
return Item.getItemFromBlock(ModBlocks.machine_electric_furnace_off);}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package com.hbm.inventory.container;
|
package com.hbm.inventory.container;
|
||||||
|
|
||||||
import com.hbm.inventory.SlotSmelting;
|
import com.hbm.inventory.SlotSmelting;
|
||||||
|
import com.hbm.inventory.SlotUpgrade;
|
||||||
import com.hbm.tileentity.machine.TileEntityMachineElectricFurnace;
|
import com.hbm.tileentity.machine.TileEntityMachineElectricFurnace;
|
||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
@ -21,6 +22,8 @@ public class ContainerElectricFurnace extends Container {
|
|||||||
this.addSlotToContainer(new Slot(tedf, 0, 56, 53));
|
this.addSlotToContainer(new Slot(tedf, 0, 56, 53));
|
||||||
this.addSlotToContainer(new Slot(tedf, 1, 56, 17));
|
this.addSlotToContainer(new Slot(tedf, 1, 56, 17));
|
||||||
this.addSlotToContainer(new SlotSmelting(invPlayer.player, tedf, 2, 116, 35));
|
this.addSlotToContainer(new SlotSmelting(invPlayer.player, tedf, 2, 116, 35));
|
||||||
|
//Upgrades
|
||||||
|
this.addSlotToContainer(new SlotUpgrade(tedf, 3, 147, 34));
|
||||||
|
|
||||||
for(int i = 0; i < 3; i++) {
|
for(int i = 0; i < 3; i++) {
|
||||||
for(int j = 0; j < 9; j++) {
|
for(int j = 0; j < 9; j++) {
|
||||||
|
|||||||
@ -10,6 +10,7 @@ import org.lwjgl.opengl.GL11;
|
|||||||
import com.hbm.inventory.container.ContainerElectricFurnace;
|
import com.hbm.inventory.container.ContainerElectricFurnace;
|
||||||
import com.hbm.lib.RefStrings;
|
import com.hbm.lib.RefStrings;
|
||||||
import com.hbm.tileentity.machine.TileEntityMachineElectricFurnace;
|
import com.hbm.tileentity.machine.TileEntityMachineElectricFurnace;
|
||||||
|
import com.hbm.util.I18nUtil;
|
||||||
|
|
||||||
public class GUIMachineElectricFurnace extends GuiInfoContainer {
|
public class GUIMachineElectricFurnace extends GuiInfoContainer {
|
||||||
|
|
||||||
@ -29,6 +30,12 @@ public class GUIMachineElectricFurnace extends GuiInfoContainer {
|
|||||||
super.drawScreen(mouseX, mouseY, f);
|
super.drawScreen(mouseX, mouseY, f);
|
||||||
|
|
||||||
this.drawElectricityInfo(this, mouseX, mouseY, guiLeft + 20, guiTop + 69 - 52, 16, 52, diFurnace.power, diFurnace.maxPower);
|
this.drawElectricityInfo(this, mouseX, mouseY, guiLeft + 20, guiTop + 69 - 52, 16, 52, diFurnace.power, diFurnace.maxPower);
|
||||||
|
|
||||||
|
String[] upgradeText = new String[3];
|
||||||
|
upgradeText[0] = I18nUtil.resolveKey("desc.gui.upgrade");
|
||||||
|
upgradeText[1] = I18nUtil.resolveKey("desc.gui.upgrade.speed");
|
||||||
|
upgradeText[2] = I18nUtil.resolveKey("desc.gui.upgrade.power");
|
||||||
|
this.drawCustomInfoStat(mouseX, mouseY, guiLeft + 151, guiTop + 19, 8, 8, mouseX, mouseY, upgradeText);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -64,11 +71,13 @@ public class GUIMachineElectricFurnace extends GuiInfoContainer {
|
|||||||
|
|
||||||
if(diFurnace.canProcess() && diFurnace.hasPower())
|
if(diFurnace.canProcess() && diFurnace.hasPower())
|
||||||
{
|
{
|
||||||
drawTexturedModalRect(guiLeft + 56, guiTop + 36, 176, 0, 15, 16);
|
drawTexturedModalRect(guiLeft + 56, guiTop + 35, 176, 0, 16, 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
int j1 = fs.getDiFurnaceProgressScaled(24);
|
int j1 = fs.getDiFurnaceProgressScaled(24);
|
||||||
drawTexturedModalRect(guiLeft + 79, guiTop + 34, 176, 14, j1 + 1, 17);
|
drawTexturedModalRect(guiLeft + 79, guiTop + 34, 176, 17, j1 + 1, 17);
|
||||||
|
|
||||||
|
this.drawInfoPanel(guiLeft + 151, guiTop + 19, 8, 8, 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -37,6 +37,8 @@ public class ItemMachineUpgrade extends Item {
|
|||||||
list.add("Delay -" + (15 * this.tier) + "% / Consumption +" + (300 * this.tier) + "HE/t");
|
list.add("Delay -" + (15 * this.tier) + "% / Consumption +" + (300 * this.tier) + "HE/t");
|
||||||
list.add(EnumChatFormatting.RED + "Laser Miner:");
|
list.add(EnumChatFormatting.RED + "Laser Miner:");
|
||||||
list.add("Delay ÷" + (1 + this.tier) + " / Consumption +" + (625 * this.tier) + "HE/t");
|
list.add("Delay ÷" + (1 + this.tier) + " / Consumption +" + (625 * this.tier) + "HE/t");
|
||||||
|
list.add(EnumChatFormatting.RED + "Electric Furnace:");
|
||||||
|
list.add("Delay -" + (25 * this.tier) + "% / Consumption +" + (50 * this.tier) + "HE/t");
|
||||||
list.add(EnumChatFormatting.RED + "Assembly Machine:");
|
list.add(EnumChatFormatting.RED + "Assembly Machine:");
|
||||||
list.add("Delay -" + (25 * this.tier) + "% / Consumption +" + (300 * this.tier) + "HE/t");
|
list.add("Delay -" + (25 * this.tier) + "% / Consumption +" + (300 * this.tier) + "HE/t");
|
||||||
list.add(EnumChatFormatting.RED + "Chemical Plant:");
|
list.add(EnumChatFormatting.RED + "Chemical Plant:");
|
||||||
@ -69,6 +71,8 @@ public class ItemMachineUpgrade extends Item {
|
|||||||
if(this.type == UpgradeType.POWER) {
|
if(this.type == UpgradeType.POWER) {
|
||||||
list.add(EnumChatFormatting.RED + "Mining Drill:");
|
list.add(EnumChatFormatting.RED + "Mining Drill:");
|
||||||
list.add("Consumption -" + (30 * this.tier) + "HE/t / Delay +" + (5 * this.tier) + "%");
|
list.add("Consumption -" + (30 * this.tier) + "HE/t / Delay +" + (5 * this.tier) + "%");
|
||||||
|
list.add(EnumChatFormatting.RED + "Electric Furnace:");
|
||||||
|
list.add("Consumption -" + (15 * this.tier) + "HE/t / Delay +" + (10 * this.tier) + "%");
|
||||||
list.add(EnumChatFormatting.RED + "Assembly Machine:");
|
list.add(EnumChatFormatting.RED + "Assembly Machine:");
|
||||||
list.add("Consumption -" + (30 * this.tier) + "HE/t / Delay +" + (5 * this.tier) + "%");
|
list.add("Consumption -" + (30 * this.tier) + "HE/t / Delay +" + (5 * this.tier) + "%");
|
||||||
list.add(EnumChatFormatting.RED + "Chemical Plant:");
|
list.add(EnumChatFormatting.RED + "Chemical Plant:");
|
||||||
|
|||||||
@ -170,7 +170,7 @@ public class AuxGaugePacket implements IMessage {
|
|||||||
TileEntityMachineElectricFurnace furn = (TileEntityMachineElectricFurnace)te;
|
TileEntityMachineElectricFurnace furn = (TileEntityMachineElectricFurnace)te;
|
||||||
|
|
||||||
if(m.id == 0)
|
if(m.id == 0)
|
||||||
furn.dualCookTime = m.value;
|
furn.progress = m.value;
|
||||||
}
|
}
|
||||||
if (te instanceof TileEntityMachineArcFurnace) {
|
if (te instanceof TileEntityMachineArcFurnace) {
|
||||||
TileEntityMachineArcFurnace furn = (TileEntityMachineArcFurnace)te;
|
TileEntityMachineArcFurnace furn = (TileEntityMachineArcFurnace)te;
|
||||||
|
|||||||
@ -1,11 +1,13 @@
|
|||||||
package com.hbm.tileentity.machine;
|
package com.hbm.tileentity.machine;
|
||||||
|
|
||||||
import com.hbm.blocks.machine.MachineElectricFurnace;
|
import com.hbm.blocks.machine.MachineElectricFurnace;
|
||||||
|
import com.hbm.inventory.UpgradeManager;
|
||||||
|
import com.hbm.items.machine.ItemMachineUpgrade.UpgradeType;
|
||||||
import com.hbm.lib.Library;
|
import com.hbm.lib.Library;
|
||||||
import com.hbm.packet.AuxElectricityPacket;
|
import com.hbm.packet.AuxElectricityPacket;
|
||||||
import com.hbm.packet.AuxGaugePacket;
|
import com.hbm.packet.AuxGaugePacket;
|
||||||
import com.hbm.packet.PacketDispatcher;
|
import com.hbm.packet.PacketDispatcher;
|
||||||
import com.hbm.tileentity.TileEntityLoadedBase;
|
import com.hbm.tileentity.TileEntityMachineBase;
|
||||||
|
|
||||||
import api.hbm.energy.IBatteryItem;
|
import api.hbm.energy.IBatteryItem;
|
||||||
import api.hbm.energy.IEnergyUser;
|
import api.hbm.energy.IEnergyUser;
|
||||||
@ -18,14 +20,17 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||||||
import net.minecraft.nbt.NBTTagList;
|
import net.minecraft.nbt.NBTTagList;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
public class TileEntityMachineElectricFurnace extends TileEntityLoadedBase implements ISidedInventory, IEnergyUser {
|
public class TileEntityMachineElectricFurnace extends TileEntityMachineBase implements ISidedInventory, IEnergyUser {
|
||||||
|
|
||||||
|
// HOLY FUCKING SHIT I SPENT 5 DAYS ON THIS SHITFUCK CLASS FILE
|
||||||
|
// thanks Martin, vaer and Bob for the help
|
||||||
private ItemStack slots[];
|
private ItemStack slots[];
|
||||||
|
|
||||||
public int dualCookTime;
|
public int progress;
|
||||||
public long power;
|
public long power;
|
||||||
public static final long maxPower = 100000;
|
public static final long maxPower = 100000;
|
||||||
public static final int processingSpeed = 100;
|
public int MaxProgress = 100;
|
||||||
|
public int consumption = 50;
|
||||||
|
|
||||||
private static final int[] slots_top = new int[] {1};
|
private static final int[] slots_top = new int[] {1};
|
||||||
private static final int[] slots_bottom = new int[] {2, 0};
|
private static final int[] slots_bottom = new int[] {2, 0};
|
||||||
@ -33,8 +38,9 @@ public class TileEntityMachineElectricFurnace extends TileEntityLoadedBase imple
|
|||||||
|
|
||||||
private String customName;
|
private String customName;
|
||||||
|
|
||||||
public TileEntityMachineElectricFurnace() {
|
public TileEntityMachineElectricFurnace(){
|
||||||
slots = new ItemStack[3];
|
super(4);
|
||||||
|
slots = new ItemStack[4];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -142,8 +148,8 @@ public class TileEntityMachineElectricFurnace extends TileEntityLoadedBase imple
|
|||||||
super.readFromNBT(nbt);
|
super.readFromNBT(nbt);
|
||||||
NBTTagList list = nbt.getTagList("items", 10);
|
NBTTagList list = nbt.getTagList("items", 10);
|
||||||
|
|
||||||
this.power = nbt.getLong("powerTime");
|
this.power = nbt.getLong("power");
|
||||||
this.dualCookTime = nbt.getInteger("cookTime");
|
this.progress = nbt.getInteger("progress");
|
||||||
slots = new ItemStack[getSizeInventory()];
|
slots = new ItemStack[getSizeInventory()];
|
||||||
|
|
||||||
for(int i = 0; i < list.tagCount(); i++)
|
for(int i = 0; i < list.tagCount(); i++)
|
||||||
@ -160,8 +166,8 @@ public class TileEntityMachineElectricFurnace extends TileEntityLoadedBase imple
|
|||||||
@Override
|
@Override
|
||||||
public void writeToNBT(NBTTagCompound nbt) {
|
public void writeToNBT(NBTTagCompound nbt) {
|
||||||
super.writeToNBT(nbt);
|
super.writeToNBT(nbt);
|
||||||
nbt.setLong("powerTime", power);
|
nbt.setLong("power", power);
|
||||||
nbt.setInteger("cookTime", dualCookTime);
|
nbt.setInteger("progress", progress);
|
||||||
NBTTagList list = new NBTTagList();
|
NBTTagList list = new NBTTagList();
|
||||||
|
|
||||||
for(int i = 0; i < slots.length; i++)
|
for(int i = 0; i < slots.length; i++)
|
||||||
@ -200,7 +206,7 @@ public class TileEntityMachineElectricFurnace extends TileEntityLoadedBase imple
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getDiFurnaceProgressScaled(int i) {
|
public int getDiFurnaceProgressScaled(int i) {
|
||||||
return (dualCookTime * i) / processingSpeed;
|
return (progress * i) / MaxProgress;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getPowerRemainingScaled(long i) {
|
public long getPowerRemainingScaled(long i) {
|
||||||
@ -212,7 +218,7 @@ public class TileEntityMachineElectricFurnace extends TileEntityLoadedBase imple
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isProcessing() {
|
public boolean isProcessing() {
|
||||||
return this.dualCookTime > 0;
|
return this.progress > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canProcess() {
|
public boolean canProcess() {
|
||||||
@ -279,25 +285,45 @@ public class TileEntityMachineElectricFurnace extends TileEntityLoadedBase imple
|
|||||||
|
|
||||||
this.updateConnections();
|
this.updateConnections();
|
||||||
|
|
||||||
|
this.consumption = 50;
|
||||||
|
this.MaxProgress = 100;
|
||||||
|
|
||||||
|
UpgradeManager.eval(slots, 3, 3);
|
||||||
|
|
||||||
|
int speedLevel = UpgradeManager.getLevel(UpgradeType.SPEED);
|
||||||
|
int powerLevel = UpgradeManager.getLevel(UpgradeType.POWER);
|
||||||
|
|
||||||
|
MaxProgress -= speedLevel * 25;
|
||||||
|
consumption += speedLevel * 50;
|
||||||
|
MaxProgress += powerLevel * 10;
|
||||||
|
consumption -= powerLevel * 15;
|
||||||
|
|
||||||
|
|
||||||
|
NBTTagCompound data = new NBTTagCompound();
|
||||||
|
data.setLong("power", this.power);
|
||||||
|
data.setInteger("MaxProgress", this.MaxProgress);
|
||||||
|
data.setInteger("progress", this.progress);
|
||||||
|
this.networkPack(data, 50);
|
||||||
|
|
||||||
if(hasPower() && canProcess())
|
if(hasPower() && canProcess())
|
||||||
{
|
{
|
||||||
dualCookTime++;
|
progress++;
|
||||||
|
|
||||||
power -= 50;
|
power -= consumption;
|
||||||
|
|
||||||
if(this.dualCookTime == TileEntityMachineElectricFurnace.processingSpeed)
|
if(this.progress == MaxProgress)
|
||||||
{
|
{
|
||||||
this.dualCookTime = 0;
|
this.progress = 0;
|
||||||
this.processItem();
|
this.processItem();
|
||||||
flag1 = true;
|
flag1 = true;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
dualCookTime = 0;
|
progress = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean trigger = true;
|
boolean trigger = true;
|
||||||
|
|
||||||
if(hasPower() && canProcess() && this.dualCookTime == 0)
|
if(hasPower() && canProcess() && this.progress == 0)
|
||||||
{
|
{
|
||||||
trigger = false;
|
trigger = false;
|
||||||
}
|
}
|
||||||
@ -305,13 +331,11 @@ public class TileEntityMachineElectricFurnace extends TileEntityLoadedBase imple
|
|||||||
if(trigger)
|
if(trigger)
|
||||||
{
|
{
|
||||||
flag1 = true;
|
flag1 = true;
|
||||||
MachineElectricFurnace.updateBlockState(this.dualCookTime > 0, this.worldObj, this.xCoord, this.yCoord, this.zCoord);
|
MachineElectricFurnace.updateBlockState(this.progress > 0, this.worldObj, this.xCoord, this.yCoord, this.zCoord);
|
||||||
}
|
}
|
||||||
|
|
||||||
power = Library.chargeTEFromItems(slots, 0, power, maxPower);
|
power = Library.chargeTEFromItems(slots, 0, power, maxPower);
|
||||||
|
|
||||||
PacketDispatcher.wrapper.sendToAllAround(new AuxElectricityPacket(xCoord, yCoord, zCoord, power), new TargetPoint(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, 50));
|
|
||||||
PacketDispatcher.wrapper.sendToAllAround(new AuxGaugePacket(xCoord, yCoord, zCoord, dualCookTime, 0), new TargetPoint(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, 50));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -320,13 +344,18 @@ public class TileEntityMachineElectricFurnace extends TileEntityLoadedBase imple
|
|||||||
this.markDirty();
|
this.markDirty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateConnections() {
|
private void updateConnections() {
|
||||||
|
|
||||||
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
|
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
|
||||||
this.trySubscribe(worldObj, xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, dir);
|
this.trySubscribe(worldObj, xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void networkUnpack(NBTTagCompound nbt) {
|
||||||
|
this.power = nbt.getLong("power");
|
||||||
|
this.MaxProgress = nbt.getInteger("MaxProgress");
|
||||||
|
this.progress = nbt.getInteger("progress");
|
||||||
|
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
public void setPower(long i) {
|
public void setPower(long i) {
|
||||||
power = i;
|
power = i;
|
||||||
@ -343,4 +372,10 @@ public class TileEntityMachineElectricFurnace extends TileEntityLoadedBase imple
|
|||||||
public long getMaxPower() {
|
public long getMaxPower() {
|
||||||
return maxPower;
|
return maxPower;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
After Width: | Height: | Size: 510 B |
|
Before Width: | Height: | Size: 464 B After Width: | Height: | Size: 528 B |
|
Before Width: | Height: | Size: 457 B After Width: | Height: | Size: 588 B |
|
After Width: | Height: | Size: 577 B |
|
After Width: | Height: | Size: 490 B |
|
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 3.6 KiB |