Compare commits

..
9 changed files with 54 additions and 41 deletions

No files matched your search

@@ -15,8 +15,13 @@ import cpw.mods.fml.common.event.FMLPreInitializationEvent;
modid = "angelica",
name = "Angelica",
version = Tags.VERSION,
dependencies = " before:lwjgl3ify@[1.5.3,);" + " after:hodgepodge@[2.4.4,);" + " after:CodeChickenCore@[1.2.0,);"
+ " after:archaicfix@[0.7.0,);" + " required-after:gtnhlib@[0.6.6,);",
dependencies = """
required-after:gtnhlib@[0.6.6,);\
before:lwjgl3ify@[1.5.3,);\
after:hodgepodge@[2.4.4,);\
after:CodeChickenCore@[1.2.0,);\
after:archaicfix@[0.7.0,);\
""",
acceptedMinecraftVersions = "[1.7.10]",
acceptableRemoteVersions = "*",
guiFactory = "com.gtnewhorizons.angelica.config.AngelicaGuiConfigFactory")
@@ -1,7 +1,6 @@
package com.gtnewhorizons.angelica.compat;
import com.gtnewhorizons.angelica.compat.backhand.BackhandReflectionCompat;
import com.gtnewhorizons.angelica.compat.holoinventory.HoloInventoryReflectionCompat;
import com.gtnewhorizons.angelica.helpers.LoadControllerHelper;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.versioning.DefaultArtifactVersion;
@@ -53,9 +52,7 @@ public class ModStatus {
isThaumicHorizonsLoaded = Loader.isModLoaded("ThaumicHorizons");
isBaublesLoaded = Loader.isModLoaded("Baubles");
if (isHoloInventoryLoaded) {
isHoloInventoryLoaded = HoloInventoryReflectionCompat.isHoloInventoryLoaded();
}
isHoloInventoryLoaded = Loader.isModLoaded("holoinventory");
// remove compat with original release of BG2
if (isBattlegearLoaded){
@@ -0,0 +1,15 @@
package com.gtnewhorizons.angelica.compat.battlegear2;
import mods.battlegear2.api.core.IInventoryPlayerBattle;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
/**
* This class exists to isolate classes that exist in Battlegear 2 but not
* in Battlegear 2 for Backhand in order to avoid class loading exceptions.
*/
public class Battlegear2Compat {
public static ItemStack getBattlegear2Offhand(EntityPlayer player) {
return ((IInventoryPlayerBattle) player.inventory).battlegear2$getCurrentOffhandWeapon();
}
}
@@ -67,10 +67,6 @@ public class HoloInventoryReflectionCompat {
angelicaOverrideSetter = angelicaOverrideSetterTemp;
}
public static boolean isHoloInventoryLoaded() {
return isLoaded;
}
public static void renderEvent(RenderGameOverlayEvent event) {
if (!isLoaded) return;
try {
@@ -6,12 +6,12 @@ import com.gtnewhorizon.gtnhlib.blockpos.IBlockPos;
import com.gtnewhorizon.gtnhlib.util.CoordinatePacker;
import com.gtnewhorizons.angelica.api.IDynamicLightProducer;
import com.gtnewhorizons.angelica.compat.ModStatus;
import com.gtnewhorizons.angelica.compat.battlegear2.Battlegear2Compat;
import com.gtnewhorizons.angelica.config.AngelicaConfig;
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
import me.jellysquid.mods.sodium.client.render.SodiumWorldRenderer;
import mods.battlegear2.api.core.IBattlePlayer;
import mods.battlegear2.api.core.IInventoryPlayerBattle;
import net.irisshaders.iris.api.v0.IrisApi;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
@@ -376,7 +376,7 @@ public class DynamicLights {
player instanceof IBattlePlayer battlePlayer &&
battlePlayer.battlegear2$isBattlemode()
) {
ItemStack offhand = ((IInventoryPlayerBattle) player.inventory).battlegear2$getCurrentOffhandWeapon();
ItemStack offhand = Battlegear2Compat.getBattlegear2Offhand(player);
if (offhand != null) {
luminance = Math.max(luminance, getLuminanceFromItemStack(offhand, inWater));
}
@@ -86,7 +86,7 @@ public enum Mixins {
// Not compatible with the lwjgl debug callbacks, so disable if that's enabled
ARCHAIC_SPLASH(new Builder("ArchaicFix Splash").addTargetedMod(TargetedMod.VANILLA).setSide(Side.CLIENT)
.setPhase(Phase.EARLY).setApplyIf(() -> AngelicaConfig.showSplashMemoryBar && !AngelicaMod.lwjglDebug).addMixinClasses(
"angelica.archaic.MixinSplashProgress"
"angelica.archaic.MixinSplashProgress$3"
,"angelica.archaic.AccessorSplashProgress"
)
),
@@ -68,4 +68,6 @@ public net.minecraft.client.renderer.EntityRenderer field_78510_Z #renderEndNano
public net.minecraft.client.multiplayer.PlayerControllerMP field_78779_k #currentGameType
public net.minecraft.world.World field_72993_I # activeChunkSet
public net.minecraft.world.World field_72993_I # activeChunkSet
public cpw.mods.fml.client.SplashProgress$SplashFontRenderer
@@ -1,6 +1,8 @@
package com.gtnewhorizons.angelica.mixins.early.angelica.archaic;
import cpw.mods.fml.client.SplashProgress;
import cpw.mods.fml.client.SplashProgress.SplashFontRenderer;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
@@ -12,12 +14,19 @@ public interface AccessorSplashProgress {
static int getBarBorderColor() {
throw new AssertionError();
}
@Accessor(remap = false)
static int getBarBackgroundColor() {
throw new AssertionError();
}
@Accessor(remap = false)
static int getFontColor() {
throw new AssertionError();
}
@Accessor(remap = false)
static SplashFontRenderer getFontRenderer() {
throw new AssertionError();
}
}
@@ -5,9 +5,9 @@ package com.gtnewhorizons.angelica.mixins.early.angelica.archaic;
import com.gtnewhorizons.angelica.Tags;
import com.gtnewhorizons.angelica.config.AngelicaConfig;
import com.gtnewhorizons.angelica.loading.AngelicaTweaker;
import cpw.mods.fml.client.SplashProgress;
import net.minecraft.client.gui.FontRenderer;
import cpw.mods.fml.client.SplashProgress.SplashFontRenderer;
import org.apache.commons.lang3.StringUtils;
import org.lwjgl.opengl.Display;
import org.spongepowered.asm.mixin.Final;
@@ -18,8 +18,6 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.lang.reflect.Field;
import static org.lwjgl.opengl.GL11.GL_TEXTURE_2D;
import static org.lwjgl.opengl.GL11.glDisable;
import static org.lwjgl.opengl.GL11.glEnable;
@@ -30,29 +28,19 @@ import static org.lwjgl.opengl.GL11.glTranslatef;
@SuppressWarnings("deprecation")
@Mixin(targets = { "cpw/mods/fml/client/SplashProgress$3" })
public class MixinSplashProgress {
private static final int memoryGoodColor = 0x78CB34;
private static final int memoryWarnColor = 0xE6E84A;
private static final int memoryLowColor = 0xE42F2F;
public class MixinSplashProgress$3 {
private static final int MEMORY_GOOD_COLOR = 0x78CB34;
private static final int MEMORY_WARN_COLOR = 0xE6E84A;
private static final int MEMORY_LOW_COLOR = 0xE42F2F;
private static float memoryColorPercent;
private static long memoryColorChangeTime;
private static FontRenderer fontRenderer = null;
@Unique
private static Boolean angelica$isArchaicFixPresent = null;
@Inject(method = "run", at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/GL11;glDisable(I)V", ordinal = 1, remap = false, shift = At.Shift.AFTER), remap = false, require = 0)
private void injectDrawMemoryBar(CallbackInfo ci) {
// NOTE: Disable this if you're checking for off thread GL calls via `-Dangelica.assertMainThread=true`
if(fontRenderer == null) {
try {
Field f = SplashProgress.class.getDeclaredField("fontRenderer");
f.setAccessible(true);
fontRenderer = (FontRenderer)f.get(null);
} catch(ReflectiveOperationException e) {
AngelicaTweaker.LOGGER.error(e);
return;
}
}
// This runs before Loader.isModLoaded() works
if (angelica$isArchaicFixPresent == null) {
try {
@@ -68,7 +56,7 @@ public class MixinSplashProgress {
glTranslatef(320 - Display.getWidth() / 2 + 4, 240 + Display.getHeight() / 2 - textHeight2, 0);
glScalef(2, 2, 1);
glEnable(GL_TEXTURE_2D);
fontRenderer.drawString("Angelica " + Tags.VERSION, 0, angelica$isArchaicFixPresent ? -10 : 0, 0x000000);
AccessorSplashProgress.getFontRenderer().drawString("Angelica " + Tags.VERSION, 0, angelica$isArchaicFixPresent ? -10 : 0, 0x000000);
glDisable(GL_TEXTURE_2D);
glPopMatrix();
if(AngelicaConfig.showSplashMemoryBar) {
@@ -95,6 +83,7 @@ public class MixinSplashProgress {
final int freeMemory = bytesToMb(Runtime.getRuntime().freeMemory());
final int usedMemory = totalMemory - freeMemory;
final float usedMemoryPercent = usedMemory / (float) maxMemory;
final SplashFontRenderer fontRenderer = AccessorSplashProgress.getFontRenderer();
glPushMatrix();
// title - message
@@ -123,13 +112,13 @@ public class MixinSplashProgress {
final int memoryBarColor;
if (memoryColorPercent < 0.75f) {
memoryBarColor = memoryGoodColor;
memoryBarColor = MEMORY_GOOD_COLOR;
} else if (memoryColorPercent < 0.85f) {
memoryBarColor = memoryWarnColor;
memoryBarColor = MEMORY_WARN_COLOR;
} else {
memoryBarColor = memoryLowColor;
memoryBarColor = MEMORY_LOW_COLOR;
}
setColor(memoryLowColor);
setColor(MEMORY_LOW_COLOR);
glPushMatrix();
glTranslatef((barWidth - 2) * (totalMemory) / (maxMemory) - 2, 0, 0);
drawBox(2, barHeight - 2);