Esempio n. 1
0
 @Override
 protected void applyAttackEffectsToEntity(World world, EntityLiving el) {
   double x = el.posX;
   double y = el.posY;
   double z = el.posZ;
   el.clearActivePotions();
   for (int h = 0; h < 5 && !(el instanceof EntityPlayer); h++) {
     ItemStack held = el.getCurrentItemOrArmor(h);
     el.setCurrentItemOrArmor(h, null);
     if (!world.isRemote && held != null) {
       EntityItem ei = new EntityItem(world, x, y, z, held);
       ReikaEntityHelper.addRandomDirVelocity(ei, 0.2);
       ei.delayBeforeCanPickup = 300;
       world.spawnEntityInWorld(ei);
     }
   }
   // ReikaChatHelper.writeEntity(world, el);
   if (el instanceof EntityDragon) {
     ((EntityDragon) el)
         .attackEntityFromPart(
             ((EntityDragon) el).dragonPartHead,
             DamageSource.setExplosionSource(new Explosion(worldObj, this, x, y, z, 20)),
             this.getAttackDamage());
     if (el.isDead || el.getHealth() <= 0) {
       RotaryAchievements.RAILDRAGON.triggerAchievement(gun.getPlacer());
     }
   } else el.attackEntityFrom(DamageSource.generic, this.getAttackDamage());
   if (el instanceof EntityPlayer) {
     if (el.isDead || el.getHealth() <= 0)
       RotaryAchievements.RAILKILLED.triggerAchievement((EntityPlayer) el);
   }
   el.motionX = motionX * power / 15F;
   el.motionY = motionY * power / 15F;
   el.motionZ = motionZ * power / 15F;
 }
 @Override
 protected boolean isValidTarget(Entity ent) {
   if (ent instanceof TargetEntity) return ((TargetEntity) ent).shouldTarget(this, placerUUID);
   if (!(ent instanceof EntityLivingBase)) return false;
   EntityLivingBase elb = (EntityLivingBase) ent;
   if (elb.isDead || elb.getHealth() <= 0) return false;
   if (ent.onGround || ent.isInWater() || ent.isInsideOfMaterial(Material.lava)) return false;
   if (elb instanceof EntityFlying && ReikaEntityHelper.isHostile(elb)) {
     return ReikaMathLibrary.py3d(
             ent.posX - xCoord - 0.5, ent.posY - yCoord - 0.5, ent.posZ - zCoord - 0.5)
         > 2;
   }
   if (ent instanceof EntityBlaze || ent instanceof EntityWither || ent instanceof EntityDragon) {
     return ReikaMathLibrary.py3d(
             ent.posX - xCoord - 0.5, ent.posY - yCoord - 0.5, ent.posZ - zCoord - 0.5)
         > 2;
   }
   if (ent instanceof FlyingMob) {
     FlyingMob fm = (FlyingMob) ent;
     return fm.isCurrentlyFlying()
         && fm.isHostile()
         && ReikaMathLibrary.py3d(
                 ent.posX - xCoord - 0.5, ent.posY - yCoord - 0.5, ent.posZ - zCoord - 0.5)
             > 2;
   }
   if (InterfaceCache.BCROBOT.instanceOf(ent)) {
     return true;
   }
   return false;
 }
Esempio n. 3
0
 private void fire(ItemStack is, World world, EntityPlayer ep, Entity ent) {
   Vec3 look = ep.getLookVec();
   double[] looks = ReikaVectorHelper.getPlayerLookCoords(ep, 2);
   if (!(ent instanceof EntityPlayer) && ReikaWorldHelper.lineOfSight(world, ep, ent)) {
     ItemStack fl = new ItemStack(Item.flint.itemID, 0, 0);
     EntityItem ei =
         new EntityItem(
             world,
             looks[0] / look.lengthVector(),
             looks[1] / look.lengthVector(),
             looks[2] / look.lengthVector(),
             fl);
     ei.delayBeforeCanPickup = 100;
     ei.motionX = look.xCoord / look.lengthVector();
     ei.motionY = look.yCoord / look.lengthVector();
     ei.motionZ = look.zCoord / look.lengthVector();
     if (!world.isRemote) ei.velocityChanged = true;
     if (!world.isRemote) world.playSoundAtEntity(ep, "dig.gravel", 1.5F, 2F);
     world.spawnEntityInWorld(ei);
     if (is.getItemDamage() > 4096) { // approx the 1-hit kill of a 10-heart mob
       ReikaParticleHelper.EXPLODE.spawnAt(world, ent.posX, ent.posY, ent.posZ);
       world.playSoundAtEntity(ent, "random.explode", 1, 1);
     }
     ent.attackEntityFrom(DamageSource.causePlayerDamage(ep), this.getAttackDamage(is));
     ReikaEntityHelper.knockbackEntity(ep, ent, 0.4);
     // ent.setRevengeTarget(ep);
   }
 }
  @Override
  public void onLivingUpdate() {
    super.onLivingUpdate();

    if (!worldObj.isRemote && colorTransitionFraction == 0 && rand.nextInt(400) == 0) {
      EntityBallLightning e = ReikaEntityHelper.getNearestEntityOfSameType(this, 24);
      if (e != null && e.colorTransitionFraction == 0) {
        this.doBolt(e);
        e.onReceiveBolt(this);
      }
    }

    // if (ticksExisted%36 == 0) {
    //	ChromaSounds.POWER.playSound(this, 0.1F, 2F);
    // }

    if (!worldObj.isRemote && rand.nextInt(1600) == 0) {
      if (!CrystalNetworker.instance
          .getNearbyPylons(worldObj, posX, posY, posZ, color, 24, false)
          .isEmpty()) {
        this.heal(this.getMaxHealth());
      }
    }

    if (!worldObj.isRemote) {

      EntityPlayer ep = worldObj.getClosestPlayerToEntity(this, -1);
      if (posY >= 128) {
        this.die();
      } else if (ep == null || worldObj.playerEntities.isEmpty()) {
        this.die();
      } else if (ticksExisted >= 12000 || rand.nextInt(12000 - ticksExisted) == 0) {
        this.die();
      } else if (worldObj.isRaining() && rand.nextInt(80) == 0) {
        this.die();
      } else if (this.getDistanceSqToEntity(ep) >= 65536) {
        this.die();
      } else if (this.getDistanceSqToEntity(ep) >= 1024 && rand.nextInt(200) == 0) {
        this.die();
      }
      // else if (spawnedEntities > 200 && rand.nextInt(spawnedEntities-200) > 0) {
      //	this.die();
      // }
      else if (rand.nextInt(20) == 0) {
        AxisAlignedBB box =
            AxisAlignedBB.getBoundingBox(posX, 0, posZ, posX, 1024, posZ).expand(24, 0, 24);
        List<EntityBallLightning> li = worldObj.getEntitiesWithinAABB(this.getClass(), box);
        if (rand.nextInt(1 + li.size() / 16) > 0) this.die();
      }
    }
  }
 @SubscribeEvent
 public void meatGrinding(LivingDropsEvent ev) {
   if (ev.source instanceof GrinderDamage) {
     ItemStack food = ReikaEntityHelper.getFoodItem(ev.entityLiving);
     ev.drops.clear();
     if (food != null) {
       World world = ev.entityLiving.worldObj;
       Random rand = RotaryCraft.rand;
       int num = 4 + rand.nextInt(4) + rand.nextInt(4) + rand.nextInt(4);
       ItemStack is = ReikaItemHelper.getSizedItemStack(food, num);
       ReikaItemHelper.dropItem(
           world, ev.entityLiving.posX, ev.entityLiving.posY, ev.entityLiving.posZ, is);
     }
     ev.setCanceled(true);
   }
 }
 @Override
 public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity e) {
   TileEntity tile = world.getTileEntity(x, y, z);
   if (tile instanceof TileEntityCrystalPortal && !world.isRemote) {
     TileEntityCrystalPortal te = (TileEntityCrystalPortal) tile;
     if (e instanceof EntityPlayer) {
       if (te.complete) {
         EntityPlayer ep = (EntityPlayer) e;
         if (te.canPlayerUse(ep)) {
           int dim = te.getTargetDimension();
           ReikaEntityHelper.transferEntityToDimension(e, dim, new ChromaTeleporter(dim));
           ProgressStage.DIMENSION.stepPlayerTo(ep);
           ReikaSoundHelper.broadcastSound(
               ChromaSounds.GOTODIM, ChromatiCraft.packetChannel, 1, 1);
         } else {
           this.denyEntity(e);
         }
       } else {
         this.denyEntity(e);
       }
     }
   }
 }
 protected final boolean isMobOrUnlistedPlayer(EntityLivingBase ent) {
   return (ReikaEntityHelper.isHostile(ent)
       || (targetPlayers
           && ent instanceof EntityPlayer
           && !this.playerIsSafe(((EntityPlayer) ent))));
 }
 @SideOnly(Side.CLIENT)
 public void drawTabIcon(RenderItem ri, int x, int y) {
   if (this == BALLLIGHTNING) {
     EntityBallLightning eb = new EntityBallLightning(Minecraft.getMinecraft().theWorld);
     eb.isDead = true;
     GL11.glPushMatrix();
     double d = 8;
     GL11.glTranslated(x + d, y + d, 0);
     double s = 18;
     GL11.glScaled(-s, s, 1);
     ReikaEntityHelper.getEntityRenderer(EntityBallLightning.class).doRender(eb, 0, 0, 0, 0, 0);
     GL11.glPopMatrix();
     return;
   } else if (this == PACKCHANGES) {
     ReikaTextureHelper.bindTerrainTexture();
     ReikaGuiAPI.instance.drawTexturedModelRectFromIcon(
         x, y + 1, ChromaIcons.QUESTION.getIcon(), 16, 14);
     return;
   } else if (this == NODENET) {
     ItemStack is = ThaumItemHelper.BlockEntry.NODEPLACER.getItem();
     GL11.glPushMatrix();
     double s = 2;
     GL11.glTranslated(x - 8, y - 6, 0);
     GL11.glScaled(s, s, 1);
     ReikaGuiAPI.instance.drawItemStack(ri, is, 0, 0);
     GL11.glPopMatrix();
     return;
   } else if (this == APIRECIPES) {
     ArrayList<ItemStack> ico = new ArrayList();
     /*
     if (ModList.THAUMCRAFT.isLoaded()) {
     	ico.add(ThaumItemHelper.BlockEntry.ANCIENTROCK.getItem());
     	ico.add(new ItemStack(ThaumItemHelper.BlockEntry.CRYSTAL.getBlock(), 1, 6));
     	ico.add(ThaumItemHelper.BlockEntry.ETHEREAL.getItem());
     	ico.add(ThaumItemHelper.ItemEntry.NITOR.getItem());
     	ico.add(ThaumItemHelper.ItemEntry.THAUMIUM.getItem());
     	ico.add(ThaumItemHelper.ItemEntry.FABRIC.getItem());
     }
     if (ModList.ROTARYCRAFT.isLoaded()) {
     	ico.add(MachineRegistry.BLASTFURNACE.getCraftedProduct());
     	ico.add(EngineType.AC.getCraftedProduct());
     	ico.add(ItemRegistry.GRAVELGUN.getStackOf());
     }
     if (ModList.REACTORCRAFT.isLoaded()) {
     	ico.add(ReactorTiles.INJECTOR.getCraftedProduct());
     }
     if (ModList.APPENG.isLoaded()) {
     	ico.add(AEApi.instance().blocks().blockController.stack(1));
     	ico.add(AEApi.instance().blocks().blockQuantumLink.stack(1));
     	ico.add(AEApi.instance().blocks().blockQuartzGrowthAccelerator.stack(1));
     }
     if (ModList.FORESTRY.isLoaded()) {
     	ico.add(new ItemStack(ForestryHandler.BlockEntry.HIVE.getBlock()));
     	ico.add(new ItemStack(ForestryHandler.ItemEntry.COMB.getItem()));
     	ico.add(new ItemStack(ForestryHandler.ItemEntry.HONEYDEW.getItem()));
     	ico.add(new ItemStack(ForestryHandler.ItemEntry.QUEEN.getItem()));
     	ico.add(new ItemStack(ForestryHandler.ItemEntry.POLLEN.getItem()));
     }
     if (ModList.FORESTRY.isLoaded()) {
     	ico.add(new ItemStack(ForestryHandler.BlockEntry.HIVE.getBlock()));
     	ico.add(new ItemStack(ForestryHandler.ItemEntry.COMB.getItem()));
     	ico.add(new ItemStack(ForestryHandler.ItemEntry.HONEYDEW.getItem()));
     	ico.add(new ItemStack(ForestryHandler.ItemEntry.QUEEN.getItem()));
     	ico.add(new ItemStack(ForestryHandler.ItemEntry.POLLEN.getItem()));
     }
      */
     for (CastingRecipe cr : RecipesCastingTable.instance.getAllAPIRecipes()) {
       if (!ReikaItemHelper.collectionContainsItemStack(ico, cr.getOutput()))
         ico.add(cr.getOutput());
     }
     if (!ico.isEmpty()) {
       int idx = (int) ((System.currentTimeMillis() / 400) % ico.size());
       ReikaGuiAPI.instance.drawItemStack(ri, ico.get(idx), x, y);
     } else {
       ReikaGuiAPI.instance.drawTexturedModelRectFromIcon(
           x, y, ChromaIcons.NOENTER.getIcon(), 16, 16);
     }
     return;
   }
   ReikaGuiAPI.instance.drawItemStack(ri, this.getTabIcon(), x, y);
 }
 private static EntityRender createCrystalRender() {
   return new EntityRender(
       new EntityChromaEnderCrystal(Minecraft.getMinecraft().theWorld),
       ReikaEntityHelper.getEntityRenderer(EntityEnderCrystal.class));
 }