andrew tolvern is dead

This commit is contained in:
Boblet 2025-03-31 16:22:16 +02:00
parent 26dcc1730d
commit 917ccb871c
2 changed files with 107 additions and 3 deletions

View File

@ -31,13 +31,11 @@ public class ParticleFoam extends EntityFX {
private static class TrailPoint {
double x, y, z;
float alpha;
public TrailPoint(double x, double y, double z, float alpha) {
this.x = x;
this.y = y;
this.z = z;
this.alpha = alpha;
}
}

View File

@ -1,11 +1,17 @@
package com.hbm.util;
import java.io.File;
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.stream.JsonWriter;
import com.hbm.items.ModItems;
import com.hbm.main.MainRegistry;
import com.hbm.util.Tuple.Quartet;
import api.hbm.entity.IResistanceProvider;
@ -39,6 +45,8 @@ public class DamageResistanceHandler {
public static final String CATEGORY_PROJECTILE = "PROJ";
public static final String CATEGORY_ENERGY = "EN";
public static final Gson gson = new Gson();
public static HashMap<Item, ResistanceStats> itemStats = new HashMap();
public static HashMap<Quartet<Item, Item, Item, Item>, ResistanceStats> setStats = new HashMap();
public static HashMap<Class<? extends Entity>, ResistanceStats> entityStats = new HashMap();
@ -46,13 +54,44 @@ public class DamageResistanceHandler {
public static HashMap<Item, List<Quartet<Item, Item, Item, Item>>> itemInfoSet = new HashMap();
public static void init() {
File folder = MainRegistry.configHbmDir;
File config = new File(folder.getAbsolutePath() + File.separatorChar + "hbmArmor.json");
File template = new File(folder.getAbsolutePath() + File.separatorChar + "_hbmArmor.json");
itemStats.clear();
setStats.clear();
entityStats.clear();
itemInfoSet.clear();
entityStats.put(EntityCreeper.class, new ResistanceStats().addCategory(CATEGORY_EXPLOSION, 2F, 0.5F));
if(!config.exists()) {
initDefaults();
writeDefault(template);
} else {
///
}
}
private static void writeDefault(File file) {
try {
JsonWriter writer = new JsonWriter(new FileWriter(file));
writer.setIndent(" ");
writer.beginObject();
writer.name("comment").value("Template file, remove the underscore ('_') from the name to enable the config.");
serialize(writer);
writer.endObject();
writer.close();
} catch(IOException e) {
e.printStackTrace();
}
}
public static void initDefaults() {
entityStats.put(EntityCreeper.class, new ResistanceStats().addCategory(CATEGORY_EXPLOSION, 2F, 0.25F));
itemStats.put(ModItems.jackt, new ResistanceStats()
.addCategory(CATEGORY_PROJECTILE, 5F, 0.5F));
@ -250,6 +289,47 @@ public class DamageResistanceHandler {
}
}
public static void serialize(JsonWriter writer) throws IOException {
/// ITEMS ///
writer.name("itemStats").beginArray();
for(Entry<Item, ResistanceStats> entry : itemStats.entrySet()) {
writer.beginArray().setIndent("");
writer.value(Item.itemRegistry.getNameForObject(entry.getKey())).setIndent(" ");
writer.beginObject();
entry.getValue().serialize(writer);
writer.setIndent("");
writer.endObject().endArray().setIndent(" ");
}
writer.endArray();
/// SETS ///
writer.name("setStats").beginArray();
for(Entry<Quartet<Item, Item, Item, Item>, ResistanceStats> entry : setStats.entrySet()) {
writer.beginArray().setIndent("");
writer.value(Item.itemRegistry.getNameForObject(entry.getKey().getW()))
.value(Item.itemRegistry.getNameForObject(entry.getKey().getX()))
.value(Item.itemRegistry.getNameForObject(entry.getKey().getY()))
.value(Item.itemRegistry.getNameForObject(entry.getKey().getZ())).setIndent(" ");
writer.beginObject();
entry.getValue().serialize(writer);
writer.setIndent("");
writer.endObject().endArray().setIndent(" ");
}
writer.endArray();
/// ENTITIES ///
writer.name("entityStats").beginArray();
for(Entry<Class<? extends Entity>, ResistanceStats> entry : entityStats.entrySet()) {
writer.beginArray().setIndent("");
writer.value(entry.getKey().getName()).setIndent(" ");
writer.beginObject();
entry.getValue().serialize(writer);
writer.setIndent("");
writer.endObject().endArray().setIndent(" ");
}
writer.endArray();
}
public static enum DamageClass {
PHYSICAL,
FIRE,
@ -393,6 +473,32 @@ public class DamageResistanceHandler {
public ResistanceStats addExact(String type, float threshold, float resistance) { exactResistances.put(type, new Resistance(threshold, resistance)); return this; }
public ResistanceStats addCategory(String type, float threshold, float resistance) { categoryResistances.put(type, new Resistance(threshold, resistance)); return this; }
public ResistanceStats setOther(float threshold, float resistance) { otherResistance = new Resistance(threshold, resistance); return this; }
public void serialize(JsonWriter writer) throws IOException {
if(!exactResistances.isEmpty()) {
writer.name("exact").beginArray();
for(Entry<String, Resistance> entry : exactResistances.entrySet()) {
writer.beginArray().setIndent("");
writer.value(entry.getKey()).value(entry.getValue().threshold).value(entry.getValue().resistance).endArray().setIndent(" ");
}
writer.endArray();
}
if(!categoryResistances.isEmpty()) {
writer.name("category").beginArray();
for(Entry<String, Resistance> entry : categoryResistances.entrySet()) {
writer.beginArray().setIndent("");
writer.value(entry.getKey()).value(entry.getValue().threshold).value(entry.getValue().resistance).endArray().setIndent(" ");
}
writer.endArray();
}
if(otherResistance != null) {
writer.name("other").beginArray().setIndent("");
writer.value(otherResistance.threshold).value(otherResistance.resistance).endArray().setIndent(" ");
}
}
}
public static class Resistance {