Search in sources :

Example 1 with Identifier

use of net.minecraft.util.Identifier in project Therrassium by codeman1o1.

the class Items method registerItems.

// Registering Items
public static void registerItems() {
    Registry.register(Registry.ITEM, new Identifier(Therrassium.MOD_ID, "therrassium_ingot"), THERRASSIUM_INGOT);
    Registry.register(Registry.ITEM, new Identifier(Therrassium.MOD_ID, "therrassium_block"), THERRASSIUM_BLOCK);
    Registry.register(Registry.ITEM, new Identifier(Therrassium.MOD_ID, "therrassium_sword"), THERRASSIUM_SWORD);
    Registry.register(Registry.ITEM, new Identifier(Therrassium.MOD_ID, "therrassium_pickaxe"), THERRASSIUM_PICKAXE);
    Registry.register(Registry.ITEM, new Identifier(Therrassium.MOD_ID, "therrassium_axe"), THERRASSIUM_AXE);
    Registry.register(Registry.ITEM, new Identifier(Therrassium.MOD_ID, "therrassium_shovel"), THERRASSIUM_SHOVEL);
    Registry.register(Registry.ITEM, new Identifier(Therrassium.MOD_ID, "therrassium_hoe"), THERRASSIUM_HOE);
    Registry.register(Registry.ITEM, new Identifier(Therrassium.MOD_ID, "therrassium_helmet"), THERRASSIUM_HELMET);
    Registry.register(Registry.ITEM, new Identifier(Therrassium.MOD_ID, "therrassium_chestplate"), THERRASSIUM_CHESTPLATE);
    Registry.register(Registry.ITEM, new Identifier(Therrassium.MOD_ID, "therrassium_leggings"), THERRASSIUM_LEGGINGS);
    Registry.register(Registry.ITEM, new Identifier(Therrassium.MOD_ID, "therrassium_boots"), THERRASSIUM_BOOTS);
}
Also used : Identifier(net.minecraft.util.Identifier)

Example 2 with Identifier

use of net.minecraft.util.Identifier in project EnvironmentZ by Globox1997.

the class ItemInit method init.

public static void init() {
    // Item
    Registry.register(Registry.ITEM, new Identifier("environmentz", "heating_stones"), HEATING_STONES);
    Registry.register(Registry.ITEM, new Identifier("environmentz", "heated_stones"), HEATED_STONES);
    Registry.register(Registry.ITEM, new Identifier("environmentz", "wolf_pelt"), WOLF_PELT_ITEM);
    Registry.register(Registry.ITEM, new Identifier("environmentz", "polar_bear_fur"), POLAR_BEAR_FUR_ITEM);
    // Armor
    Registry.register(Registry.ITEM, new Identifier("environmentz", "wolf_helmet"), WOLF_HELMET);
    Registry.register(Registry.ITEM, new Identifier("environmentz", "wolf_chestplate"), WOLF_CHESTPLATE);
    Registry.register(Registry.ITEM, new Identifier("environmentz", "wolf_leggings"), WOLF_LEGGINGS);
    Registry.register(Registry.ITEM, new Identifier("environmentz", "wolf_boots"), WOLF_BOOTS);
    // Potion
    Registry.register(Registry.POTION, "cold_resistance", COLD_RESISTANCE);
    Registry.register(Registry.POTION, "long_cold_resistance", LONG_COLD_RESISTANCE);
    Registry.register(Registry.POTION, "overheating_resistance", OVERHEATING_RESISTANCE);
    Registry.register(Registry.POTION, "long_overheating_resistance", LONG_OVERHEATING_RESISTANCE);
}
Also used : Identifier(net.minecraft.util.Identifier)

Example 3 with Identifier

use of net.minecraft.util.Identifier in project nbt-crafting by Siphalor.

the class MixinIngredient method advancedEntryFromJson.

@Unique
private static IngredientEntry advancedEntryFromJson(JsonObject jsonObject) {
    if (jsonObject.has("item") && jsonObject.has("tag")) {
        throw new JsonParseException("An ingredient entry is either a tag or an item or a potion, not both");
    }
    if (jsonObject.has("item")) {
        final Identifier identifier = new Identifier(JsonHelper.getString(jsonObject, "item"));
        try {
            final Item item = Registry.ITEM.getOrEmpty(identifier).orElseThrow(() -> {
                throw new JsonSyntaxException("Unknown item '" + identifier.toString() + "'");
            });
            IngredientStackEntry entry = new IngredientStackEntry(Registry.ITEM.getRawId(item), loadIngredientEntryCondition(jsonObject));
            if (jsonObject.has("remainder")) {
                entry.setRecipeRemainder(ShapedRecipe.getItemStack(JsonHelper.getObject(jsonObject, "remainder")));
            }
            return entry;
        } catch (Throwable e) {
            e.printStackTrace();
            return null;
        }
    }
    if (jsonObject.has("potion")) {
        final Identifier identifier = new Identifier(JsonHelper.getString(jsonObject, "potion"));
        try {
            Registry.POTION.getOrEmpty(identifier).orElseThrow(() -> {
                throw new JsonSyntaxException("Unknown potion '" + identifier.toString() + "'");
            });
            IngredientEntryCondition condition = loadIngredientEntryCondition(jsonObject);
            if (condition.requiredElements == NbtUtil.EMPTY_COMPOUND)
                condition.requiredElements = new CompoundTag();
            condition.requiredElements.putString("Potion", identifier.toString());
            IngredientStackEntry entry = new IngredientStackEntry(Registry.ITEM.getRawId(Items.POTION), condition);
            if (jsonObject.has("remainder")) {
                entry.setRecipeRemainder(ShapedRecipe.getItemStack(JsonHelper.getObject(jsonObject, "remainder")));
            }
            return entry;
        } catch (Throwable e) {
            e.printStackTrace();
            return null;
        }
    }
    if (!jsonObject.has("tag")) {
        throw new JsonParseException("An ingredient entry needs either a tag or an item");
    }
    final Identifier identifier2 = new Identifier(JsonHelper.getString(jsonObject, "tag"));
    final Tag<Item> tag = ItemTags.getContainer().get(identifier2);
    if (tag == null) {
        throw new JsonSyntaxException("Unknown item tag '" + identifier2 + "'");
    }
    IngredientMultiStackEntry entry = new IngredientMultiStackEntry(tag.values().stream().map(Registry.ITEM::getRawId).collect(Collectors.toList()), loadIngredientEntryCondition(jsonObject));
    entry.setTag(identifier2.toString());
    if (jsonObject.has("remainder")) {
        entry.setRecipeRemainder(ShapedRecipe.getItemStack(JsonHelper.getObject(jsonObject, "remainder")));
    }
    return entry;
}
Also used : Item(net.minecraft.item.Item) Identifier(net.minecraft.util.Identifier) CompoundTag(net.minecraft.nbt.CompoundTag) Unique(org.spongepowered.asm.mixin.Unique)

Example 4 with Identifier

use of net.minecraft.util.Identifier in project nbt-crafting by Siphalor.

the class NbtCrafting method registerRecipeType.

public static <T extends Recipe<?>> RecipeType<T> registerRecipeType(String name) {
    Identifier recipeTypeId = new Identifier(MOD_ID, name);
    RecipeTypeHelper.addToSyncBlacklist(recipeTypeId);
    return Registry.register(Registry.RECIPE_TYPE, recipeTypeId, new RecipeType<T>() {

        @Override
        public String toString() {
            return MOD_ID + ":" + name;
        }
    });
}
Also used : Identifier(net.minecraft.util.Identifier)

Example 5 with Identifier

use of net.minecraft.util.Identifier in project nbt-crafting by Siphalor.

the class StatChangedCriterion method conditionsFromJson.

@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public Conditions conditionsFromJson(JsonObject obj, JsonDeserializationContext context) {
    Identifier statId = new Identifier(JsonHelper.getString(obj, "stat"));
    StatType<?> statType = Registry.STAT_TYPE.getOrEmpty(statId).orElseThrow(() -> new JsonSyntaxException("Unknown stat: " + statId));
    Identifier id = new Identifier(JsonHelper.getString(obj, "id"));
    Object object = statType.getRegistry().get(id);
    return new Conditions(statType, object, NumberRange.IntRange.fromJson(obj.get("range")));
}
Also used : Identifier(net.minecraft.util.Identifier) JsonSyntaxException(com.google.gson.JsonSyntaxException) JsonObject(com.google.gson.JsonObject) AbstractCriterionConditions(net.minecraft.advancement.criterion.AbstractCriterionConditions)

Aggregations

Identifier (net.minecraft.util.Identifier)343 NbtList (net.minecraft.nbt.NbtList)36 ItemStack (net.minecraft.item.ItemStack)31 Item (net.minecraft.item.Item)28 NbtCompound (net.minecraft.nbt.NbtCompound)22 NbtElement (net.minecraft.nbt.NbtElement)22 Inject (org.spongepowered.asm.mixin.injection.Inject)22 IOException (java.io.IOException)18 Block (net.minecraft.block.Block)18 MinecraftClient (net.minecraft.client.MinecraftClient)15 BlockItem (net.minecraft.item.BlockItem)15 BlockPos (net.minecraft.util.math.BlockPos)15 Map (java.util.Map)12 BlockState (net.minecraft.block.BlockState)12 ArrayList (java.util.ArrayList)11 VertexConsumer (net.minecraft.client.render.VertexConsumer)11 ResourceManager (net.minecraft.resource.ResourceManager)11 SoundEvent (net.minecraft.sound.SoundEvent)11 ServerPlayerEntity (net.minecraft.server.network.ServerPlayerEntity)10 LiteralText (net.minecraft.text.LiteralText)10