Skip to content

Commit

Permalink
Runic Event handler fix
Browse files Browse the repository at this point in the history
  • Loading branch information
KryptonCaptain committed May 19, 2017
2 parents c951488 + 512bbda commit 312a643
Show file tree
Hide file tree
Showing 9 changed files with 227 additions and 134 deletions.
4 changes: 2 additions & 2 deletions build.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version=1.8.5
version=1.8.6
dir_output=../Build Output/TD/
mc_version=1.7.10
forge_version=10.13.4.1614
dir_repo=./
build_number=0
build_number=2
mod_name=Thaumic-Dyes-[1.7.10]
8 changes: 4 additions & 4 deletions src/main/java/thaumicdyes/common/ConfigRecipes.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public static void initRunicRecipes() {

ConfigResearch.recipes.put("EnhRunicArmor0", ThaumcraftApi.addInfusionCraftingRecipe("TD.ENHANCEDRUNICARMOR",
new ItemStack(ItemHandler.itemHelmetRunicTX), 8,
new AspectList().add(Aspect.ARMOR, 40).add(Aspect.MAGIC, 80).add(Aspect.ENERGY, 80).add(Aspect.ELDRITCH, 20).add(Aspect.CLOTH, 24).add(Aspect.CRYSTAL, 16).add(Aspect.EXCHANGE, 20),
new AspectList().add(Aspect.ARMOR, 40).add(Aspect.MAGIC, 160).add(Aspect.ENERGY, 80).add(Aspect.ELDRITCH, 20).add(Aspect.CLOTH, 24).add(Aspect.CRYSTAL, 16).add(Aspect.EXCHANGE, 20),
new ItemStack(ItemHandler.itemHelmetRunicLegacy),
new ItemStack[] {
new ItemStack(Items.nether_star),
Expand All @@ -138,7 +138,7 @@ public static void initRunicRecipes() {

ConfigResearch.recipes.put("EnhRunicArmor1", ThaumcraftApi.addInfusionCraftingRecipe("TD.ENHANCEDRUNICARMOR",
new ItemStack(ItemHandler.itemChestRunicTX), 8,
new AspectList().add(Aspect.ARMOR, 40).add(Aspect.MAGIC, 80).add(Aspect.ENERGY, 80).add(Aspect.ELDRITCH, 20).add(Aspect.CLOTH, 24).add(Aspect.CRYSTAL, 16).add(Aspect.EXCHANGE, 20),
new AspectList().add(Aspect.ARMOR, 40).add(Aspect.MAGIC, 160).add(Aspect.ENERGY, 80).add(Aspect.ELDRITCH, 20).add(Aspect.CLOTH, 24).add(Aspect.CRYSTAL, 16).add(Aspect.EXCHANGE, 20),
new ItemStack(ItemHandler.itemChestRunicLegacy),
new ItemStack[] {
new ItemStack(Items.nether_star),
Expand All @@ -153,7 +153,7 @@ public static void initRunicRecipes() {

ConfigResearch.recipes.put("EnhRunicArmor2", ThaumcraftApi.addInfusionCraftingRecipe("TD.ENHANCEDRUNICARMOR",
new ItemStack(ItemHandler.itemLegsRunicTX), 8,
new AspectList().add(Aspect.ARMOR, 40).add(Aspect.MAGIC, 80).add(Aspect.ENERGY, 80).add(Aspect.ELDRITCH, 20).add(Aspect.CLOTH, 24).add(Aspect.CRYSTAL, 16).add(Aspect.EXCHANGE, 20),
new AspectList().add(Aspect.ARMOR, 40).add(Aspect.MAGIC, 160).add(Aspect.ENERGY, 80).add(Aspect.ELDRITCH, 20).add(Aspect.CLOTH, 24).add(Aspect.CRYSTAL, 16).add(Aspect.EXCHANGE, 20),
new ItemStack(ItemHandler.itemLegsRunicLegacy),
new ItemStack[] {
new ItemStack(Items.nether_star),
Expand All @@ -168,7 +168,7 @@ public static void initRunicRecipes() {

ConfigResearch.recipes.put("EnhRunicArmor3", ThaumcraftApi.addInfusionCraftingRecipe("TD.ENHANCEDRUNICARMOR",
new ItemStack(ItemHandler.itemBootsRunicTX), 8,
new AspectList().add(Aspect.ARMOR, 40).add(Aspect.MAGIC, 80).add(Aspect.ENERGY, 80).add(Aspect.ELDRITCH, 20).add(Aspect.CLOTH, 24).add(Aspect.CRYSTAL, 16).add(Aspect.EXCHANGE, 20),
new AspectList().add(Aspect.ARMOR, 40).add(Aspect.MAGIC, 160).add(Aspect.ENERGY, 80).add(Aspect.ELDRITCH, 20).add(Aspect.CLOTH, 24).add(Aspect.CRYSTAL, 16).add(Aspect.EXCHANGE, 20),
new ItemStack(ItemHandler.itemBootsRunicLegacy),
new ItemStack[] {
new ItemStack(Items.nether_star),
Expand Down
35 changes: 23 additions & 12 deletions src/main/java/thaumicdyes/common/items/ItemHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
import thaumicdyes.common.items.CultistPaladin;
import thaumicdyes.common.items.CultistPraetorDyed;
import thaumicdyes.common.items.CultistKnightDyed;
import thaumicdyes.common.items.legacy.ItemRunicArmorLegacy;
import thaumicdyes.common.items.legacy.ItemRunicBootsTraveller;
import thaumicdyes.common.items.legacy.ItemRunicGoggles;
import thaumicdyes.common.items.legacy.ItemTXAncientMask;
import thaumicdyes.common.items.legacy.ItemTXRunicArmorEnhanced;
import thaumicdyes.common.items.runic.ItemRunicArmor;
import thaumicdyes.common.items.runic.ItemRunicArmorEnhanced;
import thaumicdyes.common.items.runic.ItemRunicBootsTraveller;
import thaumicdyes.common.items.runic.ItemRunicGoggles;
import thaumcraft.api.ThaumcraftApi;
import thaumcraft.api.aspects.Aspect;
import thaumcraft.api.aspects.AspectList;
Expand Down Expand Up @@ -102,6 +102,10 @@ public class ItemHandler {
public static Item itemLegsRunicTX;
public static Item itemBootsRunicTX;

public static Item itemHelmetRunicPrimal;
public static Item itemChestRunicPrimal;
public static Item itemLegsRunicPrimal;
public static Item itemBootsRunicPrimal;


public static void registerItems() {
Expand Down Expand Up @@ -177,6 +181,12 @@ public static void registerItems() {
GameRegistry.registerItem(itemChestRunicTX, "ItemRunicChestEnhanced");
GameRegistry.registerItem(itemLegsRunicTX, "ItemRunicLegsEnhanced");
GameRegistry.registerItem(itemBootsRunicTX, "ItemRunicBootsEnhanced");

GameRegistry.registerItem(itemHelmetRunicPrimal, "ItemRunicHelmetPrimal");
GameRegistry.registerItem(itemChestRunicPrimal, "ItemRunicChestPrimal");
GameRegistry.registerItem(itemLegsRunicPrimal, "ItemRunicLegsPrimal");
GameRegistry.registerItem(itemBootsRunicPrimal, "ItemRunicBootsPrimal");

}

public static void defineItems() {
Expand Down Expand Up @@ -242,20 +252,21 @@ public static void defineItems() {
itemChestSunKnight = (new SunKnight(ArmorMaterial.IRON, 4, 1)).setUnlocalizedName("itemChestSunKnight").setCreativeTab(ThaumicDyes.tabTD);

//legacy runic armor
itemHelmetRunicLegacy = (new ItemRunicArmorLegacy(ThaumcraftApi.armorMatSpecial, 4, 0)).setUnlocalizedName("ItemHelmetRunic").setCreativeTab(ThaumicDyes.tabTD);
itemChestRunicLegacy = (new ItemRunicArmorLegacy(ThaumcraftApi.armorMatSpecial, 4, 1)).setUnlocalizedName("ItemChestplateRunic").setCreativeTab(ThaumicDyes.tabTD);
itemLegsRunicLegacy = (new ItemRunicArmorLegacy(ThaumcraftApi.armorMatSpecial, 4, 2)).setUnlocalizedName("ItemLeggingsRunic").setCreativeTab(ThaumicDyes.tabTD);
itemBootsRunicLegacy = (new ItemRunicArmorLegacy(ThaumcraftApi.armorMatSpecial, 4, 3)).setUnlocalizedName("ItemBootsRunic").setCreativeTab(ThaumicDyes.tabTD);;
itemHelmetRunicLegacy = (new ItemRunicArmor(ThaumcraftApi.armorMatSpecial, 4, 0)).setUnlocalizedName("ItemHelmetRunic").setCreativeTab(ThaumicDyes.tabTD);
itemChestRunicLegacy = (new ItemRunicArmor(ThaumcraftApi.armorMatSpecial, 4, 1)).setUnlocalizedName("ItemChestRunic").setCreativeTab(ThaumicDyes.tabTD);
itemLegsRunicLegacy = (new ItemRunicArmor(ThaumcraftApi.armorMatSpecial, 4, 2)).setUnlocalizedName("ItemLegsRunic").setCreativeTab(ThaumicDyes.tabTD);
itemBootsRunicLegacy = (new ItemRunicArmor(ThaumcraftApi.armorMatSpecial, 4, 3)).setUnlocalizedName("ItemBootsRunic").setCreativeTab(ThaumicDyes.tabTD);;
itemGogglesRunicLegacy = (new ItemRunicGoggles(ThaumcraftApi.armorMatSpecial, 4, 0)).setUnlocalizedName("ItemGogglesRunic").setCreativeTab(ThaumicDyes.tabTD);
itemBootsTravellerRunicLegacy = (new ItemRunicBootsTraveller(ThaumcraftApi.armorMatSpecial, 4, 3)).setUnlocalizedName("ItemBootsTravellerRunic").setCreativeTab(ThaumicDyes.tabTD);;

//legacy TX
itemHelmetMaskTX = (new ItemTXAncientMask(ThaumcraftApi.armorMatSpecial, 2, 0)).setUnlocalizedName("ItemMaskEvil").setCreativeTab(ThaumicDyes.tabTD);

itemHelmetRunicTX = (new ItemTXRunicArmorEnhanced(ThaumcraftApi.armorMatSpecial, 4, 0)).setUnlocalizedName("ItemHelmetRunicEnhanced").setCreativeTab(ThaumicDyes.tabTD);
itemChestRunicTX = (new ItemTXRunicArmorEnhanced(ThaumcraftApi.armorMatSpecial, 4, 1)).setUnlocalizedName("ItemChestplateRunicEnhanced").setCreativeTab(ThaumicDyes.tabTD);
itemLegsRunicTX = (new ItemTXRunicArmorEnhanced(ThaumcraftApi.armorMatSpecial, 4, 2)).setUnlocalizedName("ItemLeggingsRunicEnhanced").setCreativeTab(ThaumicDyes.tabTD);
itemBootsRunicTX = (new ItemTXRunicArmorEnhanced(ThaumcraftApi.armorMatSpecial, 4, 3)).setUnlocalizedName("ItemBootsRunicEnhanced").setCreativeTab(ThaumicDyes.tabTD);;
itemHelmetRunicTX = (new ItemRunicArmorEnhanced(ThaumcraftApi.armorMatSpecial, 4, 0)).setUnlocalizedName("ItemHelmetRunicEnhanced").setCreativeTab(ThaumicDyes.tabTD);
itemChestRunicTX = (new ItemRunicArmorEnhanced(ThaumcraftApi.armorMatSpecial, 4, 1)).setUnlocalizedName("ItemChestRunicEnhanced").setCreativeTab(ThaumicDyes.tabTD);
itemLegsRunicTX = (new ItemRunicArmorEnhanced(ThaumcraftApi.armorMatSpecial, 4, 2)).setUnlocalizedName("ItemLegsRunicEnhanced").setCreativeTab(ThaumicDyes.tabTD);
itemBootsRunicTX = (new ItemRunicArmorEnhanced(ThaumcraftApi.armorMatSpecial, 4, 3)).setUnlocalizedName("ItemBootsRunicEnhanced").setCreativeTab(ThaumicDyes.tabTD);;



}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package thaumicdyes.common.items.legacy;
package thaumicdyes.common.items.runic;

import java.util.HashMap;
import java.util.List;
Expand All @@ -24,15 +24,15 @@
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

public class ItemRunicArmorLegacy extends ItemArmor implements ISpecialArmor, IRunicArmor
public class ItemRunicArmor extends ItemArmor implements ISpecialArmor, IRunicArmor
{
public IIcon iconHelm;
public IIcon iconChest;
public IIcon iconLegs;
public IIcon iconBoots;
public static HashMap<Integer, Long> nextTick;

public ItemRunicArmorLegacy(ArmorMaterial enumarmormaterial, int j, int k) {
public ItemRunicArmor(ArmorMaterial enumarmormaterial, int j, int k) {
super(enumarmormaterial, j, k);
this.setCreativeTab(ThaumicDyes.tabTD);
MinecraftForge.EVENT_BUS.register(this);
Expand All @@ -55,13 +55,6 @@ public IIcon getIconFromDamage(final int par1) {
return (this.armorType == 0) ? this.iconHelm : ((this.armorType == 1) ? this.iconChest : ((this.armorType == 2) ? this.iconLegs : this.iconBoots));
}

public int getMaxDamage(final ItemStack stack) {
int md = ((ItemArmor)stack.getItem()).damageReduceAmount * 8;
if (getUpgrade(stack) == 2) {
md *= (int)1.5;
}
return md;
}

public int getRunicCharge(ItemStack itemstack) {
//return (this.armorType == 0) ? itemstack.getMaxDamage() : ((this.armorType == 1) ? itemstack.getMaxDamage() : ((this.armorType == 2) ? itemstack.getMaxDamage() : itemstack.getMaxDamage()));
Expand All @@ -87,7 +80,7 @@ public String getArmorTexture(ItemStack stack, Entity entity, int slot, String t
}

public EnumRarity getRarity(final ItemStack itemstack) {
return EnumRarity.rare;
return EnumRarity.uncommon;
}

public boolean isBookEnchantable(final ItemStack itemstack1, final ItemStack itemstack2) {
Expand Down Expand Up @@ -140,23 +133,23 @@ public void damageArmor(final EntityLivingBase entity, final ItemStack stack, fi
public void onArmorTick(final World world, final EntityPlayer player, final ItemStack armor) {
if (!world.isRemote && armor.getItemDamage() > 0) {
final long time = System.currentTimeMillis();
if (!ItemRunicArmorLegacy.nextTick.containsKey(player.ticksExisted)) {
ItemRunicArmorLegacy.nextTick.put(player.ticksExisted, 0L);
if (!ItemRunicArmor.nextTick.containsKey(player.ticksExisted)) {
ItemRunicArmor.nextTick.put(player.ticksExisted, 0L);
}
if (time < ItemRunicArmorLegacy.nextTick.get(player.ticksExisted)) {
if (time < ItemRunicArmor.nextTick.get(player.ticksExisted)) {
return;
}
if (armor.getItemDamage() > 0) {
int rate = 1000;
for (int a = 0; a < 4; ++a) {
if (player.inventory.armorItemInSlot(a) != null && player.inventory.armorItemInSlot(a).getItem() instanceof ItemRunicArmorLegacy && getUpgrade(player.inventory.armorItemInSlot(a)) == 1) {
if (player.inventory.armorItemInSlot(a) != null && player.inventory.armorItemInSlot(a).getItem() instanceof ItemRunicArmor && getUpgrade(player.inventory.armorItemInSlot(a)) == 1) {
rate -= 150;
}
}
if (rate < 200) {
rate = 200;
}
ItemRunicArmorLegacy.nextTick.put(player.ticksExisted, time + rate);
ItemRunicArmor.nextTick.put(player.ticksExisted, time + rate);
armor.setItemDamage(armor.getItemDamage() - 1);
player.inventoryContainer.detectAndSendChanges();
}
Expand All @@ -170,8 +163,9 @@ public static int getUpgrade(final ItemStack armor) {
return 0;
}


static {
ItemRunicArmorLegacy.nextTick = new HashMap<Integer, Long>();
ItemRunicArmor.nextTick = new HashMap<Integer, Long>();

}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package thaumicdyes.common.items.legacy;
package thaumicdyes.common.items.runic;

import java.util.List;

Expand All @@ -16,37 +16,27 @@
import net.minecraft.world.World;
import net.minecraftforge.common.ISpecialArmor;
import net.minecraftforge.common.ISpecialArmor.ArmorProperties;
import net.minecraftforge.event.entity.living.LivingEvent;
import thaumcraft.api.IRunicArmor;
import thaumcraft.api.aspects.Aspect;
import thaumcraft.common.Thaumcraft;
import thaumcraft.common.items.armor.Hover;
import thaumicdyes.common.ThaumicDyes;
import thaumicdyes.common.items.ItemHandler;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;


public class ItemTXRunicArmorEnhanced extends ItemRunicArmorLegacy {
public class ItemRunicArmorEnhanced extends ItemRunicArmor {

public ItemTXRunicArmorEnhanced(ItemArmor.ArmorMaterial enumarmormaterial, int j, int k) {
public ItemRunicArmorEnhanced(ItemArmor.ArmorMaterial enumarmormaterial, int j, int k) {
super(enumarmormaterial, j, k);
this.setCreativeTab(ThaumicDyes.tabTD);
}


//@Override
public int getMaxDamage(ItemStack stack) {
int md = ((ItemArmor)stack.getItem()).damageReduceAmount * 8;

if (getUpgrade(stack) == 2 || getUpgrade2(stack) == 2) {
if (getUpgrade(stack) == 2 && getUpgrade2(stack) == 2) {
md *= (int)2.0;
}
else {
md *= (int)1.5;
}
}
return md;
}

//@Override
@Override
public int getRunicCharge(ItemStack itemstack) {
//return (this.armorType == 0) ? itemstack.getMaxDamage() : ((this.armorType == 1) ? itemstack.getMaxDamage() : ((this.armorType == 2) ? itemstack.getMaxDamage() : itemstack.getMaxDamage()));
//return 0;
Expand All @@ -69,9 +59,7 @@ public int getRunicCharge(ItemStack itemstack) {
}




//@Override
@Override
public ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, double damage, int slot)
{
int priority = 0;
Expand All @@ -96,7 +84,7 @@ else if (source.isUnblockable())
}


//@Override
@Override
public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot) {
int dra = ((ItemArmor)armor.getItem()).damageReduceAmount;
if (getUpgrade(armor) == 5 || getUpgrade2(armor) == 5) {
Expand Down Expand Up @@ -136,17 +124,19 @@ public void addInformation(ItemStack stack, EntityPlayer player, List list, bool
// }
}

public static int getUpgrade2(ItemStack armor)

public static int getUpgrade(ItemStack armor)
{
if ((armor.hasTagCompound()) && (armor.stackTagCompound.hasKey("upgrade2"))) {
return armor.stackTagCompound.getByte("upgrade2");
if ((armor.hasTagCompound()) && (armor.stackTagCompound.hasKey("upgrade"))) {
return armor.stackTagCompound.getByte("upgrade");
}
return 0;
}
public static int getUpgrade(ItemStack armor)

public static int getUpgrade2(ItemStack armor)
{
if ((armor.hasTagCompound()) && (armor.stackTagCompound.hasKey("upgrade"))) {
return armor.stackTagCompound.getByte("upgrade");
if ((armor.hasTagCompound()) && (armor.stackTagCompound.hasKey("upgrade2"))) {
return armor.stackTagCompound.getByte("upgrade2");
}
return 0;
}
Expand All @@ -155,7 +145,7 @@ public static int getUpgrade(ItemStack armor)
@Override
public EnumRarity getRarity(ItemStack itemstack)
{
return EnumRarity.epic;
return EnumRarity.rare;
}

@SideOnly(Side.CLIENT)
Expand Down Expand Up @@ -185,5 +175,53 @@ public int getVisDiscount(ItemStack stack, EntityPlayer player, Aspect aspect)
//return this.armorType == 3 ? 1 : 2;
return 2;
}



public void onArmorTick(World world, EntityPlayer player, ItemStack armor)
{
if ((!player.capabilities.isFlying) && (player.moveForward > 0.0F))
{
if ((player.worldObj.isRemote) && (!player.isSneaking()))
{
if (!Thaumcraft.instance.entityEventHandler.prevStep.containsKey(Integer.valueOf(player.getEntityId()))) {
Thaumcraft.instance.entityEventHandler.prevStep.put(Integer.valueOf(player.getEntityId()), Float.valueOf(player.stepHeight));
}
player.stepHeight = 1.0F;
}
if (player.onGround)
{
float bonus = 0.1F;
if (player.isInWater()) {
bonus /= 3.0F;
}
player.moveFlying(0.0F, 1.0F, bonus);
}
else if (Hover.getHover(player.getEntityId()))
{
player.jumpMovementFactor = 0.03F;
}
else
{
player.jumpMovementFactor = 0.05F;
}
}
if (player.fallDistance > 0.0F) {
player.fallDistance -= 0.5F;
}

super.onArmorTick(world, player, armor);
if ((!world.isRemote) && (armor.getItemDamage() > 0) && (player.ticksExisted % 20 == 0)) {
armor.damageItem(-1, player);
}
}

@SubscribeEvent
public void playerJumps(LivingEvent.LivingJumpEvent event)
{
if (((event.entity instanceof EntityPlayer)) && (((EntityPlayer)event.entity).inventory.armorItemInSlot(0) != null) && (((EntityPlayer)event.entity).inventory.armorItemInSlot(0).getItem() == ItemHandler.itemBootsVoidTraveller)) {
event.entityLiving.motionY += 0.35D;
}
}

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package thaumicdyes.common.items.legacy;
package thaumicdyes.common.items.runic;

import net.minecraft.util.StatCollector;
import net.minecraft.util.EnumChatFormatting;
Expand All @@ -22,7 +22,7 @@
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.living.LivingEvent;

public class ItemRunicBootsTraveller extends ItemRunicArmorLegacy
public class ItemRunicBootsTraveller extends ItemRunicArmor
{
public IIcon icon;

Expand Down Expand Up @@ -104,7 +104,7 @@ public void playerJumps(LivingEvent.LivingJumpEvent event)
@Override
public void addInformation(final ItemStack stack, final EntityPlayer player, final List list, final boolean par4) {
//list.add(EnumChatFormatting.GOLD + StatCollector.translateToLocal("item.runic.charge") + ": " + (stack.getMaxDamage() - stack.getItemDamage()) + "/" + stack.getMaxDamage());
final int u = ItemRunicArmorLegacy.getUpgrade(stack);
final int u = ItemRunicArmor.getUpgrade(stack);
if (u > 0) {
list.add(EnumChatFormatting.DARK_AQUA + StatCollector.translateToLocal("item.runic.upgrade." + u));
}
Expand Down
Loading

0 comments on commit 312a643

Please sign in to comment.