-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
78 additions
and
80 deletions.
There are no files selected for viewing
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
73 changes: 0 additions & 73 deletions
73
src/client/java/dev/enjarai/trickster/mixin/client/SodiumLevelSliceMixin.java
This file was deleted.
Oops, something went wrong.
58 changes: 58 additions & 0 deletions
58
src/client/java/dev/enjarai/trickster/mixin/client/sodium/WorldSliceMixin.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,58 @@ | ||
package dev.enjarai.trickster.mixin.client.sodium; | ||
|
||
import dev.enjarai.trickster.cca.ModChunkCumponents; | ||
import dev.enjarai.trickster.cca.ShadowDisguiseMapComponent; | ||
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; | ||
import me.jellysquid.mods.sodium.client.world.WorldSlice; | ||
import net.minecraft.block.BlockState; | ||
import net.minecraft.client.world.ClientWorld; | ||
import net.minecraft.world.chunk.EmptyChunk; | ||
import org.spongepowered.asm.mixin.*; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
@Mixin(WorldSlice.class) | ||
public abstract class WorldSliceMixin { | ||
@Shadow | ||
@Final | ||
private ClientWorld world; | ||
|
||
@Unique | ||
private final Long2ObjectOpenHashMap<ShadowDisguiseMapComponent> componentCache = new Long2ObjectOpenHashMap<>(); | ||
|
||
@Inject( | ||
method = "getBlockState(III)Lnet/minecraft/block/BlockState;", | ||
at = @At( | ||
value = "FIELD", | ||
target = "Lme/jellysquid/mods/sodium/client/world/WorldSlice;originX:I" | ||
), | ||
cancellable = true | ||
) | ||
private void disguiseBlockState(int x, int y, int z, CallbackInfoReturnable<BlockState> cir) { | ||
var chunkX = x >> 4; | ||
var chunkZ = z >> 4; | ||
var chunkId = ((long) chunkX) << 32 | ((long) chunkZ); | ||
|
||
var disguises = componentCache.get(chunkId); | ||
if (disguises == null) { | ||
var chunk = world.getChunk(chunkX, chunkZ); | ||
|
||
if (chunk != null && !(chunk instanceof EmptyChunk)) { | ||
disguises = ModChunkCumponents.SHADOW_DISGUISE_MAP.get(chunk); | ||
} | ||
|
||
if (disguises != null) { | ||
componentCache.put(chunkId, disguises); | ||
} | ||
} | ||
|
||
if (disguises != null) { | ||
var funnyState = disguises.getFunnyState(x, y, z); | ||
|
||
if (funnyState != null) { | ||
cir.setReturnValue(funnyState); | ||
} | ||
} | ||
} | ||
} |
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