Adding Staff of Saruman the White
							parent
							
								
									cb71d221d3
								
							
						
					
					
						commit
						e497559a0c
					
				| @ -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(); | ||||||
|  |     } | ||||||
|  | } | ||||||
| @ -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<EntityLivingBase> 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; | ||||||
|  |     } | ||||||
|  | } | ||||||
| @ -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; | ||||||
|  |   } | ||||||
|  | } | ||||||
| @ -1,2 +1,3 @@ | |||||||
| item.lotr:sarumanStaff.name=Staff of Saruman of Many Colours | 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 | item.lotr:boarArmorRedDwarf.name=Red Dwarven Boar Armour | ||||||
|  | |||||||
											
												Binary file not shown.
											
										
									
								| Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 7.0 KiB | 
											
												Binary file not shown.
											
										
									
								| After Width: | Height: | Size: 5.4 KiB | 
											
												Binary file not shown.
											
										
									
								| After Width: | Height: | Size: 4.2 KiB | 
					Loading…
					
					
				
		Reference in New Issue