Search in sources :

Example 1 with BlockStateArgumentAccessor

use of com.glisco.isometricrenders.mixin.BlockStateArgumentAccessor in project isometric-renders by gliscowo.

the class IsoRenderCommand method register.

public static void register(CommandDispatcher<FabricClientCommandSource> dispatcher) {
    dispatcher.register(literal("isorender").then(literal("block").executes(context -> executeBlockTarget(context.getSource())).then(argument("block", BlockStateArgumentType.blockState()).executes(context -> {
        final BlockStateArgument blockStateArgument = context.getArgument("block", BlockStateArgument.class);
        final BlockState blockState = blockStateArgument.getBlockState();
        return executeBlockState(context.getSource(), blockState, ((BlockStateArgumentAccessor) blockStateArgument).getData());
    }))).then(literal("item").executes(context -> {
        return executeItem(context.getSource(), context.getSource().getPlayer().getMainHandStack().copy());
    }).then(argument("item", ItemStackArgumentType.itemStack()).executes(context -> {
        final ItemStack stack = ItemStackArgumentType.getItemStackArgument(context, "item").createStack(1, false);
        return executeItem(context.getSource(), stack);
    }))).then(literal("entity").then(argument("entity", EntitySummonArgumentType.entitySummon()).suggests(CLIENT_SUMMONABLE_ENTITIES).executes(context -> {
        Identifier id = context.getArgument("entity", Identifier.class);
        return executeEntity(context.getSource(), EntitySummonArgumentTypeAccessor.invokeValidate(id), new CompoundTag());
    }).then(argument("nbt", NbtCompoundTagArgumentType.nbtCompound()).executes(context -> {
        Identifier id = context.getArgument("entity", Identifier.class);
        return executeEntity(context.getSource(), EntitySummonArgumentTypeAccessor.invokeValidate(id), context.getArgument("nbt", CompoundTag.class));
    })))).then(literal("insanity").executes(context -> {
        RuntimeConfig.allowInsaneResolutions = !RuntimeConfig.allowInsaneResolutions;
        if (RuntimeConfig.allowInsaneResolutions) {
            context.getSource().sendFeedback(prefix("Insane resolutions §cunlocked§7. I will not be your place to cry if this blows up your computer."));
        } else {
            context.getSource().sendFeedback(prefix("Insane resolutions §alocked§7. You're safe again"));
        }
        return 0;
    })).then(literal("area").then(argument("start", BlockPosArgumentType.blockPos()).then(argument("end", BlockPosArgumentType.blockPos()).executes(context -> {
        DefaultPosArgument startArg = context.getArgument("start", DefaultPosArgument.class);
        DefaultPosArgument endArg = context.getArgument("end", DefaultPosArgument.class);
        BlockPos pos1 = IsometricRenderHelper.getPosFromArgument(startArg, context.getSource());
        BlockPos pos2 = IsometricRenderHelper.getPosFromArgument(endArg, context.getSource());
        BlockPos start = new BlockPos(Math.min(pos1.getX(), pos2.getX()), Math.min(pos1.getY(), pos2.getY()), Math.min(pos1.getZ(), pos2.getZ()));
        BlockPos end = new BlockPos(Math.max(pos1.getX(), pos2.getX()), Math.max(pos1.getY(), pos2.getY()), Math.max(pos1.getZ(), pos2.getZ()));
        AreaIsometricRenderScreen screen = new AreaIsometricRenderScreen();
        IsometricRenderPresets.setupAreaRender(screen, start, end);
        IsometricRenderHelper.scheduleScreen(screen);
        return 0;
    })))).then(literal("creative_tab").then(argument("itemgroup", ItemGroupArgumentType.itemGroup()).suggests(ITEM_GROUPS).then(literal("batch").then(literal("blocks").executes(context -> {
        ItemGroup group = context.getArgument("itemgroup", ItemGroup.class);
        IsometricRenderHelper.batchRenderItemGroupBlocks(group);
        return 0;
    })).then(literal("items").executes(context -> {
        ItemGroup group = context.getArgument("itemgroup", ItemGroup.class);
        IsometricRenderHelper.batchRenderItemGroupItems(group);
        return 0;
    }))).then(literal("atlas").executes(context -> {
        ItemGroup group = context.getArgument("itemgroup", ItemGroup.class);
        IsometricRenderHelper.renderItemGroupAtlas(group);
        return 0;
    })))));
}
Also used : BlockEntityAccessor(com.glisco.isometricrenders.mixin.BlockEntityAccessor) net.minecraft.command.argument(net.minecraft.command.argument) EntityType(net.minecraft.entity.EntityType) ClientCommandManager.argument(net.fabricmc.fabric.api.client.command.v1.ClientCommandManager.argument) Arrays(java.util.Arrays) CommandDispatcher(com.mojang.brigadier.CommandDispatcher) BlockEntity(net.minecraft.block.entity.BlockEntity) Util(net.minecraft.util.Util) EntitySummonArgumentTypeAccessor(com.glisco.isometricrenders.mixin.EntitySummonArgumentTypeAccessor) TranslatableText(net.minecraft.text.TranslatableText) MobEntity(net.minecraft.entity.mob.MobEntity) Function(java.util.function.Function) Direction(net.minecraft.util.math.Direction) ItemStack(net.minecraft.item.ItemStack) Block(net.minecraft.block.Block) IsometricRendersClient.prefix(com.glisco.isometricrenders.client.IsometricRendersClient.prefix) SuggestionProvider(com.mojang.brigadier.suggestion.SuggestionProvider) BlockState(net.minecraft.block.BlockState) IsometricRenderPresets(com.glisco.isometricrenders.client.gui.IsometricRenderPresets) Entity(net.minecraft.entity.Entity) IsometricRenderScreen(com.glisco.isometricrenders.client.gui.IsometricRenderScreen) FabricClientCommandSource(net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource) World(net.minecraft.world.World) BlockWithEntity(net.minecraft.block.BlockWithEntity) BlockHitResult(net.minecraft.util.hit.BlockHitResult) BlockPos(net.minecraft.util.math.BlockPos) Registry(net.minecraft.util.registry.Registry) CommandSource(net.minecraft.command.CommandSource) HitResult(net.minecraft.util.hit.HitResult) AreaIsometricRenderScreen(com.glisco.isometricrenders.client.gui.AreaIsometricRenderScreen) CompoundTag(net.minecraft.nbt.CompoundTag) ItemGroup(net.minecraft.item.ItemGroup) Identifier(net.minecraft.util.Identifier) BlockStateArgumentAccessor(com.glisco.isometricrenders.mixin.BlockStateArgumentAccessor) MinecraftClient(net.minecraft.client.MinecraftClient) Text(net.minecraft.text.Text) ClientCommandManager.literal(net.fabricmc.fabric.api.client.command.v1.ClientCommandManager.literal) IsometricRenderHelper(com.glisco.isometricrenders.client.gui.IsometricRenderHelper) AreaIsometricRenderScreen(com.glisco.isometricrenders.client.gui.AreaIsometricRenderScreen) BlockState(net.minecraft.block.BlockState) Identifier(net.minecraft.util.Identifier) ItemGroup(net.minecraft.item.ItemGroup) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack) CompoundTag(net.minecraft.nbt.CompoundTag)

Aggregations

IsometricRendersClient.prefix (com.glisco.isometricrenders.client.IsometricRendersClient.prefix)1 AreaIsometricRenderScreen (com.glisco.isometricrenders.client.gui.AreaIsometricRenderScreen)1 IsometricRenderHelper (com.glisco.isometricrenders.client.gui.IsometricRenderHelper)1 IsometricRenderPresets (com.glisco.isometricrenders.client.gui.IsometricRenderPresets)1 IsometricRenderScreen (com.glisco.isometricrenders.client.gui.IsometricRenderScreen)1 BlockEntityAccessor (com.glisco.isometricrenders.mixin.BlockEntityAccessor)1 BlockStateArgumentAccessor (com.glisco.isometricrenders.mixin.BlockStateArgumentAccessor)1 EntitySummonArgumentTypeAccessor (com.glisco.isometricrenders.mixin.EntitySummonArgumentTypeAccessor)1 CommandDispatcher (com.mojang.brigadier.CommandDispatcher)1 SuggestionProvider (com.mojang.brigadier.suggestion.SuggestionProvider)1 Arrays (java.util.Arrays)1 Function (java.util.function.Function)1 ClientCommandManager.argument (net.fabricmc.fabric.api.client.command.v1.ClientCommandManager.argument)1 ClientCommandManager.literal (net.fabricmc.fabric.api.client.command.v1.ClientCommandManager.literal)1 FabricClientCommandSource (net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource)1 Block (net.minecraft.block.Block)1 BlockState (net.minecraft.block.BlockState)1 BlockWithEntity (net.minecraft.block.BlockWithEntity)1 BlockEntity (net.minecraft.block.entity.BlockEntity)1 MinecraftClient (net.minecraft.client.MinecraftClient)1