Merge branch 'HbmMods:master' into master

This commit is contained in:
BallOfEnergy 2023-06-12 14:19:30 -05:00 committed by GitHub
commit 3875309697
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 598 additions and 254 deletions

View File

@ -1,5 +1,8 @@
import org.gradle.plugins.ide.eclipse.model.internal.FileReferenceFactory
import java.nio.file.Files
import java.nio.file.Paths
import java.nio.file.StandardCopyOption
buildscript {
repositories {
@ -53,7 +56,7 @@ eclipse.classpath.file.whenMerged { cp ->
}
// Create file reference factory
def fileref = new org.gradle.plugins.ide.eclipse.model.internal.FileReferenceFactory()
def fileref = new FileReferenceFactory()
// Find all codechicken development jars
cp.entries.findAll { entry -> entry.path.contains("codechicken") && entry.path.endsWith("-dev.jar") }.forEach { entry ->
@ -132,12 +135,20 @@ if(Files.exists(Paths.get("curseforge.properties"))) {
projectId = cfprops.project_id
releaseType = "release"
displayName = "Hbm's Nuclear Tech Mod " + version_name.replace("_", "") + " for Minecraft 1.7.10"
gameVersions.addAll([
"Forge",
"Java 8",
"Client", "Server"
])
if (Files.exists(Paths.get("changelog"))) {
changelog = String.join("\r\n", Files.readAllLines(Paths.get("changelog")))
// Perform a backup of the changelog and create a new file for next changes
doLast {
Files.move(Paths.get("changelog"), Paths.get("changelog.bak"))
Files.move(Paths.get("changelog"), Paths.get("changelog.bak"), StandardCopyOption.REPLACE_EXISTING)
Files.createFile(Paths.get("changelog"))
}
}

View File

@ -0,0 +1,5 @@
# CurseForge API token (obtainable from https://legacy.curseforge.com/account/api-tokens)
api_key=
# CurseForge project ID
project_id=

View File

@ -27,6 +27,7 @@ public class BombConfig {
public static int limitExplosionLifespan = 0;
public static int rain = 0;
public static int cont = 0;
public static boolean chunkloading = true;
public static void loadFromConfig(Configuration config) {
@ -100,5 +101,7 @@ public class BombConfig {
Property rainCont = config.get(CATEGORY_NUKE, "6.06_falloutRainRadiation", 0);
rainCont.comment = "Radiation in 100th RADs created by fallout rain";
cont = rainCont.getInt();
chunkloading = CommonConfig.createConfigBool(config, CATEGORY_NUKE, "6.XX_enableChunkLoading", "Allows all types of procedural explosions to keep the central chunk loaded.", true);
}
}

View File

@ -7,11 +7,10 @@ import com.hbm.explosion.ExplosionBalefire;
import com.hbm.explosion.ExplosionNukeGeneric;
import com.hbm.main.MainRegistry;
import net.minecraft.entity.Entity;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
public class EntityBalefire extends Entity {
public class EntityBalefire extends EntityExplosionChunkloading {
public int age = 0;
public int destructionRange = 0;
@ -53,48 +52,46 @@ public class EntityBalefire extends Entity {
super(p_i1582_1_);
}
@Override
public void onUpdate() {
super.onUpdate();
if(!this.did)
{
if(GeneralConfig.enableExtendedLogging && !worldObj.isRemote)
MainRegistry.logger.log(Level.INFO, "[NUKE] Initialized BF explosion at " + posX + " / " + posY + " / " + posZ + " with strength " + destructionRange + "!");
exp = new ExplosionBalefire((int)this.posX, (int)this.posY, (int)this.posZ, this.worldObj, this.destructionRange);
this.did = true;
}
speed += 1; //increase speed to keep up with expansion
boolean flag = false;
for(int i = 0; i < this.speed; i++)
{
flag = exp.update();
if(flag) {
this.setDead();
}
}
if(!mute && rand.nextInt(5) == 0)
this.worldObj.playSoundEffect(this.posX, this.posY, this.posZ, "random.explode", 10000.0F, 0.8F + this.rand.nextFloat() * 0.2F);
if(!flag) {
if(!mute)
this.worldObj.playSoundEffect(this.posX, this.posY, this.posZ, "ambient.weather.thunder", 10000.0F, 0.8F + this.rand.nextFloat() * 0.2F);
ExplosionNukeGeneric.dealDamage(this.worldObj, this.posX, this.posY, this.posZ, this.destructionRange * 2);
}
age++;
}
@Override
protected void entityInit() { }
public void onUpdate() {
super.onUpdate();
if(!worldObj.isRemote) loadChunk((int) Math.floor(posX / 16D), (int) Math.floor(posZ / 16D));
if(!this.did) {
if(GeneralConfig.enableExtendedLogging && !worldObj.isRemote)
MainRegistry.logger.log(Level.INFO, "[NUKE] Initialized BF explosion at " + posX + " / " + posY + " / " + posZ + " with strength " + destructionRange + "!");
exp = new ExplosionBalefire((int) this.posX, (int) this.posY, (int) this.posZ, this.worldObj, this.destructionRange);
this.did = true;
}
speed += 1; // increase speed to keep up with expansion
boolean flag = false;
for(int i = 0; i < this.speed; i++) {
flag = exp.update();
if(flag) {
clearChunkLoader();
this.setDead();
}
}
if(!mute && rand.nextInt(5) == 0)
this.worldObj.playSoundEffect(this.posX, this.posY, this.posZ, "random.explode", 10000.0F, 0.8F + this.rand.nextFloat() * 0.2F);
if(!flag) {
if(!mute)
this.worldObj.playSoundEffect(this.posX, this.posY, this.posZ, "ambient.weather.thunder", 10000.0F, 0.8F + this.rand.nextFloat() * 0.2F);
ExplosionNukeGeneric.dealDamage(this.worldObj, this.posX, this.posY, this.posZ, this.destructionRange * 2);
}
age++;
}
public EntityBalefire mute() {
this.mute = true;

View File

@ -1,49 +0,0 @@
package com.hbm.entity.logic;
import net.minecraft.entity.Entity;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
public abstract class EntityEnvirEffect extends Entity {
public int maxAge = 100;
public int blockRadius = 7;
public int entityRadius = 7;
public int chance = 10;
public boolean hasBlockEffect = true;
public boolean hasEntityEffect = true;
public EntityEnvirEffect(World p_i1582_1_) {
super(p_i1582_1_);
}
@Override
protected void entityInit() {
}
@Override
protected void readEntityFromNBT(NBTTagCompound nbt) {
this.ticksExisted = nbt.getInteger("lifetime");
this.maxAge = nbt.getInteger("lifecap");
}
@Override
protected void writeEntityToNBT(NBTTagCompound nbt) {
nbt.setInteger("lifetime", this.ticksExisted);
nbt.setInteger("lifecap", this.maxAge);
}
public void onUpdate() {
if(hasBlockEffect && rand.nextInt(chance) == 0)
applyBlockEffect();
if(hasEntityEffect && rand.nextInt(chance) == 0)
applyEntityEffect();
}
private void applyBlockEffect() { };
private void applyEntityEffect() { };
}

View File

@ -1,15 +0,0 @@
package com.hbm.entity.logic;
import net.minecraft.world.World;
public class EntityEnvirEffectRad extends EntityEnvirEffect {
public EntityEnvirEffectRad(World p_i1582_1_) {
super(p_i1582_1_);
}
public void randomizeAge(int min, int max) {
this.maxAge = min + rand.nextInt(max - min);
}
}

View File

@ -0,0 +1,51 @@
package com.hbm.entity.logic;
import com.hbm.main.MainRegistry;
import net.minecraft.entity.Entity;
import net.minecraft.world.ChunkCoordIntPair;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeChunkManager;
import net.minecraftforge.common.ForgeChunkManager.Ticket;
import net.minecraftforge.common.ForgeChunkManager.Type;
public abstract class EntityExplosionChunkloading extends Entity implements IChunkLoader {
private Ticket loaderTicket;
private ChunkCoordIntPair loadedChunk;
public EntityExplosionChunkloading(World world) {
super(world);
}
@Override
protected void entityInit() {
init(ForgeChunkManager.requestTicket(MainRegistry.instance, worldObj, Type.ENTITY));
}
@Override
public void init(Ticket ticket) {
if(!worldObj.isRemote && ticket != null) {
if(loaderTicket == null) {
loaderTicket = ticket;
loaderTicket.bindEntity(this);
loaderTicket.getModData();
}
ForgeChunkManager.forceChunk(loaderTicket, new ChunkCoordIntPair(chunkCoordX, chunkCoordZ));
}
}
public void loadChunk(int x, int z) {
if(this.loadedChunk == null) {
this.loadedChunk = new ChunkCoordIntPair(x, z);
ForgeChunkManager.forceChunk(loaderTicket, loadedChunk);
}
}
public void clearChunkLoader() {
if(!worldObj.isRemote && loaderTicket != null && loadedChunk != null) {
ForgeChunkManager.unforceChunk(loaderTicket, loadedChunk);
}
}
}

View File

@ -20,14 +20,13 @@ import com.hbm.packet.AuxParticlePacketNT;
import com.hbm.packet.PacketDispatcher;
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
@Spaghetti("why???")
public class EntityNukeExplosionMK3 extends Entity {
public class EntityNukeExplosionMK3 extends EntityExplosionChunkloading {
public int age = 0;
public int destructionRange = 0;
@ -59,31 +58,32 @@ public class EntityNukeExplosionMK3 extends Entity {
long time = nbt.getLong("milliTime");
if(BombConfig.limitExplosionLifespan > 0 && System.currentTimeMillis() - time > BombConfig.limitExplosionLifespan * 1000)
if(BombConfig.limitExplosionLifespan > 0 && System.currentTimeMillis() - time > BombConfig.limitExplosionLifespan * 1000) {
this.clearChunkLoader();
this.setDead();
}
if(this.waste)
{
exp = new ExplosionNukeAdvanced((int)this.posX, (int)this.posY, (int)this.posZ, this.worldObj, this.destructionRange, this.coefficient, 0);
if(this.waste) {
exp = new ExplosionNukeAdvanced((int) this.posX, (int) this.posY, (int) this.posZ, this.worldObj, this.destructionRange, this.coefficient, 0);
exp.readFromNbt(nbt, "exp_");
wst = new ExplosionNukeAdvanced((int)this.posX, (int)this.posY, (int)this.posZ, this.worldObj, (int)(this.destructionRange * 1.8), this.coefficient, 2);
wst = new ExplosionNukeAdvanced((int) this.posX, (int) this.posY, (int) this.posZ, this.worldObj, (int) (this.destructionRange * 1.8), this.coefficient, 2);
wst.readFromNbt(nbt, "wst_");
vap = new ExplosionNukeAdvanced((int)this.posX, (int)this.posY, (int)this.posZ, this.worldObj, (int)(this.destructionRange * 2.5), this.coefficient, 1);
vap = new ExplosionNukeAdvanced((int) this.posX, (int) this.posY, (int) this.posZ, this.worldObj, (int) (this.destructionRange * 2.5), this.coefficient, 1);
vap.readFromNbt(nbt, "vap_");
} else {
} else {
if(extType == 0) {
expl = new ExplosionFleija((int)this.posX, (int)this.posY, (int)this.posZ, this.worldObj, this.destructionRange, this.coefficient, this.coefficient2);
if(extType == 0) {
expl = new ExplosionFleija((int) this.posX, (int) this.posY, (int) this.posZ, this.worldObj, this.destructionRange, this.coefficient, this.coefficient2);
expl.readFromNbt(nbt, "expl_");
}
if(extType == 1) {
sol = new ExplosionSolinium((int)this.posX, (int)this.posY, (int)this.posZ, this.worldObj, this.destructionRange, this.coefficient, this.coefficient2);
sol.readFromNbt(nbt, "sol_");
}
}
this.did = true;
}
if(extType == 1) {
sol = new ExplosionSolinium((int) this.posX, (int) this.posY, (int) this.posZ, this.worldObj, this.destructionRange, this.coefficient, this.coefficient2);
sol.readFromNbt(nbt, "sol_");
}
}
this.did = true;
}
@Override
@ -120,6 +120,8 @@ public class EntityNukeExplosionMK3 extends Entity {
@Override
public void onUpdate() {
super.onUpdate();
if(!worldObj.isRemote) loadChunk((int) Math.floor(posX / 16D), (int) Math.floor(posZ / 16D));
if(!this.did)
{
@ -149,25 +151,31 @@ public class EntityNukeExplosionMK3 extends Entity {
boolean flag = false;
boolean flag3 = false;
for(int i = 0; i < this.speed; i++)
{
if(waste) {
flag = exp.update();
wst.update();
flag3 = vap.update();
if(flag3) {
this.setDead();
}
} else {
if(extType == 0)
if(expl.update())
this.setDead();
if(extType == 1)
if(sol.update())
this.setDead();
}
}
for(int i = 0; i < this.speed; i++) {
if(waste) {
flag = exp.update();
wst.update();
flag3 = vap.update();
if(flag3) {
this.clearChunkLoader();
this.setDead();
}
} else {
if(extType == 0) {
if(expl.update()) {
this.clearChunkLoader();
this.setDead();
}
}
if(extType == 1) {
if(sol.update()) {
this.clearChunkLoader();
this.setDead();
}
}
}
}
if(!flag)
{
@ -196,9 +204,6 @@ public class EntityNukeExplosionMK3 extends Entity {
age++;
}
@Override
protected void entityInit() { }
public static HashMap<ATEntry, Long> at = new HashMap();

View File

@ -14,7 +14,6 @@ import com.hbm.util.ContaminationUtil;
import com.hbm.util.ContaminationUtil.ContaminationType;
import com.hbm.util.ContaminationUtil.HazardType;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
@ -22,7 +21,7 @@ import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
public class EntityNukeExplosionMK5 extends Entity {
public class EntityNukeExplosionMK5 extends EntityExplosionChunkloading {
//Strength of the blast
public int strength;
@ -52,9 +51,12 @@ public class EntityNukeExplosionMK5 extends Entity {
public void onUpdate() {
if(strength == 0) {
this.clearChunkLoader();
this.setDead();
return;
}
if(!worldObj.isRemote) loadChunk((int) Math.floor(posX / 16D), (int) Math.floor(posZ / 16D));
for(Object player : this.worldObj.playerEntities) {
((EntityPlayer)player).triggerAchievement(MainRegistry.achManhattan);
@ -92,9 +94,11 @@ public class EntityNukeExplosionMK5 extends Entity {
fallout.setScale((int)(this.length * 2.5 + falloutAdd) * BombConfig.falloutRange / 100);
this.worldObj.spawnEntityInWorld(fallout);
this.clearChunkLoader();
this.setDead();
} else {
this.clearChunkLoader();
this.setDead();
}
}

View File

@ -8,11 +8,10 @@ import com.hbm.explosion.ExplosionTom;
import com.hbm.main.MainRegistry;
import com.hbm.saveddata.TomSaveData;
import net.minecraft.entity.Entity;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
public class EntityTomBlast extends Entity {
public class EntityTomBlast extends EntityExplosionChunkloading {
public int age = 0;
public int destructionRange = 0;
@ -54,6 +53,8 @@ public class EntityTomBlast extends Entity {
public void onUpdate() {
super.onUpdate();
if(!worldObj.isRemote) loadChunk((int) Math.floor(posX / 16D), (int) Math.floor(posZ / 16D));
if(!this.did) {
if(GeneralConfig.enableExtendedLogging && !worldObj.isRemote)
@ -89,8 +90,4 @@ public class EntityTomBlast extends Entity {
age++;
}
@Override
protected void entityInit() {
}
}

View File

@ -48,46 +48,36 @@ public abstract class EntityMissileBaseAdvanced extends Entity implements IChunk
targetZ = (int) posZ;
}
public boolean canBeCollidedWith()
{
return true;
}
public boolean attackEntityFrom(DamageSource p_70097_1_, float p_70097_2_)
{
if (this.isEntityInvulnerable())
{
return false;
}
else
{
if (!this.isDead && !this.worldObj.isRemote)
{
health -= p_70097_2_;
if (this.health <= 0)
{
this.setDead();
this.killMissile();
}
}
public boolean canBeCollidedWith() {
return true;
}
return true;
}
}
private void killMissile() {
ExplosionLarge.explode(worldObj, posX, posY, posZ, 5, true, false, true);
ExplosionLarge.spawnShrapnelShower(worldObj, posX, posY, posZ, motionX, motionY, motionZ, 15, 0.075);
ExplosionLarge.spawnMissileDebris(worldObj, posX, posY, posZ, motionX, motionY, motionZ, 0.25, getDebris(), getDebrisRareDrop());
}
public boolean attackEntityFrom(DamageSource p_70097_1_, float p_70097_2_) {
if(this.isEntityInvulnerable()) {
return false;
} else {
if(!this.isDead && !this.worldObj.isRemote) {
health -= p_70097_2_;
if(this.health <= 0) {
this.setDead();
this.killMissile();
}
}
return true;
}
}
private void killMissile() {
ExplosionLarge.explode(worldObj, posX, posY, posZ, 5, true, false, true);
ExplosionLarge.spawnShrapnelShower(worldObj, posX, posY, posZ, motionX, motionY, motionZ, 15, 0.075);
ExplosionLarge.spawnMissileDebris(worldObj, posX, posY, posZ, motionX, motionY, motionZ, 0.25, getDebris(), getDebrisRareDrop());
}
public EntityMissileBaseAdvanced(World world, float x, float y, float z, int a, int b) {
super(world);
this.ignoreFrustumCheck = true;
/*this.posX = x;
this.posY = y;
this.posZ = z;*/
this.setLocationAndAngles(x, y, z, 0, 0);
startX = (int) x;
startZ = (int) z;
@ -95,19 +85,19 @@ public abstract class EntityMissileBaseAdvanced extends Entity implements IChunk
targetZ = b;
this.motionY = 2;
Vec3 vector = Vec3.createVectorHelper(targetX - startX, 0, targetZ - startZ);
accelXZ = decelY = 1/vector.lengthVector();
Vec3 vector = Vec3.createVectorHelper(targetX - startX, 0, targetZ - startZ);
accelXZ = decelY = 1 / vector.lengthVector();
decelY *= 2;
velocity = 1;
this.setSize(1.5F, 1.5F);
this.setSize(1.5F, 1.5F);
}
@Override
protected void entityInit() {
init(ForgeChunkManager.requestTicket(MainRegistry.instance, worldObj, Type.ENTITY));
this.dataWatcher.addObject(8, Integer.valueOf(this.health));
this.dataWatcher.addObject(8, Integer.valueOf(this.health));
}
@Override
@ -212,7 +202,6 @@ public abstract class EntityMissileBaseAdvanced extends Entity implements IChunk
}
if(!this.worldObj.isRemote)
//this.worldObj.spawnEntityInWorld(new EntitySmokeFX(this.worldObj, this.posX, this.posY, this.posZ, 0.0, 0.0, 0.0));
PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacket(posX, posY, posZ, 2),
new TargetPoint(worldObj.provider.dimensionId, posX, posY, posZ, 300));
@ -220,30 +209,28 @@ public abstract class EntityMissileBaseAdvanced extends Entity implements IChunk
this.worldObj.getBlock((int)this.posX, (int)this.posY, (int)this.posZ) != Blocks.water &&
this.worldObj.getBlock((int)this.posX, (int)this.posY, (int)this.posZ) != Blocks.flowing_water) {
if(!this.worldObj.isRemote)
{
onImpact();
}
this.setDead();
return;
}
loadNeighboringChunks((int)(posX / 16), (int)(posZ / 16));
if(motionY < -1 && this.isCluster && !worldObj.isRemote) {
cluster();
this.setDead();
return;
}
if(!this.worldObj.isRemote) {
onImpact();
}
this.killAndClear();
return;
}
loadNeighboringChunks((int) (posX / 16), (int) (posZ / 16));
if(motionY < -1 && this.isCluster && !worldObj.isRemote) {
cluster();
this.setDead();
return;
}
}
}
}
@Override
@Override
@SideOnly(Side.CLIENT)
public boolean isInRangeToRenderDist(double distance)
{
return distance < 500000;
}
public boolean isInRangeToRenderDist(double distance) {
return true;
}
public abstract void onImpact();
@ -272,30 +259,31 @@ public abstract class EntityMissileBaseAdvanced extends Entity implements IChunk
List<ChunkCoordIntPair> loadedChunks = new ArrayList<ChunkCoordIntPair>();
public void loadNeighboringChunks(int newChunkX, int newChunkZ)
{
if(!worldObj.isRemote && loaderTicket != null)
{
for(ChunkCoordIntPair chunk : loadedChunks)
{
ForgeChunkManager.unforceChunk(loaderTicket, chunk);
}
public void loadNeighboringChunks(int newChunkX, int newChunkZ) {
if(!worldObj.isRemote && loaderTicket != null) {
clearChunkLoader();
loadedChunks.clear();
loadedChunks.add(new ChunkCoordIntPair(newChunkX, newChunkZ));
loadedChunks.add(new ChunkCoordIntPair(newChunkX + 1, newChunkZ + 1));
loadedChunks.add(new ChunkCoordIntPair(newChunkX - 1, newChunkZ - 1));
loadedChunks.add(new ChunkCoordIntPair(newChunkX + 1, newChunkZ - 1));
loadedChunks.add(new ChunkCoordIntPair(newChunkX - 1, newChunkZ + 1));
loadedChunks.add(new ChunkCoordIntPair(newChunkX + 1, newChunkZ));
loadedChunks.add(new ChunkCoordIntPair(newChunkX, newChunkZ + 1));
loadedChunks.add(new ChunkCoordIntPair(newChunkX - 1, newChunkZ));
loadedChunks.add(new ChunkCoordIntPair(newChunkX, newChunkZ - 1));
loadedChunks.clear();
loadedChunks.add(new ChunkCoordIntPair(newChunkX, newChunkZ));
loadedChunks.add(new ChunkCoordIntPair(newChunkX + (int) Math.ceil((this.posX + this.motionX) / 16D), newChunkZ + (int) Math.ceil((this.posZ + this.motionZ) / 16D)));
for(ChunkCoordIntPair chunk : loadedChunks)
{
ForgeChunkManager.forceChunk(loaderTicket, chunk);
}
}
}
for(ChunkCoordIntPair chunk : loadedChunks) {
ForgeChunkManager.forceChunk(loaderTicket, chunk);
}
}
}
public void killAndClear() {
this.setDead();
this.clearChunkLoader();
}
public void clearChunkLoader() {
if(!worldObj.isRemote && loaderTicket != null) {
for(ChunkCoordIntPair chunk : loadedChunks) {
ForgeChunkManager.unforceChunk(loaderTicket, chunk);
}
}
}
}

View File

@ -1,5 +1,6 @@
package com.hbm.explosion.nt;
@Deprecated
public interface IExplosionLogic {
public void updateLogic();

View File

@ -10,6 +10,7 @@ import net.minecraft.init.Blocks;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
@Deprecated
public class Mark5 implements IExplosionLogic {
//holds rays after being calculated up to where the blocks get removed

View File

@ -123,6 +123,7 @@ public class PollutionHandler {
try {
File pollutionFile = new File(dirPath, fileName);
if(!pollutionFile.getParentFile().exists()) pollutionFile.getParentFile().mkdirs();
if(!pollutionFile.exists()) pollutionFile.createNewFile();
NBTTagCompound data = perWorld.get(world).writeToNBT();
CompressedStreamTools.writeCompressed(data, new FileOutputStream(pollutionFile));

View File

@ -48,7 +48,7 @@ public class FluidType {
public double compression = DEFAULT_COMPRESSION;
public HashMap<Class, Object> containers = new HashMap();
private HashMap<Class<? extends FluidTrait>, FluidTrait> traits = new HashMap();
public HashMap<Class<? extends FluidTrait>, FluidTrait> traits = new HashMap();
//public List<EnumFluidTrait> enumTraits = new ArrayList();
private ResourceLocation texture;

View File

@ -1,12 +1,22 @@
package com.hbm.inventory.fluid;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.stream.JsonWriter;
import com.hbm.inventory.fluid.trait.*;
import com.hbm.inventory.fluid.trait.FluidTraitSimple.*;
import com.hbm.lib.ModDamageSource;
import com.hbm.main.MainRegistry;
import com.hbm.potion.HbmPotion;
import com.hbm.inventory.fluid.trait.FT_Combustible.FuelGrade;
import com.hbm.inventory.fluid.trait.FT_Coolable.CoolingType;
@ -20,6 +30,8 @@ import net.minecraft.potion.PotionEffect;
public class Fluids {
public static final Gson gson = new Gson();
public static FluidType NONE;
public static FluidType WATER;
public static FluidType STEAM;
@ -562,6 +574,73 @@ public class Fluids {
registerCalculatedFuel(SYNGAS, (coalHeat * (1000 /* bucket */ / 100 /* mB per coal */) * flammabilityLow * demandLow * complexityChemplant) * 1.5, 1.25, FuelGrade.GAS); //same as coal oil, +50% bonus
registerCalculatedFuel(OXYHYDROGEN, 5_000, 3, FuelGrade.GAS); // whatever
File folder = MainRegistry.configHbmDir;
File config = new File(folder.getAbsolutePath() + File.separatorChar + "hbmFluids.json");
File template = new File(folder.getAbsolutePath() + File.separatorChar + "_hbmFluids.json");
if(!config.exists()) {
writeDefault(template);
} else {
readConfig(config);
}
}
private static void writeDefault(File file) {
try {
JsonWriter writer = new JsonWriter(new FileWriter(file));
writer.setIndent(" ");
writer.beginObject();
for(FluidType type : metaOrder) {
writer.name(type.getUnlocalizedName()).beginObject();
for(Entry<Class<? extends FluidTrait>, FluidTrait> entry : type.traits.entrySet()) {
writer.name(FluidTrait.traitNameMap.inverse().get(entry.getKey())).beginObject();
entry.getValue().serializeJSON(writer);
writer.endObject();
}
writer.endObject();
}
writer.endObject();
writer.close();
} catch(IOException e) {
e.printStackTrace();
}
}
private static void readConfig(File config) {
try {
JsonObject json = gson.fromJson(new FileReader(config), JsonObject.class);
for(FluidType type : metaOrder) {
JsonElement element = json.get(type.getUnlocalizedName());
if(element != null) {
type.traits.clear();
JsonObject obj = element.getAsJsonObject();
for(Entry<String, JsonElement> entry : obj.entrySet()) {
Class<? extends FluidTrait> traitClass = FluidTrait.traitNameMap.get(entry.getKey());
try {
FluidTrait trait = traitClass.newInstance();
trait.deserializeJSON(entry.getValue().getAsJsonObject());
type.addTraits(trait);
} catch(Exception ex) {
ex.printStackTrace();
}
}
}
}
} catch(Exception ex) {
ex.printStackTrace();
}
}
private static void registerCalculatedFuel(FluidType type, double base, double combustMult, FuelGrade grade) {

View File

@ -1,7 +1,10 @@
package com.hbm.inventory.fluid.trait;
import java.io.IOException;
import java.util.List;
import com.google.gson.JsonObject;
import com.google.gson.stream.JsonWriter;
import com.hbm.util.BobMathUtil;
import net.minecraft.util.EnumChatFormatting;
@ -11,6 +14,8 @@ public class FT_Combustible extends FluidTrait {
protected FuelGrade fuelGrade;
protected long combustionEnergy;
public FT_Combustible() { }
public FT_Combustible(FuelGrade grade, long energy) {
this.fuelGrade = grade;
this.combustionEnergy = energy;
@ -53,4 +58,16 @@ public class FT_Combustible extends FluidTrait {
return this.grade;
}
}
@Override
public void serializeJSON(JsonWriter writer) throws IOException {
writer.name("energy").value(combustionEnergy);
writer.name("grade").value(fuelGrade.name());
}
@Override
public void deserializeJSON(JsonObject obj) {
this.combustionEnergy = obj.get("energy").getAsLong();
this.fuelGrade = FuelGrade.valueOf(obj.get("grade").getAsString());
}
}

View File

@ -1,9 +1,14 @@
package com.hbm.inventory.fluid.trait;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;
import com.google.gson.JsonObject;
import com.google.gson.stream.JsonWriter;
import com.hbm.inventory.fluid.FluidType;
import com.hbm.inventory.fluid.Fluids;
import net.minecraft.util.EnumChatFormatting;
@ -11,10 +16,12 @@ public class FT_Coolable extends FluidTrait {
protected HashMap<CoolingType, Double> efficiency = new HashMap();
public final FluidType coolsTo;
public FluidType coolsTo;
public int amountReq;
public int amountProduced;
public final int heatEnergy;
public int heatEnergy;
public FT_Coolable() { }
public FT_Coolable(FluidType type, int req, int prod, int heat) {
this.coolsTo = type;
@ -56,4 +63,28 @@ public class FT_Coolable extends FluidTrait {
this.name = name;
}
}
@Override
public void serializeJSON(JsonWriter writer) throws IOException {
writer.name("coolsTo").value(this.coolsTo.getUnlocalizedName());
writer.name("amountReq").value(this.amountReq);
writer.name("amountProd").value(this.amountProduced);
writer.name("heatEnergy").value(this.heatEnergy);
for(Entry<CoolingType, Double> entry : this.efficiency.entrySet()) {
writer.name(entry.getKey().name()).value(entry.getValue());
}
}
@Override
public void deserializeJSON(JsonObject obj) {
this.coolsTo = Fluids.fromName(obj.get("coolsTo").getAsString());
this.amountReq = obj.get("amountReq").getAsInt();
this.amountProduced = obj.get("amountProd").getAsInt();
this.heatEnergy = obj.get("heatEnergy").getAsInt();
for(CoolingType type : CoolingType.values()) {
if(obj.has(type.name())) efficiency.put(type, obj.get(type.name()).getAsDouble());
}
}
}

View File

@ -1,7 +1,11 @@
package com.hbm.inventory.fluid.trait;
import java.io.IOException;
import java.util.List;
import com.google.gson.JsonObject;
import com.google.gson.stream.JsonWriter;
import net.minecraft.util.EnumChatFormatting;
public class FT_Corrosive extends FluidTrait {
@ -9,6 +13,8 @@ public class FT_Corrosive extends FluidTrait {
/* 0-100 */
private int rating;
public FT_Corrosive() { }
public FT_Corrosive(int rating) {
this.rating = rating;
}
@ -29,4 +35,14 @@ public class FT_Corrosive extends FluidTrait {
else
info.add(EnumChatFormatting.YELLOW + "[Corrosive]");
}
@Override
public void serializeJSON(JsonWriter writer) throws IOException {
writer.name("rating").value(rating);
}
@Override
public void deserializeJSON(JsonObject obj) {
this.rating = obj.get("rating").getAsInt();
}
}

View File

@ -1,7 +1,10 @@
package com.hbm.inventory.fluid.trait;
import java.io.IOException;
import java.util.List;
import com.google.gson.JsonObject;
import com.google.gson.stream.JsonWriter;
import com.hbm.util.BobMathUtil;
import net.minecraft.util.EnumChatFormatting;
@ -11,6 +14,8 @@ public class FT_Flammable extends FluidTrait {
/** How much heat energy (usually translates into HE 1:1) 1000mB hold */
private long energy;
public FT_Flammable() { }
public FT_Flammable(long energy) {
this.energy = energy;
}
@ -28,4 +33,14 @@ public class FT_Flammable extends FluidTrait {
if(energy > 0)
info.add(EnumChatFormatting.YELLOW + "Provides " + EnumChatFormatting.RED + "" + BobMathUtil.getShortNumber(energy) + "TU " + EnumChatFormatting.YELLOW + "per bucket");
}
@Override
public void serializeJSON(JsonWriter writer) throws IOException {
writer.name("energy").value(energy);
}
@Override
public void deserializeJSON(JsonObject obj) {
this.energy = obj.get("energy").getAsLong();
}
}

View File

@ -1,12 +1,18 @@
package com.hbm.inventory.fluid.trait;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.stream.JsonWriter;
import com.hbm.inventory.fluid.FluidType;
import com.hbm.inventory.fluid.Fluids;
import net.minecraft.util.EnumChatFormatting;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;
public class FT_Heatable extends FluidTrait {
@ -71,4 +77,45 @@ public class FT_Heatable extends FluidTrait {
this.name = name;
}
}
@Override
public void serializeJSON(JsonWriter writer) throws IOException {
writer.name("steps").beginArray();
for(HeatingStep step : steps) {
writer.beginObject();
writer.name("typeProduced").value(step.typeProduced.getUnlocalizedName());
writer.name("amountReq").value(step.amountReq);
writer.name("amountProd").value(step.amountProduced);
writer.name("heatReq").value(step.heatReq);
writer.endObject();
}
writer.endArray();
for(Entry<HeatingType, Double> entry : this.efficiency.entrySet()) {
writer.name(entry.getKey().name()).value(entry.getValue());
}
}
@Override
public void deserializeJSON(JsonObject obj) {
JsonArray steps = obj.get("steps").getAsJsonArray();
for(int i = 0; i < steps.size(); i++) {
JsonObject step = steps.get(i).getAsJsonObject();
this.steps.add(new HeatingStep(
step.get("amountReq").getAsInt(),
step.get("heatReq").getAsInt(),
Fluids.fromName(step.get("typeProduced").getAsString()),
step.get("amountProd").getAsInt()
));
}
for(HeatingType type : HeatingType.values()) {
if(obj.has(type.name())) efficiency.put(type, obj.get(type.name()).getAsDouble());
}
}
}

View File

@ -1,7 +1,11 @@
package com.hbm.inventory.fluid.trait;
import java.io.IOException;
import java.util.List;
import com.google.gson.JsonObject;
import com.google.gson.stream.JsonWriter;
import net.minecraft.util.EnumChatFormatting;
@Deprecated //use FT_Toxin instead
@ -10,6 +14,8 @@ public class FT_Poison extends FluidTrait {
protected boolean withering = false;
protected int level = 0;
public FT_Poison() { }
public FT_Poison(boolean withering, int level) {
this.withering = withering;
this.level = level;
@ -27,4 +33,14 @@ public class FT_Poison extends FluidTrait {
public void addInfoHidden(List<String> info) {
info.add(EnumChatFormatting.GREEN + "[Toxic Fumes]");
}
@Override public void serializeJSON(JsonWriter writer) throws IOException {
writer.name("level").value(this.level);
writer.name("withering").value(this.withering);
}
@Override public void deserializeJSON(JsonObject obj) {
this.level = obj.get("level").getAsInt();
this.withering = obj.get("withering").getAsBoolean();
}
}

View File

@ -1,8 +1,12 @@
package com.hbm.inventory.fluid.trait;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.stream.JsonWriter;
import com.hbm.util.ArmorRegistry;
import com.hbm.util.ArmorUtil;
import com.hbm.util.I18nUtil;
@ -132,4 +136,76 @@ public class FT_Toxin extends FluidTrait {
}
}
}
@Override public void serializeJSON(JsonWriter writer) throws IOException {
writer.name("entries").beginArray();
for(ToxinEntry entry : entries) {
writer.beginObject();
if(entry instanceof ToxinDirectDamage) {
ToxinDirectDamage e = (ToxinDirectDamage) entry;
writer.name("type").value("directdamage");
writer.name("amount").value(e.amount);
writer.name("source").value(e.damage.damageType);
writer.name("delay").value(e.delay);
writer.name("hazmat").value(e.fullBody);
writer.name("masktype").value(e.clazz.name());
}
if(entry instanceof ToxinEffects) {
ToxinEffects e = (ToxinEffects) entry;
writer.name("type").value("effects");
writer.name("effects").beginArray();
writer.setIndent("");
for(PotionEffect effect : e.effects) {
writer.beginArray();
writer.value(effect.getPotionID()).value(effect.getDuration()).value(effect.getAmplifier()).value(effect.getIsAmbient());
writer.endArray();
}
writer.endArray();
writer.setIndent(" ");
writer.name("hazmat").value(e.fullBody);
writer.name("masktype").value(e.clazz.name());
}
writer.endObject();
}
writer.endArray();
}
@Override public void deserializeJSON(JsonObject obj) {
JsonArray array = obj.get("entries").getAsJsonArray();
for(int i = 0; i < array.size(); i++) {
JsonObject entry = array.get(i).getAsJsonObject();
String name = entry.get("type").getAsString();
if(name.equals("directdamage")) {
ToxinDirectDamage e = new ToxinDirectDamage(
new DamageSource(entry.get("source").getAsString()),
entry.get("amount").getAsFloat(),
entry.get("delay").getAsInt(),
HazardClass.valueOf(entry.get("masktype").getAsString()),
entry.get("hazmat").getAsBoolean()
);
this.entries.add(e);
}
if(name.equals("effects")) {
ToxinEffects e = new ToxinEffects(
HazardClass.valueOf(entry.get("masktype").getAsString()),
entry.get("hazmat").getAsBoolean()
);
JsonArray effects = entry.get("effects").getAsJsonArray();
for(int j = 0; j < effects.size(); j++) {
JsonArray effect = effects.get(j).getAsJsonArray();
PotionEffect potion = new PotionEffect(effect.get(0).getAsInt(), effect.get(1).getAsInt(), effect.get(2).getAsInt(), effect.get(3).getAsBoolean());
e.effects.add(potion);
}
this.entries.add(e);
}
}
}
}

View File

@ -1,7 +1,10 @@
package com.hbm.inventory.fluid.trait;
import java.io.IOException;
import java.util.List;
import com.google.gson.JsonObject;
import com.google.gson.stream.JsonWriter;
import com.hbm.handler.radiation.ChunkRadiationManager;
import com.hbm.inventory.fluid.tank.FluidTank;
@ -12,6 +15,8 @@ public class FT_VentRadiation extends FluidTrait {
float radPerMB = 0;
public FT_VentRadiation() { }
public FT_VentRadiation(float rad) {
this.radPerMB = rad;
}
@ -29,4 +34,14 @@ public class FT_VentRadiation extends FluidTrait {
public void addInfo(List<String> info) {
info.add(EnumChatFormatting.YELLOW + "[Radioactive]");
}
@Override
public void serializeJSON(JsonWriter writer) throws IOException {
writer.name("radiation").value(radPerMB);
}
@Override
public void deserializeJSON(JsonObject obj) {
this.radPerMB = obj.get("radiation").getAsFloat();
}
}

View File

@ -1,12 +1,41 @@
package com.hbm.inventory.fluid.trait;
import java.io.IOException;
import java.util.List;
import com.google.common.collect.HashBiMap;
import com.google.gson.JsonObject;
import com.google.gson.stream.JsonWriter;
import com.hbm.inventory.fluid.tank.FluidTank;
import com.hbm.inventory.fluid.trait.FluidTraitSimple.*;
import net.minecraft.world.World;
public abstract class FluidTrait {
public static HashBiMap<String, Class<? extends FluidTrait>> traitNameMap = HashBiMap.create();
static {
traitNameMap.put("combustible", FT_Combustible.class); // x
traitNameMap.put("coolable", FT_Coolable.class); // x
traitNameMap.put("corrosive", FT_Corrosive.class); // x
traitNameMap.put("flammable", FT_Flammable.class); // x
traitNameMap.put("heatable", FT_Heatable.class); // x
traitNameMap.put("poison", FT_Poison.class); // x
traitNameMap.put("toxin", FT_Toxin.class); // x
traitNameMap.put("ventradiation", FT_VentRadiation.class); // x
traitNameMap.put("gaseous", FT_Gaseous.class);
traitNameMap.put("gaseous_art", FT_Gaseous_ART.class);
traitNameMap.put("liquid", FT_Liquid.class);
traitNameMap.put("viscous", FT_Viscous.class);
traitNameMap.put("plasma", FT_Plasma.class);
traitNameMap.put("amat", FT_Amat.class);
traitNameMap.put("leadcontainer", FT_LeadContainer.class);
traitNameMap.put("delicious", FT_Delicious.class);
traitNameMap.put("noid", FT_NoID.class);
traitNameMap.put("nocontainer", FT_NoContainer.class);
}
/** Important information that should always be displayed */
public void addInfo(List<String> info) { }
@ -14,4 +43,7 @@ public abstract class FluidTrait {
public void addInfoHidden(List<String> info) { }
public void onFluidRelease(World world, int x, int y, int z, FluidTank tank, int overflowAmount) { }
public void serializeJSON(JsonWriter writer) throws IOException { }
public void deserializeJSON(JsonObject obj) { }
}

View File

@ -47,10 +47,10 @@ public class HbmPotion extends Potion {
}
public static void init() {
taint = registerPotion(PotionConfig.taintID, true, 8388736, "potion.hbm_taint", 0, 0);
radiation = registerPotion(PotionConfig.radiationID, true, 8700200, "potion.hbm_radiation", 1, 0);
bang = registerPotion(PotionConfig.bangID, true, 1118481, "potion.hbm_bang", 3, 0);
mutation = registerPotion(PotionConfig.mutationID, false, 8388736, "potion.hbm_mutation", 2, 0);
taint = registerPotion(PotionConfig.taintID, true, 0x800080, "potion.hbm_taint", 0, 0);
radiation = registerPotion(PotionConfig.radiationID, true, 0x84C128, "potion.hbm_radiation", 1, 0);
bang = registerPotion(PotionConfig.bangID, true, 0x111111, "potion.hbm_bang", 3, 0);
mutation = registerPotion(PotionConfig.mutationID, false, 0x800080, "potion.hbm_mutation", 2, 0);
radx = registerPotion(PotionConfig.radxID, false, 0xBB4B00, "potion.hbm_radx", 5, 0);
lead = registerPotion(PotionConfig.leadID, true, 0x767682, "potion.hbm_lead", 6, 0);
radaway = registerPotion(PotionConfig.radawayID, false, 0xBB4B00, "potion.hbm_radaway", 7, 0);
@ -58,7 +58,7 @@ public class HbmPotion extends Potion {
phosphorus = registerPotion(PotionConfig.phosphorusID, true, 0xFFFF00, "potion.hbm_phosphorus", 1, 1);
stability = registerPotion(PotionConfig.stabilityID, false, 0xD0D0D0, "potion.hbm_stability", 2, 1);
potionsickness = registerPotion(PotionConfig.potionsicknessID, false, 0xff8080, "potion.hbm_potionsickness", 3, 1);
death = registerPotion(PotionConfig.deathID, false, 1118481, "potion.hbm_death", 4, 1);
death = registerPotion(PotionConfig.deathID, false, 0x111111, "potion.hbm_death", 4, 1);
}
public static HbmPotion registerPotion(int id, boolean isBad, int color, String name, int x, int y) {