Skip to content

Commit

Permalink
Fix a bug causing player to get stuck between two claims with force f…
Browse files Browse the repository at this point in the history
…ield augment
  • Loading branch information
Patbox committed Jan 5, 2024
1 parent 74e44a9 commit ad10d35
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 9 deletions.
14 changes: 7 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check these on https://fabricmc.net/use
minecraft_version=1.20.3-rc1
yarn_mappings=1.20.3-rc1+build.1
loader_version=0.15.0
minecraft_version=1.20.4
yarn_mappings=1.20.4+build.1
loader_version=0.15.3

#Fabric api
fabric_version=0.91.1+1.20.3
fabric_version=0.91.1+1.20.4

# Mod Properties
mod_version = `1.11.0`
mod_version = 1.11.1
maven_group = eu.pb4
archives_base_name = goml

Expand All @@ -20,8 +20,8 @@ archives_base_name = goml
rtree_version=0.3.0
cca_version=5.4.0
pal_version=1.9.0
polymer_version=0.7.0+1.20.3-rc1
sgui_version=1.3.0+1.20.2
polymer_version=0.7.4+1.20.4
sgui_version=1.4.1+1.20.4
stapi_version=2.2.0+1.20.3-rc1
placeholder_version=2.3.0+1.20.3
common-protection-api_version=1.0.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,19 @@
import net.minecraft.text.MutableText;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import net.minecraft.util.Pair;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.Heightmap;
import net.minecraft.world.World;
import org.apache.commons.lang3.mutable.MutableObject;
import org.jetbrains.annotations.Nullable;

import java.util.Optional;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;

public class ForceFieldAugmentBlock extends ClaimAugmentBlock {

Expand All @@ -46,8 +51,20 @@ public ForceFieldAugmentBlock(Settings settings, String texture) {
@Override
public void onPlayerEnter(Claim claim, PlayerEntity player) {
if (shouldBlock(claim, player) && claim.getClaimBox().minecraftBox().contains(player.getPos())) {
var pair = ClaimUtils.getClosestXZBorder(claim, player.getPos(), 1);
var pairPart = ClaimUtils.getClosestXZBorder(claim, player.getPos());
Pair<Vec3d, Direction> pair = ClaimUtils.getClosestXZBorder(claim, player.getPos(), 2);
int distance = 0;
while (true) {
var i = shouldBlock(player.getWorld(), pair.getLeft(), player);

if (i == -1) {
break;
}
distance += i;
pair = ClaimUtils.getClosestXZBorder(claim, player.getPos(), 2 + distance);
}


var pairPart = ClaimUtils.getClosestXZBorder(claim, player.getPos(), distance);

var pos = pair.getLeft();
var dir = pair.getRight();
Expand Down Expand Up @@ -124,6 +141,14 @@ public boolean shouldBlock(Claim claim, PlayerEntity player) {
return doThing;
}


private int shouldBlock(World world, Vec3d pos, PlayerEntity player) {
var x = ClaimUtils.getClaimsAt(world, BlockPos.ofFloored(pos))
.filter(entry -> entry.getValue().hasAugment(this) && shouldBlock(entry.getValue(), player)).collect(Collectors.toList());

return x.isEmpty() ? -1 : x.get(0).getValue().getRadius();
}

@Override
public void openSettings(Claim claim, ServerPlayerEntity player, @Nullable Runnable closeCallback) {
var gui = new SimpleGui(ScreenHandlerType.HOPPER, player, false) {
Expand Down

0 comments on commit ad10d35

Please sign in to comment.