mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
implement configuration for forcefield emitter
github desktop fucking sucks
This commit is contained in:
parent
a37dd9e639
commit
78cbabf1e6
@ -1,14 +1,18 @@
|
|||||||
package com.hbm.tileentity.machine;
|
package com.hbm.tileentity.machine;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
import com.google.gson.stream.JsonWriter;
|
||||||
import com.hbm.inventory.container.ContainerForceField;
|
import com.hbm.inventory.container.ContainerForceField;
|
||||||
import com.hbm.inventory.gui.GUIForceField;
|
import com.hbm.inventory.gui.GUIForceField;
|
||||||
import com.hbm.items.ModItems;
|
import com.hbm.items.ModItems;
|
||||||
import com.hbm.lib.Library;
|
import com.hbm.lib.Library;
|
||||||
import com.hbm.packet.PacketDispatcher;
|
import com.hbm.packet.PacketDispatcher;
|
||||||
import com.hbm.packet.toclient.TEFFPacket;
|
import com.hbm.packet.toclient.TEFFPacket;
|
||||||
|
import com.hbm.tileentity.IConfigurableMachine;
|
||||||
import com.hbm.tileentity.IGUIProvider;
|
import com.hbm.tileentity.IGUIProvider;
|
||||||
import com.hbm.tileentity.TileEntityLoadedBase;
|
import com.hbm.tileentity.TileEntityLoadedBase;
|
||||||
|
|
||||||
@ -30,7 +34,7 @@ import net.minecraft.util.Vec3;
|
|||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
public class TileEntityForceField extends TileEntityLoadedBase implements ISidedInventory, IEnergyReceiverMK2, IGUIProvider {
|
public class TileEntityForceField extends TileEntityLoadedBase implements ISidedInventory, IEnergyReceiverMK2, IGUIProvider, IConfigurableMachine {
|
||||||
|
|
||||||
private ItemStack slots[];
|
private ItemStack slots[];
|
||||||
|
|
||||||
@ -43,10 +47,10 @@ public class TileEntityForceField extends TileEntityLoadedBase implements ISided
|
|||||||
public float radius = 16;
|
public float radius = 16;
|
||||||
public boolean isOn = false;
|
public boolean isOn = false;
|
||||||
public int color = 0x0000FF;
|
public int color = 0x0000FF;
|
||||||
public final int baseCon = 1000;
|
public static int baseCon = 1000;
|
||||||
public final int radCon = 500;
|
public static int radCon = 500;
|
||||||
public final int shCon = 250;
|
public static int shCon = 250;
|
||||||
public static final long maxPower = 1000000;
|
public static long maxPower = 1000000;
|
||||||
|
|
||||||
private static final int[] slots_top = new int[] {0};
|
private static final int[] slots_top = new int[] {0};
|
||||||
private static final int[] slots_bottom = new int[] {0};
|
private static final int[] slots_bottom = new int[] {0};
|
||||||
@ -54,6 +58,44 @@ public class TileEntityForceField extends TileEntityLoadedBase implements ISided
|
|||||||
|
|
||||||
private String customName;
|
private String customName;
|
||||||
|
|
||||||
|
// config options stuff.
|
||||||
|
public static int baseRadius = 16;
|
||||||
|
public static int radUpgrade = 16;
|
||||||
|
public static int shUpgrade = 50;
|
||||||
|
public static double cooldownModif = 1;
|
||||||
|
public static double healthRegenModif = 1;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getConfigName() {
|
||||||
|
return "forcefield";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void readIfPresent(JsonObject obj) {
|
||||||
|
maxPower = IConfigurableMachine.grab(obj, "L:powerCap", maxPower);
|
||||||
|
baseCon = IConfigurableMachine.grab(obj, "I:baseConsumption", baseCon);
|
||||||
|
radCon = IConfigurableMachine.grab(obj, "I:radiusConsumption", radCon);
|
||||||
|
shCon = IConfigurableMachine.grab(obj, "I:shieldConsumption", shCon);
|
||||||
|
baseRadius = IConfigurableMachine.grab(obj, "I:baseRadius", baseRadius);
|
||||||
|
radUpgrade = IConfigurableMachine.grab(obj, "I:radiusUpgrade", radUpgrade);
|
||||||
|
shUpgrade = IConfigurableMachine.grab(obj, "I:shieldUpgrade", shUpgrade);
|
||||||
|
cooldownModif = IConfigurableMachine.grab(obj, "D:cooldownModifier", cooldownModif);
|
||||||
|
healthRegenModif = IConfigurableMachine.grab(obj, "D:healthRegenModifier", healthRegenModif);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeConfig(JsonWriter writer) throws IOException {
|
||||||
|
writer.name("L:powerCap").value(maxPower);
|
||||||
|
writer.name("I:baseConsumption").value(baseCon);
|
||||||
|
writer.name("I:radiusConsumption").value(radCon);
|
||||||
|
writer.name("I:shieldConsumption").value(shCon);
|
||||||
|
writer.name("I:baseRadius").value(baseRadius);
|
||||||
|
writer.name("I:radiusUpgrade").value(radUpgrade);
|
||||||
|
writer.name("I:shieldUpgrade").value(shUpgrade);
|
||||||
|
writer.name("D:cooldownModifier").value(cooldownModif);
|
||||||
|
writer.name("D:healthRegenModifier").value(healthRegenModif);
|
||||||
|
}
|
||||||
|
|
||||||
public TileEntityForceField() {
|
public TileEntityForceField() {
|
||||||
slots = new ItemStack[3];
|
slots = new ItemStack[3];
|
||||||
}
|
}
|
||||||
@ -243,20 +285,20 @@ public class TileEntityForceField extends TileEntityLoadedBase implements ISided
|
|||||||
|
|
||||||
int rStack = 0;
|
int rStack = 0;
|
||||||
int hStack = 0;
|
int hStack = 0;
|
||||||
radius = 16;
|
radius = baseRadius;
|
||||||
maxHealth = 100;
|
maxHealth = 100;
|
||||||
|
|
||||||
if(slots[1] != null && slots[1].getItem() == ModItems.upgrade_radius) {
|
if(slots[1] != null && slots[1].getItem() == ModItems.upgrade_radius) {
|
||||||
rStack = slots[1].stackSize;
|
rStack = slots[1].stackSize;
|
||||||
radius += rStack * 16;
|
radius += rStack * radUpgrade;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(slots[2] != null && slots[2].getItem() == ModItems.upgrade_health) {
|
if(slots[2] != null && slots[2].getItem() == ModItems.upgrade_health) {
|
||||||
hStack = slots[2].stackSize;
|
hStack = slots[2].stackSize;
|
||||||
maxHealth += hStack * 50;
|
maxHealth += hStack * shUpgrade;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.powerCons = this.baseCon + rStack * this.radCon + hStack * this.shCon;
|
this.powerCons = baseCon + rStack * radCon + hStack * shCon;
|
||||||
|
|
||||||
power = Library.chargeTEFromItems(slots, 0, power, maxPower);
|
power = Library.chargeTEFromItems(slots, 0, power, maxPower);
|
||||||
|
|
||||||
@ -272,7 +314,7 @@ public class TileEntityForceField extends TileEntityLoadedBase implements ISided
|
|||||||
cooldown--;
|
cooldown--;
|
||||||
} else {
|
} else {
|
||||||
if(health < maxHealth)
|
if(health < maxHealth)
|
||||||
health += maxHealth / 100;
|
health += (maxHealth / 100) * healthRegenModif;
|
||||||
|
|
||||||
if(health > maxHealth)
|
if(health > maxHealth)
|
||||||
health = maxHealth;
|
health = maxHealth;
|
||||||
@ -314,7 +356,7 @@ public class TileEntityForceField extends TileEntityLoadedBase implements ISided
|
|||||||
|
|
||||||
if(health <= 0) {
|
if(health <= 0) {
|
||||||
health = 0;
|
health = 0;
|
||||||
cooldown = (int) (100 + radius);
|
cooldown = (int) (100 + radius * (float)cooldownModif);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user