@@ -2,12 +2,15 @@ package anticope.rejects.commands;
|
||||
|
||||
import anticope.rejects.arguments.EnumStringArgumentType;
|
||||
import anticope.rejects.utils.GiveUtils;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import meteordevelopment.meteorclient.commands.Command;
|
||||
import net.minecraft.command.CommandSource;
|
||||
import net.minecraft.component.ComponentChanges;
|
||||
import net.minecraft.component.DataComponentTypes;
|
||||
import net.minecraft.component.type.NbtComponent;
|
||||
import net.minecraft.component.type.ProfileComponent;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
@@ -20,8 +23,7 @@ import net.minecraft.text.Text;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import static com.mojang.brigadier.Command.SINGLE_SUCCESS;
|
||||
import static meteordevelopment.meteorclient.MeteorClient.mc;
|
||||
import static anticope.rejects.utils.accounts.GetPlayerUUID.getUUID;
|
||||
|
||||
public class GiveCommand extends Command {
|
||||
|
||||
@@ -33,86 +35,98 @@ public class GiveCommand extends Command {
|
||||
|
||||
@Override
|
||||
public void build(LiteralArgumentBuilder<CommandSource> builder) {
|
||||
// TODO : finish this
|
||||
builder.then(literal("egg").executes(ctx -> {
|
||||
ItemStack inHand = mc.player.getMainHandStack();
|
||||
ItemStack item = new ItemStack(Items.STRIDER_SPAWN_EGG);
|
||||
NbtCompound ct = new NbtCompound();
|
||||
|
||||
NbtCompound itemNbt = inHand
|
||||
.getOrDefault(DataComponentTypes.CUSTOM_DATA, NbtComponent.DEFAULT)
|
||||
.copyNbt();
|
||||
|
||||
if (inHand.getItem() instanceof BlockItem) {
|
||||
itemNbt.putInt("Time", 1);
|
||||
itemNbt.putString("id", "minecraft:falling_block");
|
||||
itemNbt.put("BlockState", new NbtCompound());
|
||||
itemNbt.getCompound("BlockState").putString("Name", Registries.ITEM.getId(inHand.getItem()).toString());
|
||||
if (inHand.getComponents().contains(DataComponentTypes.BLOCK_ENTITY_DATA)) {
|
||||
itemNbt.put("TileEntityData", inHand.get(DataComponentTypes.BLOCK_ENTITY_DATA).copyNbt());
|
||||
}
|
||||
NbtCompound t = new NbtCompound();
|
||||
t.put("EntityTag", ct);
|
||||
item.set(DataComponentTypes.CUSTOM_DATA, NbtComponent.of(itemNbt));
|
||||
ct.putInt("Time", 1);
|
||||
ct.putString("id", "minecraft:falling_block");
|
||||
ct.put("BlockState", new NbtCompound());
|
||||
ct.getCompound("BlockState").putString("Name", Registries.ITEM.getId(inHand.getItem()).toString());
|
||||
|
||||
} else {
|
||||
ct.putString("id", "minecraft:item");
|
||||
NbtCompound it = new NbtCompound();
|
||||
it.putString("id", Registries.ITEM.getId(inHand.getItem()).toString());
|
||||
it.putInt("Count", inHand.getCount());
|
||||
if (!inHand.getComponents().isEmpty()) {
|
||||
it.put("tag", inHand.getOrDefault(DataComponentTypes.CUSTOM_DATA, NbtComponent.DEFAULT).copyNbt());
|
||||
}
|
||||
ct.put("Item", it);
|
||||
NbtCompound itemTag = new NbtCompound();
|
||||
itemTag.putString("id", Registries.ITEM.getId(inHand.getItem()).toString());
|
||||
itemTag.putInt("Count", inHand.getCount());
|
||||
|
||||
ct.put("Item", itemTag);
|
||||
}
|
||||
NbtCompound t = new NbtCompound();
|
||||
t.put("EntityTag", ct);
|
||||
item.set(DataComponentTypes.CUSTOM_DATA, NbtComponent.of(t));
|
||||
item.set(DataComponentTypes.CUSTOM_NAME, inHand.getName());
|
||||
|
||||
var changes = ComponentChanges.builder()
|
||||
.add(DataComponentTypes.CUSTOM_NAME, inHand.getName())
|
||||
.add(DataComponentTypes.CUSTOM_DATA, NbtComponent.of(t))
|
||||
.build();
|
||||
|
||||
item.applyChanges(changes);
|
||||
GiveUtils.giveItem(item);
|
||||
return SINGLE_SUCCESS;
|
||||
}));
|
||||
|
||||
//TODO: allow for custom cords to place oob
|
||||
//TODO: allow for custom cords to place oob, though optional args
|
||||
builder.then(literal("holo").then(argument("message", StringArgumentType.greedyString()).executes(ctx -> {
|
||||
String message = ctx.getArgument("message", String.class).replace("&", "\247");
|
||||
ItemStack stack = new ItemStack(Items.ARMOR_STAND);
|
||||
ItemStack stack = new ItemStack(Items.STRIDER_SPAWN_EGG);
|
||||
NbtCompound tag = new NbtCompound();
|
||||
NbtList NbtList = new NbtList();
|
||||
NbtList.add(NbtDouble.of(mc.player.getX()));
|
||||
NbtList.add(NbtDouble.of(mc.player.getY()));
|
||||
NbtList.add(NbtDouble.of(mc.player.getZ()));
|
||||
NbtList pos = new NbtList();
|
||||
|
||||
pos.add(NbtDouble.of(mc.player.getX()));
|
||||
pos.add(NbtDouble.of(mc.player.getY()));
|
||||
pos.add(NbtDouble.of(mc.player.getZ()));
|
||||
|
||||
tag.putString("id", "minecraft:armor_stand");
|
||||
tag.put("Pos", pos);
|
||||
tag.putBoolean("Invisible", true);
|
||||
tag.putBoolean("Invulnerable", true);
|
||||
tag.putBoolean("Interpret", true);
|
||||
tag.putBoolean("NoGravity", true);
|
||||
tag.putBoolean("CustomNameVisible", true);
|
||||
tag.putString("CustomName", Text.literal(message).toString());
|
||||
tag.put("Pos", NbtList);
|
||||
stack.set(DataComponentTypes.ENTITY_DATA, NbtComponent.of(tag));
|
||||
|
||||
var changes = ComponentChanges.builder()
|
||||
.add(DataComponentTypes.CUSTOM_NAME, Text.literal(message))
|
||||
.add(DataComponentTypes.ENTITY_DATA, NbtComponent.of(tag))
|
||||
.build();
|
||||
|
||||
stack.applyChanges(changes);
|
||||
GiveUtils.giveItem(stack);
|
||||
return SINGLE_SUCCESS;
|
||||
})));
|
||||
|
||||
//TODO, make invisible through potion effect
|
||||
builder.then(literal("bossbar").then(argument("message", StringArgumentType.greedyString()).executes(ctx -> {
|
||||
String message = ctx.getArgument("message", String.class).replace("&", "\247");
|
||||
ItemStack stack = new ItemStack(Items.BAT_SPAWN_EGG);
|
||||
NbtCompound tag = new NbtCompound();
|
||||
tag.putString("CustomName", Text.literal(message).toString());
|
||||
tag.putBoolean("NoAI", true);
|
||||
tag.putBoolean("Silent", true);
|
||||
tag.putBoolean("PersistenceRequired", true);
|
||||
tag.putBoolean("Invisible", true);
|
||||
tag.put("id", NbtString.of("minecraft:wither"));
|
||||
stack.set(DataComponentTypes.ENTITY_DATA, NbtComponent.of(tag));
|
||||
|
||||
var changes = ComponentChanges.builder()
|
||||
.add(DataComponentTypes.CUSTOM_NAME, Text.literal(message))
|
||||
.add(DataComponentTypes.ENTITY_DATA, NbtComponent.of(tag))
|
||||
.build();
|
||||
stack.applyChanges(changes);
|
||||
|
||||
GiveUtils.giveItem(stack);
|
||||
return SINGLE_SUCCESS;
|
||||
})));
|
||||
|
||||
// TODO : resolve textures, should be easy now that UUID is resolved
|
||||
builder.then(literal("head").then(argument("owner", StringArgumentType.greedyString()).executes(ctx -> {
|
||||
String playerName = ctx.getArgument("owner", String.class);
|
||||
ItemStack itemStack = new ItemStack(Items.PLAYER_HEAD);
|
||||
NbtCompound tag = new NbtCompound();
|
||||
tag.putString("SkullOwner", playerName);
|
||||
itemStack.set(DataComponentTypes.CUSTOM_DATA, NbtComponent.of(tag));
|
||||
|
||||
var changes = ComponentChanges.builder()
|
||||
.add(DataComponentTypes.PROFILE, new ProfileComponent(new GameProfile(getUUID(playerName), playerName)))
|
||||
.build();
|
||||
|
||||
itemStack.applyChanges(changes);
|
||||
|
||||
GiveUtils.giveItem(itemStack);
|
||||
return SINGLE_SUCCESS;
|
||||
})));
|
||||
|
||||
Reference in New Issue
Block a user