Esempio n. 1
0
  public BlockLoader() {
    registerBlock(drinks_store);
    registerBlock(drinks_brewer);
    registerBlock(rain_collector);

    GameRegistry.registerTileEntity(TileEntityDS.class, drinks_store.getLocalizedName());
    GameRegistry.registerTileEntity(TileEntityDB.class, drinks_brewer.getUnlocalizedName());
    GameRegistry.registerTileEntity(TileEntityRC.class, rain_collector.getUnlocalizedName());

    GameRegistry.addRecipe(
        new ItemStack(drinks_store),
        new Object[] {
          "***", "*#*", "*^*", '*', Items.quartz, '#', Blocks.glass_pane, '^', Blocks.piston
        });

    GameRegistry.addRecipe(
        new ItemStack(drinks_brewer, 1),
        new Object[] {
          "***", "*#*", "***", '*', Blocks.cobblestone, '#', Items.glass_bottle,
        });

    GameRegistry.addRecipe(
        new ItemStack(rain_collector, 1),
        new Object[] {
          "***", "*#*", "***", '*', Blocks.cobblestone, '#', Items.bucket,
        });
  }
  @Mod.EventHandler
  public void onPreInit(FMLPreInitializationEvent e) {
    GameRegistry.registerBlock(
        blockPosterBed, ItemBlockMulti.class, blockPosterBed.getUnlocalizedName());
    GameRegistry.registerBlock(blockBed, ItemBlockMulti.class, blockBed.getUnlocalizedName());
    GameRegistry.registerBlock(blockBarrelInventory, blockBarrelInventory.getUnlocalizedName());

    proxy.registerRenderers();
  }
 public static void reg(Block block) {
   if (!block.getUnlocalizedName().contains("door")) {
     Minecraft.getMinecraft()
         .getRenderItem()
         .getItemModelMesher()
         .register(
             Item.getItemFromBlock(block),
             0,
             new ModelResourceLocation(
                 MoreCraft.MODID + ":" + block.getUnlocalizedName().substring(5), "inventory"));
   }
 }
Esempio n. 4
0
 public ItemAdvancedBase(Block b) {
   super(b);
   TileEntity te = ((BlockContainerAdvanced) b).createNewTileEntity(null, 0);
   Class<?>[] interfaces = te.getClass().getInterfaces();
   for (Class<?> curInterface : interfaces) {
     String intName = curInterface.getName();
     tileInterfaces.add(intName.substring(intName.lastIndexOf('.') + 1, intName.length()));
   }
   setUnlocalizedName(b.getUnlocalizedName());
   if (tileInterfaces.contains("IUpgradable")) {
     IUpgradable up = (IUpgradable) te;
     String name = String.format(StatCollector.translateToLocal(b.getUnlocalizedName() + ".name"));
     ItemBoost.upgradeable.add(name + ": " + up.getInfo());
   }
 }
Esempio n. 5
0
  public static final void init() {

    // Blood Steel
    GameRegistry.registerBlock(
        blockBloodSteel = new BasicBlock("blockBloodSteel", Material.iron), "blockBloodSteel");

    // Arcane Infuser - Must Init blocks first as they're not static.
    arcaneInfuser =
        new ArcaneInfuser(false)
            .setBlockName("ArcaneInfuser")
            .setCreativeTab(TMCreativeTabs.tabBlock);
    arcaneInfuserActive = new ArcaneInfuser(true).setBlockName("ArcaneInfuserActive");
    GameRegistry.registerBlock(arcaneInfuser, arcaneInfuser.getUnlocalizedName());
    GameRegistry.registerBlock(arcaneInfuserActive, arcaneInfuserActive.getUnlocalizedName());
  }
Esempio n. 6
0
 @Override
 public String getName() {
   if (block != null) {
     return block.getUnlocalizedName();
   }
   return null;
 }
 @Override
 public boolean onBlockDestroyed(
     ItemStack itemStack,
     World world,
     Block destroyedBlock,
     int x,
     int y,
     int z,
     EntityLivingBase player) {
   // System.out.println("Test (" + x + "," + y + "," + z + ")");
   // player.getLookVec();
   int numBlocks = 0;
   for (int i = -1; i <= 1; i++) {
     for (int j = -1; j <= 1; j++) {
       for (int k = -1; k <= 1; k++) {
         Block block = world.getBlock(x + i, y + j, z + k);
         if (block != null) {
           System.out.println("block: " + block.getUnlocalizedName());
           System.out.println("can:  " + itemStack.getItem().canHarvestBlock(block, itemStack));
           if (this.canHarvestBlock(block, itemStack)) {
             int fortuneLevel =
                 EnchantmentHelper.getEnchantmentLevel(Enchantment.fortune.effectId, itemStack);
             block.dropBlockAsItem(
                 world, x, y, z, world.getBlockMetadata(x + i, y + j, z + k), fortuneLevel);
             world.setBlockToAir(x + i, y + j, z + k);
             numBlocks++;
           }
         }
       }
     }
   }
   itemStack.damageItem(numBlocks / 3, player);
   // Block block = Block.blocksList[l]
   return false;
 }
Esempio n. 8
0
  private static int findFuelValue(ItemStack stack) {
    try {
      Item item = stack.getItem();

      if (item instanceof ItemBlock) {
        Block block = InvTools.getBlockFromStack(stack);

        String name = block.getUnlocalizedName();
        if (name != null && name.contains("blockScaffold")) return 0;
      }

      //            if (itemID == Item.coal.itemID && stack.getItemDamage() == 0)
      //                return 1600;

      if (item == Items.blaze_rod) return 1000;

      FluidStack liquid = FluidItemHelper.getFluidStackInContainer(stack);
      if (liquid != null && Fluids.LAVA.get() == liquid.getFluid()) return liquid.amount;

      String name = stack.getItem().getUnlocalizedName();
      if (name != null && name.contains("itemScrap")) return 0;

      return TileEntityFurnace.getItemBurnTime(stack);
    } catch (Exception ex) {
      Game.logThrowable(
          "Error in Fuel Handler! Is some mod creating items that are not compliant with standards?",
          ex);
    }
    return 0;
  }
Esempio n. 9
0
 private void commitSeppuku(Block block, int meta) {
   Proxies.log.info(
       "Obsolete gadget %s-%s has no replacement defined. Committing sepukku.",
       block.getUnlocalizedName(), meta);
   worldObj.removeTileEntity(xCoord, yCoord, zCoord);
   worldObj.setBlockToAir(xCoord, yCoord, zCoord);
 }
 private static String upgradeBlockId(String id) {
   Matcher match = oldNamePattern.matcher(id);
   if (!match.matches()) return null;
   id = match.group(1);
   for (Block block : GameData.getBlockRegistry().typeSafeIterable())
     if (id.equals(block.getUnlocalizedName()))
       return GameData.getBlockRegistry().getNameForObject(block).replace(':', '.')
           + match.group(2);
   return null;
 }
  @Override
  public void registerBlock(
      ModManager manager,
      String name,
      String modPrefix,
      Block block,
      Class<? extends ItemBlock> itemBlock) {
    super.registerBlock(manager, name, modPrefix, block, itemBlock);

    // Set block name if it is missing
    if (block.getUnlocalizedName() == null || block.getUnlocalizedName().contains("null")) {
      block.setBlockName((modPrefix != null ? modPrefix : "") + name);
    }

    // Set texture name if it is missing
    if (modPrefix != null && (block.textureName == null || block.textureName.isEmpty())) {
      block.setBlockTextureName(modPrefix + name);
    }

    // Sets creative tab if it is missing
    if (manager.defaultTab != null && block.getCreativeTabToDisplayOn() == null) {
      block.setCreativeTab(manager.defaultTab);
    }
  }
Esempio n. 12
0
 public BlockHandler(Block bloc, String... names) {
   super(names[0]);
   this.block = bloc;
   if (block != null) {
     block
         .setBlockName(names[0])
         .setBlockTextureName(names[1])
         .setCreativeTab(Steamcraft.steamTab); // finalizing the block
     if (names.length > 2) {
       oreName = names[2];
     }
     if (block.hasTileEntity(0)) {
       GameRegistry.registerTileEntity(
           block.createTileEntity(null, 0).getClass(), block.getUnlocalizedName());
     }
   }
 }
  @SubscribeEvent
  public void onBlockClick(PlayerInteractEvent e) {
    if (!e.world.isRemote) {
      if (e.action == Action.RIGHT_CLICK_BLOCK
          && CmdDumpBlockData.getWaitForBlockClick(e.entityPlayer.getUniqueID())) {
        StringBuilder sb = new StringBuilder();
        Block blc = e.world.getBlock(e.x, e.y, e.z);
        if (blc == null) {
          return;
        }

        int meta = e.world.getBlockMetadata(e.x, e.y, e.z);

        sb.append(
            "BlockID: "
                + GameData.getBlockRegistry().getNameForObject(blc)
                + "("
                + GameData.getBlockRegistry().getIDForObject(blc)
                + ")\n");
        sb.append(
            "Block name: " + blc.getUnlocalizedName() + " = " + blc.getLocalizedName() + "\n");
        sb.append("XYZ: " + e.x + " " + e.y + " " + e.z + "\n");
        sb.append("Metadata: " + meta + "\n");
        sb.append(
            "Lightlevel: "
                + "block: "
                + e.world.getSavedLightValue(EnumSkyBlock.Block, e.x, e.y, e.z)
                + ", sky: "
                + e.world.getSavedLightValue(EnumSkyBlock.Sky, e.x, e.y, e.z)
                + "\n");
        if (blc.hasTileEntity(meta)) {
          TileEntity te = e.world.getTileEntity(e.x, e.y, e.z);
          if (te != null) {
            NBTTagCompound nbt = new NBTTagCompound();
            te.writeToNBT(nbt);
            sb.append("NBT: {" + CmdDumpItemData.getNBTString(nbt, 1) + "}");
          }
        }

        System.out.println("\n" + sb.toString());

        e.setCanceled(true);
      }
    }
  }
Esempio n. 14
0
  private void legacyConversion(int kind, NBTTagCompound nbttagcompound) {
    if (definitionMap == null) createDefinitionMap();

    Block block = worldObj.getBlock(xCoord, yCoord, zCoord);
    if (!definitionMap.containsKey(block) || !definitionMap.get(block).containsKey(kind)) {
      commitSeppuku(block, kind);
      return;
    }

    MachineDefinition definition = definitionMap.get(block).get(kind);
    Proxies.log.info(
        "Converting obsolete gadget %s-%s to new '%s' %s-%s",
        block.getUnlocalizedName(),
        kind,
        definition.teIdent,
        definition.block.getUnlocalizedName(),
        definition.meta);

    Proxies.log.info("Removing old tile entity...");
    worldObj.removeTileEntity(xCoord, yCoord, zCoord);
    worldObj.setBlockToAir(xCoord, yCoord, zCoord);
    Proxies.log.info("Setting to new block id...");
    worldObj.setBlock(
        xCoord, yCoord, zCoord, definition.block, definition.meta, Defaults.FLAG_BLOCK_SYNCH);
    TileEntity tile = worldObj.getTileEntity(xCoord, yCoord, zCoord);
    if (tile == null) throw new RuntimeException("Failed to set new block tile entity!");
    else if (tile.getClass() != definition.teClass)
      throw new RuntimeException(
          String.format(
              "Converted tile entity was '%s' instead of expected '%s'",
              tile.getClass(), definition.teClass));
    Proxies.log.info("Refreshing converted tile entity %s with nbt data...", tile.getClass());
    if (nbttagcompound.hasKey("Machine"))
      tile.readFromNBT(
          complementNBT(nbttagcompound, nbttagcompound.getCompoundTag("Machine"), definition));
    else tile.readFromNBT(nbttagcompound);
  }
Esempio n. 15
0
 public void registerBlock(Block block, Class<? extends ItemBlock> item) {
   GameRegistry.registerBlock(block, item, block.getUnlocalizedName().replace("tile.", ""));
 }
Esempio n. 16
0
 public void prepareBlock(Block aBlock, Class<? extends ItemBlock> itemBlock) {
   GameRegistry.registerBlock(aBlock, itemBlock, aBlock.getUnlocalizedName());
 }
Esempio n. 17
0
  public static String getUnlocalizedName(Block block) {
    String name = block.getUnlocalizedName();
    if (name.startsWith("tile.")) name = name.substring(5);

    return name;
  }
Esempio n. 18
0
 private static void registerBlock(Block block) {
   GameRegistry.registerBlock(block, block.getUnlocalizedName().substring(5));
   block.setCreativeTab(AwesomeMod.awesomeCreativeTab);
 }
 public static Icon forBlock(IconRegister ir, Block block, String s) {
   return forNameRaw(ir, block.getUnlocalizedName().replaceAll("tile.", "") + s);
 }
Esempio n. 20
0
 /**
  * Registers a block to the gameregistry
  *
  * @param i The block being registered
  */
 static void register(Block i) {
   GameRegistry.registerBlock(i, i.getUnlocalizedName().substring(5));
 }
Esempio n. 21
0
 private void registerBlock(Block b) {
   String name = b.getUnlocalizedName().replace("tile.", "");
   GameRegistry.registerBlock(b, name);
   ItemLoader.ALL_ITEMS.add(Item.getItemFromBlock(b));
 }
Esempio n. 22
0
 public static String getName(Block block) {
   String res = block.getUnlocalizedName();
   return res.substring(5);
 }
  private boolean saveShipToSchematic(String fileName, StringBuilder reason) {
    NBTTagCompound schematic = new NBTTagCompound();

    short width = (short) (shipCore.maxX - shipCore.minX + 1);
    short length = (short) (shipCore.maxZ - shipCore.minZ + 1);
    short height = (short) (shipCore.maxY - shipCore.minY + 1);

    if (width <= 0 || length <= 0 || height <= 0) {
      reason.append("Invalid ship dimensions, nothing to scan");
      return false;
    }

    schematic.setShort("Width", width);
    schematic.setShort("Length", length);
    schematic.setShort("Height", height);

    int size = width * length * height;

    // Consume energy
    if (!consumeEnergy(getScanningEnergyCost(size), false)) {
      reason.append("Insufficient energy (" + getScanningEnergyCost(size) + " required)");
      return false;
    }

    NBTTagList localBlocks = new NBTTagList();
    byte localMetadata[] = new byte[size];

    NBTTagList tileEntitiesList = new NBTTagList();

    for (int x = 0; x < width; x++) {
      for (int y = 0; y < height; y++) {
        for (int z = 0; z < length; z++) {
          Block block = worldObj.getBlock(shipCore.minX + x, shipCore.minY + y, shipCore.minZ + z);

          // Skip leftBehind and anchor blocks
          if (WarpDriveConfig.BLOCKS_LEFTBEHIND.contains(block)
              || WarpDriveConfig.BLOCKS_ANCHOR.contains(block)) {
            block = Blocks.air;
          }

          // Old coord calc [x + (y * length + z) * width]
          localBlocks.appendTag(new NBTTagString(block.getUnlocalizedName()));
          localMetadata[x + (y * length + z) * width] =
              (byte)
                  worldObj.getBlockMetadata(
                      shipCore.minX + x, shipCore.minY + y, shipCore.minZ + z);

          if (!block.isAssociatedBlock(Blocks.air)) {
            TileEntity te =
                worldObj.getTileEntity(shipCore.minX + x, shipCore.minY + y, shipCore.minZ + z);
            if (te != null) {
              try {
                NBTTagCompound tileTag = new NBTTagCompound();
                te.writeToNBT(tileTag);

                // Clear inventory.
                if (te instanceof IInventory) {
                  TileEntity tmp_te = TileEntity.createAndLoadEntity(tileTag);
                  if (tmp_te instanceof IInventory) {
                    for (int i = 0; i < ((IInventory) tmp_te).getSizeInventory(); i++) {
                      ((IInventory) tmp_te).setInventorySlotContents(i, null);
                    }
                  }
                  tmp_te.writeToNBT(tileTag);
                }

                // Remove energy from energy storages
                // IC2
                if (tileTag.hasKey("energy")) {
                  tileTag.setInteger("energy", 0);
                }
                // Gregtech
                if (tileTag.hasKey("mStoredEnergy")) {
                  tileTag.setInteger("mStoredEnergy", 0);
                }

                // Transform TE's coordinates from local axis to
                // .schematic offset-axis
                tileTag.setInteger("x", te.xCoord - shipCore.minX);
                tileTag.setInteger("y", te.yCoord - shipCore.minY);
                tileTag.setInteger("z", te.zCoord - shipCore.minZ);

                tileEntitiesList.appendTag(tileTag);
              } catch (Exception exception) {
                exception.printStackTrace();
              }
            }
          }
        }
      }
    }

    schematic.setString("Materials", "Alpha");
    schematic.setTag("Blocks", localBlocks);
    schematic.setByteArray("Data", localMetadata);

    schematic.setTag("Entities", new NBTTagList()); // don't save entities
    schematic.setTag("TileEntities", tileEntitiesList);

    writeNBTToFile(fileName, schematic);

    return true;
  }
Esempio n. 24
0
 public static void register() {
   GameRegistry.registerBlock(
       breadore, breadore.getUnlocalizedName().substring(5)); // tile.breadore
 }
Esempio n. 25
0
 public void prepareBlock(Block aBlock) {
   GameRegistry.registerBlock(aBlock, aBlock.getUnlocalizedName());
 }