mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-11-16 18:54:45 +00:00
Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9a73dc9bfd | ||
|
|
f01cdfda4b | ||
|
|
daa1405ba4 |
No files matched your search
@@ -101,6 +101,11 @@ public class AngelicaConfig {
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean fixLotrSodiumCompat;
|
||||
|
||||
@Config.Comment("Fix thread-safety in Extra Utilities rendering")
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean fixExtraUtilsSodiumCompat;
|
||||
|
||||
@Config.Comment("Enable Debug Logging")
|
||||
@Config.DefaultBoolean(false)
|
||||
@Config.RequiresMcRestart
|
||||
|
||||
@@ -1112,8 +1112,8 @@ public class GLStateManager {
|
||||
}
|
||||
|
||||
public static void glLoadMatrix(DoubleBuffer m) {
|
||||
conersionMatrix4d.set(m);
|
||||
getMatrixStack().set(conersionMatrix4d);
|
||||
conversionMatrix4d.set(m);
|
||||
getMatrixStack().set(conversionMatrix4d);
|
||||
GL11.glLoadMatrix(m);
|
||||
}
|
||||
|
||||
@@ -1160,16 +1160,16 @@ public class GLStateManager {
|
||||
public static void glMultMatrix(FloatBuffer floatBuffer) {
|
||||
GL11.glMultMatrix(floatBuffer);
|
||||
tempMatrix4f.set(floatBuffer);
|
||||
getMatrixStack().mul(conersionMatrix4f);
|
||||
getMatrixStack().mul(tempMatrix4f);
|
||||
}
|
||||
|
||||
public static final Matrix4d conersionMatrix4d = new Matrix4d();
|
||||
public static final Matrix4f conersionMatrix4f = new Matrix4f();
|
||||
public static final Matrix4d conversionMatrix4d = new Matrix4d();
|
||||
public static final Matrix4f conversionMatrix4f = new Matrix4f();
|
||||
public static void glMultMatrix(DoubleBuffer matrix) {
|
||||
GL11.glMultMatrix(matrix);
|
||||
conersionMatrix4d.set(matrix);
|
||||
conersionMatrix4f.set(conersionMatrix4d);
|
||||
getMatrixStack().mul(conersionMatrix4f);
|
||||
conversionMatrix4d.set(matrix);
|
||||
conversionMatrix4f.set(conversionMatrix4d);
|
||||
getMatrixStack().mul(conversionMatrix4f);
|
||||
}
|
||||
|
||||
private static final Vector3f rotation = new Vector3f();
|
||||
|
||||
@@ -248,7 +248,7 @@ public class HUDCaching {
|
||||
// moved to here due to the method being called from a mixin
|
||||
public static void disableHoloInventory() {
|
||||
if (ModStatus.isHoloInventoryLoaded){
|
||||
Renderer.INSTANCE.angelicaOverride = true;
|
||||
Renderer.INSTANCE.angelicaOverride = isEnabled;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.gtnewhorizon.gtnhmixins.IEarlyMixinLoader;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import com.gtnewhorizons.angelica.mixins.Mixins;
|
||||
import com.gtnewhorizons.angelica.mixins.TargetedMod;
|
||||
import com.gtnewhorizons.angelica.transform.compat.CompatASMTransformers;
|
||||
import cpw.mods.fml.relauncher.IFMLLoadingPlugin;
|
||||
import jss.notfine.asm.AsmTransformers;
|
||||
import jss.notfine.asm.mappings.Namer;
|
||||
@@ -19,6 +20,8 @@ import org.apache.logging.log4j.core.config.LoggerConfig;
|
||||
import org.spongepowered.asm.launch.GlobalProperties;
|
||||
import org.spongepowered.asm.service.mojang.MixinServiceLaunchWrapper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -67,10 +70,17 @@ public class AngelicaTweaker implements IFMLLoadingPlugin, IEarlyMixinLoader {
|
||||
}
|
||||
|
||||
// Return any others here
|
||||
|
||||
if (transformerClasses == null) {
|
||||
|
||||
//Mod Compat transformers
|
||||
List<String> transformers = new ArrayList<String>();
|
||||
transformers.addAll(CompatASMTransformers.getTransformers());
|
||||
|
||||
//NotFine transformers
|
||||
Namer.initNames();
|
||||
transformerClasses = AsmTransformers.getTransformers();
|
||||
transformers.addAll(Arrays.asList(AsmTransformers.getTransformers()));
|
||||
|
||||
transformerClasses = transformers.toArray(new String[0]);
|
||||
}
|
||||
return transformerClasses;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.gtnewhorizons.angelica.mixins;
|
||||
|
||||
import com.gtnewhorizons.angelica.AngelicaMod;
|
||||
import com.gtnewhorizons.angelica.compat.ModStatus;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import com.gtnewhorizons.angelica.loading.AngelicaTweaker;
|
||||
import cpw.mods.fml.relauncher.FMLLaunchHandler;
|
||||
@@ -183,6 +184,14 @@ public enum Mixins {
|
||||
"angelica.animation.MixinWorldRenderer",
|
||||
"angelica.animation.MixinRenderItem")),
|
||||
|
||||
EXTRA_UTILITIES_THREAD_SAFETY(new Builder("Enable thread safety fixes in Extra Utilities").setPhase(Phase.LATE)
|
||||
.addTargetedMod(TargetedMod.EXTRAUTILS).setSide(Side.CLIENT)
|
||||
.setApplyIf(() -> AngelicaConfig.fixExtraUtilsSodiumCompat)
|
||||
.addMixinClasses(
|
||||
"client.extrautils.MixinRenderBlockConnectedTextures",
|
||||
"client.extrautils.MixinRenderBlockConnectedTexturesEthereal",
|
||||
"client.extrautils.MixinIconConnectedTexture")),
|
||||
|
||||
SPEEDUP_CAMPFIRE_BACKPORT_ANIMATIONS(new Builder("Add animation speedup support to Campfire Backport").setPhase(Phase.LATE)
|
||||
.addTargetedMod(TargetedMod.CAMPFIRE_BACKPORT).setSide(Side.CLIENT)
|
||||
.setApplyIf(() -> AngelicaConfig.speedupAnimations)
|
||||
|
||||
+96
@@ -0,0 +1,96 @@
|
||||
package com.gtnewhorizons.angelica.mixins.late.client.extrautils;
|
||||
|
||||
import com.rwtema.extrautils.block.IconConnectedTexture;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.util.IIcon;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
|
||||
@Mixin(IconConnectedTexture.class)
|
||||
public class MixinIconConnectedTexture {
|
||||
|
||||
@Final
|
||||
@Shadow(remap = false)
|
||||
public IIcon[] icons;
|
||||
|
||||
@Unique
|
||||
private ThreadLocal<Integer> newN = ThreadLocal.withInitial(() -> 0);
|
||||
|
||||
/**
|
||||
* @author Cleptomania
|
||||
* @reason Supper thread-safety for connected textures
|
||||
*/
|
||||
@Overwrite(remap = false)
|
||||
public void setType(int i) {
|
||||
this.newN.set(i);
|
||||
}
|
||||
|
||||
/**
|
||||
* @author Cleptomania
|
||||
* @reason Supper thread-safety for connected textures
|
||||
*/
|
||||
@Overwrite
|
||||
public float getMinU() {
|
||||
return this.icons[newN.get()].getMinU();
|
||||
}
|
||||
|
||||
/**
|
||||
* @author Cleptomania
|
||||
* @reason Supper thread-safety for connected textures
|
||||
*/
|
||||
@Overwrite
|
||||
public float getMaxU() {
|
||||
return this.icons[newN.get()].getMaxU();
|
||||
}
|
||||
|
||||
/**
|
||||
* @author Cleptomania
|
||||
* @reason Supper thread-safety for connected textures
|
||||
*/
|
||||
@Overwrite
|
||||
public float getMinV() {
|
||||
return this.icons[newN.get()].getMinV();
|
||||
}
|
||||
|
||||
/**
|
||||
* @author Cleptomania
|
||||
* @reason Supper thread-safety for connected textures
|
||||
*/
|
||||
@Overwrite
|
||||
public float getMaxV() {
|
||||
return this.icons[newN.get()].getMaxV();
|
||||
}
|
||||
|
||||
/**
|
||||
* @author Cleptomania
|
||||
* @reason Supper thread-safety for connected textures
|
||||
*/
|
||||
@Overwrite
|
||||
public String getIconName() {
|
||||
return this.icons[newN.get()].getIconName();
|
||||
}
|
||||
|
||||
/**
|
||||
* @author Cleptomania
|
||||
* @reason Supper thread-safety for connected textures
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Overwrite
|
||||
public int getIconWidth() {
|
||||
return this.icons[newN.get()].getIconWidth();
|
||||
}
|
||||
|
||||
/**
|
||||
* @author Cleptomania
|
||||
* @reason Supper thread-safety for connected textures
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Overwrite
|
||||
public int getIconHeight() {
|
||||
return this.icons[newN.get()].getIconHeight();
|
||||
}
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
package com.gtnewhorizons.angelica.mixins.late.client.extrautils;
|
||||
|
||||
import com.rwtema.extrautils.block.render.FakeRenderBlocks;
|
||||
import com.rwtema.extrautils.block.render.RenderBlockConnectedTextures;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
|
||||
@Mixin(RenderBlockConnectedTextures.class)
|
||||
public class MixinRenderBlockConnectedTextures {
|
||||
|
||||
@Unique
|
||||
private FakeRenderBlocks newFakeRender = new FakeRenderBlocks();
|
||||
|
||||
/**
|
||||
* @author Cleptomania
|
||||
* @reason Thread safety compat (don't use static FakeRenderBlocks anymore)
|
||||
*/
|
||||
@Overwrite(remap = false)
|
||||
public FakeRenderBlocks getFakeRender() {
|
||||
return newFakeRender;
|
||||
}
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
package com.gtnewhorizons.angelica.mixins.late.client.extrautils;
|
||||
|
||||
import com.rwtema.extrautils.block.render.FakeRenderBlocks;
|
||||
import com.rwtema.extrautils.block.render.FakeRenderEtherealBlocks;
|
||||
import com.rwtema.extrautils.block.render.RenderBlockConnectedTextures;
|
||||
import com.rwtema.extrautils.block.render.RenderBlockConnectedTexturesEthereal;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
|
||||
@Mixin(RenderBlockConnectedTexturesEthereal.class)
|
||||
public abstract class MixinRenderBlockConnectedTexturesEthereal extends RenderBlockConnectedTextures{
|
||||
|
||||
@Unique
|
||||
private FakeRenderEtherealBlocks newFakeRenderEthereal = new FakeRenderEtherealBlocks();
|
||||
|
||||
/**
|
||||
* @author Cleptomania
|
||||
* @reason Thread safety fixes for ethereal connected textures. The way the subclassing
|
||||
* works for this system means overwriting this function to use our new non-static
|
||||
* FakeRenderEtherealBlocks field is about the only way to do it.
|
||||
*/
|
||||
@Overwrite(remap = false)
|
||||
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
|
||||
if (renderer.hasOverrideBlockTexture())
|
||||
return renderer.renderStandardBlock(block, x, y, z);
|
||||
getFakeRender().setWorld(renderer.blockAccess);
|
||||
getFakeRender().curBlock = world.getBlock(x, y, z);
|
||||
getFakeRender().curMeta = world.getBlockMetadata(x, y, z);
|
||||
block.setBlockBoundsBasedOnState(getFakeRender().blockAccess, x, y, z);
|
||||
getFakeRender().setRenderBoundsFromBlock(block);
|
||||
boolean render = getFakeRender().renderStandardBlock(block, x, y, z);
|
||||
newFakeRenderEthereal.setWorld(renderer.blockAccess);
|
||||
newFakeRenderEthereal.curBlock = fakeRender.curBlock;
|
||||
newFakeRenderEthereal.curMeta = fakeRender.curMeta;
|
||||
double h = 0.05D;
|
||||
newFakeRenderEthereal.setRenderBounds(h, h, h, 1.0D - h, 1.0D - h, 1.0D - h);
|
||||
render &= newFakeRenderEthereal.renderStandardBlock(block, x, y, z);
|
||||
return render;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.gtnewhorizons.angelica.transform.compat;
|
||||
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import com.gtnewhorizons.angelica.loading.AngelicaTweaker;
|
||||
import cpw.mods.fml.relauncher.FMLLaunchHandler;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public enum CompatASMTransformers {
|
||||
|
||||
EXTRA_UTILITIES_ISBRH("RenderBlockColor Transformer", () -> AngelicaConfig.fixExtraUtilsSodiumCompat, Side.CLIENT,
|
||||
"com.gtnewhorizons.angelica.transform.compat.ExtraUtilsTransformer"
|
||||
);
|
||||
|
||||
private final Supplier<Boolean> applyIf;
|
||||
private final Side side;
|
||||
private final String[] transformerClasses;
|
||||
|
||||
CompatASMTransformers(String description, Supplier<Boolean> applyIf, Side side, String... transformers) {
|
||||
this.applyIf = applyIf;
|
||||
this.side = side;
|
||||
this.transformerClasses = transformers;
|
||||
}
|
||||
|
||||
private boolean shouldBeLoaded() { return applyIf.get() && shouldLoadSide(); }
|
||||
|
||||
private boolean shouldLoadSide() {
|
||||
return side == Side.BOTH || (side == Side.SERVER && FMLLaunchHandler.side()
|
||||
.isServer())
|
||||
|| (side == Side.CLIENT && FMLLaunchHandler.side()
|
||||
.isClient());
|
||||
}
|
||||
|
||||
public static List<String> getTransformers() {
|
||||
final List<String> list = new ArrayList<>();
|
||||
for (CompatASMTransformers transformer : values()) {
|
||||
if (transformer.shouldBeLoaded()) {
|
||||
AngelicaTweaker.LOGGER.info("Loading transformer {}", (Object[]) transformer.transformerClasses);
|
||||
list.addAll(Arrays.asList(transformer.transformerClasses));
|
||||
} else {
|
||||
AngelicaTweaker.LOGGER.info("Not loading transformer {}", (Object[]) transformer.transformerClasses);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private enum Side {
|
||||
BOTH,
|
||||
CLIENT,
|
||||
SERVER
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.gtnewhorizons.angelica.transform.compat;
|
||||
|
||||
import com.gtnewhorizons.angelica.loading.AngelicaTweaker;
|
||||
import com.gtnewhorizons.angelica.transform.ClassConstantPoolParser;
|
||||
import net.minecraft.launchwrapper.IClassTransformer;
|
||||
import org.objectweb.asm.ClassReader;
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
import org.objectweb.asm.tree.AnnotationNode;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ExtraUtilsTransformer implements IClassTransformer {
|
||||
|
||||
private static final String RenderBlockColor = "com.rwtema.extrautils.block.render.RenderBlockColor";
|
||||
private static final String RenderBlockConnectedTextures = "com.rwtema.extrautils.block.render.RenderBlockConnectedTextures";
|
||||
private static final String RenderBlockConnectedTexturesEthereal = "com.rwtema.extrautils.block.render.RenderBlockConnectedTexturesEthereal";
|
||||
private static final String RenderBlockFullBright = "com.rwtema.extrautils.block.render.RenderBlockFullBright";
|
||||
private static final String RenderBlockSpike = "com.rwtema.extrautils.block.render.RenderBlockSpike";
|
||||
|
||||
private static final List<String> transformedClasses = Arrays.asList(RenderBlockColor, RenderBlockConnectedTextures, RenderBlockConnectedTexturesEthereal, RenderBlockFullBright, RenderBlockSpike);
|
||||
|
||||
private static final Map<String, Boolean> perThreadMap = new HashMap<>();
|
||||
|
||||
static {
|
||||
perThreadMap.put(RenderBlockColor, false);
|
||||
perThreadMap.put(RenderBlockConnectedTextures, true);
|
||||
perThreadMap.put(RenderBlockConnectedTexturesEthereal, true);
|
||||
perThreadMap.put(RenderBlockFullBright, false);
|
||||
perThreadMap.put(RenderBlockSpike, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] transform(final String className, String transformedName, byte[] basicClass) {
|
||||
if (basicClass == null) return null;
|
||||
|
||||
if (!transformedClasses.contains(transformedName)) {
|
||||
return basicClass;
|
||||
}
|
||||
|
||||
AngelicaTweaker.LOGGER.info("Adding ThreadSafeISBRH for Extra Utilities to: {}", transformedName);
|
||||
|
||||
final ClassReader cr = new ClassReader(basicClass);
|
||||
final ClassNode cn = new ClassNode();
|
||||
cr.accept(cn, 0);
|
||||
|
||||
addThreadSafeISBRHAnnotation(transformedName, cn);
|
||||
|
||||
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
|
||||
cn.accept(cw);
|
||||
return cw.toByteArray();
|
||||
}
|
||||
|
||||
public void addThreadSafeISBRHAnnotation(String transformedName, ClassNode cn) {
|
||||
|
||||
AnnotationNode isbrhAnnotation = new AnnotationNode("Lcom/gtnewhorizons/angelica/api/ThreadSafeISBRH;");
|
||||
|
||||
Boolean perThread = perThreadMap.get(transformedName);
|
||||
if (perThread == null) {
|
||||
perThread = false;
|
||||
AngelicaTweaker.LOGGER.info("Tried to add ThreadSafeISBRH annotation to {} which is missing from perThreadMap. Using false for perThread.", transformedName);
|
||||
}
|
||||
isbrhAnnotation.values = Arrays.asList("perThread", perThread);
|
||||
|
||||
if (cn.visibleAnnotations == null) {
|
||||
cn.visibleAnnotations = new ArrayList<>();
|
||||
}
|
||||
cn.visibleAnnotations.add(isbrhAnnotation);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user