Skip to content

Commit

Permalink
Fix potentially wonky check for lava transformation recipes
Browse files Browse the repository at this point in the history
  • Loading branch information
62832 committed Nov 4, 2024
1 parent d8ba8fe commit b799907
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 6 additions & 4 deletions src/main/java/gripe/_90/megacells/misc/LavaTransformLogic.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,17 @@
import net.neoforged.neoforge.event.OnDatapackSyncEvent;
import net.neoforged.neoforge.event.server.ServerStartedEvent;

import appeng.recipes.transform.TransformRecipe;
import appeng.recipes.AERecipeTypes;

public final class LavaTransformLogic {
private static final Set<Item> lavaCache = new HashSet<>();

static {
NeoForge.EVENT_BUS.addListener((ServerStartedEvent event) -> lavaCache.clear());
NeoForge.EVENT_BUS.addListener((OnDatapackSyncEvent event) -> {
if (event.getPlayer() == null) lavaCache.clear();
if (event.getPlayer() == null) {
lavaCache.clear();
}
});
}

Expand All @@ -41,7 +43,7 @@ public static boolean allIngredientsPresent(ItemEntity entity) {
.map(e -> ((ItemEntity) e).getItem().getItem())
.toList();

for (var recipe : level.getRecipeManager().getAllRecipesFor(TransformRecipe.TYPE)) {
for (var recipe : level.getRecipeManager().getAllRecipesFor(AERecipeTypes.TRANSFORM)) {
if (recipe.value().circumstance.isFluidTag(FluidTags.LAVA)) {
return recipe.value().getIngredients().stream().noneMatch(ingredient -> {
for (var stack : ingredient.getItems()) {
Expand All @@ -61,7 +63,7 @@ public static boolean allIngredientsPresent(ItemEntity entity) {
@SuppressWarnings("SameReturnValue")
private static Set<Item> getLavaTransformableItems(Level level) {
if (lavaCache.isEmpty()) {
for (var recipe : level.getRecipeManager().getAllRecipesFor(TransformRecipe.TYPE)) {
for (var recipe : level.getRecipeManager().getAllRecipesFor(AERecipeTypes.TRANSFORM)) {
if (!recipe.value().circumstance.isFluidTag(FluidTags.LAVA)) {
continue;
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/gripe/_90/megacells/mixin/ItemEntityMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ private void lavaTimeout(CallbackInfo ci) {
var state = level().getFluidState(new BlockPos(x, y, z));

if (state.is(FluidTags.LAVA)) {
mega$lavaImmune = mega$lavaTicks++ <= 200 || LavaTransformLogic.allIngredientsPresent(self);
mega$lavaImmune = mega$lavaTicks <= 200;

if (mega$lavaTicks > 200 && LavaTransformLogic.allIngredientsPresent(self)) {
if (mega$lavaTicks++ > 200 && LavaTransformLogic.allIngredientsPresent(self)) {
mega$lavaTicks = 0;
}
}
Expand Down

0 comments on commit b799907

Please sign in to comment.