Several bugfixes, overhaul of TileEntity-based upgrade management
This commit is contained in:
parent
081e204dbf
commit
7a7b398f31
18 changed files with 302 additions and 367 deletions
|
@ -39,8 +39,8 @@ public class GuiAdvancedElectricMachine extends GuiContainer
|
|||
|
||||
fontRenderer.drawString(tileEntity.fullName, 45, 6, 0x404040);
|
||||
fontRenderer.drawString("Inventory", 8, (ySize - 96) + 2, 0x404040);
|
||||
fontRenderer.drawString("S:" + (tileEntity.speedMultiplier+1) + "x", 179, 47, 0x404040);
|
||||
fontRenderer.drawString("E:" + (tileEntity.energyMultiplier+1) + "x", 179, 57, 0x404040);
|
||||
fontRenderer.drawString("S:" + (tileEntity.getSpeedMultiplier()+1) + "x", 179, 47, 0x404040);
|
||||
fontRenderer.drawString("E:" + (tileEntity.getEnergyMultiplier()+1) + "x", 179, 57, 0x404040);
|
||||
|
||||
if(xAxis >= 165 && xAxis <= 169 && yAxis >= 17 && yAxis <= 69)
|
||||
{
|
||||
|
@ -83,7 +83,7 @@ public class GuiAdvancedElectricMachine extends GuiContainer
|
|||
displayInt = tileEntity.getScaledProgress(24);
|
||||
drawTexturedModalRect(guiWidth + 79, guiHeight + 39, 176 + 26, 0, displayInt + 1, 7);
|
||||
|
||||
displayInt = tileEntity.getScaledUpgradeProgress(14);
|
||||
displayInt = tileEntity.upgradeComponent.getScaledUpgradeProgress(14);
|
||||
drawTexturedModalRect(guiWidth + 180, guiHeight + 30, 176 + 26, 71, 10, displayInt);
|
||||
|
||||
redstoneControl.renderBackground(xAxis, yAxis, guiWidth, guiHeight);
|
||||
|
|
|
@ -39,8 +39,8 @@ public class GuiElectricMachine extends GuiContainer
|
|||
|
||||
fontRenderer.drawString(tileEntity.fullName, 45, 6, 0x404040);
|
||||
fontRenderer.drawString("Inventory", 8, (ySize - 96) + 2, 0x404040);
|
||||
fontRenderer.drawString("S:" + (tileEntity.speedMultiplier+1) + "x", 179, 47, 0x404040);
|
||||
fontRenderer.drawString("E:" + (tileEntity.energyMultiplier+1) + "x", 179, 57, 0x404040);
|
||||
fontRenderer.drawString("S:" + (tileEntity.getSpeedMultiplier()+1) + "x", 179, 47, 0x404040);
|
||||
fontRenderer.drawString("E:" + (tileEntity.getEnergyMultiplier()+1) + "x", 179, 57, 0x404040);
|
||||
|
||||
if(xAxis >= 165 && xAxis <= 169 && yAxis >= 17 && yAxis <= 69)
|
||||
{
|
||||
|
@ -80,7 +80,7 @@ public class GuiElectricMachine extends GuiContainer
|
|||
displayInt = tileEntity.getScaledProgress(24);
|
||||
drawTexturedModalRect(guiWidth + 79, guiHeight + 39, 176 + 26, 0, displayInt + 1, 7);
|
||||
|
||||
displayInt = tileEntity.getScaledUpgradeProgress(14);
|
||||
displayInt = tileEntity.upgradeComponent.getScaledUpgradeProgress(14);
|
||||
drawTexturedModalRect(guiWidth + 180, guiHeight + 30, 176 + 26, 59, 10, displayInt);
|
||||
|
||||
redstoneControl.renderBackground(xAxis, yAxis, guiWidth, guiHeight);
|
||||
|
|
|
@ -42,8 +42,8 @@ public class GuiFactory extends GuiContainer
|
|||
fontRenderer.drawString(tileEntity.fullName, 48, 4, 0x404040);
|
||||
fontRenderer.drawString("Inventory", 8, (ySize - 93) + 2, 0x404040);
|
||||
fontRenderer.drawString(RecipeType.values()[tileEntity.recipeType].getName(), 124, (ySize - 93) + 2, 0x404040);
|
||||
fontRenderer.drawString("S:" + (tileEntity.speedMultiplier+1) + "x", 179, 47, 0x404040);
|
||||
fontRenderer.drawString("E:" + (tileEntity.energyMultiplier+1) + "x", 179, 57, 0x404040);
|
||||
fontRenderer.drawString("S:" + (tileEntity.getSpeedMultiplier()+1) + "x", 179, 47, 0x404040);
|
||||
fontRenderer.drawString("E:" + (tileEntity.getEnergyMultiplier()+1) + "x", 179, 57, 0x404040);
|
||||
|
||||
if(xAxis >= 165 && xAxis <= 169 && yAxis >= 17 && yAxis <= 69)
|
||||
{
|
||||
|
@ -80,7 +80,7 @@ public class GuiFactory extends GuiContainer
|
|||
displayInt = tileEntity.getScaledEnergyLevel(52);
|
||||
drawTexturedModalRect(guiWidth + 165, guiHeight + 17 + 52 - displayInt, 176 + 26, 52 - displayInt, 4, displayInt);
|
||||
|
||||
displayInt = tileEntity.getScaledUpgradeProgress(14);
|
||||
displayInt = tileEntity.upgradeComponent.getScaledUpgradeProgress(14);
|
||||
drawTexturedModalRect(guiWidth + 180, guiHeight + 30, 176 + 26, 72, 10, displayInt);
|
||||
|
||||
displayInt = tileEntity.getScaledRecipeProgress(15);
|
||||
|
|
|
@ -43,8 +43,8 @@ public class GuiMetallurgicInfuser extends GuiContainer
|
|||
|
||||
fontRenderer.drawString(tileEntity.fullName, 45, 6, 0x404040);
|
||||
fontRenderer.drawString("Inventory", 8, (ySize - 96) + 2, 0x404040);
|
||||
fontRenderer.drawString("S:" + (tileEntity.speedMultiplier+1) + "x", 179, 47, 0x404040);
|
||||
fontRenderer.drawString("E:" + (tileEntity.energyMultiplier+1) + "x", 179, 57, 0x404040);
|
||||
fontRenderer.drawString("S:" + (tileEntity.getSpeedMultiplier()+1) + "x", 179, 47, 0x404040);
|
||||
fontRenderer.drawString("E:" + (tileEntity.getEnergyMultiplier()+1) + "x", 179, 57, 0x404040);
|
||||
|
||||
if(xAxis >= 165 && xAxis <= 169 && yAxis >= 17 && yAxis <= 69)
|
||||
{
|
||||
|
@ -74,7 +74,7 @@ public class GuiMetallurgicInfuser extends GuiContainer
|
|||
displayInt = tileEntity.getScaledEnergyLevel(52);
|
||||
drawTexturedModalRect(guiWidth + 165, guiHeight + 17 + 52 - displayInt, 176 + 26, 52 - displayInt, 4, displayInt);
|
||||
|
||||
displayInt = tileEntity.getScaledUpgradeProgress(14);
|
||||
displayInt = tileEntity.upgradeComponent.getScaledUpgradeProgress(14);
|
||||
drawTexturedModalRect(guiWidth + 180, guiHeight + 30, 176 + 26, 60, 10, displayInt);
|
||||
|
||||
if(tileEntity.type != null)
|
||||
|
|
|
@ -23,11 +23,12 @@ public class GuiTheoreticalElementizer extends GuiAdvancedElectricMachine
|
|||
|
||||
if(tileEntity.isActive)
|
||||
{
|
||||
displayText = "Status: " + (int)(((float)tileEntity.operatingTicks/MekanismUtils.getTicks(tileEntity.speedMultiplier, tileEntity.TICKS_REQUIRED))*100) + "%";
|
||||
displayText = "Status: " + (int)(((float)tileEntity.operatingTicks/MekanismUtils.getTicks(tileEntity.getSpeedMultiplier(), tileEntity.TICKS_REQUIRED))*100) + "%";
|
||||
}
|
||||
else {
|
||||
displayText = "Status: " + EnumColor.DARK_RED + "Off";
|
||||
}
|
||||
|
||||
fontRenderer.drawString(displayText, 80, 60, 0x404040);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -432,12 +432,12 @@ public class EnergyNetwork extends DynamicNetwork<TileEntity, EnergyNetwork>
|
|||
@Override
|
||||
public String getNeeded()
|
||||
{
|
||||
return ElectricityDisplay.getDisplay((float) (getEnergyNeeded(new ArrayList<TileEntity>())*Mekanism.TO_UE), ElectricityDisplay.ElectricUnit.JOULES);
|
||||
return ElectricityDisplay.getDisplay((float)(getEnergyNeeded(new ArrayList<TileEntity>())*Mekanism.TO_UE), ElectricityDisplay.ElectricUnit.JOULES);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFlow()
|
||||
{
|
||||
return ElectricityDisplay.getDisplay((float) (getPower()*Mekanism.TO_UE), ElectricityDisplay.ElectricUnit.WATT);
|
||||
return ElectricityDisplay.getDisplay((float)(getPower()*Mekanism.TO_UE), ElectricityDisplay.ElectricUnit.WATT);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package mekanism.common;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
@ -16,6 +17,8 @@ import net.minecraft.tileentity.TileEntity;
|
|||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.Event;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
|
@ -49,6 +52,26 @@ public class FluidNetwork extends DynamicNetwork<IFluidHandler, FluidNetwork>
|
|||
register();
|
||||
}
|
||||
|
||||
public int getTotalNeeded(List<TileEntity> ignored)
|
||||
{
|
||||
int toReturn = 0;
|
||||
|
||||
for(IFluidHandler handler : possibleAcceptors)
|
||||
{
|
||||
ForgeDirection side = acceptorDirections.get(handler).getOpposite();
|
||||
|
||||
for(Fluid fluid : FluidRegistry.getRegisteredFluids().values())
|
||||
{
|
||||
int filled = handler.fill(side, new FluidStack(fluid, Integer.MAX_VALUE), false);
|
||||
|
||||
toReturn += filled;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public int emit(FluidStack fluidToSend, boolean doTransfer, TileEntity emitter)
|
||||
{
|
||||
List availableAcceptors = Arrays.asList(getAcceptors(fluidToSend).toArray());
|
||||
|
@ -271,7 +294,7 @@ public class FluidNetwork extends DynamicNetwork<IFluidHandler, FluidNetwork>
|
|||
@Override
|
||||
public String getNeeded()
|
||||
{
|
||||
return "Undefined for Fluid networks";
|
||||
return "Fluid needed (any type): " + (float)getTotalNeeded(new ArrayList())/1000F + " buckets";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
20
common/mekanism/common/ITileComponent.java
Normal file
20
common/mekanism/common/ITileComponent.java
Normal file
|
@ -0,0 +1,20 @@
|
|||
package mekanism.common;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public interface ITileComponent
|
||||
{
|
||||
public void tick();
|
||||
|
||||
public void read(NBTTagCompound nbtTags);
|
||||
|
||||
public void read(ByteArrayDataInput dataStream);
|
||||
|
||||
public void write(NBTTagCompound nbtTags);
|
||||
|
||||
public void write(ArrayList data);
|
||||
}
|
|
@ -9,11 +9,11 @@ import net.minecraft.tileentity.TileEntity;
|
|||
import net.minecraft.util.ChatMessageComponent;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ItemEnergyMeter extends ItemEnergized
|
||||
public class ItemNetworkReader extends ItemEnergized
|
||||
{
|
||||
public static double ENERGY_PER_USE = 400;
|
||||
|
||||
public ItemEnergyMeter(int id)
|
||||
public ItemNetworkReader(int id)
|
||||
{
|
||||
super(id, 60000, 120);
|
||||
}
|
||||
|
@ -31,13 +31,13 @@ public class ItemEnergyMeter extends ItemEnergized
|
|||
{
|
||||
setEnergy(stack, getEnergy(stack)-ENERGY_PER_USE);
|
||||
|
||||
ITransmitter cable = (ITransmitter)tileEntity;
|
||||
ITransmitter transmitter = (ITransmitter)tileEntity;
|
||||
|
||||
player.sendChatToPlayer(ChatMessageComponent.func_111066_d(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " -------------"));
|
||||
player.sendChatToPlayer(ChatMessageComponent.func_111066_d(EnumColor.GREY + " *Cables: " + EnumColor.DARK_GREY + cable.getNetworkSize()));
|
||||
player.sendChatToPlayer(ChatMessageComponent.func_111066_d(EnumColor.GREY + " *Acceptors: " + EnumColor.DARK_GREY + cable.getNetworkAcceptorSize()));
|
||||
player.sendChatToPlayer(ChatMessageComponent.func_111066_d(EnumColor.GREY + " *Needed energy: " + EnumColor.DARK_GREY + cable.getNetworkNeeded()));
|
||||
player.sendChatToPlayer(ChatMessageComponent.func_111066_d(EnumColor.GREY + " *Power: " + EnumColor.DARK_GREY + cable.getNetworkFlow() ));
|
||||
player.sendChatToPlayer(ChatMessageComponent.func_111066_d(EnumColor.GREY + " *Transmitters: " + EnumColor.DARK_GREY + transmitter.getNetworkSize()));
|
||||
player.sendChatToPlayer(ChatMessageComponent.func_111066_d(EnumColor.GREY + " *Acceptors: " + EnumColor.DARK_GREY + transmitter.getNetworkAcceptorSize()));
|
||||
player.sendChatToPlayer(ChatMessageComponent.func_111066_d(EnumColor.GREY + " *Needed: " + EnumColor.DARK_GREY + transmitter.getNetworkNeeded()));
|
||||
player.sendChatToPlayer(ChatMessageComponent.func_111066_d(EnumColor.GREY + " *Power: " + EnumColor.DARK_GREY + transmitter.getNetworkFlow() ));
|
||||
player.sendChatToPlayer(ChatMessageComponent.func_111066_d(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[=======]" + EnumColor.GREY + " -------------"));
|
||||
}
|
||||
}
|
|
@ -156,7 +156,7 @@ public class Mekanism
|
|||
public static Item PortableTeleporter;
|
||||
public static Item TeleportationCore;
|
||||
public static Item Configurator;
|
||||
public static Item EnergyMeter;
|
||||
public static Item NetworkReader;
|
||||
|
||||
//Blocks
|
||||
public static Block BasicBlock;
|
||||
|
@ -374,7 +374,7 @@ public class Mekanism
|
|||
CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(Robit.getUnchargedItem(), new Object[] {
|
||||
" S ", "ECE", "OIO", Character.valueOf('S'), "ingotSteel", Character.valueOf('E'), EnergyTablet.getUnchargedItem(), Character.valueOf('C'), AtomicCore, Character.valueOf('O'), "ingotRefinedObsidian", Character.valueOf('I'), new ItemStack(MachineBlock, 1, 13)
|
||||
}));
|
||||
CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(new ItemStack(EnergyMeter), new Object[] {
|
||||
CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(new ItemStack(NetworkReader), new Object[] {
|
||||
" G ", "AEA", " I ", Character.valueOf('G'), Block.glass, Character.valueOf('A'), EnrichedAlloy, Character.valueOf('E'), EnergyTablet.getUnchargedItem(), Character.valueOf('I'), "ingotSteel"
|
||||
}));
|
||||
|
||||
|
@ -493,7 +493,7 @@ public class Mekanism
|
|||
LanguageRegistry.addName(PortableTeleporter, "Portable Teleporter");
|
||||
LanguageRegistry.addName(TeleportationCore, "Teleportation Core");
|
||||
LanguageRegistry.addName(Configurator, "Configurator");
|
||||
LanguageRegistry.addName(EnergyMeter, "EnergyMeter");
|
||||
LanguageRegistry.addName(NetworkReader, "NetworkReader");
|
||||
|
||||
//Localization for BasicBlock
|
||||
LanguageRegistry.instance().addStringLocalization("tile.BasicBlock.OsmiumBlock.name", "Osmium Block");
|
||||
|
@ -613,7 +613,7 @@ public class Mekanism
|
|||
Clump = new ItemClump(configuration.getItem("Clump", 11219).getInt()-256);
|
||||
DirtyDust = new ItemDirtyDust(configuration.getItem("DirtyDust", 11220).getInt()-256);
|
||||
Configurator = new ItemConfigurator(configuration.getItem("Configurator", 11221).getInt()).setUnlocalizedName("Configurator");
|
||||
EnergyMeter = new ItemEnergyMeter(configuration.getItem("EnergyMeter", 11222).getInt()).setUnlocalizedName("EnergyMeter");
|
||||
NetworkReader = new ItemNetworkReader(configuration.getItem("NetworkReader", 11222).getInt()).setUnlocalizedName("NetworkReader");
|
||||
configuration.save();
|
||||
|
||||
//Registrations
|
||||
|
@ -643,7 +643,7 @@ public class Mekanism
|
|||
GameRegistry.registerItem(Clump, "Clump");
|
||||
GameRegistry.registerItem(DirtyDust, "DirtyDust");
|
||||
GameRegistry.registerItem(Configurator, "Configurator");
|
||||
GameRegistry.registerItem(EnergyMeter, "EnergyMeter");
|
||||
GameRegistry.registerItem(NetworkReader, "NetworkReader");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -9,6 +9,7 @@ import mekanism.api.SideData;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
||||
import dan200.computer.api.IComputerAccess;
|
||||
|
@ -52,8 +53,11 @@ public abstract class TileEntityAdvancedElectricMachine extends TileEntityBasicM
|
|||
sideConfig = new byte[] {2, 1, 0, 4, 5, 3};
|
||||
|
||||
inventory = new ItemStack[5];
|
||||
|
||||
SECONDARY_ENERGY_PER_TICK = secondaryPerTick;
|
||||
MAX_SECONDARY_ENERGY = maxSecondaryEnergy;
|
||||
|
||||
upgradeComponent = new UpgradeTileComponent(this, 4);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -72,66 +76,18 @@ public abstract class TileEntityAdvancedElectricMachine extends TileEntityBasicM
|
|||
{
|
||||
ChargeUtils.discharge(3, this);
|
||||
|
||||
if(inventory[4] != null)
|
||||
{
|
||||
if(inventory[4].isItemEqual(new ItemStack(Mekanism.EnergyUpgrade)) && energyMultiplier < 8)
|
||||
{
|
||||
if(upgradeTicks < UPGRADE_TICKS_REQUIRED)
|
||||
{
|
||||
upgradeTicks++;
|
||||
}
|
||||
else if(upgradeTicks == UPGRADE_TICKS_REQUIRED)
|
||||
{
|
||||
upgradeTicks = 0;
|
||||
energyMultiplier++;
|
||||
|
||||
inventory[4].stackSize--;
|
||||
|
||||
if(inventory[4].stackSize == 0)
|
||||
{
|
||||
inventory[4] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(inventory[4].isItemEqual(new ItemStack(Mekanism.SpeedUpgrade)) && speedMultiplier < 8)
|
||||
{
|
||||
if(upgradeTicks < UPGRADE_TICKS_REQUIRED)
|
||||
{
|
||||
upgradeTicks++;
|
||||
}
|
||||
else if(upgradeTicks == UPGRADE_TICKS_REQUIRED)
|
||||
{
|
||||
upgradeTicks = 0;
|
||||
speedMultiplier++;
|
||||
|
||||
inventory[4].stackSize--;
|
||||
|
||||
if(inventory[4].stackSize == 0)
|
||||
{
|
||||
inventory[4] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
upgradeTicks = 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
upgradeTicks = 0;
|
||||
}
|
||||
|
||||
handleSecondaryFuel();
|
||||
|
||||
if(canOperate() && MekanismUtils.canFunction(this) && electricityStored >= MekanismUtils.getEnergyPerTick(speedMultiplier, energyMultiplier, ENERGY_PER_TICK) && secondaryEnergyStored >= MekanismUtils.getEnergyPerTick(speedMultiplier, energyMultiplier, SECONDARY_ENERGY_PER_TICK))
|
||||
if(canOperate() && MekanismUtils.canFunction(this) && electricityStored >= MekanismUtils.getEnergyPerTick(getSpeedMultiplier(), getEnergyMultiplier(), ENERGY_PER_TICK) && secondaryEnergyStored >= MekanismUtils.getEnergyPerTick(getSpeedMultiplier(), getEnergyMultiplier(), SECONDARY_ENERGY_PER_TICK))
|
||||
{
|
||||
setActive(true);
|
||||
|
||||
operatingTicks++;
|
||||
|
||||
secondaryEnergyStored -= MekanismUtils.getEnergyPerTick(speedMultiplier, energyMultiplier, SECONDARY_ENERGY_PER_TICK);
|
||||
electricityStored -= MekanismUtils.getEnergyPerTick(speedMultiplier, energyMultiplier, ENERGY_PER_TICK);
|
||||
secondaryEnergyStored -= MekanismUtils.getEnergyPerTick(getSpeedMultiplier(), getEnergyMultiplier(), SECONDARY_ENERGY_PER_TICK);
|
||||
electricityStored -= MekanismUtils.getEnergyPerTick(getSpeedMultiplier(), getEnergyMultiplier(), ENERGY_PER_TICK);
|
||||
|
||||
if((operatingTicks) >= MekanismUtils.getTicks(speedMultiplier, TICKS_REQUIRED))
|
||||
if((operatingTicks) >= MekanismUtils.getTicks(getSpeedMultiplier(), TICKS_REQUIRED))
|
||||
{
|
||||
operate();
|
||||
|
||||
|
@ -331,7 +287,7 @@ public abstract class TileEntityAdvancedElectricMachine extends TileEntityBasicM
|
|||
switch(method)
|
||||
{
|
||||
case 0:
|
||||
return new Object[] {electricityStored};
|
||||
return new Object[] {getEnergy()};
|
||||
case 1:
|
||||
return new Object[] {secondaryEnergyStored};
|
||||
case 2:
|
||||
|
@ -343,9 +299,9 @@ public abstract class TileEntityAdvancedElectricMachine extends TileEntityBasicM
|
|||
case 5:
|
||||
return new Object[] {canOperate()};
|
||||
case 6:
|
||||
return new Object[] {MekanismUtils.getEnergy(energyMultiplier, MAX_ELECTRICITY)};
|
||||
return new Object[] {MekanismUtils.getEnergy(getEnergyMultiplier(), getMaxEnergy())};
|
||||
case 7:
|
||||
return new Object[] {(MekanismUtils.getEnergy(energyMultiplier, MAX_ELECTRICITY)-electricityStored)};
|
||||
return new Object[] {(MekanismUtils.getEnergy(getEnergyMultiplier(), getMaxEnergy())-getEnergy())};
|
||||
default:
|
||||
System.err.println("[Mekanism] Attempted to call unknown method with computer ID " + computer.getID());
|
||||
return new Object[] {"Unknown command."};
|
||||
|
|
|
@ -31,9 +31,16 @@ public abstract class TileEntityBasicBlock extends TileEntity implements IWrench
|
|||
/** A timer used to send packets to clients. */
|
||||
public int packetTick;
|
||||
|
||||
public Set<ITileComponent> components = new HashSet<ITileComponent>();
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
for(ITileComponent component : components)
|
||||
{
|
||||
component.tick();
|
||||
}
|
||||
|
||||
onUpdate();
|
||||
|
||||
if(!worldObj.isRemote)
|
||||
|
|
|
@ -42,18 +42,6 @@ public abstract class TileEntityBasicMachine extends TileEntityElectricBlock imp
|
|||
/** Ticks required to operate -- or smelt an item. */
|
||||
public int TICKS_REQUIRED;
|
||||
|
||||
/** This machine's speed multiplier. */
|
||||
public int speedMultiplier;
|
||||
|
||||
/** This machine's energy multiplier. */
|
||||
public int energyMultiplier;
|
||||
|
||||
/** How long it takes this machine to install an upgrade. */
|
||||
public int UPGRADE_TICKS_REQUIRED = 40;
|
||||
|
||||
/** How many upgrade ticks have progressed. */
|
||||
public int upgradeTicks;
|
||||
|
||||
/** How many ticks must pass until this block's active state can sync with the client. */
|
||||
public int updateDelay;
|
||||
|
||||
|
@ -67,7 +55,9 @@ public abstract class TileEntityBasicMachine extends TileEntityElectricBlock imp
|
|||
public ResourceLocation guiLocation;
|
||||
|
||||
/** This machine's current RedstoneControl type. */
|
||||
public RedstoneControl controlType;
|
||||
public RedstoneControl controlType = RedstoneControl.DISABLED;
|
||||
|
||||
public UpgradeTileComponent upgradeComponent;
|
||||
|
||||
/**
|
||||
* The foundation of all machines - a simple tile entity with a facing, active state, initialized state, sound effect, and animated texture.
|
||||
|
@ -86,7 +76,6 @@ public abstract class TileEntityBasicMachine extends TileEntityElectricBlock imp
|
|||
soundURL = soundPath;
|
||||
guiLocation = location;
|
||||
isActive = false;
|
||||
controlType = RedstoneControl.DISABLED;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -117,12 +106,11 @@ public abstract class TileEntityBasicMachine extends TileEntityElectricBlock imp
|
|||
public void readFromNBT(NBTTagCompound nbtTags)
|
||||
{
|
||||
super.readFromNBT(nbtTags);
|
||||
|
||||
upgradeComponent.read(nbtTags);
|
||||
|
||||
operatingTicks = nbtTags.getInteger("operatingTicks");
|
||||
clientActive = isActive = nbtTags.getBoolean("isActive");
|
||||
speedMultiplier = nbtTags.getInteger("speedMultiplier");
|
||||
energyMultiplier = nbtTags.getInteger("energyMultiplier");
|
||||
upgradeTicks = nbtTags.getInteger("upgradeTicks");
|
||||
controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")];
|
||||
|
||||
if(nbtTags.hasKey("sideDataStored"))
|
||||
|
@ -139,11 +127,10 @@ public abstract class TileEntityBasicMachine extends TileEntityElectricBlock imp
|
|||
{
|
||||
super.writeToNBT(nbtTags);
|
||||
|
||||
upgradeComponent.write(nbtTags);
|
||||
|
||||
nbtTags.setInteger("operatingTicks", operatingTicks);
|
||||
nbtTags.setBoolean("isActive", isActive);
|
||||
nbtTags.setInteger("speedMultiplier", speedMultiplier);
|
||||
nbtTags.setInteger("energyMultiplier", energyMultiplier);
|
||||
nbtTags.setInteger("upgradeTicks", upgradeTicks);
|
||||
nbtTags.setInteger("controlType", controlType.ordinal());
|
||||
|
||||
nbtTags.setBoolean("sideDataStored", true);
|
||||
|
@ -158,11 +145,11 @@ public abstract class TileEntityBasicMachine extends TileEntityElectricBlock imp
|
|||
public void handlePacketData(ByteArrayDataInput dataStream)
|
||||
{
|
||||
super.handlePacketData(dataStream);
|
||||
|
||||
upgradeComponent.read(dataStream);;
|
||||
|
||||
operatingTicks = dataStream.readInt();
|
||||
isActive = dataStream.readBoolean();
|
||||
speedMultiplier = dataStream.readInt();
|
||||
energyMultiplier = dataStream.readInt();
|
||||
upgradeTicks = dataStream.readInt();
|
||||
controlType = RedstoneControl.values()[dataStream.readInt()];
|
||||
|
||||
for(int i = 0; i < 6; i++)
|
||||
|
@ -177,13 +164,14 @@ public abstract class TileEntityBasicMachine extends TileEntityElectricBlock imp
|
|||
public ArrayList getNetworkedData(ArrayList data)
|
||||
{
|
||||
super.getNetworkedData(data);
|
||||
|
||||
upgradeComponent.write(data);
|
||||
|
||||
data.add(operatingTicks);
|
||||
data.add(isActive);
|
||||
data.add(speedMultiplier);
|
||||
data.add(energyMultiplier);
|
||||
data.add(upgradeTicks);
|
||||
data.add(controlType.ordinal());
|
||||
data.add(sideConfig);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
@ -237,18 +225,13 @@ public abstract class TileEntityBasicMachine extends TileEntityElectricBlock imp
|
|||
*/
|
||||
public int getScaledProgress(int i)
|
||||
{
|
||||
return operatingTicks*i / MekanismUtils.getTicks(speedMultiplier, TICKS_REQUIRED);
|
||||
}
|
||||
|
||||
public int getScaledUpgradeProgress(int i)
|
||||
{
|
||||
return upgradeTicks*i / UPGRADE_TICKS_REQUIRED;
|
||||
return operatingTicks*i / MekanismUtils.getTicks(getSpeedMultiplier(), TICKS_REQUIRED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxEnergy()
|
||||
{
|
||||
return MekanismUtils.getEnergy(energyMultiplier, MAX_ELECTRICITY);
|
||||
return MekanismUtils.getEnergy(getEnergyMultiplier(), MAX_ELECTRICITY);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -275,7 +258,7 @@ public abstract class TileEntityBasicMachine extends TileEntityElectricBlock imp
|
|||
public double transferEnergyToAcceptor(double amount)
|
||||
{
|
||||
double rejects = 0;
|
||||
double neededElectricity = MekanismUtils.getEnergy(energyMultiplier, MAX_ELECTRICITY)-electricityStored;
|
||||
double neededElectricity = MekanismUtils.getEnergy(getEnergyMultiplier(), getMaxEnergy())-getEnergy();
|
||||
|
||||
if(amount <= neededElectricity)
|
||||
{
|
||||
|
@ -352,25 +335,25 @@ public abstract class TileEntityBasicMachine extends TileEntityElectricBlock imp
|
|||
@Override
|
||||
public int getEnergyMultiplier(Object... data)
|
||||
{
|
||||
return energyMultiplier;
|
||||
return upgradeComponent.energyMultiplier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnergyMultiplier(int multiplier, Object... data)
|
||||
{
|
||||
energyMultiplier = multiplier;
|
||||
upgradeComponent.energyMultiplier = multiplier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSpeedMultiplier(Object... data)
|
||||
{
|
||||
return speedMultiplier;
|
||||
return upgradeComponent.speedMultiplier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSpeedMultiplier(int multiplier, Object... data)
|
||||
{
|
||||
speedMultiplier = multiplier;
|
||||
upgradeComponent.speedMultiplier = multiplier;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -32,6 +32,8 @@ public abstract class TileEntityElectricMachine extends TileEntityBasicMachine
|
|||
sideConfig = new byte[] {2, 1, 0, 0, 4, 3};
|
||||
|
||||
inventory = new ItemStack[4];
|
||||
|
||||
upgradeComponent = new UpgradeTileComponent(this, 3);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -43,69 +45,21 @@ public abstract class TileEntityElectricMachine extends TileEntityBasicMachine
|
|||
{
|
||||
ChargeUtils.discharge(1, this);
|
||||
|
||||
if(inventory[3] != null)
|
||||
{
|
||||
if(inventory[3].isItemEqual(new ItemStack(Mekanism.EnergyUpgrade)) && energyMultiplier < 8)
|
||||
{
|
||||
if(upgradeTicks < UPGRADE_TICKS_REQUIRED)
|
||||
{
|
||||
upgradeTicks++;
|
||||
}
|
||||
else if(upgradeTicks == UPGRADE_TICKS_REQUIRED)
|
||||
{
|
||||
upgradeTicks = 0;
|
||||
energyMultiplier++;
|
||||
|
||||
inventory[3].stackSize--;
|
||||
|
||||
if(inventory[3].stackSize == 0)
|
||||
{
|
||||
inventory[3] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(inventory[3].isItemEqual(new ItemStack(Mekanism.SpeedUpgrade)) && speedMultiplier < 8)
|
||||
{
|
||||
if(upgradeTicks < UPGRADE_TICKS_REQUIRED)
|
||||
{
|
||||
upgradeTicks++;
|
||||
}
|
||||
else if(upgradeTicks == UPGRADE_TICKS_REQUIRED)
|
||||
{
|
||||
upgradeTicks = 0;
|
||||
speedMultiplier++;
|
||||
|
||||
inventory[3].stackSize--;
|
||||
|
||||
if(inventory[3].stackSize == 0)
|
||||
{
|
||||
inventory[3] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
upgradeTicks = 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
upgradeTicks = 0;
|
||||
}
|
||||
|
||||
if(canOperate() && MekanismUtils.canFunction(this) && electricityStored >= MekanismUtils.getEnergyPerTick(speedMultiplier, energyMultiplier, ENERGY_PER_TICK))
|
||||
if(canOperate() && MekanismUtils.canFunction(this) && electricityStored >= MekanismUtils.getEnergyPerTick(getSpeedMultiplier(), getEnergyMultiplier(), ENERGY_PER_TICK))
|
||||
{
|
||||
setActive(true);
|
||||
|
||||
if((operatingTicks+1) < MekanismUtils.getTicks(speedMultiplier, TICKS_REQUIRED))
|
||||
if((operatingTicks+1) < MekanismUtils.getTicks(getSpeedMultiplier(), TICKS_REQUIRED))
|
||||
{
|
||||
operatingTicks++;
|
||||
electricityStored -= MekanismUtils.getEnergyPerTick(speedMultiplier, energyMultiplier, ENERGY_PER_TICK);
|
||||
electricityStored -= MekanismUtils.getEnergyPerTick(getSpeedMultiplier(), getEnergyMultiplier(), ENERGY_PER_TICK);
|
||||
}
|
||||
else if((operatingTicks+1) >= MekanismUtils.getTicks(speedMultiplier, TICKS_REQUIRED))
|
||||
else if((operatingTicks+1) >= MekanismUtils.getTicks(getSpeedMultiplier(), TICKS_REQUIRED))
|
||||
{
|
||||
operate();
|
||||
|
||||
operatingTicks = 0;
|
||||
electricityStored -= MekanismUtils.getEnergyPerTick(speedMultiplier, energyMultiplier, ENERGY_PER_TICK);
|
||||
electricityStored -= MekanismUtils.getEnergyPerTick(getSpeedMultiplier(), getEnergyMultiplier(), ENERGY_PER_TICK);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -217,7 +171,7 @@ public abstract class TileEntityElectricMachine extends TileEntityBasicMachine
|
|||
switch(method)
|
||||
{
|
||||
case 0:
|
||||
return new Object[] {electricityStored};
|
||||
return new Object[] {getEnergy()};
|
||||
case 1:
|
||||
return new Object[] {operatingTicks};
|
||||
case 2:
|
||||
|
@ -227,9 +181,9 @@ public abstract class TileEntityElectricMachine extends TileEntityBasicMachine
|
|||
case 4:
|
||||
return new Object[] {canOperate()};
|
||||
case 5:
|
||||
return new Object[] {MekanismUtils.getEnergy(energyMultiplier, MAX_ELECTRICITY)};
|
||||
return new Object[] {getMaxEnergy()};
|
||||
case 6:
|
||||
return new Object[] {(MekanismUtils.getEnergy(energyMultiplier, MAX_ELECTRICITY)-electricityStored)};
|
||||
return new Object[] {getMaxEnergy()-getEnergy()};
|
||||
default:
|
||||
System.err.println("[Mekanism] Attempted to call unknown method with computer ID " + computer.getID());
|
||||
return new Object[] {"Unknown command."};
|
||||
|
|
|
@ -32,7 +32,7 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IEnerg
|
|||
public FactoryTier tier;
|
||||
|
||||
/** This machine's side configuration. */
|
||||
public byte[] sideConfig;
|
||||
public byte[] sideConfig = new byte[] {4, 3, 0, 0, 2, 1};
|
||||
|
||||
/** An arraylist of SideData for this machine. */
|
||||
public ArrayList<SideData> sideOutputs = new ArrayList<SideData>();
|
||||
|
@ -46,18 +46,6 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IEnerg
|
|||
/** How much energy each operation consumes per tick. */
|
||||
public double ENERGY_PER_TICK = Mekanism.factoryUsage;
|
||||
|
||||
/** This machine's speed multiplier. */
|
||||
public int speedMultiplier;
|
||||
|
||||
/** This machine's energy multiplier. */
|
||||
public int energyMultiplier;
|
||||
|
||||
/** How long it takes this machine to install an upgrade. */
|
||||
public int UPGRADE_TICKS_REQUIRED = 40;
|
||||
|
||||
/** How many upgrade ticks have progressed. */
|
||||
public int upgradeTicks;
|
||||
|
||||
/** How long it takes this factory to switch recipe types. */
|
||||
public int RECIPE_TICKS_REQUIRED = 40;
|
||||
|
||||
|
@ -77,7 +65,9 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IEnerg
|
|||
public int recipeType;
|
||||
|
||||
/** This machine's current RedstoneControl type. */
|
||||
public RedstoneControl controlType;
|
||||
public RedstoneControl controlType = RedstoneControl.DISABLED;
|
||||
|
||||
public UpgradeTileComponent upgradeComponent = new UpgradeTileComponent(this, 0);
|
||||
|
||||
public TileEntityFactory()
|
||||
{
|
||||
|
@ -88,18 +78,16 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IEnerg
|
|||
sideOutputs.add(new SideData(EnumColor.DARK_GREEN, new int[] {1}));
|
||||
sideOutputs.add(new SideData(EnumColor.DARK_RED, new int[] {4, 5, 6}));
|
||||
sideOutputs.add(new SideData(EnumColor.DARK_BLUE, new int[] {7, 8, 9}));
|
||||
|
||||
sideConfig = new byte[] {4, 3, 0, 0, 2, 1};
|
||||
}
|
||||
|
||||
public TileEntityFactory(FactoryTier type, MachineType machine)
|
||||
{
|
||||
super(type.name + " Factory", machine.baseEnergy);
|
||||
|
||||
tier = type;
|
||||
inventory = new ItemStack[4+type.processes*2];
|
||||
progress = new int[type.processes];
|
||||
isActive = false;
|
||||
controlType = RedstoneControl.DISABLED;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -126,54 +114,6 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IEnerg
|
|||
|
||||
ChargeUtils.discharge(1, this);
|
||||
|
||||
if(inventory[0] != null)
|
||||
{
|
||||
if(inventory[0].isItemEqual(new ItemStack(Mekanism.EnergyUpgrade)) && energyMultiplier < 8)
|
||||
{
|
||||
if(upgradeTicks < UPGRADE_TICKS_REQUIRED)
|
||||
{
|
||||
upgradeTicks++;
|
||||
}
|
||||
else if(upgradeTicks == UPGRADE_TICKS_REQUIRED)
|
||||
{
|
||||
upgradeTicks = 0;
|
||||
energyMultiplier++;
|
||||
|
||||
inventory[0].stackSize--;
|
||||
|
||||
if(inventory[0].stackSize == 0)
|
||||
{
|
||||
inventory[0] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(inventory[0].isItemEqual(new ItemStack(Mekanism.SpeedUpgrade)) && speedMultiplier < 8)
|
||||
{
|
||||
if(upgradeTicks < UPGRADE_TICKS_REQUIRED)
|
||||
{
|
||||
upgradeTicks++;
|
||||
}
|
||||
else if(upgradeTicks == UPGRADE_TICKS_REQUIRED)
|
||||
{
|
||||
upgradeTicks = 0;
|
||||
speedMultiplier++;
|
||||
|
||||
inventory[0].stackSize--;
|
||||
|
||||
if(inventory[0].stackSize == 0)
|
||||
{
|
||||
inventory[0] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
upgradeTicks = 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
upgradeTicks = 0;
|
||||
}
|
||||
|
||||
if(inventory[2] != null && inventory[3] == null)
|
||||
{
|
||||
if(inventory[2].isItemEqual(new ItemStack(Mekanism.MachineBlock, 1, MachineType.ENERGIZED_SMELTER.meta)) && recipeType != 0)
|
||||
|
@ -234,19 +174,19 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IEnerg
|
|||
|
||||
for(int process = 0; process < tier.processes; process++)
|
||||
{
|
||||
if(MekanismUtils.canFunction(this) && canOperate(getInputSlot(process), getOutputSlot(process)) && electricityStored >= MekanismUtils.getEnergyPerTick(speedMultiplier, energyMultiplier, ENERGY_PER_TICK))
|
||||
if(MekanismUtils.canFunction(this) && canOperate(getInputSlot(process), getOutputSlot(process)) && electricityStored >= MekanismUtils.getEnergyPerTick(getSpeedMultiplier(), getEnergyMultiplier(), ENERGY_PER_TICK))
|
||||
{
|
||||
if((progress[process]+1) < MekanismUtils.getTicks(speedMultiplier, TICKS_REQUIRED))
|
||||
if((progress[process]+1) < MekanismUtils.getTicks(getSpeedMultiplier(), TICKS_REQUIRED))
|
||||
{
|
||||
progress[process]++;
|
||||
electricityStored -= MekanismUtils.getEnergyPerTick(speedMultiplier, energyMultiplier, ENERGY_PER_TICK);
|
||||
electricityStored -= MekanismUtils.getEnergyPerTick(getSpeedMultiplier(), getEnergyMultiplier(), ENERGY_PER_TICK);
|
||||
}
|
||||
else if((progress[process]+1) >= MekanismUtils.getTicks(speedMultiplier, TICKS_REQUIRED))
|
||||
else if((progress[process]+1) >= MekanismUtils.getTicks(getSpeedMultiplier(), TICKS_REQUIRED))
|
||||
{
|
||||
operate(getInputSlot(process), getOutputSlot(process));
|
||||
|
||||
progress[process] = 0;
|
||||
electricityStored -= MekanismUtils.getEnergyPerTick(speedMultiplier, energyMultiplier, ENERGY_PER_TICK);
|
||||
electricityStored -= MekanismUtils.getEnergyPerTick(getSpeedMultiplier(), getEnergyMultiplier(), ENERGY_PER_TICK);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -269,7 +209,7 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IEnerg
|
|||
}
|
||||
}
|
||||
|
||||
if(MekanismUtils.canFunction(this) && hasOperation && electricityStored >= MekanismUtils.getEnergyPerTick(speedMultiplier, energyMultiplier, ENERGY_PER_TICK))
|
||||
if(MekanismUtils.canFunction(this) && hasOperation && electricityStored >= MekanismUtils.getEnergyPerTick(getSpeedMultiplier(), getEnergyMultiplier(), ENERGY_PER_TICK))
|
||||
{
|
||||
setActive(true);
|
||||
}
|
||||
|
@ -380,12 +320,7 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IEnerg
|
|||
|
||||
public int getScaledProgress(int i, int process)
|
||||
{
|
||||
return progress[process]*i / MekanismUtils.getTicks(speedMultiplier, TICKS_REQUIRED);
|
||||
}
|
||||
|
||||
public int getScaledUpgradeProgress(int i)
|
||||
{
|
||||
return upgradeTicks*i / UPGRADE_TICKS_REQUIRED;
|
||||
return progress[process]*i / MekanismUtils.getTicks(getSpeedMultiplier(), TICKS_REQUIRED);
|
||||
}
|
||||
|
||||
public int getScaledRecipeProgress(int i)
|
||||
|
@ -448,11 +383,11 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IEnerg
|
|||
public void handlePacketData(ByteArrayDataInput dataStream)
|
||||
{
|
||||
super.handlePacketData(dataStream);
|
||||
speedMultiplier = dataStream.readInt();
|
||||
energyMultiplier = dataStream.readInt();
|
||||
|
||||
upgradeComponent.read(dataStream);
|
||||
|
||||
isActive = dataStream.readBoolean();
|
||||
recipeType = dataStream.readInt();
|
||||
upgradeTicks = dataStream.readInt();
|
||||
recipeTicks = dataStream.readInt();
|
||||
controlType = RedstoneControl.values()[dataStream.readInt()];
|
||||
|
||||
|
@ -474,11 +409,10 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IEnerg
|
|||
{
|
||||
super.readFromNBT(nbtTags);
|
||||
|
||||
speedMultiplier = nbtTags.getInteger("speedMultiplier");
|
||||
energyMultiplier = nbtTags.getInteger("energyMultiplier");
|
||||
upgradeComponent.read(nbtTags);
|
||||
|
||||
clientActive = isActive = nbtTags.getBoolean("isActive");
|
||||
recipeType = nbtTags.getInteger("recipeType");
|
||||
upgradeTicks = nbtTags.getInteger("upgradeTicks");
|
||||
recipeTicks = nbtTags.getInteger("recipeTicks");
|
||||
controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")];
|
||||
|
||||
|
@ -501,11 +435,10 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IEnerg
|
|||
{
|
||||
super.writeToNBT(nbtTags);
|
||||
|
||||
nbtTags.setInteger("speedMultiplier", speedMultiplier);
|
||||
nbtTags.setInteger("energyMultiplier", energyMultiplier);
|
||||
upgradeComponent.write(nbtTags);
|
||||
|
||||
nbtTags.setBoolean("isActive", isActive);
|
||||
nbtTags.setInteger("recipeType", recipeType);
|
||||
nbtTags.setInteger("upgradeTicks", upgradeTicks);
|
||||
nbtTags.setInteger("recipeTicks", recipeTicks);
|
||||
nbtTags.setInteger("controlType", controlType.ordinal());
|
||||
|
||||
|
@ -527,11 +460,10 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IEnerg
|
|||
{
|
||||
super.getNetworkedData(data);
|
||||
|
||||
data.add(speedMultiplier);
|
||||
data.add(energyMultiplier);
|
||||
upgradeComponent.write(data);
|
||||
|
||||
data.add(isActive);
|
||||
data.add(recipeType);
|
||||
data.add(upgradeTicks);
|
||||
data.add(recipeTicks);
|
||||
data.add(controlType.ordinal());
|
||||
data.add(progress);
|
||||
|
@ -560,7 +492,7 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IEnerg
|
|||
public double transferEnergyToAcceptor(double amount)
|
||||
{
|
||||
double rejects = 0;
|
||||
double neededElectricity = MekanismUtils.getEnergy(energyMultiplier, MAX_ELECTRICITY)-electricityStored;
|
||||
double neededElectricity = getMaxEnergy()-getEnergy();
|
||||
|
||||
if(amount <= neededElectricity)
|
||||
{
|
||||
|
@ -636,9 +568,9 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IEnerg
|
|||
|
||||
return new Object[] {canOperate(getInputSlot((Integer)arguments[0]), getOutputSlot((Integer)arguments[0]))};
|
||||
case 4:
|
||||
return new Object[] {MekanismUtils.getEnergy(energyMultiplier, MAX_ELECTRICITY)};
|
||||
return new Object[] {getMaxEnergy()};
|
||||
case 5:
|
||||
return new Object[] {(MekanismUtils.getEnergy(energyMultiplier, MAX_ELECTRICITY)-electricityStored)};
|
||||
return new Object[] {getMaxEnergy()-getEnergy()};
|
||||
default:
|
||||
System.err.println("[Mekanism] Attempted to call unknown method with computer ID " + computer.getID());
|
||||
return new Object[] {"Unknown command."};
|
||||
|
@ -660,7 +592,7 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IEnerg
|
|||
@Override
|
||||
public double getMaxEnergy()
|
||||
{
|
||||
return MekanismUtils.getEnergy(energyMultiplier, MAX_ELECTRICITY);
|
||||
return MekanismUtils.getEnergy(getEnergyMultiplier(), MAX_ELECTRICITY);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -742,25 +674,25 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IEnerg
|
|||
@Override
|
||||
public int getEnergyMultiplier(Object... data)
|
||||
{
|
||||
return energyMultiplier;
|
||||
return upgradeComponent.energyMultiplier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnergyMultiplier(int multiplier, Object... data)
|
||||
{
|
||||
energyMultiplier = multiplier;
|
||||
upgradeComponent.energyMultiplier = multiplier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSpeedMultiplier(Object... data)
|
||||
{
|
||||
return speedMultiplier;
|
||||
return upgradeComponent.speedMultiplier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSpeedMultiplier(int multiplier, Object... data)
|
||||
{
|
||||
speedMultiplier = multiplier;
|
||||
upgradeComponent.speedMultiplier = multiplier;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -33,7 +33,7 @@ import dan200.computer.api.IPeripheral;
|
|||
public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implements IEnergySink, IPeripheral, IActiveState, IConfigurable, IUpgradeManagement, IHasSound, IStrictEnergyAcceptor, IRedstoneControl
|
||||
{
|
||||
/** This machine's side configuration. */
|
||||
public byte[] sideConfig;
|
||||
public byte[] sideConfig = new byte[] {2, 1, 0, 5, 3, 4};
|
||||
|
||||
/** An arraylist of SideData for this machine. */
|
||||
public ArrayList<SideData> sideOutputs = new ArrayList<SideData>();
|
||||
|
@ -50,18 +50,6 @@ public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implem
|
|||
/** How many ticks it takes to run an operation. */
|
||||
public int TICKS_REQUIRED = 200;
|
||||
|
||||
/** This machine's speed multiplier. */
|
||||
public int speedMultiplier;
|
||||
|
||||
/** This machine's energy multiplier. */
|
||||
public int energyMultiplier;
|
||||
|
||||
/** How long it takes this machine to install an upgrade. */
|
||||
public int UPGRADE_TICKS_REQUIRED = 40;
|
||||
|
||||
/** How many upgrade ticks have progressed. */
|
||||
public int upgradeTicks;
|
||||
|
||||
/** The amount of infuse this machine has stored. */
|
||||
public int infuseStored;
|
||||
|
||||
|
@ -78,7 +66,9 @@ public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implem
|
|||
public int updateDelay;
|
||||
|
||||
/** This machine's current RedstoneControl type. */
|
||||
public RedstoneControl controlType;
|
||||
public RedstoneControl controlType = RedstoneControl.DISABLED;
|
||||
|
||||
public UpgradeTileComponent upgradeComponent = new UpgradeTileComponent(this, 0);
|
||||
|
||||
public TileEntityMetallurgicInfuser()
|
||||
{
|
||||
|
@ -91,10 +81,7 @@ public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implem
|
|||
sideOutputs.add(new SideData(EnumColor.DARK_BLUE, new int[] {3}));
|
||||
sideOutputs.add(new SideData(EnumColor.DARK_GREEN, new int[] {4}));
|
||||
|
||||
sideConfig = new byte[] {2, 1, 0, 5, 3, 4};
|
||||
|
||||
inventory = new ItemStack[5];
|
||||
controlType = RedstoneControl.DISABLED;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -121,54 +108,6 @@ public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implem
|
|||
|
||||
ChargeUtils.discharge(4, this);
|
||||
|
||||
if(inventory[0] != null)
|
||||
{
|
||||
if(inventory[0].isItemEqual(new ItemStack(Mekanism.EnergyUpgrade)) && energyMultiplier < 8)
|
||||
{
|
||||
if(upgradeTicks < UPGRADE_TICKS_REQUIRED)
|
||||
{
|
||||
upgradeTicks++;
|
||||
}
|
||||
else if(upgradeTicks == UPGRADE_TICKS_REQUIRED)
|
||||
{
|
||||
upgradeTicks = 0;
|
||||
energyMultiplier++;
|
||||
|
||||
inventory[0].stackSize--;
|
||||
|
||||
if(inventory[0].stackSize == 0)
|
||||
{
|
||||
inventory[0] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(inventory[0].isItemEqual(new ItemStack(Mekanism.SpeedUpgrade)) && speedMultiplier < 8)
|
||||
{
|
||||
if(upgradeTicks < UPGRADE_TICKS_REQUIRED)
|
||||
{
|
||||
upgradeTicks++;
|
||||
}
|
||||
else if(upgradeTicks == UPGRADE_TICKS_REQUIRED)
|
||||
{
|
||||
upgradeTicks = 0;
|
||||
speedMultiplier++;
|
||||
|
||||
inventory[0].stackSize--;
|
||||
|
||||
if(inventory[0].stackSize == 0)
|
||||
{
|
||||
inventory[0] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
upgradeTicks = 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
upgradeTicks = 0;
|
||||
}
|
||||
|
||||
if(inventory[1] != null)
|
||||
{
|
||||
if(InfuseRegistry.getObject(inventory[1]) != null)
|
||||
|
@ -192,21 +131,21 @@ public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implem
|
|||
}
|
||||
}
|
||||
|
||||
if(canOperate() && MekanismUtils.canFunction(this) && electricityStored >= MekanismUtils.getEnergyPerTick(speedMultiplier, energyMultiplier, ENERGY_PER_TICK))
|
||||
if(canOperate() && MekanismUtils.canFunction(this) && getEnergy() >= MekanismUtils.getEnergyPerTick(getSpeedMultiplier(), getEnergyMultiplier(), ENERGY_PER_TICK))
|
||||
{
|
||||
setActive(true);
|
||||
|
||||
if((operatingTicks+1) < MekanismUtils.getTicks(speedMultiplier, TICKS_REQUIRED))
|
||||
if((operatingTicks+1) < MekanismUtils.getTicks(getSpeedMultiplier(), TICKS_REQUIRED))
|
||||
{
|
||||
operatingTicks++;
|
||||
electricityStored -= MekanismUtils.getEnergyPerTick(speedMultiplier, energyMultiplier, ENERGY_PER_TICK);
|
||||
electricityStored -= MekanismUtils.getEnergyPerTick(getSpeedMultiplier(), getEnergyMultiplier(), ENERGY_PER_TICK);
|
||||
}
|
||||
else if((operatingTicks+1) >= MekanismUtils.getTicks(speedMultiplier, TICKS_REQUIRED))
|
||||
else if((operatingTicks+1) >= MekanismUtils.getTicks(getSpeedMultiplier(), TICKS_REQUIRED))
|
||||
{
|
||||
operate();
|
||||
|
||||
operatingTicks = 0;
|
||||
electricityStored -= MekanismUtils.getEnergyPerTick(speedMultiplier, energyMultiplier, ENERGY_PER_TICK);
|
||||
electricityStored -= MekanismUtils.getEnergyPerTick(getSpeedMultiplier(), getEnergyMultiplier(), ENERGY_PER_TICK);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -349,12 +288,7 @@ public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implem
|
|||
|
||||
public int getScaledProgress(int i)
|
||||
{
|
||||
return operatingTicks*i / MekanismUtils.getTicks(speedMultiplier, TICKS_REQUIRED);
|
||||
}
|
||||
|
||||
public int getScaledUpgradeProgress(int i)
|
||||
{
|
||||
return upgradeTicks*i / UPGRADE_TICKS_REQUIRED;
|
||||
return operatingTicks*i / MekanismUtils.getTicks(getSpeedMultiplier(), TICKS_REQUIRED);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -373,8 +307,8 @@ public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implem
|
|||
{
|
||||
super.readFromNBT(nbtTags);
|
||||
|
||||
speedMultiplier = nbtTags.getInteger("speedMultiplier");
|
||||
energyMultiplier = nbtTags.getInteger("energyMultiplier");
|
||||
upgradeComponent.read(nbtTags);
|
||||
|
||||
clientActive = isActive = nbtTags.getBoolean("isActive");
|
||||
operatingTicks = nbtTags.getInteger("operatingTicks");
|
||||
infuseStored = nbtTags.getInteger("infuseStored");
|
||||
|
@ -419,8 +353,8 @@ public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implem
|
|||
{
|
||||
super.writeToNBT(nbtTags);
|
||||
|
||||
nbtTags.setInteger("speedMultiplier", speedMultiplier);
|
||||
nbtTags.setInteger("energyMultiplier", energyMultiplier);
|
||||
upgradeComponent.write(nbtTags);
|
||||
|
||||
nbtTags.setBoolean("isActive", isActive);
|
||||
nbtTags.setInteger("operatingTicks", operatingTicks);
|
||||
nbtTags.setInteger("infuseStored", infuseStored);
|
||||
|
@ -453,8 +387,8 @@ public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implem
|
|||
|
||||
super.handlePacketData(dataStream);
|
||||
|
||||
speedMultiplier = dataStream.readInt();
|
||||
energyMultiplier = dataStream.readInt();
|
||||
upgradeComponent.read(dataStream);
|
||||
|
||||
isActive = dataStream.readBoolean();
|
||||
operatingTicks = dataStream.readInt();
|
||||
infuseStored = dataStream.readInt();
|
||||
|
@ -474,8 +408,8 @@ public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implem
|
|||
{
|
||||
super.getNetworkedData(data);
|
||||
|
||||
data.add(speedMultiplier);
|
||||
data.add(energyMultiplier);
|
||||
upgradeComponent.write(data);
|
||||
|
||||
data.add(isActive);
|
||||
data.add(operatingTicks);
|
||||
data.add(infuseStored);
|
||||
|
@ -511,7 +445,7 @@ public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implem
|
|||
switch(method)
|
||||
{
|
||||
case 0:
|
||||
return new Object[] {electricityStored};
|
||||
return new Object[] {getEnergy()};
|
||||
case 1:
|
||||
return new Object[] {operatingTicks};
|
||||
case 2:
|
||||
|
@ -519,13 +453,13 @@ public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implem
|
|||
case 3:
|
||||
return new Object[] {canOperate()};
|
||||
case 4:
|
||||
return new Object[] {MekanismUtils.getEnergy(energyMultiplier, MAX_ELECTRICITY)};
|
||||
return new Object[] {getMaxEnergy()};
|
||||
case 5:
|
||||
return new Object[] {(MekanismUtils.getEnergy(energyMultiplier, MAX_ELECTRICITY)-electricityStored)};
|
||||
return new Object[] {getMaxEnergy()-getEnergy()};
|
||||
case 6:
|
||||
return new Object[] {infuseStored};
|
||||
case 7:
|
||||
return new Object[] {(MAX_INFUSE-infuseStored)};
|
||||
return new Object[] {MAX_INFUSE-infuseStored};
|
||||
default:
|
||||
System.err.println("[Mekanism] Attempted to call unknown method with computer ID " + computer.getID());
|
||||
return new Object[] {"Unknown command."};
|
||||
|
@ -553,7 +487,7 @@ public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implem
|
|||
@Override
|
||||
public double getMaxEnergy()
|
||||
{
|
||||
return MekanismUtils.getEnergy(energyMultiplier, MAX_ELECTRICITY);
|
||||
return MekanismUtils.getEnergy(getEnergyMultiplier(), MAX_ELECTRICITY);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -635,25 +569,25 @@ public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implem
|
|||
@Override
|
||||
public int getEnergyMultiplier(Object... data)
|
||||
{
|
||||
return energyMultiplier;
|
||||
return upgradeComponent.energyMultiplier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnergyMultiplier(int multiplier, Object... data)
|
||||
{
|
||||
energyMultiplier = multiplier;
|
||||
upgradeComponent.energyMultiplier = multiplier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSpeedMultiplier(Object... data)
|
||||
{
|
||||
return speedMultiplier;
|
||||
return upgradeComponent.speedMultiplier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSpeedMultiplier(int multiplier, Object... data)
|
||||
{
|
||||
speedMultiplier = multiplier;
|
||||
upgradeComponent.speedMultiplier = multiplier;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
125
common/mekanism/common/UpgradeTileComponent.java
Normal file
125
common/mekanism/common/UpgradeTileComponent.java
Normal file
|
@ -0,0 +1,125 @@
|
|||
package mekanism.common;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
||||
public class UpgradeTileComponent implements ITileComponent
|
||||
{
|
||||
/** How long it takes this machine to install an upgrade. */
|
||||
public static int UPGRADE_TICKS_REQUIRED = 40;
|
||||
|
||||
private int upgradeSlot;
|
||||
|
||||
/** How many upgrade ticks have progressed. */
|
||||
public int upgradeTicks;
|
||||
|
||||
/** This machine's speed multiplier. */
|
||||
public int speedMultiplier;
|
||||
|
||||
/** This machine's energy multiplier. */
|
||||
public int energyMultiplier;
|
||||
|
||||
public TileEntityContainerBlock tileEntity;
|
||||
|
||||
public UpgradeTileComponent(TileEntityContainerBlock tile, int slot)
|
||||
{
|
||||
tileEntity = tile;
|
||||
upgradeSlot = slot;
|
||||
|
||||
tile.components.add(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick()
|
||||
{
|
||||
if(!tileEntity.worldObj.isRemote)
|
||||
{
|
||||
if(tileEntity.inventory[upgradeSlot] != null)
|
||||
{
|
||||
if(tileEntity.inventory[upgradeSlot].isItemEqual(new ItemStack(Mekanism.EnergyUpgrade)) && energyMultiplier < 8)
|
||||
{
|
||||
if(upgradeTicks < UPGRADE_TICKS_REQUIRED)
|
||||
{
|
||||
upgradeTicks++;
|
||||
}
|
||||
else if(upgradeTicks == UPGRADE_TICKS_REQUIRED)
|
||||
{
|
||||
upgradeTicks = 0;
|
||||
energyMultiplier++;
|
||||
|
||||
tileEntity.inventory[upgradeSlot].stackSize--;
|
||||
|
||||
if(tileEntity.inventory[upgradeSlot].stackSize == 0)
|
||||
{
|
||||
tileEntity.inventory[upgradeSlot] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(tileEntity.inventory[upgradeSlot].isItemEqual(new ItemStack(Mekanism.SpeedUpgrade)) && speedMultiplier < 8)
|
||||
{
|
||||
if(upgradeTicks < UPGRADE_TICKS_REQUIRED)
|
||||
{
|
||||
upgradeTicks++;
|
||||
}
|
||||
else if(upgradeTicks == UPGRADE_TICKS_REQUIRED)
|
||||
{
|
||||
upgradeTicks = 0;
|
||||
speedMultiplier++;
|
||||
|
||||
tileEntity.inventory[upgradeSlot].stackSize--;
|
||||
|
||||
if(tileEntity.inventory[upgradeSlot].stackSize == 0)
|
||||
{
|
||||
tileEntity.inventory[upgradeSlot] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
upgradeTicks = 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
upgradeTicks = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getScaledUpgradeProgress(int i)
|
||||
{
|
||||
return upgradeTicks*i / UPGRADE_TICKS_REQUIRED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(NBTTagCompound nbtTags)
|
||||
{
|
||||
speedMultiplier = nbtTags.getInteger("speedMultiplier");
|
||||
energyMultiplier = nbtTags.getInteger("energyMultiplier");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(ByteArrayDataInput dataStream)
|
||||
{
|
||||
speedMultiplier = dataStream.readInt();
|
||||
energyMultiplier = dataStream.readInt();
|
||||
upgradeTicks = dataStream.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(NBTTagCompound nbtTags)
|
||||
{
|
||||
nbtTags.setInteger("speedMultiplier", speedMultiplier);
|
||||
nbtTags.setInteger("energyMultiplier", energyMultiplier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(ArrayList data)
|
||||
{
|
||||
data.add(speedMultiplier);
|
||||
data.add(energyMultiplier);
|
||||
data.add(upgradeTicks);
|
||||
}
|
||||
}
|
BIN
resources/assets/mekanism/gui/GuiUpgradeManagement.png
Normal file
BIN
resources/assets/mekanism/gui/GuiUpgradeManagement.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.6 KiB |
Loading…
Add table
Reference in a new issue