improved creative give
This commit is contained in:
@@ -4,9 +4,9 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
import net.minecraft.nbt.NbtList;
|
||||
import net.minecraft.network.packet.c2s.play.CreativeInventoryActionC2SPacket;
|
||||
import net.minecraft.text.LiteralText;
|
||||
|
||||
import cloudburst.rejects.utils.GiveUtils;
|
||||
import minegame159.meteorclient.gui.GuiTheme;
|
||||
import minegame159.meteorclient.gui.WindowScreen;
|
||||
import minegame159.meteorclient.gui.widgets.containers.WTable;
|
||||
@@ -18,7 +18,6 @@ import minegame159.meteorclient.settings.Settings;
|
||||
import minegame159.meteorclient.utils.network.HttpUtils;
|
||||
import minegame159.meteorclient.utils.network.MeteorExecutor;
|
||||
import minegame159.meteorclient.utils.player.ChatUtils;
|
||||
import minegame159.meteorclient.utils.player.SlotUtils;
|
||||
|
||||
import static minegame159.meteorclient.utils.Utils.mc;
|
||||
|
||||
@@ -31,6 +30,7 @@ import java.lang.reflect.Type;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
|
||||
public class HeadScreen extends WindowScreen {
|
||||
|
||||
@@ -95,7 +95,11 @@ public class HeadScreen extends WindowScreen {
|
||||
t.add(theme.label(head.getName().asString()));
|
||||
WButton give = t.add(theme.button("Give")).widget();
|
||||
give.action = () -> {
|
||||
addItem(head);
|
||||
try {
|
||||
GiveUtils.giveItem(head);
|
||||
} catch (CommandSyntaxException e) {
|
||||
ChatUtils.error("Heads", e.getMessage());
|
||||
}
|
||||
};
|
||||
WButton equip = t.add(theme.button("Equip")).widget();
|
||||
equip.tooltip = "Equip client-side.";
|
||||
@@ -127,17 +131,4 @@ public class HeadScreen extends WindowScreen {
|
||||
return head;
|
||||
}
|
||||
|
||||
private void addItem(ItemStack item) {
|
||||
if (!mc.player.getAbilities().creativeMode) {
|
||||
ChatUtils.error("Heads", "You must be in creative mode to use this.");
|
||||
return;
|
||||
}
|
||||
for(int i = 0; i < 36; i++) {
|
||||
ItemStack stack = mc.player.getInventory().getStack(SlotUtils.indexToId(i));
|
||||
if (stack == null || !stack.isEmpty() || stack.getItem() != Items.AIR) continue;
|
||||
mc.player.networkHandler.sendPacket(new CreativeInventoryActionC2SPacket(SlotUtils.indexToId(i), item));
|
||||
return;
|
||||
}
|
||||
ChatUtils.error("Heads", "No space in hotbar.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,9 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/*
|
||||
Ported from: https://github.com/BleachDrinker420/BleachHack/pull/211
|
||||
*/
|
||||
public class InteractionScreen extends Screen {
|
||||
|
||||
private final Entity entity;
|
||||
|
||||
Reference in New Issue
Block a user