@Override public void updateEntity(World world, int x, int y, int z, int meta) { super.updateTileEntity(); int temp = (int) (15 * this.getArraySize() * this.getArrayOverallBrightness()); for (int i = -3; i <= 3; i++) { for (int j = -3; j <= 3; j++) { if (ConfigRegistry.BLOCKDAMAGE.getState()) { ReikaWorldHelper.temperatureEnvironment(world, x + i, y + 1, z + j, Math.min(temp, 1750)); if (temp >= 1500) { this.delete(); world.setBlock(x, y, z, Blocks.flowing_lava); } } AxisAlignedBB above = AxisAlignedBB.getBoundingBox(x + i, y + 1, z + j, x + i + 1, y + 2, z + j + 1); List<EntityLivingBase> in = world.getEntitiesWithinAABB(EntityLivingBase.class, above); for (EntityLivingBase e : in) { if (temp > 400) e.setFire(3); } } } if (world.getBlock(x, y - 1, z) == Blocks.air || MachineRegistry.getMachine(world, x, y - 1, z) != this.getMachine()) { // ReikaJavaLibrary.pConsole("TOWER: "+this.getTowerHeight()+"; SIZE: "+this.getArraySize()); this.generatePower(world, x, y, z); } else { write = null; } if (world.getBlock(x, y + 1, z) != Blocks.air) return; mirrorTimer.update(); if (mirrorTimer.checkCap()) { if (solarBlocks.isEmpty()) { lightMultiplier = 0; solarBlocks.recursiveAdd(world, x, y, z, this.getTileEntityBlockID()); numberMirrors = solarBlocks.getSize(); while (solarBlocks.getSize() > 0) { Coordinate c = solarBlocks.getNextAndMoveOn(); MachineRegistry m = MachineRegistry.getMachine(world, c.xCoord, c.yCoord, c.zCoord); if (m == MachineRegistry.MIRROR) { TileEntityMirror te = (TileEntityMirror) world.getTileEntity(c.xCoord, c.yCoord, c.zCoord); te.targetloc = new Coordinate(x, y, z); float light = te.getLightLevel(); lightMultiplier += light; } else numberMirrors--; } lightMultiplier /= 15F; lightMultiplier /= numberMirrors; } } if (write != null) { this.basicPowerReceiver(); } }
@Override public void onUpdate() { ticksExisted++; boolean hit = false; int id = worldObj.getBlockId((int) posX, (int) posY, (int) posZ); MachineRegistry m = MachineRegistry.getMachine(worldObj, posX, posY, posZ); List mobs = worldObj.getEntitiesWithinAABB(EntityLiving.class, this.getBoundingBox().expand(1, 1, 1)); // ReikaJavaLibrary.pConsole("ID: "+id+" and "+mobs.size()+" mobs"); hit = (mobs.size() > 0 || (m != MachineRegistry.RAILGUN && id != 0 && !ReikaWorldHelper.softBlocks(id))); // ReikaJavaLibrary.pConsole(hit+" by "+id+" or mobs "+mobs.size()); if (ReikaWorldHelper.softBlocks(id) && !ReikaMathLibrary.isValueInsideBoundsIncl(8, 11, id) && ConfigRegistry.BLOCKDAMAGE.getState()) ReikaWorldHelper.recursiveBreakWithinSphere( worldObj, (int) posX, (int) posY, (int) posZ, id, -1, (int) posX, (int) posY, (int) posZ, 4); if (hit) { // ReikaChatHelper.write("HIT @ "+ticksExisted+" by "+(mobs.size() > 0)); this.onImpact(null); if (power < 15) this.setDead(); return; } // ReikaChatHelper.write(this.ticksExisted); for (float i = -0.2F; i <= 0.2; i += 0.2F) worldObj.createExplosion(this, posX + i, posY + i, posZ + i, 0F, false); // worldObj.spawnParticle("hugeexplosion", posX, posY, posZ, 0, 0, 0); if (!worldObj.isRemote && (shootingEntity != null && shootingEntity.isDead || !worldObj.blockExists((int) posX, (int) posY, (int) posZ))) this.setDead(); else { if (ticksExisted > 80 && !worldObj.isRemote) this.onImpact(null); this.onEntityUpdate(); Vec3 var15 = worldObj.getWorldVec3Pool().getVecFromPool(posX, posY, posZ); Vec3 var2 = worldObj .getWorldVec3Pool() .getVecFromPool(posX + motionX, posY + motionY, posZ + motionZ); MovingObjectPosition var3 = worldObj.rayTraceBlocks(var15, var2); var15 = worldObj.getWorldVec3Pool().getVecFromPool(posX, posY, posZ); var2 = worldObj .getWorldVec3Pool() .getVecFromPool(posX + motionX, posY + motionY, posZ + motionZ); if (var3 != null) var2 = worldObj .getWorldVec3Pool() .getVecFromPool(var3.hitVec.xCoord, var3.hitVec.yCoord, var3.hitVec.zCoord); Entity var4 = null; List var5 = worldObj.getEntitiesWithinAABBExcludingEntity( this, boundingBox.addCoord(motionX, motionY, motionZ).expand(1.0D, 1.0D, 1.0D)); double var6 = 0.0D; for (int var8 = 0; var8 < var5.size(); ++var8) { Entity var9 = (Entity) var5.get(var8); if (var9.canBeCollidedWith() && (!var9.isEntityEqual(shootingEntity))) { float var10 = 0.3F; AxisAlignedBB var11 = var9.boundingBox.expand(var10, var10, var10); MovingObjectPosition var12 = var11.calculateIntercept(var15, var2); if (var12 != null) { double var13 = var15.distanceTo(var12.hitVec); if (var13 < var6 || var6 == 0.0D) { var4 = var9; var6 = var13; } } } } if (var4 != null) var3 = new MovingObjectPosition(var4); if (var3 != null) this.onImpact(var3); posX += motionX; posY += motionY; posZ += motionZ; if (this.isInWater()) { worldObj.createExplosion(this, posX, posY, posZ, 3F, false); for (int var19 = 0; var19 < 4; ++var19) { float var18 = 0.25F; worldObj.spawnParticle( "bubble", posX - motionX * var18, posY - motionY * var18, posZ - motionZ * var18, motionX, motionY, motionZ); } } this.setPosition(posX, posY, posZ); } }
public boolean makeBeam( World world, int x, int y, int z, int metadata, int step, int id, int maxdist) { boolean value = false; if (ConfigRegistry.BLOCKDAMAGE.getState()) { if (id == Block.stone.blockID || id == Block.cobblestone.blockID || id == Block.stoneBrick.blockID || id == Block.sandStone.blockID) { int chance = (int) ((power - MINPOWER) / (1024 * step * 32)); chance = ReikaMathLibrary.extrema(chance, 1, "max"); if (rand.nextInt(chance) != 0) if (rand.nextInt(step) == 0) ReikaWorldHelper.legacySetBlockWithNotify( world, x + step * xstep, y + step * ystep, z + step * zstep, Block.lavaMoving.blockID); world.spawnParticle( "lava", x + step * xstep + rand.nextFloat(), y + step * ystep + rand.nextFloat(), z + step * zstep + rand.nextFloat(), 0, 0, 0); } if (id == Block.sand.blockID) { int chance = (int) ((power - MINPOWER) / (1024 * step * 16)); chance = ReikaMathLibrary.extrema(chance, 1, "max"); if (rand.nextInt(chance) != 0) if (rand.nextInt(step) == 0) ReikaWorldHelper.legacySetBlockWithNotify( world, x + step * xstep, y + step * ystep, z + step * zstep, Block.glass.blockID); } if (id == Block.gravel.blockID) { int chance = (int) ((power - MINPOWER) / (1024 * step * 16)); chance = ReikaMathLibrary.extrema(chance, 1, "max"); if (rand.nextInt(chance) != 0) if (rand.nextInt(step) == 0) ReikaWorldHelper.legacySetBlockWithNotify( world, x + step * xstep, y + step * ystep, z + step * zstep, Block.cobblestone.blockID); } /* if (id == Block.netherrack.blockID) { if (world.getBlockId(x+step*xstep, 1+y+step*ystep, z+step*zstep) == 0) { ReikaWorldHelper.legacySetBlockWithNotify(world, x+step*xstep, 1+y+step*ystep, z+step*zstep, Block.fire.blockID); } }*/ if (id == Block.netherrack.blockID && tickcount >= 6) { world.newExplosion( null, x + step * xstep + 0.5, y + step * ystep + 0.5, z + step * zstep + 0.5, 3F, true, true); if (step >= 500) RotaryAchievements.NETHERHEATRAY.triggerAchievement(this.getPlacer()); step = maxdist; value = true; } if (id == Block.dirt.blockID || id == Block.tilledField.blockID) { int chance = (int) ((power - MINPOWER) / (1024 * step * 16)); chance = ReikaMathLibrary.extrema(chance, 1, "max"); if (rand.nextInt(chance) != 0) if (rand.nextInt(step) == 0) ReikaWorldHelper.legacySetBlockWithNotify( world, x + step * xstep, y + step * ystep, z + step * zstep, Block.sand.blockID); } if (id == Block.grass.blockID || id == Block.mycelium.blockID) { int chance = (int) ((power - MINPOWER) / (1024 * step * 16)); chance = ReikaMathLibrary.extrema(chance, 1, "max"); if (rand.nextInt(chance) != 0) if (rand.nextInt(step) == 0) ReikaWorldHelper.legacySetBlockWithNotify( world, x + step * xstep, y + step * ystep, z + step * zstep, Block.dirt.blockID); } if (id == Block.ice.blockID || id == Block.blockSnow.blockID) { int chance = (int) ((power - MINPOWER) / (1024 * step * 4)); chance = ReikaMathLibrary.extrema(chance, 1, "max"); if (rand.nextInt(chance) != 0) if (rand.nextInt(step) == 0) ReikaWorldHelper.legacySetBlockWithNotify( world, x + step * xstep, y + step * ystep, z + step * zstep, Block.waterMoving.blockID); } if (id == Block.tallGrass.blockID || id == Block.web.blockID || id == Block.plantYellow.blockID || id == Block.snow.blockID || id == Block.plantRed.blockID || id == Block.mushroomRed.blockID || id == Block.mushroomBrown.blockID || id == Block.deadBush.blockID || id == Block.crops.blockID || id == 142 || id == 141 || id == Block.vine.blockID || id == Block.melonStem.blockID || id == Block.pumpkinStem.blockID || id == Block.waterlily.blockID) { int chance = (int) ((power - MINPOWER) / (1024 * step * 2)); chance = ReikaMathLibrary.extrema(chance, 1, "max"); if (rand.nextInt(chance) != 0) if (rand.nextInt(step) == 0) { ReikaWorldHelper.legacySetBlockWithNotify( world, x + step * xstep, y + step * ystep, z + step * zstep, 0); if (id == Block.snow.blockID) world.playSoundEffect( x + step * xstep + 0.5D, y + step * ystep + 0.5D, z + step * zstep + 0.5D, "random.fizz", 0.5F, 2.6F + (rand.nextFloat() - rand.nextFloat()) * 0.8F); } } if (id == Block.waterMoving.blockID || id == Block.waterStill.blockID) { // ModLoader.getMinecraftInstance().thePlayer.addChatMessage(String.format("%d", id)); int chance = (int) ((power - MINPOWER) / (1024 * step * 2)); chance = ReikaMathLibrary.extrema(chance, 1, "max"); if (rand.nextInt(chance) != 0) if (rand.nextInt(step) == 0) { ReikaWorldHelper.legacySetBlockWithNotify( world, x + step * xstep, y + step * ystep, z + step * zstep, 0); world.playSoundEffect( x + step * xstep + 0.5D, y + step * ystep + 0.5D, z + step * zstep + 0.5D, "random.fizz", 0.5F, 2.6F + (rand.nextFloat() - rand.nextFloat()) * 0.8F); } } if (id == Block.tnt.blockID) { ReikaWorldHelper.legacySetBlockWithNotify( world, x + step * xstep, y + step * ystep, z + step * zstep, 0); EntityTNTPrimed var6 = new EntityTNTPrimed( world, x + step * xstep + 0.5D, y + step * ystep + 0.5D, z + step * zstep + 0.5D, null); world.spawnEntityInWorld(var6); world.playSoundAtEntity(var6, "random.fuse", 1.0F, 1.0F); world.spawnParticle( "lava", x + step * xstep + rand.nextFloat(), y + step * ystep + rand.nextFloat(), z + step * zstep + rand.nextFloat(), 0, 0, 0); } /* if (id == 0) { if (world.getBlockId(x+step*xstep, -1+y+step*ystep, z+step*zstep) == Block.netherrack.blockID) { ReikaWorldHelper.legacySetBlockWithNotify(world, x+step*xstep, y+step*ystep, z+step*zstep, Block.fire.blockID); } }*/ } return value; }
@Override public void onImpact(MovingObjectPosition mov) { if (mov != null && MachineRegistry.getMachine(worldObj, mov.blockX, mov.blockY, mov.blockZ) == MachineRegistry.RAILGUN) { this.setDead(); return; } if (isDead) return; World world = worldObj; double x = posX; double y = posY; double z = posZ; int x0 = (int) x; int y0 = (int) y; int z0 = (int) z; EntityLiving el; Entity ent; // ReikaChatHelper.writeCoords(world, x, y, z); // ReikaChatHelper.writeBlockAtCoords(world, x0, y0, z0); world.spawnParticle("hugeexplosion", x0, y0, z0, 0, 0, 0); for (int i = -3; i <= 3; i++) { for (int j = -3; j <= 3; j++) { for (int k = -3; k <= 3; k++) { if (i * j * k < 9 && i * j * k > -9) { if (ConfigRegistry.BLOCKDAMAGE.getState()) { int id = world.getBlockId(x0 + i, y0 + j, z0 + k); if (ReikaWorldHelper.softBlocks(id) && !ReikaWorldHelper.isLiquidSourceBlock(worldObj, x0 + i, y0 + j, z0 + k)) ReikaWorldHelper.recursiveBreakWithinSphere( world, x0 + i, y0 + j, z0 + k, id, -1, x0 + i, y0 + j, z0 + k, 5); if (power >= 1) { ReikaWorldHelper.recursiveBreakWithinSphere( world, x0 + i, y0 + j, z0 + k, Block.leaves.blockID, -1, x0 + i, y0 + j, z0 + k, 5); ReikaWorldHelper.recursiveBreakWithinSphere( world, x0 + i, y0 + j, z0 + k, Block.plantRed.blockID, -1, x0 + i, y0 + j, z0 + k, 5); ReikaWorldHelper.recursiveBreakWithinSphere( world, x0 + i, y0 + j, z0 + k, Block.plantYellow.blockID, -1, x0 + i, y0 + j, z0 + k, 5); ReikaWorldHelper.recursiveBreakWithinSphere( world, x0 + i, y0 + j, z0 + k, Block.reed.blockID, -1, x0 + i, y0 + j, z0 + k, 5); ReikaWorldHelper.recursiveBreakWithinSphere( world, x0 + i, y0 + j, z0 + k, Block.waterlily.blockID, -1, x0 + i, y0 + j, z0 + k, 5); ReikaWorldHelper.recursiveBreakWithinSphere( world, x0 + i, y0 + j, z0 + k, Block.mushroomBrown.blockID, -1, x0 + i, y0 + j, z0 + k, 5); ReikaWorldHelper.recursiveBreakWithinSphere( world, x0 + i, y0 + j, z0 + k, Block.mushroomRed.blockID, -1, x0 + i, y0 + j, z0 + k, 5); ReikaWorldHelper.recursiveBreakWithinSphere( world, x0 + i, y0 + j, z0 + k, Block.sapling.blockID, -1, x0 + i, y0 + j, z0 + k, 5); ReikaWorldHelper.recursiveBreakWithinSphere( world, x0 + i, y0 + j, z0 + k, Block.web.blockID, -1, x0 + i, y0 + j, z0 + k, 5); ReikaWorldHelper.recursiveBreakWithinSphere( world, x0 + i, y0 + j, z0 + k, Block.cactus.blockID, -1, x0 + i, y0 + j, z0 + k, 5); ReikaWorldHelper.recursiveBreakWithinSphere( world, x0 + i, y0 + j, z0 + k, Block.flowerPot.blockID, -1, x0 + i, y0 + j, z0 + k, 5); } if (power >= 2) { ReikaWorldHelper.recursiveBreakWithinSphere( world, x0 + i, y0 + j, z0 + k, Block.glass.blockID, -1, x0 + i, y0 + j, z0 + k, 5); ReikaWorldHelper.recursiveBreakWithinSphere( world, x0 + i, y0 + j, z0 + k, Block.thinGlass.blockID, -1, x0 + i, y0 + j, z0 + k, 5); ReikaWorldHelper.recursiveBreakWithinSphere( world, x0 + i, y0 + j, z0 + k, Block.glowStone.blockID, -1, x0 + i, y0 + j, z0 + k, 5); ReikaWorldHelper.recursiveBreakWithinSphere( world, x0 + i, y0 + j, z0 + k, Block.mushroomCapRed.blockID, -1, x0 + i, y0 + j, z0 + k, 5); ReikaWorldHelper.recursiveBreakWithinSphere( world, x0 + i, y0 + j, z0 + k, Block.mushroomCapBrown.blockID, -1, x0 + i, y0 + j, z0 + k, 5); ReikaWorldHelper.recursiveBreakWithinSphere( world, x0 + i, y0 + j, z0 + k, Block.ladder.blockID, -1, x0 + i, y0 + j, z0 + k, 5); ReikaWorldHelper.recursiveBreakWithinSphere( world, x0 + i, y0 + j, z0 + k, Block.signPost.blockID, -1, x0 + i, y0 + j, z0 + k, 5); ReikaWorldHelper.recursiveBreakWithinSphere( world, x0 + i, y0 + j, z0 + k, Block.signWall.blockID, -1, x0 + i, y0 + j, z0 + k, 5); } if (power >= 3) { ReikaWorldHelper.recursiveBreakWithinSphere( world, x0 + i, y0 + j, z0 + k, Block.wood.blockID, -1, x0 + i, y0 + j, z0 + k, 5); ReikaWorldHelper.recursiveBreakWithinSphere( world, x0 + i, y0 + j, z0 + k, Block.planks.blockID, -1, x0 + i, y0 + j, z0 + k, 5); ReikaWorldHelper.recursiveBreakWithinSphere( world, x0 + i, y0 + j, z0 + k, Block.fence.blockID, -1, x0 + i, y0 + j, z0 + k, 5); ReikaWorldHelper.recursiveBreakWithinSphere( world, x0 + i, y0 + j, z0 + k, Block.cloth.blockID, -1, x0 + i, y0 + j, z0 + k, 5); ReikaWorldHelper.recursiveBreakWithinSphere( world, x0 + i, y0 + j, z0 + k, Block.workbench.blockID, -1, x0 + i, y0 + j, z0 + k, 5); ReikaWorldHelper.recursiveBreakWithinSphere( world, x0 + i, y0 + j, z0 + k, Block.doorWood.blockID, -1, x0 + i, y0 + j, z0 + k, 5); ReikaWorldHelper.recursiveBreakWithinSphere( world, x0 + i, y0 + j, z0 + k, Block.netherrack.blockID, -1, x0 + i, y0 + j, z0 + k, 5); } if (power >= 4) { ReikaWorldHelper.recursiveBreakWithinSphere( world, x0 + i, y0 + j, z0 + k, Block.sand.blockID, -1, x0 + i, y0 + j, z0 + k, 5); ReikaWorldHelper.recursiveBreakWithinSphere( world, x0 + i, y0 + j, z0 + k, Block.gravel.blockID, -1, x0 + i, y0 + j, z0 + k, 5); ReikaWorldHelper.recursiveBreakWithinSphere( world, x0 + i, y0 + j, z0 + k, Block.blockClay.blockID, -1, x0 + i, y0 + j, z0 + k, 5); ReikaWorldHelper.recursiveBreakWithinSphere( world, x0 + i, y0 + j, z0 + k, Block.slowSand.blockID, -1, x0 + i, y0 + j, z0 + k, 5); } if (power >= 3) { // ReikaWorldHelper.recursiveBreakWithinSphere(world, x0+i, y0+j, z0+k, // Block.grass.blockID, -1, x0+i, y0+j, z0+k, 5); // ReikaWorldHelper.recursiveFillWithinSphere(world, x0+i, y0+j-7, z0+k, // Block.grass.blockID, -1, Block.dirt.blockID, 0, x0+i, y0+j-7, z0+k, 5); if (id == Block.grass.blockID) { if (power >= 5) { Block.blocksList[id].dropBlockAsItem(world, x0 + i, y0 + j, z0 + k, 0, 0); ReikaWorldHelper.legacySetBlockWithNotify(world, x0 + i, y0 + j, z0 + k, 0); } else ReikaWorldHelper.legacySetBlockWithNotify( world, x0 + i, y0 + j, z0 + k, Block.dirt.blockID); } world.markBlockForUpdate(x0 + i, y0 + j, z0 + k); if (id == Block.dirt.blockID) { int meta = world.getBlockMetadata(x0 + i, y0 + j, z0 + k); if (meta >= 3 || (meta > 3 - (power - 6) && power > 6)) { Block.blocksList[id].dropBlockAsItem(world, x0 + i, y0 + j, z0 + k, 0, 0); ReikaWorldHelper.legacySetBlockWithNotify(world, x0 + i, y0 + j, z0 + k, 0); } else ReikaWorldHelper.legacySetBlockMetadataWithNotify( world, x0 + i, y0 + j, z0 + k, meta + 1); } } if (power >= 5) { if (id == Block.stone.blockID) { int meta = world.getBlockMetadata(x0 + i, y0 + j, z0 + k); if (meta >= 2 || (meta > 2 - (power - 8) && power > 8)) { if (power <= 12) ReikaWorldHelper.legacySetBlockWithNotify( world, x0 + i, y0 + j, z0 + k, Block.cobblestone.blockID); else { Block.blocksList[id].dropBlockAsItem(world, x0 + i, y0 + j, z0 + k, 0, 0); ReikaWorldHelper.legacySetBlockWithNotify(world, x0 + i, y0 + j, z0 + k, 0); } } else ReikaWorldHelper.legacySetBlockMetadataWithNotify( world, x0 + i, y0 + j, z0 + k, meta + 1); } if (id == Block.cobblestone.blockID || id == Block.cobblestoneWall.blockID || id == Block.cobblestoneMossy.blockID) { int meta = world.getBlockMetadata(x0 + i, y0 + j, z0 + k); if (meta >= 3 || (meta > 3 - (power - 8) && power > 8)) { Block.blocksList[id].dropBlockAsItem(world, x0 + i, y0 + j, z0 + k, 0, 0); ReikaWorldHelper.legacySetBlockWithNotify(world, x0 + i, y0 + j, z0 + k, 0); } else ReikaWorldHelper.legacySetBlockMetadataWithNotify( world, x0 + i, y0 + j, z0 + k, meta + 1); } } if (power == 14) { for (int n = 1; n < Block.blocksList.length; n++) { if (Block.blocksList[n] != null && n != MachineRegistry.RAILGUN.getBlockID() && ReikaMathLibrary.isValueOutsideBounds(7, 11, n)) { ReikaWorldHelper.recursiveBreakWithinSphere( world, x0 + i, y0 + j, z0 + k, n, -1, x0 + i, y0 + j, z0 + k, 3); } } } if (power == 15) { for (int n = 1; n < Block.blocksList.length; n++) { if (Block.blocksList[n] != null && n != MachineRegistry.RAILGUN.getBlockID() && ReikaMathLibrary.isValueOutsideBounds(7, 11, n)) { ReikaWorldHelper.recursiveBreakWithinSphere( world, x0 + i, y0 + j, z0 + k, n, -1, x0 + i, y0 + j, z0 + k, 6); } } } } AxisAlignedBB splash = AxisAlignedBB.getBoundingBox(x, y, z, x, y, z).expand(3, 3, 3); // world.createExplosion(this, x, y, z, 3F, false); List dmgd = world.getEntitiesWithinAABB(Entity.class, splash); for (int l = 0; l < dmgd.size(); l++) { ent = (Entity) dmgd.get(l); if (ent instanceof EntityLiving) { el = (EntityLiving) ent; this.applyAttackEffectsToEntity(world, el); } else if (ent instanceof EntityEnderCrystal || ent instanceof EntityPainting || ent instanceof EntityItemFrame) // Will not target but will destroy ent.attackEntityFrom(DamageSource.generic, this.getAttackDamage()); } } for (int m = 0; m < 2; m++) { world.spawnParticle( "lava", x - 1 + 2 * rand.nextFloat() + i, y - 1.5 + rand.nextFloat() + j, z - 1 + 2 * rand.nextFloat() + k, 0, 0, 0); } } } } this.setDead(); // ent.attackEntityFrom(DamageSource.outOfWorld, el.getHealth()*(1+el.getTotalArmorValue())); }