diff --git a/src/main/java/com/zivilon/cinder_loe/CinderLoE.java b/src/main/java/com/zivilon/cinder_loe/CinderLoE.java index f8b8022..d79d3ed 100644 --- a/src/main/java/com/zivilon/cinder_loe/CinderLoE.java +++ b/src/main/java/com/zivilon/cinder_loe/CinderLoE.java @@ -285,6 +285,7 @@ public class CinderLoE { public static Item pallandoStaff; public static Item alatarStaff; public static Item sarumanStaff; + public static Item sarumanWhiteStaff; // Relics public static Item welfRelic; @@ -379,6 +380,7 @@ public class CinderLoE { //Misc EntityRegistry.registerModEntity(EntityWarDart.class, "WarDart", (entityID + 44), this, 64, 1, true); EntityRegistry.registerModEntity(SarumanFireball.class, "SarumanFireball", entityID + 0, this, 64, 10, true); + EntityRegistry.registerModEntity(SarumanWhiteFireball.class, "SarumanWhiteFireball", entityID + 61, this, 64, 10, true); EntityRegistry.registerModEntity(LOTREntitySauron.class, "LOTREntitySauron", (entityID + 28), this, 64, 1, true); EntityRegistry.registerModEntity(UtumnoSlaveTrader.class, "UtumnoSlaveTrader", (entityID + 30), this, 64, 1, true); @@ -555,6 +557,7 @@ public class CinderLoE { pallandoStaff = (new PallandoStaff()).setUnlocalizedName("lotr:pallandoStaff").setTextureName("lotr:pallandoStaff"); alatarStaff = (new AlatarStaff()).setUnlocalizedName("lotr:alatarStaff").setTextureName("lotr:alatarStaff"); sarumanStaff = (new SarumanStaff()).setUnlocalizedName("lotr:sarumanStaff").setTextureName("lotr:sarumanStaff"); + sarumanWhiteStaff = (new SarumanWhiteStaff()).setUnlocalizedName("lotr:sarumanWhiteStaff").setTextureName("lotr:sarumanStaff"); // Relics welfRelic = (new WoodElfRelic()).setUnlocalizedName("lotr:welfRelic").setTextureName("lotr:welfRelic"); unitLevelTool = (new unitLevelTool()).setUnlocalizedName("lotr:unitLevelTool").setTextureName("stick"); @@ -621,11 +624,13 @@ public class CinderLoE { ItemRegistration.register(pallandoStaff, "pallandoStaff", 6701); ItemRegistration.register(alatarStaff, "alatarStaff", 6702); ItemRegistration.register(sarumanStaff, "sarumanStaff", 6703); + ItemRegistration.register(sarumanWhiteStaff, "sarumanWhiteStaff", 6705); linkLOTRWeapon(radagastStaff, "radagastStaff"); linkLOTRWeapon(pallandoStaff, "pallandoStaff"); linkLOTRWeapon(alatarStaff, "alatarStaff"); linkLOTRWeapon(sarumanStaff, "sarumanStaff"); + linkLOTRWeapon(sarumanWhiteStaff, "sarumanWhiteStaff"); //Relics ItemRegistration.register(welfRelic, "welfRelic", 6704); @@ -961,6 +966,7 @@ public class CinderLoE { RenderingRegistry.registerEntityRenderingHandler(CorruptSkeletonArcher.class, new RenderCorruptSkeleton()); RenderingRegistry.registerEntityRenderingHandler(SarumanFireball.class, new RenderSarumanFireball()); + RenderingRegistry.registerEntityRenderingHandler(SarumanWhiteFireball.class, new RenderSarumanWhiteFireball()); RenderingRegistry.registerEntityRenderingHandler(Renegade.class, new RenderRenegade()); RenderingRegistry.registerEntityRenderingHandler(RenegadeCaptain.class, new RenderRenegade()); RenderingRegistry.registerEntityRenderingHandler(Wraith.class, new RenderWraith()); @@ -1192,6 +1198,7 @@ public class CinderLoE { CinderCore.registerItemFallback(Item.getIdFromItem(pallandoStaff), Item.getIdFromItem(LOTRMod.gandalfStaffWhite), "cinder_loe", "1.0"); CinderCore.registerItemFallback(Item.getIdFromItem(alatarStaff), Item.getIdFromItem(LOTRMod.gandalfStaffWhite), "cinder_loe", "1.0"); CinderCore.registerItemFallback(Item.getIdFromItem(sarumanStaff), Item.getIdFromItem(LOTRMod.gandalfStaffWhite), "cinder_loe", "1.0"); + CinderCore.registerItemFallback(Item.getIdFromItem(sarumanWhiteStaff), Item.getIdFromItem(LOTRMod.gandalfStaffWhite), "cinder_loe", "1.4"); // == Relics == CinderCore.registerItemFallback(Item.getIdFromItem(welfRelic), Item.getIdFromItem(LOTRMod.rhinoHorn), "cinder_loe", "1.2"); // == Specials == @@ -1263,6 +1270,7 @@ public class CinderLoE { CinderCore.registerEntityFallback(CorruptOrc.class, LOTREntityGundabadOrc.class, "cinder_loe", "1.2.3"); CinderCore.registerEntityFallback(SarumanFireball.class, LOTREntityGandalfFireball.class, "cinder_loe", "1.0"); + CinderCore.registerEntityFallback(SarumanWhiteFireball.class, LOTREntityGandalfFireball.class, "cinder_loe", "1.4"); CinderCore.registerEntityFallback(Renegade.class, LOTREntityBandit.class, "cinder_loe", "1.0"); CinderCore.registerEntityFallback(RenegadeCaptain.class, LOTREntityBandit.class, "cinder_loe", "1.1"); CinderCore.registerEntityFallback(Wraith.class, LOTREntityMarshWraith.class, "cinder_loe", "1.0"); diff --git a/src/main/java/com/zivilon/cinder_loe/client/render/RenderSarumanWhiteFireball.java b/src/main/java/com/zivilon/cinder_loe/client/render/RenderSarumanWhiteFireball.java new file mode 100644 index 0000000..ec581ab --- /dev/null +++ b/src/main/java/com/zivilon/cinder_loe/client/render/RenderSarumanWhiteFireball.java @@ -0,0 +1,50 @@ +package com.zivilon.cinder_loe.client.render; + +import lotr.client.LOTRClientProxy; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.entity.Render; +import net.minecraft.entity.Entity; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; + +import com.zivilon.cinder_loe.entity.SarumanWhiteFireball; + +public class RenderSarumanWhiteFireball extends Render { + public static final ResourceLocation particlesTexture = new ResourceLocation("cinder_loe:misc/particles.png"); + + protected ResourceLocation getEntityTexture(Entity entity) { + return particlesTexture; + } + + public void doRender(Entity entity, double d, double d1, double d2, float f, float f1) { + GL11.glPushMatrix(); + GL11.glTranslatef((float)d, (float)d1, (float)d2); + GL11.glEnable(32826); + bindEntityTexture(entity); + Tessellator tessellator = Tessellator.instance; + drawSprite(tessellator, 32 + ((SarumanWhiteFireball)entity).animationTick); + GL11.glDisable(32826); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glPopMatrix(); + } + + private void drawSprite(Tessellator tessellator, int index) { + float f = (index % 8 * 16 + 0) / 128.0F; + float f1 = (index % 8 * 16 + 16) / 128.0F; + float f2 = (index / 8 * 16 + 0) / 128.0F; + float f3 = (index / 8 * 16 + 16) / 128.0F; + float f4 = 1.0F; + float f5 = 0.5F; + float f6 = 0.25F; + GL11.glRotatef(180.0F - this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(-this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 1.0F, 0.0F); + tessellator.setBrightness(15728880); + tessellator.addVertexWithUV((0.0F - f5), (0.0F - f6), 0.0D, f, f3); + tessellator.addVertexWithUV((f4 - f5), (0.0F - f6), 0.0D, f1, f3); + tessellator.addVertexWithUV((f4 - f5), (f4 - f6), 0.0D, f1, f2); + tessellator.addVertexWithUV((0.0F - f5), (f4 - f6), 0.0D, f, f2); + tessellator.draw(); + } +} \ No newline at end of file diff --git a/src/main/java/com/zivilon/cinder_loe/coremod/LOTRWeaponLinker.java b/src/main/java/com/zivilon/cinder_loe/coremod/LOTRWeaponLinker.java index 75f95db..469b3de 100644 --- a/src/main/java/com/zivilon/cinder_loe/coremod/LOTRWeaponLinker.java +++ b/src/main/java/com/zivilon/cinder_loe/coremod/LOTRWeaponLinker.java @@ -20,7 +20,7 @@ public class LOTRWeaponLinker implements IClassTransformer { // Can add any number of items, append with comma return addLinks(basicClass, "spearRedDwarf", "crossbowRedDwarf", "swordRedDwarf", "battleaxeRedDwarf", "pikeRedDwarf", "daggerRedDwarf", "daggerRedDwarfPoisoned", "hammerRedDwarf", - "radagastStaff", "alatarStaff", "pallandoStaff", "sarumanStaff", "maceWarlord", + "radagastStaff", "alatarStaff", "pallandoStaff", "sarumanStaff", "maceWarlord", "sarumanWhiteStaff", "spearLimwaith", "tridentLimwaith", "daggerLimwaith", "daggerLimwaithPoisoned", "truncheonLimwaith", "battleaxeLimwaith", "blowgunLimwaith", "frostblade", "spearsolidgold", "whip", "spearUnnamed", "welfRelic", "daggerVoid", "swordBree", diff --git a/src/main/java/com/zivilon/cinder_loe/entity/SarumanWhiteFireball.java b/src/main/java/com/zivilon/cinder_loe/entity/SarumanWhiteFireball.java new file mode 100644 index 0000000..f1882f2 --- /dev/null +++ b/src/main/java/com/zivilon/cinder_loe/entity/SarumanWhiteFireball.java @@ -0,0 +1,92 @@ +package com.zivilon.cinder_loe.entity; + +import cpw.mods.fml.common.network.simpleimpl.IMessage; + +import lotr.common.LOTRLevelData; +import lotr.common.LOTRMod; +import lotr.common.entity.npc.LOTREntityNPC; +import lotr.common.entity.animal.LOTREntityHorse; +import lotr.common.entity.projectile.LOTREntityGandalfFireball; +import lotr.common.fac.LOTRFaction; +import lotr.common.network.LOTRPacketHandler; +import lotr.common.network.LOTRPacketWeaponFX; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.ai.attributes.IAttributeInstance; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.projectile.EntityThrowable; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.World; + +import java.util.ArrayList; +import java.util.List; + +public class SarumanWhiteFireball extends LOTREntityGandalfFireball { + public SarumanWhiteFireball(World world) { + super(world); + } + + public SarumanWhiteFireball(World world, EntityLivingBase entityliving) { + super(world, entityliving); + } + + public SarumanWhiteFireball(World world, double d, double d1, double d2) { + super(world, d, d1, d2); + } + + protected void onImpact(MovingObjectPosition m) { + if (!this.worldObj.isRemote) + if (m.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { + explode((Entity)null); + } else if (m.typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY) { + Entity entity = m.entityHit; + if (isEntityVulnerable(entity)) + explode(entity); + } + } + + private void explode(Entity target) { + if (this.worldObj.isRemote) + return; + this.worldObj.playSoundAtEntity((Entity)this, "lotr:item.gandalfFireball", 4.0F, (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F); + LOTRPacketWeaponFX packet = new LOTRPacketWeaponFX(LOTRPacketWeaponFX.Type.MACE_SAURON, (Entity)this); + LOTRPacketHandler.networkWrapper.sendToAllAround((IMessage)packet, LOTRPacketHandler.nearEntity((Entity)this, 64.0D)); + if (target != null && isEntityVulnerable(target)) + target.attackEntityFrom(DamageSource.causeMobDamage(getThrower()), 10.0F); + List entities = this.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, this.boundingBox.expand(6.0D, 6.0D, 6.0D)); + if (!entities.isEmpty()) + for (int i = 0; i < entities.size(); i++) { + EntityLivingBase entity = entities.get(i); + if (entity != target && isEntityVulnerable((Entity)entity)) { + float damage = 10.0F - getDistanceToEntity((Entity)entity) * 0.5F; + if (damage > 0.0F) + entity.attackEntityFrom(DamageSource.causeMobDamage(getThrower()), damage); + } + } + setDead(); + } + + private boolean isEntityVulnerable(Entity entity) { + if (entity == getThrower()) + return false; + if (!(entity instanceof EntityLivingBase)) + return false; + if (entity instanceof EntityPlayer) + return (LOTRLevelData.getData((EntityPlayer)entity).getAlignment(LOTRFaction.HIGH_ELF) < 0.0F); + return !LOTRFaction.HIGH_ELF.isGoodRelation(LOTRMod.getNPCFaction(entity)); + } + + protected float func_70182_d() { + return 1.5F; + } + + protected float getGravityVelocity() { + return 0.0F; + } +} \ No newline at end of file diff --git a/src/main/java/com/zivilon/cinder_loe/items/SarumanWhiteStaff.java b/src/main/java/com/zivilon/cinder_loe/items/SarumanWhiteStaff.java new file mode 100644 index 0000000..68984f6 --- /dev/null +++ b/src/main/java/com/zivilon/cinder_loe/items/SarumanWhiteStaff.java @@ -0,0 +1,46 @@ +package com.zivilon.cinder_loe.items; + +import cpw.mods.fml.common.network.simpleimpl.IMessage; +import java.util.List; +import lotr.common.LOTRCreativeTabs; +import lotr.common.LOTRLevelData; +import lotr.common.LOTRMod; +import lotr.common.fac.LOTRFaction; +import lotr.common.network.LOTRPacketHandler; +import lotr.common.network.LOTRPacketWeaponFX; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumAction; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.potion.PotionEffect; +import net.minecraft.potion.Potion; +import net.minecraft.server.MinecraftServer; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; + +import com.zivilon.cinder_loe.items.WizardStaff; +import com.zivilon.cinder_loe.entity.SarumanWhiteFireball; + +public class SarumanWhiteStaff extends WizardStaff { + public SarumanWhiteStaff() { + super(); + } + + public ItemStack onEaten(ItemStack itemstack, World world, EntityPlayer entityplayer) { + entityplayer.swingItem(); + itemstack.damageItem(2, (EntityLivingBase)entityplayer); + world.playSoundAtEntity((Entity)entityplayer, "mob.ghast.fireball", 2.0F, (itemRand.nextFloat() - itemRand.nextFloat()) * 0.2F + 1.0F); + if (!world.isRemote) { + world.spawnEntityInWorld((Entity)new SarumanWhiteFireball(world, (EntityLivingBase)entityplayer)); + LOTRPacketWeaponFX packet = new LOTRPacketWeaponFX(LOTRPacketWeaponFX.Type.MACE_SAURON, (Entity)entityplayer); + LOTRPacketHandler.networkWrapper.sendToAllAround((IMessage)packet, LOTRPacketHandler.nearEntity((Entity)entityplayer, 64.0D)); + } + return itemstack; + } +} \ No newline at end of file diff --git a/src/main/java/com/zivilon/cinder_loe/mixins/MixinEntityLivingBase.java b/src/main/java/com/zivilon/cinder_loe/mixins/MixinEntityLivingBase.java index a566896..66c73be 100644 --- a/src/main/java/com/zivilon/cinder_loe/mixins/MixinEntityLivingBase.java +++ b/src/main/java/com/zivilon/cinder_loe/mixins/MixinEntityLivingBase.java @@ -199,26 +199,23 @@ public abstract class MixinEntityLivingBase extends Entity { @Dynamic private void check_cauldron() { - try { - Class target_class = EntityLivingBase.class; - - while (target_class != null) { - Method[] methods = target_class.getDeclaredMethods(); - - for (Method method : methods) { - if (method.getName().equals("damageEntity_CB")) { - cauldron_method = method; - return; - } - } + try { + Class target_class = EntityLivingBase.class; + Method[] methods = target_class.getDeclaredMethods(); + + for (Method method : methods) { + if (method.getName().equals("damageEntity_CB")) { + cauldron_method = method; + return; } - } catch (Exception e) { - e.printStackTrace(); } - - return; + } catch (Exception e) { + e.printStackTrace(); } + return; +} + @Dynamic public boolean entitydamage_cauldron(DamageSource source, float damage) { boolean return_value = true; diff --git a/src/main/resources/assets/cinder_loe/lang/en_GB.lang b/src/main/resources/assets/cinder_loe/lang/en_GB.lang index 9206c9c..2b6899c 100644 --- a/src/main/resources/assets/cinder_loe/lang/en_GB.lang +++ b/src/main/resources/assets/cinder_loe/lang/en_GB.lang @@ -1,2 +1,3 @@ item.lotr:sarumanStaff.name=Staff of Saruman of Many Colours +item.lotr:sarumanWhiteStaff.name=Staff of Saruman the White item.lotr:boarArmorRedDwarf.name=Red Dwarven Boar Armour diff --git a/src/main/resources/assets/cinder_loe/lang/en_US.lang b/src/main/resources/assets/cinder_loe/lang/en_US.lang index 399e4aa..5c645fd 100644 --- a/src/main/resources/assets/cinder_loe/lang/en_US.lang +++ b/src/main/resources/assets/cinder_loe/lang/en_US.lang @@ -102,6 +102,7 @@ item.lotr:radagastStaff.name=Staff of Radagast the Brown item.lotr:pallandoStaff.name=Staff of Pallando the Blue item.lotr:alatarStaff.name=Staff of Alatar the Blue item.lotr:sarumanStaff.name=Staff of Saruman of Many Colors +item.lotr:sarumanWhiteStaff.name=Staff of Saruman the White item.lotr:welfRelic.name=Horn of the Greenwood Stag diff --git a/src/main/resources/assets/cinder_loe/misc/particles.png b/src/main/resources/assets/cinder_loe/misc/particles.png index 49e035d..4c77142 100644 Binary files a/src/main/resources/assets/cinder_loe/misc/particles.png and b/src/main/resources/assets/cinder_loe/misc/particles.png differ diff --git a/src/main/resources/assets/lotr/textures/items/large/sarumanWhiteStaff.png b/src/main/resources/assets/lotr/textures/items/large/sarumanWhiteStaff.png new file mode 100644 index 0000000..0262cb5 Binary files /dev/null and b/src/main/resources/assets/lotr/textures/items/large/sarumanWhiteStaff.png differ diff --git a/src/main/resources/assets/lotr/textures/items/sarumanWhiteStaff.png b/src/main/resources/assets/lotr/textures/items/sarumanWhiteStaff.png new file mode 100644 index 0000000..c5eb5b8 Binary files /dev/null and b/src/main/resources/assets/lotr/textures/items/sarumanWhiteStaff.png differ