Example #1
0
  @EventHandler
  public void postInit(FMLPostInitializationEvent event) {
    proxy.postInit(event);

    ItemsVC.initTabIcons();
    DynTreeGenerators.initGenerators();

    Recipes.addRecipes();
    EnumAnvilRecipe.registerRecipes();
    EnumCarpentryRecipes.registerRecipes();
  }
  @Override
  public void execute(ICommandSender sender, String[] args) throws CommandException {
    World world = sender.getEntityWorld();
    int chunkX = sender.getPosition().getX() >> 4;
    int chunkZ = sender.getPosition().getZ() >> 4;

    if (args.length == 0) {
      sender.addChatMessage(new ChatComponentText(getCommandUsage(sender)));
      return;
    }

    if (args[0].equals("meteorshower")) {
      VintageCraft.instance.packetPipeline.sendToAll(new StartMeteorShowerPacket(10000));
      MinecraftServer.getServer()
          .getConfigurationManager()
          .sendChatMsg(new ChatComponentText("Something strange is happening in the night sky"));
    }

    if (args[0].equals("moonphase")) {
      int moonphase =
          sender.getEntityWorld().provider.getMoonPhase(sender.getEntityWorld().getWorldTime());

      sender.addChatMessage(new ChatComponentText("" + moonphase));
    }

    if (args[0].equals("time")) {
      sender.addChatMessage(
          new ChatComponentText(
              (Math.floor(sender.getEntityWorld().getTotalWorldTime() / 2400F) / 10f)
                  + " days passed"));
    }

    if (args[0].equals("cow")) {
      EntityCowVC cow = new EntityCowVC(sender.getEntityWorld());
      BlockPos pos = sender.getPosition();
      cow.setLocationAndAngles(
          pos.getX(),
          pos.getY() + 0.5f,
          pos.getZ(),
          sender.getEntityWorld().rand.nextFloat() * 360.0F,
          0.0F);
      world.spawnEntityInWorld(cow);
    }

    if (args[0].equals("sheep")) {
      EntitySheepVC sheep = new EntitySheepVC(sender.getEntityWorld());
      BlockPos pos = sender.getPosition();
      sheep.setLocationAndAngles(
          pos.getX(),
          pos.getY() + 0.5f,
          pos.getZ(),
          sender.getEntityWorld().rand.nextFloat() * 360.0F,
          0.0F);
      world.spawnEntityInWorld(sheep);
    }

    if (args[0].equals("mobcap")) {
      sender.addChatMessage(
          new ChatComponentText(
              EnumCreatureType.MONSTER.getMaxNumberOfCreature()
                  + " max mobs / "
                  + (Math.floor(sender.getEntityWorld().getTotalWorldTime() / 2400F) / 10f)
                  + " days passed"));

      VintageCraftMobTweaker.setSpawnCap(
          EnumCreatureType.MONSTER,
          VintageCraftMobTweaker.spawnCapByDay(
              sender.getEntityWorld().getTotalWorldTime() / 24000L,
              sender.getEntityWorld().getDifficulty()));
    }

    if (args[0].equals("clear")) {
      int wdt = 30;
      int hgt = 80;

      clearArea(sender.getEntityWorld(), sender.getPosition(), wdt, hgt);
    }

    if (args[0].equals("clearwater")) {
      int wdt = 80;
      int hgt = 80;

      clearAreaWater(sender.getEntityWorld(), sender.getPosition(), wdt, hgt);
    }

    if (args[0].equals("clearrock")) {
      int wdt = 100;
      int hgt = 200;
      BlockPos pos = new BlockPos(sender.getPosition().getX(), 0, sender.getPosition().getZ());
      clearAreaRock(sender.getEntityWorld(), pos, wdt, hgt);
      System.out.println("rock cleared");
    }

    if (args[0].equals("replace")) {
      int wdt = 35;
      int hgt = 35;

      replaceBlocks(sender.getPosition(), sender, wdt, hgt, false);
    }
    if (args[0].equals("replaceignoremeta")) {
      int wdt = 35;
      int hgt = 35;

      replaceBlocks(sender.getPosition(), sender, wdt, hgt, true);
    }

    if (args[0].equals("plane")) {
      int wdt = 30;
      int hgt = 30;

      clearArea(sender.getEntityWorld(), sender.getPosition(), wdt, hgt);

      wdt = 80;
      createPlane(
          sender.getEntityWorld(),
          sender.getPosition(),
          80,
          BlocksVC.topsoil
              .getDefaultState()
              .withProperty(BlockTopSoil.organicLayer, EnumOrganicLayer.NORMALGRASS));
    }

    if (args[0].equals("gen")) {
      GsonBuilder builder = new GsonBuilder();
      builder.registerTypeAdapter(IBlockState.class, new BlockStateSerializer());

      Gson gson = builder.create();

      DynTreeGen gen = gson.fromJson(args[1], DynTreeGen.class);

      gen.growTree(sender.getEntityWorld(), sender.getPosition().north());
    }

    if (args[0].equals("cgentree") || args[0].equals("cgenltree") || args[0].equals("cgenptree")) {
      args[0] = args[0].substring(1);
      int wdt = 30;
      int hgt = 80;

      clearArea(sender.getEntityWorld(), sender.getPosition(), wdt, hgt);
    }

    if (args[0].equals("genvillage")) {
      DynVillageGenerators.initGenerators();

      float size = 1f;
      if (args.length >= 2) {
        size = (float) parseDouble(args[1]);
      }

      EnumVillage.DEFAULT
          .getGenerator()
          .generate(sender.getEntityWorld(), sender.getPosition(), size);
    }

    if (args[0].equals("gentree") || args[0].equals("genltree") || args[0].equals("genptree")) {
      float size = 1f;
      float bend = 0f;
      EnumTree tree = EnumTree.SCOTSPINE;

      if (args.length >= 2) {
        tree = tree.valueOf(args[1].toUpperCase(Locale.ROOT));
      }

      if (args.length >= 3) {
        size = (float) parseDouble(args[2]);
      }

      if (args.length == 4) {
        bend = (float) parseDouble(args[3]);
      }

      DynTreeGenerators.initGenerators();

      DynTreeGen gen = tree.defaultGenerator;
      if (args[0].equals("genltree")) gen = tree.lushGenerator;
      if (args[0].equals("genptree")) gen = tree.poorGenerator;

      gen.growTree(sender.getEntityWorld(), sender.getPosition().down().east(3), size);
    }

    if (args[0].equals("genheightmap")) {
      /*GenLayerVC.shouldDraw = true;

      long seed = sender.getEntityWorld().rand.nextInt(50000);
      GenLayerTerrain normalTerrainGen = new GenLayerTerrain(seed + 0);

      ChunkPrimer primer = new ChunkPrimer();
      normalTerrainGen.generateTerrain(0, 0, primer, sender.getEntityWorld());

      GenLayerVC.drawImageGrayScale(256, genlayer, name);

      GenLayerVC.shouldDraw = false;*/
    }

    if (args[0].equals("genlayer")) {
      if (args.length == 1) {
        sender.addChatMessage(new ChatComponentText(getCommandUsage(sender)));
        return;
      }

      long seed = sender.getEntityWorld().rand.nextInt(50000);

      // seed = 1L;

      GenLayerVC.shouldDraw = true;

      if (args[1].equals("climate")) {
        GenLayerVC.genClimate(seed);
      }
      if (args[1].equals("forest")) {
        GenLayerVC.genForest(seed);
      }
      if (args[1].equals("biomes")) {
        GenLayerVC.genErosion(seed);
      }
      if (args[1].equals("deposits")) {
        GenLayerVC.genDeposits(seed);
      }
      if (args[1].equals("age")) {
        GenLayerVC.genAgemap(seed);
      }
      if (args[1].equals("heightmap")) {
        GenLayerVC.genHeightmap(seed);
      }
      if (args[1].equals("noisemod")) {
        GenLayerVC layer = GenLayerVC.genNoiseFieldModifier(seed, -70);
        // GenLayerVC.drawImage(16 * 6, layer.getInts(chunkX-3, chunkZ-3, 16 * 6, 16 * 6),
        // "currentchunknoisemod", 3);
        // GenLayerVC.drawImage(16, layer.getInts(chunkX, chunkZ, 16, 16), "currentchunknoisemod",
        // 3);
      }

      if (args[1].equals("noisemod2")) {
        GenLayerVC.genNoiseFieldModifier(seed, 0);
      }
      if (args[1].equals("rockoffset")) {
        GenLayerVC.genHorizontalRockOffsetMap(seed);
      }

      if (args[1].equals("drainage")) {
        MapGenLakes lakegen = new MapGenLakes();
        lakegen.generate(new Random(), chunkX, chunkZ, world, null, null);
        System.out.println("done");
      }

      GenLayerVC.shouldDraw = false;

      sender.addChatMessage(
          new ChatComponentText("Layers generated with seed " + seed + " to " + getCleanPath()));
    }

    if (args[0].equals("climate")) {
      int climate[] = VCraftWorld.instance.getClimate(sender.getPosition());
      int forest = VCraftWorld.instance.getForest(sender.getPosition());

      sender.addChatMessage(
          new ChatComponentText(
              "Temperature "
                  + climate[0]
                  + ", Rainfall "
                  + climate[2]
                  + ", Fertility "
                  + climate[1]
                  + ", Forest "
                  + forest
                  + ", mod forest "
                  + EnumTree.getForestDensity(255 - forest, climate[2], climate[0])
                  + ", descaled temp "
                  + VCraftWorld.instance.deScaleTemperature(climate[0])));

      EnumFlowerGroup flora =
          EnumFlowerGroup.getRandomFlowerForClimate(
              climate[2], climate[0], forest, sender.getEntityWorld().rand);
      System.out.println("chosen flower " + flora);

      EnumTree tree =
          EnumTree.getRandomTreeForClimate(
              climate[2],
              climate[0],
              forest,
              sender.getPosition().getY(),
              sender.getEntityWorld().rand);
      System.out.println("chosen tree " + tree);
      /*if (flora != null) {
      	sender.getEntityWorld().setBlockState(sender.getPosition(), flora.variants[0].getBlockState());
      }*/
      // System.out.println("tree size " + (0.66f - Math.max(0, (sender.getPosition().getY() * 1f /
      // EnumTree.SCOTSPINE.maxy) - 0.5f)));   //sender.getEntityWorld().rand.nextFloat()/3 -
    }

    if (args[0].equals("reloadgrass")) {
      VCraftWorld.instance.loadTextures(Minecraft.getMinecraft().getResourceManager());
      sender.addChatMessage(new ChatComponentText("reloaded."));
    }

    if (args[0].equals("grasscolor")) {
      sender.addChatMessage(
          new ChatComponentText(
              "#"
                  + Integer.toHexString(
                      VCraftWorld.instance.getGrassColorAtPos(sender.getPosition()))));
    }

    if (args[0].equals("toplayers")) {
      EnumRockType rocktype = EnumRockType.CHERT;

      IBlockState[] states =
          EnumCrustLayerGroup.getTopLayers(
              rocktype, sender.getPosition().down(), sender.getEntityWorld().rand);

      System.out.println(states.length);

      for (IBlockState state : states) {
        System.out.println(state);
      }
    }

    if (args[0].equals("noisegen")) {
      BlockPos pos = sender.getPosition();
      NoiseGeneratorOctaves noiseGen1 = new NoiseGeneratorOctaves(sender.getEntityWorld().rand, 4);
      int xSize = 5;
      int ySize = 17;
      int zSize = 5;

      double horizontalScale = 300D;
      double verticalScale = 300D; // probably horizontal scale

      double noise1[] = new double[0];
      noise1 =
          noiseGen1.generateNoiseOctaves(
              null,
              pos.getX(),
              0,
              pos.getZ(),
              xSize,
              ySize,
              zSize,
              horizontalScale,
              verticalScale,
              horizontalScale);

      // File outFile = new File(name+".bmp");

      for (double num : noise1) {
        System.out.println(num);
      }
    }
  }