Skip to content

Commit

Permalink
Attempt to fix level emitter crafting
Browse files Browse the repository at this point in the history
  • Loading branch information
iczero committed Jan 4, 2025
1 parent b5432ad commit 5e71ecd
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 18 deletions.
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false
org.gradle.parallel=true
parchment_minecraft_version=1.21
parchment_mappings_version=2024.07.28
parchment_minecraft_version=1.21.1
parchment_mappings_version=2024.11.17
## Environment Properties
minecraft_release=1.21.1
minecraft_version=1.21.1
minecraft_version_range=1.21.1
neoforge_version=21.1.62
neoforge_version=21.1.92
neoforge_version_range=[21.1.1,)
loader_version_range=[4,)
## Mod Properties
Expand Down
Empty file modified gradlew
100644 → 100755
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
import java.util.Set;

import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;
import com.llamalad7.mixinextras.sugar.Local;

import org.apache.commons.lang3.mutable.MutableObject;
import org.objectweb.asm.Opcodes;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
Expand Down Expand Up @@ -71,28 +71,49 @@ public class MixinCraftingService {
@Shadow
public void addLink(CraftingLink link) {}

@Inject(method = "onServerEndTick", at = @At("TAIL"))
private void tickAdvClusters(CallbackInfo ci) {
var previouslyCrafting = this.currentlyCrafting;
@Shadow
private long lastProcessedCraftingLogicChangeTick;

@Inject(
method = "onServerEndTick",
at =
@At(
value = "FIELD",
target = "Lappeng/me/service/CraftingService;lastProcessedCraftingLogicChangeTick:J",
opcode = Opcodes.GETFIELD,
ordinal = 0))
private void tickAdvClusters1(CallbackInfo ci, @Local long latestChange) {
long latestChangeLocal = 0;
for (var cluster : this.advancedAE$advCraftingCPUClusters) {
if (cluster != null) {
for (var cpu : cluster.getActiveCPUs()) {
cpu.craftingLogic.tickCraftingLogic(energyGrid, (CraftingService) (Object) this);
cpu.craftingLogic.getAllWaitingFor(this.currentlyCrafting);
latestChangeLocal = Math.max(latestChangeLocal, cpu.craftingLogic.getLastModifiedOnTick());
}
}
}

// Notify watchers about items no longer being crafted
var changed = new HashSet<AEKey>();
changed.addAll(Sets.difference(previouslyCrafting, currentlyCrafting));
changed.addAll(Sets.difference(currentlyCrafting, previouslyCrafting));
for (var what : changed) {
for (var watcher : interestManager.get(what)) {
watcher.getHost().onRequestChange(what);
}
for (var watcher : interestManager.getAllStacksWatchers()) {
watcher.getHost().onRequestChange(what);
if (latestChangeLocal > latestChange) {
// our crafting CPUs did something, fire notifications
this.lastProcessedCraftingLogicChangeTick = -1;
}
}

@Inject(
method = "onServerEndTick",
at =
@At(
value = "FIELD",
target =
"Lappeng/me/service/CraftingService;interests:Lcom/google/common/collect/Multimap;",
opcode = Opcodes.GETFIELD,
ordinal = 0))
private void tickAdvClusters2(CallbackInfo ci) {
for (var cluster : this.advancedAE$advCraftingCPUClusters) {
if (cluster != null) {
for (var cpu : cluster.getActiveCPUs()) {
cpu.craftingLogic.getAllWaitingFor(this.currentlyCrafting);
}
}
}
}
Expand Down

0 comments on commit 5e71ecd

Please sign in to comment.