Search in sources :

Example 51 with Identifier

use of net.minecraft.util.Identifier in project WK by witches-kitchen.

the class WKGenerator method register.

public static void register() {
    RegistryKey<ConfiguredFeature<?, ?>> blackthornTree = RegistryKey.of(Registry.CONFIGURED_FEATURE_KEY, new Identifier("witcheskitchen", "tree_blackthorn"));
    RegistryKey<ConfiguredFeature<?, ?>> elderTree = RegistryKey.of(Registry.CONFIGURED_FEATURE_KEY, new Identifier("witcheskitchen", "tree_elder"));
    RegistryKey<ConfiguredFeature<?, ?>> elderElderTree = RegistryKey.of(Registry.CONFIGURED_FEATURE_KEY, new Identifier("witcheskitchen", "tree_elder_elder"));
    RegistryKey<ConfiguredFeature<?, ?>> hawthornTree = RegistryKey.of(Registry.CONFIGURED_FEATURE_KEY, new Identifier("witcheskitchen", "tree_hawthorn"));
    RegistryKey<ConfiguredFeature<?, ?>> juniperTree = RegistryKey.of(Registry.CONFIGURED_FEATURE_KEY, new Identifier("witcheskitchen", "tree_juniper"));
    RegistryKey<ConfiguredFeature<?, ?>> rowanTree = RegistryKey.of(Registry.CONFIGURED_FEATURE_KEY, new Identifier("witcheskitchen", "tree_rowan"));
    RegistryKey<ConfiguredFeature<?, ?>> sumacTree = RegistryKey.of(Registry.CONFIGURED_FEATURE_KEY, new Identifier("witcheskitchen", "tree_sumac"));
    Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, blackthornTree.getValue(), BLACKTHORN_TREE);
    Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, elderTree.getValue(), ELDER_TREE);
    Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, elderElderTree.getValue(), ELDER_ELDER_TREE);
    Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, hawthornTree.getValue(), HAWTHORN_TREE);
    Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, juniperTree.getValue(), JUNIPER_TREE);
    Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, rowanTree.getValue(), ROWAN_TREE);
    Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, sumacTree.getValue(), SUMAC_TREE);
    if (WKConfig.get().debugMode) {
        WK.logger.info("Witches Kitchen Base Generation: Successfully Loaded");
    }
}
Also used : Identifier(net.minecraft.util.Identifier)

Example 52 with Identifier

use of net.minecraft.util.Identifier in project WK by witches-kitchen.

the class WKSoundEvents method register.

private static SoundEvent register(String name) {
    Identifier id = new Identifier(WK.MODID, name);
    SoundEvent soundEvent = new SoundEvent(id);
    SOUND_EVENTS.put(id, soundEvent);
    return soundEvent;
}
Also used : SoundEvent(net.minecraft.sound.SoundEvent) Identifier(net.minecraft.util.Identifier)

Example 53 with Identifier

use of net.minecraft.util.Identifier in project WK by witches-kitchen.

the class RecipeUtil method deserializeStack.

/**
 * Deserializes a {@link ItemStack} from Json.
 * Supports "count" and "nbt" fields.
 *
 * @param object JsonObject
 * @return brand-new Item deserialized
 */
public static ItemStack deserializeStack(JsonObject object) {
    final Identifier id = new Identifier(JsonHelper.getString(object, "item"));
    final Item item = Registry.ITEM.get(id);
    if (Items.AIR == item) {
        throw new IllegalStateException("Invalid item: " + item);
    }
    int count = 1;
    if (object.has("count")) {
        count = JsonHelper.getInt(object, "count");
    }
    final ItemStack stack = new ItemStack(item, count);
    if (object.has("nbt")) {
        final NbtCompound tag = (NbtCompound) Dynamic.convert(JsonOps.INSTANCE, NbtOps.INSTANCE, object.get("nbt"));
        stack.setNbt(tag);
    }
    return stack;
}
Also used : Item(net.minecraft.item.Item) Identifier(net.minecraft.util.Identifier) NbtCompound(net.minecraft.nbt.NbtCompound) ItemStack(net.minecraft.item.ItemStack)

Example 54 with Identifier

use of net.minecraft.util.Identifier in project EdenClient by HahaOO7.

the class ContainerInfo method getStackFromCompound.

private ItemStack getStackFromCompound(NbtCompound tag) {
    Item item = Registry.ITEM.get(new Identifier(tag.getString("id")));
    ItemStack stack = item.getDefaultStack();
    stack.setCount(tag.getByte("Count"));
    return stack;
}
Also used : Item(net.minecraft.item.Item) Identifier(net.minecraft.util.Identifier) ItemStack(net.minecraft.item.ItemStack)

Example 55 with Identifier

use of net.minecraft.util.Identifier in project EdenClient by HahaOO7.

the class WorldEditReplaceHelper method registerCommand.

private void registerCommand(String command) {
    LiteralArgumentBuilder<ClientCommandSource> node = literal(command);
    node.then(literal("replace").then(argument("from", StringArgumentType.word()).suggests(this::suggestValidBlocks).then(argument("to", StringArgumentType.word()).suggests(this::suggestValidBlocks).executes(c -> {
        Optional<Block> fromBlockOpt = Registry.BLOCK.getOrEmpty(new Identifier(c.getArgument("from", String.class)));
        Optional<Block> toBlockOpt = Registry.BLOCK.getOrEmpty(new Identifier(c.getArgument("to", String.class)));
        if (fromBlockOpt.isEmpty() || toBlockOpt.isEmpty()) {
            sendModMessage("One of your block-inputs doesn't exist.");
            return 0;
        }
        Block fromBlock = fromBlockOpt.get();
        Block toBlock = toBlockOpt.get();
        if (fromBlock.equals(toBlock)) {
            sendModMessage("Both input-blocks can't be the same!");
            return 0;
        }
        String[] currentOperation = new String[] { getBlockIDFromBlock(toBlock), getBlockIDFromBlock(fromBlock) };
        undoCommandStack.add(currentOperation);
        return replaceCommandRequest(fromBlock, toBlock, delay, true);
    }))));
    node.then(literal("undo").executes(c -> {
        if (undoCommandStack.size() == 0) {
            sendModMessage("Nothing left to undo.");
            return 0;
        }
        replaceUndoRequest(Registry.BLOCK.get(new Identifier(undoCommandStack.peek()[0])), Registry.BLOCK.get(new Identifier(undoCommandStack.peek()[1])), delay);
        redoCommandStack.add(new String[] { undoCommandStack.peek()[1], undoCommandStack.peek()[0] });
        undoCommandStack.pop();
        return 1;
    }));
    node.then(literal("redo").executes(c -> {
        if (redoCommandStack.size() == 0) {
            sendModMessage("Nothing left to redo.");
            return 0;
        }
        replaceRedoRequest(Registry.BLOCK.get(new Identifier(redoCommandStack.peek()[0])), Registry.BLOCK.get(new Identifier(redoCommandStack.peek()[1])), delay);
        undoCommandStack.add(new String[] { redoCommandStack.peek()[1], redoCommandStack.peek()[0] });
        redoCommandStack.pop();
        return 1;
    }));
    node.then(literal("delay").then(argument("delay", IntegerArgumentType.integer(0, 40)).executes(c -> {
        this.delay = c.getArgument("delay", Integer.class);
        sendModMessage(ChatColor.GOLD + "Set delay to " + ChatColor.AQUA + delay + ChatColor.GOLD + " ticks.");
        return 1;
    })));
    node.then(literal("togglemessages").executes(c -> {
        ClientPlayerEntity entityPlayer = PlayerUtils.getPlayer();
        entityPlayer.sendChatMessage("/eignoremessage predefined worldedit");
        return 1;
    }));
    register(node, "The WorldEditReplaceHelper helps you replace blocks that have specific properties which normal WorldEdit doesn't take into consideration when replacing blocks.", "Blocks like stairs, slabs, panes, walls, trapdoors, etc. can be replaced by other blocks of their type with their properties (waterlogged, shape, direction, etc.) unaffected.");
}
Also used : net.minecraft.block.enums(net.minecraft.block.enums) PerWorldConfig(at.haha007.edenclient.utils.config.PerWorldConfig) ChatColor(at.haha007.edenclient.utils.ChatColor) CompletableFuture(java.util.concurrent.CompletableFuture) Stack(java.util.Stack) ArrayList(java.util.ArrayList) Direction(net.minecraft.util.math.Direction) DefaultedRegistry(net.minecraft.util.registry.DefaultedRegistry) StringArgumentType(com.mojang.brigadier.arguments.StringArgumentType) net.minecraft.block(net.minecraft.block) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) CommandManager(at.haha007.edenclient.command.CommandManager) PlayerUtils.sendModMessage(at.haha007.edenclient.utils.PlayerUtils.sendModMessage) Scheduler(at.haha007.edenclient.utils.Scheduler) SuggestionsBuilder(com.mojang.brigadier.suggestion.SuggestionsBuilder) ClientCommandSource(net.minecraft.client.network.ClientCommandSource) Suggestions(com.mojang.brigadier.suggestion.Suggestions) CommandContext(com.mojang.brigadier.context.CommandContext) Collectors(java.util.stream.Collectors) LiteralArgumentBuilder(com.mojang.brigadier.builder.LiteralArgumentBuilder) Registry(net.minecraft.util.registry.Registry) List(java.util.List) ConfigSubscriber(at.haha007.edenclient.utils.config.ConfigSubscriber) Identifier(net.minecraft.util.Identifier) Optional(java.util.Optional) ClientPlayerEntity(net.minecraft.client.network.ClientPlayerEntity) IntegerArgumentType(com.mojang.brigadier.arguments.IntegerArgumentType) PlayerUtils(at.haha007.edenclient.utils.PlayerUtils) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Identifier(net.minecraft.util.Identifier) Optional(java.util.Optional) ClientCommandSource(net.minecraft.client.network.ClientCommandSource) ClientPlayerEntity(net.minecraft.client.network.ClientPlayerEntity)

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