Skip to content

Commit c4e0fb5

Browse files
committed
Added Bonemeal Aura
1 parent 9d5c6f0 commit c4e0fb5

4 files changed

Lines changed: 150 additions & 2 deletions

File tree

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ yarn_mappings=1.20.6+build.1
77
loader_version=0.15.11
88

99
# Mod Properties
10-
mod_version=2.2
10+
mod_version=2.3
1111
maven_group=cqb13.NumbyHack
1212
archives_base_name=Numby-Hack
1313

src/main/java/cqb13/NumbyHack/NumbyHack.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public void onInitialize() {
4343
Modules.get().add(new AutoLogPlus());
4444
Modules.get().add(new BetterPlace());
4545
Modules.get().add(new Beyblade());
46+
Modules.get().add(new BonemealAura());
4647
Modules.get().add(new ChatEncryption());
4748
Modules.get().add(new ChorusExploit());
4849
Modules.get().add(new ConditionToggle());
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
package cqb13.NumbyHack.modules.general;
2+
3+
import cqb13.NumbyHack.NumbyHack;
4+
import meteordevelopment.meteorclient.events.render.Render3DEvent;
5+
import meteordevelopment.meteorclient.events.world.TickEvent;
6+
import meteordevelopment.meteorclient.renderer.ShapeMode;
7+
import meteordevelopment.meteorclient.settings.*;
8+
import meteordevelopment.meteorclient.systems.modules.Module;
9+
import meteordevelopment.meteorclient.utils.Utils;
10+
import meteordevelopment.meteorclient.utils.player.FindItemResult;
11+
import meteordevelopment.meteorclient.utils.player.InvUtils;
12+
import meteordevelopment.meteorclient.utils.player.Rotations;
13+
import meteordevelopment.meteorclient.utils.render.color.SettingColor;
14+
import meteordevelopment.orbit.EventHandler;
15+
import net.minecraft.block.AzaleaBlock;
16+
import net.minecraft.block.Block;
17+
import net.minecraft.block.CocoaBlock;
18+
import net.minecraft.block.CropBlock;
19+
import net.minecraft.block.MushroomPlantBlock;
20+
import net.minecraft.block.SaplingBlock;
21+
import net.minecraft.block.StemBlock;
22+
import net.minecraft.block.SweetBerryBushBlock;
23+
import net.minecraft.item.Items;
24+
import net.minecraft.network.packet.c2s.play.PlayerInteractBlockC2SPacket;
25+
import net.minecraft.util.Hand;
26+
import net.minecraft.util.hit.BlockHitResult;
27+
import net.minecraft.util.math.BlockPos;
28+
import net.minecraft.util.math.Direction;
29+
30+
public class BonemealAura extends Module {
31+
private final SettingGroup sgGeneral = settings.getDefaultGroup();
32+
private final SettingGroup sgRender = settings.createGroup("Render");
33+
34+
private final Setting<Integer> horizontalRange = sgGeneral.add(new IntSetting.Builder()
35+
.name("horizontal-range")
36+
.description("How far around the player to bonemeal.")
37+
.defaultValue(4)
38+
.min(1)
39+
.sliderRange(1, 6)
40+
.build()
41+
);
42+
43+
private final Setting<Integer> verticalRange = sgGeneral.add(new IntSetting.Builder()
44+
.name("vertical-range")
45+
.description("How high above the player to bonemeal.")
46+
.defaultValue(2)
47+
.min(1)
48+
.sliderRange(1, 6)
49+
.build()
50+
);
51+
52+
53+
private final Setting<ShapeMode> shapeMode = sgRender.add(new EnumSetting.Builder<ShapeMode>()
54+
.name("shape-mode")
55+
.description("How the shapes are rendered.")
56+
.defaultValue(ShapeMode.Both)
57+
.build()
58+
);
59+
60+
private final Setting<SettingColor> sideColor = sgRender.add(new ColorSetting.Builder()
61+
.name("side-color")
62+
.description("The side color of the target block rendering.")
63+
.defaultValue(new SettingColor(146,188,98, 75))
64+
.build()
65+
);
66+
67+
private final Setting<SettingColor> lineColor = sgRender.add(new ColorSetting.Builder()
68+
.name("line-color")
69+
.description("The line color of the target block rendering.")
70+
.defaultValue(new SettingColor(146,188,98, 190))
71+
.build()
72+
);
73+
74+
public BonemealAura() {
75+
super(NumbyHack.CATEGORY, "bonemeal-aura", "Automatically bonemeal crops around the player");
76+
}
77+
78+
public boolean isBonemealing;
79+
80+
@EventHandler
81+
private void onTick(TickEvent.Pre event) {
82+
BlockPos crop = getCrop();
83+
if (crop == null) {
84+
isBonemealing = false;
85+
return;
86+
}
87+
88+
FindItemResult bonemeal = InvUtils.findInHotbar(Items.BONE_MEAL);
89+
if (!bonemeal.found()) {
90+
isBonemealing = false;
91+
return;
92+
}
93+
94+
95+
isBonemealing = true;
96+
Rotations.rotate(Rotations.getYaw(crop), Rotations.getPitch(crop), () -> {
97+
InvUtils.swap(bonemeal.slot(), false);
98+
mc.player.networkHandler.sendPacket(new PlayerInteractBlockC2SPacket(Hand.MAIN_HAND, new BlockHitResult(Utils.vec3d(crop), Direction.UP, crop, false), 0));
99+
mc.player.swingHand(Hand.MAIN_HAND);
100+
});
101+
}
102+
103+
private BlockPos getCrop() {
104+
for (int x = -horizontalRange.get(); x < horizontalRange.get(); x++) {
105+
for (int y = -verticalRange.get(); y < verticalRange.get(); y++) {
106+
for (int z = -horizontalRange.get(); z < horizontalRange.get(); z++) {
107+
BlockPos blockPos = mc.player.getBlockPos().add(x, y, z);
108+
Block block = mc.world.getBlockState(blockPos).getBlock();
109+
if (block instanceof CropBlock cropBlock) {
110+
int age = cropBlock.getAge(mc.world.getBlockState(blockPos));
111+
if (age < cropBlock.getMaxAge())
112+
return blockPos;
113+
}
114+
if (block instanceof CocoaBlock) {
115+
int age = mc.world.getBlockState(blockPos).get(CocoaBlock.AGE);
116+
if (age < 2)
117+
return blockPos;
118+
}
119+
if (block instanceof StemBlock) {
120+
int age = mc.world.getBlockState(blockPos).get(StemBlock.AGE);
121+
if (age < StemBlock.MAX_AGE)
122+
return blockPos;
123+
}
124+
if (block instanceof MushroomPlantBlock) {
125+
return blockPos;
126+
}
127+
if (block instanceof SweetBerryBushBlock) {
128+
int age = mc.world.getBlockState(blockPos).get(SweetBerryBushBlock.AGE);
129+
if (age < 3)
130+
return blockPos;
131+
}
132+
if (block instanceof SaplingBlock || block instanceof AzaleaBlock){
133+
return blockPos;
134+
}
135+
}
136+
}
137+
}
138+
return null;
139+
}
140+
141+
@EventHandler
142+
private void onRender(Render3DEvent event) {
143+
BlockPos crop = getCrop();
144+
if (crop == null || !InvUtils.findInHotbar(Items.BONE_MEAL).found()) return;
145+
event.renderer.box(crop, sideColor.get(), lineColor.get(), shapeMode.get(), 0);
146+
}
147+
}

src/main/resources/fabric.mod.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@
2929
"depends": {
3030
"java": ">=17",
3131
"minecraft": ">=${mc_version}",
32-
"meteor-client": ">=0.5.1"
32+
"meteor-client": ">=0.5.5"
3333
}
3434
}

0 commit comments

Comments
 (0)