-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed flywheel block entities still rendering after ship is deleted
- Loading branch information
1 parent
b3b3682
commit 9528e93
Showing
7 changed files
with
71 additions
and
28 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
common/src/main/java/org/valkyrienskies/mod/compat/FlywheelEvents.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package org.valkyrienskies.mod.compat; | ||
|
||
import com.jozufozu.flywheel.backend.instancing.InstanceWorld; | ||
import java.util.Collections; | ||
import java.util.Set; | ||
import java.util.WeakHashMap; | ||
import org.valkyrienskies.core.impl.hooks.VSEvents.ShipUnloadEventClient; | ||
import org.valkyrienskies.mod.mixinducks.MixinBlockEntityInstanceManagerDuck; | ||
|
||
public class FlywheelEvents { | ||
static { | ||
registerEvents(); | ||
} | ||
|
||
private static final Set<InstanceWorld> weakLoadedInstanceWorlds = | ||
Collections.newSetFromMap( | ||
new WeakHashMap<>() | ||
); | ||
|
||
private static synchronized void registerEvents() { | ||
ShipUnloadEventClient.Companion.on(event -> { | ||
for (final InstanceWorld instanceWorld : weakLoadedInstanceWorlds) { | ||
((MixinBlockEntityInstanceManagerDuck) instanceWorld.getBlockEntityInstanceManager()).vs$removeShipManager(event.getShip()); | ||
} | ||
}); | ||
} | ||
|
||
public static void onInstanceWorldLoad(final InstanceWorld instanceWorld) { | ||
weakLoadedInstanceWorlds.add(instanceWorld); | ||
} | ||
|
||
public static void onInstanceWorldUnload(final InstanceWorld instanceWorld) { | ||
weakLoadedInstanceWorlds.remove(instanceWorld); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters