From 41edd8660290951287f82ded9cc02c330b709d1c Mon Sep 17 00:00:00 2001 From: WayofTime Date: Sun, 1 May 2016 10:01:00 -0400 Subject: [PATCH] Work on Elytra upgrade. Fixed Lava Crystals again --- changelog.txt | 1 + .../bloodmagic/item/ItemLavaCrystal.java | 5 +- .../item/armour/ItemLivingArmour.java | 47 +++++++++++++++++-- .../upgrade/LivingArmourUpgradeJump.java | 6 +-- 4 files changed, 50 insertions(+), 9 deletions(-) diff --git a/changelog.txt b/changelog.txt index 1e2c7d25..56b84d3b 100644 --- a/changelog.txt +++ b/changelog.txt @@ -6,6 +6,7 @@ Version 2.0.0-35 - Started adding in the Alchemy Table... not really started. - Changed it so that the Mending enchantment consumes the EXP before the Tome of Peritia does - Added fall distance mitigation to the jump upgrade +- Fixed Lava Crystals... again. ------------------------------------------------------ Version 2.0.0-34 diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemLavaCrystal.java b/src/main/java/WayofTime/bloodmagic/item/ItemLavaCrystal.java index 07b19284..3cd4b88f 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemLavaCrystal.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemLavaCrystal.java @@ -3,7 +3,6 @@ package WayofTime.bloodmagic.item; import java.util.ArrayList; import java.util.List; -import WayofTime.bloodmagic.api.util.helper.NetworkHelper; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.MobEffects; import net.minecraft.item.Item; @@ -15,6 +14,7 @@ import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.Pair; import WayofTime.bloodmagic.api.Constants; +import WayofTime.bloodmagic.api.util.helper.NetworkHelper; import WayofTime.bloodmagic.api.util.helper.PlayerHelper; import WayofTime.bloodmagic.client.IVariantProvider; @@ -31,7 +31,7 @@ public class ItemLavaCrystal extends ItemBindableBase implements IFuelHandler, I @Override public ItemStack getContainerItem(ItemStack itemStack) { - NetworkHelper.getSoulNetwork(this.getOwnerName(itemStack)).syphon(25); + NetworkHelper.getSoulNetwork(this.getOwnerUUID(itemStack)).syphon(25); ItemStack copiedStack = itemStack.copy(); copiedStack.setItemDamage(copiedStack.getItemDamage()); copiedStack.stackSize = 1; @@ -61,6 +61,7 @@ public class ItemLavaCrystal extends ItemBindableBase implements IFuelHandler, I // { // return 200; // } +// System.out.println(FMLCommonHandler.instance().getSide()); if (NetworkHelper.canSyphonFromContainer(fuel, 25)) { diff --git a/src/main/java/WayofTime/bloodmagic/item/armour/ItemLivingArmour.java b/src/main/java/WayofTime/bloodmagic/item/armour/ItemLivingArmour.java index 8c21d318..665f17e8 100644 --- a/src/main/java/WayofTime/bloodmagic/item/armour/ItemLivingArmour.java +++ b/src/main/java/WayofTime/bloodmagic/item/armour/ItemLivingArmour.java @@ -1,11 +1,14 @@ package WayofTime.bloodmagic.item.armour; +import java.lang.reflect.Field; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; +import net.minecraft.client.entity.EntityPlayerSP; +import net.minecraft.client.model.ModelElytra; import net.minecraft.client.renderer.ItemMeshDefinition; import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.entity.Entity; @@ -16,10 +19,12 @@ import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.datasync.DataParameter; import net.minecraft.util.DamageSource; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; import net.minecraftforge.common.ISpecialArmor; +import net.minecraftforge.fml.relauncher.ReflectionHelper; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import WayofTime.bloodmagic.BloodMagic; @@ -39,6 +44,9 @@ import com.google.common.collect.Multimap; public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshProvider { + private static Field _FLAGS = ReflectionHelper.findField(Entity.class, "FLAGS", "field_184240_ax"); + + private static DataParameter FLAGS = null; public static String[] names = { "helmet", "chest", "legs", "boots" }; public static final boolean useSpecialArmourCalculation = true; @@ -257,8 +265,42 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshP { super.onArmorTick(world, player, stack); - if (world.isRemote) + if (world.isRemote && this == ModItems.livingArmourChest) { + + if (player instanceof EntityPlayerSP) //Sanity check + { + EntityPlayerSP spPlayer = (EntityPlayerSP) player; + + if (FLAGS == null) + { + ModelElytra d; + try + { + FLAGS = (DataParameter) _FLAGS.get(null); + } catch (IllegalArgumentException e) + { + e.printStackTrace(); + } catch (IllegalAccessException e) + { + e.printStackTrace(); + } + } + + if (FLAGS != null) + { + if (spPlayer.movementInput.jump && !spPlayer.onGround && spPlayer.motionY < 0.0D && !spPlayer.isElytraFlying() && !spPlayer.capabilities.isFlying) + { + byte b0 = player.getDataManager().get(FLAGS); + player.getDataManager().set(FLAGS, (byte) (b0 | 1 << 7)); + } else if (spPlayer.isElytraFlying() && !spPlayer.movementInput.jump && !spPlayer.onGround) + { + byte b0 = player.getDataManager().get(FLAGS); + player.getDataManager().set(FLAGS, (byte) (b0 & ~(1 << 7))); + } + } + } + return; } @@ -274,9 +316,6 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshP { this.setIsEnabled(stack, true); armour.onTick(world, player); - } else - { - this.setIsEnabled(stack, false); } setLivingArmour(stack, armour, false); diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeJump.java b/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeJump.java index a16ea1c6..0b317a1e 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeJump.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeJump.java @@ -1,11 +1,11 @@ package WayofTime.bloodmagic.livingArmour.upgrade; -import WayofTime.bloodmagic.api.Constants; -import WayofTime.bloodmagic.api.livingArmour.ILivingArmour; -import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; +import WayofTime.bloodmagic.api.Constants; +import WayofTime.bloodmagic.api.livingArmour.ILivingArmour; +import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; public class LivingArmourUpgradeJump extends LivingArmourUpgrade {