Skip to content

Commit 2631886

Browse files
committed
Automatically get the plot size
1 parent fa621e2 commit 2631886

File tree

6 files changed

+44
-14
lines changed

6 files changed

+44
-14
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ yarn_mappings=1.20+build.1
88
loader_version=0.14.21
99

1010
# Mod Properties
11-
mod_version=1.2.1
11+
mod_version=1.2.2
1212
maven_group=dev.dfonline
1313
archives_base_name=CodeClient
1414

src/main/java/dev/dfonline/codeclient/CodeClient.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import dev.dfonline.codeclient.action.Action;
55
import dev.dfonline.codeclient.action.None;
66
import dev.dfonline.codeclient.config.Config;
7-
import dev.dfonline.codeclient.dev.ChestPeeker;
87
import dev.dfonline.codeclient.dev.Debug.Debug;
98
import dev.dfonline.codeclient.dev.DevInventory.DevInventoryScreen;
109
import dev.dfonline.codeclient.dev.NoClip;

src/main/java/dev/dfonline/codeclient/dev/NoClip.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ public static Vec3d handleClientPosition(Vec3d movement) {
3434
double x = Math.max(player.getX() + movement.x * 1.3, plot.getX() - 22);
3535
double y = Math.max(player.getY() + movement.y * 1, 50);
3636
double z = Math.max(player.getZ() + movement.z * 1.3, plot.getZ() - 2);
37+
if(plot.getSize() != null) {
38+
z = Math.min(z, plot.getZ() + plot.getSize().size + 3);
39+
}
3740

3841
player.setOnGround(false);
3942
boolean wantsToFall = player.isSneaking() && (player.getPitch() > 40);
@@ -58,7 +61,16 @@ public static float getJumpHeight() {
5861
public static Vec3d handleSeverPosition() {
5962
if(CodeClient.location instanceof Dev plot) {
6063
ClientPlayerEntity player = CodeClient.MC.player;
61-
Vec3d pos = new Vec3d(Math.max(player.getX(), plot.getX() - 20), player.getY(), Math.max(player.getZ(), plot.getZ()));
64+
65+
double z = Math.max(player.getZ(), plot.getZ());
66+
if(plot.getSize() != null) {
67+
z = Math.min(z, plot.getZ() + plot.getSize().size + 0.999);
68+
}
69+
70+
Vec3d pos = new Vec3d(Math.max(player.getX(), plot.getX() - 20),
71+
player.getY(),
72+
z);
73+
6274
if (isInsideWall(pos)) {
6375
double nearestFloor = Math.floor(player.getY() / 5) * 5;
6476
pos = new Vec3d(pos.x, nearestFloor + 2, pos.z);

src/main/java/dev/dfonline/codeclient/location/Plot.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public Integer getZ() {
4040
public Boolean isInPlot(BlockPos pos) {
4141
if(size == null) return null;
4242

43-
return isInArea(pos.toCenterPos()) && isInDev(pos.toCenterPos());
43+
return isInArea(pos.toCenterPos()) || isInDev(pos.toCenterPos());
4444
}
4545

4646
/**
@@ -52,8 +52,8 @@ public Boolean isInArea(Vec3d pos) {
5252
double x = pos.getX();
5353
double z = pos.getZ();
5454

55-
boolean inX = (x >= originX) && (x <= originX + size.size);
56-
boolean inZ = (z >= originZ) && (z <= originZ + size.size);
55+
boolean inX = (x >= originX) && (x <= originX + size.size + 1);
56+
boolean inZ = (z >= originZ) && (z <= originZ + size.size + 1);
5757

5858
return inX && inZ;
5959
}
@@ -63,8 +63,8 @@ public Boolean isInDev(Vec3d pos) {
6363
double x = pos.getX();
6464
double z = pos.getZ();
6565

66-
boolean inX = (x >= originX - 20) || ((pos.getY() >= 50) && (x >= originX - 21));
67-
boolean inZ = (z >= originZ) && (z <= originZ + size.size);
66+
boolean inX = (x < originX) && ((x >= originX - 20) || ((pos.getY() >= 50) && (x >= originX - 21)));
67+
boolean inZ = (z >= originZ) && (z <= originZ + size.size + 1);
6868

6969
return inX && inZ;
7070
}

src/main/java/dev/dfonline/codeclient/mixin/render/MChunkRendererRegion.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import dev.dfonline.codeclient.CodeClient;
44
import dev.dfonline.codeclient.dev.NoClip;
55
import dev.dfonline.codeclient.location.Dev;
6+
import dev.dfonline.codeclient.location.Plot;
67
import net.minecraft.block.BlockState;
78
import net.minecraft.block.Blocks;
89
import net.minecraft.client.render.chunk.ChunkRendererRegion;
@@ -25,4 +26,24 @@ private void getAppearance(BlockPos pos, CallbackInfoReturnable<BlockState> cir)
2526
if(state != null) cir.setReturnValue(state);
2627
}
2728
}
29+
30+
@Inject(method = "getBlockState", at = @At("RETURN"))
31+
private void getSize(BlockPos pos, CallbackInfoReturnable<BlockState> cir) {
32+
BlockState block = cir.getReturnValue();
33+
if(block == null) return;
34+
if(CodeClient.location instanceof Plot plot) {
35+
if(plot.getX() == null) return;
36+
if(plot.getSize() != null) return;
37+
38+
if(pos.getY() != 49) return;
39+
if(block.getBlock() != Blocks.STONE) return;
40+
41+
if(pos.getX() + 1 > plot.getX()) return;
42+
if(pos.getX() < plot.getX() - 19) return;
43+
44+
if(pos.getZ() == plot.getZ() + 50) plot.setSize(Plot.Size.BASIC);
45+
if(pos.getZ() == plot.getZ() + 100) plot.setSize(Plot.Size.LARGE);
46+
if(pos.getZ() == plot.getZ() + 300) plot.setSize(Plot.Size.MASSIVE);
47+
}
48+
}
2849
}

src/main/resources/CodeClient.mixins.json

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,17 @@
1515
"network.MClientPlayNetworkHandler",
1616
"render.MChunkRendererRegion",
1717
"render.MDebugRenderer",
18+
"render.hud.MDrawContext",
1819
"render.hud.MInGameHud",
1920
"render.hud.MInGameOverlayRenderer",
20-
"render.hud.MDrawContext",
2121
"render.hud.MTitleScreen",
2222
"world.ClientWorldAccessor",
2323
"world.MWorldRenderer",
2424
"world.block.MAbstractBlockState",
25-
"world.block.MBarrier"
25+
"world.block.MBarrier",
26+
"world.block.MBlockItem"
2627
],
2728
"injectors": {
2829
"defaultRequire": 1
29-
},
30-
"mixins": [
31-
"world.block.MBlockItem"
32-
]
30+
}
3331
}

0 commit comments

Comments
 (0)