-
Notifications
You must be signed in to change notification settings - Fork 52
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
11 changed files
with
34 additions
and
154 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
### 5.0.1-SNAPSHOT | ||
- Update to Sodium 0.5 | ||
|
||
### 5.0.0 | ||
- Update to Minecraft 1.20.1 | ||
|
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
20 changes: 1 addition & 19 deletions
20
src/main/java/de/johni0702/minecraft/bobby/ext/ClientChunkManagerExt.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,27 +1,9 @@ | ||
package de.johni0702.minecraft.bobby.ext; | ||
|
||
import de.johni0702.minecraft.bobby.FakeChunkManager; | ||
import de.johni0702.minecraft.bobby.sodium.ChunkStatusListener; | ||
|
||
public interface ClientChunkManagerExt { | ||
FakeChunkManager bobby_getFakeChunkManager(); | ||
void bobby_onFakeChunkAdded(int x, int z); | ||
void bobby_onFakeChunkRemoved(int x, int z); | ||
|
||
/** | ||
* Mark Sodium's {@link ChunkStatusListener} as paused. | ||
* This effectively delays all unload notifications until un-paused and most importantly removes redundant (as in | ||
* unload followed by a load) ones. Otherwise Sodium will unload the geometry and the chunk will be missing until | ||
* it is rebuilt. | ||
* | ||
* Has no effect on the vanilla renderer because it polls chunks every frame and gets no intermediate state. | ||
* | ||
* This method is idempotent. | ||
*/ | ||
void bobby_pauseChunkStatusListener(); | ||
|
||
/** | ||
* Resumes Sodium's {@link ChunkStatusListener}, forwarding all updates which are still applicable. | ||
*/ | ||
void bobby_resumeChunkStatusListener(); | ||
void bobby_onFakeChunkRemoved(int x, int z, boolean willBeReplaced); | ||
} |
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
54 changes: 16 additions & 38 deletions
54
src/main/java/de/johni0702/minecraft/bobby/mixin/sodium/SodiumChunkManagerMixin.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,55 +1,33 @@ | ||
package de.johni0702.minecraft.bobby.mixin.sodium; | ||
|
||
import de.johni0702.minecraft.bobby.ext.ClientChunkManagerExt; | ||
import de.johni0702.minecraft.bobby.sodium.BufferedChunkStatusListener; | ||
import de.johni0702.minecraft.bobby.sodium.ChunkStatusListener; | ||
import de.johni0702.minecraft.bobby.sodium.SodiumChunkStatusListenerImpl; | ||
import me.jellysquid.mods.sodium.client.render.chunk.map.ChunkStatus; | ||
import me.jellysquid.mods.sodium.client.render.chunk.map.ChunkTrackerHolder; | ||
import net.minecraft.client.world.ClientChunkManager; | ||
import net.minecraft.client.world.ClientWorld; | ||
import net.minecraft.util.math.ChunkSectionPos; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Unique; | ||
|
||
@Mixin(value = ClientChunkManager.class, priority = 1010) // higher than our normal one | ||
public abstract class SodiumChunkManagerMixin implements ClientChunkManagerExt { | ||
@Unique | ||
private ChunkStatusListener listener = new SodiumChunkStatusListenerImpl(); | ||
private final ClientWorld world; | ||
|
||
@Unique | ||
private BufferedChunkStatusListener bufferedListener; | ||
|
||
@Override | ||
public void bobby_onFakeChunkAdded(int x, int z) { | ||
if (this.listener != null) { | ||
this.listener.onChunkAdded(x, z); | ||
} | ||
} | ||
|
||
@Override | ||
public void bobby_onFakeChunkRemoved(int x, int z) { | ||
if (this.listener != null) { | ||
this.listener.onChunkRemoved(x, z); | ||
} | ||
protected SodiumChunkManagerMixin(ClientWorld world) { | ||
this.world = world; | ||
} | ||
|
||
@Override | ||
public void bobby_pauseChunkStatusListener() { | ||
if (this.listener == this.bufferedListener) { | ||
return; | ||
} | ||
|
||
if (this.bufferedListener == null || this.bufferedListener.delegate != this.listener) { | ||
this.bufferedListener = new BufferedChunkStatusListener(this.listener); | ||
} | ||
|
||
this.listener = this.bufferedListener; | ||
public void bobby_onFakeChunkAdded(int x, int z) { | ||
// Fake chunks always have light data included, so we use ALL rather than just HAS_BLOCK_DATA | ||
ChunkTrackerHolder.get(world).onChunkStatusAdded(x, z, ChunkStatus.FLAG_ALL); | ||
} | ||
|
||
@Override | ||
public void bobby_resumeChunkStatusListener() { | ||
if (this.listener != this.bufferedListener) { | ||
return; | ||
} | ||
|
||
this.bufferedListener.flush(); | ||
this.listener = this.bufferedListener.delegate; | ||
public void bobby_onFakeChunkRemoved(int x, int z, boolean willBeReplaced) { | ||
// If we know the chunk will be replaced by a real one, then we can pretend like light data is already | ||
// available, otherwise Sodium will unload the chunk for a few frames until MC's delayed light update gets | ||
// around to actually inserting the real light. | ||
boolean stillHasLight = willBeReplaced || world.getLightingProvider().isLightingEnabled(ChunkSectionPos.from(x, 0, z)); | ||
ChunkTrackerHolder.get(world).onChunkStatusRemoved(x, z, stillHasLight ? ChunkStatus.FLAG_HAS_BLOCK_DATA : ChunkStatus.FLAG_ALL); | ||
} | ||
} |
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: 0 additions & 33 deletions
33
src/main/java/de/johni0702/minecraft/bobby/sodium/BufferedChunkStatusListener.java
This file was deleted.
Oops, something went wrong.
6 changes: 0 additions & 6 deletions
6
src/main/java/de/johni0702/minecraft/bobby/sodium/ChunkStatusListener.java
This file was deleted.
Oops, something went wrong.
22 changes: 0 additions & 22 deletions
22
src/main/java/de/johni0702/minecraft/bobby/sodium/SodiumChunkStatusListenerImpl.java
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -39,7 +39,7 @@ | |
"modmenu": "^${modMenuVersion}" | ||
}, | ||
"breaks": { | ||
"sodium": "<0.3.0" | ||
"sodium": "<0.5.1" | ||
}, | ||
|
||
"custom": { | ||
|