diff --git a/changelog.txt b/changelog.txt index 92787aac..08eb21bf 100644 --- a/changelog.txt +++ b/changelog.txt @@ -7,6 +7,8 @@ Version 2.0.1-43 - Updated the Guide (Woooooooooooooo........) - (Possibly?) fixed Tome of Peritia bug of the Negative Speed of Light - Added recipes for all ores -> dust in the alchemy table. +- Added the recipes for the Sentient Tools - yes, they all drop Will. +- Fixed the bow so that it now gives you Will when you kill a mob - it does not drop the Will, it goes directly to you. ------------------------------------------------------ Version 2.0.1-42 diff --git a/src/main/java/WayofTime/bloodmagic/entity/projectile/EntitySentientArrow.java b/src/main/java/WayofTime/bloodmagic/entity/projectile/EntitySentientArrow.java index 2737031a..db1a7162 100644 --- a/src/main/java/WayofTime/bloodmagic/entity/projectile/EntitySentientArrow.java +++ b/src/main/java/WayofTime/bloodmagic/entity/projectile/EntitySentientArrow.java @@ -1,11 +1,13 @@ package WayofTime.bloodmagic.entity.projectile; import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.monster.IMob; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.projectile.EntityTippedArrow; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.EnumDifficulty; import net.minecraft.world.World; import WayofTime.bloodmagic.api.Constants; import WayofTime.bloodmagic.api.soul.EnumDemonWillType; @@ -26,18 +28,23 @@ public class EntitySentientArrow extends EntityTippedArrow super(worldIn, x, y, z); } - public EntitySentientArrow(World worldIn, EntityLivingBase shooter, EnumDemonWillType type) + public EntitySentientArrow(World worldIn, EntityLivingBase shooter, EnumDemonWillType type, double reinburseAmount) { super(worldIn, shooter); - this.reimbursedAmountOnHit = 0; + this.reimbursedAmountOnHit = reinburseAmount; this.type = type; } - public void reimbursePlayer() + public void reimbursePlayer(EntityLivingBase hitEntity, float damage) { if (this.shootingEntity instanceof EntityPlayer) { - PlayerDemonWillHandler.addDemonWill(EnumDemonWillType.DEFAULT, (EntityPlayer) this.shootingEntity, reimbursedAmountOnHit); + if (hitEntity.worldObj.getDifficulty() != EnumDifficulty.PEACEFUL && !(hitEntity instanceof IMob)) + { + return; + } + + PlayerDemonWillHandler.addDemonWill(type, (EntityPlayer) this.shootingEntity, reimbursedAmountOnHit * damage / 20f); } } diff --git a/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientBow.java b/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientBow.java index 62843ee8..9a8e93bd 100644 --- a/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientBow.java +++ b/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientBow.java @@ -2,6 +2,7 @@ package WayofTime.bloodmagic.item.soul; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.monster.EntitySlime; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.projectile.EntityArrow; import net.minecraft.init.Enchantments; @@ -34,6 +35,9 @@ public class ItemSentientBow extends ItemBow implements IMultiWillTool//, IMeshP public static int[] soulBracket = new int[] { 16, 60, 200, 400, 1000 }; public static double[] defaultDamageAdded = new double[] { 0.25, 0.5, 0.75, 1, 1.25 }; public static float[] velocityAdded = new float[] { 0.25f, 0.5f, 0.75f, 1, 1.25f }; + public static double[] soulDrainPerSwing = new double[] { 0.05, 0.1, 0.2, 0.4, 0.75 }; //TODO + public static double[] soulDrop = new double[] { 2, 4, 7, 10, 13 }; + public static double[] staticDrop = new double[] { 1, 1, 2, 3, 3 }; public ItemSentientBow() { @@ -86,6 +90,11 @@ public class ItemSentientBow extends ItemBow implements IMultiWillTool//, IMeshP this.setCurrentType(stack, soulsRemaining > 0 ? type : EnumDemonWillType.DEFAULT); int level = getLevel(stack, soulsRemaining); // + double drain = level >= 0 ? soulDrainPerSwing[level] : 0; + + setDrainOfActivatedBow(stack, drain); + setStaticDropOfActivatedBow(stack, level >= 0 ? staticDrop[level] : 1); + setDropOfActivatedBow(stack, level >= 0 ? soulDrop[level] : 0); // double drain = level >= 0 ? soulDrainPerSwing[level] : 0; // double extraDamage = level >= 0 ? damageAdded[level] : 0; // @@ -204,6 +213,57 @@ public class ItemSentientBow extends ItemBow implements IMultiWillTool//, IMeshP tag.setString(Constants.NBT.WILL_TYPE, type.toString()); } + public double getDrainOfActivatedBow(ItemStack stack) + { + NBTHelper.checkNBT(stack); + + NBTTagCompound tag = stack.getTagCompound(); + return tag.getDouble(Constants.NBT.SOUL_SWORD_ACTIVE_DRAIN); + } + + public void setDrainOfActivatedBow(ItemStack stack, double drain) + { + NBTHelper.checkNBT(stack); + + NBTTagCompound tag = stack.getTagCompound(); + + tag.setDouble(Constants.NBT.SOUL_SWORD_ACTIVE_DRAIN, drain); + } + + public double getStaticDropOfActivatedBow(ItemStack stack) + { + NBTHelper.checkNBT(stack); + + NBTTagCompound tag = stack.getTagCompound(); + return tag.getDouble(Constants.NBT.SOUL_SWORD_STATIC_DROP); + } + + public void setStaticDropOfActivatedBow(ItemStack stack, double drop) + { + NBTHelper.checkNBT(stack); + + NBTTagCompound tag = stack.getTagCompound(); + + tag.setDouble(Constants.NBT.SOUL_SWORD_STATIC_DROP, drop); + } + + public double getDropOfActivatedBow(ItemStack stack) + { + NBTHelper.checkNBT(stack); + + NBTTagCompound tag = stack.getTagCompound(); + return tag.getDouble(Constants.NBT.SOUL_SWORD_DROP); + } + + public void setDropOfActivatedBow(ItemStack stack, double drop) + { + NBTHelper.checkNBT(stack); + + NBTTagCompound tag = stack.getTagCompound(); + + tag.setDouble(Constants.NBT.SOUL_SWORD_DROP, drop); + } + @Override public ActionResult onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand) { @@ -246,8 +306,11 @@ public class ItemSentientBow extends ItemBow implements IMultiWillTool//, IMeshP //Need to do some stuffs // ItemArrow itemarrow = ((ItemArrow) (itemstack.getItem() instanceof ItemArrow ? itemstack.getItem() : Items.arrow)); // EntityArrow entityArrow = itemarrow.createArrow(world, itemstack, player); + + double amount = (this.getDropOfActivatedBow(stack) * world.rand.nextDouble() + this.getStaticDropOfActivatedBow(stack)); + float newArrowVelocity = arrowVelocity * getVelocityOfArrow(stack); - EntitySentientArrow entityArrow = new EntitySentientArrow(world, entityLiving, type); + EntitySentientArrow entityArrow = new EntitySentientArrow(world, entityLiving, type, amount); entityArrow.setAim(player, player.rotationPitch, player.rotationYaw, 0.0F, newArrowVelocity, 1.0F); if (newArrowVelocity == 0) diff --git a/src/main/java/WayofTime/bloodmagic/util/handler/event/WillHandler.java b/src/main/java/WayofTime/bloodmagic/util/handler/event/WillHandler.java index e6baf03a..e55e6ecc 100644 --- a/src/main/java/WayofTime/bloodmagic/util/handler/event/WillHandler.java +++ b/src/main/java/WayofTime/bloodmagic/util/handler/event/WillHandler.java @@ -1,13 +1,9 @@ package WayofTime.bloodmagic.util.handler.event; -import WayofTime.bloodmagic.annot.Handler; -import WayofTime.bloodmagic.api.soul.*; -import WayofTime.bloodmagic.demonAura.PosXY; -import WayofTime.bloodmagic.demonAura.WillChunk; -import WayofTime.bloodmagic.demonAura.WorldDemonWillHandler; -import WayofTime.bloodmagic.entity.projectile.EntitySentientArrow; -import WayofTime.bloodmagic.registry.ModItems; -import WayofTime.bloodmagic.registry.ModPotions; +import java.util.HashMap; +import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; + import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityItem; @@ -17,36 +13,49 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.potion.PotionEffect; import net.minecraft.util.DamageSource; +import net.minecraft.util.EntityDamageSourceIndirect; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.ChunkPos; import net.minecraft.world.EnumDifficulty; +import net.minecraftforge.event.entity.living.LivingDeathEvent; import net.minecraftforge.event.entity.living.LivingDropsEvent; -import net.minecraftforge.event.entity.living.LivingHurtEvent; import net.minecraftforge.event.entity.player.EntityItemPickupEvent; import net.minecraftforge.event.world.ChunkDataEvent; import net.minecraftforge.fml.common.eventhandler.Event; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; - -import java.util.HashMap; -import java.util.List; -import java.util.concurrent.CopyOnWriteArrayList; +import WayofTime.bloodmagic.annot.Handler; +import WayofTime.bloodmagic.api.soul.DemonWillHolder; +import WayofTime.bloodmagic.api.soul.EnumDemonWillType; +import WayofTime.bloodmagic.api.soul.IDemonWill; +import WayofTime.bloodmagic.api.soul.IDemonWillWeapon; +import WayofTime.bloodmagic.api.soul.PlayerDemonWillHandler; +import WayofTime.bloodmagic.demonAura.PosXY; +import WayofTime.bloodmagic.demonAura.WillChunk; +import WayofTime.bloodmagic.demonAura.WorldDemonWillHandler; +import WayofTime.bloodmagic.entity.projectile.EntitySentientArrow; +import WayofTime.bloodmagic.registry.ModItems; +import WayofTime.bloodmagic.registry.ModPotions; @Handler -public class WillHandler { +public class WillHandler +{ private final HashMap serverTicks = new HashMap(); // Adds Will to player @SubscribeEvent - public void onItemPickup(EntityItemPickupEvent event) { + public void onItemPickup(EntityItemPickupEvent event) + { ItemStack stack = event.getItem().getEntityItem(); - if (stack != null && stack.getItem() instanceof IDemonWill) { + if (stack != null && stack.getItem() instanceof IDemonWill) + { EntityPlayer player = event.getEntityPlayer(); ItemStack remainder = PlayerDemonWillHandler.addDemonWill(player, stack); - if (remainder == null || ((IDemonWill) stack.getItem()).getWill(stack) < 0.0001 || PlayerDemonWillHandler.isDemonWillFull(EnumDemonWillType.DEFAULT, player)) { + if (remainder == null || ((IDemonWill) stack.getItem()).getWill(stack) < 0.0001 || PlayerDemonWillHandler.isDemonWillFull(EnumDemonWillType.DEFAULT, player)) + { stack.stackSize = 0; event.setResult(Event.Result.ALLOW); } @@ -54,12 +63,17 @@ public class WillHandler { } @SubscribeEvent - public void onEntityAttacked(LivingHurtEvent event) + public void onEntityAttacked(LivingDeathEvent event) { - Entity sourceEntity = event.getSource().getEntity(); + if (event.getSource() instanceof EntityDamageSourceIndirect) + { + Entity sourceEntity = ((EntityDamageSourceIndirect) event.getSource()).getSourceOfDamage(); - if (sourceEntity instanceof EntitySentientArrow) - ((EntitySentientArrow) sourceEntity).reimbursePlayer(); + if (sourceEntity instanceof EntitySentientArrow) + { + ((EntitySentientArrow) sourceEntity).reimbursePlayer(event.getEntityLiving(), event.getEntityLiving().getMaxHealth()); + } + } } // Add/Drop Demon Will for Player