This commit is contained in:
Boblet 2025-07-03 15:01:24 +02:00
parent 3da96091da
commit 6282bd028d
5 changed files with 53 additions and 48 deletions

View File

@ -1,7 +1,10 @@
## Changed
* The chemistry achievement now requires the new chemical plant
* The new chemical plant can now be used to upgrade the meteorite sword
* Fluid containers are now re-registered when using `/ntmreload` which should correctly generate fluid container items for freshly added custom fluids
* Recipe configs will no longer try to parse null value recipes, meaing that trailing commas in a recipe config will no longer create an error
## Fixed
* Fixed crash caused by breaking a tool while the fortune or silk touch ability is enabled
* Fixed NTM adding mob spawns to the mushroom island
* Fixed NTM adding mob spawns to the mushroom island
# Fixed line break not working on the tip of the day

View File

@ -1,6 +1,7 @@
package com.hbm.commands;
import com.hbm.config.ItemPoolConfigJSON;
import com.hbm.inventory.FluidContainerRegistry;
import com.hbm.inventory.fluid.Fluids;
import com.hbm.inventory.recipes.loader.SerializableRecipe;
import com.hbm.particle.helper.SkeletonCreator;
@ -27,7 +28,9 @@ public class CommandReloadRecipes extends CommandBase {
@Override
public void processCommand(ICommandSender sender, String[] args) {
try {
FluidContainerRegistry.clearRegistry(); // we do this first so IFluidRegisterListener can go wild with the registry
Fluids.reloadFluids();
FluidContainerRegistry.register();
SerializableRecipe.initialize();
ItemPoolConfigJSON.initialize();
DamageResistanceHandler.init();

View File

@ -18,12 +18,18 @@ import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
public class FluidContainerRegistry {
//TODO: continue incorporating hashmaps into this
// TODO: continue incorporating hashmaps into this
public static List<FluidContainer> allContainers = new ArrayList<FluidContainer>();
private static HashMap<FluidType, List<FluidContainer>> containerMap = new HashMap<FluidType, List<FluidContainer>>();
public static void clearRegistry() {
allContainers.clear();
containerMap.clear();
}
public static void register() {
FluidContainerRegistry.registerContainer(new FluidContainer(new ItemStack(Items.water_bucket), new ItemStack(Items.bucket), Fluids.WATER, 1000));
FluidContainerRegistry.registerContainer(new FluidContainer(new ItemStack(Items.potionitem), new ItemStack(Items.glass_bottle), Fluids.WATER, 250));
FluidContainerRegistry.registerContainer(new FluidContainer(new ItemStack(Items.lava_bucket), new ItemStack(Items.bucket), Fluids.LAVA, 1000));
@ -59,34 +65,34 @@ public class FluidContainerRegistry {
FluidContainerRegistry.registerContainer(new FluidContainer(new ItemStack(Items.experience_bottle), new ItemStack(Items.glass_bottle), Fluids.XPJUICE, 100));
FluidContainerRegistry.registerContainer(new FluidContainer(new ItemStack(ModItems.can_mug), new ItemStack(ModItems.can_empty), Fluids.MUG, 100));
FluidType[] fluids = Fluids.getAll();
for(int i = 1; i < fluids.length; i++) {
FluidType type = fluids[i];
int id = type.getID();
if(type.getContainer(CD_Canister.class) != null) FluidContainerRegistry.registerContainer(new FluidContainer(new ItemStack(ModItems.canister_full, 1, id), new ItemStack(ModItems.canister_empty), type, 1000));
if(type.getContainer(CD_Gastank.class) != null) FluidContainerRegistry.registerContainer(new FluidContainer(new ItemStack(ModItems.gas_full, 1, id), new ItemStack(ModItems.gas_empty), type, 1000));
if(type.hasNoContainer()) continue;
if(type.isDispersable()){
FluidContainerRegistry.registerContainer(new FluidContainer(new ItemStack(ModItems.disperser_canister, 1 , i), new ItemStack(ModItems.disperser_canister_empty), Fluids.fromID(i), 2000));
FluidContainerRegistry.registerContainer(new FluidContainer(new ItemStack(ModItems.glyphid_gland, 1 , i), new ItemStack(ModItems.glyphid_gland_empty), Fluids.fromID(i), 4000));
if(type.isDispersable()) {
FluidContainerRegistry.registerContainer(new FluidContainer(new ItemStack(ModItems.disperser_canister, 1, i), new ItemStack(ModItems.disperser_canister_empty), Fluids.fromID(i), 2000));
FluidContainerRegistry.registerContainer(new FluidContainer(new ItemStack(ModItems.glyphid_gland, 1, i), new ItemStack(ModItems.glyphid_gland_empty), Fluids.fromID(i), 4000));
}
FluidContainerRegistry.registerContainer(new FluidContainer(new ItemStack(ModItems.fluid_tank_lead_full, 1, id), new ItemStack(ModItems.fluid_tank_lead_empty), type, 1000));
if(type.needsLeadContainer()) continue;
FluidContainerRegistry.registerContainer(new FluidContainer(new ItemStack(ModItems.fluid_tank_full, 1, id), new ItemStack(ModItems.fluid_tank_empty), type, 1000));
FluidContainerRegistry.registerContainer(new FluidContainer(new ItemStack(ModItems.fluid_barrel_full, 1, id), new ItemStack(ModItems.fluid_barrel_empty), type, 16000));
}
Compat.registerCompatFluidContainers();
}
public static void registerContainer(FluidContainer con) {
allContainers.add(con);
OreDictionary.registerOre(con.type.getDict(con.content), con.fullContainer);
@ -103,51 +109,48 @@ public class FluidContainerRegistry {
}
public static FluidContainer getContainer(FluidType type, ItemStack stack) {
if(stack == null)
return null;
if(stack == null) return null;
ItemStack sta = stack.copy();
sta.stackSize = 1;
if (!containerMap.containsKey(type))
if(!containerMap.containsKey(type))
return null;
for (FluidContainer container : getContainers(type)) {
if (ItemStack.areItemStacksEqual(container.emptyContainer, sta) && ItemStack.areItemStackTagsEqual(container.emptyContainer, sta)) {
for(FluidContainer container : getContainers(type)) {
if(ItemStack.areItemStacksEqual(container.emptyContainer, sta) && ItemStack.areItemStackTagsEqual(container.emptyContainer, sta)) {
return container;
}
}
return null;
}
public static int getFluidContent(ItemStack stack, FluidType type) {
if(stack == null)
return 0;
ItemStack sta = stack.copy();
sta.stackSize = 1;
if (!containerMap.containsKey(type))
if(!containerMap.containsKey(type))
return 0;
for(FluidContainer container : containerMap.get(type)) {
if(ItemStack.areItemStacksEqual(container.fullContainer, sta) && ItemStack.areItemStackTagsEqual(container.fullContainer, sta))
return container.content;
}
return 0;
}
public static FluidType getFluidType(ItemStack stack) {
if(stack == null)
return Fluids.NONE;
if(stack == null) return Fluids.NONE;
ItemStack sta = stack.copy();
sta.stackSize = 1;
for(FluidContainer container : allContainers) {
if(ItemStack.areItemStacksEqual(container.fullContainer, sta) && ItemStack.areItemStackTagsEqual(container.fullContainer, sta))
return container.type;
@ -155,29 +158,26 @@ public class FluidContainerRegistry {
return Fluids.NONE;
}
public static ItemStack getFullContainer(ItemStack stack, FluidType type) {
if(stack == null)
return null;
if(stack == null) return null;
ItemStack sta = stack.copy();
sta.stackSize = 1;
if (!containerMap.containsKey(type))
return null;
if(!containerMap.containsKey(type)) return null;
for(FluidContainer container : containerMap.get(type)) {
if(ItemStack.areItemStacksEqual(container.emptyContainer, sta) && ItemStack.areItemStackTagsEqual(container.emptyContainer, sta))
if(ItemStack.areItemStacksEqual(container.emptyContainer, sta) && ItemStack.areItemStackTagsEqual(container.emptyContainer, sta))
return container.fullContainer.copy();
}
return null;
}
public static ItemStack getEmptyContainer(ItemStack stack) {
if(stack == null)
return null;
if(stack == null) return null;
ItemStack sta = stack.copy();
sta.stackSize = 1;
@ -185,8 +185,7 @@ public class FluidContainerRegistry {
if(ItemStack.areItemStacksEqual(container.fullContainer, sta) && ItemStack.areItemStackTagsEqual(container.fullContainer, sta))
return container.emptyContainer == null ? null : container.emptyContainer.copy();
}
return null;
}
}

View File

@ -166,7 +166,7 @@ public class LoadingScreenRendererNT extends LoadingScreenRenderer {
this.mc.fontRenderer.drawStringWithShadow(this.currentlyDisplayedText, (width - this.mc.fontRenderer.getStringWidth(this.currentlyDisplayedText)) / 2, height / 2 - 4 - 16, 16777215);
this.mc.fontRenderer.drawStringWithShadow(this.message, (width - this.mc.fontRenderer.getStringWidth(this.message)) / 2, height / 2 - 4 + 8, 16777215);
String[] frags = this.tipOfTheDay.split("$");
String[] frags = this.tipOfTheDay.split("\\$");
for(int i = 0; i < frags.length; i++) {
String frag = frags[i];
this.mc.fontRenderer.drawStringWithShadow(EnumChatFormatting.YELLOW + frag, (width - this.mc.fontRenderer.getStringWidth(frag)) / 2, height / 2 - 4 - 60 + i * 10, 16777215);

View File

@ -237,7 +237,7 @@ public abstract class SerializableRecipe {
JsonObject json = gson.fromJson(reader, JsonObject.class);
JsonArray recipes = json.get("recipes").getAsJsonArray();
for(JsonElement recipe : recipes) {
this.readRecipe(recipe);
if(recipe != null) this.readRecipe(recipe);
}
}