Transfer ASM to Mixins (#41)

This commit is contained in:
Alexdoru authored and GitHub committed 2025-11-04 21:37:53 +01:00
1 parent eb35d92a6d
commit 0e8572ca64
27 files changed
+235 -777

No files matched your search

+5 -5
View File
@@ -3,14 +3,14 @@
dependencies {
api('thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev')
api('com.github.GTNewHorizons:Baubles:1.0.4:dev')
api("com.github.GTNewHorizons:GTNHLib:0.6.36:dev")
api("com.github.GTNewHorizons:GTNHLib:0.7.3:dev")
api('com.github.GTNewHorizons:ThaumicEnergistics:1.7.8-GTNH:dev')
api('com.github.GTNewHorizons:ThaumicEnergistics:1.7.14-GTNH:dev')
compileOnly('com.github.GTNewHorizons:waila:1.8.10:dev') { transitive = false }
compileOnly('com.github.GTNewHorizons:ThaumicHorizons:1.7.5:dev') { transitive = false }
compileOnly('com.github.GTNewHorizons:waila:1.9.7:dev') { transitive = false }
compileOnly('com.github.GTNewHorizons:ThaumicHorizons:1.8.4:dev') { transitive = false }
compileOnly('curse.maven:automagy-222153:2285272')
compileOnly('curse.maven:mystcraft-224599:2417044')
runtimeOnlyNonPublishable('com.github.GTNewHorizons:NotEnoughItems:2.7.60-GTNH:dev')
implementation('com.github.GTNewHorizons:NotEnoughItems:2.8.25-GTNH:dev')
}
+4 -2
View File
@@ -96,7 +96,9 @@ usesMixinDebug = true
# Specify the location of your implementation of IMixinConfigPlugin. Leave it empty otherwise.
mixinPlugin =
# Specify the package that contains all of your Mixins. You may only place Mixins in this package or the build will fail!
# Specify the package that contains all of your Mixins. The package must exist or
# the build will fail. If you have a package property defined in your mixins.<modid>.json,
# it must match with this or the build will fail.
mixinsPackage = mixins
# Specify the core mod entry class if you use a core mod. This class must implement IFMLLoadingPlugin!
@@ -151,7 +153,7 @@ modrinthProjectId =
# type can be one of [project, version],
# and the name is the Modrinth project or version slug/id of the other mod.
# Example: required-project:fplib;optional-project:gasstation;incompatible-project:gregtech
# Note: GTNH Mixins is automatically set as a required dependency if usesMixins = true
# Note: UniMixins is automatically set as a required dependency if usesMixins = true.
modrinthRelations =
# Publishing to CurseForge requires you to set the CURSEFORGE_TOKEN environment variable to one of your CurseForge API tokens.
+1 -1
View File
@@ -17,7 +17,7 @@ pluginManagement {
}
plugins {
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.38'
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.47'
}
@@ -16,7 +16,7 @@ import thaumcraft.common.entities.golems.EnumGolemType;
*/
public abstract class AdditionalGolemType {
private EnumGolemType enumEntry;
private final EnumGolemType enumEntry;
private Item placerItem;
private String modId;
@@ -29,8 +29,9 @@ public abstract class AdditionalGolemType {
public final int regenDelay;
public final int strength;
public AdditionalGolemType(int maxHealth, int armor, float movementSpeed, boolean fireResist, int upgradeAmount,
int carryLimit, int regenDelay, int strength) {
public AdditionalGolemType(EnumGolemType enumEntry, int maxHealth, int armor, float movementSpeed,
boolean fireResist, int upgradeAmount, int carryLimit, int regenDelay, int strength) {
this.enumEntry = enumEntry;
this.maxHealth = maxHealth;
this.armor = armor;
this.movementSpeed = movementSpeed;
@@ -74,11 +75,6 @@ public abstract class AdditionalGolemType {
return this.modId;
}
@Deprecated
public final void setEnumEntry(EnumGolemType enumEntry) {
this.enumEntry = enumEntry;
}
@Deprecated
public void setPlacerItem(Item placerItem) {
this.placerItem = placerItem;
@@ -198,11 +198,11 @@ public class RenderTileNodeBasic {
public static void renderTileEntityAt(TileEntity tile, double x, double y, double z, float partialTicks,
float size) {
// Gadomancy Added event hook
EventHandlerRedirect.preNodeRender(tile);
EventHandlerRedirect.preNodeRender();
if (!(tile instanceof INode)) {
// Gadomancy Added event hook
EventHandlerRedirect.postNodeRender(tile);
EventHandlerRedirect.postNodeRender();
return;
}
INode node = (INode) tile;
@@ -255,7 +255,7 @@ public class RenderTileNodeBasic {
((TileNode) tile).drainCollision = null;
// Gadomancy Added event hook
EventHandlerRedirect.postNodeRender(tile);
EventHandlerRedirect.postNodeRender();
return;
}
MovingObjectPosition drainCollision = ((TileNode) tile).drainCollision;
@@ -299,6 +299,6 @@ public class RenderTileNodeBasic {
}
// Gadomancy Added event hook
EventHandlerRedirect.postNodeRender(tile);
EventHandlerRedirect.postNodeRender();
}
}
@@ -23,7 +23,6 @@ import makeo.gadomancy.common.data.config.ModConfig;
import makeo.gadomancy.common.entities.golems.ItemAdditionalGolemPlacer;
import makeo.gadomancy.common.entities.golems.nbt.ExtendedGolemProperties;
import makeo.gadomancy.common.registration.RegisteredBlocks;
import makeo.gadomancy.common.utils.GolemEnumHelper;
import makeo.gadomancy.common.utils.NBTHelper;
import makeo.gadomancy.common.utils.StringHelper;
import thaumcraft.api.aspects.Aspect;
@@ -39,20 +38,17 @@ public class DefaultApiHandler implements IApiHandler {
private static final Logger log = LogManager.getLogger("Gadomancy_API");
private static Map<String, AdditionalGolemType> additionalGolemTypes = new HashMap<String, AdditionalGolemType>();
private static final Map<String, AdditionalGolemType> additionalGolemTypes = new HashMap<>();
@Override
public boolean registerAdditionalGolemType(String name, String modId, AdditionalGolemType newType) {
String uniqueName = name.toUpperCase();
if (!DefaultApiHandler.additionalGolemTypes.containsKey(uniqueName)) {
GolemEnumHelper.addGolemType(uniqueName, newType);
ItemAdditionalGolemPlacer placerItem = new ItemAdditionalGolemPlacer(newType);
GameRegistry
.registerItem(placerItem, "item" + StringHelper.firstToUpper(name.toLowerCase()) + "GolemPlacer");
newType.setModId(modId);
newType.setPlacerItem(placerItem);
DefaultApiHandler.additionalGolemTypes.put(uniqueName, newType);
return true;
}
@@ -8,6 +8,7 @@ import net.minecraft.util.ResourceLocation;
import makeo.gadomancy.api.golems.AdditionalGolemType;
import makeo.gadomancy.common.Gadomancy;
import makeo.gadomancy.common.utils.SimpleResourceLocation;
import thaumcraft.common.entities.golems.EnumGolemType;
/**
* This class is part of the Gadomancy Mod Gadomancy is Open Source and distributed under the GNU LESSER GENERAL PUBLIC
@@ -18,7 +19,7 @@ import makeo.gadomancy.common.utils.SimpleResourceLocation;
public class ObsidianGolemType extends AdditionalGolemType {
public ObsidianGolemType() {
super(50, 18, 0.27F, true, 2, 32, 100, 6);
super(EnumGolemType.valueOf("OBSIDIAN"), 50, 18, 0.27F, true, 2, 32, 100, 6);
}
@Override
@@ -1,48 +0,0 @@
package makeo.gadomancy.common.entities.golems.types;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.util.ResourceLocation;
import makeo.gadomancy.api.golems.AdditionalGolemType;
/**
* This class is part of the Gadomancy Mod Gadomancy is Open Source and distributed under the GNU LESSER GENERAL PUBLIC
* LICENSE for more read the LICENSE file
*
* Created by makeo @ 29.07.2015 00:15
*/
public class RemovedGolemType extends AdditionalGolemType {
public RemovedGolemType() {
super(0, 0, 0, false, 0, 0, 1000, 0);
}
@Override
public String getUnlocalizedName() {
return "";
}
private IIcon icon;
@Override
public void registerIcons(IIconRegister ir) {
this.icon = ir.registerIcon("");
}
@Override
public IIcon getIcon(ItemStack stack, int pass) {
return this.icon;
}
@Override
public ResourceLocation getEntityTexture() {
return new ResourceLocation("");
}
@Override
public ResourceLocation getInvSlotTexture() {
return new ResourceLocation("");
}
}
@@ -8,6 +8,7 @@ import net.minecraft.util.ResourceLocation;
import makeo.gadomancy.api.golems.AdditionalGolemType;
import makeo.gadomancy.common.Gadomancy;
import makeo.gadomancy.common.utils.SimpleResourceLocation;
import thaumcraft.common.entities.golems.EnumGolemType;
/**
* This class is part of the Gadomancy Mod Gadomancy is Open Source and distributed under the GNU LESSER GENERAL PUBLIC
@@ -18,7 +19,7 @@ import makeo.gadomancy.common.utils.SimpleResourceLocation;
public class SilverwoodGolemType extends AdditionalGolemType {
public SilverwoodGolemType() {
super(20, 9, 0.38f, false, 3, 8, 75, 1);
super(EnumGolemType.valueOf("SILVERWOOD"), 20, 9, 0.38f, false, 3, 8, 75, 1);
}
@Override
@@ -11,9 +11,7 @@ import makeo.gadomancy.common.data.DataFamiliar;
import makeo.gadomancy.common.data.SyncDataHolder;
import makeo.gadomancy.common.network.PacketHandler;
import makeo.gadomancy.common.network.packets.PacketSyncConfigs;
import makeo.gadomancy.common.network.packets.PacketUpdateGolemTypeOrder;
import makeo.gadomancy.common.network.packets.PacketUpdateOnlineState;
import makeo.gadomancy.common.utils.GolemEnumHelper;
import makeo.gadomancy.common.utils.world.TCMazeHandler;
/**
@@ -28,7 +26,6 @@ public class EventHandlerNetwork {
@SubscribeEvent
public void on(PlayerEvent.PlayerLoggedInEvent e) {
EntityPlayerMP p = (EntityPlayerMP) e.player;
PacketHandler.INSTANCE.sendTo(new PacketUpdateGolemTypeOrder(GolemEnumHelper.getCurrentMapping()), p);
PacketHandler.INSTANCE.sendTo(new PacketSyncConfigs(), p);
PacketHandler.INSTANCE
.sendTo(new PacketUpdateOnlineState(MinecraftServer.getServer().isServerInOnlineMode()), p);
@@ -1,23 +1,15 @@
package makeo.gadomancy.common.events;
import net.minecraft.client.Minecraft;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.server.MinecraftServer;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.client.event.DrawBlockHighlightEvent;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import makeo.gadomancy.common.registration.RegisteredEnchantments;
import makeo.gadomancy.common.registration.RegisteredPotions;
import makeo.gadomancy.common.utils.MiscUtils;
import thaumcraft.api.aspects.Aspect;
import thaumcraft.common.config.ConfigItems;
/**
@@ -29,7 +21,6 @@ import thaumcraft.common.config.ConfigItems;
public class EventHandlerRedirect {
private static final ItemStack ITEM_GOGGLES = new ItemStack(ConfigItems.itemGoggles);
private static boolean hasChanged;
private static ItemStack oldItem;
@@ -58,94 +49,13 @@ public class EventHandlerRedirect {
}
@SideOnly(Side.CLIENT)
public static void preNodeRender(TileEntity tile) {
public static void preNodeRender() {
EventHandlerRedirect.addGoggles(Minecraft.getMinecraft().renderViewEntity);
}
@SideOnly(Side.CLIENT)
public static void postNodeRender(TileEntity tile) {
public static void postNodeRender() {
EventHandlerRedirect.removeGoggles(Minecraft.getMinecraft().renderViewEntity);
}
public static void preBlockHighlight(DrawBlockHighlightEvent event) {
EventHandlerRedirect.addGoggles(event.player);
}
public static void postBlockHighlight(DrawBlockHighlightEvent event) {
EventHandlerRedirect.removeGoggles(event.player);
}
public static int getAdditionalVisDiscount(EntityPlayer player, Aspect aspect, int currentTotalDiscount) {
if (player.isPotionActive(RegisteredPotions.VIS_DISCOUNT)) {
currentTotalDiscount += (player.getActivePotionEffect(RegisteredPotions.VIS_DISCOUNT).getAmplifier() + 1)
* 8;
}
return currentTotalDiscount;
}
public static int getFortuneLevel(EntityLivingBase entity) {
int fortuneLevel = EventHandlerRedirect
.getRealEnchantmentLevel(Enchantment.fortune.effectId, entity.getHeldItem());
if (entity.isPotionActive(RegisteredPotions.POTION_LUCK)) {
int lvl = entity.getActivePotionEffect(RegisteredPotions.POTION_LUCK).getAmplifier() + 1; // Amplifier
// 0-indexed
fortuneLevel += lvl;
}
return fortuneLevel;
}
public static int getLootingLevel(EntityLivingBase entity) {
int lootingLevel = EventHandlerRedirect
.getRealEnchantmentLevel(Enchantment.looting.effectId, entity.getHeldItem());
if (entity.isPotionActive(RegisteredPotions.POTION_LUCK)) {
int lvl = entity.getActivePotionEffect(RegisteredPotions.POTION_LUCK).getAmplifier() + 1; // Amplifier
// 0-indexed
lootingLevel += lvl;
}
return lootingLevel;
}
public static int onGetEnchantmentLevel(int enchantmentId, ItemStack stack) {
EntityPlayer possiblePlayer = null;
if (stack != null) {
MinecraftServer server = MinecraftServer.getServer();
if (server != null && server.getConfigurationManager() != null) {
for (EntityPlayer player : server.getConfigurationManager().playerEntityList) {
if (player != null && player.getHeldItem() == stack) {
possiblePlayer = player;
break;
}
}
}
}
if (possiblePlayer != null) {
if (enchantmentId == Enchantment.fortune.effectId) {
return EventHandlerRedirect.getFortuneLevel(possiblePlayer);
} else if (enchantmentId == Enchantment.looting.effectId) {
return EventHandlerRedirect.getLootingLevel(possiblePlayer);
}
}
return EventHandlerRedirect.getRealEnchantmentLevel(enchantmentId, stack);
}
private static int getRealEnchantmentLevel(int enchantmentId, ItemStack stack) {
if (stack == null) {
return 0;
} else {
NBTTagList nbttaglist = stack.getEnchantmentTagList();
if (nbttaglist == null) {
return 0;
} else {
for (int j = 0; j < nbttaglist.tagCount(); ++j) {
short id = nbttaglist.getCompoundTagAt(j).getShort("id");
if (id == enchantmentId) {
return nbttaglist.getCompoundTagAt(j).getShort("lvl");
}
}
return 0;
}
}
}
}
@@ -39,7 +39,6 @@ import makeo.gadomancy.common.entities.EntityItemElement;
import makeo.gadomancy.common.items.ItemElement;
import makeo.gadomancy.common.registration.RegisteredBlocks;
import makeo.gadomancy.common.registration.RegisteredItems;
import makeo.gadomancy.common.utils.GolemEnumHelper;
import makeo.gadomancy.common.utils.ItemUtils;
import makeo.gadomancy.common.utils.MiscUtils;
import makeo.gadomancy.common.utils.NBTHelper;
@@ -161,10 +160,6 @@ public class EventHandlerWorld {
public void on(WorldEvent.Load e) {
if (!e.world.isRemote && e.world.provider.dimensionId == 0) {
Gadomancy.loadModData();
GolemEnumHelper.validateSavedMapping();
GolemEnumHelper.reorderEnum();
TCMazeHandler.init();
}
}
@@ -1,16 +1,10 @@
package makeo.gadomancy.common.integration;
import java.util.ArrayList;
import java.util.Iterator;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import makeo.gadomancy.common.items.ItemFakeGolemPlacer;
import codechicken.nei.api.API;
import makeo.gadomancy.common.registration.RegisteredBlocks;
import makeo.gadomancy.common.registration.RegisteredItems;
import makeo.gadomancy.common.utils.Injector;
/**
* This class is part of the Gadomancy Mod Gadomancy is Open Source and distributed under the GNU LESSER GENERAL PUBLIC
@@ -25,45 +19,16 @@ public class IntegrationNEI extends IntegrationMod {
return "NotEnoughItems";
}
private Injector nei;
@Override
protected void doInit() {
this.nei = new Injector("codechicken.nei.api.API");
this.hideItem(new ItemStack(RegisteredItems.itemFakeModIcon));
this.hideItem(new ItemStack(RegisteredBlocks.blockStickyJar, 1, Short.MAX_VALUE));
this.hideItem(new ItemStack(RegisteredItems.itemPackage, 1, Short.MAX_VALUE));
this.hideItem(new ItemStack(RegisteredItems.itemFakeLootbag, 1, Short.MAX_VALUE));
this.hideItem(new ItemStack(RegisteredBlocks.blockExtendedNodeJar, 1, Short.MAX_VALUE));
this.hideItem(new ItemStack(RegisteredItems.itemExtendedNodeJar, 1, Short.MAX_VALUE));
this.hideItem(new ItemStack(RegisteredItems.itemFakeGolemPlacer, 1, Short.MAX_VALUE)); // This does... nothing?
// ffs.
this.hideItem(new ItemStack(RegisteredItems.itemTransformationFocus, 1, Short.MAX_VALUE));
this.hideItem(new ItemStack(RegisteredItems.itemFamiliar_old, 1, Short.MAX_VALUE));
}
public static void checkItems(ArrayList items) {
Iterator iterator = items.iterator();
while (iterator.hasNext()) {
Object item = iterator.next();
if (item != null && item instanceof ItemStack
&& ((ItemStack) item).getItem() != null
&& ((ItemStack) item).getItem() instanceof ItemFakeGolemPlacer) {
iterator.remove();
}
}
}
private void hideItem(ItemStack item) {
this.nei.invokeMethod("hideItem", ItemStack.class, item);
}
public void setItemListEntries(Block block, Iterable<ItemStack> items) {
this.setItemListEntries(Item.getItemFromBlock(block), items);
}
public void setItemListEntries(Item item, Iterable<ItemStack> items) {
this.nei.invokeMethod("setItemListEntries", new Class[] { Item.class, Iterable.class }, item, items);
API.hideItem(new ItemStack(RegisteredItems.itemFakeModIcon));
API.hideItem(new ItemStack(RegisteredBlocks.blockStickyJar, 1, Short.MAX_VALUE));
API.hideItem(new ItemStack(RegisteredItems.itemPackage, 1, Short.MAX_VALUE));
API.hideItem(new ItemStack(RegisteredItems.itemFakeLootbag, 1, Short.MAX_VALUE));
API.hideItem(new ItemStack(RegisteredBlocks.blockExtendedNodeJar, 1, Short.MAX_VALUE));
API.hideItem(new ItemStack(RegisteredItems.itemExtendedNodeJar, 1, Short.MAX_VALUE));
API.hideItem(new ItemStack(RegisteredItems.itemFakeGolemPlacer, 1, Short.MAX_VALUE));
API.hideItem(new ItemStack(RegisteredItems.itemTransformationFocus, 1, Short.MAX_VALUE));
API.hideItem(new ItemStack(RegisteredItems.itemFamiliar_old, 1, Short.MAX_VALUE));
}
}
@@ -12,7 +12,6 @@ import makeo.gadomancy.common.network.packets.PacketSyncData;
import makeo.gadomancy.common.network.packets.PacketTCNodeBolt;
import makeo.gadomancy.common.network.packets.PacketTCNotificationText;
import makeo.gadomancy.common.network.packets.PacketTCWispyLine;
import makeo.gadomancy.common.network.packets.PacketUpdateGolemTypeOrder;
import makeo.gadomancy.common.network.packets.PacketUpdateOnlineState;
/**
@@ -30,8 +29,6 @@ public class PacketHandler {
int id = 0;
// Random stuff
PacketHandler.INSTANCE
.registerMessage(PacketUpdateGolemTypeOrder.class, PacketUpdateGolemTypeOrder.class, id++, Side.CLIENT);
PacketHandler.INSTANCE
.registerMessage(PacketStartAnimation.class, PacketStartAnimation.class, id++, Side.CLIENT);
PacketHandler.INSTANCE
@@ -1,69 +0,0 @@
package makeo.gadomancy.common.network.packets;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.util.Map;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import io.netty.buffer.ByteBuf;
import makeo.gadomancy.common.utils.GolemEnumHelper;
/**
* This class is part of the Gadomancy Mod Gadomancy is Open Source and distributed under the GNU LESSER GENERAL PUBLIC
* LICENSE for more read the LICENSE file
*
* Created by makeo @ 30.07.2015 18:07
*/
public class PacketUpdateGolemTypeOrder implements IMessage, IMessageHandler<PacketUpdateGolemTypeOrder, IMessage> {
private Map<String, Integer> mapping;
public PacketUpdateGolemTypeOrder() {}
public PacketUpdateGolemTypeOrder(Map<String, Integer> mapping) {
this.mapping = mapping;
}
@Override
public void fromBytes(ByteBuf buf) {
if (FMLCommonHandler.instance().getSide().isServer()) return;
byte[] data = new byte[buf.readInt()];
buf.readBytes(data);
ByteArrayInputStream in = new ByteArrayInputStream(data);
try {
this.mapping = (Map<String, Integer>) new ValidatingObjectInputStream(in).readObject();
in.close();
} catch (Exception ignored) {} // IOException | ClassNotFoundException ignored
}
@Override
public void toBytes(ByteBuf buf) {
ByteArrayOutputStream out = new ByteArrayOutputStream();
try {
new ObjectOutputStream(out).writeObject(this.mapping);
} catch (IOException ignored) {}
byte[] data = out.toByteArray();
buf.writeInt(data.length);
buf.writeBytes(data);
try {
out.close();
} catch (IOException ignored) {}
}
@Override
public IMessage onMessage(PacketUpdateGolemTypeOrder message, MessageContext ctx) {
if (message.mapping != null) {
GolemEnumHelper.reorderEnum(message.mapping);
}
return null;
}
}
@@ -1,227 +0,0 @@
package makeo.gadomancy.common.utils;
import java.lang.reflect.Field;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import net.minecraftforge.common.util.EnumHelper;
import cpw.mods.fml.relauncher.Side;
import makeo.gadomancy.api.GadomancyApi;
import makeo.gadomancy.api.golems.AdditionalGolemType;
import makeo.gadomancy.client.events.ResourceReloadListener;
import makeo.gadomancy.common.Gadomancy;
import makeo.gadomancy.common.entities.golems.types.RemovedGolemType;
import thaumcraft.common.entities.golems.EnumGolemType;
/**
* This class is part of the Gadomancy Mod Gadomancy is Open Source and distributed under the GNU LESSER GENERAL PUBLIC
* LICENSE for more read the LICENSE file
*
* Created by makeo @ 29.07.2015 01:07
*/
public class GolemEnumHelper {
private static final RemovedGolemType REMOVED_GOLEM_TYPE = new RemovedGolemType();
private static final Injector INJECTOR = new Injector(EnumGolemType.class);
private static final Injector ENUM_INJECTOR = new Injector(Enum.class);
private static final Injector CLASS_INJECTOR = new Injector(Class.class);
private static Field valuesField;
private static Field getValuesField() {
if (GolemEnumHelper.valuesField == null) {
for (Field field : EnumGolemType.class.getDeclaredFields()) {
if (field.getType().equals(EnumGolemType[].class)) {
field.setAccessible(true);
GolemEnumHelper.valuesField = field;
return field;
}
}
throw new IllegalStateException("Couldn't find the values$ field of EnumGolemType");
}
return GolemEnumHelper.valuesField;
}
private static final Class<?>[] ENUM_PARAMS = { String.class, int.class, int.class, int.class, float.class,
boolean.class, int.class, int.class, int.class, int.class };
private static Field ordinalField;
public static Field getOrdinalField() {
if (GolemEnumHelper.ordinalField == null) {
try {
GolemEnumHelper.ordinalField = Enum.class.getDeclaredField("ordinal");
} catch (NoSuchFieldException ignored) {}
}
return GolemEnumHelper.ordinalField;
}
private static EnumGolemType createEnum(String name, int ordinal, AdditionalGolemType type) {
resetEnumCache();
return INJECTOR.invokeUnsafeConstructor(
ENUM_PARAMS,
new Object[] { name, ordinal, type.maxHealth, type.armor, type.movementSpeed, type.fireResist,
type.upgradeAmount, type.carryLimit, type.regenDelay, type.strength });
}
private static void resetEnumCache() {
CLASS_INJECTOR.setObject(EnumGolemType.class);
try {
Field enumConstants = EnumGolemType.class.getClass().getDeclaredField("enumConstants");
CLASS_INJECTOR.setField(enumConstants, null);
} catch (Exception e) {
// no-op, worst case there is an outdated cache on new JVM versions
}
try {
Field enumConstantDirectory = EnumGolemType.class.getClass().getDeclaredField("enumConstantDirectory");
CLASS_INJECTOR.setField(enumConstantDirectory, null);
} catch (Exception e) {
// no-op, worst case there is an outdated cache on new JVM versions
}
}
private static void addEnum(int ordinal, EnumGolemType type) {
EnumGolemType[] values = GolemEnumHelper.resizeValues(ordinal + 1);
values[ordinal] = type;
resetEnumCache();
}
private static EnumGolemType addEnum(String name, int ordinal, AdditionalGolemType type) {
EnumGolemType enumEntry = GolemEnumHelper.createEnum(name, ordinal, type);
GolemEnumHelper.addEnum(ordinal, enumEntry);
type.setEnumEntry(enumEntry);
resetEnumCache();
return enumEntry;
}
private static EnumGolemType[] resizeValues(int size) {
EnumGolemType[] values = GolemEnumHelper.INJECTOR.getField(GolemEnumHelper.getValuesField());
if (size > values.length) {
EnumGolemType[] newValues = new EnumGolemType[size];
System.arraycopy(values, 0, newValues, 0, values.length);
for (int i = values.length; i < newValues.length; i++) {
newValues[i] = GolemEnumHelper.createEnum("REMOVED", i, GolemEnumHelper.REMOVED_GOLEM_TYPE);
}
GolemEnumHelper.setValues(newValues);
resetEnumCache();
return newValues;
}
return values;
}
private static void setValues(EnumGolemType[] values) {
try {
EnumHelper.setFailsafeFieldValue(GolemEnumHelper.getValuesField(), null, values);
resetEnumCache();
} catch (Exception ignored) {}
}
public static EnumGolemType addGolemType(String name, AdditionalGolemType type) {
return GolemEnumHelper.addEnum(name, GolemEnumHelper.getOrdinal(name), type);
}
private static int getOrdinal(String name) {
Map<String, Integer> map = GolemEnumHelper.getCurrentMapping();
if (map.containsKey(name)) {
return map.get(name);
}
int returnVal = -1;
int i = GolemEnumHelper.calcDefaultGolemCount();
do {
boolean contains = false;
for (Map.Entry<String, Integer> entry : map.entrySet()) {
if (entry.getValue() == i) {
contains = true;
}
}
if (!contains) {
returnVal = i;
}
i++;
} while (returnVal < 0);
map.put(name, returnVal);
GolemEnumHelper.saveCurrentMapping(map);
return returnVal;
}
public static void reorderEnum() {
GolemEnumHelper.reorderEnum(GolemEnumHelper.getCurrentMapping());
}
public static void reorderEnum(Map<String, Integer> mapping) {
EnumGolemType[] oldValues = EnumGolemType.values();
GolemEnumHelper.resetEnum();
for (Map.Entry<String, Integer> entry : mapping.entrySet()) {
for (EnumGolemType type : oldValues) {
if (type.name().equals(entry.getKey())) {
GolemEnumHelper.ENUM_INJECTOR.setObject(type);
GolemEnumHelper.ENUM_INJECTOR.setFieldInt(GolemEnumHelper.getOrdinalField(), entry.getValue());
GolemEnumHelper.addEnum(entry.getValue(), type);
}
}
}
new Injector(EnumGolemType.class).setField("codeToTypeMapping", null);
resetEnumCache();
if (Gadomancy.proxy.getSide() == Side.CLIENT) {
ResourceReloadListener.getInstance().reloadGolemResources();
}
}
private static void resetEnum() {
EnumGolemType[] newValues = Arrays
.copyOfRange(EnumGolemType.values(), 0, GolemEnumHelper.calcDefaultGolemCount());
GolemEnumHelper.setValues(newValues);
resetEnumCache();
}
private static int calcDefaultGolemCount() {
EnumGolemType[] values = EnumGolemType.values();
for (int i = 0; i < values.length; i++) {
if (GadomancyApi.isAdditionalGolemType(values[i])) {
return i;
}
}
return values.length;
}
public static void validateSavedMapping() {
if (GolemEnumHelper.hasCurrentMapping()) {
Map<String, Integer> mapping = GolemEnumHelper.getCurrentMapping();
for (Map.Entry<String, Integer> entry : GolemEnumHelper.defaultMapping.entrySet()) {
if (!mapping.containsKey(entry.getKey())) {
mapping.put(entry.getKey(), GolemEnumHelper.getOrdinal(entry.getKey()));
}
}
}
}
private static Map<String, Integer> defaultMapping = new HashMap<>();
public static Map<String, Integer> getCurrentMapping() {
if (GolemEnumHelper.hasCurrentMapping()) {
return Gadomancy.getModData().get("GolemTypeMapping", new HashMap<>());
} else if (Gadomancy.getModData() != null) {
Gadomancy.getModData().set("GolemTypeMapping", GolemEnumHelper.defaultMapping);
}
return GolemEnumHelper.defaultMapping;
}
public static boolean hasCurrentMapping() {
return Gadomancy.getModData() != null && Gadomancy.getModData().contains("GolemTypeMapping");
}
private static void saveCurrentMapping(Map<String, Integer> map) {
if (Gadomancy.getModData() != null) {
Gadomancy.getModData().set("GolemTypeMapping", map);
}
}
}
@@ -6,8 +6,6 @@ import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.Arrays;
import com.google.common.base.Throwables;
import cpw.mods.fml.relauncher.ReflectionHelper;
import sun.misc.Unsafe;
@@ -97,17 +95,6 @@ public class Injector {
return null;
}
public <T> T invokeUnsafeConstructor(Class<?>[] paramTypes, Object... params) {
try {
final Method constructor = this.clazz.getMethod("gadomancyRawCreate", paramTypes);
Object created = constructor.invoke(null, params);
return (T) created;
} catch (Throwable e) {
Throwables.propagate(e);
}
throw new IllegalStateException();
}
public <T> T invokeMethod(String name, Object... params) {
return this.invokeMethod(name, this.extractClasses(params), params);
}
@@ -1,11 +1,13 @@
package makeo.gadomancy.coremod;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.gtnewhorizon.gtnhmixins.IEarlyMixinLoader;
import cpw.mods.fml.relauncher.IFMLCallHook;
import cpw.mods.fml.relauncher.IFMLLoadingPlugin;
import cpw.mods.fml.relauncher.IFMLLoadingPlugin.MCVersion;
import cpw.mods.fml.relauncher.IFMLLoadingPlugin.TransformerExclusions;
/**
* This class is part of the Gadomancy Mod Gadomancy is Open Source and distributed under the GNU LESSER GENERAL PUBLIC
@@ -13,14 +15,9 @@ import cpw.mods.fml.relauncher.IFMLLoadingPlugin.TransformerExclusions;
* <p/>
* Created by makeo @ 07.12.2015 21:17
*/
@TransformerExclusions("makeo.gadomancy.coremod")
@MCVersion("1.7.10")
public class GadomancyCore implements IFMLLoadingPlugin, IFMLCallHook {
@Override
public Void call() throws Exception {
return null;
}
@IFMLLoadingPlugin.MCVersion("1.7.10")
@IFMLLoadingPlugin.TransformerExclusions("makeo.gadomancy.coremod")
public class GadomancyCore implements IFMLLoadingPlugin, IEarlyMixinLoader {
@Override
public String[] getASMTransformerClass() {
@@ -42,6 +39,16 @@ public class GadomancyCore implements IFMLLoadingPlugin, IFMLCallHook {
@Override
public String getAccessTransformerClass() {
return "makeo.gadomancy.coremod.GadomancyTransformer";
return null;
}
@Override
public String getMixinConfig() {
return "mixins.gadomancy.early.json";
}
@Override
public List<String> getMixins(Set<String> loadedCoreMods) {
return Collections.singletonList("minecraft.MixinEnchantmentHelper");
}
}
@@ -1,12 +1,14 @@
package makeo.gadomancy.coremod;
import java.util.Collections;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import com.gtnewhorizon.gtnhmixins.ILateMixinLoader;
import com.gtnewhorizon.gtnhmixins.LateMixin;
import cpw.mods.fml.relauncher.FMLLaunchHandler;
@LateMixin
public class GadomancyLateMixins implements ILateMixinLoader {
@@ -17,12 +19,16 @@ public class GadomancyLateMixins implements ILateMixinLoader {
@Override
public List<String> getMixins(Set<String> loadedMods) {
final List<String> mixins = new ArrayList<>();
if (loadedMods.contains("Thaumcraft")) {
// Replaces Thaumcraft's blockAiry with more nodes
// Config for this mixin is in the mixin itself
// config is not loaded at apply time
return Collections.singletonList("thaumcraft.MixinConfigBlocks");
if (FMLLaunchHandler.side().isClient()) {
mixins.add("thaumcraft.MixinRenderEventHandler");
mixins.add("thaumcraft.MixinTileNodeRenderer");
mixins.add("thaumcraft.MixinWandManager");
}
mixins.add("thaumcraft.MixinConfigBlocks");
mixins.add("thaumcraft.MixinEnumGolemType");
}
return Collections.emptyList();
return mixins;
}
}
@@ -1,227 +0,0 @@
package makeo.gadomancy.coremod;
import java.io.IOException;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.tree.AbstractInsnNode;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.InsnList;
import org.objectweb.asm.tree.InsnNode;
import org.objectweb.asm.tree.MethodInsnNode;
import org.objectweb.asm.tree.MethodNode;
import org.objectweb.asm.tree.VarInsnNode;
import cpw.mods.fml.common.FMLLog;
import cpw.mods.fml.common.asm.transformers.AccessTransformer;
/**
* This class is part of the Gadomancy Mod Gadomancy is Open Source and distributed under the GNU LESSER GENERAL PUBLIC
* LICENSE for more read the LICENSE file
* <p/>
* Created by makeo @ 07.12.2015 21:48
*/
public class GadomancyTransformer extends AccessTransformer {
public static final String NAME_ENCHANTMENT_HELPER = "net.minecraft.enchantment.EnchantmentHelper";
public static final String NAME_WANDMANAGER = "thaumcraft.common.items.wands.WandManager";
public static final String NAME_NODE_RENDERER = "thaumcraft.client.renderers.tile.TileNodeRenderer";
public static final String NAME_RENDER_EVENT_HANDLER = "thaumcraft.client.lib.RenderEventHandler";
public static final String NAME_NEI_ITEMPANEL = "codechicken.nei.ItemPanel";
public static final String NAME_ENTITY_LIVING_BASE = "net.minecraft.entity.EntityLivingBase";
public static final String NAME_GOLEM_ENUM = "thaumcraft.common.entities.golems.EnumGolemType";
public GadomancyTransformer() throws IOException {}
@Override
public byte[] transform(String name, String transformedName, byte[] bytes) {
boolean needsTransform = transformedName.equalsIgnoreCase(GadomancyTransformer.NAME_ENCHANTMENT_HELPER)
|| transformedName.equalsIgnoreCase(GadomancyTransformer.NAME_WANDMANAGER)
|| transformedName.equalsIgnoreCase(GadomancyTransformer.NAME_NODE_RENDERER)
|| transformedName.equalsIgnoreCase(GadomancyTransformer.NAME_RENDER_EVENT_HANDLER)
|| transformedName.equals(GadomancyTransformer.NAME_NEI_ITEMPANEL)
|| transformedName.equalsIgnoreCase(GadomancyTransformer.NAME_ENTITY_LIVING_BASE)
|| transformedName.equalsIgnoreCase(GadomancyTransformer.NAME_GOLEM_ENUM);
if (!needsTransform) return super.transform(name, transformedName, bytes);
FMLLog.info("[GadomancyTransformer] Transforming " + name + ": " + transformedName);
ClassNode node = new ClassNode();
ClassReader reader = new ClassReader(bytes);
reader.accept(node, 0);
if (transformedName.equalsIgnoreCase(GadomancyTransformer.NAME_ENCHANTMENT_HELPER)) {
for (MethodNode mn : node.methods) {
if (mn.name.equals("getFortuneModifier") || mn.name.equals("func_77517_e")) {
mn.instructions = new InsnList();
mn.instructions.add(new VarInsnNode(Opcodes.ALOAD, 0));
mn.instructions.add(
new MethodInsnNode(
Opcodes.INVOKESTATIC,
"makeo/gadomancy/common/events/EventHandlerRedirect",
"getFortuneLevel",
"(Lnet/minecraft/entity/EntityLivingBase;)I",
false));
mn.instructions.add(new InsnNode(Opcodes.IRETURN));
} else if (mn.name.equals("getEnchantmentLevel") || mn.name.equals("func_77506_a")) {
mn.instructions = new InsnList();
mn.instructions.add(new VarInsnNode(Opcodes.ILOAD, 0));
mn.instructions.add(new VarInsnNode(Opcodes.ALOAD, 1));
mn.instructions.add(
new MethodInsnNode(
Opcodes.INVOKESTATIC,
"makeo/gadomancy/common/events/EventHandlerRedirect",
"onGetEnchantmentLevel",
"(ILnet/minecraft/item/ItemStack;)I",
false));
mn.instructions.add(new InsnNode(Opcodes.IRETURN));
}
}
} else if (transformedName.equalsIgnoreCase(GadomancyTransformer.NAME_WANDMANAGER)) {
for (MethodNode mn : node.methods) {
if (mn.name.equals("getTotalVisDiscount")) {
InsnList updateTotal = new InsnList();
updateTotal.add(new VarInsnNode(Opcodes.ALOAD, 0));
updateTotal.add(new VarInsnNode(Opcodes.ALOAD, 1));
updateTotal.add(new VarInsnNode(Opcodes.ILOAD, 2));
updateTotal.add(
new MethodInsnNode(
Opcodes.INVOKESTATIC,
"makeo/gadomancy/common/events/EventHandlerRedirect",
"getAdditionalVisDiscount",
"(Lnet/minecraft/entity/player/EntityPlayer;Lthaumcraft/api/aspects/Aspect;I)I",
false));
mn.instructions.insertBefore(mn.instructions.get(mn.instructions.size() - 5), updateTotal);
}
}
} else if (transformedName.equalsIgnoreCase(GadomancyTransformer.NAME_NODE_RENDERER)) {
for (MethodNode mn : node.methods) {
if (mn.name.equals("renderTileEntityAt")) {
InsnList setBefore = new InsnList();
setBefore.add(new VarInsnNode(Opcodes.ALOAD, 1));
setBefore.add(
new MethodInsnNode(
Opcodes.INVOKESTATIC,
"makeo/gadomancy/common/events/EventHandlerRedirect",
"preNodeRender",
"(Lnet/minecraft/tileentity/TileEntity;)V",
false));
mn.instructions.insertBefore(mn.instructions.get(0), setBefore);
AbstractInsnNode next = mn.instructions.get(0);
while (next != null) {
AbstractInsnNode insnNode = next;
next = insnNode.getNext();
if (insnNode.getOpcode() == Opcodes.RETURN) {
InsnList setAfter = new InsnList();
setAfter.add(new VarInsnNode(Opcodes.ALOAD, 1));
setAfter.add(
new MethodInsnNode(
Opcodes.INVOKESTATIC,
"makeo/gadomancy/common/events/EventHandlerRedirect",
"postNodeRender",
"(Lnet/minecraft/tileentity/TileEntity;)V",
false));
mn.instructions.insertBefore(insnNode, setAfter);
}
}
}
}
} else if (transformedName.equalsIgnoreCase(GadomancyTransformer.NAME_RENDER_EVENT_HANDLER)) {
for (MethodNode mn : node.methods) {
if (mn.name.equals("blockHighlight")) {
InsnList setBefore = new InsnList();
setBefore.add(new VarInsnNode(Opcodes.ALOAD, 1));
setBefore.add(
new MethodInsnNode(
Opcodes.INVOKESTATIC,
"makeo/gadomancy/common/events/EventHandlerRedirect",
"preBlockHighlight",
"(Lnet/minecraftforge/client/event/DrawBlockHighlightEvent;)V",
false));
mn.instructions.insertBefore(mn.instructions.get(0), setBefore);
AbstractInsnNode next = mn.instructions.get(0);
while (next != null) {
AbstractInsnNode insnNode = next;
next = insnNode.getNext();
if (insnNode.getOpcode() == Opcodes.RETURN) {
InsnList setAfter = new InsnList();
setAfter.add(new VarInsnNode(Opcodes.ALOAD, 1));
setAfter.add(
new MethodInsnNode(
Opcodes.INVOKESTATIC,
"makeo/gadomancy/common/events/EventHandlerRedirect",
"postBlockHighlight",
"(Lnet/minecraftforge/client/event/DrawBlockHighlightEvent;)V",
false));
mn.instructions.insertBefore(insnNode, setAfter);
}
}
}
}
} else if (transformedName.equalsIgnoreCase(GadomancyTransformer.NAME_NEI_ITEMPANEL)) {
for (MethodNode mn : node.methods) {
if (mn.name.equals("updateItemList")) {
InsnList newInstructions = new InsnList();
newInstructions.add(new VarInsnNode(Opcodes.ALOAD, 0));
newInstructions.add(
new MethodInsnNode(
Opcodes.INVOKESTATIC,
"makeo/gadomancy/common/integration/IntegrationNEI",
"checkItems",
"(Ljava/util/ArrayList;)V",
false));
newInstructions.add(mn.instructions);
mn.instructions = newInstructions;
}
}
} else if (transformedName.equalsIgnoreCase(GadomancyTransformer.NAME_GOLEM_ENUM)) {
// Create constructor accessor
final MethodVisitor methodVisitor = node.visitMethod(
Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC,
"gadomancyRawCreate",
"(Ljava/lang/String;IIIFZIIII)Lthaumcraft/common/entities/golems/EnumGolemType;",
null,
null);
methodVisitor.visitCode();
methodVisitor.visitTypeInsn(Opcodes.NEW, "thaumcraft/common/entities/golems/EnumGolemType");
methodVisitor.visitInsn(Opcodes.DUP);
methodVisitor.visitVarInsn(Opcodes.ALOAD, 0);
methodVisitor.visitVarInsn(Opcodes.ILOAD, 1);
methodVisitor.visitVarInsn(Opcodes.ILOAD, 2);
methodVisitor.visitVarInsn(Opcodes.ILOAD, 3);
methodVisitor.visitVarInsn(Opcodes.FLOAD, 4);
methodVisitor.visitVarInsn(Opcodes.ILOAD, 5);
methodVisitor.visitVarInsn(Opcodes.ILOAD, 6);
methodVisitor.visitVarInsn(Opcodes.ILOAD, 7);
methodVisitor.visitVarInsn(Opcodes.ILOAD, 8);
methodVisitor.visitVarInsn(Opcodes.ILOAD, 9);
methodVisitor.visitMethodInsn(
Opcodes.INVOKESPECIAL,
"thaumcraft/common/entities/golems/EnumGolemType",
"<init>",
"(Ljava/lang/String;IIIFZIIII)V",
false);
methodVisitor.visitInsn(Opcodes.ARETURN);
methodVisitor.visitMaxs(12, 10);
methodVisitor.visitEnd();
}
ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS);
node.accept(writer);
bytes = writer.toByteArray();
return super.transform(name, transformedName, bytes);
}
}
@@ -0,0 +1,24 @@
package makeo.gadomancy.mixins.early.minecraft;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.EntityLivingBase;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
import makeo.gadomancy.common.registration.RegisteredPotions;
@Mixin(EnchantmentHelper.class)
public class MixinEnchantmentHelper {
@ModifyReturnValue(method = { "getFortuneModifier", "getLootingModifier" }, at = @At("RETURN"))
private static int gadomancy$applyLuckPotion(int original, EntityLivingBase entity) {
if (entity.isPotionActive(RegisteredPotions.POTION_LUCK)) {
return original + (entity.getActivePotionEffect(RegisteredPotions.POTION_LUCK).getAmplifier() + 1);
}
return original;
}
}
@@ -15,6 +15,7 @@ public class MixinConfigBlocks {
@Redirect(method = "initializeBlocks", at = @At(value = "NEW", target = "()Lthaumcraft/common/blocks/BlockAiry;"))
private static BlockAiry gadomancy$replaceBlockAiry() {
// Replaces Thaumcraft's blockAiry with more nodes
return ModConfig.enableAdditionalNodeTypes ? new BlockNode() : new BlockAiry();
}
}
@@ -0,0 +1,62 @@
package makeo.gadomancy.mixins.late.thaumcraft;
import java.util.ArrayList;
import java.util.Arrays;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Mutable;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.gen.Invoker;
import thaumcraft.common.entities.golems.EnumGolemType;
@Mixin(EnumGolemType.class)
public class MixinEnumGolemType {
@Unique
private static final EnumGolemType SILVERWOOD_GOLEM = gadomancy$expandGolemEnum(
"SILVERWOOD",
20,
9,
0.38f,
false,
3,
8,
75,
1);
@Shadow(remap = false)
@Final
@Mutable
private static EnumGolemType[] $VALUES;
@Invoker(value = "<init>", remap = false)
private static EnumGolemType gadomancy$InitInvoker(String name, int ordinal, int health, int armor, float speed,
boolean fireResist, int upgrades, int carry, int regenDelay, int strength) {
throw new IllegalStateException("Mixin stub invoked");
}
@Unique
private static EnumGolemType gadomancy$expandGolemEnum(String name, int health, int armor, float speed,
boolean fireResist, int upgrades, int carry, int regenDelay, int strength) {
assert $VALUES != null;
ArrayList<EnumGolemType> values = new ArrayList<>(Arrays.asList($VALUES));
EnumGolemType golem = gadomancy$InitInvoker(
name,
values.get(values.size() - 1).ordinal() + 1,
health,
armor,
speed,
fireResist,
upgrades,
carry,
regenDelay,
strength);
values.add(golem);
$VALUES = values.toArray(new EnumGolemType[0]);
return golem;
}
}
@@ -0,0 +1,26 @@
package makeo.gadomancy.mixins.late.thaumcraft;
import net.minecraftforge.client.event.DrawBlockHighlightEvent;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import makeo.gadomancy.common.events.EventHandlerRedirect;
import thaumcraft.client.lib.RenderEventHandler;
@Mixin(value = RenderEventHandler.class, remap = false)
public class MixinRenderEventHandler {
@Inject(method = "blockHighlight", at = @At("HEAD"))
private void gadomancy$pre(DrawBlockHighlightEvent event, CallbackInfo ci) {
EventHandlerRedirect.addGoggles(event.player);
}
@Inject(method = "blockHighlight", at = @At("RETURN"))
private void gadomancy$post(DrawBlockHighlightEvent event, CallbackInfo ci) {
EventHandlerRedirect.removeGoggles(event.player);
}
}
@@ -0,0 +1,24 @@
package makeo.gadomancy.mixins.late.thaumcraft;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import makeo.gadomancy.common.events.EventHandlerRedirect;
import thaumcraft.client.renderers.tile.TileNodeRenderer;
@Mixin(value = TileNodeRenderer.class)
public class MixinTileNodeRenderer {
@Inject(method = "renderTileEntityAt", at = @At("HEAD"))
private void gadomancy$preRender(CallbackInfo ci) {
EventHandlerRedirect.preNodeRender();
}
@Inject(method = "renderTileEntityAt", at = @At("RETURN"))
private void gadomancy$postRender(CallbackInfo ci) {
EventHandlerRedirect.postNodeRender();
}
}
@@ -0,0 +1,24 @@
package makeo.gadomancy.mixins.late.thaumcraft;
import net.minecraft.entity.player.EntityPlayer;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
import makeo.gadomancy.common.registration.RegisteredPotions;
import thaumcraft.common.items.wands.WandManager;
@Mixin(WandManager.class)
public class MixinWandManager {
@ModifyReturnValue(method = "getTotalVisDiscount", at = @At(value = "RETURN", ordinal = 1), remap = false)
private static float gadomancy$modifyVisDiscount(float original, EntityPlayer player) {
if (player.isPotionActive(RegisteredPotions.VIS_DISCOUNT)) {
original += (player.getActivePotionEffect(RegisteredPotions.VIS_DISCOUNT).getAmplifier() + 1) * 0.08F;
}
return original;
}
}
@@ -0,0 +1,8 @@
{
"required": true,
"minVersion": "0.8.5-GTNH",
"package": "makeo.gadomancy.mixins.early",
"refmap": "mixins.gadomancy.refmap.json",
"target": "@env(DEFAULT)",
"compatibilityLevel": "JAVA_8"
}