-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Disable thread safety checks with FalseTweaks (#88)
Also adds an API to detect if the thread's tesselator is being captured.
- Loading branch information
Showing
10 changed files
with
77 additions
and
8 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,11 @@ | ||
// Add any additional repositories for your dependencies here | ||
|
||
repositories { | ||
|
||
maven { | ||
name = 'mavenpattern' | ||
url = 'https://mvn.falsepattern.com/releases' | ||
content { | ||
includeGroup 'com.falsepattern' | ||
} | ||
} | ||
} |
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
25 changes: 25 additions & 0 deletions
25
src/main/java/com/gtnewhorizon/gtnhlib/api/CapturingTesselator.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,25 @@ | ||
package com.gtnewhorizon.gtnhlib.api; | ||
|
||
import net.minecraft.client.renderer.Tessellator; | ||
|
||
import com.gtnewhorizon.gtnhlib.client.renderer.TessellatorManager; | ||
|
||
@SuppressWarnings("unused") | ||
public interface CapturingTesselator { | ||
|
||
/** | ||
* @return True if this thread is capturing quads, false otherwise | ||
*/ | ||
static boolean isCapturing() { | ||
return TessellatorManager.isCurrentlyCapturing(); | ||
} | ||
|
||
/** | ||
* @throws IllegalStateException If the thread is not capturing and is not the main one. | ||
* @return The CapturingTesselator for this thread if capturing, or else {@link Tessellator#instance} if on the main | ||
* one. | ||
*/ | ||
static Tessellator getThreadTesselator() { | ||
return TessellatorManager.get(); | ||
} | ||
} |
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
14 changes: 14 additions & 0 deletions
14
src/main/java/com/gtnewhorizon/gtnhlib/compat/FalseTweaks.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,14 @@ | ||
package com.gtnewhorizon.gtnhlib.compat; | ||
|
||
import com.falsepattern.falsetweaks.api.ThreadedChunkUpdates; | ||
|
||
public class FalseTweaks { | ||
|
||
/** | ||
* When FalseTweaks is loaded, it may inject into the Tesselator to do its own threaded chunk building. If it's | ||
* doing that, disable our checks and let FT handle it. | ||
*/ | ||
public static boolean doTessSafetyChecks() { | ||
return !ThreadedChunkUpdates.isEnabled(); | ||
} | ||
} |
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,8 @@ | ||
package com.gtnewhorizon.gtnhlib.compat; | ||
|
||
import cpw.mods.fml.common.Loader; | ||
|
||
public class Mods { | ||
|
||
public static final boolean FALSETWEAKS = Loader.isModLoaded("falsetweaks"); | ||
} |
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