@Override public void onEntityCollidedWithBlock( World par1World, int par2, int par3, int par4, Entity entity) { if (entity.ticksExisted % 3 == 0 && (entity instanceof EntityLiving) && !(entity.ridingEntity instanceof EntityBoat)) { // depth determines strength of hunger and weakness up to 3fold. int intensity = par1World.getBlockMaterial(par2, par3 + 1, par4) == par1World.getBlockMaterial(par2, par3, par4) ? par1World.getBlockMaterial(par2, par3 + 2, par4) == par1World.getBlockMaterial(par2, par3, par4) ? 3 : 2 : 1; EntityLiving entityliving = (EntityLiving) entity; PotionEffect weakness = entityliving.isEntityUndead() ? new PotionEffect(Potion.damageBoost.id, 24, 1) : new PotionEffect(Potion.weakness.id, 24, 1 * intensity); PotionEffect hunger = new PotionEffect(Potion.hunger.id, 6, 8 * intensity); entityliving.addPotionEffect(weakness); entityliving.addPotionEffect(hunger); if (entity instanceof EntityWaterMob && new Random().nextInt(500) < 1) { PotionEffect harm = new PotionEffect(Potion.harm.id, 1, 0); entityliving.addPotionEffect(harm); } } }
@SuppressWarnings("unchecked") @Override protected void onImpact(MovingObjectPosition par1MovingObjectPosition) { if (isExplode) { this.explodeSize = 3.0F; } if (isNuke) { this.explodeSize = 35.0F; } if (par1MovingObjectPosition.entityHit != null) { par1MovingObjectPosition.entityHit.attackEntityFrom( DamageSource.causeThrownDamage(this, this.getThrower()), 2); par1MovingObjectPosition.entityHit.setFire(5); } if (!this.worldObj.isRemote && !isNuke) { this.worldObj.newExplosion( (Entity) null, this.posX, this.posY, this.posZ, explodeSize, onFire, true); this.isDead = true; } else if (!this.worldObj.isRemote && isNuke) { this.worldObj.newExplosion( (Entity) null, this.posX, this.posY, this.posZ, explodeSize, onFire, true); Iterator<EntityLiving> itr = this.worldObj .getEntitiesWithinAABB(EntityLiving.class, this.boundingBox.expand(30, 30, 30)) .iterator(); while (itr.hasNext()) { EntityLiving entity = itr.next(); double dx = Math.abs(entity.posX - this.posX); double dy = Math.abs(entity.posY - this.posY); double dz = Math.abs(entity.posZ - this.posZ); int distance = (int) Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2) + Math.pow(dz, 2)); if (30 - distance >= 0) { entity.addPotionEffect( new PotionEffect(2, (60 + (30 - distance)) * 20, (30 - distance) / 5)); entity.addPotionEffect( new PotionEffect(4, (60 + (30 - distance)) * 20, (30 - distance) / 5)); entity.addPotionEffect( new PotionEffect(18, (60 + (30 - distance)) * 20, (30 - distance) / 5)); entity.addPotionEffect( new PotionEffect(19, (60 + (30 - distance)) * 20, (30 - distance) / 5)); } } this.isDead = true; } }
/** Called when this EntityThrowable hits a block or entity. */ @Override protected void onImpact(MovingObjectPosition mop) { this.spawnParticles(); AxisAlignedBB bb = boundingBox.expand(4.0D, 2.0D, 4.0D); List eList = worldObj.getEntitiesWithinAABB(EntityLiving.class, bb); Iterator i = eList.iterator(); while (i.hasNext()) { EntityLiving e = (EntityLiving) i.next(); e.addPotionEffect(new PotionEffect(Potion.weakness.id, 1200, 0)); e.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 1200, 0)); e.addPotionEffect(new PotionEffect(Potion.poison.id, 1200, 0)); } this.setDead(); }
/** * Triggered whenever an entity collides with this block (enters into the block). Args: world, x, * y, z, entity */ @Override public void onEntityCollidedWithBlock(World par1World, int x, int y, int z, Entity par5Entity) { if (par5Entity instanceof EntityLiving) { if (par5Entity.isInsideOfMaterial(this.blockMaterial)) { ((EntityLiving) par5Entity).addPotionEffect(new PotionEffect(Potion.blindness.id, 20, 2)); } } }
@Override public boolean hitEntity( ItemStack par1ItemStack, EntityLiving par2, EntityLiving par3EntityLiving) { par2.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 20, 50)); // float sizeY = par2. float sizeY = par2.height + 1.0F; float sizeX = par2.width + 1.0F; // float sizeZ = sizeX; for (float y = 0; y <= sizeY; y += 1.0F) { for (float x = 0; x <= sizeX; x += 1.0F) { par2.worldObj.setBlock( (int) (par2.posX + x), (int) (par2.posY + y), (int) par2.posZ, Block.obsidian.blockID); par2.worldObj.setBlock( (int) (par2.posX - x), (int) (par2.posY + y), (int) par2.posZ, Block.obsidian.blockID); } for (float z = 0; z <= sizeX; z += 1.0F) { par2.worldObj.setBlock( (int) par2.posX, (int) (par2.posY + y), (int) (par2.posZ + z), Block.obsidian.blockID); par2.worldObj.setBlock( (int) par2.posX, (int) (par2.posY + y), (int) (par2.posZ - z), Block.obsidian.blockID); } // corners // par2.worldObj.setBlock((int)(par2.posX+sizeX), // (int)(par2.posY+y), (int)(par2.posZ+sizeZ), // Block.obsidian.blockID); // par2.worldObj.setBlock((int)(par2.posX-sizeX), // (int)(par2.posY+y), (int)(par2.posZ-sizeZ), // Block.obsidian.blockID); // par2.worldObj.setBlock((int)(par2.posX+sizeX), // (int)(par2.posY+y), (int)(par2.posZ-sizeZ), // Block.obsidian.blockID); // par2.worldObj.setBlock((int)(par2.posX-sizeX), // (int)(par2.posY+y), (int)(par2.posZ+sizeZ), // Block.obsidian.blockID); // // par2.worldObj.setBlock((int)(par2.posX+sizeX), // (int)(par2.posY+y), (int)(par2.posZ), Block.obsidian.blockID); // par2.worldObj.setBlock((int)(par2.posX), (int)(par2.posY+y), // (int)(par2.posZ+sizeZ), Block.obsidian.blockID); // par2.worldObj.setBlock((int)(par2.posX-sizeX), // (int)(par2.posY+y), (int)(par2.posZ), Block.obsidian.blockID); // par2.worldObj.setBlock((int)(par2.posX), (int)(par2.posY+y), // (int)(par2.posZ-sizeZ), Block.obsidian.blockID); if (y == sizeY) par2.worldObj.setBlock( (int) par2.posX, (int) (par2.posY + y), (int) par2.posZ, Block.obsidian.blockID); } // par2EntityLiving.worldObj.createExplosion(par2EntityLiving, // par2EntityLiving.posX, par2EntityLiving.posY, par2EntityLiving.posZ, // 6.0F, true); return false; }
@Override @SideOnly(Side.CLIENT) public void onEntityCollidedWithBlock( World world, int i, int j, int k, Entity entity) // when an entity steps into the liquid { if (entity instanceof EntityPlayer) { ((EntityPlayer) entity) .addPotionEffect( new PotionEffect( Potion.damageBoost.getId(), 1200, 1)); // allows the potion affect to effect players } if (entity instanceof EntityLiving) { ((EntityLiving) entity) .addPotionEffect( new PotionEffect( Potion.damageBoost.getId(), 1200, 1)); // allows the potion affect to effect mobs } }
@Override public void doPostExplode() { super.doPostExplode(); if (!this.worldObj.isRemote) { if (this.canFocusBeam(this.worldObj, position) && this.thread.isComplete) { /* * Freeze all nearby entities. */ List<EntityLiving> livingEntities = worldObj.getEntitiesWithinAABB( EntityLiving.class, AxisAlignedBB.getBoundingBox( position.xPos - getRadius(), position.yPos - getRadius(), position.zPos - getRadius(), position.xPos + getRadius(), position.yPos + getRadius(), position.zPos + getRadius())); Iterator<EntityLiving> it = livingEntities.iterator(); while (it.hasNext()) { EntityLiving entity = it.next(); entity.addPotionEffect( new CustomPotionEffect(PoisonFrostBite.INSTANCE.getId(), 60 * 20, 1, null)); entity.addPotionEffect(new PotionEffect(Potion.confusion.id, 10 * 20, 2)); entity.addPotionEffect(new PotionEffect(Potion.digSlowdown.id, 120 * 20, 2)); entity.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 120 * 20, 4)); } for (Pos3D targetPosition : this.thread.results) { double distanceFromCenter = position.distance(targetPosition); if (distanceFromCenter > this.getRadius()) continue; /* * Reduce the chance of setting blocks on fire based on distance from center. */ double chance = this.getRadius() - (Math.random() * distanceFromCenter); if (chance > distanceFromCenter * 0.55) { /* * Place down ice blocks. */ Block block = this.worldObj.getBlock( (int) targetPosition.xPos, (int) targetPosition.yPos, (int) targetPosition.zPos); if (block == Blocks.fire || block == Blocks.flowing_lava || block == Blocks.lava) { this.worldObj.setBlock( (int) targetPosition.xPos, (int) targetPosition.yPos, (int) targetPosition.zPos, Blocks.snow, 0, 2); } else if (worldObj.isAirBlock( (int) targetPosition.xPos, (int) targetPosition.yPos, (int) targetPosition.zPos) && this.worldObj.getBlock( (int) targetPosition.xPos, (int) targetPosition.yPos - 1, (int) targetPosition.zPos) != Blocks.ice && !worldObj.isAirBlock( (int) targetPosition.xPos, (int) targetPosition.yPos - 1, (int) targetPosition.zPos)) { this.worldObj.setBlock( (int) targetPosition.xPos, (int) targetPosition.yPos, (int) targetPosition.zPos, Blocks.ice, 0, 2); } } } this.worldObj.playSoundEffect( position.xPos + 0.5D, position.yPos + 0.5D, position.zPos + 0.5D, Reference.PREFIX + "redmatter", 6.0F, (1.0F + (worldObj.rand.nextFloat() - worldObj.rand.nextFloat()) * 0.2F) * 1F); } this.worldObj.setWorldTime(1200); } }