From a0b3b70aafcc9caf9dd56cec59ab321221e36834 Mon Sep 17 00:00:00 2001 From: database-test <143010276+database-test@users.noreply.github.com> Date: Sun, 27 Oct 2024 10:12:00 -0400 Subject: [PATCH] idk anymore --- .../core/mixin/block/EndPortalBlockMixin.java | 25 +++++++++++-------- .../minigames/games/bridge/BridgeGame.java | 9 ++++--- .../minigames/games/bridge/BridgeMap.java | 3 ++- 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/nexia/core/mixin/block/EndPortalBlockMixin.java b/src/main/java/com/nexia/core/mixin/block/EndPortalBlockMixin.java index bdd908d4..ef948ff5 100644 --- a/src/main/java/com/nexia/core/mixin/block/EndPortalBlockMixin.java +++ b/src/main/java/com/nexia/core/mixin/block/EndPortalBlockMixin.java @@ -1,14 +1,13 @@ package com.nexia.core.mixin.block; -import com.nexia.minigames.games.bridge.BridgeGame; + import com.nexia.base.player.NexiaPlayer; import com.nexia.base.player.PlayerDataManager; -import com.nexia.core.NexiaCore; -import com.nexia.minigames.games.duels.util.player.DuelsPlayerData; +import com.nexia.minigames.games.bridge.BridgeGame; +import com.nexia.minigames.games.bridge.util.player.BridgePlayerData; import net.minecraft.core.BlockPos; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.Entity; import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.EndPortalBlock; import net.minecraft.world.level.block.state.BlockState; import org.spongepowered.asm.mixin.Mixin; @@ -16,8 +15,7 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import static com.nexia.minigames.games.bridge.BridgeGame.team1; -import static com.nexia.minigames.games.bridge.BridgeGame.team2; +import static com.nexia.core.NexiaCore.BRIDGE_DATA_MANAGER; @Mixin(EndPortalBlock.class) public class EndPortalBlockMixin { @@ -26,16 +24,21 @@ public class EndPortalBlockMixin { ) private void entityInside(BlockState blockState, Level level, BlockPos blockPos, Entity entity, CallbackInfo ci) { if (!(entity instanceof ServerPlayer serverPlayer)) return; - NexiaPlayer nexiaPlayer = new NexiaPlayer(serverPlayer); - if (nexiaPlayer.unwrap() == entity && nexiaPlayer.hasTag("in_bridge_game")) { - BridgeGame.goal(nexiaPlayer); + NexiaPlayer nexiaPlayer = new NexiaPlayer(serverPlayer); + if (nexiaPlayer.hasTag("in_bridge_game")) { + BridgePlayerData data = (BridgePlayerData) PlayerDataManager.getDataManager(BRIDGE_DATA_MANAGER).get(nexiaPlayer); + if (data.team == BridgeGame.team1) { + BridgeGame.goal(nexiaPlayer, "team1"); + } + if (data.team == BridgeGame.team2) { + BridgeGame.goal(nexiaPlayer, "team2"); + } } - -} + } } diff --git a/src/main/java/com/nexia/minigames/games/bridge/BridgeGame.java b/src/main/java/com/nexia/minigames/games/bridge/BridgeGame.java index aeba6df4..9dd1d264 100644 --- a/src/main/java/com/nexia/minigames/games/bridge/BridgeGame.java +++ b/src/main/java/com/nexia/minigames/games/bridge/BridgeGame.java @@ -39,6 +39,7 @@ import java.time.Duration; import java.util.ArrayList; +import java.util.Objects; import java.util.UUID; import static com.nexia.core.NexiaCore.BRIDGE_DATA_MANAGER; @@ -245,7 +246,7 @@ public static void second() { } } - public static void goal(NexiaPlayer player) { + public static void goal(NexiaPlayer player, String team) { if (!team1.refreshTeam() || !team2.refreshTeam()) endGame(null); @@ -255,7 +256,6 @@ public static void goal(NexiaPlayer player) { if (!BridgeGame.isEnding) { - var i = 0; // for (i = 0; player == team1.players.get(i); i++) { // PlayerDataManager.getDataManager(BRIDGE_DATA_MANAGER).get(player.getUUID()).savedData.incrementInteger("goals"); @@ -264,13 +264,13 @@ public static void goal(NexiaPlayer player) { // // } //the most cursed thing ive ever written - if (BridgeGame.team1.players.contains(player)) { + if (Objects.equals(team, "team1")) { PlayerDataManager.getDataManager(BRIDGE_DATA_MANAGER).get(player.getUUID()).savedData.incrementInteger("goals"); team1.goals++; teamID = '1'; } - if (BridgeGame.team2.players.contains(player)) { + if (Objects.equals(team, "team2")) { PlayerDataManager.getDataManager(BRIDGE_DATA_MANAGER).get(player.getUUID()).savedData.incrementInteger("goals"); team2.goals++; teamID = '2'; @@ -551,6 +551,7 @@ public static void tick() { if (BridgeGame.world.players().isEmpty()) { } + // AABB aabb = new AABB(BridgeGame.map.corner1, BridgeGame.map.corner2); // Predicate predicate = o -> true; diff --git a/src/main/java/com/nexia/minigames/games/bridge/BridgeMap.java b/src/main/java/com/nexia/minigames/games/bridge/BridgeMap.java index a1f9e258..904155e1 100644 --- a/src/main/java/com/nexia/minigames/games/bridge/BridgeMap.java +++ b/src/main/java/com/nexia/minigames/games/bridge/BridgeMap.java @@ -11,7 +11,7 @@ public class BridgeMap { - public static final BridgeMap NETHFLAT = new BridgeMap("NETHFLAT", "NETHFLAT", new EntityPos(0, 80, -41, 0, 0), new EntityPos(0, 80, 41, 180, 0), new StructureMap(new Identifier("bridge", "nethflat"), StructureMap.Rotation.NO_ROTATION, true, new BlockPos(0, 80, 0), new BlockPos(-36, -3, -51), true)); + public static final BridgeMap NETHFLAT = new BridgeMap("Neth Flat", "Neth Flat", new EntityPos(0, 80, -41, 0, 0), new EntityPos(0, 80, 41, 180, 0), new StructureMap(new Identifier("bridge", "nethflat"), StructureMap.Rotation.NO_ROTATION, true, new BlockPos(0, 80, 0), new BlockPos(-36, -3, -51), true)); public static List bridgeMaps = new ArrayList<>(); public String id; public String name; @@ -19,6 +19,7 @@ public class BridgeMap { public EntityPos team2Pos; public StructureMap structureMap; + public BridgeMap(String id, String name, EntityPos team1Pos, EntityPos team2Pos, StructureMap structureMap) { this.id = id; this.name = name;