-
Notifications
You must be signed in to change notification settings - Fork 181
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b9202ac
commit 8320595
Showing
69 changed files
with
815 additions
and
860 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 46 additions & 46 deletions
92
src/main/java/gregtech/api/items/armor/ISpecialArmorLogic.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,46 @@ | ||
package gregtech.api.items.armor; | ||
|
||
import net.minecraft.entity.EntityLivingBase; | ||
import net.minecraft.entity.player.EntityPlayer; | ||
import net.minecraft.inventory.EntityEquipmentSlot; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.util.DamageSource; | ||
import net.minecraftforge.common.ISpecialArmor.ArmorProperties; | ||
|
||
import javax.annotation.Nonnull; | ||
|
||
/** | ||
* Armor logic that wraps {@link net.minecraftforge.common.ISpecialArmor} methods | ||
* to allow full control over damage absorption additionally to vanilla attribute values | ||
*/ | ||
public interface ISpecialArmorLogic extends IArmorLogic { | ||
|
||
/** | ||
* Retrieves the modifiers to be used when calculating armor damage. | ||
* | ||
* Armor will higher priority will have damage applied to them before | ||
* lower priority ones. If there are multiple pieces of armor with the | ||
* same priority, damage will be distributed between them based on there | ||
* absorption ratio. | ||
*/ | ||
ArmorProperties getProperties(EntityLivingBase player, @Nonnull ItemStack armor, DamageSource source, double damage, EntityEquipmentSlot equipmentSlot); | ||
|
||
/** | ||
* Get the displayed effective armor. | ||
* | ||
* @return The number of armor points for display, 2 per shield. | ||
*/ | ||
int getArmorDisplay(EntityPlayer player, @Nonnull ItemStack armor, int slot); | ||
|
||
/** | ||
* Simple check to see if the armor should interact with "Unblockable" damage | ||
* sources. A fair number of vanilla damage sources have this tag, such as | ||
* Anvils, Falling, Fire, and Magic. | ||
* | ||
* Returning true here means that the armor is able to meaningfully respond | ||
* to this damage source. Otherwise, no interaction is allowed. | ||
*/ | ||
default boolean handleUnblockableDamage(EntityLivingBase entity, @Nonnull ItemStack armor, DamageSource source, double damage, EntityEquipmentSlot equipmentSlot) { | ||
return false; | ||
} | ||
} | ||
package gregtech.api.items.armor; | ||
|
||
import net.minecraft.entity.EntityLivingBase; | ||
import net.minecraft.entity.player.EntityPlayer; | ||
import net.minecraft.inventory.EntityEquipmentSlot; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.util.DamageSource; | ||
import net.minecraftforge.common.ISpecialArmor.ArmorProperties; | ||
|
||
import javax.annotation.Nonnull; | ||
|
||
/** | ||
* Armor logic that wraps {@link net.minecraftforge.common.ISpecialArmor} methods | ||
* to allow full control over damage absorption additionally to vanilla attribute values | ||
*/ | ||
public interface ISpecialArmorLogic extends IArmorLogic { | ||
|
||
/** | ||
* Retrieves the modifiers to be used when calculating armor damage. | ||
* <p> | ||
* Armor will higher priority will have damage applied to them before | ||
* lower priority ones. If there are multiple pieces of armor with the | ||
* same priority, damage will be distributed between them based on there | ||
* absorption ratio. | ||
*/ | ||
ArmorProperties getProperties(EntityLivingBase player, @Nonnull ItemStack armor, DamageSource source, double damage, EntityEquipmentSlot equipmentSlot); | ||
|
||
/** | ||
* Get the displayed effective armor. | ||
* | ||
* @return The number of armor points for display, 2 per shield. | ||
*/ | ||
int getArmorDisplay(EntityPlayer player, @Nonnull ItemStack armor, int slot); | ||
|
||
/** | ||
* Simple check to see if the armor should interact with "Unblockable" damage | ||
* sources. A fair number of vanilla damage sources have this tag, such as | ||
* Anvils, Falling, Fire, and Magic. | ||
* <p> | ||
* Returning true here means that the armor is able to meaningfully respond | ||
* to this damage source. Otherwise, no interaction is allowed. | ||
*/ | ||
default boolean handleUnblockableDamage(EntityLivingBase entity, @Nonnull ItemStack armor, DamageSource source, double damage, EntityEquipmentSlot equipmentSlot) { | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 32 additions & 32 deletions
64
src/main/java/gregtech/common/asm/LayerArmorBaseVisitor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,32 @@ | ||
package gregtech.common.asm; | ||
|
||
import org.objectweb.asm.MethodVisitor; | ||
import org.objectweb.asm.Opcodes; | ||
|
||
import gregtech.common.asm.util.ObfMapping; | ||
|
||
class LayerArmorBaseVisitor extends MethodVisitor implements Opcodes { | ||
|
||
public static final String TARGET_CLASS_NAME = "net/minecraft/client/renderer/entity/layers/LayerArmorBase"; | ||
public static final ObfMapping TARGET_METHOD = new ObfMapping(TARGET_CLASS_NAME, "func_188361_a", "(Lnet/minecraft/entity/EntityLivingBase;FFFFFFFLnet/minecraft/inventory/EntityEquipmentSlot;)V"); | ||
|
||
private static final String ARMOR_HOOKS_OWNER = "gregtech/api/items/armor/ArmorRenderHooks"; | ||
private static final String ARMOR_HOOKS_SIGNATURE = "(Lnet/minecraft/client/renderer/entity/layers/LayerArmorBase;Lnet/minecraft/entity/EntityLivingBase;FFFFFFFLnet/minecraft/inventory/EntityEquipmentSlot;)V"; | ||
private static final String ARMOR_HOOKS_METHOD_NAME = "renderArmorLayer"; | ||
|
||
public LayerArmorBaseVisitor(MethodVisitor mv) { | ||
super(Opcodes.ASM5, mv); | ||
} | ||
|
||
@Override | ||
public void visitInsn(int opcode) { | ||
if (opcode == Opcodes.RETURN) { | ||
super.visitVarInsn(ALOAD, 0); //this | ||
super.visitVarInsn(ALOAD, 1); //entityLivingBaseIn | ||
for (int i = 0; i < 7; i++) super.visitVarInsn(FLOAD, 2 + i); //limbSwing, limbSwingAmount, partialTicks, ageInTicks, netHeadYaw, headPitch, scale | ||
super.visitVarInsn(ALOAD, 9); //slotIn | ||
super.visitMethodInsn(INVOKESTATIC, ARMOR_HOOKS_OWNER, ARMOR_HOOKS_METHOD_NAME, ARMOR_HOOKS_SIGNATURE, false); | ||
} | ||
super.visitInsn(opcode); | ||
} | ||
} | ||
package gregtech.common.asm; | ||
|
||
import gregtech.common.asm.util.ObfMapping; | ||
import org.objectweb.asm.MethodVisitor; | ||
import org.objectweb.asm.Opcodes; | ||
|
||
class LayerArmorBaseVisitor extends MethodVisitor implements Opcodes { | ||
|
||
public static final String TARGET_CLASS_NAME = "net/minecraft/client/renderer/entity/layers/LayerArmorBase"; | ||
public static final ObfMapping TARGET_METHOD = new ObfMapping(TARGET_CLASS_NAME, "func_188361_a", "(Lnet/minecraft/entity/EntityLivingBase;FFFFFFFLnet/minecraft/inventory/EntityEquipmentSlot;)V"); | ||
|
||
private static final String ARMOR_HOOKS_OWNER = "gregtech/api/items/armor/ArmorRenderHooks"; | ||
private static final String ARMOR_HOOKS_SIGNATURE = "(Lnet/minecraft/client/renderer/entity/layers/LayerArmorBase;Lnet/minecraft/entity/EntityLivingBase;FFFFFFFLnet/minecraft/inventory/EntityEquipmentSlot;)V"; | ||
private static final String ARMOR_HOOKS_METHOD_NAME = "renderArmorLayer"; | ||
|
||
public LayerArmorBaseVisitor(MethodVisitor mv) { | ||
super(Opcodes.ASM5, mv); | ||
} | ||
|
||
@Override | ||
public void visitInsn(int opcode) { | ||
if (opcode == Opcodes.RETURN) { | ||
super.visitVarInsn(ALOAD, 0); //this | ||
super.visitVarInsn(ALOAD, 1); //entityLivingBaseIn | ||
for (int i = 0; i < 7; i++) | ||
super.visitVarInsn(FLOAD, 2 + i); //limbSwing, limbSwingAmount, partialTicks, ageInTicks, netHeadYaw, headPitch, scale | ||
super.visitVarInsn(ALOAD, 9); //slotIn | ||
super.visitMethodInsn(INVOKESTATIC, ARMOR_HOOKS_OWNER, ARMOR_HOOKS_METHOD_NAME, ARMOR_HOOKS_SIGNATURE, false); | ||
} | ||
super.visitInsn(opcode); | ||
} | ||
} |
111 changes: 55 additions & 56 deletions
111
src/main/java/gregtech/common/asm/LayerCustomHeadVisitor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,55 @@ | ||
package gregtech.common.asm; | ||
|
||
import org.objectweb.asm.Label; | ||
import org.objectweb.asm.MethodVisitor; | ||
import org.objectweb.asm.Opcodes; | ||
|
||
import gregtech.common.asm.util.ObfMapping; | ||
import gregtech.common.asm.util.SafeMethodVisitor; | ||
|
||
class LayerCustomHeadVisitor extends SafeMethodVisitor { | ||
|
||
public static final String TARGET_CLASS_NAME = "net/minecraft/client/renderer/entity/layers/LayerCustomHead"; | ||
public static final ObfMapping TARGET_METHOD = new ObfMapping(TARGET_CLASS_NAME, "func_177141_a", "(Lnet/minecraft/entity/EntityLivingBase;FFFFFFF)V"); | ||
|
||
private static final String METHOD_OWNER = "net/minecraft/client/renderer/ItemRenderer"; | ||
private static final String METHOD_SIGNATURE = "(Lnet/minecraft/entity/EntityLivingBase;Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/renderer/block/model/ItemCameraTransforms$TransformType;)V"; | ||
private static final String METHOD_NAME = "func_178099_a"; | ||
private static final ObfMapping METHOD_MAPPING = new ObfMapping(METHOD_OWNER, METHOD_NAME, METHOD_SIGNATURE).toRuntime(); | ||
|
||
|
||
private static final String ARMOR_HOOKS_OWNER = "gregtech/api/items/armor/ArmorRenderHooks"; | ||
private static final String ARMOR_HOOKS_SIGNATURE = "(Lnet/minecraft/entity/EntityLivingBase;)Z"; | ||
private static final String ARMOR_HOOKS_METHOD_NAME = "shouldNotRenderHeadItem"; | ||
|
||
public LayerCustomHeadVisitor(MethodVisitor mv) { | ||
super(Opcodes.ASM5, mv); | ||
} | ||
|
||
private boolean checkTargetInsn(int opcode, String owner, String name, String desc) { | ||
return opcode == Opcodes.INVOKEVIRTUAL && METHOD_MAPPING.s_owner.equals(owner) && METHOD_MAPPING.matches(name, desc); | ||
} | ||
|
||
@Override | ||
public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) { | ||
if (checkTargetInsn(opcode, owner, name, desc)) { | ||
markPatchedSuccessfully(); | ||
Label endLabel = new Label(); | ||
Label skipLabel = new Label(); | ||
super.visitVarInsn(Opcodes.ALOAD, 1); //load entity | ||
super.visitMethodInsn(Opcodes.INVOKESTATIC, ARMOR_HOOKS_OWNER, ARMOR_HOOKS_METHOD_NAME, ARMOR_HOOKS_SIGNATURE, false); | ||
super.visitJumpInsn(Opcodes.IFEQ, skipLabel); | ||
for (int i = 0; i < 4; i++) super.visitInsn(Opcodes.POP); //pop this, entity, stack, transformType | ||
super.visitJumpInsn(Opcodes.GOTO, endLabel); | ||
super.visitLabel(skipLabel); | ||
super.visitMethodInsn(opcode, owner, name, desc, itf); | ||
super.visitLabel(endLabel); | ||
return; | ||
} | ||
super.visitMethodInsn(opcode, owner, name, desc, itf); | ||
} | ||
|
||
@Override | ||
protected String getInjectTargetString() { | ||
return String.format("Patch target: %s; injection point: %s; (point not found)", TARGET_METHOD, METHOD_MAPPING); | ||
} | ||
} | ||
package gregtech.common.asm; | ||
|
||
import gregtech.common.asm.util.ObfMapping; | ||
import gregtech.common.asm.util.SafeMethodVisitor; | ||
import org.objectweb.asm.Label; | ||
import org.objectweb.asm.MethodVisitor; | ||
import org.objectweb.asm.Opcodes; | ||
|
||
class LayerCustomHeadVisitor extends SafeMethodVisitor { | ||
|
||
public static final String TARGET_CLASS_NAME = "net/minecraft/client/renderer/entity/layers/LayerCustomHead"; | ||
public static final ObfMapping TARGET_METHOD = new ObfMapping(TARGET_CLASS_NAME, "func_177141_a", "(Lnet/minecraft/entity/EntityLivingBase;FFFFFFF)V"); | ||
|
||
private static final String METHOD_OWNER = "net/minecraft/client/renderer/ItemRenderer"; | ||
private static final String METHOD_SIGNATURE = "(Lnet/minecraft/entity/EntityLivingBase;Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/renderer/block/model/ItemCameraTransforms$TransformType;)V"; | ||
private static final String METHOD_NAME = "func_178099_a"; | ||
private static final ObfMapping METHOD_MAPPING = new ObfMapping(METHOD_OWNER, METHOD_NAME, METHOD_SIGNATURE).toRuntime(); | ||
|
||
|
||
private static final String ARMOR_HOOKS_OWNER = "gregtech/api/items/armor/ArmorRenderHooks"; | ||
private static final String ARMOR_HOOKS_SIGNATURE = "(Lnet/minecraft/entity/EntityLivingBase;)Z"; | ||
private static final String ARMOR_HOOKS_METHOD_NAME = "shouldNotRenderHeadItem"; | ||
|
||
public LayerCustomHeadVisitor(MethodVisitor mv) { | ||
super(Opcodes.ASM5, mv); | ||
} | ||
|
||
private boolean checkTargetInsn(int opcode, String owner, String name, String desc) { | ||
return opcode == Opcodes.INVOKEVIRTUAL && METHOD_MAPPING.s_owner.equals(owner) && METHOD_MAPPING.matches(name, desc); | ||
} | ||
|
||
@Override | ||
public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) { | ||
if (checkTargetInsn(opcode, owner, name, desc)) { | ||
markPatchedSuccessfully(); | ||
Label endLabel = new Label(); | ||
Label skipLabel = new Label(); | ||
super.visitVarInsn(Opcodes.ALOAD, 1); //load entity | ||
super.visitMethodInsn(Opcodes.INVOKESTATIC, ARMOR_HOOKS_OWNER, ARMOR_HOOKS_METHOD_NAME, ARMOR_HOOKS_SIGNATURE, false); | ||
super.visitJumpInsn(Opcodes.IFEQ, skipLabel); | ||
for (int i = 0; i < 4; i++) super.visitInsn(Opcodes.POP); //pop this, entity, stack, transformType | ||
super.visitJumpInsn(Opcodes.GOTO, endLabel); | ||
super.visitLabel(skipLabel); | ||
super.visitMethodInsn(opcode, owner, name, desc, itf); | ||
super.visitLabel(endLabel); | ||
return; | ||
} | ||
super.visitMethodInsn(opcode, owner, name, desc, itf); | ||
} | ||
|
||
@Override | ||
protected String getInjectTargetString() { | ||
return String.format("Patch target: %s; injection point: %s; (point not found)", TARGET_METHOD, METHOD_MAPPING); | ||
} | ||
} |
Oops, something went wrong.