Skip to content

Commit 9523730

Browse files
authored
1 parent c370261 commit 9523730

File tree

3 files changed

+86
-1
lines changed

3 files changed

+86
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@
6464
- Gamemode notifier
6565
- Ghost Mode (Taken from an [unmerged PR](https://github.com/MeteorDevelopment/meteor-client/pull/1932))
6666
- Glide (Ported from [Wurst](https://github.com/Wurst-Imperium/Wurst7/tree))
67-
- Insta Mine (Removed from Meteor in [62cd0](https://github.com/MeteorDevelopment/meteor-client/commit/62cd0461e48a6c50f040bf48de25be1fa4eba77e))
6867
- Item generator (Ported from [Wurst](https://github.com/Wurst-Imperium/Wurst7/tree))
6968
- InteractionMenu (Ported from [BleachHack](https://github.com/BleachDrinker420/BleachHack/pull/211))
7069
- Jetpack
@@ -107,6 +106,7 @@
107106
## Commands
108107
- `.center`
109108
- `.clear-chat` (Removed from meteor in [9aebf](https://github.com/MeteorDevelopment/meteor-client/commit/9aebf6a0e4ffa739d901c8b8d7f48d07af2fe839))
109+
- `.fill`
110110
- `.ghost` (Ported from [AntiGhost](https://github.com/gbl/AntiGhost/blob/fabric_1_16/src/main/java/de/guntram/mcmod/antighost/AntiGhost.java))
111111
- `.save-skin`
112112
- `.heads`

src/main/java/anticope/rejects/MeteorRejectsAddon.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ public void onInitialize() {
8989
// Commands
9090
Commands.add(new CenterCommand());
9191
Commands.add(new ClearChatCommand());
92+
Commands.add(new FillCommand());
9293
Commands.add(new GhostCommand());
9394
Commands.add(new GiveCommand());
9495
Commands.add(new HeadsCommand());
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
package anticope.rejects.commands;
2+
3+
import anticope.rejects.arguments.ClientPosArgumentType;
4+
import com.mojang.brigadier.arguments.StringArgumentType;
5+
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
6+
import meteordevelopment.meteorclient.commands.Command;
7+
import net.minecraft.block.BlockState;
8+
import net.minecraft.command.CommandSource;
9+
import net.minecraft.command.argument.BlockStateArgument;
10+
import net.minecraft.command.argument.BlockStateArgumentType;
11+
import net.minecraft.util.math.BlockPos;
12+
import net.minecraft.util.math.Vec3d;
13+
14+
public class FillCommand extends Command {
15+
16+
public FillCommand() {
17+
super("fill", "Fills a specified area with a block");
18+
}
19+
@Override
20+
public void build(LiteralArgumentBuilder<CommandSource> builder) {
21+
builder.then(argument("from-pos", ClientPosArgumentType.pos()).then(argument("to-pos", ClientPosArgumentType.pos()).then(argument("block", BlockStateArgumentType.blockState(REGISTRY_ACCESS)).executes(ctx -> {
22+
Vec3d fromPos = ClientPosArgumentType.getPos(ctx, "from-pos");
23+
Vec3d toPos = ClientPosArgumentType.getPos(ctx, "to-pos");
24+
BlockState blockState = ctx.getArgument("block", BlockStateArgument.class).getBlockState();
25+
26+
fillArea(fromPos, toPos, blockState, null);
27+
28+
return SINGLE_SUCCESS;
29+
}))));
30+
31+
builder.then(argument("from-pos", ClientPosArgumentType.pos()).then(argument("to-pos", ClientPosArgumentType.pos()).then(argument("block", BlockStateArgumentType.blockState(REGISTRY_ACCESS)).then(argument("replace", StringArgumentType.string()).then(argument("filter", BlockStateArgumentType.blockState(REGISTRY_ACCESS)).executes(ctx -> {
32+
Vec3d fromPos = ClientPosArgumentType.getPos(ctx, "from-pos");
33+
Vec3d toPos = ClientPosArgumentType.getPos(ctx, "to-pos");
34+
BlockState findBlock = ctx.getArgument("block", BlockStateArgument.class).getBlockState();
35+
BlockState filterBlock = ctx.getArgument("filter", BlockStateArgument.class).getBlockState();
36+
37+
fillArea(fromPos, toPos, findBlock, filterBlock);
38+
39+
return SINGLE_SUCCESS;
40+
}))))));
41+
}
42+
43+
private void fillArea(Vec3d fromPos, Vec3d toPos, BlockState blockState, BlockState filterBlock) {
44+
MinMaxCoords coords = getMinMaxCoords(fromPos, toPos);
45+
46+
for (int x = coords.minX; x <= coords.maxX; x++) {
47+
for (int y = coords.minY; y <= coords.maxY; y++) {
48+
for (int z = coords.minZ; z <= coords.maxZ; z++) {
49+
BlockPos pos = new BlockPos(x, y, z);
50+
51+
if (filterBlock == null || mc.world.getBlockState(pos).equals(filterBlock)) {
52+
mc.world.setBlockState(pos, blockState);
53+
}
54+
}
55+
}
56+
}
57+
}
58+
59+
//Send help
60+
private MinMaxCoords getMinMaxCoords(Vec3d fromPos, Vec3d toPos) {
61+
int minX = Math.min((int) fromPos.getX(), (int) toPos.getX());
62+
int maxX = Math.max((int) fromPos.getX(), (int) toPos.getX());
63+
int minY = Math.min((int) fromPos.getY(), (int) toPos.getY());
64+
int maxY = Math.max((int) fromPos.getY(), (int) toPos.getY());
65+
int minZ = Math.min((int) fromPos.getZ(), (int) toPos.getZ());
66+
int maxZ = Math.max((int) fromPos.getZ(), (int) toPos.getZ());
67+
68+
return new MinMaxCoords(minX, maxX, minY, maxY, minZ, maxZ);
69+
}
70+
//gotta have that clean code
71+
private static class MinMaxCoords {
72+
public final int minX, maxX, minY, maxY, minZ, maxZ;
73+
74+
public MinMaxCoords(int minX, int maxX, int minY, int maxY, int minZ, int maxZ) {
75+
this.minX = minX;
76+
this.maxX = maxX;
77+
this.minY = minY;
78+
this.maxY = maxY;
79+
this.minZ = minZ;
80+
this.maxZ = maxZ;
81+
}
82+
}
83+
84+
}

0 commit comments

Comments
 (0)