Skip to content

Commit

Permalink
Automatically get the plot size
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgeRNG committed Jun 29, 2023
1 parent fa621e2 commit 2631886
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 14 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ yarn_mappings=1.20+build.1
loader_version=0.14.21

# Mod Properties
mod_version=1.2.1
mod_version=1.2.2
maven_group=dev.dfonline
archives_base_name=CodeClient

Expand Down
1 change: 0 additions & 1 deletion src/main/java/dev/dfonline/codeclient/CodeClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import dev.dfonline.codeclient.action.Action;
import dev.dfonline.codeclient.action.None;
import dev.dfonline.codeclient.config.Config;
import dev.dfonline.codeclient.dev.ChestPeeker;
import dev.dfonline.codeclient.dev.Debug.Debug;
import dev.dfonline.codeclient.dev.DevInventory.DevInventoryScreen;
import dev.dfonline.codeclient.dev.NoClip;
Expand Down
14 changes: 13 additions & 1 deletion src/main/java/dev/dfonline/codeclient/dev/NoClip.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ public static Vec3d handleClientPosition(Vec3d movement) {
double x = Math.max(player.getX() + movement.x * 1.3, plot.getX() - 22);
double y = Math.max(player.getY() + movement.y * 1, 50);
double z = Math.max(player.getZ() + movement.z * 1.3, plot.getZ() - 2);
if(plot.getSize() != null) {
z = Math.min(z, plot.getZ() + plot.getSize().size + 3);
}

player.setOnGround(false);
boolean wantsToFall = player.isSneaking() && (player.getPitch() > 40);
Expand All @@ -58,7 +61,16 @@ public static float getJumpHeight() {
public static Vec3d handleSeverPosition() {
if(CodeClient.location instanceof Dev plot) {
ClientPlayerEntity player = CodeClient.MC.player;
Vec3d pos = new Vec3d(Math.max(player.getX(), plot.getX() - 20), player.getY(), Math.max(player.getZ(), plot.getZ()));

double z = Math.max(player.getZ(), plot.getZ());
if(plot.getSize() != null) {
z = Math.min(z, plot.getZ() + plot.getSize().size + 0.999);
}

Vec3d pos = new Vec3d(Math.max(player.getX(), plot.getX() - 20),
player.getY(),
z);

if (isInsideWall(pos)) {
double nearestFloor = Math.floor(player.getY() / 5) * 5;
pos = new Vec3d(pos.x, nearestFloor + 2, pos.z);
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/dev/dfonline/codeclient/location/Plot.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public Integer getZ() {
public Boolean isInPlot(BlockPos pos) {
if(size == null) return null;

return isInArea(pos.toCenterPos()) && isInDev(pos.toCenterPos());
return isInArea(pos.toCenterPos()) || isInDev(pos.toCenterPos());
}

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

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

return inX && inZ;
}
Expand All @@ -63,8 +63,8 @@ public Boolean isInDev(Vec3d pos) {
double x = pos.getX();
double z = pos.getZ();

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

return inX && inZ;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import dev.dfonline.codeclient.CodeClient;
import dev.dfonline.codeclient.dev.NoClip;
import dev.dfonline.codeclient.location.Dev;
import dev.dfonline.codeclient.location.Plot;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.client.render.chunk.ChunkRendererRegion;
Expand All @@ -25,4 +26,24 @@ private void getAppearance(BlockPos pos, CallbackInfoReturnable<BlockState> cir)
if(state != null) cir.setReturnValue(state);
}
}

@Inject(method = "getBlockState", at = @At("RETURN"))
private void getSize(BlockPos pos, CallbackInfoReturnable<BlockState> cir) {
BlockState block = cir.getReturnValue();
if(block == null) return;
if(CodeClient.location instanceof Plot plot) {
if(plot.getX() == null) return;
if(plot.getSize() != null) return;

if(pos.getY() != 49) return;
if(block.getBlock() != Blocks.STONE) return;

if(pos.getX() + 1 > plot.getX()) return;
if(pos.getX() < plot.getX() - 19) return;

if(pos.getZ() == plot.getZ() + 50) plot.setSize(Plot.Size.BASIC);
if(pos.getZ() == plot.getZ() + 100) plot.setSize(Plot.Size.LARGE);
if(pos.getZ() == plot.getZ() + 300) plot.setSize(Plot.Size.MASSIVE);
}
}
}
10 changes: 4 additions & 6 deletions src/main/resources/CodeClient.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,17 @@
"network.MClientPlayNetworkHandler",
"render.MChunkRendererRegion",
"render.MDebugRenderer",
"render.hud.MDrawContext",
"render.hud.MInGameHud",
"render.hud.MInGameOverlayRenderer",
"render.hud.MDrawContext",
"render.hud.MTitleScreen",
"world.ClientWorldAccessor",
"world.MWorldRenderer",
"world.block.MAbstractBlockState",
"world.block.MBarrier"
"world.block.MBarrier",
"world.block.MBlockItem"
],
"injectors": {
"defaultRequire": 1
},
"mixins": [
"world.block.MBlockItem"
]
}
}

0 comments on commit 2631886

Please sign in to comment.