mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
invertable foundry filters, more machine configs
This commit is contained in:
parent
385a7cef83
commit
4985b2e550
@ -12,6 +12,7 @@ import com.hbm.tileentity.machine.TileEntityFoundryOutlet;
|
||||
import com.hbm.util.I18nUtil;
|
||||
|
||||
import api.hbm.block.ICrucibleAcceptor;
|
||||
import api.hbm.block.IToolable;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
@ -32,7 +33,7 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent.Pre;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class FoundryOutlet extends BlockContainer implements ICrucibleAcceptor, ILookOverlay {
|
||||
public class FoundryOutlet extends BlockContainer implements ICrucibleAcceptor, ILookOverlay, IToolable {
|
||||
|
||||
@SideOnly(Side.CLIENT) public IIcon iconTop;
|
||||
@SideOnly(Side.CLIENT) public IIcon iconSide;
|
||||
@ -136,6 +137,31 @@ public class FoundryOutlet extends BlockContainer implements ICrucibleAcceptor,
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onScrew(World world, EntityPlayer player, int x, int y, int z, int side, float fX, float fY, float fZ, ToolType tool) {
|
||||
|
||||
if(tool == ToolType.SCREWDRIVER) {
|
||||
if(world.isRemote) return true;
|
||||
|
||||
TileEntityFoundryOutlet tile = (TileEntityFoundryOutlet) world.getTileEntity(x, y, z);
|
||||
tile.filter = null;
|
||||
tile.invertFilter = false;
|
||||
tile.markDirty();
|
||||
world.markBlockForUpdate(x, y, z);
|
||||
}
|
||||
|
||||
if(tool == ToolType.HAND_DRILL) {
|
||||
if(world.isRemote) return true;
|
||||
|
||||
TileEntityFoundryOutlet tile = (TileEntityFoundryOutlet) world.getTileEntity(x, y, z);
|
||||
tile.invertFilter = !tile.invertFilter;
|
||||
tile.markDirty();
|
||||
world.markBlockForUpdate(x, y, z);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override public boolean canAcceptPartialPour(World world, int x, int y, int z, double dX, double dY, double dZ, ForgeDirection side, MaterialStack stack) { return false; }
|
||||
@Override public MaterialStack pour(World world, int x, int y, int z, double dX, double dY, double dZ, ForgeDirection side, MaterialStack stack) { return stack; }
|
||||
|
||||
@ -174,6 +200,9 @@ public class FoundryOutlet extends BlockContainer implements ICrucibleAcceptor,
|
||||
if(outlet.filter != null) {
|
||||
text.add(EnumChatFormatting.YELLOW + I18nUtil.resolveKey("foundry.filter", outlet.filter.names[0]));
|
||||
}
|
||||
if(outlet.invertFilter) {
|
||||
text.add(EnumChatFormatting.YELLOW + I18nUtil.resolveKey("foundry.invertFilter"));
|
||||
}
|
||||
if(outlet.invertRedstone) {
|
||||
text.add(EnumChatFormatting.DARK_RED + I18nUtil.resolveKey("foundry.inverted"));
|
||||
}
|
||||
|
||||
@ -14,6 +14,12 @@ import com.hbm.main.MainRegistry;
|
||||
import com.hbm.tileentity.IConfigurableMachine;
|
||||
import com.hbm.tileentity.TileMappings;
|
||||
|
||||
/**
|
||||
* Dynamically generated JSON config using the IConfigurableMachine interface.
|
||||
* How it works: simply implement the interface, the system will read all relevant
|
||||
* tile entities from the registry automatically and generate config options.
|
||||
* @author hbm
|
||||
*/
|
||||
public class MachineDynConfig {
|
||||
|
||||
public static final Gson gson = new Gson();
|
||||
@ -58,6 +64,10 @@ public class MachineDynConfig {
|
||||
writer.setIndent(" ");
|
||||
writer.beginObject();
|
||||
|
||||
writer.name("info").beginArray();
|
||||
for(String line : getComment()) writer.value(line);
|
||||
writer.endArray();
|
||||
|
||||
for(IConfigurableMachine dummy : dummies) {
|
||||
|
||||
try {
|
||||
@ -75,4 +85,18 @@ public class MachineDynConfig {
|
||||
|
||||
} catch(Exception ex) { }
|
||||
}
|
||||
|
||||
private static String[] getComment() {
|
||||
return new String[] {
|
||||
"Unlike other JSON configs, this one does not use a variable amount of options (like recipes), rather all config options are fixed.",
|
||||
"This means that there is no distinction between template and used config, you can simply edit this file and it will use the new values.",
|
||||
"If you wish to reset one or multiple values to default, simply delete them, the file is re-created every time the game starts (but changed values persist!)",
|
||||
"How this works in detail:",
|
||||
"- Machines have default values on init",
|
||||
"- The config system will try to read the config file. It will replace the default values where applicable, and keep them when an option is missing.",
|
||||
"- The config system will then use the full set of values - configured or default if missing - and re-create the config file to include any missing entries.",
|
||||
"This final step also means that any custom non-config values added to the JSON, while not causing errors, will be deleted when the config is re-created.",
|
||||
"It also means that should an update add more values to an existing machines, those will be retroactively added to the config using the default value."
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,9 +1,13 @@
|
||||
package com.hbm.module;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.tileentity.IConfigurableMachine;
|
||||
import com.hbm.util.ItemStackUtil;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
@ -35,6 +39,45 @@ public class ModuleBurnTime {
|
||||
modHeat[i] = 1.0D;
|
||||
}
|
||||
}
|
||||
|
||||
public void readIfPresent(JsonObject obj) {
|
||||
modTime[modLog] = IConfigurableMachine.grab(obj, "D:timeLog", modTime[modLog]);
|
||||
modTime[modWood] = IConfigurableMachine.grab(obj, "D:timeWood", modTime[modWood]);
|
||||
modTime[modCoal] = IConfigurableMachine.grab(obj, "D:timeCoal", modTime[modCoal]);
|
||||
modTime[modLignite] = IConfigurableMachine.grab(obj, "D:timeLignite", modTime[modLignite]);
|
||||
modTime[modCoke] = IConfigurableMachine.grab(obj, "D:timeCoke", modTime[modCoke]);
|
||||
modTime[modSolid] = IConfigurableMachine.grab(obj, "D:timeSolid", modTime[modSolid]);
|
||||
modTime[modRocket] = IConfigurableMachine.grab(obj, "D:timeRocket", modTime[modRocket]);
|
||||
modTime[modBalefire] = IConfigurableMachine.grab(obj, "D:timeBalefire", modTime[modBalefire]);
|
||||
|
||||
modHeat[modLog] = IConfigurableMachine.grab(obj, "D:heatLog", modHeat[modLog]);
|
||||
modHeat[modWood] = IConfigurableMachine.grab(obj, "D:heatWood", modHeat[modWood]);
|
||||
modHeat[modCoal] = IConfigurableMachine.grab(obj, "D:heatCoal", modHeat[modCoal]);
|
||||
modHeat[modLignite] = IConfigurableMachine.grab(obj, "D:heatLignite", modHeat[modLignite]);
|
||||
modHeat[modCoke] = IConfigurableMachine.grab(obj, "D:heatCoke", modHeat[modCoke]);
|
||||
modHeat[modSolid] = IConfigurableMachine.grab(obj, "D:heatSolid", modHeat[modSolid]);
|
||||
modHeat[modRocket] = IConfigurableMachine.grab(obj, "D:heatRocket", modHeat[modRocket]);
|
||||
modHeat[modBalefire] = IConfigurableMachine.grab(obj, "D:heatBalefie", modHeat[modBalefire]);
|
||||
}
|
||||
|
||||
public void writeConfig(JsonWriter writer) throws IOException {
|
||||
writer.name("D:timeLog").value(modTime[modLog]);
|
||||
writer.name("D:timeWood").value(modTime[modWood]);
|
||||
writer.name("D:timeCoal").value(modTime[modCoal]);
|
||||
writer.name("D:timeLignite").value(modTime[modLignite]);
|
||||
writer.name("D:timeCoke").value(modTime[modCoke]);
|
||||
writer.name("D:timeSolid").value(modTime[modSolid]);
|
||||
writer.name("D:timeRocket").value(modTime[modRocket]);
|
||||
writer.name("D:timeBalefire").value(modTime[modBalefire]);
|
||||
writer.name("D:heatLog").value(modHeat[modLog]);
|
||||
writer.name("D:heatWood").value(modHeat[modWood]);
|
||||
writer.name("D:heatCoal").value(modHeat[modCoal]);
|
||||
writer.name("D:heatLignite").value(modHeat[modLignite]);
|
||||
writer.name("D:heatCoke").value(modHeat[modCoke]);
|
||||
writer.name("D:heatSolid").value(modHeat[modSolid]);
|
||||
writer.name("D:heatRocket").value(modHeat[modRocket]);
|
||||
writer.name("D:heatBalefie").value(modHeat[modBalefire]);
|
||||
}
|
||||
|
||||
public int getBurnTime(ItemStack stack) {
|
||||
int fuel = TileEntityFurnace.getItemBurnTime(stack);
|
||||
|
||||
@ -1,8 +1,11 @@
|
||||
package com.hbm.tileentity.machine;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import com.hbm.blocks.BlockDummyable;
|
||||
import com.hbm.inventory.container.ContainerCrucible;
|
||||
import com.hbm.inventory.gui.GUICrucible;
|
||||
@ -13,6 +16,7 @@ import com.hbm.inventory.material.NTMMaterial;
|
||||
import com.hbm.inventory.recipes.CrucibleRecipes;
|
||||
import com.hbm.inventory.recipes.CrucibleRecipes.CrucibleRecipe;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.tileentity.IConfigurableMachine;
|
||||
import com.hbm.tileentity.IGUIProvider;
|
||||
import com.hbm.tileentity.TileEntityMachineBase;
|
||||
import com.hbm.util.CrucibleUtil;
|
||||
@ -34,21 +38,46 @@ import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class TileEntityCrucible extends TileEntityMachineBase implements IGUIProvider {
|
||||
public class TileEntityCrucible extends TileEntityMachineBase implements IGUIProvider, IConfigurableMachine {
|
||||
|
||||
public int heat;
|
||||
public static final int maxHeat = 100_000;
|
||||
public int progress;
|
||||
public static final int processTime = 20_000;
|
||||
public static final double diffusion = 0.25D;
|
||||
|
||||
//because eclipse's auto complete is dumb as a fucking rock, it's now called "ZCapacity" so it's listed AFTER the actual stacks in the auto complete list.
|
||||
//also martin i know you read these: no i will not switch to intellij after using eclipse for 8 years.
|
||||
public final int recipeZCapacity = MaterialShapes.BLOCK.q(16);
|
||||
public final int wasteZCapacity = MaterialShapes.BLOCK.q(16);
|
||||
|
||||
public List<MaterialStack> recipeStack = new ArrayList();
|
||||
public List<MaterialStack> wasteStack = new ArrayList();
|
||||
|
||||
/* CONFIGURABLE CONSTANTS */
|
||||
//because eclipse's auto complete is dumb as a fucking rock, it's now called "ZCapacity" so it's listed AFTER the actual stacks in the auto complete list.
|
||||
//also martin i know you read these: no i will not switch to intellij after using eclipse for 8 years.
|
||||
public static int recipeZCapacity = MaterialShapes.BLOCK.q(16);
|
||||
public static int wasteZCapacity = MaterialShapes.BLOCK.q(16);
|
||||
public static int processTime = 20_000;
|
||||
public static double diffusion = 0.25D;
|
||||
public static int maxHeat = 100_000;
|
||||
|
||||
@Override
|
||||
public String getConfigName() {
|
||||
return "crucible";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readIfPresent(JsonObject obj) {
|
||||
recipeZCapacity = IConfigurableMachine.grab(obj, "I:recipeCapacity", recipeZCapacity);
|
||||
wasteZCapacity = IConfigurableMachine.grab(obj, "I:wasteCapacity", wasteZCapacity);
|
||||
processTime = IConfigurableMachine.grab(obj, "I:processHeat", processTime);
|
||||
diffusion = IConfigurableMachine.grab(obj, "D:diffusion", diffusion);
|
||||
maxHeat = IConfigurableMachine.grab(obj, "I:heatCap", maxHeat);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeConfig(JsonWriter writer) throws IOException {
|
||||
writer.name("I:recipeCapacity").value(recipeZCapacity);
|
||||
writer.name("I:wasteCapacity").value(wasteZCapacity);
|
||||
writer.name("I:processHeat").value(processTime);
|
||||
writer.name("D:diffusion").value(diffusion);
|
||||
writer.name("I:heatCap").value(maxHeat);
|
||||
}
|
||||
|
||||
public TileEntityCrucible() {
|
||||
super(10);
|
||||
}
|
||||
|
||||
@ -16,6 +16,8 @@ public class TileEntityFoundryOutlet extends TileEntityFoundryBase {
|
||||
|
||||
public NTMMaterial filter = null;
|
||||
public NTMMaterial lastFilter = null;
|
||||
/* inverts filter behavior, will let everything but the filter material pass */
|
||||
public boolean invertFilter = false;
|
||||
/** inverts redstone behavior, i.e. when TRUE, the outlet will be blocked by default and only open with redstone */
|
||||
public boolean invertRedstone = false;
|
||||
public boolean lastClosed = false;
|
||||
@ -45,7 +47,7 @@ public class TileEntityFoundryOutlet extends TileEntityFoundryBase {
|
||||
@Override
|
||||
public boolean canAcceptPartialFlow(World world, int x, int y, int z, ForgeDirection side, MaterialStack stack) {
|
||||
|
||||
if(filter != null && filter != stack.material) return false;
|
||||
if(filter != null && (filter != stack.material ^ invertFilter)) return false;
|
||||
if(isClosed()) return false;
|
||||
if(side != ForgeDirection.getOrientation(this.getBlockMetadata()).getOpposite()) return false;
|
||||
|
||||
@ -86,6 +88,7 @@ public class TileEntityFoundryOutlet extends TileEntityFoundryBase {
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
this.invertRedstone = nbt.getBoolean("invert");
|
||||
this.invertFilter = nbt.getBoolean("invertFilter");
|
||||
this.filter = Mats.matById.get((int) nbt.getShort("filter"));
|
||||
}
|
||||
|
||||
@ -93,6 +96,7 @@ public class TileEntityFoundryOutlet extends TileEntityFoundryBase {
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
super.writeToNBT(nbt);
|
||||
nbt.setBoolean("invert", this.invertRedstone);
|
||||
nbt.setBoolean("invertFilter", this.invertFilter);
|
||||
nbt.setShort("filter", this.filter == null ? -1 : (short) this.filter.id);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,9 +1,14 @@
|
||||
package com.hbm.tileentity.machine;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import com.hbm.blocks.BlockDummyable;
|
||||
import com.hbm.inventory.container.ContainerFirebox;
|
||||
import com.hbm.inventory.gui.GUIFirebox;
|
||||
import com.hbm.module.ModuleBurnTime;
|
||||
import com.hbm.tileentity.IConfigurableMachine;
|
||||
import com.hbm.tileentity.IGUIProvider;
|
||||
import com.hbm.tileentity.TileEntityMachineBase;
|
||||
|
||||
@ -20,7 +25,7 @@ import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class TileEntityHeaterFirebox extends TileEntityMachineBase implements IGUIProvider, IHeatSource {
|
||||
public class TileEntityHeaterFirebox extends TileEntityMachineBase implements IGUIProvider, IHeatSource, IConfigurableMachine {
|
||||
|
||||
public int maxBurnTime;
|
||||
public int burnTime;
|
||||
@ -32,27 +37,27 @@ public class TileEntityHeaterFirebox extends TileEntityMachineBase implements IG
|
||||
public float prevDoorAngle = 0;
|
||||
|
||||
public int heatEnergy;
|
||||
public static final int maxHeatEnergy = 100_000;
|
||||
|
||||
public ModuleBurnTime burnModule;
|
||||
|
||||
public static int baseHeat = 100;
|
||||
public static double timeMult = 1D;
|
||||
public static int maxHeatEnergy = 100_000;
|
||||
public static ModuleBurnTime burnModule = new ModuleBurnTime()
|
||||
.setLigniteTimeMod(1.25)
|
||||
.setCoalTimeMod(1.25)
|
||||
.setCokeTimeMod(1.25)
|
||||
.setSolidTimeMod(1.5)
|
||||
.setRocketTimeMod(1.5)
|
||||
.setBalefireTimeMod(0.5)
|
||||
|
||||
.setLigniteHeatMod(2)
|
||||
.setCoalHeatMod(2)
|
||||
.setCokeHeatMod(2)
|
||||
.setSolidHeatMod(3)
|
||||
.setRocketHeatMod(5)
|
||||
.setBalefireHeatMod(15);
|
||||
|
||||
public TileEntityHeaterFirebox() {
|
||||
super(2);
|
||||
|
||||
burnModule = new ModuleBurnTime()
|
||||
.setLigniteTimeMod(1.25)
|
||||
.setCoalTimeMod(1.25)
|
||||
.setCokeTimeMod(1.25)
|
||||
.setSolidTimeMod(1.5)
|
||||
.setRocketTimeMod(1.5)
|
||||
.setBalefireTimeMod(0.5)
|
||||
|
||||
.setLigniteHeatMod(2)
|
||||
.setCoalHeatMod(2)
|
||||
.setCokeHeatMod(2)
|
||||
.setSolidHeatMod(3)
|
||||
.setRocketHeatMod(5)
|
||||
.setBalefireHeatMod(15);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -82,11 +87,11 @@ public class TileEntityHeaterFirebox extends TileEntityMachineBase implements IG
|
||||
for(int i = 0; i < 2; i++) {
|
||||
if(slots[i] != null) {
|
||||
|
||||
int fuel = burnModule.getBurnTime(slots[i]);
|
||||
int fuel = (int) (burnModule.getBurnTime(slots[i]) * timeMult);
|
||||
|
||||
if(fuel > 0) {
|
||||
this.maxBurnTime = this.burnTime = fuel;
|
||||
this.burnHeat = burnModule.getBurnHeat(100, slots[i]);
|
||||
this.burnHeat = burnModule.getBurnHeat(baseHeat, slots[i]);
|
||||
slots[i].stackSize--;
|
||||
|
||||
if(slots[i].stackSize == 0) {
|
||||
@ -232,4 +237,29 @@ public class TileEntityHeaterFirebox extends TileEntityMachineBase implements IG
|
||||
public double getMaxRenderDistanceSquared() {
|
||||
return 65536.0D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getConfigName() {
|
||||
return "firebox";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readIfPresent(JsonObject obj) {
|
||||
baseHeat = IConfigurableMachine.grab(obj, "I:baseHeat", baseHeat);
|
||||
timeMult = IConfigurableMachine.grab(obj, "D:burnTimeMult", timeMult);
|
||||
maxHeatEnergy = IConfigurableMachine.grab(obj, "I:heatCap", maxHeatEnergy);
|
||||
if(obj.has("burnModule")) {
|
||||
burnModule.readIfPresent(obj.get("M:burnModule").getAsJsonObject());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeConfig(JsonWriter writer) throws IOException {
|
||||
writer.name("I:baseHeat").value(baseHeat);
|
||||
writer.name("D:burnTimeMult").value(timeMult);
|
||||
writer.name("I:heatCap").value(maxHeatEnergy);
|
||||
writer.name("M:burnModule").beginObject();
|
||||
burnModule.writeConfig(writer);
|
||||
writer.endObject();
|
||||
}
|
||||
}
|
||||
|
||||
@ -269,7 +269,7 @@ public class TileEntityMachineCoal extends TileEntityLoadedBase implements ISide
|
||||
|
||||
if(slots[1] != null && TileEntityFurnace.getItemBurnTime(slots[1]) > 0 && burnTime <= 0)
|
||||
{
|
||||
burnTime = TileEntityFurnace.getItemBurnTime(slots[1]) / 2;
|
||||
burnTime = (int) (TileEntityFurnace.getItemBurnTime(slots[1]) * fuelMod);
|
||||
slots[1].stackSize -= 1;
|
||||
if(slots[1].stackSize == 0)
|
||||
{
|
||||
|
||||
@ -258,7 +258,7 @@ public class TileEntityMachineDiesel extends TileEntityMachineBase implements IE
|
||||
|
||||
@Override
|
||||
public void readIfPresent(JsonObject obj) {
|
||||
maxPower = IConfigurableMachine.grab(obj, "I:powerCap", maxPower);
|
||||
maxPower = IConfigurableMachine.grab(obj, "L:powerCap", maxPower);
|
||||
fluidCap = IConfigurableMachine.grab(obj, "I:fuelCap", fluidCap);
|
||||
|
||||
if(obj.has("D[:efficiency")) {
|
||||
@ -272,7 +272,7 @@ public class TileEntityMachineDiesel extends TileEntityMachineBase implements IE
|
||||
|
||||
@Override
|
||||
public void writeConfig(JsonWriter writer) throws IOException {
|
||||
writer.name("I:powerCap").value(maxPower);
|
||||
writer.name("L:powerCap").value(maxPower);
|
||||
writer.name("I:fuelCap").value(fluidCap);
|
||||
|
||||
String info = "Fuel grades in order: ";
|
||||
|
||||
@ -1,7 +1,11 @@
|
||||
package com.hbm.tileentity.machine;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import com.hbm.interfaces.IFluidAcceptor;
|
||||
import com.hbm.interfaces.IFluidContainer;
|
||||
import com.hbm.inventory.FluidContainerRegistry;
|
||||
@ -15,6 +19,7 @@ import com.hbm.lib.Library;
|
||||
import com.hbm.packet.AuxElectricityPacket;
|
||||
import com.hbm.packet.AuxGaugePacket;
|
||||
import com.hbm.packet.PacketDispatcher;
|
||||
import com.hbm.tileentity.IConfigurableMachine;
|
||||
import com.hbm.tileentity.TileEntityLoadedBase;
|
||||
|
||||
import api.hbm.energy.IBatteryItem;
|
||||
@ -27,17 +32,28 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class TileEntityMachineSeleniumEngine extends TileEntityLoadedBase implements ISidedInventory, IEnergyGenerator, IFluidContainer, IFluidAcceptor {
|
||||
public class TileEntityMachineSeleniumEngine extends TileEntityLoadedBase implements ISidedInventory, IEnergyGenerator, IFluidContainer, IFluidAcceptor, IConfigurableMachine {
|
||||
|
||||
private ItemStack slots[];
|
||||
|
||||
public long power;
|
||||
public int soundCycle = 0;
|
||||
public static final long maxPower = 250000;
|
||||
public long powerCap = 250000;
|
||||
public FluidTank tank;
|
||||
public int pistonCount = 0;
|
||||
|
||||
public static long maxPower = 250000;
|
||||
public static int fluidCap = 16000;
|
||||
public static double pistonExp = 1.15D;
|
||||
public static boolean shutUp = false;
|
||||
public static HashMap<FuelGrade, Double> fuelEfficiency = new HashMap();
|
||||
static {
|
||||
fuelEfficiency.put(FuelGrade.LOW, 1.0D);
|
||||
fuelEfficiency.put(FuelGrade.MEDIUM, 0.75D);
|
||||
fuelEfficiency.put(FuelGrade.HIGH, 0.5D);
|
||||
fuelEfficiency.put(FuelGrade.AERO, 0.05D);
|
||||
}
|
||||
|
||||
private static final int[] slots_top = new int[] { 0 };
|
||||
private static final int[] slots_bottom = new int[] { 1, 2 };
|
||||
private static final int[] slots_side = new int[] { 2 };
|
||||
@ -46,7 +62,7 @@ public class TileEntityMachineSeleniumEngine extends TileEntityLoadedBase implem
|
||||
|
||||
public TileEntityMachineSeleniumEngine() {
|
||||
slots = new ItemStack[14];
|
||||
tank = new FluidTank(Fluids.DIESEL, 16000, 0);
|
||||
tank = new FluidTank(Fluids.DIESEL, fluidCap, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -257,15 +273,6 @@ public class TileEntityMachineSeleniumEngine extends TileEntityLoadedBase implem
|
||||
return getHEFromFuel() > 0;
|
||||
}
|
||||
|
||||
public static HashMap<FuelGrade, Double> fuelEfficiency = new HashMap();
|
||||
|
||||
static {
|
||||
fuelEfficiency.put(FuelGrade.LOW, 1.0D);
|
||||
fuelEfficiency.put(FuelGrade.MEDIUM, 0.75D);
|
||||
fuelEfficiency.put(FuelGrade.HIGH, 0.5D);
|
||||
fuelEfficiency.put(FuelGrade.AERO, 0.05D);
|
||||
}
|
||||
|
||||
public long getHEFromFuel() {
|
||||
return getHEFromFuel(tank.getTankType());
|
||||
}
|
||||
@ -285,22 +292,22 @@ public class TileEntityMachineSeleniumEngine extends TileEntityLoadedBase implem
|
||||
public void generate() {
|
||||
if (hasAcceptableFuel()) {
|
||||
if (tank.getFill() > 0) {
|
||||
if (soundCycle == 0) {
|
||||
//if (tank.getTankType().name().equals(FluidType.) > 0)
|
||||
// this.worldObj.playSoundEffect(this.xCoord, this.yCoord, this.zCoord, "fireworks.blast", 1.0F, 1.0F);
|
||||
//else
|
||||
|
||||
if(!shutUp) {
|
||||
if (soundCycle == 0) {
|
||||
this.worldObj.playSoundEffect(this.xCoord, this.yCoord, this.zCoord, "fireworks.blast", 1.0F, 0.5F);
|
||||
}
|
||||
soundCycle++;
|
||||
|
||||
if (soundCycle >= 3)
|
||||
soundCycle = 0;
|
||||
}
|
||||
soundCycle++;
|
||||
|
||||
if (soundCycle >= 3)
|
||||
soundCycle = 0;
|
||||
|
||||
tank.setFill(tank.getFill() - this.pistonCount);
|
||||
if(tank.getFill() < 0)
|
||||
tank.setFill(0);
|
||||
|
||||
power += getHEFromFuel() * Math.pow(this.pistonCount, 1.15D);
|
||||
power += getHEFromFuel() * Math.pow(this.pistonCount, pistonExp);
|
||||
|
||||
if(power > powerCap)
|
||||
power = powerCap;
|
||||
@ -353,4 +360,45 @@ public class TileEntityMachineSeleniumEngine extends TileEntityLoadedBase implem
|
||||
public boolean canConnect(ForgeDirection dir) {
|
||||
return dir == ForgeDirection.DOWN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getConfigName() {
|
||||
return "radialengine";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readIfPresent(JsonObject obj) {
|
||||
maxPower = IConfigurableMachine.grab(obj, "L:powerCap", maxPower);
|
||||
fluidCap = IConfigurableMachine.grab(obj, "I:fuelCap", fluidCap);
|
||||
pistonExp = IConfigurableMachine.grab(obj, "D:pistonGenExponent", pistonExp);
|
||||
|
||||
if(obj.has("D[:efficiency")) {
|
||||
JsonArray array = obj.get("D[:efficiency").getAsJsonArray();
|
||||
for(FuelGrade grade : FuelGrade.values()) {
|
||||
fuelEfficiency.put(grade, array.get(grade.ordinal()).getAsDouble());
|
||||
}
|
||||
}
|
||||
|
||||
shutUp = IConfigurableMachine.grab(obj, "B:shutUp", shutUp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeConfig(JsonWriter writer) throws IOException {
|
||||
writer.name("L:powerCap").value(maxPower);
|
||||
writer.name("I:fuelCap").value(fluidCap);
|
||||
writer.name("D:pistonGenExponent").value(pistonExp);
|
||||
|
||||
String info = "Fuel grades in order: ";
|
||||
for(FuelGrade grade : FuelGrade.values()) info += grade.name() + " ";
|
||||
info = info.trim();
|
||||
writer.name("INFO").value(info);
|
||||
|
||||
writer.name("D[:efficiency").beginArray().setIndent("");
|
||||
for(FuelGrade grade : FuelGrade.values()) {
|
||||
double d = fuelEfficiency.containsKey(grade) ? fuelEfficiency.get(grade) : 0.0D;
|
||||
writer.value(d);
|
||||
}
|
||||
writer.endArray().setIndent(" ");
|
||||
writer.name("B:shutUp").value(shutUp);
|
||||
}
|
||||
}
|
||||
|
||||
@ -311,7 +311,7 @@ public class GuiWorldInAJar extends GuiScreen {
|
||||
return false;
|
||||
}
|
||||
|
||||
//ublic static GuiWorldInAJar shittyHack;
|
||||
//public static GuiWorldInAJar shittyHack;
|
||||
|
||||
public void drawStackText(List<Object[]> lines, int x, int y, FontRenderer font) {
|
||||
|
||||
|
||||
@ -35,7 +35,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.Vec3;
|
||||
|
||||
public class CannerySILEX extends CanneryBase{
|
||||
public class CannerySILEX extends CanneryBase {
|
||||
|
||||
@Override
|
||||
public ItemStack getIcon() {
|
||||
|
||||
@ -493,6 +493,7 @@ fluid.volcanic_lava_fluid=Vulkanische Lava
|
||||
|
||||
foundry.filter=Filter: %s
|
||||
foundry.inverted=Redstone invertiert
|
||||
foundry.invertFilter=Filter invertiert
|
||||
foundry.noCast=Keine Form eingelegt!
|
||||
|
||||
geiger.chunkRad=Chunk-Strahlung:
|
||||
|
||||
@ -712,6 +712,7 @@ fluid.volcanic_lava_fluid=Volcanic Lava
|
||||
|
||||
foundry.filter=Filter: %s
|
||||
foundry.inverted=Redstone inverted
|
||||
foundry.invertFilter=Filter inverted
|
||||
foundry.noCast=No mold installed!
|
||||
|
||||
geiger.chunkRad=Current chunk radiation:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user