diff --git a/src/main/java/mod/emt/harkenscythe/client/renderers/RenderHSSoul.java b/src/main/java/mod/emt/harkenscythe/client/renderers/RenderHSSoul.java index 5c5d015..5f58167 100644 --- a/src/main/java/mod/emt/harkenscythe/client/renderers/RenderHSSoul.java +++ b/src/main/java/mod/emt/harkenscythe/client/renderers/RenderHSSoul.java @@ -2,7 +2,7 @@ import mod.emt.harkenscythe.HarkenScythe; import mod.emt.harkenscythe.client.models.ModelHSSoul; -import mod.emt.harkenscythe.entities.HSSoul; +import mod.emt.harkenscythe.entities.HSEntitySoul; import net.minecraft.client.model.ModelBase; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.entity.Render; @@ -14,7 +14,7 @@ import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class RenderHSSoul extends Render +public class RenderHSSoul extends Render { private static final ResourceLocation SOUL_TEXTURES = new ResourceLocation(HarkenScythe.MOD_ID, "textures/entities/soul_common.png"); private final ModelBase modelSoul = new ModelHSSoul(); @@ -26,7 +26,7 @@ public RenderHSSoul(RenderManager renderManagerIn) } @Override - public void doRender(HSSoul entity, double x, double y, double z, float entityYaw, float partialTicks) + public void doRender(HSEntitySoul entity, double x, double y, double z, float entityYaw, float partialTicks) { float f = (float) entity.getInnerRotation() + partialTicks; GlStateManager.pushMatrix(); @@ -40,15 +40,15 @@ public void doRender(HSSoul entity, double x, double y, double z, float entityYa } @Override - protected ResourceLocation getEntityTexture(HSSoul entity) + protected ResourceLocation getEntityTexture(HSEntitySoul entity) { return SOUL_TEXTURES; } - public static class Factory implements IRenderFactory + public static class Factory implements IRenderFactory { @Override - public Render createRenderFor(RenderManager manager) + public Render createRenderFor(RenderManager manager) { return new RenderHSSoul(manager); } diff --git a/src/main/java/mod/emt/harkenscythe/entities/HSEntityBlood.java b/src/main/java/mod/emt/harkenscythe/entities/HSEntityBlood.java new file mode 100644 index 0000000..f6383a8 --- /dev/null +++ b/src/main/java/mod/emt/harkenscythe/entities/HSEntityBlood.java @@ -0,0 +1,58 @@ +package mod.emt.harkenscythe.entities; + +import mod.emt.harkenscythe.init.HSItems; +import mod.emt.harkenscythe.items.HSEssenceKeeper; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.SoundEvents; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumHand; +import net.minecraft.util.EnumParticleTypes; +import net.minecraft.util.SoundCategory; +import net.minecraft.world.World; + +public class HSEntityBlood extends HSEntityEssence +{ + public HSEntityBlood(World worldIn) + { + super(worldIn); + } + + @Override + public boolean processInitialInteract(EntityPlayer player, EnumHand hand) + { + ItemStack stack = player.getHeldItem(hand); + Item item = stack.getItem(); + if (item instanceof HSEssenceKeeper) + { + if (!player.capabilities.isCreativeMode) + { + if (item == HSItems.essence_keeper || item == HSItems.essence_vessel) + { + stack.shrink(1); + ItemStack newStack = item == HSItems.essence_keeper ? new ItemStack(HSItems.essence_keeper_blood) : new ItemStack(HSItems.essence_vessel_blood); + newStack.setItemDamage(newStack.getMaxDamage() - 1); + player.setHeldItem(hand, newStack); + } + else if (item == HSItems.essence_keeper_blood || item == HSItems.essence_vessel_blood) + { + if (stack.getItemDamage() == 0) return false; + if (stack.getItemDamage() > 0) + { + stack.setItemDamage(stack.getItemDamage() - 1); + } + if (stack.getItemDamage() <= 0) + { + stack.shrink(1); + ItemStack newStack = item == HSItems.essence_keeper_blood ? new ItemStack(HSItems.essence_keeper_blood) : new ItemStack(HSItems.essence_vessel_blood); + player.setHeldItem(hand, newStack); + } + } + } + this.world.playSound(null, player.getPosition(), SoundEvents.ITEM_BOTTLE_FILL_DRAGONBREATH, SoundCategory.PLAYERS, 1.0F, 1.0F); + this.world.spawnParticle(EnumParticleTypes.CLOUD, this.posX, this.posY + 1.5D, this.posZ, 0.0D, 0.1D, 0.0D); + this.setDead(); + } + return super.processInitialInteract(player, hand); + } +} diff --git a/src/main/java/mod/emt/harkenscythe/entities/HSSoul.java b/src/main/java/mod/emt/harkenscythe/entities/HSEntityEssence.java similarity index 58% rename from src/main/java/mod/emt/harkenscythe/entities/HSSoul.java rename to src/main/java/mod/emt/harkenscythe/entities/HSEntityEssence.java index b4bb58c..f51ecb9 100644 --- a/src/main/java/mod/emt/harkenscythe/entities/HSSoul.java +++ b/src/main/java/mod/emt/harkenscythe/entities/HSEntityEssence.java @@ -3,25 +3,21 @@ import java.util.List; import mod.emt.harkenscythe.init.HSItems; import mod.emt.harkenscythe.init.HSSoundEvents; -import mod.emt.harkenscythe.items.HSEssenceKeeper; import net.minecraft.entity.Entity; import net.minecraft.entity.item.EntityItem; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.SoundEvents; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.EnumHand; import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.SoundCategory; import net.minecraft.world.World; -public class HSSoul extends Entity +public abstract class HSEntityEssence extends Entity { private static final int DESPAWN_TIME = 6000; private int innerRotation; - public HSSoul(World worldIn) + protected HSEntityEssence(World worldIn) { super(worldIn); this.setSize(1.0F, 1.0F); @@ -89,42 +85,4 @@ protected void readEntityFromNBT(NBTTagCompound compound) {} @Override protected void writeEntityToNBT(NBTTagCompound compound) {} - - @Override - public boolean processInitialInteract(EntityPlayer player, EnumHand hand) - { - ItemStack stack = player.getHeldItem(hand); - Item item = stack.getItem(); - if (item instanceof HSEssenceKeeper) - { - if (!player.capabilities.isCreativeMode) - { - if (item == HSItems.essence_keeper || item == HSItems.essence_vessel) - { - stack.shrink(1); - ItemStack newStack = item == HSItems.essence_keeper ? new ItemStack(HSItems.essence_keeper_soul) : new ItemStack(HSItems.essence_vessel_soul); - newStack.setItemDamage(newStack.getMaxDamage() - 1); - player.setHeldItem(hand, newStack); - } - else if (item == HSItems.essence_keeper_soul || item == HSItems.essence_vessel_soul) - { - if (stack.getItemDamage() == 0) return false; - if (stack.getItemDamage() > 0) - { - stack.setItemDamage(stack.getItemDamage() - 1); - } - if (stack.getItemDamage() <= 0) - { - stack.shrink(1); - ItemStack newStack = item == HSItems.essence_keeper_soul ? new ItemStack(HSItems.essence_keeper_soul) : new ItemStack(HSItems.essence_vessel_soul); - player.setHeldItem(hand, newStack); - } - } - } - this.world.playSound(null, player.getPosition(), SoundEvents.ITEM_BOTTLE_FILL_DRAGONBREATH, SoundCategory.PLAYERS, 1.0F, 1.0F); - this.world.spawnParticle(EnumParticleTypes.CLOUD, this.posX, this.posY + 1.5D, this.posZ, 0.0D, 0.1D, 0.0D); - this.setDead(); - } - return super.processInitialInteract(player, hand); - } } diff --git a/src/main/java/mod/emt/harkenscythe/entities/HSEntitySoul.java b/src/main/java/mod/emt/harkenscythe/entities/HSEntitySoul.java new file mode 100644 index 0000000..b570d78 --- /dev/null +++ b/src/main/java/mod/emt/harkenscythe/entities/HSEntitySoul.java @@ -0,0 +1,58 @@ +package mod.emt.harkenscythe.entities; + +import mod.emt.harkenscythe.init.HSItems; +import mod.emt.harkenscythe.items.HSEssenceKeeper; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.SoundEvents; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumHand; +import net.minecraft.util.EnumParticleTypes; +import net.minecraft.util.SoundCategory; +import net.minecraft.world.World; + +public class HSEntitySoul extends HSEntityEssence +{ + public HSEntitySoul(World worldIn) + { + super(worldIn); + } + + @Override + public boolean processInitialInteract(EntityPlayer player, EnumHand hand) + { + ItemStack stack = player.getHeldItem(hand); + Item item = stack.getItem(); + if (item instanceof HSEssenceKeeper) + { + if (!player.capabilities.isCreativeMode) + { + if (item == HSItems.essence_keeper || item == HSItems.essence_vessel) + { + stack.shrink(1); + ItemStack newStack = item == HSItems.essence_keeper ? new ItemStack(HSItems.essence_keeper_soul) : new ItemStack(HSItems.essence_vessel_soul); + newStack.setItemDamage(newStack.getMaxDamage() - 1); + player.setHeldItem(hand, newStack); + } + else if (item == HSItems.essence_keeper_soul || item == HSItems.essence_vessel_soul) + { + if (stack.getItemDamage() == 0) return false; + if (stack.getItemDamage() > 0) + { + stack.setItemDamage(stack.getItemDamage() - 1); + } + if (stack.getItemDamage() <= 0) + { + stack.shrink(1); + ItemStack newStack = item == HSItems.essence_keeper_soul ? new ItemStack(HSItems.essence_keeper_soul) : new ItemStack(HSItems.essence_vessel_soul); + player.setHeldItem(hand, newStack); + } + } + } + this.world.playSound(null, player.getPosition(), SoundEvents.ITEM_BOTTLE_FILL_DRAGONBREATH, SoundCategory.PLAYERS, 1.0F, 1.0F); + this.world.spawnParticle(EnumParticleTypes.CLOUD, this.posX, this.posY + 1.5D, this.posZ, 0.0D, 0.1D, 0.0D); + this.setDead(); + } + return super.processInitialInteract(player, hand); + } +} diff --git a/src/main/java/mod/emt/harkenscythe/events/HSLivingDeathEvent.java b/src/main/java/mod/emt/harkenscythe/events/HSLivingDeathEvent.java index 2e1f24c..01d32e9 100644 --- a/src/main/java/mod/emt/harkenscythe/events/HSLivingDeathEvent.java +++ b/src/main/java/mod/emt/harkenscythe/events/HSLivingDeathEvent.java @@ -1,7 +1,9 @@ package mod.emt.harkenscythe.events; import mod.emt.harkenscythe.HarkenScythe; -import mod.emt.harkenscythe.entities.HSSoul; +import mod.emt.harkenscythe.entities.HSEntityBlood; +import mod.emt.harkenscythe.entities.HSEntitySoul; +import mod.emt.harkenscythe.items.tools.HSGlaive; import mod.emt.harkenscythe.items.tools.HSScythe; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; @@ -23,9 +25,15 @@ public static void onEntityDeath(LivingDeathEvent event) if (!world.isRemote && damageSource.getTrueSource() instanceof EntityPlayer && damageSource.getDamageType().equals("hs_reap")) { EntityPlayer player = (EntityPlayer) event.getSource().getTrueSource(); - if (player.getHeldItemMainhand().getItem() instanceof HSScythe) + if (player.getHeldItemMainhand().getItem() instanceof HSGlaive) { - HSSoul soul = new HSSoul(world); + HSEntityBlood blood = new HSEntityBlood(world); + blood.setPosition(entity.posX, entity.posY, entity.posZ); + world.spawnEntity(blood); + } + else if (player.getHeldItemMainhand().getItem() instanceof HSScythe) + { + HSEntitySoul soul = new HSEntitySoul(world); soul.setPosition(entity.posX, entity.posY, entity.posZ); world.spawnEntity(soul); } diff --git a/src/main/java/mod/emt/harkenscythe/init/HSRegistry.java b/src/main/java/mod/emt/harkenscythe/init/HSRegistry.java index b3095af..f5e79d1 100644 --- a/src/main/java/mod/emt/harkenscythe/init/HSRegistry.java +++ b/src/main/java/mod/emt/harkenscythe/init/HSRegistry.java @@ -5,7 +5,8 @@ import mod.emt.harkenscythe.HarkenScythe; import mod.emt.harkenscythe.client.renderers.RenderHSSoul; import mod.emt.harkenscythe.client.renderers.RenderHSSoulAltar; -import mod.emt.harkenscythe.entities.HSSoul; +import mod.emt.harkenscythe.entities.HSEntityBlood; +import mod.emt.harkenscythe.entities.HSEntitySoul; import mod.emt.harkenscythe.tileentities.HSSoulAltarTE; import net.minecraft.block.Block; import net.minecraft.init.Blocks; @@ -54,12 +55,8 @@ public static void registerEntities(RegistryEvent.Register event) { int id = 1; event.getRegistry().registerAll( - EntityEntryBuilder.create() - .entity(HSSoul.class) - .id(new ResourceLocation(HarkenScythe.MOD_ID, "soul"), id++) - .name("soul") - .tracker(64, 1, true) - .build() + EntityEntryBuilder.create().entity(HSEntityBlood.class).id(new ResourceLocation(HarkenScythe.MOD_ID, "blood"), id++).name("blood").tracker(64, 1, true).build(), + EntityEntryBuilder.create().entity(HSEntitySoul.class).id(new ResourceLocation(HarkenScythe.MOD_ID, "soul"), id++).name("soul").tracker(64, 1, true).build() ); } @@ -83,7 +80,7 @@ public static void registerRecipes() @SubscribeEvent public static void registerEntityRenderers(ModelRegistryEvent event) { - RenderingRegistry.registerEntityRenderingHandler(HSSoul.class, new RenderHSSoul.Factory()); + RenderingRegistry.registerEntityRenderingHandler(HSEntitySoul.class, new RenderHSSoul.Factory()); } @SideOnly(Side.CLIENT)