improved creative give

This commit is contained in:
Cloudburst
2021-06-13 12:55:08 +02:00
parent 2d1381a648
commit e787518284
9 changed files with 217 additions and 366 deletions

View File

@@ -3,7 +3,7 @@
![Last commit](https://img.shields.io/github/last-commit/C10udburst/meteor-rejects) ![Last commit](https://img.shields.io/github/last-commit/C10udburst/meteor-rejects)
An addon to Meteor Client that adds modules and commands that were too useless to be added to Meteor directly. An addon to Meteor Client that adds modules and commands that were too useless to be added to Meteor directly.
Also includes unmerged PRs. Also includes unmerged PRs. Some features are blatantly stolen from other clients ([Cornos](https://github.com/cornos/Cornos), [BleachHack](https://github.com/BleachDrinker420/BleachHack)).
### How to use: ### How to use:
- Download the latest release of this mod from the releases tab. - Download the latest release of this mod from the releases tab.

View File

@@ -17,6 +17,7 @@ import java.lang.invoke.MethodHandles;
import cloudburst.rejects.commands.*; import cloudburst.rejects.commands.*;
import cloudburst.rejects.gui.hud.*; import cloudburst.rejects.gui.hud.*;
import cloudburst.rejects.modules.*; import cloudburst.rejects.modules.*;
import cloudburst.rejects.utils.GiveUtils;
import cloudburst.rejects.utils.Utils; import cloudburst.rejects.utils.Utils;
public class MeteorRejectsAddon extends MeteorAddon { public class MeteorRejectsAddon extends MeteorAddon {
@@ -28,7 +29,9 @@ public class MeteorRejectsAddon extends MeteorAddon {
LOG.info("Initializing Meteor Rejects Addon"); LOG.info("Initializing Meteor Rejects Addon");
MeteorClient.EVENT_BUS.registerLambdaFactory("cloudburst.rejects", (lookupInMethod, klass) -> (MethodHandles.Lookup) lookupInMethod.invoke(null, klass, MethodHandles.lookup())); MeteorClient.EVENT_BUS.registerLambdaFactory("cloudburst.rejects", (lookupInMethod, klass) -> (MethodHandles.Lookup) lookupInMethod.invoke(null, klass, MethodHandles.lookup()));
Utils.init(); Utils.init();
GiveUtils.init();
Modules modules = Modules.get(); Modules modules = Modules.get();
modules.add(new AntiBot()); modules.add(new AntiBot());

View File

@@ -3,21 +3,17 @@ package cloudburst.rejects.commands;
import com.mojang.brigadier.arguments.StringArgumentType; import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.builder.LiteralArgumentBuilder; import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
import net.minecraft.command.CommandSource; import net.minecraft.command.CommandSource;
import net.minecraft.item.*; import net.minecraft.item.*;
import net.minecraft.nbt.*; import net.minecraft.nbt.*;
import net.minecraft.network.packet.c2s.play.CreativeInventoryActionC2SPacket;
import cloudburst.rejects.arguments.EnumStringArgumentType; import cloudburst.rejects.arguments.EnumStringArgumentType;
import cloudburst.rejects.utils.GiveUtils;
import minegame159.meteorclient.systems.commands.Command; import minegame159.meteorclient.systems.commands.Command;
import minegame159.meteorclient.utils.player.SlotUtils;
import net.minecraft.text.LiteralText; import net.minecraft.text.LiteralText;
import net.minecraft.text.Text; import net.minecraft.text.Text;
import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.Registry;
import static cloudburst.rejects.utils.GiveUtils.createPreset;
import static com.mojang.brigadier.Command.SINGLE_SUCCESS; import static com.mojang.brigadier.Command.SINGLE_SUCCESS;
import java.util.*; import java.util.*;
@@ -27,18 +23,11 @@ public class GiveCommand extends Command {
public GiveCommand() { public GiveCommand() {
super("give", "Gives items in creative", "item", "kit"); super("give", "Gives items in creative", "item", "kit");
} }
private final Collection<String> PRESETS = GiveUtils.PRESETS.keySet();
private final static SimpleCommandExceptionType NOT_IN_CREATIVE = new SimpleCommandExceptionType(new LiteralText("You must be in creative mode to use this."));
private final static SimpleCommandExceptionType NO_SPACE = new SimpleCommandExceptionType(new LiteralText("No space in hotbar"));
private final Collection<String> PRESETS = Arrays.asList("forceop", "negs", "stacked", "spawners", "bookban",
"test", "eggs");
private final Collection<String> CONTAINERS = Arrays.asList("chest", "shulker", "trapped_chest", "barrel",
"dispenser", "egg");
@Override @Override
public void build(LiteralArgumentBuilder<CommandSource> builder) { public void build(LiteralArgumentBuilder<CommandSource> builder) {
builder.then(literal("egg").executes(ctx -> { builder.then(literal("egg").executes(ctx -> {
if (!mc.player.getAbilities().creativeMode) throw NOT_IN_CREATIVE.create();
ItemStack inHand = mc.player.getMainHandStack(); ItemStack inHand = mc.player.getMainHandStack();
ItemStack item = new ItemStack(Items.STRIDER_SPAWN_EGG); ItemStack item = new ItemStack(Items.STRIDER_SPAWN_EGG);
NbtCompound ct = new NbtCompound(); NbtCompound ct = new NbtCompound();
@@ -67,12 +56,11 @@ public class GiveCommand extends Command {
t.put("EntityTag", ct); t.put("EntityTag", ct);
item.setTag(t); item.setTag(t);
item.setCustomName(inHand.getName()); item.setCustomName(inHand.getName());
addItem(item); GiveUtils.giveItem(item);
return SINGLE_SUCCESS; return SINGLE_SUCCESS;
})); }));
builder.then(literal("holo").then(argument("message", StringArgumentType.greedyString()).executes(ctx -> { builder.then(literal("holo").then(argument("message", StringArgumentType.greedyString()).executes(ctx -> {
if (!mc.player.getAbilities().creativeMode) throw NOT_IN_CREATIVE.create();
String message = ctx.getArgument("message", String.class); String message = ctx.getArgument("message", String.class);
message = message.replace("&", "\247"); message = message.replace("&", "\247");
ItemStack stack = new ItemStack(Items.ARMOR_STAND); ItemStack stack = new ItemStack(Items.ARMOR_STAND);
@@ -89,67 +77,24 @@ public class GiveCommand extends Command {
tag.putString("CustomName", Text.Serializer.toJson(new LiteralText(message))); tag.putString("CustomName", Text.Serializer.toJson(new LiteralText(message)));
tag.put("Pos", NbtList); tag.put("Pos", NbtList);
stack.putSubTag("EntityTag", tag); stack.putSubTag("EntityTag", tag);
addItem(stack); GiveUtils.giveItem(stack);
return SINGLE_SUCCESS; return SINGLE_SUCCESS;
}))); })));
builder.then(literal("firework").executes(ctx -> {
if (!mc.player.getAbilities().creativeMode) throw NOT_IN_CREATIVE.create();
ItemStack firework = new ItemStack(Items.FIREWORK_ROCKET);
NbtCompound baseCompound = new NbtCompound();
NbtCompound tagCompound = new NbtCompound();
NbtList explosionList = new NbtList();
for(int i = 0; i < 5000; i++)
{
NbtCompound explosionCompound = new NbtCompound();
Random rand = new Random();
explosionCompound.putByte("Type", (byte)rand.nextInt(5));
int colors[] = {1973019,11743532,3887386,5320730,2437522,8073150,2651799,11250603,4408131,14188952,4312372,14602026,6719955,12801229,15435844,15790320};
explosionCompound.putIntArray("Colors", colors);
explosionList.add(explosionCompound);
}
tagCompound.putInt("Flight", 0);
tagCompound.put("Explosions", explosionList);
baseCompound.put("Fireworks", tagCompound);
firework.setTag(baseCompound);
addItem(firework);
return SINGLE_SUCCESS;
}));
builder.then(literal("head").then(argument("owner",StringArgumentType.greedyString()).executes(ctx -> { builder.then(literal("head").then(argument("owner",StringArgumentType.greedyString()).executes(ctx -> {
if (!mc.player.getAbilities().creativeMode) throw NOT_IN_CREATIVE.create();
String playerName = ctx.getArgument("owner",String.class); String playerName = ctx.getArgument("owner",String.class);
ItemStack itemStack = new ItemStack(Items.PLAYER_HEAD); ItemStack itemStack = new ItemStack(Items.PLAYER_HEAD);
NbtCompound tag = new NbtCompound(); NbtCompound tag = new NbtCompound();
tag.putString("SkullOwner", playerName); tag.putString("SkullOwner", playerName);
itemStack.setTag(tag); itemStack.setTag(tag);
addItem(itemStack); GiveUtils.giveItem(itemStack);
return SINGLE_SUCCESS; return SINGLE_SUCCESS;
}))); })));
builder.then(literal("preset").then(argument("name", new EnumStringArgumentType(PRESETS)) builder.then(literal("preset").then(argument("name", new EnumStringArgumentType(PRESETS)).executes(context -> {
.then(argument("container", new EnumStringArgumentType(CONTAINERS)).executes(context -> {
if (!mc.player.getAbilities().creativeMode) throw NOT_IN_CREATIVE.create();
String name = context.getArgument("name", String.class); String name = context.getArgument("name", String.class);
String container = context.getArgument("container", String.class); GiveUtils.giveItem(GiveUtils.getPreset(name));
addItem(createPreset(name, container));
return SINGLE_SUCCESS; return SINGLE_SUCCESS;
})))); })));
}
private void addItem(ItemStack item) throws CommandSyntaxException {
for(int i = 0; i < 36; i++) {
ItemStack stack = mc.player.getInventory().getStack(SlotUtils.indexToId(i));
if (!stack.isEmpty()) continue;
mc.player.networkHandler.sendPacket(new CreativeInventoryActionC2SPacket(SlotUtils.indexToId(i), item));
return;
}
throw NO_SPACE.create();
} }
} }

View File

@@ -28,6 +28,10 @@ import java.util.List;
import com.mojang.brigadier.arguments.IntegerArgumentType; import com.mojang.brigadier.arguments.IntegerArgumentType;
/*
Ported from Cornos
https://github.com/cornos/Cornos/blob/master/src/main/java/me/zeroX150/cornos/features/command/impl/Scan.java
*/
public class ServerCommand extends Command { public class ServerCommand extends Command {
private final static SimpleCommandExceptionType ADDRESS_ERROR = new SimpleCommandExceptionType(new LiteralText("Couldn't obtain server address")); private final static SimpleCommandExceptionType ADDRESS_ERROR = new SimpleCommandExceptionType(new LiteralText("Couldn't obtain server address"));

View File

@@ -4,9 +4,9 @@ import net.minecraft.item.ItemStack;
import net.minecraft.item.Items; import net.minecraft.item.Items;
import net.minecraft.nbt.NbtCompound; import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtList; import net.minecraft.nbt.NbtList;
import net.minecraft.network.packet.c2s.play.CreativeInventoryActionC2SPacket;
import net.minecraft.text.LiteralText; import net.minecraft.text.LiteralText;
import cloudburst.rejects.utils.GiveUtils;
import minegame159.meteorclient.gui.GuiTheme; import minegame159.meteorclient.gui.GuiTheme;
import minegame159.meteorclient.gui.WindowScreen; import minegame159.meteorclient.gui.WindowScreen;
import minegame159.meteorclient.gui.widgets.containers.WTable; 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.HttpUtils;
import minegame159.meteorclient.utils.network.MeteorExecutor; import minegame159.meteorclient.utils.network.MeteorExecutor;
import minegame159.meteorclient.utils.player.ChatUtils; import minegame159.meteorclient.utils.player.ChatUtils;
import minegame159.meteorclient.utils.player.SlotUtils;
import static minegame159.meteorclient.utils.Utils.mc; 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.common.reflect.TypeToken;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.GsonBuilder; import com.google.gson.GsonBuilder;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
public class HeadScreen extends WindowScreen { public class HeadScreen extends WindowScreen {
@@ -95,7 +95,11 @@ public class HeadScreen extends WindowScreen {
t.add(theme.label(head.getName().asString())); t.add(theme.label(head.getName().asString()));
WButton give = t.add(theme.button("Give")).widget(); WButton give = t.add(theme.button("Give")).widget();
give.action = () -> { give.action = () -> {
addItem(head); try {
GiveUtils.giveItem(head);
} catch (CommandSyntaxException e) {
ChatUtils.error("Heads", e.getMessage());
}
}; };
WButton equip = t.add(theme.button("Equip")).widget(); WButton equip = t.add(theme.button("Equip")).widget();
equip.tooltip = "Equip client-side."; equip.tooltip = "Equip client-side.";
@@ -127,17 +131,4 @@ public class HeadScreen extends WindowScreen {
return head; 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.");
}
} }

View File

@@ -32,6 +32,9 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.function.Consumer; import java.util.function.Consumer;
/*
Ported from: https://github.com/BleachDrinker420/BleachHack/pull/211
*/
public class InteractionScreen extends Screen { public class InteractionScreen extends Screen {
private final Entity entity; private final Entity entity;

View File

@@ -46,7 +46,7 @@ public class Gravity extends Module {
} }
else if (moon.get()) { else if (moon.get()) {
Vec3d velocity = mc.player.getVelocity(); Vec3d velocity = mc.player.getVelocity();
((IVec3d) velocity).set(velocity.x, velocity.y + 0.0568000030517578, velocity.z); // Yes, this was precisely calculated. ((IVec3d) velocity).set(velocity.x, velocity.y + 0.0568000030517578, velocity.z); // Yes, this was precisely calculated by the cornos dev (https://github.com/cornos/Cornos/blob/master/src/main/java/me/zeroX150/cornos/features/module/impl/movement/MoonGravity.java)
} }
} }
} }

View File

@@ -17,6 +17,9 @@ import net.minecraft.world.chunk.WorldChunk;
import java.util.*; import java.util.*;
/*
Ported from: https://github.com/BleachDrinker420/BleachHack/blob/master/BleachHack-Fabric-1.16/src/main/java/bleach/hack/module/mods/NewChunks.java
*/
public class NewChunks extends Module { public class NewChunks extends Module {
private final SettingGroup sgGeneral = settings.getDefaultGroup(); private final SettingGroup sgGeneral = settings.getDefaultGroup();

File diff suppressed because one or more lines are too long