public Potion(LootCondition[] conditionsIn, @Nonnull String name, boolean splash) { super(conditionsIn); this.name = new ResourceLocation(name); this.splash = splash; if (!PotionType.REGISTRY.containsKey(this.name)) { throw new RuntimeException(name + " is not a valid potion type"); } }
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; }
@Override public IBlockState build() { if(!Block.REGISTRY.containsKey(this.rLoc)) throw new IllegalArgumentException("No block found for resource location "+this.rLoc); final Block block = Block.REGISTRY.getObject(this.rLoc); final BlockStateContainer container = block.getBlockState(); IBlockState state = block.getDefaultState(); final Iterator<Entry<String, String>> it = this.properties.entrySet().iterator(); while(it.hasNext()){ final Entry<String, String> entry = it.next(); final IProperty<?> prop = container.getProperty(entry.getKey()); if(prop == null){ LogHelper.error("No property "+entry.getKey()+" found for block "+this.rLoc+". Skipping it."); it.remove(); continue; } if(!prop.parseValue(entry.getValue()).isPresent()){ LogHelper.error("Value "+entry.getValue()+" is not valid for property "+entry.getKey()+". Skipping it."); continue; } state = this.withProperty(state, prop, entry.getValue()); } return state; }
@SuppressWarnings({ "rawtypes" }) public static BlockStateInfo fromString(final String input) throws LocalizedException { final int start = input.indexOf('['); final int end = input.indexOf(']'); final String blockName; final String stateData; if (start > -1 && end > -1) { blockName = input.substring(0, start); stateData = input.substring(start + 1, end); } else { blockName = input; stateData = ""; } final ResourceLocation location = new ResourceLocation(blockName); if (!Block.REGISTRY.containsKey(location)) { throw new LocalizedException(Names.Messages.INVALID_BLOCK, blockName); } final Block block = Block.REGISTRY.getObject(location); final Map<IProperty, Comparable> propertyData = parsePropertyData(block.getDefaultState(), stateData, true); return new BlockStateInfo(block, propertyData); }
public @Nonnull Things add(@Nullable ResourceLocation resourceLocation) { if (resourceLocation != null) { if (net.minecraft.block.Block.REGISTRY.containsKey(resourceLocation)) { Block block = net.minecraft.block.Block.REGISTRY.getObject(resourceLocation); nameList.add("block:" + block.getRegistryName()); } // this ugly thing seems to be what Forge wants you to use Item item = net.minecraft.item.Item.REGISTRY.getObject(resourceLocation); if (item != null) { nameList.add("item:" + item.getRegistryName()); } add(new ResourceThing(resourceLocation)); } return this; }
@Override public @Nonnull NNList<IThing> bake() { // this ugly thing seems to be what Forge wants you to use if (net.minecraft.block.Block.REGISTRY.containsKey(resourceLocation)) { Block block = net.minecraft.block.Block.REGISTRY.getObject(resourceLocation); return new BlockThing(block).bake(); } // this ugly thing seems to be what Forge wants you to use Item item = net.minecraft.item.Item.REGISTRY.getObject(resourceLocation); if (item != null) { return new ItemThing(item).bake(); } return NNList.emptyList(); }
if (meta < 0) { if (allowBlock && net.minecraft.block.Block.REGISTRY.containsKey(resourceLocation)) { Block block = net.minecraft.block.Block.REGISTRY.getObject(resourceLocation); return new BlockThing(block).bake(); if (allowBlock && net.minecraft.block.Block.REGISTRY.containsKey(resourceLocation)) { Block block = net.minecraft.block.Block.REGISTRY.getObject(resourceLocation); return new ItemStackThing(new ItemStack(block, 1, meta)).bake();
private static ItemStack findItem(ResourceLocation resLoc, int meta){ if(Item.REGISTRY.containsKey(resLoc)){ Item item = Item.REGISTRY.getObject(resLoc); if(item != null){ return new ItemStack(item, 1, meta); } } else if(Block.REGISTRY.containsKey(resLoc)){ Block block = Block.REGISTRY.getObject(resLoc); if(block != null){ return new ItemStack(block, 1, meta); } } return StackUtil.getEmpty(); }
@Nonnull @Override public Ingredient parse(JsonContext context, JsonObject json) { ResourceLocation effect = new ResourceLocation(JsonUtils.getString(json, "effect")); if (!Potion.REGISTRY.containsKey(effect)) { throw new JsonSyntaxException("Unknown effect '" + effect + "'"); } ResourceLocation potion = new ResourceLocation(JsonUtils.getString(json, "potion")); if (!PotionType.REGISTRY.containsKey(potion)) { throw new JsonSyntaxException("Unknown potion '" + potion + "'"); } return new IngredientBrew(Potion.REGISTRY.getObject(effect), PotionType.REGISTRY.getObject(potion)); } }
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; }
if (!Block.REGISTRY.containsKey(blockLocation)) { CookingForBlockheads.logger.warn("Connector block '" + blockLocation + "' not found"); continue;
public static RecipeInput getItemStack(Attributes attributes) { int stackSize = getIntValue(AT_NUMBER, attributes, 1); boolean useMeta = true; int itemMeta = 0; String metaString = getStringValue(AT_ITEM_META, attributes, "0"); if ("*".equals(metaString)) { useMeta = false; } else { itemMeta = getIntValue(AT_ITEM_META, attributes, 0); } ItemStack res = Prep.getEmpty(); String modId = getStringValue(AT_MOD_ID, attributes, null); String name = getStringValue(AT_ITEM_NAME, attributes, null); if (modId != null && name != null) { ResourceLocation rl = new ResourceLocation(modId, name); Item i = Item.REGISTRY.getObject(rl); if (i != null) { res = new ItemStack(i, stackSize, useMeta ? itemMeta : 0); } else if (Block.REGISTRY.containsKey(rl)) { Block b = Block.REGISTRY.getObject(rl); res = new ItemStack(b, stackSize, useMeta ? itemMeta : 0); } } if (Prep.isInvalid(res)) { Log.debug("Could not create an item stack from the attributes " + toString(attributes)); return null; } return new RecipeInput(res, useMeta, getFloatValue(AT_MULTIPLIER, attributes, 1), getIntValue(AT_SLOT, attributes, -1)); }
if (Block.REGISTRY.containsKey(new ResourceLocation(EnderIO.DOMAIN, "block_alloy_smelter"))) { icon = Block.REGISTRY.getObject(new ResourceLocation(EnderIO.DOMAIN, "block_alloy_smelter"));