public void performEffect(EntityLivingBase p_76394_1_, int p_76394_2_) { if (this.id == REGENERATION.id) { if (p_76394_1_.getHealth() < p_76394_1_.getMaxHealth()) { p_76394_1_.heal(1.0F); } } else if (this.id == POISON.id) { if (p_76394_1_.getHealth() > 1.0F) { p_76394_1_.attackEntityFrom(DamageSource.magic, 1.0F); } } else if (this.id == WITHER.id) { p_76394_1_.attackEntityFrom(DamageSource.wither, 1.0F); } else if (this.id == HUNGER.id && p_76394_1_ instanceof EntityPlayer) { ((EntityPlayer) p_76394_1_).addExhaustion(0.025F * (float) (p_76394_2_ + 1)); } else if (this.id == SATURATION.id && p_76394_1_ instanceof EntityPlayer) { if (!p_76394_1_.worldObj.isRemote) { ((EntityPlayer) p_76394_1_).getFoodStats().addStats(p_76394_2_ + 1, 1.0F); } } else if ((this.id != INSTANT_HEALTH.id || p_76394_1_.isEntityUndead()) && (this.id != INSTANT_DAMAGE.id || !p_76394_1_.isEntityUndead())) { if (this.id == INSTANT_DAMAGE.id && !p_76394_1_.isEntityUndead() || this.id == INSTANT_HEALTH.id && p_76394_1_.isEntityUndead()) { p_76394_1_.attackEntityFrom(DamageSource.magic, (float) (6 << p_76394_2_)); } } else { p_76394_1_.heal((float) Math.max(4 << p_76394_2_, 0)); } }
public void func_180793_a( Entity p_180793_1_, Entity p_180793_2_, EntityLivingBase p_180793_3_, int p_180793_4_, double p_180793_5_) { int var7; if ((this.id != INSTANT_HEALTH.id || p_180793_3_.isEntityUndead()) && (this.id != INSTANT_DAMAGE.id || !p_180793_3_.isEntityUndead())) { if (this.id == INSTANT_DAMAGE.id && !p_180793_3_.isEntityUndead() || this.id == INSTANT_HEALTH.id && p_180793_3_.isEntityUndead()) { var7 = (int) (p_180793_5_ * (double) (6 << p_180793_4_) + 0.5D); if (p_180793_1_ == null) { p_180793_3_.attackEntityFrom(DamageSource.magic, (float) var7); } else { p_180793_3_.attackEntityFrom( DamageSource.causeIndirectMagicDamage(p_180793_1_, p_180793_2_), (float) var7); } } } else { var7 = (int) (p_180793_5_ * (double) (4 << p_180793_4_) + 0.5D); p_180793_3_.heal((float) var7); } }
/** * Current implementations of this method in child classes do not use the entry argument beside * ev. They just raise the damage on the stack. */ public boolean hitEntity( ItemStack par1ItemStack, EntityLivingBase par2EntityLivingBase, EntityLivingBase par3EntityLivingBase) { if (tool == 4 || tool == 5) { NBTTagCompound tag = par1ItemStack.getTagCompound(); this.currentCharge = tag.getInteger("CurrentCharge"); if (this.currentCharge >= 24) { this.currentCharge -= 24; tag.setInteger("CurrentCharge", this.currentCharge); int extra = this.doModuleHitAdditions(par2EntityLivingBase, par3EntityLivingBase); par2EntityLivingBase.attackEntityFrom( DamageSource.magic, 20 + extra); // /2 because its steel not the best material return false; } return false; } else { NBTTagCompound tag = par1ItemStack.getTagCompound(); this.currentCharge = tag.getInteger("CurrentCharge"); if (this.currentCharge >= 48) { this.currentCharge -= 48; tag.setInteger("CurrentCharge", this.currentCharge); int extra = this.doModuleHitAdditions(par2EntityLivingBase, par3EntityLivingBase); par2EntityLivingBase.attackEntityFrom( DamageSource.magic, 12 + extra / 2); // /2 because its steel not the best material return false; } return false; } }
private void doBolt(EntityBallLightning other) { Vec3 vec = ReikaVectorHelper.getVec2Pt(posX, posY, posZ, other.posX, other.posY, other.posZ); // EntityGluon g = new EntityGluon(this, other); // worldObj.spawnEntityInWorld(g); targetColor = other.color; ReikaPacketHelper.sendDataPacket( ChromatiCraft.packetChannel, ChromaPackets.GLUON.ordinal(), new DimensionTarget(worldObj), this.getEntityId(), other.getEntityId()); double len = vec.lengthVector(); for (double i = 0; i < len; i += 0.0625) { double dx = posX - i * vec.xCoord / len; double dy = posY - i * vec.yCoord / len; double dz = posZ - i * vec.zCoord / len; if (worldObj.isRemote) this.gluonParticles(other, dx, dy, dz, (float) (i / len)); if (ChromaOptions.HOSTILEFOREST.getState()) { AxisAlignedBB box = AxisAlignedBB.getBoundingBox(dx, dy, dz, dx, dy, dz).expand(0.5, 0.5, 0.5); List<EntityLivingBase> elb = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, box); for (EntityLivingBase e : elb) { e.attackEntityFrom(DamageSource.generic, isPylonSpawn ? 4 : 1); } } } }
@Override public void doSpellCasterEffect(EntityPlayer caster) { final int radius = 10; caster.worldObj.playSoundAtEntity(caster, "mob.enderdragon.wings", 1.0F, 1.0F); for (final Object obj : caster.worldObj.getEntitiesWithinAABBExcludingEntity( caster, AxisAlignedBB.getBoundingBox( caster.posX - radius, caster.posY - 3, caster.posZ - radius, caster.posX + radius, caster.posY + 3, caster.posZ + radius))) { if (obj instanceof EntityLivingBase) { final EntityLivingBase entity = (EntityLivingBase) obj; entity.attackEntityFrom(DamageSource.causeIndirectMagicDamage(caster, entity), 0.0F); double deltaX = entity.posX - caster.posX; double deltaZ; for (deltaZ = entity.posZ - caster.posZ; deltaX * deltaX + deltaZ * deltaZ < 1.0E-4D; deltaZ = (Math.random() - Math.random()) * 0.01D) { deltaX = (Math.random() - Math.random()) * 0.01D; } for (int i = 0; i < 10; i++) { entity.knockBack(caster, 10.0F, deltaX * -1, deltaZ * -1); } } } }
@Override public boolean hitEntity(ItemStack stack, EntityLivingBase victim, EntityLivingBase player) { if (player.worldObj.isRemote) return true; if (victim instanceof EntityPlayer) { EntityPlayer pvp = (EntityPlayer) victim; if (LudicrousItems.isInfinite(pvp)) { victim.attackEntityFrom( new DamageSourceInfinitySword(player).setDamageBypassesArmor(), 4.0F); return true; } if (pvp.getHeldItem() != null && pvp.getHeldItem().getItem() == LudicrousItems.infinity_sword && pvp.isUsingItem()) return true; } try { stupidMojangProtectedVariable.setInt(victim, 60); } catch (Exception e) { Lumberjack.log(Level.ERROR, e, "The sword isn't reflecting right! Polish it!"); } victim .func_110142_aN() .func_94547_a( new DamageSourceInfinitySword(player), victim.getHealth(), victim.getHealth()); victim.setHealth(0); victim.onDeath(new EntityDamageSource("infinity", player)); return true; }
@Override protected void onImpact(MovingObjectPosition mop) { if (!this.worldObj.isRemote && getThrower() != null) { if (mop.entityHit != null) { Entity ent = mop.entityHit; if (ent instanceof EntityLivingBase) { ((EntityLivingBase) ent) .attackEntityFrom(DamageSource.causeIndirectMagicDamage(getThrower(), ent), this.dmg); if (this.corrosive) { try { ((EntityLivingBase) ent).addPotionEffect(new PotionEffect(Potion.wither.id, 160, 1)); } catch (Exception e) { e.printStackTrace(); } } else { try { ((EntityLivingBase) ent) .addPotionEffect(new PotionEffect(Potion.weakness.id, 160, 1)); } catch (Exception e) { e.printStackTrace(); } } } } this.worldObj.playSoundAtEntity( this, "random.fizz", 0.5F, 2.6F + (this.rand.nextFloat() - this.rand.nextFloat()) * 0.8F); this.ticksExisted = 100; this.worldObj.setEntityState(this, (byte) 16); } setDead(); }
@Override public IMessage onMessage(PacketKurosawaAttack message, MessageContext ctx) { EntityPlayer player = ctx.getServerHandler().playerEntity; Kurosawa item = (Kurosawa) player.getHeldItem().getItem(); if (!item.getCooldown()) { World world = player.worldObj; EntityLivingBase target = (EntityLivingBase) world.getEntityByID(message.targetID); Vec3 targetPos = target.getPositionVector(); Vec3 attackerPos = player.getPositionVector(); Vec3 distance = targetPos.subtractReverse(attackerPos).normalize(); distance = new Vec3(distance.xCoord * 3, distance.yCoord * 3, distance.zCoord * 3); player.setPositionAndRotation( target.posX - distance.xCoord, target.posY - distance.yCoord, target.posZ - distance.zCoord, player.rotationYaw + 180, player.rotationPitch); player.setRotationYawHead(player.rotationYawHead + 180); player.cameraPitch += 180; player.setPositionAndUpdate( target.posX - distance.xCoord, target.posY - distance.yCoord, target.posZ - distance.zCoord); target.attackEntityFrom(DamageSource.causePlayerDamage(player), 44); item.setCooldown(); } return null; }
public boolean tryFireMinigun(EntityLivingBase target) { boolean lastShotOfAmmo = false; if (ammo != null && (pressurizable == null || pressurizable.getPressure(stack) > 0)) { setMinigunTriggerTimeOut(Math.max(10, getMinigunSoundCounter())); if (getMinigunSpeed() == MAX_GUN_SPEED && (!requiresTarget || gunAimedAtTarget)) { if (!requiresTarget) target = raytraceTarget(); lastShotOfAmmo = ammo.attemptDamageItem(1, rand); if (pressurizable != null) pressurizable.addAir(stack, -airUsage); if (target != null) { ItemStack potion = ItemGunAmmo.getPotion(ammo); if (potion != null) { if (rand.nextInt(20) == 0) { List<PotionEffect> effects = Items.potionitem.getEffects(potion); if (effects != null) { for (PotionEffect effect : effects) { target.addPotionEffect(new PotionEffect(effect)); } } } } else { target.attackEntityFrom(DamageSource.causePlayerDamage(player), 4); } } } } return lastShotOfAmmo; }
/** Performs a ranged attack according to the AI's rangedAttackID. */ private void doRangedAttack() { // 43% chance to "miss" int chanceToMiss = entityHost.isPotionActive(Potion.moveSpeed) ? 10 : 43; if (worldObj.rand.nextInt(100) < chanceToMiss) { AMCore.instance.proxy.particleManager.BoltFromPointToPoint( worldObj, entityHost.posX, entityHost.posY + entityHost.getEyeHeight(), entityHost.posZ, attackTarget.posX + worldObj.rand.nextFloat() - 0.5f, attackTarget.posY + attackTarget.getEyeHeight() + worldObj.rand.nextFloat() - 0.5f, attackTarget.posZ + worldObj.rand.nextFloat() - 0.5f, 2, -1); } else { AMCore.instance.proxy.particleManager.BoltFromEntityToEntity( worldObj, entityHost, entityHost, attackTarget, this.damage, 2, -1); float manaDrained = this.manaDrainedPerCasterLevel * ExtendedProperties.For(attackTarget).getMagicLevel(); ExtendedProperties.For(attackTarget) .setCurrentMana(ExtendedProperties.For(attackTarget).getCurrentMana() - (manaDrained)); ExtendedProperties.For(attackTarget).forceSync(); attackTarget.attackEntityFrom( DamageSource.causeIndirectMagicDamage(entityHost, entityHost), this.damage); if (manaDrained > 100) { entityHost.heal(1); if (entityHost.worldObj.difficultySetting == EnumDifficulty.HARD) { attackTarget.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 40, 1, true)); entityHost.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 40, 3, true)); } } } }
@Override public boolean onUse(final EntityPlayer player) { if (player.worldObj.isRemote) { return false; } Entity targetCl = Minecraft.getMinecraft().pointedEntity; Entity targetSr = null; if (targetCl != null) { targetSr = player.worldObj.getEntityByID(targetCl.getEntityId()); } float base = (float) player.getEntityAttribute(SharedMonsterAttributes.attackDamage).getAttributeValue(); float extra = new Random().nextFloat() * 1024 / (2048 - this.getExperience(player)); if (targetSr instanceof EntityLivingBase) { EntityLivingBase entity = (EntityLivingBase) targetSr; if (entity instanceof EntitySlime) { base = Math.min(base / 5, entity.getHealth() - 0.1F); extra = 0F; } entity.attackEntityFrom(DamageSource.causePlayerDamage(player), base); entity.attackEntityFrom(NullaDamageSource.CauseAuroraDamage(player), base * extra); double vx = 0.2D * (entity.posX - player.posX); double vy = 0.2D * (entity.posY - player.posY + 2D); double vz = 0.2D * (entity.posZ - player.posZ); Minecraft.getMinecraft().thePlayer.setVelocity(vx, vy, vz); } else { return false; } if (player.getHeldItem() != null) { player.getHeldItem().damageItem(16, player); } // 随机事件只在服务器发生 if (!player.worldObj.isRemote) { Random rand = new Random(); int exp = rand.nextInt(5) + 1; modifyExperience(player, exp); } return true; }
public void onEntityBlocked(EntityLivingBase entity) { if (this.worldObj.isRemote) { if (PowerNodeRegistry.For(getWorldObj()).checkPower(this, PowerTypes.DARK, 50)) { entity.attackEntityFrom(DamageSource.magic, 5); PowerNodeRegistry.For(getWorldObj()).consumePower(this, PowerTypes.DARK, 50); } } }
/** * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, * world, entityPlayer */ public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) { world.playSoundAtEntity(entityplayer, "morecreeps:firegem", 1.0F, 1.0F); itemstack.damageItem(1, entityplayer); entityplayer.swingItem(); List list = world.getEntitiesWithinAABB( EntityLivingBase.class, new AxisAlignedBB( entityplayer.posX, entityplayer.posY, entityplayer.posZ, entityplayer.posX + 1.0D, entityplayer.posY + 1.0D, entityplayer.posZ + 1.0D) .expand(10D, 10D, 10D)); for (int i = 0; i < list.size(); i++) { Entity entity = (Entity) list.get(i); if (!(entity instanceof EntityLivingBase)) { continue; } EntityLivingBase entityliving = (EntityLivingBase) entity; if ((entityliving instanceof CREEPSEntityHotdog) || (entityliving instanceof CREEPSEntityHunchback) || (entityliving instanceof EntityPlayer) || (entityliving instanceof CREEPSEntityGuineaPig) || (entityliving instanceof CREEPSEntityPreacher)) { continue; } if (world.isRemote) { for (int j = 0; j < 10; j++) { double d = random.nextGaussian() * 0.02D; double d1 = random.nextGaussian() * 0.02D; double d2 = random.nextGaussian() * 0.02D; world.spawnParticle( EnumParticleTypes.SMOKE_NORMAL, entityliving.posX + (double) (random.nextFloat() * 1.5F), entityliving.posY + 0.5D + (double) (random.nextFloat() * 2.5F), entityliving.posZ + (double) (random.nextFloat() * 1.5F), d, d1, d2); } } entityliving.attackEntityFrom(DamageSource.inFire, 2F); entityliving.motionY += 0.5D; entityliving.setFire(15); } return itemstack; }
@Override public void onWornTick(ItemStack stack, EntityLivingBase player) { if (!player.isInvisible()) { player.setInvisible(true); } NBTTagCompound tag = new NBTTagCompound(); ((EntityPlayer) player).writeToNBT(tag); NBTTagCompound forgeTag = tag.getCompoundTag("ForgeData"); int corruption = 0; if (forgeTag.hasKey("MindCorruption")) corruption = forgeTag.getInteger("MindCorruption"); else forgeTag.setInteger("MindCorruption", 0); ((EntityPlayer) player).capabilities.disableDamage = true; if (!player.worldObj.isRemote) { if (corruption <= 0) { ((EntityPlayer) player) .addChatMessage( new ChatComponentText( EMTTextHelper.PURPLE + "You have worn the Ring. Your soul has now been forever " + EMTTextHelper.PURPLE + "tainted. " + EMTTextHelper.RED + EMTTextHelper.ITALIC + "Beware of wearing the ring. The tainting will only " + EMTTextHelper.RED + EMTTextHelper.ITALIC + "increase, and strange things will start happening.")); } else if (corruption > 6000 && corruption < 24000 && random.nextInt(2000) == 0) { player.addPotionEffect(new PotionEffect(Potion.blindness.id, 500, 2, false)); } else if (corruption >= 6000 && corruption < 24000 && random.nextInt(2000) == 0) { player.addPotionEffect(new PotionEffect(Potion.confusion.id, 500, 2, false)); } else if (corruption >= 24000 && corruption < 72000 && random.nextInt(2000) == 0) { ((EntityPlayer) player).capabilities.disableDamage = false; player.attackEntityFrom(DamageSource.magic, 5); } else if (corruption >= 72000 && corruption < 120000 && random.nextInt(4000) == 0) { ((EntityPlayer) player).capabilities.disableDamage = false; player.motionY += 2d; } else if (corruption >= 120000 && random.nextInt(10000) == 0) { ((EntityPlayer) player).capabilities.disableDamage = false; player.addPotionEffect(new PotionEffect(Potion.wither.id, 5000, 4, false)); } else if (corruption + 100 >= Integer.MAX_VALUE) { // =3333333 player.isDead = true; } } forgeTag.setInteger("MindCorruption", ++corruption); tag.setTag("ForgeData", forgeTag); ((EntityPlayer) player).readFromNBT(tag); }
public boolean tryFill( ItemStack stackBase, World world, EntityLivingBase entity, InventoryPlayer inven) { // Stack to use if (world.isRemote) { return false; } ItemStack stack = stackBase; if (stackBase.stackSize > 1) { stack = stackBase.copy(); stack.stackSize = 1; } ItemData data = new ItemData(stack); if (!data.isDirty() && stack.getItemDamage() == 0) { data.fill(entity); if (data.getId() != -1) { world.playSoundAtEntity( entity, "clonecraft:needle.extract", 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + 0.5F); if (!(entity instanceof EntityPlayer) || !((EntityPlayer) entity).capabilities.isCreativeMode) { entity.attackEntityFrom(DamageSource.generic, 2.0f); entity.addPotionEffect(new PotionEffect(Potion.confusion.getId(), 400)); entity.addPotionEffect(new PotionEffect(Potion.weakness.getId(), 400)); } data.save(stack); stack.setItemDamage(1); if (stack != stackBase) { stackBase.stackSize--; CloneCraftHelper.addToInventory(inven, 0, 36, stack); if (stack.stackSize > 0) { CloneCraftHelper.dropAtEntity(entity, stack); } } return true; } } return false; }
@Override protected void performByOwnerOnTarget(EntityLivingBase owner, EntityLivingBase target) { // Reset hurtCD int tempHurtCD = target.hurtResistantTime; target.hurtResistantTime = 0; // Check if target is unfriendly if (!(owner instanceof EntityPlayer) || !BattleClassesUtils.isTargetFriendly((EntityPlayer) owner, target)) { // Get DamageSource from school DamageSource damageSource = BattleClassesDamageSources.createEntityDamageSourceForAbilitySchool( owner, this.getAbilitySchool()); // Attack target by outputValue target.attackEntityFrom(damageSource, getOutputValue()); } // Reset hurtCD target.hurtResistantTime = tempHurtCD; }
@Override public boolean hitEntity(ItemStack itemStack, EntityLivingBase target, EntityLivingBase player) { itemStack.damageItem(1, player); if (hammerType.equals(EnumHammerType.POGO)) { target.motionY = Math.abs(player.motionY) + target.motionY + 0.5; player.motionY = 0; player.fallDistance = 0; } else if (hammerType.equals(EnumHammerType.SCARLET)) target.setFire(50); else if (hammerType.equals(EnumHammerType.POPAMATIC)) target.attackEntityFrom( DamageSource.magic, (float) (player.worldObj.rand.nextInt(6) + 1) * (player.worldObj.rand.nextInt(6) + 1)); else if (hammerType.equals(EnumHammerType.FEARNOANVIL) && player.worldObj.rand.nextGaussian() > 0.9) // Just a suggestion, keep it if you like it. target.addPotionEffect( new PotionEffect( 2, 100, 3)); // Would prefer it being triggered by a critical hit instead, if it can. return true; }
/** Returns true if the item can be used on the given entity, e.g. shears on sheep. */ @Override public boolean itemInteractionForEntity( ItemStack itemStack, EntityPlayer entityPlayer, EntityLivingBase entity) { if (itemStack != null) { onItemRightClick(itemStack, entity.worldObj, entityPlayer); if (NBTHelper.getString(itemStack, "command") != null && NBTHelper.getString(itemStack, "command") == "/kill Entity") { if (entity != null && !entity.worldObj.isRemote) { ChatHelper.send(entityPlayer, "Attempting to damage entity: " + entity.toString()); entity.attackEntityFrom( DamageSource.outOfWorld, Float.MAX_VALUE); // MAKE A NEW DAMAGE SOURCE // entity.setHealth(0.0F); // entity.setDead(); } } } return true; }
@Override public void collideWithEntity(Entity entity) { if (target != null) { if (entity.getUniqueID().compareTo(target.getUniqueID()) == 0) { target.attackEntityFrom(DamageSource.generic, damage); this.getEntityWorld().removeEntity(this); for (int i = 0; i < 80; i++) { Roots.proxy.spawnParticleMagicAuraFX( getEntityWorld(), posX, posY + height / 2.0f, posZ, Math.pow(1.15f * (random.nextFloat() - 0.5f), 3.0), Math.pow(1.15f * (random.nextFloat() - 0.5f), 3.0), Math.pow(1.15f * (random.nextFloat() - 0.5f), 3.0), 76, 230, 0); } } } }
@Override public void updateEntity() { if (worldObj.isRemote) { this.rotation += this.rotationIncrement; } else { surroundingCheckTicks++; } if (worldObj.isRemote || ticksSinceLastEntityScan++ > 25) { updateNearbyEntities(); ticksSinceLastEntityScan = 0; } Iterator<EntityLivingBase> it = cachedEntities.iterator(); while (it.hasNext()) { EntityLivingBase ent = it.next(); if (ent.isDead) { it.remove(); continue; } MovingObjectPosition mop = this.worldObj.rayTraceBlocks( Vec3.createVectorHelper(xCoord + 0.5, yCoord + 1.5, zCoord + 0.5), Vec3.createVectorHelper(ent.posX, ent.posY + ent.getEyeHeight(), ent.posZ), false); if (EntityUtilities.isSummon(ent) || mop != null) { continue; } ent.motionY = 0; ent.motionX = 0; ent.motionZ = 0; double deltaX = this.xCoord + 0.5f - ent.posX; double deltaZ = this.zCoord + 0.5f - ent.posZ; double deltaY = this.yCoord - ent.posY; double angle = Math.atan2(deltaZ, deltaX); double offsetX = Math.cos(angle) * 0.1; double offsetZ = Math.sin(angle) * 0.1; double offsetY = 0.05f; double distanceHorizontal = deltaX * deltaX + deltaZ * deltaZ; double distanceVertical = this.yCoord - ent.posY; boolean spawnedParticles = false; if (distanceHorizontal < 1.3) { if (distanceVertical < -1.5) { if (worldObj.isRemote && worldObj.rand.nextInt(10) < 3) { AMCore.proxy.particleManager.BoltFromPointToPoint( worldObj, xCoord + 0.5, yCoord + 1.3, zCoord + 0.5, ent.posX, ent.posY, ent.posZ, 4, 0x000000); } } if (distanceVertical < -2) { offsetY = 0; if (!worldObj.isRemote) { if (ent.attackEntityFrom(DamageSources.darkNexus, 4)) { if (ent.getHealth() <= 0) { ent.setDead(); float power = ((int) Math.ceil((ent.getMaxHealth() * (ent.ticksExisted / 20)) % 5000)) * this.powerMultiplier; PowerNodeRegistry.For(this.worldObj).insertPower(this, PowerTypes.DARK, power); } } } } } if (worldObj.isRemote) { if (!arcs.containsKey(ent)) { AMLineArc arc = (AMLineArc) AMCore.proxy.particleManager.spawn( worldObj, "textures/blocks/oreblocksunstone.png", xCoord + 0.5, yCoord + 1.3, zCoord + 0.5, ent); if (arc != null) { arc.setExtendToTarget(); arc.setRBGColorF(1, 1, 1); } arcs.put(ent, arc); } Iterator arcIterator = arcs.keySet().iterator(); ArrayList<Entity> toRemove = new ArrayList<Entity>(); while (arcIterator.hasNext()) { Entity arcEnt = (Entity) arcIterator.next(); AMLineArc arc = (AMLineArc) arcs.get(arcEnt); if (arcEnt == null || arcEnt.isDead || arc == null || arc.isDead || new AMVector3(ent).distanceSqTo(new AMVector3(xCoord, yCoord, zCoord)) > 100) toRemove.add(arcEnt); } for (Entity e : toRemove) { arcs.remove(e); } } if (!worldObj.isRemote) ent.moveEntity(offsetX, offsetY, offsetZ); } if (surroundingCheckTicks % 100 == 0) { checkNearbyBlockState(); surroundingCheckTicks = 1; if (!worldObj.isRemote && PowerNodeRegistry.For(this.worldObj).checkPower(this, this.capacity * 0.1f)) { List<EntityPlayer> nearbyPlayers = worldObj.getEntitiesWithinAABB( EntityPlayer.class, AxisAlignedBB.getBoundingBox( this.xCoord - 2, this.yCoord, this.zCoord - 2, this.xCoord + 2, this.yCoord + 3, this.zCoord + 2)); for (EntityPlayer p : nearbyPlayers) { if (p.isPotionActive(BuffList.manaRegen.id)) continue; p.addPotionEffect(new BuffEffectManaRegen(600, 3)); } } // TODO: /*if (rand.nextDouble() < (this.getCharge() / this.getCapacity()) * 0.01){ int maxSev = (int)Math.ceil((this.getCharge() / this.getCapacity()) * 2) + rand.nextInt(2); IllEffectsManager.instance.ApplyRandomBadThing(this, IllEffectSeverity.values()[maxSev], BadThingTypes.DARKNEXUS); }*/ } super.callSuperUpdate(); }
@Override public void updateTask() { EntityLivingBase entitylivingbase = attacker.getAttackTarget(); attacker.getLookHelper().setLookPositionWithEntity(entitylivingbase, 30.0F, 30.0F); if ((longMemory && attacker.getHealth() <= 150 || attacker.getEntitySenses().canSee(entitylivingbase)) && --findAttemptCount <= 0 && attacker.getHealth() <= 150) { findAttemptCount = failedPathFindingPenalty + 4 + attacker.getRNG().nextInt(7); attacker.getNavigator().tryMoveToEntityLiving(entitylivingbase, speedTowardsTarget); if (attacker.getNavigator().getPath() != null) { PathPoint finalPathPoint = attacker.getNavigator().getPath().getFinalPathPoint(); if (finalPathPoint != null && entitylivingbase.getDistanceSq( finalPathPoint.xCoord, finalPathPoint.yCoord, finalPathPoint.zCoord) < 1D) failedPathFindingPenalty = 0; else failedPathFindingPenalty += 10; } else failedPathFindingPenalty += 10; } attackTick = Math.max(attackTick - 1, 0); double d0 = attacker.width * 1F * attacker.width * 1F + entitylivingbase.width; if (attacker.getDistanceSq( entitylivingbase.posX, entitylivingbase.boundingBox.minY, entitylivingbase.posZ) <= d0) if (attackTick <= 0) { attackTick = 10; attacker.attackEntityAsMob(entitylivingbase); entitylivingbase.attackEntityFrom(DamageSource.causeMobDamage(attacker), 4.0F); entitylivingbase.addVelocity( -MathHelper.sin(attacker.rotationYaw * 3.141593F / 180.0F) * 0.5F, 0.1D, MathHelper.cos(attacker.rotationYaw * 3.141593F / 180.0F) * 0.5F); } if (attacker.getDistanceSq( entitylivingbase.posX, entitylivingbase.boundingBox.minY, entitylivingbase.posZ) > d0 + 1D && attacker.getDistanceSq( entitylivingbase.posX, entitylivingbase.boundingBox.minY, entitylivingbase.posZ) < d0 + 256.0D && attacker.getHealth() < 150) if (attackTick <= 0) { ++shouldDo; if (shouldDo == 1) attackTick = 40; else if (shouldDo <= 2) attackTick = 20; else { attackTick = 20; shouldDo = 0; } if (shouldDo == 1) { Vec3 look = attacker.getLookVec(); double direction = Math.toRadians(attacker.renderYawOffset); EntityPoisonJet jet = new EntityPoisonJet(worldObj, attacker); jet.setPosition( attacker.posX + -Math.sin(direction) * 3.5D, attacker.posY + attacker.height * 0.5, attacker.posZ + Math.cos(direction) * 3.5D); jet.motionX = look.xCoord * 1.0; jet.motionY = look.yCoord * 2.2; jet.motionZ = look.zCoord * 1.0; worldObj.spawnEntityInWorld(jet); } } if (attacker.getDistanceSq( entitylivingbase.posX, entitylivingbase.boundingBox.minY, entitylivingbase.posZ) > d0 + 9D && attacker.getDistanceSq( entitylivingbase.posX, entitylivingbase.boundingBox.minY, entitylivingbase.posZ) < d0 + 256.0D && attacker.getHealth() > 150) { if (attackTick <= 0) { ++shouldDo; if (shouldDo == 1) attackTick = 200; else if (shouldDo <= 2) attackTick = 20; else { attackTick = 40; shouldDo = 0; } if (shouldDo == 1) { Vec3 look = attacker.getLookVec(); double direction = Math.toRadians(attacker.renderYawOffset); EntityTarantulaEgg babyEgg = new EntityTarantulaEgg(worldObj, attacker); babyEgg.setPosition( attacker.posX + -Math.sin(direction) * 3.5D, attacker.posY + attacker.height, attacker.posZ + Math.cos(direction) * 3.5D); babyEgg.motionX = look.xCoord * 1.0; babyEgg.motionY = look.yCoord * 2.2; babyEgg.motionZ = look.zCoord * 1.0; worldObj.spawnEntityInWorld(babyEgg); } if (worldObj.rand.nextInt(3) == 1) { attackTick = 30; attacker.motionY = 0.61999998688697815D; jumpAttack = true; } } if (jumpAttack && attacker.motionY == -0.0784000015258789D) { areaOfEffect(); ((EntityTarantulaMiniboss) attacker).spawnBlamParticles(); jumpAttack = false; } } }
@Override public ItemStack onItemRightClick(ItemStack is, World world, EntityPlayer ep) { if (is.getItemDamage() <= 0) { this.noCharge(); return is; } this.warnCharge(is); if (!ReikaPlayerAPI.playerHasOrIsCreative(ep, Block.gravel.blockID, -1)) { if (!world.isRemote) world.playAuxSFX(1001, (int) ep.posX, (int) ep.posY, (int) ep.posZ, 1); return is; } for (float i = 1; i <= 128; i += 0.5) { Vec3 look = ep.getLookVec(); double[] looks = ReikaVectorHelper.getPlayerLookCoords(ep, i); AxisAlignedBB fov = AxisAlignedBB.getBoundingBox( looks[0] - 0.5, looks[1] - 0.5, looks[2] - 0.5, looks[0] + 0.5, looks[1] + 0.5, looks[2] + 0.5); List infov = world.getEntitiesWithinAABB(EntityLivingBase.class, fov); for (int k = 0; k < infov.size(); k++) { EntityLivingBase ent = (EntityLivingBase) infov.get(k); if (!ep.equals(ent) && this.isEntityAttackable(ent) && ReikaWorldHelper.lineOfSight(world, ep, ent)) { double dist = ReikaMathLibrary.py3d(ep.posX - ent.posX, ep.posY - ent.posY, ep.posZ - ent.posZ); double x = ep.posX + look.xCoord; double y = ep.posY + ep.getEyeHeight() + look.yCoord; double z = ep.posZ + look.zCoord; double dx = ent.posX - ep.posX; double dy = ent.posY - ep.posY; double dz = ent.posZ - ep.posZ; if (!world.isRemote) { ItemStack fl = new ItemStack(Item.flint); EntityItem ei = new EntityItem( world, look.xCoord / look.lengthVector() + ep.posX, look.yCoord / look.lengthVector() + ep.posY, look.zCoord / look.lengthVector() + ep.posZ, fl); ei.delayBeforeCanPickup = 100; ei.motionX = dx; ei.motionY = dy + 1; ei.motionZ = dz; // ReikaChatHelper.writeCoords(world, ei.posX, ei.posY, ei.posZ); ei.velocityChanged = true; world.playSoundAtEntity(ep, "dig.gravel", 1.5F, 2F); ei.lifespan = 5; world.spawnEntityInWorld(ei); if (is.getItemDamage() > 4096) { // approx the 1-hit kill of a 10-heart mob // ReikaPacketHelper.sendUpdatePacket(RotaryCraft.packetChannel, // PacketRegistry.GRAVELGUN.getMinValue(), world, (int)ent.posX, (int)ent.posY, // (int)ent.posZ); // world.playSoundAtEntity(ep, "random.explode", 0.25F, 1F); } if (ent instanceof EntityDragon) { EntityDragon ed = (EntityDragon) ent; ed.attackEntityFromPart( ed.dragonPartBody, DamageSource.causePlayerDamage(ep), this.getAttackDamage(is)); } else { int dmg = this.getAttackDamage(is); if (ent instanceof EntityPlayer) { for (int n = 1; n < 5; n++) { ItemRegistry ir = ItemRegistry.getEntry(ent.getCurrentItemOrArmor(n)); if (ir != null) { if (ir.isBedrockArmor()) dmg *= 0.75; } } } ent.attackEntityFrom(DamageSource.causePlayerDamage(ep), dmg); if (dmg >= 500) RotaryAchievements.MASSIVEHIT.triggerAchievement(ep); } if (ent instanceof EntityMob && (ent.isDead || ent.getHealth() <= 0) && ReikaMathLibrary.py3d(ep.posX - ent.posX, ep.posY - ent.posY, ep.posZ - ent.posZ) >= 80) RotaryAchievements.GRAVELGUN.triggerAchievement(ep); } // ReikaWorldHelper.spawnParticleLine(world, x, y, z, ent.posX, ent.posY+ent.height/2, // ent.posZ, "crit", 0, 0, 0, 60); for (float t = 0; t < 2; t += 0.05F) world.spawnParticle("crit", x, y, z, dx / dist * t, dy / dist * t, dz / dist * t); } } if (infov.size() > 0 && !(infov.size() == 1 && infov.get(0) instanceof EntityPlayer)) { if (!ep.capabilities.isCreativeMode) ReikaInventoryHelper.findAndDecrStack( Block.gravel.blockID, -1, ep.inventory.mainInventory); return new ItemStack(is.itemID, is.stackSize, is.getItemDamage() - 1); } } return is; }