From 9768909eb8a24097fe965e53efa0ee0b56e62965 Mon Sep 17 00:00:00 2001 From: WayofTime Date: Sat, 9 Apr 2016 15:35:02 -0400 Subject: [PATCH] Fixed it so the sentient bow actually shoots sentient arrows. --- .../entity/RenderEntitySentientArrow.java | 21 +++++++++++++++++-- .../projectile/EntitySentientArrow.java | 11 +++++++--- .../bloodmagic/item/soul/ItemSentientBow.java | 4 ++++ 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/src/main/java/WayofTime/bloodmagic/client/render/entity/RenderEntitySentientArrow.java b/src/main/java/WayofTime/bloodmagic/client/render/entity/RenderEntitySentientArrow.java index 94af8862..ee35fc89 100644 --- a/src/main/java/WayofTime/bloodmagic/client/render/entity/RenderEntitySentientArrow.java +++ b/src/main/java/WayofTime/bloodmagic/client/render/entity/RenderEntitySentientArrow.java @@ -18,7 +18,11 @@ import WayofTime.bloodmagic.entity.projectile.EntitySentientArrow; @SideOnly(Side.CLIENT) public class RenderEntitySentientArrow extends Render { - private static final ResourceLocation arrowTextures = new ResourceLocation("bloodmagic:textures/entities/soulArrow.png"); + private static final ResourceLocation defaultTexture = new ResourceLocation("bloodmagic:textures/entities/soulArrow.png"); + private static final ResourceLocation corrosiveTexture = new ResourceLocation("bloodmagic:textures/entities/soulArrow_corrosive.png"); + private static final ResourceLocation vengefulTexture = new ResourceLocation("bloodmagic:textures/entities/soulArrow_vengeful.png"); + private static final ResourceLocation destructiveTexture = new ResourceLocation("bloodmagic:textures/entities/soulArrow_destructive.png"); + private static final ResourceLocation steadfastTexture = new ResourceLocation("bloodmagic:textures/entities/soulArrow_steadfast.png"); public RenderEntitySentientArrow(RenderManager renderManagerIn) { @@ -95,6 +99,19 @@ public class RenderEntitySentientArrow extends Render */ protected ResourceLocation getEntityTexture(EntitySentientArrow entity) { - return arrowTextures; + switch (entity.type) + { + case CORROSIVE: + return corrosiveTexture; + case DESTRUCTIVE: + return destructiveTexture; + case STEADFAST: + return steadfastTexture; + case VENGEFUL: + return vengefulTexture; + case DEFAULT: + default: + return defaultTexture; + } } } \ No newline at end of file diff --git a/src/main/java/WayofTime/bloodmagic/entity/projectile/EntitySentientArrow.java b/src/main/java/WayofTime/bloodmagic/entity/projectile/EntitySentientArrow.java index cc16c60b..577869bf 100644 --- a/src/main/java/WayofTime/bloodmagic/entity/projectile/EntitySentientArrow.java +++ b/src/main/java/WayofTime/bloodmagic/entity/projectile/EntitySentientArrow.java @@ -7,12 +7,14 @@ import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; +import WayofTime.bloodmagic.api.Constants; import WayofTime.bloodmagic.api.soul.EnumDemonWillType; import WayofTime.bloodmagic.api.soul.PlayerDemonWillHandler; public class EntitySentientArrow extends EntityArrow { public double reimbursedAmountOnHit = 0; + public EnumDemonWillType type = EnumDemonWillType.DEFAULT; public EntitySentientArrow(World worldIn) { @@ -24,10 +26,11 @@ public class EntitySentientArrow extends EntityArrow super(worldIn, x, y, z); } - public EntitySentientArrow(World worldIn, EntityLivingBase shooter, double reimbursement) + public EntitySentientArrow(World worldIn, EntityLivingBase shooter, EnumDemonWillType type) { - this(worldIn, shooter.posX, shooter.posY, shooter.posZ); - this.reimbursedAmountOnHit = reimbursement; + super(worldIn, shooter); + this.reimbursedAmountOnHit = 0; + this.type = type; } public void reimbursePlayer() @@ -44,6 +47,7 @@ public class EntitySentientArrow extends EntityArrow super.writeEntityToNBT(tag); tag.setDouble("reimbursement", reimbursedAmountOnHit); + tag.setString(Constants.NBT.WILL_TYPE, type.toString()); } @Override @@ -52,6 +56,7 @@ public class EntitySentientArrow extends EntityArrow super.readEntityFromNBT(tag); reimbursedAmountOnHit = tag.getDouble("reimbursement"); + type = EnumDemonWillType.valueOf(tag.getString(Constants.NBT.WILL_TYPE)); } @Override diff --git a/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientBow.java b/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientBow.java index c26c9cf3..b5bafb89 100644 --- a/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientBow.java +++ b/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientBow.java @@ -26,6 +26,7 @@ import WayofTime.bloodmagic.api.iface.IMultiWillTool; import WayofTime.bloodmagic.api.soul.EnumDemonWillType; import WayofTime.bloodmagic.api.soul.PlayerDemonWillHandler; import WayofTime.bloodmagic.api.util.helper.NBTHelper; +import WayofTime.bloodmagic.entity.projectile.EntitySentientArrow; import WayofTime.bloodmagic.registry.ModItems; public class ItemSentientBow extends ItemBow implements IMultiWillTool//, IMeshProvider @@ -182,9 +183,12 @@ public class ItemSentientBow extends ItemBow implements IMultiWillTool//, IMeshP if (!worldIn.isRemote) { + EnumDemonWillType type = this.getCurrentType(stack); + //Need to do some stuffs ItemArrow itemarrow = ((ItemArrow) (itemstack.getItem() instanceof ItemArrow ? itemstack.getItem() : Items.arrow)); EntityArrow entityarrow = itemarrow.createArrow(worldIn, itemstack, entityplayer); + entityarrow = new EntitySentientArrow(worldIn, entityLiving, type); entityarrow.func_184547_a(entityplayer, entityplayer.rotationPitch, entityplayer.rotationYaw, 0.0F, arrowVelocity * 3.0F, 1.0F); if (arrowVelocity == 1.0F)