Skip to content

Commit

Permalink
Change experiments description, fix possible CMEs with furnace burn t…
Browse files Browse the repository at this point in the history
…ime handler
  • Loading branch information
Roadhog360 committed Oct 5, 2024
1 parent 3c6fd4c commit d51b9eb
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -1950,70 +1951,77 @@ public void onPostWorldTick(TickEvent.WorldTickEvent e) {
}
}

private final ItemStackSet NO_BURN_ITEMS = new ItemStackSet();
private final ItemStackMap<Integer> BURN_TIME_REMAPPING = new ItemStackMap<>();
private final ItemStackSet noBurnItems = new ItemStackSet();
private final ItemStackMap<Integer> 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)
Expand Down

0 comments on commit d51b9eb

Please sign in to comment.