mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-02-12 16:14:24 +01:00
Fix baubles support. I blame Forge (specifically CPW) for breaking lazy classloading. This would never have happened with LiteLoader.
This commit is contained in:
parent
466053be4e
commit
ee64143a6a
3 changed files with 38 additions and 12 deletions
|
@ -1,5 +1,6 @@
|
||||||
package com.minelittlepony.unicopia.extern;
|
package com.minelittlepony.unicopia.extern;
|
||||||
|
|
||||||
|
import com.minelittlepony.unicopia.Unicopia;
|
||||||
import com.minelittlepony.unicopia.item.ItemAlicornAmulet;
|
import com.minelittlepony.unicopia.item.ItemAlicornAmulet;
|
||||||
|
|
||||||
import baubles.api.BaubleType;
|
import baubles.api.BaubleType;
|
||||||
|
@ -16,7 +17,11 @@ import net.minecraft.util.EnumActionResult;
|
||||||
import net.minecraft.util.EnumHand;
|
import net.minecraft.util.EnumHand;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
public class BaubleAlicornAmulet extends ItemAlicornAmulet implements IBauble {
|
class BaubleAlicornAmulet extends ItemAlicornAmulet implements IBauble {
|
||||||
|
|
||||||
|
static {
|
||||||
|
Unicopia.log.warn("Loaded BaubleAlicornAmulet.class If this is called, baubles must be present. Otherwise the game has probably already crashed...");
|
||||||
|
}
|
||||||
|
|
||||||
public BaubleAlicornAmulet(String domain, String name) {
|
public BaubleAlicornAmulet(String domain, String name) {
|
||||||
super(domain, name);
|
super(domain, name);
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package com.minelittlepony.unicopia.extern;
|
package com.minelittlepony.unicopia.extern;
|
||||||
|
|
||||||
|
import com.minelittlepony.unicopia.Unicopia;
|
||||||
|
import com.minelittlepony.unicopia.forgebullshit.FUF;
|
||||||
import com.minelittlepony.unicopia.item.ItemAlicornAmulet;
|
import com.minelittlepony.unicopia.item.ItemAlicornAmulet;
|
||||||
|
|
||||||
import baubles.api.BaubleType;
|
|
||||||
import baubles.api.BaublesApi;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
|
|
||||||
|
@ -12,30 +12,49 @@ public class Baubles {
|
||||||
private static boolean checkComplete;
|
private static boolean checkComplete;
|
||||||
private static boolean modIsActive;
|
private static boolean modIsActive;
|
||||||
|
|
||||||
static boolean isModActive() {
|
@FUF(reason = "Forge is so strict with their class loading it's a ff**8 joke")
|
||||||
|
public static boolean isModActive() {
|
||||||
if (!checkComplete) {
|
if (!checkComplete) {
|
||||||
checkComplete = true;
|
checkComplete = true;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
modIsActive = BaubleType.AMULET.getValidSlots().length > 0;
|
modIsActive = baubles.api.BaubleType.AMULET.getValidSlots().length > 0;
|
||||||
} catch (Exception e) {
|
} catch (Throwable e) {
|
||||||
|
Unicopia.log.error("Baubles are not present. Continuing without them.");
|
||||||
|
|
||||||
modIsActive = false;
|
modIsActive = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (modIsActive) {
|
||||||
|
Unicopia.log.debug("Baubles detected. baubles.api.BaubleType.AMULET.getValidSlots().length > 0 is true.");
|
||||||
|
}
|
||||||
|
|
||||||
return modIsActive;
|
return modIsActive;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ItemAlicornAmulet alicornAmulet(String domain, String name) {
|
public static ItemAlicornAmulet alicornAmulet() {
|
||||||
if (isModActive()) {
|
try {
|
||||||
return new BaubleAlicornAmulet(domain, name);
|
if (isModActive()) {
|
||||||
|
Unicopia.log.debug("Constructing BaubleAlicornAmulet.");
|
||||||
|
|
||||||
|
// FUCK YOU FORGE YOU PIECE OF SHIT
|
||||||
|
// DON'T LOAD THIS GOD DAMN CLASS UNTIL I FUCKING TELL YOU TO
|
||||||
|
|
||||||
|
Class<?> cls = ClassLoader.getSystemClassLoader().loadClass("com.minelittlepony.unicopia.extern.BaubleAlicornAmulet");
|
||||||
|
|
||||||
|
return (ItemAlicornAmulet)cls.getConstructor(String.class, String.class).newInstance(Unicopia.MODID, "alicorn_amulet");
|
||||||
|
}
|
||||||
|
} catch (Throwable e) {
|
||||||
|
Unicopia.log.error("Unicopia-Baubles support failed to load.", e);
|
||||||
}
|
}
|
||||||
return new ItemAlicornAmulet(domain, name);
|
|
||||||
|
return new ItemAlicornAmulet(Unicopia.MODID, "alicorn_amulet");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int isBaubleEquipped(EntityPlayer player, Item bauble) {
|
public static int isBaubleEquipped(EntityPlayer player, Item bauble) {
|
||||||
if (isModActive()) {
|
if (isModActive()) {
|
||||||
return BaublesApi.isBaubleEquipped(player, bauble);
|
return baubles.api.BaublesApi.isBaubleEquipped(player, bauble);
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -141,7 +141,8 @@ public class UItems {
|
||||||
public static final ItemSpell curse = new ItemCurse(Unicopia.MODID, "corrupted_gem");
|
public static final ItemSpell curse = new ItemCurse(Unicopia.MODID, "corrupted_gem");
|
||||||
|
|
||||||
public static final ItemOfHolding bag_of_holding = new ItemOfHolding(Unicopia.MODID, "bag_of_holding");
|
public static final ItemOfHolding bag_of_holding = new ItemOfHolding(Unicopia.MODID, "bag_of_holding");
|
||||||
public static final ItemAlicornAmulet alicorn_amulet = Baubles.alicornAmulet(Unicopia.MODID, "alicorn_amulet");
|
public static final ItemAlicornAmulet alicorn_amulet = Baubles.isModActive()
|
||||||
|
? Baubles.alicornAmulet() : new ItemAlicornAmulet(Unicopia.MODID, "alicorn_amulet");
|
||||||
|
|
||||||
public static final ItemSpellbook spellbook = new ItemSpellbook(Unicopia.MODID, "spellbook");
|
public static final ItemSpellbook spellbook = new ItemSpellbook(Unicopia.MODID, "spellbook");
|
||||||
public static final Item staff_meadow_brook = new ItemStaff(Unicopia.MODID, "staff_meadow_brook").setMaxDamage(2);
|
public static final Item staff_meadow_brook = new ItemStaff(Unicopia.MODID, "staff_meadow_brook").setMaxDamage(2);
|
||||||
|
@ -231,6 +232,7 @@ public class UItems {
|
||||||
.setUseAction(EnumAction.DRINK)
|
.setUseAction(EnumAction.DRINK)
|
||||||
.setContainerItem(Items.GLASS_BOTTLE);
|
.setContainerItem(Items.GLASS_BOTTLE);
|
||||||
|
|
||||||
|
|
||||||
static void init(IForgeRegistry<Item> registry) {
|
static void init(IForgeRegistry<Item> registry) {
|
||||||
RegistryLockSpinner.open(Item.REGISTRY, Items.class, r -> r
|
RegistryLockSpinner.open(Item.REGISTRY, Items.class, r -> r
|
||||||
.replace(Items.APPLE, red_apple)
|
.replace(Items.APPLE, red_apple)
|
||||||
|
|
Loading…
Reference in a new issue