Merge pull request #641 from Adam29Adam29/master

Electric Furnace Rework
This commit is contained in:
HbmMods 2022-06-24 08:10:45 +02:00 committed by GitHub
commit bf2224b880
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 87 additions and 33 deletions

View File

@ -34,6 +34,8 @@ public class MachineElectricFurnace extends BlockContainer {
@SideOnly(Side.CLIENT)
private IIcon iconFront;
private IIcon iconTop;
private IIcon iconBottom;
public MachineElectricFurnace(boolean blockState) {
super(Material.iron);
@ -45,7 +47,9 @@ public class MachineElectricFurnace extends BlockContainer {
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
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
@ -53,7 +57,7 @@ public class MachineElectricFurnace extends BlockContainer {
public IIcon getIcon(int side, int metadata) {
//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.blockIcon);
return metadata == 0 && side == 3 ? this.iconFront : (side == metadata ? this.iconFront : side == 0 ? this.iconBottom : side == 1 ? this.iconTop : this.blockIcon);
}
@Override
@ -262,6 +266,5 @@ public class MachineElectricFurnace extends BlockContainer {
@SideOnly(Side.CLIENT)
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);}
}

View File

@ -1,6 +1,7 @@
package com.hbm.inventory.container;
import com.hbm.inventory.SlotSmelting;
import com.hbm.inventory.SlotUpgrade;
import com.hbm.tileentity.machine.TileEntityMachineElectricFurnace;
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, 1, 56, 17));
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 j = 0; j < 9; j++) {

View File

@ -10,6 +10,7 @@ import org.lwjgl.opengl.GL11;
import com.hbm.inventory.container.ContainerElectricFurnace;
import com.hbm.lib.RefStrings;
import com.hbm.tileentity.machine.TileEntityMachineElectricFurnace;
import com.hbm.util.I18nUtil;
public class GUIMachineElectricFurnace extends GuiInfoContainer {
@ -29,6 +30,12 @@ public class GUIMachineElectricFurnace extends GuiInfoContainer {
super.drawScreen(mouseX, mouseY, f);
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
@ -64,11 +71,13 @@ public class GUIMachineElectricFurnace extends GuiInfoContainer {
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);
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);
}
}

View File

@ -37,6 +37,8 @@ public class ItemMachineUpgrade extends Item {
list.add("Delay -" + (15 * this.tier) + "% / Consumption +" + (300 * this.tier) + "HE/t");
list.add(EnumChatFormatting.RED + "Laser Miner:");
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("Delay -" + (25 * this.tier) + "% / Consumption +" + (300 * this.tier) + "HE/t");
list.add(EnumChatFormatting.RED + "Chemical Plant:");
@ -69,6 +71,8 @@ public class ItemMachineUpgrade extends Item {
if(this.type == UpgradeType.POWER) {
list.add(EnumChatFormatting.RED + "Mining Drill:");
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("Consumption -" + (30 * this.tier) + "HE/t / Delay +" + (5 * this.tier) + "%");
list.add(EnumChatFormatting.RED + "Chemical Plant:");

View File

@ -170,7 +170,7 @@ public class AuxGaugePacket implements IMessage {
TileEntityMachineElectricFurnace furn = (TileEntityMachineElectricFurnace)te;
if(m.id == 0)
furn.dualCookTime = m.value;
furn.progress = m.value;
}
if (te instanceof TileEntityMachineArcFurnace) {
TileEntityMachineArcFurnace furn = (TileEntityMachineArcFurnace)te;

View File

@ -1,11 +1,13 @@
package com.hbm.tileentity.machine;
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.packet.AuxElectricityPacket;
import com.hbm.packet.AuxGaugePacket;
import com.hbm.packet.PacketDispatcher;
import com.hbm.tileentity.TileEntityLoadedBase;
import com.hbm.tileentity.TileEntityMachineBase;
import api.hbm.energy.IBatteryItem;
import api.hbm.energy.IEnergyUser;
@ -18,14 +20,17 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
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[];
public int dualCookTime;
public int progress;
public long power;
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_bottom = new int[] {2, 0};
@ -33,8 +38,9 @@ public class TileEntityMachineElectricFurnace extends TileEntityLoadedBase imple
private String customName;
public TileEntityMachineElectricFurnace() {
slots = new ItemStack[3];
public TileEntityMachineElectricFurnace(){
super(4);
slots = new ItemStack[4];
}
@Override
@ -142,8 +148,8 @@ public class TileEntityMachineElectricFurnace extends TileEntityLoadedBase imple
super.readFromNBT(nbt);
NBTTagList list = nbt.getTagList("items", 10);
this.power = nbt.getLong("powerTime");
this.dualCookTime = nbt.getInteger("cookTime");
this.power = nbt.getLong("power");
this.progress = nbt.getInteger("progress");
slots = new ItemStack[getSizeInventory()];
for(int i = 0; i < list.tagCount(); i++)
@ -160,8 +166,8 @@ public class TileEntityMachineElectricFurnace extends TileEntityLoadedBase imple
@Override
public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt);
nbt.setLong("powerTime", power);
nbt.setInteger("cookTime", dualCookTime);
nbt.setLong("power", power);
nbt.setInteger("progress", progress);
NBTTagList list = new NBTTagList();
for(int i = 0; i < slots.length; i++)
@ -198,21 +204,21 @@ public class TileEntityMachineElectricFurnace extends TileEntityLoadedBase imple
return false;
}
public int getDiFurnaceProgressScaled(int i) {
return (dualCookTime * i) / processingSpeed;
return (progress * i) / MaxProgress;
}
public long getPowerRemainingScaled(long i) {
return (power * i) / maxPower;
}
public boolean hasPower() {
return power > 0;
}
public boolean isProcessing() {
return this.dualCookTime > 0;
return this.progress > 0;
}
public boolean canProcess() {
@ -278,26 +284,46 @@ public class TileEntityMachineElectricFurnace extends TileEntityLoadedBase imple
if(!worldObj.isRemote) {
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())
{
dualCookTime++;
progress++;
power -= 50;
power -= consumption;
if(this.dualCookTime == TileEntityMachineElectricFurnace.processingSpeed)
if(this.progress == MaxProgress)
{
this.dualCookTime = 0;
this.progress = 0;
this.processItem();
flag1 = true;
}
}else{
dualCookTime = 0;
progress = 0;
}
boolean trigger = true;
if(hasPower() && canProcess() && this.dualCookTime == 0)
if(hasPower() && canProcess() && this.progress == 0)
{
trigger = false;
}
@ -305,13 +331,11 @@ public class TileEntityMachineElectricFurnace extends TileEntityLoadedBase imple
if(trigger)
{
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);
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();
}
}
private void updateConnections() {
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
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
public void setPower(long i) {
power = i;
@ -343,4 +372,10 @@ public class TileEntityMachineElectricFurnace extends TileEntityLoadedBase imple
public long getMaxPower() {
return maxPower;
}
}
@Override
public String getName() {
// TODO Auto-generated method stub
return null;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 510 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 464 B

After

Width:  |  Height:  |  Size: 528 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 457 B

After

Width:  |  Height:  |  Size: 588 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 577 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 490 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB