Exemplo n.º 1
0
  @Override
  public void postInit(FMLPostInitializationEvent event) {
    super.postInit(event);

    registerModelLocation(Item.getItemFromBlock(BlocksVC.woodenrail), "woodenrail", "inventory");

    registerModelLocation(Item.getItemFromBlock(BlocksVC.saltlamp), "saltlamp", "inventory");

    registerModelLocation(
        Item.getItemFromBlock(BlocksVC.tallmetalmolds), "tallmetalmolds", "inventory");

    registerModelLocation(
        Item.getItemFromBlock(BlocksVC.blastpowdersack), "blastpowdersack", "inventory");

    addVariantNamesFromEnum(
        Item.getItemFromBlock(BlocksVC.stonepot), "vintagecraft:stonepot/", EnumRockType.values());
    registerModelLocation(Item.getItemFromBlock(BlocksVC.stonepot), "stonepot", "inventory");

    registerModelLocation(Item.getItemFromBlock(BlocksVC.toolrack), "toolrack", "inventory");

    addVariantNamesFromEnum(
        Item.getItemFromBlock(BlocksVC.axle), "vintagecraft:axle/", EnumTree.values());
    registerModelLocation(Item.getItemFromBlock(BlocksVC.axle), "axle", "inventory");

    addVariantNamesFromEnum(
        Item.getItemFromBlock(BlocksVC.angledgears),
        "vintagecraft:angledgearbox/",
        EnumTree.values());
    registerModelLocation(
        Item.getItemFromBlock(BlocksVC.angledgears), "angledgearbox", "inventory");

    addVariantNamesFromEnum(
        Item.getItemFromBlock(BlocksVC.windmillrotor),
        "vintagecraft:windmillrotor/",
        EnumTree.values());
    registerModelLocation(
        Item.getItemFromBlock(BlocksVC.windmillrotor), "windmillrotor", "inventory");

    addVariantNamesFromEnum(
        Item.getItemFromBlock(BlocksVC.bellows), "vintagecraft:bellows/", EnumTree.values());
    registerModelLocation(Item.getItemFromBlock(BlocksVC.bellows), "bellows", "inventory");

    addVariantNamesFromEnum(
        Item.getItemFromBlock(BlocksVC.grindstone),
        "vintagecraft:grindstone/",
        EnumRockType.values());
    registerModelLocation(Item.getItemFromBlock(BlocksVC.grindstone), "grindstone", "inventory");

    for (EnumTree treetype : EnumTree.values()) {
      if (treetype.jankahardness > 800) {
        ModelBakery.addVariantName(
            Item.getItemFromBlock(BlocksVC.carpenterTable),
            "vintagecraft:carpentertable/" + treetype.getName());

        for (EnumBucketContents cnt : EnumBucketContents.values()) {
          ModelBakery.addVariantName(
              Item.getItemFromBlock(BlocksVC.woodbucket),
              "vintagecraft:woodbucket/" + treetype.getName() + "-" + cnt.getName());
        }
      }
    }
    registerModelLocation(Item.getItemFromBlock(BlocksVC.woodbucket), "woodbucket", "inventory");
    registerModelLocation(
        Item.getItemFromBlock(BlocksVC.carpenterTable), "carpentertable", "inventory");

    registerModelLocation(ItemsVC.stone, "stone", "inventory");
    registerModelLocation(ItemsVC.seeds, "seeds", "inventory");

    registerModelLocation(ItemsVC.fireclay_ball, "fireclay_ball", "inventory");
    registerModelLocation(ItemsVC.fireclay_brick_raw, "fireclay_brick_raw", "inventory");
    registerModelLocation(ItemsVC.fireclay_brick, "fireclay_brick", "inventory");

    registerModelLocation(ItemsVC.ore, "ore", "inventory");
    registerModelLocation(ItemsVC.metalingot, "ingot", "inventory");

    registerModelLocation(ItemsVC.seeds, "seeds", "inventory");
    registerModelLocation(ItemsVC.dryGrass, "drygrass", "inventory");

    registerModelLocation(ItemsVC.coalpoweredMinecart, "minecart/coalpowered", "inventory");
    registerModelLocation(ItemsVC.emptyMinecart, "minecart/empty", "inventory");

    registerModelLocation(ItemsVC.blastingPowder, "blastingpowder", "inventory");
    registerModelLocation(ItemsVC.flaxFibers, "flaxfibers", "inventory");

    registerModelLocation(ItemsVC.linenCloth, "linencloth", "inventory");
    registerModelLocation(ItemsVC.firestarter, "firestarter", "inventory");
    registerModelLocation(ItemsVC.ironTuyere, "irontuyere", "inventory");
    registerModelLocation(ItemsVC.flaxTwine, "flaxtwine", "inventory");
    registerModelLocation(ItemsVC.stitchedleather, "stitchedleather", "inventory");
    registerModelLocation(ItemsVC.sail, "sail", "inventory");
    registerModelLocation(ItemsVC.peatbrick, "peatbrick", "inventory");

    registerModelLocation(ItemsVC.tools.values().toArray(new Item[0]), "tool", "inventory");
    registerModelLocation(ItemsVC.toolheads.values().toArray(new Item[0]), "toolhead", "inventory");

    registerModelLocation(ItemsVC.anvilbase, "anvilbase", "inventory");
    registerModelLocation(ItemsVC.anvilsurface, "anvilsurface", "inventory");

    registerModelLocation(ItemsVC.armor.values().toArray(new Item[0]), "armor", "inventory");

    registerModelLocation(
        new Item[] {
          ItemsVC.bread,
          ItemsVC.porkchopRaw,
          ItemsVC.porkchopCooked,
          ItemsVC.beefRaw,
          ItemsVC.beefCooked,
          ItemsVC.chickenRaw,
          ItemsVC.chickenCooked
        },
        "food",
        "inventory");

    ClientRegistry.registerTileEntity(TEIngotPile.class, "ingotpile", new TESRIngotPile());
    ClientRegistry.registerTileEntity(TEToolRack.class, "toolrack", new TESRToolRack());
    ClientRegistry.registerTileEntity(TEVessel.class, "ceramicvessel2", new TESRCeramicVessel());
    ClientRegistry.registerTileEntity(TEStonePot.class, "stonepot", new TESRStonePot());
    ClientRegistry.registerTileEntity(TEAxle.class, "axle", new TESRAxle());
    ClientRegistry.registerTileEntity(
        TEAngledGears.class, "angledgearbox", new TESRAngledGearBox());
    ClientRegistry.registerTileEntity(
        TEWindmillRotor.class, "windmillrotor", new TESRWindmillRotor());
    ClientRegistry.registerTileEntity(TEGrindStone.class, "grindstone", new TESRGrindstone());
    ClientRegistry.registerTileEntity(TEBellows.class, "bellows", new TESRBellows());
    ClientRegistry.registerTileEntity(
        TETallMetalMold.class, "tallmetalmold", new TESRTallMetalMold());
    ClientRegistry.registerTileEntity(TEWoodBucket.class, "woodbucket", new TESRWoodBucket());
  }
  @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);
      }
    }
  }