-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split some mixins to their platforms
- Loading branch information
Showing
11 changed files
with
143 additions
and
71 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
...in/java/ca/spottedleaf/moonrise/fabric/mixin/chunk_system/FabricDistanceManagerMixin.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,33 @@ | ||
package ca.spottedleaf.moonrise.fabric.mixin.chunk_system; | ||
|
||
import ca.spottedleaf.moonrise.patches.chunk_system.level.chunk.ChunkSystemDistanceManager; | ||
import net.minecraft.server.level.ChunkLevel; | ||
import net.minecraft.server.level.DistanceManager; | ||
import net.minecraft.server.level.FullChunkStatus; | ||
import net.minecraft.server.level.TicketType; | ||
import net.minecraft.world.level.ChunkPos; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Overwrite; | ||
|
||
@Mixin(DistanceManager.class) | ||
abstract class FabricDistanceManagerMixin implements ChunkSystemDistanceManager { | ||
|
||
/** | ||
* @reason Route to new chunk system | ||
* @author Spottedleaf | ||
*/ | ||
@Overwrite | ||
public <T> void addRegionTicket(final TicketType<T> type, final ChunkPos pos, final int radius, final T identifier) { | ||
this.moonrise$getChunkHolderManager().addTicketAtLevel(type, pos, ChunkLevel.byStatus(FullChunkStatus.FULL) - radius, identifier); | ||
} | ||
|
||
/** | ||
* @reason Route to new chunk system | ||
* @author Spottedleaf | ||
*/ | ||
@Overwrite | ||
public <T> void removeRegionTicket(final TicketType<T> type, final ChunkPos pos, final int radius, final T identifier) { | ||
this.moonrise$getChunkHolderManager().removeTicketAtLevel(type, pos, ChunkLevel.byStatus(FullChunkStatus.FULL) - radius, identifier); | ||
} | ||
|
||
} |
27 changes: 27 additions & 0 deletions
27
...in/java/ca/spottedleaf/moonrise/fabric/mixin/chunk_system/FabricMinecraftServerMixin.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,27 @@ | ||
package ca.spottedleaf.moonrise.fabric.mixin.chunk_system; | ||
|
||
import ca.spottedleaf.moonrise.common.util.TickThread; | ||
import net.minecraft.server.MinecraftServer; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
|
||
@Mixin(MinecraftServer.class) | ||
abstract class FabricMinecraftServerMixin { | ||
|
||
/** | ||
* @reason Make server thread an instance of TickThread for thread checks | ||
* @author Spottedleaf | ||
*/ | ||
@Redirect( | ||
method = "spin", | ||
at = @At( | ||
value = "NEW", | ||
target = "(Ljava/lang/Runnable;Ljava/lang/String;)Ljava/lang/Thread;" | ||
) | ||
) | ||
private static Thread createTickThread(final Runnable target, final String name) { | ||
return new TickThread(target, name); | ||
} | ||
|
||
} |
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
33 changes: 33 additions & 0 deletions
33
...ava/ca/spottedleaf/moonrise/neoforge/mixin/chunk_system/NeoForgeDistanceManagerMixin.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,33 @@ | ||
package ca.spottedleaf.moonrise.neoforge.mixin.chunk_system; | ||
|
||
import ca.spottedleaf.moonrise.patches.chunk_system.level.chunk.ChunkSystemDistanceManager; | ||
import net.minecraft.server.level.ChunkLevel; | ||
import net.minecraft.server.level.DistanceManager; | ||
import net.minecraft.server.level.FullChunkStatus; | ||
import net.minecraft.server.level.TicketType; | ||
import net.minecraft.world.level.ChunkPos; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Overwrite; | ||
|
||
@Mixin(DistanceManager.class) | ||
abstract class NeoForgeDistanceManagerMixin implements ChunkSystemDistanceManager { | ||
|
||
/** | ||
* @reason Route to new chunk system | ||
* @author Spottedleaf | ||
*/ | ||
@Overwrite | ||
public <T> void addRegionTicket(final TicketType<T> type, final ChunkPos pos, final int radius, final T identifier, final boolean forceTicks) { | ||
this.moonrise$getChunkHolderManager().addTicketAtLevel(type, pos, ChunkLevel.byStatus(FullChunkStatus.FULL) - radius, identifier); | ||
} | ||
|
||
/** | ||
* @reason Route to new chunk system | ||
* @author Spottedleaf | ||
*/ | ||
@Overwrite | ||
public <T> void removeRegionTicket(final TicketType<T> type, final ChunkPos pos, final int radius, final T identifier, final boolean forceTicks) { | ||
this.moonrise$getChunkHolderManager().removeTicketAtLevel(type, pos, ChunkLevel.byStatus(FullChunkStatus.FULL) - radius, identifier); | ||
} | ||
|
||
} |
27 changes: 27 additions & 0 deletions
27
...ava/ca/spottedleaf/moonrise/neoforge/mixin/chunk_system/NeoForgeMinecraftServerMixin.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,27 @@ | ||
package ca.spottedleaf.moonrise.neoforge.mixin.chunk_system; | ||
|
||
import ca.spottedleaf.moonrise.common.util.TickThread; | ||
import net.minecraft.server.MinecraftServer; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
|
||
@Mixin(MinecraftServer.class) | ||
abstract class NeoForgeMinecraftServerMixin { | ||
|
||
/** | ||
* @reason Make server thread an instance of TickThread for thread checks | ||
* @author Spottedleaf | ||
*/ | ||
@Redirect( | ||
method = "spin", | ||
at = @At( | ||
value = "NEW", | ||
target = "(Ljava/lang/ThreadGroup;Ljava/lang/Runnable;Ljava/lang/String;)Ljava/lang/Thread;" | ||
) | ||
) | ||
private static Thread createTickThread(final ThreadGroup group, final Runnable task, final String name) { | ||
return new TickThread(group, task, name); | ||
} | ||
|
||
} |
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
3 changes: 3 additions & 0 deletions
3
.../ca/spottedleaf/moonrise/patches/chunk_system/level/chunk/ChunkSystemDistanceManager.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 |
---|---|---|
@@ -1,9 +1,12 @@ | ||
package ca.spottedleaf.moonrise.patches.chunk_system.level.chunk; | ||
|
||
import ca.spottedleaf.moonrise.patches.chunk_system.scheduling.ChunkHolderManager; | ||
import net.minecraft.server.level.ChunkMap; | ||
|
||
public interface ChunkSystemDistanceManager { | ||
|
||
public ChunkMap moonrise$getChunkMap(); | ||
|
||
public ChunkHolderManager moonrise$getChunkHolderManager(); | ||
|
||
} |