From d51b9ebfa190255b0841e907aeb8b73eec7dcabb Mon Sep 17 00:00:00 2001 From: roadhog360 Date: Sat, 5 Oct 2024 13:11:26 -0500 Subject: [PATCH] Change experiments description, fix possible CMEs with furnace burn time handler --- .../configs/ConfigExperiments.java | 13 ++- .../core/handlers/ServerEventHandler.java | 100 ++++++++++-------- 2 files changed, 63 insertions(+), 50 deletions(-) diff --git a/src/main/java/ganymedes01/etfuturum/configuration/configs/ConfigExperiments.java b/src/main/java/ganymedes01/etfuturum/configuration/configs/ConfigExperiments.java index 49739214..692c36c0 100644 --- a/src/main/java/ganymedes01/etfuturum/configuration/configs/ConfigExperiments.java +++ b/src/main/java/ganymedes01/etfuturum/configuration/configs/ConfigExperiments.java @@ -26,10 +26,15 @@ public class ConfigExperiments extends ConfigBase { public ConfigExperiments(File file) { super(file); setCategoryComment(catExperiments, - "Unfinished features. Handle with care! To automatically enable all of these at once, use \"-Detfuturum.testing=true\" in your program arguments." + - "\nFor the safety of people playing any packs that include these features, a chat message will be issued when any of them are enabled." + - "\nNote that when a config option has no comment at all, not even saying what the default value is, that means the option was removed." + - "\nIn that case check the regular configs as it was likely moved there."); + """ + Unfinished features. Handle with care! To automatically enable all of these at once, use "-Detfuturum.testing=true" in your program arguments. + For the safety of people playing any packs that include these features, a chat message will be issued when any of them are enabled. + These features are not finished, may cause breakages and are subject to receive major changes at any time. + This can also include breaking changes, and even changed IDs. + + Note that when a config option has no comment at all, not even saying what the default value is, that means the option was removed. + In that case check the regular configs as it was likely moved there. + """); configCats.add(getCategory(catExperiments)); } diff --git a/src/main/java/ganymedes01/etfuturum/core/handlers/ServerEventHandler.java b/src/main/java/ganymedes01/etfuturum/core/handlers/ServerEventHandler.java index 7865caf5..713fbe27 100644 --- a/src/main/java/ganymedes01/etfuturum/core/handlers/ServerEventHandler.java +++ b/src/main/java/ganymedes01/etfuturum/core/handlers/ServerEventHandler.java @@ -105,6 +105,7 @@ import java.lang.reflect.Field; import java.lang.reflect.Method; import java.util.*; +import java.util.concurrent.atomic.AtomicBoolean; @SuppressWarnings("deprecation") public class ServerEventHandler { @@ -1950,70 +1951,77 @@ public void onPostWorldTick(TickEvent.WorldTickEvent e) { } } - private final ItemStackSet NO_BURN_ITEMS = new ItemStackSet(); - private final ItemStackMap BURN_TIME_REMAPPING = new ItemStackMap<>(); + private final ItemStackSet noBurnItems = new ItemStackSet(); + private final ItemStackMap burnTimeRemappings = new ItemStackMap<>(); @SubscribeEvent public void fuelBurnTime(FuelBurnTimeEvent e) { if (e.fuel == null || e.fuel.getItem() == null || Item.itemRegistry.getNameForObject(e.fuel.getItem()) == null) return; - if (NO_BURN_ITEMS.isEmpty()) { - NO_BURN_ITEMS.add(ModBlocks.WOOD_PLANKS.newItemStack(1, 0)); - NO_BURN_ITEMS.add(ModBlocks.WOOD_PLANKS.newItemStack(1, 1)); - NO_BURN_ITEMS.add(ModBlocks.WOOD_FENCE.newItemStack(1, 0)); - NO_BURN_ITEMS.add(ModBlocks.WOOD_FENCE.newItemStack(1, 1)); - - NO_BURN_ITEMS.add(ModBlocks.WOOD_SLAB.newItemStack(1, 0)); - NO_BURN_ITEMS.add(ModBlocks.WOOD_SLAB.newItemStack(1, 1)); - NO_BURN_ITEMS.add(ModBlocks.WOOD_SLAB.newItemStack(1, 8)); - NO_BURN_ITEMS.add(ModBlocks.WOOD_SLAB.newItemStack(1, 9)); - - NO_BURN_ITEMS.add(ModBlocks.DOUBLE_WOOD_SLAB.newItemStack(1, 0)); - NO_BURN_ITEMS.add(ModBlocks.DOUBLE_WOOD_SLAB.newItemStack(1, 1)); - NO_BURN_ITEMS.add(ModBlocks.DOUBLE_WOOD_SLAB.newItemStack(1, 8)); - NO_BURN_ITEMS.add(ModBlocks.DOUBLE_WOOD_SLAB.newItemStack(1, 9)); - - NO_BURN_ITEMS.add(ModBlocks.CRIMSON_STEM.newItemStack(1, OreDictionary.WILDCARD_VALUE)); - NO_BURN_ITEMS.add(ModBlocks.WARPED_STEM.newItemStack(1, OreDictionary.WILDCARD_VALUE)); - NO_BURN_ITEMS.add(ModBlocks.CRIMSON_STAIRS.newItemStack(1, OreDictionary.WILDCARD_VALUE)); - NO_BURN_ITEMS.add(ModBlocks.WARPED_STAIRS.newItemStack(1, OreDictionary.WILDCARD_VALUE)); - NO_BURN_ITEMS.add(ModBlocks.CRIMSON_FENCE_GATE.newItemStack(1, OreDictionary.WILDCARD_VALUE)); - NO_BURN_ITEMS.add(ModBlocks.WARPED_FENCE_GATE.newItemStack(1, OreDictionary.WILDCARD_VALUE)); - NO_BURN_ITEMS.add(ModBlocks.CRIMSON_BUTTON.newItemStack(1, OreDictionary.WILDCARD_VALUE)); - NO_BURN_ITEMS.add(ModBlocks.WARPED_BUTTON.newItemStack(1, OreDictionary.WILDCARD_VALUE)); - NO_BURN_ITEMS.add(ModBlocks.CRIMSON_PRESSURE_PLATE.newItemStack(1, OreDictionary.WILDCARD_VALUE)); - NO_BURN_ITEMS.add(ModBlocks.WARPED_PRESSURE_PLATE.newItemStack(1, OreDictionary.WILDCARD_VALUE)); - NO_BURN_ITEMS.add(ModBlocks.CRIMSON_DOOR.newItemStack(1, OreDictionary.WILDCARD_VALUE)); - NO_BURN_ITEMS.add(ModBlocks.WARPED_DOOR.newItemStack(1, OreDictionary.WILDCARD_VALUE)); - NO_BURN_ITEMS.add(ModBlocks.CRIMSON_TRAPDOOR.newItemStack(1, OreDictionary.WILDCARD_VALUE)); - NO_BURN_ITEMS.add(ModBlocks.WARPED_TRAPDOOR.newItemStack(1, OreDictionary.WILDCARD_VALUE)); - NO_BURN_ITEMS.add(ModBlocks.CRIMSON_SIGN.newItemStack(1, OreDictionary.WILDCARD_VALUE)); - NO_BURN_ITEMS.add(ModBlocks.WARPED_SIGN.newItemStack(1, OreDictionary.WILDCARD_VALUE)); + initFurnaceModifiers(); - for (ModBlocks bed : ModBlocks.BEDS) { - if (bed.isEnabled()) { - NO_BURN_ITEMS.add(bed.newItemStack()); - } - } - } - if (NO_BURN_ITEMS.contains(e.fuel)) { + if (noBurnItems.contains(e.fuel)) { e.burnTime = 0; e.setResult(Result.DENY); return; } - if (BURN_TIME_REMAPPING.isEmpty()) { - BURN_TIME_REMAPPING.put(ModItems.BAMBOO.newItemStack(1, OreDictionary.WILDCARD_VALUE), 50); - } - - Integer time = BURN_TIME_REMAPPING.get(e.fuel); + Integer time = burnTimeRemappings.get(e.fuel); if (time != null) { e.burnTime = time; e.setResult(Result.ALLOW); } } + private final AtomicBoolean initNoBurnItems = new AtomicBoolean(false); + private final AtomicBoolean initBurnTimeRemappings = new AtomicBoolean(false); + private void initFurnaceModifiers() { + if (!initNoBurnItems.getAndSet(true)) { + noBurnItems.add(ModBlocks.WOOD_PLANKS.newItemStack(1, 0)); + noBurnItems.add(ModBlocks.WOOD_PLANKS.newItemStack(1, 1)); + noBurnItems.add(ModBlocks.WOOD_FENCE.newItemStack(1, 0)); + noBurnItems.add(ModBlocks.WOOD_FENCE.newItemStack(1, 1)); + + noBurnItems.add(ModBlocks.WOOD_SLAB.newItemStack(1, 0)); + noBurnItems.add(ModBlocks.WOOD_SLAB.newItemStack(1, 1)); + noBurnItems.add(ModBlocks.WOOD_SLAB.newItemStack(1, 8)); + noBurnItems.add(ModBlocks.WOOD_SLAB.newItemStack(1, 9)); + + noBurnItems.add(ModBlocks.DOUBLE_WOOD_SLAB.newItemStack(1, 0)); + noBurnItems.add(ModBlocks.DOUBLE_WOOD_SLAB.newItemStack(1, 1)); + noBurnItems.add(ModBlocks.DOUBLE_WOOD_SLAB.newItemStack(1, 8)); + noBurnItems.add(ModBlocks.DOUBLE_WOOD_SLAB.newItemStack(1, 9)); + + noBurnItems.add(ModBlocks.CRIMSON_STEM.newItemStack(1, OreDictionary.WILDCARD_VALUE)); + noBurnItems.add(ModBlocks.WARPED_STEM.newItemStack(1, OreDictionary.WILDCARD_VALUE)); + noBurnItems.add(ModBlocks.CRIMSON_STAIRS.newItemStack(1, OreDictionary.WILDCARD_VALUE)); + noBurnItems.add(ModBlocks.WARPED_STAIRS.newItemStack(1, OreDictionary.WILDCARD_VALUE)); + noBurnItems.add(ModBlocks.CRIMSON_FENCE_GATE.newItemStack(1, OreDictionary.WILDCARD_VALUE)); + noBurnItems.add(ModBlocks.WARPED_FENCE_GATE.newItemStack(1, OreDictionary.WILDCARD_VALUE)); + noBurnItems.add(ModBlocks.CRIMSON_BUTTON.newItemStack(1, OreDictionary.WILDCARD_VALUE)); + noBurnItems.add(ModBlocks.WARPED_BUTTON.newItemStack(1, OreDictionary.WILDCARD_VALUE)); + noBurnItems.add(ModBlocks.CRIMSON_PRESSURE_PLATE.newItemStack(1, OreDictionary.WILDCARD_VALUE)); + noBurnItems.add(ModBlocks.WARPED_PRESSURE_PLATE.newItemStack(1, OreDictionary.WILDCARD_VALUE)); + noBurnItems.add(ModBlocks.CRIMSON_DOOR.newItemStack(1, OreDictionary.WILDCARD_VALUE)); + noBurnItems.add(ModBlocks.WARPED_DOOR.newItemStack(1, OreDictionary.WILDCARD_VALUE)); + noBurnItems.add(ModBlocks.CRIMSON_TRAPDOOR.newItemStack(1, OreDictionary.WILDCARD_VALUE)); + noBurnItems.add(ModBlocks.WARPED_TRAPDOOR.newItemStack(1, OreDictionary.WILDCARD_VALUE)); + noBurnItems.add(ModBlocks.CRIMSON_SIGN.newItemStack(1, OreDictionary.WILDCARD_VALUE)); + noBurnItems.add(ModBlocks.WARPED_SIGN.newItemStack(1, OreDictionary.WILDCARD_VALUE)); + + for (ModBlocks bed : ModBlocks.BEDS) { + if (bed.isEnabled()) { + noBurnItems.add(bed.newItemStack()); + } + } + } + + if (!initBurnTimeRemappings.getAndSet(true)) { + burnTimeRemappings.put(ModItems.BAMBOO.newItemStack(1, OreDictionary.WILDCARD_VALUE), 50); + } + } + @SubscribeEvent public void onWorldLoad(WorldEvent.Load e) { if (ConfigMixins.enableElytra)