mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-11-21 04:42:17 +00:00
Compare commits
10
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8c3ac9e310 | ||
|
|
6a7c2520d0 | ||
|
|
a0d782a1a5 | ||
|
|
aebaab8d6f | ||
|
|
05158317e8 | ||
|
|
4d39c90ba6 | ||
|
|
83cf0801ef | ||
|
|
db49a613a0 | ||
|
|
64087f53c5 | ||
|
|
efb039ff38 |
No files matched your search
@@ -7,6 +7,7 @@
|
||||
|
||||
|
||||
# Required Dependencies
|
||||
* [UniMixins](https://github.com/LegacyModdingMC/UniMixins/releases) >= 0.1.14
|
||||
* [GTNHLib](https://github.com/GTNewHorizons/GTNHLib/releases) >= 0.2.1
|
||||
|
||||
# Known (temporary) Incompatibilities
|
||||
|
||||
+1
-1
@@ -57,7 +57,7 @@ replaceGradleTokenInFile =
|
||||
# In case your mod provides an API for other mods to implement you may declare its package here. Otherwise, you can
|
||||
# leave this property empty.
|
||||
# Example value: apiPackage = api + modGroup = com.myname.mymodid -> com.myname.mymodid.api
|
||||
apiPackage =
|
||||
apiPackage = api
|
||||
|
||||
# Specify the configuration file for Forge's access transformers here. It must be placed into /src/main/resources/META-INF/
|
||||
# There can be multiple files in a comma-separated list.
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.gtnewhorizons.angelica.api;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import static java.lang.annotation.ElementType.TYPE;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
/**
|
||||
* Marks an ISBRH as thread-safe, allowing Angelica to run it off-thread.
|
||||
*
|
||||
* <p>Note: Any tessellator access <i>must</i> be done within the methods of the ISBRH and not cached in the class.</p>
|
||||
*/
|
||||
@Documented
|
||||
@Target({ TYPE })
|
||||
@Retention(RUNTIME)
|
||||
public @interface ThreadSafeISBRH {
|
||||
/**
|
||||
* Specifies whether Angelica should create a thread local instance of the class for each thread.
|
||||
* <ul>
|
||||
* <li>If this is set to <tt>true</tt>, a new instance will be created using the default constructor on each thread.</li>
|
||||
* <ul>
|
||||
* <li>Note: If your renderer requires arguments to the constructor, do <i>not</i> use this annotation;
|
||||
* instead use the {@link ThreadSafeISBRHFactory} interface and implement the {@link ThreadSafeISBRHFactory#newInstance} method. </li>
|
||||
* </ul>
|
||||
* <li>If this is set to <tt>false</tt>, the main thread instance will be used on all threads.
|
||||
* Use this option if your renderer class has no state, and can be safely used from multiple threads as is.</li>
|
||||
* <ul>
|
||||
* <li>No state/non final variables should be stored in the ISBRH as it is not guaranteed to be thread safe.</li>
|
||||
* </ul>
|
||||
* </ul>
|
||||
*/
|
||||
boolean perThread();
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.gtnewhorizons.angelica.api;
|
||||
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
|
||||
/**
|
||||
* Marks an ISBRH as thread-safe using a thread local instance, allowing Angelica to run it off-thread.
|
||||
* Use this when your ISBRH uses a non-default constructor.
|
||||
* <p>To avoid a hard dependency on Angelica, you will likely want to mark this as an optional interface using:</p>
|
||||
* <pre>
|
||||
* @Optional.Interface(modid = "angelica", iface = "com.gtnewhorizons.angelica.api.ThreadSafeISBRHFactory")
|
||||
* </pre>
|
||||
*
|
||||
* <p><b>Notes</b></p>
|
||||
* <ul>
|
||||
* <li>Any tessellator access <i>must</i> be done within the methods of the ISBRH and not cached in the class.</li>
|
||||
* <li>If your class uses a default constructor or is thread-safe by default, consider using the simpler {@link ThreadSafeISBRH}
|
||||
* annotation instead.
|
||||
* </ul>
|
||||
*/
|
||||
public interface ThreadSafeISBRHFactory extends ISimpleBlockRenderingHandler {
|
||||
ThreadSafeISBRHFactory newInstance();
|
||||
}
|
||||
@@ -83,11 +83,6 @@ public class AngelicaConfig {
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean optimizeTextureLoading;
|
||||
|
||||
@Config.Comment("Optimize slow glGetInteger in Jabba w/ Nvidia Drivers")
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean optimizeJabbaGetInteger;
|
||||
|
||||
@Config.Comment("Fix thread-safety in lotrs rendering")
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.RequiresMcRestart
|
||||
|
||||
@@ -230,7 +230,7 @@ public class GLStateManager {
|
||||
};
|
||||
}
|
||||
|
||||
private static void glGetBoolean(int pname, ByteBuffer params) {
|
||||
public static void glGetBoolean(int pname, ByteBuffer params) {
|
||||
if(GLStateManager.BYPASS_CACHE) {
|
||||
GL11.glGetBoolean(pname, params);
|
||||
return;
|
||||
@@ -598,7 +598,7 @@ public class GLStateManager {
|
||||
}
|
||||
|
||||
public static void glDeleteTextures(IntBuffer ids) {
|
||||
for(int i = 0; i < ids.capacity(); i++) {
|
||||
for(int i = 0; i < ids.remaining(); i++) {
|
||||
onDeleteTexture(ids.get(i));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.interfaces;
|
||||
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
|
||||
public interface IThreadSafeISBRH extends ISimpleBlockRenderingHandler {
|
||||
IThreadSafeISBRH getThreadLocal();
|
||||
|
||||
}
|
||||
@@ -20,11 +20,19 @@ public class MixinCompatHackTweaker implements ITweaker {
|
||||
public static final boolean DISABLE_OPTIFINE_AND_FASTCRAFT = true;
|
||||
@Override
|
||||
public void acceptOptions(List<String> args, File gameDir, File assetsDir, String profile) {
|
||||
verifyDependencies();
|
||||
|
||||
if(DISABLE_OPTIFINE_AND_FASTCRAFT) {
|
||||
LOGGER.info("Disabling Optifine and Fastcraft (if present)");
|
||||
disableOptifineAndFastcraft();
|
||||
}
|
||||
}
|
||||
|
||||
private void verifyDependencies() {
|
||||
if(MixinCompatHackTweaker.class.getResource("/it/unimi/dsi/fastutil/ints/Int2ObjectMap.class") == null) {
|
||||
throw new RuntimeException("Missing dependency: Angelica requires GTNHLib 0.2.1 or newer! Download: https://modrinth.com/mod/gtnhlib");
|
||||
}
|
||||
}
|
||||
|
||||
private void disableOptifineAndFastcraft() {
|
||||
// Remove Optifine and Fastcraft transformers & Mod Containers
|
||||
|
||||
@@ -79,6 +79,7 @@ public enum Mixins {
|
||||
,"shaders.startup.MixinInitRenderer"
|
||||
,"shaders.startup.MixinAbstractTexture"
|
||||
,"shaders.startup.MixinTextureAtlasSprite"
|
||||
,"shaders.startup.MixinTextureMap"
|
||||
)
|
||||
),
|
||||
|
||||
|
||||
+6
-6
@@ -31,17 +31,17 @@ public abstract class MixinBlockLeaves extends BlockLeavesBase {
|
||||
//A mod dev had no idea what they were doing.
|
||||
return getIcon(side, world.getBlockMetadata(x, y, z));
|
||||
}
|
||||
int renderMode = ((LeavesQuality)Settings.MODE_LEAVES.option.getStore()).ordinal() - 1;
|
||||
int maskedMeta = world.getBlockMetadata(x, y, z) & 3;
|
||||
renderMode = switch (renderMode) {
|
||||
case -1 -> SettingsManager.leavesOpaque ? 1 : 0;
|
||||
case 4 -> world.getBlock(
|
||||
int renderMode;
|
||||
if(Settings.MODE_LEAVES.option.getStore() == LeavesQuality.SHELLED_FAST) {
|
||||
renderMode = world.getBlock(
|
||||
x + Facing.offsetsXForSide[side],
|
||||
y + Facing.offsetsYForSide[side],
|
||||
z + Facing.offsetsZForSide[side]
|
||||
) instanceof ILeafBlock ? 1 : 0;
|
||||
default -> renderMode > 1 ? 0 : renderMode;
|
||||
};
|
||||
} else {
|
||||
renderMode = SettingsManager.leavesOpaque ? 1 : 0;
|
||||
}
|
||||
maskedMeta = maskedMeta >= field_150129_M[renderMode].length ? 0 : maskedMeta;
|
||||
return field_150129_M[renderMode][maskedMeta];
|
||||
}
|
||||
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
package com.gtnewhorizons.angelica.mixins.early.shaders.startup;
|
||||
|
||||
import net.coderbot.iris.texture.pbr.PBRAtlasHolder;
|
||||
import net.coderbot.iris.texture.pbr.TextureAtlasExtension;
|
||||
import net.minecraft.client.renderer.texture.AbstractTexture;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(TextureMap.class)
|
||||
public abstract class MixinTextureMap extends AbstractTexture implements TextureAtlasExtension {
|
||||
@Unique
|
||||
private PBRAtlasHolder iris$pbrHolder;
|
||||
|
||||
@Inject(method = "updateAnimations()V", at = @At("TAIL"))
|
||||
private void iris$onTailUpdateAnimations(CallbackInfo ci) {
|
||||
if (iris$pbrHolder != null) {
|
||||
iris$pbrHolder.cycleAnimationFrames();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PBRAtlasHolder getPBRHolder() {
|
||||
return iris$pbrHolder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PBRAtlasHolder getOrCreatePBRHolder() {
|
||||
if (iris$pbrHolder == null) {
|
||||
iris$pbrHolder = new PBRAtlasHolder();
|
||||
}
|
||||
return iris$pbrHolder;
|
||||
}
|
||||
}
|
||||
+27
-5
@@ -1,21 +1,26 @@
|
||||
package com.gtnewhorizons.angelica.mixins.early.sodium;
|
||||
|
||||
import com.gtnewhorizons.angelica.interfaces.IThreadSafeISBRH;
|
||||
import com.gtnewhorizons.angelica.api.ThreadSafeISBRH;
|
||||
import com.gtnewhorizons.angelica.api.ThreadSafeISBRHFactory;
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.IRenderingRegistryExt;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.Map;
|
||||
|
||||
@Mixin(value = RenderingRegistry.class, remap = false)
|
||||
public class MixinRenderingRegistry implements IRenderingRegistryExt {
|
||||
@Shadow private Map<Integer, ISimpleBlockRenderingHandler> blockRenderers;
|
||||
|
||||
private ThreadLocal<Map<Class<?>, Object>> THREAD_LOCAL_MAP = ThreadLocal.withInitial(Reference2ObjectOpenHashMap::new);
|
||||
@Override
|
||||
public ISimpleBlockRenderingHandler getISBRH(int modelId) {
|
||||
return this.blockRenderers.get(modelId);
|
||||
@@ -23,10 +28,27 @@ public class MixinRenderingRegistry implements IRenderingRegistryExt {
|
||||
|
||||
@WrapOperation(method = { "renderWorldBlock", "renderInventoryBlock", "renderItemAsFull3DBlock" }, at = @At(value="INVOKE", target="Ljava/util/Map;get(Ljava/lang/Object;)Ljava/lang/Object;"))
|
||||
private Object getWrapped(Map<Integer, ISimpleBlockRenderingHandler> instance, Object modelId, Operation<ISimpleBlockRenderingHandler> original) {
|
||||
final ISimpleBlockRenderingHandler res = original.call(instance, modelId);
|
||||
if(res instanceof IThreadSafeISBRH isbhr) {
|
||||
return isbhr.getThreadLocal();
|
||||
// TODO: Move this to BlockRenderer
|
||||
|
||||
// Get the main thread handler
|
||||
final ISimpleBlockRenderingHandler mainThreadHandler = original.call(instance, modelId);
|
||||
if(Thread.currentThread() != GLStateManager.getMainThread()) {
|
||||
ThreadSafeISBRH annotation = mainThreadHandler.getClass().getAnnotation(ThreadSafeISBRH.class);
|
||||
if (annotation != null && annotation.perThread()) {
|
||||
return THREAD_LOCAL_MAP.get().computeIfAbsent(mainThreadHandler.getClass(), k -> {
|
||||
try {
|
||||
// Won't work with non-default constructors, use ThreadSafeISBRHFactory instead
|
||||
return mainThreadHandler.getClass().getDeclaredConstructor().newInstance();
|
||||
} catch (InstantiationException | IllegalAccessException | NoSuchMethodException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch(InvocationTargetException e) {
|
||||
throw new RuntimeException(e.getCause());
|
||||
}
|
||||
});
|
||||
} else if (mainThreadHandler.getClass().isInstance(ThreadSafeISBRHFactory.class)) {
|
||||
return THREAD_LOCAL_MAP.get().computeIfAbsent(mainThreadHandler.getClass(), k -> ((ThreadSafeISBRHFactory) mainThreadHandler).newInstance());
|
||||
}
|
||||
}
|
||||
return res;
|
||||
return mainThreadHandler;
|
||||
}
|
||||
}
|
||||
+6
-6
@@ -20,17 +20,17 @@ public abstract class MixinBlockMagicalLeaves extends Block implements ILeafBloc
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
|
||||
int renderMode = ((LeavesQuality)Settings.MODE_LEAVES.option.getStore()).ordinal() - 1;
|
||||
int maskedMeta = world.getBlockMetadata(x, y, z) & 3;
|
||||
renderMode = switch (renderMode) {
|
||||
case -1 -> SettingsManager.leavesOpaque ? 1 : 0;
|
||||
case 4 -> world.getBlock(
|
||||
int renderMode;
|
||||
if(Settings.MODE_LEAVES.option.getStore() == LeavesQuality.SHELLED_FAST) {
|
||||
renderMode = world.getBlock(
|
||||
x + Facing.offsetsXForSide[side],
|
||||
y + Facing.offsetsYForSide[side],
|
||||
z + Facing.offsetsZForSide[side]
|
||||
) instanceof ILeafBlock ? 1 : 0;
|
||||
default -> renderMode > 1 ? 0 : renderMode;
|
||||
};
|
||||
} else {
|
||||
renderMode = SettingsManager.leavesOpaque ? 1 : 0;
|
||||
}
|
||||
maskedMeta = maskedMeta > 1 ? 0 : maskedMeta;
|
||||
return icon[renderMode + maskedMeta * 2];
|
||||
}
|
||||
|
||||
+6
-6
@@ -17,17 +17,17 @@ public abstract class MixinBlockTFLeaves extends BlockLeaves {
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
|
||||
int renderMode = ((LeavesQuality)Settings.MODE_LEAVES.option.getStore()).ordinal() - 1;
|
||||
int maskedMeta = world.getBlockMetadata(x, y, z) & 3;
|
||||
renderMode = switch (renderMode) {
|
||||
case -1 -> SettingsManager.leavesOpaque ? 1 : 0;
|
||||
case 4 -> world.getBlock(
|
||||
int renderMode;
|
||||
if(Settings.MODE_LEAVES.option.getStore() == LeavesQuality.SHELLED_FAST) {
|
||||
renderMode = world.getBlock(
|
||||
x + Facing.offsetsXForSide[side],
|
||||
y + Facing.offsetsYForSide[side],
|
||||
z + Facing.offsetsZForSide[side]
|
||||
) instanceof ILeafBlock ? 1 : 0;
|
||||
default -> renderMode > 1 ? 0 : renderMode;
|
||||
};
|
||||
} else {
|
||||
renderMode = SettingsManager.leavesOpaque ? 1 : 0;
|
||||
}
|
||||
maskedMeta = maskedMeta > 1 ? 0 : maskedMeta;
|
||||
return Blocks.leaves.field_150129_M[renderMode][maskedMeta];
|
||||
}
|
||||
|
||||
+6
-6
@@ -17,16 +17,16 @@ public abstract class MixinBlockTFLeaves3 extends BlockLeaves {
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
|
||||
int renderMode = ((LeavesQuality)Settings.MODE_LEAVES.option.getStore()).ordinal() - 1;
|
||||
renderMode = switch (renderMode) {
|
||||
case -1 -> SettingsManager.leavesOpaque ? 1 : 0;
|
||||
case 4 -> world.getBlock(
|
||||
int renderMode;
|
||||
if(Settings.MODE_LEAVES.option.getStore() == LeavesQuality.SHELLED_FAST) {
|
||||
renderMode = world.getBlock(
|
||||
x + Facing.offsetsXForSide[side],
|
||||
y + Facing.offsetsYForSide[side],
|
||||
z + Facing.offsetsZForSide[side]
|
||||
) instanceof ILeafBlock ? 1 : 0;
|
||||
default -> renderMode > 1 ? 0 : renderMode;
|
||||
};
|
||||
} else {
|
||||
renderMode = SettingsManager.leavesOpaque ? 1 : 0;
|
||||
}
|
||||
return Blocks.leaves.field_150129_M[renderMode][0];
|
||||
}
|
||||
|
||||
|
||||
+6
-6
@@ -16,17 +16,17 @@ import twilightforest.block.BlockTFMagicLeaves;
|
||||
public abstract class MixinBlockTFMagicLeaves extends BlockLeaves {
|
||||
@Override
|
||||
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
|
||||
int renderMode = ((LeavesQuality)Settings.MODE_LEAVES.option.getStore()).ordinal() - 1;
|
||||
int maskedMeta = world.getBlockMetadata(x, y, z) & 3;
|
||||
renderMode = switch (renderMode) {
|
||||
case -1 -> SettingsManager.leavesOpaque ? 1 : 0;
|
||||
case 4 -> world.getBlock(
|
||||
int renderMode;
|
||||
if(Settings.MODE_LEAVES.option.getStore() == LeavesQuality.SHELLED_FAST) {
|
||||
renderMode = world.getBlock(
|
||||
x + Facing.offsetsXForSide[side],
|
||||
y + Facing.offsetsYForSide[side],
|
||||
z + Facing.offsetsZForSide[side]
|
||||
) instanceof ILeafBlock ? 1 : 0;
|
||||
default -> renderMode > 1 ? 0 : renderMode;
|
||||
};
|
||||
} else {
|
||||
renderMode = SettingsManager.leavesOpaque ? 1 : 0;
|
||||
}
|
||||
maskedMeta = maskedMeta > 1 ? 0 : maskedMeta;
|
||||
return switch (maskedMeta) {
|
||||
case 1 -> renderMode == 1 ? SPR_TRANSLEAVES_OPAQUE : SPR_TRANSLEAVES;
|
||||
|
||||
+6
-6
@@ -28,17 +28,17 @@ public abstract class MixinBlockWitchLeaves extends BlockLeavesBase {
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
|
||||
int renderMode = ((LeavesQuality)Settings.MODE_LEAVES.option.getStore()).ordinal() - 1;
|
||||
int maskedMeta = world.getBlockMetadata(x, y, z) & 3;
|
||||
renderMode = switch (renderMode) {
|
||||
case -1 -> SettingsManager.leavesOpaque ? 1 : 0;
|
||||
case 4 -> world.getBlock(
|
||||
int renderMode;
|
||||
if(Settings.MODE_LEAVES.option.getStore() == LeavesQuality.SHELLED_FAST) {
|
||||
renderMode = world.getBlock(
|
||||
x + Facing.offsetsXForSide[side],
|
||||
y + Facing.offsetsYForSide[side],
|
||||
z + Facing.offsetsZForSide[side]
|
||||
) instanceof ILeafBlock ? 1 : 0;
|
||||
default -> renderMode > 1 ? 0 : renderMode;
|
||||
};
|
||||
} else {
|
||||
renderMode = SettingsManager.leavesOpaque ? 1 : 0;
|
||||
}
|
||||
maskedMeta = maskedMeta > 1 ? 0 : maskedMeta;
|
||||
return iconsForModes[renderMode][maskedMeta];
|
||||
}
|
||||
|
||||
+13
-5
@@ -1,10 +1,10 @@
|
||||
package com.gtnewhorizons.angelica.rendering;
|
||||
|
||||
import com.gtnewhorizons.angelica.interfaces.IThreadSafeISBRH;
|
||||
import com.gtnewhorizons.angelica.api.ThreadSafeISBRH;
|
||||
import com.gtnewhorizons.angelica.api.ThreadSafeISBRHFactory;
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.IRenderingRegistryExt;
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.versioning.ComparableVersion;
|
||||
import it.unimi.dsi.fastutil.objects.Reference2BooleanMap;
|
||||
import it.unimi.dsi.fastutil.objects.Reference2BooleanOpenHashMap;
|
||||
import net.minecraft.block.Block;
|
||||
@@ -39,8 +39,16 @@ public class AngelicaBlockSafetyRegistry {
|
||||
}
|
||||
|
||||
private static boolean populateCanRenderOffThread(Block block, Reference2BooleanMap<Block> map) {
|
||||
@SuppressWarnings("deprecation")
|
||||
final boolean canBeOffThread = map == ISBRH_SAFETY_MAP ? ((IRenderingRegistryExt)RenderingRegistry.instance()).getISBRH(block.getRenderType()) instanceof IThreadSafeISBRH : !(block.getClass().getName().startsWith("gregtech."));
|
||||
final boolean canBeOffThread;
|
||||
if(map == ISBRH_SAFETY_MAP) {
|
||||
@SuppressWarnings("deprecation")
|
||||
final ISimpleBlockRenderingHandler isbrh = ((IRenderingRegistryExt)RenderingRegistry.instance()).getISBRH(block.getRenderType());
|
||||
canBeOffThread = isbrh != null
|
||||
&& (isbrh.getClass().isAnnotationPresent(ThreadSafeISBRH.class)
|
||||
|| isbrh instanceof ThreadSafeISBRHFactory);
|
||||
} else {
|
||||
canBeOffThread = !(block.getClass().getName().startsWith("gregtech."));
|
||||
}
|
||||
|
||||
final long stamp = LOCK.writeLock();
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import java.util.List;
|
||||
|
||||
public class BlockTransformer implements IClassTransformer {
|
||||
public static final String BlockClass = "net/minecraft/block/Block";
|
||||
public static final String BlockPackage = BlockClass.substring(0, BlockClass.lastIndexOf('/') + 1);
|
||||
private static final String BlockClassFriendly = BlockClass.replace('/', '.');
|
||||
public static final List<Pair<String, String>> BlockBoundsFields = ImmutableList.of(
|
||||
Pair.of("minX", "field_149759_B"),
|
||||
|
||||
@@ -61,6 +61,16 @@ public class ClassConstantPoolParser {
|
||||
* for
|
||||
*/
|
||||
public boolean find(byte[] basicClass) {
|
||||
return find(basicClass, false);
|
||||
}
|
||||
/**
|
||||
* Returns true if the constant pool of the class represented by this byte array contains one of the Strings we are looking
|
||||
* for.
|
||||
*
|
||||
* @param prefixes If true, it is enough for a constant pool entry to <i>start</i> with one of our Strings to count as a match -
|
||||
* otherwise, the entire String has to match.
|
||||
*/
|
||||
public boolean find(byte[] basicClass, boolean prefixes) {
|
||||
if (basicClass == null || basicClass.length == 0) {
|
||||
return false;
|
||||
}
|
||||
@@ -92,9 +102,9 @@ public class ClassConstantPoolParser {
|
||||
final int strLen = readUnsignedShort(index + 1, basicClass);
|
||||
size = 3 + strLen;
|
||||
for (byte[] bytes : BYTES_TO_SEARCH) {
|
||||
if (strLen == bytes.length) {
|
||||
if (prefixes ? strLen >= bytes.length : strLen == bytes.length) {
|
||||
boolean found = true;
|
||||
for (int j = index + 3; j < index + 3 + strLen; j++) {
|
||||
for (int j = index + 3; j < index + 3 + bytes.length; j++) {
|
||||
if (basicClass[j] != bytes[j - (index + 3)]) {
|
||||
found = false;
|
||||
break;
|
||||
|
||||
@@ -36,6 +36,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
import static com.gtnewhorizons.angelica.transform.BlockTransformer.BlockBoundsFields;
|
||||
import static com.gtnewhorizons.angelica.transform.BlockTransformer.BlockClass;
|
||||
import static com.gtnewhorizons.angelica.transform.BlockTransformer.BlockPackage;
|
||||
|
||||
/**
|
||||
* This transformer redirects all Tessellator.instance field accesses to go through our TessellatorManager.
|
||||
@@ -63,8 +64,16 @@ public class RedirectorTransformer implements IClassTransformer {
|
||||
"startGame", "func_71384_a",
|
||||
"initializeTextures", "func_77474_a"
|
||||
);
|
||||
/** All classes in <tt>net.minecraft.block.*</tt> are the block subclasses save for these. */
|
||||
private static final List<String> VanillaBlockExclusions = Arrays.asList(
|
||||
"net/minecraft/block/IGrowable",
|
||||
"net/minecraft/block/ITileEntityProvider",
|
||||
"net/minecraft/block/BlockEventData",
|
||||
"net/minecraft/block/BlockSourceImpl",
|
||||
"net/minecraft/block/material/"
|
||||
);
|
||||
|
||||
private static final ClassConstantPoolParser cstPoolParser = new ClassConstantPoolParser(GL11, GL13, GL14, OpenGlHelper, EXTBlendFunc, ARBMultiTexture, TessellatorClass, BlockClass,
|
||||
private static final ClassConstantPoolParser cstPoolParser = new ClassConstantPoolParser(GL11, GL13, GL14, OpenGlHelper, EXTBlendFunc, ARBMultiTexture, TessellatorClass, BlockPackage,
|
||||
Project);
|
||||
private static final Map<String, Map<String, String>> methodRedirects = new HashMap<>();
|
||||
private static final Map<Integer, String> glCapRedirects = new HashMap<>();
|
||||
@@ -76,7 +85,7 @@ public class RedirectorTransformer implements IClassTransformer {
|
||||
);
|
||||
private static int remaps = 0;
|
||||
|
||||
private static final Set<String> blockSubclasses = Collections.newSetFromMap(new ConcurrentHashMap<>());
|
||||
private static final Set<String> moddedBlockSubclasses = Collections.newSetFromMap(new ConcurrentHashMap<>());
|
||||
// Block owners we *shouldn't* redirect because they shadow one of our fields
|
||||
private static final Set<String> blockOwnerExclusions = Collections.newSetFromMap(new ConcurrentHashMap<>());
|
||||
|
||||
@@ -152,7 +161,22 @@ public class RedirectorTransformer implements IClassTransformer {
|
||||
methodRedirects.put(EXTBlendFunc, RedirectMap.newMap().add("glBlendFuncSeparateEXT", "tryBlendFuncSeparate"));
|
||||
methodRedirects.put(ARBMultiTexture, RedirectMap.newMap().add("glActiveTextureARB"));
|
||||
methodRedirects.put(Project, RedirectMap.newMap().add("gluPerspective"));
|
||||
blockSubclasses.add(BlockClass);
|
||||
}
|
||||
|
||||
private boolean isVanillaBlockSubclass(String className) {
|
||||
if(className.startsWith(BlockTransformer.BlockPackage)) {
|
||||
for(String exclusion : VanillaBlockExclusions) {
|
||||
if(className.startsWith(exclusion)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isBlockSubclass(String className) {
|
||||
return isVanillaBlockSubclass(className) || moddedBlockSubclasses.contains(className);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -167,7 +191,7 @@ public class RedirectorTransformer implements IClassTransformer {
|
||||
}
|
||||
}
|
||||
|
||||
if (!cstPoolParser.find(basicClass)) {
|
||||
if (!cstPoolParser.find(basicClass, true)) {
|
||||
return basicClass;
|
||||
}
|
||||
|
||||
@@ -176,19 +200,17 @@ public class RedirectorTransformer implements IClassTransformer {
|
||||
cr.accept(cn, 0);
|
||||
|
||||
// Track subclasses of Block
|
||||
if (blockSubclasses.contains(cn.superName)) {
|
||||
blockSubclasses.add(cn.name);
|
||||
if (!isVanillaBlockSubclass(cn.name) && isBlockSubclass(cn.superName)) {
|
||||
moddedBlockSubclasses.add(cn.name);
|
||||
cstPoolParser.addString(cn.name);
|
||||
}
|
||||
|
||||
// Check if this class shadows any fields of the parent class
|
||||
if(blockSubclasses.contains(cn.name)) {
|
||||
if(moddedBlockSubclasses.contains(cn.name)) {
|
||||
// If a superclass shadows, then so do we, because JVM will resolve a reference on our class to that
|
||||
// superclass
|
||||
boolean doWeShadow;
|
||||
if(cn.name.equals(BlockClass)) {
|
||||
doWeShadow = false; // by definition
|
||||
} else if(blockOwnerExclusions.contains(cn.superName)) {
|
||||
if(blockOwnerExclusions.contains(cn.superName)) {
|
||||
doWeShadow = true;
|
||||
} else {
|
||||
// Check if we declare any known field names
|
||||
@@ -274,7 +296,7 @@ public class RedirectorTransformer implements IClassTransformer {
|
||||
}
|
||||
}
|
||||
else if ((node.getOpcode() == Opcodes.GETFIELD || node.getOpcode() == Opcodes.PUTFIELD) && node instanceof FieldInsnNode fNode) {
|
||||
if(!blockOwnerExclusions.contains(fNode.owner) && blockSubclasses.contains(fNode.owner) && AngelicaConfig.enableSodium) {
|
||||
if(!blockOwnerExclusions.contains(fNode.owner) && isBlockSubclass(fNode.owner) && AngelicaConfig.enableSodium) {
|
||||
Pair<String, String> fieldToRedirect = null;
|
||||
for(Pair<String, String> blockPairs : BlockBoundsFields) {
|
||||
if(fNode.name.equals(blockPairs.getLeft()) || fNode.name.equals(blockPairs.getRight())) {
|
||||
|
||||
@@ -85,7 +85,7 @@ public class SettingsManager {
|
||||
//Do not re-enable, see MixinBlockLeaves workaround for Angelica/Sodium style menus.
|
||||
//mc.renderGlobal.loadRenderers();
|
||||
LeavesQuality value = (LeavesQuality)Settings.MODE_LEAVES.option.getStore();
|
||||
leavesOpaque = value == LeavesQuality.FANCY || (value == LeavesQuality.DEFAULT && !mc.gameSettings.fancyGraphics);
|
||||
leavesOpaque = value == LeavesQuality.FAST || (value == LeavesQuality.DEFAULT && !mc.gameSettings.fancyGraphics);
|
||||
Blocks.leaves.setGraphicsLevel(!leavesOpaque);
|
||||
Blocks.leaves2.setGraphicsLevel(!leavesOpaque);
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ public class LeafRenderUtil {
|
||||
}
|
||||
if(otherBlock instanceof ILeafBlock) {
|
||||
switch ((LeavesQuality)Settings.MODE_LEAVES.option.getStore()) {
|
||||
case FANCY, SMART -> {
|
||||
case FAST, SMART -> {
|
||||
return false;
|
||||
}
|
||||
case SHELLED_FANCY, SHELLED_FAST -> {
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.google.common.collect.ImmutableList;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import jss.notfine.core.Settings;
|
||||
import jss.notfine.core.SettingsManager;
|
||||
import me.flashyreese.mods.reeses_sodium_options.client.gui.ReeseSodiumVideoOptionsScreen;
|
||||
import me.jellysquid.mods.sodium.client.gui.options.OptionFlag;
|
||||
import me.jellysquid.mods.sodium.client.gui.options.OptionGroup;
|
||||
@@ -162,7 +163,8 @@ public class SodiumGameOptionPages {
|
||||
.setTooltip(I18n.format("sodium.options.graphics_quality.tooltip"))
|
||||
.setControl(option -> new CyclingControl<>(option, GraphicsMode.class))
|
||||
.setBinding(
|
||||
(opts, value) -> opts.fancyGraphics = value.isFancy(),
|
||||
(opts, value) -> { opts.fancyGraphics = value.isFancy();
|
||||
SettingsManager.graphicsUpdated(); },
|
||||
opts -> GraphicsMode.fromBoolean(opts.fancyGraphics))
|
||||
.setImpact(OptionImpact.HIGH)
|
||||
.setFlags(OptionFlag.REQUIRES_RENDERER_RELOAD)
|
||||
|
||||
+9
-7
@@ -201,13 +201,15 @@ public class ChunkRenderRebuildTask<T extends ChunkGraphicsState> extends ChunkR
|
||||
|
||||
if(hasMainThreadBlocks) {
|
||||
// Render the other blocks on the main thread
|
||||
try {
|
||||
CompletableFuture.runAsync(() -> this.performMainBuild(cache, buffers, cancellationSource, bounds, renderData, mainThreadBlocks), AngelicaRenderQueue.executor()).get();
|
||||
} catch(InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
return null;
|
||||
} catch(ExecutionException e) {
|
||||
throw new RuntimeException(e);
|
||||
var future = CompletableFuture.runAsync(() -> this.performMainBuild(cache, buffers, cancellationSource, bounds, renderData, mainThreadBlocks), AngelicaRenderQueue.executor());
|
||||
while(!future.isDone() && !cancellationSource.isCancelled()) {
|
||||
try {
|
||||
future.get();
|
||||
} catch(InterruptedException e) {
|
||||
// go around and check cancellation
|
||||
} catch(ExecutionException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
// Check if cancellation happened during that, so we don't render an incomplete chunk
|
||||
if(cancellationSource.isCancelled()) return null;
|
||||
|
||||
@@ -74,7 +74,10 @@ public class AtlasPBRLoader implements PBRTextureLoader<TextureMap> {
|
||||
}
|
||||
|
||||
if (normalAtlas != null) {
|
||||
if (normalAtlas.tryUpload(atlasWidth, atlasHeight, mipLevel, ((TextureMapAccessor) texMap).getAnisotropicFiltering())) {
|
||||
if (normalAtlas.tryUpload(atlasWidth,
|
||||
atlasHeight,
|
||||
mipLevel,
|
||||
((TextureMapAccessor) texMap).getAnisotropicFiltering())) {
|
||||
pbrTextureConsumer.acceptNormalTexture(normalAtlas);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user