Skip to content

Commit

Permalink
Single player saftey
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgeRNG committed Jun 11, 2023
1 parent 98ef29a commit 7b6b203
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ public static BlockHitResult onBlockInteract(BlockHitResult hitResult) {

@Nullable
public static VoxelShape customVoxelShape(BlockView world, BlockPos pos) {
if(CodeClient.location instanceof Dev plot) {
if(CodeClient.MC != null && CodeClient.MC.player != null && CodeClient.location instanceof Dev plot) {
Config.LayerInteractionMode mode = Config.getConfig().CodeLayerInteractionMode;
boolean isLevel = plot.isInCodeSpace(pos.getX(), plot.getZ()) && pos.getY() % 5 == 4;
boolean noClipAllowsBlock = Config.getConfig().NoClipEnabled || world.getBlockState(pos).isAir();
Expand Down
13 changes: 6 additions & 7 deletions src/main/java/dev/dfonline/codeclient/mixin/entity/MEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,19 @@ private void insideWall(CallbackInfoReturnable<Boolean> cir) {

@Inject(method = "move", at = @At("HEAD"), cancellable = true)
private void onMove(MovementType movementType, Vec3d movement, CallbackInfo ci) {
if(!NoClip.isIgnoringWalls()) return;
if(CodeClient.MC.player == null) return;
if(this.getId() != CodeClient.MC.player.getId()) return;
if(NoClip.isIgnoringWalls()) {
Vec3d pos = NoClip.handleClientPosition(movement);
if(pos != null) {
this.setPosition(pos);
ci.cancel();
}
Vec3d pos = NoClip.handleClientPosition(movement);
if(pos != null) {
this.setPosition(pos);
ci.cancel();
}
}

@Inject(method = "wouldPoseNotCollide", at = @At("HEAD"), cancellable = true)
private void wouldPoseNotCollide(EntityPose pose, CallbackInfoReturnable<Boolean> cir) {
if(this.getId() == CodeClient.MC.player.getId() && NoClip.isIgnoringWalls()) {
if(NoClip.isIgnoringWalls() && this.getId() == CodeClient.MC.player.getId()) {
cir.setReturnValue(true);
}
}
Expand Down

0 comments on commit 7b6b203

Please sign in to comment.