From ad10d35c42cf1bbf4be48b04a41e73de315c940c Mon Sep 17 00:00:00 2001 From: Patbox <39821509+Patbox@users.noreply.github.com> Date: Fri, 5 Jan 2024 15:26:36 +0100 Subject: [PATCH] Fix a bug causing player to get stuck between two claims with force field augment --- gradle.properties | 14 ++++----- .../block/augment/ForceFieldAugmentBlock.java | 29 +++++++++++++++++-- 2 files changed, 34 insertions(+), 9 deletions(-) diff --git a/gradle.properties b/gradle.properties index d5899eb..a5756d8 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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 @@ -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 diff --git a/src/main/java/draylar/goml/block/augment/ForceFieldAugmentBlock.java b/src/main/java/draylar/goml/block/augment/ForceFieldAugmentBlock.java index b78941c..84f3b00 100644 --- a/src/main/java/draylar/goml/block/augment/ForceFieldAugmentBlock.java +++ b/src/main/java/draylar/goml/block/augment/ForceFieldAugmentBlock.java @@ -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 { @@ -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 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(); @@ -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) {