use of ladysnake.gaspunk.gas.Gas in project Gaspunk by Ladysnake.
the class GasDeserializer method write.
@Override
public void write(JsonWriter out, Gas value) throws IOException {
out.beginObject();
if (value.getType() instanceof GasTypes) {
GasTypes type = (GasTypes) value.getType();
out.name("gasType");
out.value(type.name());
} else
throw new JsonException("Cannot serialize unknown type " + value.getType());
if (value.getParticleType() instanceof GasParticleTypes) {
GasParticleTypes type = (GasParticleTypes) value.getParticleType();
out.name("particleType");
out.value(type.name());
} else
throw new JsonException("Cannot serialize unknown type " + value.getParticleType());
out.name("color");
out.value(value.getColor());
out.name("bottleColor");
out.value(value.getBottleColor());
out.name("agents");
out.beginArray();
for (Gas.AgentEffect effect : value.getAgents()) {
out.beginObject();
out.name("agent");
out.value(GasAgents.getId(effect.getAgent()).toString());
out.name("potency");
out.value(effect.getPotency());
out.endObject();
}
out.endArray();
out.endObject();
}
use of ladysnake.gaspunk.gas.Gas in project Gaspunk by Ladysnake.
the class SicknessTests method testGasTick.
// @Test
public void testGasTick() {
IBreathingHandler handler = CapabilityBreathing.getHandler(mockedCreeper).get();
Gas gas = new Gas(GasTypes.SMOKE, 0xFF);
handler.setConcentration(gas, 0.5f);
assertTrue(handler.getGasConcentrations().containsKey(gas));
handler.tick();
assertFalse(handler.getGasConcentrations().containsKey(gas));
}
use of ladysnake.gaspunk.gas.Gas in project Gaspunk by Ladysnake.
the class SicknessTests method testMustardGas.
// @Test
public void testMustardGas() {
IBreathingHandler breathingHandler = CapabilityBreathing.getHandler(mockedCreeper).get();
final float concentration = 1.0f;
final float time = 5;
Gas gas = new Gas(GasTypes.GAS, 0xFF, NERVE, 1);
for (int i = 0; i < time; i++) {
breathingHandler.setConcentration(gas, concentration);
breathingHandler.tick();
}
float potency = gas.getAgents().get(0).getPotency();
float oracle = potency * time;
// TODO make a test for evolution in gas concentration
// assertEquals(oracle, breathingHandler.getGasConcentrations().get(ModGases.MUSTARD_GAS), 1E-8f);
}
use of ladysnake.gaspunk.gas.Gas in project Gaspunk by Ladysnake.
the class ModGases method addGases.
@SubscribeEvent
public static void addGases(RegistryEvent.Register<PotionType> event) {
REGISTRY.register(new SuspendableGas(GasTypes.GAS, 0x00FFFFFF, GasAgents.getAgent(new ResourceLocation(GasPunk.MOD_ID, "nerve")), 0.8F).setRegistryName("sarin_gas"));
REGISTRY.register(new Gas(GasTypes.GAS, GasParticleTypes.GAS, 0x99FFFFFF, 0xAA0033FF, ImmutableList.of(), new String[0]).setRegistryName("air"));
for (EnumDyeColor color : EnumDyeColor.values()) {
// this is probably illegal in 53 states but I didn't want to parse the value back from the table
REGISTRY.register(new Gas(GasTypes.SMOKE, 0xFF000000 | (int) ReflectionHelper.getPrivateValue(EnumDyeColor.class, color, "colorValue", "field_193351_w")).setRegistryName("colored_smoke_" + color.getName()));
}
}
use of ladysnake.gaspunk.gas.Gas in project Gaspunk by Ladysnake.
the class GasDeserializer method loadGases.
@SubscribeEvent
public static void loadGases(RegistryEvent.Register<IGas> event) {
ModContainer gaspunkContainer = Loader.instance().activeModContainer();
Loader.instance().getActiveModList().forEach(GasDeserializer::loadGases);
Loader.instance().setActiveModContainer(gaspunkContainer);
File configFolder = new File(Loader.instance().getConfigDir(), GasPunk.MOD_ID + "/custom_gases");
// if the config folder was just created or couldn't be created, no need to search it
try {
if (!configFolder.mkdirs() && configFolder.exists()) {
Files.walk(configFolder.toPath()).forEach(path -> loadGases(configFolder.toPath(), path));
} else if (configFolder.exists()) {
// generate an example gas file
IGas exampleGas = new Gas.Builder().addAgent(GasAgents.getAgent(new ResourceLocation(GasPunk.MOD_ID, "lachrymator")), 0.5f).addAgent(GasAgents.getAgent(new ResourceLocation(GasPunk.MOD_ID, "nerve")), 0.375f).setColor(0x55CAFE66).setBottleColor(0x75DADD10).setType(GasTypes.GAS).addTooltipLine("For more examples, check the technical wiki:").addTooltipLine("https://github.com/Ladysnake/Gaspunk/wiki").build();
Files.write(configFolder.toPath().resolve("_example.json"), GSON.toJson(exampleGas).getBytes(), StandardOpenOption.CREATE_NEW);
}
} catch (IOException e) {
GasPunk.LOGGER.error("Error while loading gases from config", e);
}
}
Aggregations