@Nullable @Override public String getName(BlockType blockType) { return Block.REGISTRY.getObject(new ResourceLocation(blockType.getId())).getLocalizedName(); }
private Boolean isBlacklisted(Block block) { List<Block> blockList = new ArrayList<Block>(); for (int blocks = 0; blocks < ConfigHandler.WOA_BLACKLISTED_BLOCKS.length; blocks++) { String entry = ConfigHandler.WOA_BLACKLISTED_BLOCKS[blocks].trim(); Block outBlock = Block.REGISTRY.getObject(new ResourceLocation(entry)); blockList.add(outBlock); } if(blockList.contains(block)) return true; return false; }
private static void populateExtraAirBlocks() { extraAirBlockList.clear(); for (final String name : extraAirBlocks) { final Block block = Block.REGISTRY.getObject(new ResourceLocation(name)); if (block != Blocks.AIR) { extraAirBlockList.add(block); } } }
public Block getBlock(String blockName) { return Block.REGISTRY.getObject(new ResourceLocation(modID, blockName)); } }
public static Block getBlockByName(String name) { return Block.REGISTRY.getObject(new ResourceLocation(name)); }
@Override public @Nonnull ItemStack apply(@Nonnull ItemStack stack, @Nonnull Random rand, @Nonnull LootContext context) { PotionType type = PotionType.REGISTRY.getObject(this.name); ItemStack potion = PotionUtil.getEmptyPotion(splash); PotionUtils.addPotionToItemStack(potion, type); return potion; }
@SuppressWarnings("deprecation") @Override public IBlockState deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { String[] state = json.getAsString().split(" "); ResourceLocation block = new ResourceLocation(state[0]); int meta = state.length == 2 ? Integer.parseInt(state[1]) : 0; return Block.REGISTRY.getObject(block).getStateFromMeta(meta); } }
public static Block findBlock(@Nonnull String mod, @Nonnull String blockName) { final ResourceLocation name = new ResourceLocation(mod, blockName); if (Block.REGISTRY.containsKey(name)) { return Block.REGISTRY.getObject(name); } return null; }
public static List<TippedArrowRecipeWrapper> getTippedArrowRecipes() { List<TippedArrowRecipeWrapper> recipes = new ArrayList<>(); for (ResourceLocation potionTypeResourceLocation : PotionType.REGISTRY.getKeys()) { PotionType potionType = PotionType.REGISTRY.getObject(potionTypeResourceLocation); TippedArrowRecipeWrapper recipe = new TippedArrowRecipeWrapper(potionType); recipes.add(recipe); } return recipes; }
@Override public Instance deserializeInstance(JsonObject json, JsonDeserializationContext context) { JsonElement blockElement = json.get("block"); Block block = null; if (blockElement != null && !blockElement.isJsonNull()) { block = Block.REGISTRY.getObject(new ResourceLocation(json.get("block").getAsString())); if (block == null) { throw new JsonSyntaxException("No block found with name: " + json.get("block").getAsString()); } } return new Instance(getId(), block, VariableFacadePredicate.deserialize(json.get("variable_facade"))); }
public static IBlockState getStateFromString(String name) { String[] split = name.split(" "); String block = split[0]; int meta = split.length > 1 ? getIntegerFromString(split[1]): 0; Block theBlock = Block.REGISTRY.getObject(new ResourceLocation(block)); return theBlock.getStateFromMeta(meta); }
public static RubberTreeFarmer create() { Block sapling = Block.REGISTRY.getObject(new ResourceLocation("techreborn", "rubberSapling")); Block wood = Block.REGISTRY.getObject(new ResourceLocation("techreborn", "rubberLog")); Item resin = Item.REGISTRY.getObject(new ResourceLocation("techreborn", "part")); if (sapling != Blocks.AIR && wood != Blocks.AIR && resin != null) { return new RubberTreeFarmerTechReborn(sapling, wood, new ItemStack(resin, 1, 31)); } return null; }
public static RubberTreeFarmer create() { Block sapling = Block.REGISTRY.getObject(new ResourceLocation("ic2", "sapling")); Block wood = Block.REGISTRY.getObject(new ResourceLocation("ic2", "rubber_wood")); Item resin = Item.REGISTRY.getObject(new ResourceLocation("ic2", "misc_resource")); if (sapling != Blocks.AIR && wood != Blocks.AIR && resin != null) { return new RubberTreeFarmerIC2exp(sapling, wood, new ItemStack(resin, 1, 4)); } return null; }
public static RubberTreeFarmer create() { Block sapling = Block.REGISTRY.getObject(new ResourceLocation("ic2", "blockrubsapling")); Block wood = Block.REGISTRY.getObject(new ResourceLocation("ic2", "blockrubwood")); Item resin = Item.REGISTRY.getObject(new ResourceLocation("ic2", "itemharz")); if (sapling != Blocks.AIR && wood != Blocks.AIR && resin != null) { return new RubberTreeFarmerIC2classic(sapling, wood, new ItemStack(resin)); } return null; }
public void readFromNBT(NBTTagCompound tag) { pos = NBTHelper.readBlockPos("Location", tag); block = Block.REGISTRY.getObject(new ResourceLocation(tag.getString("Block"))); meta = tag.getInteger("Meta"); }
@Override public void postInit(FMLPostInitializationEvent event) { for(ResourceLocation r : Block.REGISTRY.getKeys()) { Block block = Block.REGISTRY.getObject(r); Item item = Item.getItemFromBlock(block); if(block == null || item == null || !(item instanceof ItemBlock) || blacklist.contains(r.toString())) continue; if(!BlockDispenser.DISPENSE_BEHAVIOR_REGISTRY.containsKey(item)) BlockDispenser.DISPENSE_BEHAVIOR_REGISTRY.putObject(item, new BehaviourBlock((ItemBlock) item, block)); } }
@Override @SideOnly(Side.CLIENT) public void postInitClient(FMLPostInitializationEvent event) { registerGreenerColor(Blocks.GRASS, Blocks.TALLGRASS, Blocks.DOUBLE_PLANT, Blocks.REEDS); if(affectFolliage) registerGreenerColor(Blocks.LEAVES, Blocks.LEAVES2, Blocks.VINE); for(String s : extraBlocks) { Block b = Block.REGISTRY.getObject(new ResourceLocation(s)); if(b != null) registerGreenerColor(b); } }
@Override public void readFromNBT(NBTTagCompound tag) { super.readFromNBT(tag); ownerPos = BlockPos.fromLong(tag.getLong("owner")); String ownerModid = tag.getString("owner_block_modid"); String ownerName = tag.getString("owner_block_name"); Block block = Block.REGISTRY.getObject(new ResourceLocation(ownerModid, ownerName)); if (block == null) { MOLog.error("Missing owner block " + ownerModid + ":" + ownerName); } else { ownerBlock = block; } }
@Override public void load(NBTTagCompound tag) { ResourceLocation pipeBlockName = new ResourceLocation(tag.getString("PipeBlock")); //noinspection unchecked this.pipeBlock = (BlockPipe<PipeType, NodeDataType, ?>) Block.REGISTRY.getObject(pipeBlockName); this.pipeType = pipeBlock.getPipeTypeClass().getEnumConstants()[tag.getInteger("PipeType")]; this.material = Material.MATERIAL_REGISTRY.getObject(tag.getString("PipeMaterial")); this.insulationColor = tag.getInteger("InsulationColor"); this.activeConnections = tag.getInteger("ActiveConnections"); this.blockedConnections = tag.getInteger("BlockedConnections"); getCoverableImplementation().writeToNBT(tag); reinitializeShape(); }
public static HempFarmerIE create() { if (Block.REGISTRY.containsKey(new ResourceLocation("ImmersiveEngineering", "hemp"))) { Block hempBlock = Block.REGISTRY.getObject(new ResourceLocation("ImmersiveEngineering", "hemp")); Item hempSeedItem = Item.REGISTRY.getObject(new ResourceLocation("ImmersiveEngineering", "seed")); if (hempSeedItem != null) { ItemStack hempSeed = new ItemStack(hempSeedItem); return new HempFarmerIE(new CustomSeedFarmer(hempBlock, 4, hempSeed), new StemFarmer(hempBlock, hempSeed)); } } return null; }