CreateMod/src/main/java/com/simibubi/create/foundation/command/GlueCommand.java
PepperBell 6800c24c58 Fix command permission requirements
- Commands glue, highlight, and replaceInCommandBlocks now require OP
level 2 instead of 0
2021-09-05 21:14:41 -07:00

33 lines
1.1 KiB
Java

package com.simibubi.create.foundation.command;
import com.mojang.brigadier.builder.ArgumentBuilder;
import com.simibubi.create.content.contraptions.components.structureMovement.glue.SuperGlueEntity;
import net.minecraft.command.CommandSource;
import net.minecraft.command.Commands;
import net.minecraft.command.arguments.BlockPosArgument;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.server.ServerWorld;
public class GlueCommand {
public static ArgumentBuilder<CommandSource, ?> register() {
return Commands.literal("glue")
.requires(cs -> cs.hasPermission(2))
.then(Commands.argument("pos", BlockPosArgument.blockPos())
//.then(Commands.argument("direction", EnumArgument.enumArgument(Direction.class))
.executes(ctx -> {
BlockPos pos = BlockPosArgument.getOrLoadBlockPos(ctx, "pos");
ServerWorld world = ctx.getSource().getLevel();
SuperGlueEntity entity = new SuperGlueEntity(world, pos, Direction.UP);
entity.playPlaceSound();
world.addFreshEntity(entity);
return 1;
}));
}
}