aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsyeyoung <cyong06@naver.com>2021-02-03 19:37:18 +0900
committersyeyoung <cyong06@naver.com>2021-02-03 19:37:18 +0900
commitc0411a7d330464c03ec3fbfb9ac7e9cd7373a30c (patch)
tree7304af657d969751748381b02c79017d0a0e29a2
parent216bf76d3375f315962878cae03a73d4f1c11cea (diff)
downloadSkyblock-Dungeons-Guide-c0411a7d330464c03ec3fbfb9ac7e9cd7373a30c.tar.gz
Skyblock-Dungeons-Guide-c0411a7d330464c03ec3fbfb9ac7e9cd7373a30c.tar.bz2
Skyblock-Dungeons-Guide-c0411a7d330464c03ec3fbfb9ac7e9cd7373a30c.zip
works pretty well
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorCreeperSolver.java122
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorTeleportMazeSolver.java2
2 files changed, 70 insertions, 54 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorCreeperSolver.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorCreeperSolver.java
index d0c5be1c..81ae3d62 100755
--- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorCreeperSolver.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorCreeperSolver.java
@@ -8,7 +8,9 @@ import kr.syeyoung.dungeonsguide.utils.RenderUtils;
import net.minecraft.block.Block;
import net.minecraft.entity.monster.EntityCreeper;
import net.minecraft.init.Blocks;
+import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
+import net.minecraft.util.EnumFacing;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;
@@ -33,69 +35,83 @@ public class RoomProcessorCreeperSolver extends GeneralRoomProcessor {
private void findCreeperAndDoPoses() {
World w = getDungeonRoom().getContext().getWorld();
- Set<BlockPos> prismarines = new HashSet<BlockPos>();
- final BlockPos low = getDungeonRoom().getMin().add(0,-3,0);
- final BlockPos high = getDungeonRoom().getMax().add(0,15,0);
- List<EntityCreeper> creeepr = w.getEntities(EntityCreeper.class, new Predicate<EntityCreeper>() {
- @Override
- public boolean apply(@Nullable EntityCreeper input) {
- if (input.isInvisible()) return false;
- BlockPos pos = input.getPosition();
- return low.getX() < pos.getX() && pos.getX() < high.getX()
- && low.getZ() < pos.getZ() && pos.getZ() < high.getZ();
+ List<BlockPos> prismarines = new ArrayList<BlockPos>();
+ final BlockPos low = getDungeonRoom().getMin().add(0,-2,0);
+ final BlockPos high = getDungeonRoom().getMax().add(0,20,0);
+ final AxisAlignedBB axis = AxisAlignedBB.fromBounds(
+ low.getX() + 15, low.getY(), low.getZ() + 15,
+ high.getX() - 15, low.getY() + 10.5, high.getZ() - 15
+ );
+
+ for (BlockPos pos : BlockPos.getAllInBox(low, high)) {
+ Block b = w.getBlockState(pos).getBlock();
+ if (b == Blocks.prismarine || b == Blocks.sea_lantern) {
+ for (EnumFacing face:EnumFacing.VALUES) {
+ if (w.getBlockState(pos.offset(face)).getBlock() == Blocks.air) {
+ prismarines.add(pos);
+ break;
+ }
+ }
}
- });
- if (creeepr.isEmpty()) {
- bugged = true;
- return;
}
- EntityCreeper creeper = creeepr.get(0);
- Vec3 position = creeper.getPositionVector().addVector(0,1,0);
- for (BlockPos allInBox : BlockPos.getAllInBox(low, high)) {
- Block b = w.getChunkFromBlockCoords(allInBox).getBlock(allInBox);
- if (b == Blocks.prismarine || b == Blocks.sea_lantern) {
- if (prismarines.contains(allInBox)) continue;
- prismarines.add(allInBox);
-
- Vec3 vector = new Vec3(allInBox.getX() +0.5, allInBox.getY() +0.5, allInBox.getZ() +0.5);
- Vec3 pos = position.subtract(vector).normalize();
- BlockPos opposite = null;
- for (int i = 5; i < 28;i++) {
- Vec3 result = vector.addVector(pos.xCoord * i, pos.yCoord * i, pos.zCoord * i);
- BlockPos pos3 = new BlockPos(result);
- if (w.getChunkFromBlockCoords(pos3).getBlock(pos3) != Blocks.air && pos3.distanceSq(creeper.getPosition()) > 5) {
- opposite = pos3;
+ System.out.println("prismarins: "+prismarines);
+
+ while (prismarines.size() > 1) {
+ BlockPos first = prismarines.get(0);
+ BlockPos highestMatch = null;
+ int highestDist = 0;
+ label: for (int i = 1; i < prismarines.size(); i++) {
+ BlockPos second = prismarines.get(i);
+
+ if (second.distanceSq(first) < highestDist) continue;
+
+ double zslope = (second.getZ() - first.getZ()) / ((double)second.getX() - first.getX());
+ double zIntercept = (first.getZ() - first.getX() * zslope);
+
+ double yslope = (second.getY() - first.getY()) / ((double)second.getX() - first.getX());
+ double yIntercept = (first.getY() - first.getX() * yslope);
+
+ for (double x = axis.minX; x < axis.maxX; x += 0.1) {
+ double y = yslope * x + yIntercept;
+ double z = zslope * x + zIntercept;
+
+ if (y > axis.minY && y < axis.maxY && z > axis.minZ && z < axis.maxZ) {
+ // found pair
+ highestDist = (int) second.distanceSq(first);
+ highestMatch = second;
+ break;
}
}
- if (opposite == null) continue;
-
- BlockPos otherPrismarine = null;
- for (BlockPos inBox : BlockPos.getAllInBox(opposite.add(-2, -3, -2), opposite.add(2, 3, 2))) {
- if (prismarines.contains(inBox)) continue;
- if ( low.getX() < inBox.getX() && inBox.getX() < high.getX()
- && low.getZ() < inBox.getZ() && inBox.getZ() < high.getZ()) {
- Block b3 = w.getChunkFromBlockCoords(inBox).getBlock(inBox);
- if (b3 == Blocks.prismarine || b3 == Blocks.sea_lantern) {
-// for (EnumFacing ef : EnumFacing.values()) {
-// BlockPos b4 = inBox.offset(ef);
-// if (w.getChunkFromBlockCoords(b4).getBlock(b4) == Blocks.air) {
-// otherPrismarine = inBox;
-// }
-// }
-// break;
- otherPrismarine = inBox;
- break;
- }
+
+ double xslope = (second.getX() - first.getX()) / ((double)second.getZ() - first.getZ());
+ double xIntercept = (first.getX() - first.getZ() * xslope);
+
+ yslope = (second.getY() - first.getY()) / ((double)second.getZ() - first.getZ());
+ yIntercept = (first.getY() - first.getZ() * yslope);
+
+ for (double z = axis.minZ; z < axis.maxZ; z += 0.1) {
+ double y = yslope * z + yIntercept;
+ double x = xslope * z + xIntercept;
+
+ if (y > axis.minY && y < axis.maxY && x > axis.minX && x < axis.maxX) {
+ // found pair
+ highestDist = (int) second.distanceSq(first);
+ highestMatch = second;
+ break;
}
}
- if (otherPrismarine == null) continue;
+ }
+
- prismarines.add(otherPrismarine);
- poses.add(new BlockPos[] {allInBox, otherPrismarine});
+ if (highestMatch == null) {
+ prismarines.remove(first);
+ } else {
+ prismarines.remove(first);
+ prismarines.remove(highestMatch);
+ poses.add(new BlockPos[] {first, highestMatch});
}
}
- bugged = false;
}
@Override
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorTeleportMazeSolver.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorTeleportMazeSolver.java
index 4949f0f9..10226293 100755
--- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorTeleportMazeSolver.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorTeleportMazeSolver.java
@@ -53,7 +53,7 @@ public class RoomProcessorTeleportMazeSolver extends GeneralRoomProcessor {
posZ1 = entityPlayerSP.posZ;
slope1 = lookVec.zCoord / lookVec.xCoord;
times ++;
- } else if (times % 4 == 3 && intersection == null) {
+ } else if (times % 4 == 3) {
posX2 = entityPlayerSP.posX;
posZ2 = entityPlayerSP.posZ;
slope2 = lookVec.zCoord / lookVec.xCoord;