mirror of
https://github.com/GTNewHorizons/Gadomancy.git
synced 2026-11-20 03:59:56 +00:00
- Hacky Hacky He He
This commit is contained in:
1 parent
ae0367a5bd
commit
aa96cd4db9
4 files changed
+46
-6
No files matched your search
@@ -10,6 +10,9 @@ import makeo.gadomancy.common.entities.EntityPermNoClipItem;
|
||||
import makeo.gadomancy.common.familiar.FamiliarAIController;
|
||||
import makeo.gadomancy.common.items.ItemAuraCore;
|
||||
import makeo.gadomancy.common.utils.world.TCMazeHandler;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.boss.IBossDisplayData;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -48,6 +51,10 @@ public class EventHandlerEntity {
|
||||
}
|
||||
}*/
|
||||
|
||||
public static int onGetFortuneLevel(EntityLivingBase entity) {
|
||||
return EnchantmentHelper.getEnchantmentLevel(Enchantment.fortune.effectId, entity.getHeldItem());
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void on(EnderTeleportEvent e) {
|
||||
if(!(e.entityLiving instanceof EntityPlayer) && !(e.entityLiving instanceof IBossDisplayData)) {
|
||||
|
||||
@@ -37,10 +37,10 @@ public abstract class PotionCustomTexture extends Potion {
|
||||
tes.startDrawingQuads();
|
||||
Color c = new Color(getLiquidColor());
|
||||
tes.setColorRGBA(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha());
|
||||
tes.addVertexWithUV(x + 6, y + 7, 0, 0, 0);
|
||||
tes.addVertexWithUV(x + 6, y + 7, 0, 0, 0);
|
||||
tes.addVertexWithUV(x + 6, y + 7 + 18, 0, 0, 1);
|
||||
tes.addVertexWithUV(x + 6 + 18, y + 7 + 18, 0, 1, 1);
|
||||
tes.addVertexWithUV(x + 6 + 18, y + 7, 0, 1, 0);
|
||||
tes.addVertexWithUV(x + 6 + 18, y + 7, 0, 1, 0);
|
||||
tes.draw();
|
||||
}
|
||||
|
||||
|
||||
@@ -40,12 +40,10 @@ public class GadomancyCore implements IFMLLoadingPlugin, IFMLCallHook {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectData(Map<String, Object> data) {
|
||||
|
||||
}
|
||||
public void injectData(Map<String, Object> data) {}
|
||||
|
||||
@Override
|
||||
public String getAccessTransformerClass() {
|
||||
return null;
|
||||
return "makeo.gadomancy.coremod.GadomancyTransformer";
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,18 @@ package makeo.gadomancy.coremod;
|
||||
|
||||
import cpw.mods.fml.common.asm.transformers.AccessTransformer;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import org.objectweb.asm.ClassReader;
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
import org.objectweb.asm.Type;
|
||||
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 java.io.IOException;
|
||||
|
||||
/**
|
||||
@@ -16,5 +28,28 @@ public class GadomancyTransformer extends AccessTransformer {
|
||||
public GadomancyTransformer() throws IOException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] transform(String name, String transformedName, byte[] bytes) {
|
||||
if(name.equalsIgnoreCase("net.minecraft.enchantment.EnchantmentHelper")) {
|
||||
ClassNode node = new ClassNode();
|
||||
ClassReader reader = new ClassReader(bytes);
|
||||
reader.accept(node, 0);
|
||||
|
||||
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/EventHandlerEntity",
|
||||
"onGetFortuneLevel", "(Lnet/minecraft/entity/EntityLivingBase;)I", false));
|
||||
mn.instructions.add(new InsnNode(Opcodes.IRETURN));
|
||||
}
|
||||
}
|
||||
|
||||
ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS);
|
||||
node.accept(writer);
|
||||
bytes = writer.toByteArray();
|
||||
}
|
||||
return super.transform(name, transformedName, bytes);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user