Esempio n. 1
0
 public static DimensionType register(
     String name,
     String suffix,
     int id,
     Class<? extends WorldProvider> provider,
     boolean keepLoaded) {
   String enum_name = name.replace(" ", "_").toLowerCase();
   DimensionType ret =
       net.minecraftforge.common.util.EnumHelper.addEnum(
           DimensionType.class, enum_name, ENUM_ARGS, id, name, suffix, provider);
   return ret.setLoadSpawn(keepLoaded);
 }
public class ItemEUConduit extends AbstractItemConduit {

  public static final ModObject itemEUConduit =
      EnumHelper.addEnum(ModObject.class, "itemEUConduit", new Class<?>[0], new Object[0]);

  public static ItemEUConduit create() {
    ItemEUConduit result = new ItemEUConduit();
    result.init();
    return result;
  }

  static ItemConduitSubtype[] subtypes =
      new ItemConduitSubtype[] {
        new ItemConduitSubtype("itemT0EUConduit", "rea:itemT0EUConduit"),
        new ItemConduitSubtype("itemT1EUConduit", "rea:itemT1EUConduit"),
        new ItemConduitSubtype("itemT2EUConduit", "rea:itemT2EUConduit"),
        new ItemConduitSubtype("itemT3EUConduit", "rea:itemT3EUConduit"),
        new ItemConduitSubtype("itemT4EUConduit", "rea:itemT4EUConduit"),
        new ItemConduitSubtype("itemT5EUConduit", "rea:itemT5EUConduit"),
      };

  protected ItemEUConduit() {
    super(itemEUConduit, subtypes);

    // TODO Auto-generated constructor stub
  }

  @Override
  public Class<? extends IConduit> getBaseConduitType() {
    // TODO Auto-generated method stub
    return IEUConduit.class;
  }

  @Override
  public IConduit createConduit(ItemStack item, EntityPlayer player) {
    // TODO Auto-generated method stub
    return new EUConduit(item.getItemDamage());
  }

  @Override
  public boolean shouldHideFacades(ItemStack stack, EntityPlayer player) {
    // TODO Auto-generated method stub
    return true;
  }
}
 @Override
 public void init(FMLInitializationEvent event) {
   Class[][] commonTypes = {
     {MusicTicker.MusicType.class, ResourceLocation.class, int.class, int.class},
   };
   MUSIC_TYPE_MARS =
       EnumHelper.addEnum(
           commonTypes,
           MusicTicker.MusicType.class,
           "MARS_JC",
           new ResourceLocation(GalacticraftCore.ASSET_DOMAIN, "galacticraft.musicSpace"),
           12000,
           24000);
   ClientProxyCore.registerHandlers();
   ClientProxyCore.registerTileEntityRenderers();
   ClientProxyCore.registerBlockHandlers();
   ClientProxyCore.setupCapes();
 }
/** @author CovertJaguar <http://www.railcraft.info/> */
public class HiveDecorator {

  @SuppressWarnings("rawtypes")
  public static final EventType EVENT_TYPE =
      EnumHelper.addEnum(EventType.class, "FORESTRY_HIVES", new Class[0], new Object[0]);

  private static HiveDecorator instance;

  public static HiveDecorator instance() {
    if (instance == null) {
      instance = new HiveDecorator();
    }
    return instance;
  }

  private HiveDecorator() {}

  public void decorateHives(
      IChunkProvider chunkProvider,
      World world,
      Random rand,
      int chunkX,
      int chunkZ,
      boolean hasVillageGenerated) {
    if (!TerrainGen.populate(
        chunkProvider, world, rand, chunkX, chunkZ, hasVillageGenerated, EVENT_TYPE)) {
      return;
    }

    decorateHives(world, rand, chunkX, chunkZ);
  }

  public void decorateHives(World world, Random rand, int chunkX, int chunkZ) {
    List<Hive> hives = PluginApiculture.hiveRegistry.getHives();

    if (Config.generateBeehivesDebug) {
      decorateHivesDebug(world, chunkX, chunkZ, hives);
      return;
    }

    Collections.shuffle(hives, rand);
    for (Hive hive : hives) {
      if (genHive(world, rand, chunkX, chunkZ, hive)) {
        return;
      }
    }
  }

  public boolean genHive(World world, Random rand, int chunkX, int chunkZ, Hive hive) {
    if (hive.genChance() * Config.getBeehivesRate() < rand.nextFloat() * 100.0f) {
      return false;
    }

    int worldX = chunkX * 16;
    int worldZ = chunkZ * 16;

    BiomeGenBase biome = world.getBiomeGenForCoords(worldX, worldZ);
    EnumHumidity humidity = EnumHumidity.getFromValue(biome.rainfall);

    if (!hive.isGoodBiome(biome) || !hive.isGoodHumidity(humidity)) {
      return false;
    }

    for (int tries = 0; tries < 4; tries++) {
      int x = worldX + rand.nextInt(16);
      int z = worldZ + rand.nextInt(16);

      if (tryGenHive(world, x, z, hive)) {
        return true;
      }
    }

    return false;
  }

  private void decorateHivesDebug(World world, int chunkX, int chunkZ, List<Hive> hives) {
    int worldX = chunkX * 16;
    int worldZ = chunkZ * 16;
    BiomeGenBase biome = world.getBiomeGenForCoords(worldX, worldZ);
    EnumHumidity humidity = EnumHumidity.getFromValue(biome.rainfall);

    for (int x = 0; x < 16; x++) {
      for (int z = 0; z < 16; z++) {
        Collections.shuffle(hives, world.rand);
        for (Hive hive : hives) {
          if (!hive.isGoodBiome(biome) || !hive.isGoodHumidity(humidity)) {
            continue;
          }

          tryGenHive(world, worldX + x, worldZ + z, hive);
        }
      }
    }
  }

  private boolean tryGenHive(World world, int x, int z, Hive hive) {

    int y = hive.getYForHive(world, x, z);

    if (y < 0) {
      return false;
    }

    if (!hive.canReplace(world, x, y, z)) {
      return false;
    }

    BiomeGenBase biome = world.getBiomeGenForCoords(x, z);
    EnumTemperature temperature = EnumTemperature.getFromValue(biome.getFloatTemperature(x, y, z));
    if (!hive.isGoodTemperature(temperature)) {
      return false;
    }

    if (!hive.isValidLocation(world, x, y, z)) {
      return false;
    }

    return setHive(world, x, y, z, hive);
  }

  protected boolean setHive(World world, int x, int y, int z, Hive hive) {
    Block hiveBlock = hive.getHiveBlock();
    boolean placed =
        world.setBlock(x, y, z, hiveBlock, hive.getHiveMeta(), Defaults.FLAG_BLOCK_SYNCH);
    if (!placed) {
      return false;
    }

    Block placedBlock = world.getBlock(x, y, z);
    if (!Block.isEqualTo(hiveBlock, placedBlock)) {
      return false;
    }

    hiveBlock.onBlockAdded(world, x, y, z);
    world.markBlockForUpdate(x, y, z);

    if (!Config.generateBeehivesDebug) {
      hive.postGen(world, x, y, z);
    }
    return true;
  }
}
Esempio n. 5
0
public class BlockCobbleworks extends AbstractMachineBlock<TileCobbleworks>
    implements IFrameworkBlock, ITextureProvider {

  public static final ModObject ModObject_blockCobbleworks =
      EnumHelper.addEnum(ModObject.class, "blockCobbleworks", new Class<?>[0], new Object[0]);
  public static BlockCobbleworks blockCobbleworks;
  public int localRenderId;

  public static BlockCobbleworks create() {
    blockCobbleworks = new BlockCobbleworks();
    blockCobbleworks.init();
    return blockCobbleworks;
  }

  protected BlockCobbleworks() {
    super(ModObject_blockCobbleworks, TileCobbleworks.class);
  }

  @Nonnull
  public static BlockCobbleworks getBlock() {
    return notnull(blockCobbleworks, "BlockCobbleworks has not been initialized");
  }

  @Override
  public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
    TileEntity te = world.getTileEntity(x, y, z);
    if (te instanceof TileCobbleworks) {
      return new ContainerCobbleworks(player.inventory, (TileCobbleworks) te);
    }
    return null;
  }

  @Override
  public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
    TileEntity te = world.getTileEntity(x, y, z);
    if (te instanceof TileCobbleworks) {
      return new GuiCobbleworks(player.inventory, (TileCobbleworks) te);
    }
    return null;
  }

  @Override
  protected int getGuiId() {
    return GuiIds.GUI_ID_COBBLEWORKS;
  }

  @Override
  protected String getMachineFrontIconKey(boolean active) {
    return "enderio:machineTemplate";
  }

  @Override
  public int getRenderType() {
    return localRenderId;
  }

  @Override
  protected String getModelIconKey(boolean active) {
    return EnderIOAddons.DOMAIN + ":frameworkModel";
  }

  @Override
  public @Nonnull String getControllerModelName() {
    return "cobbleController";
  }

  @Override
  public boolean renderAsNormalBlock() {
    return false;
  }

  @Override
  public boolean isOpaqueCube() {
    return false;
  }

  @SideOnly(Side.CLIENT)
  @Override
  public void randomDisplayTick(World world, int x, int y, int z, Random rand) {
    if (isActive(world, x, y, z) && !world.getBlock(x, y + 1, z).isOpaqueCube()) {
      float startX = x + 0.8F - rand.nextFloat() * 0.6F;
      float startY = y + 1.0F;
      float startZ = z + 0.8F - rand.nextFloat() * 0.6F;
      if (rand.nextInt(20) == 0) {
        world.spawnParticle("lava", startX, startY, startZ, 0.0D, -0.2D, 0.0D);
      } else {
        world.spawnParticle("smoke", startX, startY, startZ, 0.0D, 0.0D, 0.0D);
      }
    }
  }

  IIcon controllerTexture;

  @Override
  @SideOnly(Side.CLIENT)
  public void registerBlockIcons(IIconRegister iIconRegister) {
    super.registerBlockIcons(iIconRegister);

    controllerTexture = iIconRegister.registerIcon(EnderIOAddons.DOMAIN + ":frameworkController");
  }

  @Override
  public IIcon getTexture() {
    return controllerTexture;
  }
}