diff options
author | syeyoung <cyoung06@naver.com> | 2021-10-04 14:06:32 +0900 |
---|---|---|
committer | syeyoung <cyoung06@naver.com> | 2021-10-04 14:06:32 +0900 |
commit | a98c778b6e3398f265eeb56e1984c28aadb153bd (patch) | |
tree | bb8812236ae51b7a3077e4327820897cca1b99a1 /src/main/java/kr/syeyoung/dungeonsguide/dungeon | |
parent | dcd661c9108005b43f595d010c92d3221f866fb8 (diff) | |
download | Skyblock-Dungeons-Guide-a98c778b6e3398f265eeb56e1984c28aadb153bd.tar.gz Skyblock-Dungeons-Guide-a98c778b6e3398f265eeb56e1984c28aadb153bd.tar.bz2 Skyblock-Dungeons-Guide-a98c778b6e3398f265eeb56e1984c28aadb153bd.zip |
- Blood rush mode
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide/dungeon')
7 files changed, 159 insertions, 48 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/MapProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/MapProcessor.java index 3bea78f8..aed2f2a1 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/MapProcessor.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/MapProcessor.java @@ -22,9 +22,11 @@ import com.google.common.collect.BiMap; import com.google.common.collect.HashBiMap; import com.google.common.collect.Sets; import kr.syeyoung.dungeonsguide.DungeonsGuide; +import kr.syeyoung.dungeonsguide.dungeon.doorfinder.EDungeonDoorType; import kr.syeyoung.dungeonsguide.dungeon.events.DungeonMapUpdateEvent; import kr.syeyoung.dungeonsguide.dungeon.events.DungeonNodataEvent; import kr.syeyoung.dungeonsguide.dungeon.events.DungeonRoomDiscoverEvent; +import kr.syeyoung.dungeonsguide.dungeon.events.SerializableBlockPos; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; import kr.syeyoung.dungeonsguide.dungeon.doorfinder.DungeonSpecificDataProviderRegistry; import kr.syeyoung.dungeonsguide.dungeon.doorfinder.DungeonSpecificDataProvider; @@ -36,14 +38,12 @@ import net.minecraft.client.Minecraft; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemMap; import net.minecraft.item.ItemStack; -import net.minecraft.util.BlockPos; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.Vec3; -import net.minecraft.util.Vec4b; +import net.minecraft.util.*; import net.minecraft.world.storage.MapData; import net.minecraftforge.common.MinecraftForge; import javax.vecmath.Vector2d; +import javax.vecmath.Vector2f; import java.awt.*; import java.util.*; import java.util.List; @@ -250,7 +250,7 @@ public class MapProcessor { MapUtils.record(mapData, mapPoint.x, mapPoint.y, new Color(0,255,255,80)); DungeonRoom rooms = buildRoom(mapData, new Point(x,y)); if (rooms == null) continue; - context.createEvent(new DungeonRoomDiscoverEvent(rooms.getUnitPoints().get(0), rooms.getRoomMatcher().getRotation(), rooms.getMin(), rooms.getShape(),rooms.getColor(), rooms.getDungeonRoomInfo().getUuid(), rooms.getDungeonRoomInfo().getName(), rooms.getDungeonRoomInfo().getProcessorId())); + context.createEvent(new DungeonRoomDiscoverEvent(rooms.getUnitPoints().get(0), rooms.getRoomMatcher().getRotation(), new SerializableBlockPos(rooms.getMin()), new SerializableBlockPos(rooms.getMax()), rooms.getShape(),rooms.getColor(), rooms.getDungeonRoomInfo().getUuid(), rooms.getDungeonRoomInfo().getName(), rooms.getDungeonRoomInfo().getProcessorId())); DungeonsGuide.sendDebugChat(new ChatComponentText("New Map discovered! shape: "+rooms.getShape()+ " color: "+rooms.getColor()+" unitPos: "+x+","+y)); DungeonsGuide.sendDebugChat(new ChatComponentText("New Map discovered! mapMin: "+rooms.getMin() + " mapMx: "+rooms.getMax())); StringBuilder builder = new StringBuilder(); @@ -278,6 +278,7 @@ public class MapProcessor { } } + private static final Set<Vector2d> door_dirs = Sets.newHashSet(new Vector2d(0,0.5), new Vector2d(0, -0.5), new Vector2d(0.5, 0), new Vector2d(-0.5 , 0)); private DungeonRoom buildRoom(byte[] mapData, Point unitPoint) { Queue<Point[]> toCheck = new LinkedList<Point[]>(); toCheck.add(new Point[] {unitPoint, unitPoint}); // requestor, target @@ -309,12 +310,44 @@ public class MapProcessor { int localX = p.x - minX, localY = p.y - minY; shape |= 1 <<(localY *4 + localX); } - + Set<Vector2d> doors = new HashSet<>(); + for (Point p: ayConnected) { + for (Vector2d v: door_dirs) { + Vector2d v2 = new Vector2d(p.x + v.x , p.y + v.y ); + if (doors.contains(v2)) doors.remove(v2); + else doors.add(v2); + } + } Point pt2 = roomPointToMapPoint(ayConnected.get(0)); byte unit1 = MapUtils.getMapColorAt(mapData, pt2.x, pt2.y); + // 0: none 1: open door door 2. unopen door 3: wither door 4. red door + Set<Tuple<Vector2d, EDungeonDoorType>> doorsAndStates = new HashSet<>(); + final int halfWidth = unitRoomDimension.width + 4; + for (Vector2d door : doors) { + int floorX = (int)Math.floor(door.x), floorY = (int)Math.floor(door.y); + Point mapPt = roomPointToMapPoint(new Point(floorX, floorY)); + Point target = new Point(mapPt.x+ unitRoomDimension.width/2 + (int)(halfWidth*(door.x - floorX)), mapPt.y + unitRoomDimension.height/2 + (int)(halfWidth*(door.y - floorY)) ); + MapUtils.record(mapData, target.x, target.y, Color.green); + byte color = MapUtils.getMapColorAt(mapData, target.x, target.y); + + Vector2d vector2d = new Vector2d(door.x - minX, door.y - minY); + if (color == 0) { + doorsAndStates.add(new Tuple<>(vector2d, EDungeonDoorType.NONE)); + } else if (color == 85) { + doorsAndStates.add(new Tuple<>(vector2d, EDungeonDoorType.UNOPEN)); + } else if (color == 119) { + doorsAndStates.add(new Tuple<>(vector2d, EDungeonDoorType.WITHER)); + } else if (color == 18 && unit1 != 18) { + doorsAndStates.add(new Tuple<>(vector2d, EDungeonDoorType.BLOOD)); + } else { + doorsAndStates.add(new Tuple<>(vector2d, EDungeonDoorType.ENTRANCE)); + } + } + + try{ - return new DungeonRoom(ayConnected, shape, unit1, roomPointToWorldPoint(new Point(minX, minY)), roomPointToWorldPoint(new Point(maxX+1, maxY+1)).add(-1, 0, -1), context); + return new DungeonRoom(ayConnected, shape, unit1, roomPointToWorldPoint(new Point(minX, minY)), roomPointToWorldPoint(new Point(maxX+1, maxY+1)).add(-1, 0, -1), context, doorsAndStates); } catch (IllegalStateException ex) { DungeonsGuide.sendDebugChat(new ChatComponentText("Failed to load room, retrying later :: "+ex.getLocalizedMessage())); return null; @@ -373,7 +406,7 @@ public class MapProcessor { stabilizationTick++; } - if (stabilizationTick > 5) { + if (stabilizationTick > 20) { if (doorDimension == null) buildMap(mapData); else processMap(mapData); } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/doorfinder/DungeonDoor.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/doorfinder/DungeonDoor.java index d841bb65..9a52dad8 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/doorfinder/DungeonDoor.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/doorfinder/DungeonDoor.java @@ -31,22 +31,20 @@ import java.util.Set; public class DungeonDoor { private final World w; private final BlockPos position; - private boolean exist = true; + private EDungeonDoorType type; private boolean isZDir; private static final Set<Block> legalBlocks = Sets.newHashSet(Blocks.coal_block, Blocks.barrier, Blocks.monster_egg, Blocks.air, Blocks.stained_hardened_clay); - private boolean requiresKey = false; - private boolean opened = false; - - public DungeonDoor(World world, BlockPos pos) { + public DungeonDoor(World world, BlockPos pos, EDungeonDoorType type) { this.w = world; this.position = pos; Block itshouldbeall = world.getChunkFromBlockCoords(pos).getBlock(pos); - if (!legalBlocks.contains(itshouldbeall)) { - exist = false; - return; - } + + if (type == EDungeonDoorType.WITHER && itshouldbeall == Blocks.air) type = EDungeonDoorType.WITHER_FAIRY; + this.type = type; + boolean exist = type.isExist(); + for (int x = -1; x<=1; x++) for (int y = -1; y<=1; y++) for (int z = -1; z<=1; z++) { @@ -78,13 +76,6 @@ public class DungeonDoor { } if (!exist) { isZDir = false; - return; - } - - if (itshouldbeall == Blocks.stained_hardened_clay || itshouldbeall == Blocks.coal_block) { - requiresKey = true; - } else if (itshouldbeall == Blocks.barrier) { - opened = true; } } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/doorfinder/EDungeonDoorType.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/doorfinder/EDungeonDoorType.java new file mode 100644 index 00000000..3a07629e --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/doorfinder/EDungeonDoorType.java @@ -0,0 +1,33 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +package kr.syeyoung.dungeonsguide.dungeon.doorfinder; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@AllArgsConstructor +@Getter +public enum EDungeonDoorType { + NONE(false, false, false,"?"), ENTRANCE(true, false, false, "entrance"), WITHER(true, true,true,"withergate"),WITHER_FAIRY(true, false,true,"wither-fairy-gate"), BLOOD(true, true,true, "bloodgate"), UNOPEN(true, false, false,"gate"); + + private boolean exist; + private boolean keyRequired; + private boolean headToBlood; + private String name; +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/events/DungeonRoomDiscoverEvent.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/events/DungeonRoomDiscoverEvent.java index 05a48262..9e8b74ce 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/events/DungeonRoomDiscoverEvent.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/events/DungeonRoomDiscoverEvent.java @@ -30,7 +30,8 @@ import java.util.UUID; public class DungeonRoomDiscoverEvent implements DungeonEventData { private Point unitPt; private int rotation; - private BlockPos min; + private SerializableBlockPos min; + private SerializableBlockPos max; private int shape; private int color; private UUID roomUID; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/events/SerializableBlockPos.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/events/SerializableBlockPos.java new file mode 100644 index 00000000..ab1031e7 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/events/SerializableBlockPos.java @@ -0,0 +1,36 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +package kr.syeyoung.dungeonsguide.dungeon.events; + +import lombok.AllArgsConstructor; +import lombok.Data; +import net.minecraft.util.BlockPos; + +import java.io.Serializable; + +@Data @AllArgsConstructor +public class SerializableBlockPos implements Serializable { + private int x, y, z; + + public SerializableBlockPos(BlockPos pos) { + this.x = pos.getX(); + this.y = pos.getY(); + this.z = pos.getZ(); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonRoomDoor.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonRoomDoor.java index 80e10365..5ff85a13 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonRoomDoor.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonRoomDoor.java @@ -25,6 +25,8 @@ import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; import kr.syeyoung.dungeonsguide.dungeon.doorfinder.DungeonDoor; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; import kr.syeyoung.dungeonsguide.utils.RenderUtils; +import lombok.Getter; +import net.minecraft.init.Blocks; import net.minecraft.util.BlockPos; import java.awt.*; @@ -32,10 +34,26 @@ import java.util.HashSet; import java.util.Set; public class DungeonRoomDoor implements DungeonMechanic { + @Getter private final DungeonDoor doorfinder; + private OffsetPoint offsetPoint; - public DungeonRoomDoor(DungeonDoor doorfinder) { + public DungeonRoomDoor(DungeonRoom dungeonRoom, DungeonDoor doorfinder) { this.doorfinder = doorfinder; + if (doorfinder.isZDir()) { + if (dungeonRoom.canAccessAbsolute(doorfinder.getPosition().add(0,0,2))) + offsetPoint = new OffsetPoint(dungeonRoom, doorfinder.getPosition().add(0,0,2)); + else if (dungeonRoom.canAccessAbsolute(doorfinder.getPosition().add(0,0,-2))) + offsetPoint = new OffsetPoint(dungeonRoom, doorfinder.getPosition().add(0,0,-2)); + } else { + if (dungeonRoom.canAccessAbsolute(doorfinder.getPosition().add(2,0,0))) + offsetPoint = new OffsetPoint(dungeonRoom, doorfinder.getPosition().add(2,0,0)); + else if (dungeonRoom.canAccessAbsolute(doorfinder.getPosition().add(-2,0,0))) + offsetPoint = new OffsetPoint(dungeonRoom, doorfinder.getPosition().add(-2,0,0)); + } + if (offsetPoint == null) { + offsetPoint = new OffsetPoint(dungeonRoom, doorfinder.getPosition()); + } } @Override @@ -44,7 +62,7 @@ public class DungeonRoomDoor implements DungeonMechanic { Set<Action> base; Set<Action> preRequisites = base = new HashSet<Action>(); { - ActionMove actionMove = new ActionMove(new OffsetPoint(dungeonRoom, doorfinder.getPosition())); + ActionMove actionMove = new ActionMove(offsetPoint); preRequisites.add(actionMove); preRequisites = actionMove.getPreRequisite(); } @@ -53,7 +71,7 @@ public class DungeonRoomDoor implements DungeonMechanic { @Override public void highlight(Color color, String name, DungeonRoom dungeonRoom, float partialTicks) { - BlockPos pos = doorfinder.getPosition(); + BlockPos pos = offsetPoint.getBlockPos(dungeonRoom); RenderUtils.highlightBlock(pos, color,partialTicks); RenderUtils.drawTextAtWorld(name, pos.getX() +0.5f, pos.getY()+0.75f, pos.getZ()+0.5f, 0xFFFFFFFF, 0.03f, false, true, partialTicks); RenderUtils.drawTextAtWorld(getCurrentState(dungeonRoom), pos.getX() +0.5f, pos.getY()+0.25f, pos.getZ()+0.5f, 0xFFFFFFFF, 0.03f, false, true, partialTicks); @@ -61,7 +79,7 @@ public class DungeonRoomDoor implements DungeonMechanic { @Override public String getCurrentState(DungeonRoom dungeonRoom) { - return doorfinder.isRequiresKey() ?"key" : "normal"; + return doorfinder.getType().isKeyRequired() ? "key" : "normal"; } @Override @@ -76,6 +94,6 @@ public class DungeonRoomDoor implements DungeonMechanic { @Override public OffsetPoint getRepresentingPoint(DungeonRoom dungeonRoom) { - return new OffsetPoint(dungeonRoom, doorfinder.getPosition()); + return offsetPoint; } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoom.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoom.java index f92d21c5..a5a1f5d7 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoom.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoom.java @@ -19,10 +19,12 @@ package kr.syeyoung.dungeonsguide.dungeon.roomfinder; import com.google.common.collect.Sets; +import kr.syeyoung.dungeonsguide.DungeonsGuide; import kr.syeyoung.dungeonsguide.dungeon.DungeonContext; import kr.syeyoung.dungeonsguide.dungeon.MapProcessor; import kr.syeyoung.dungeonsguide.dungeon.data.DungeonRoomInfo; import kr.syeyoung.dungeonsguide.dungeon.doorfinder.DungeonDoor; +import kr.syeyoung.dungeonsguide.dungeon.doorfinder.EDungeonDoorType; import kr.syeyoung.dungeonsguide.dungeon.events.DungeonStateChangeEvent; import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonMechanic; import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonRoomDoor; @@ -43,10 +45,7 @@ import net.minecraft.entity.Entity; import net.minecraft.pathfinding.PathEntity; import net.minecraft.pathfinding.PathFinder; import net.minecraft.pathfinding.PathPoint; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.BlockPos; -import net.minecraft.util.MathHelper; -import net.minecraft.util.Vec3; +import net.minecraft.util.*; import net.minecraft.world.ChunkCache; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; @@ -92,7 +91,7 @@ public class DungeonRoom { cached = new HashMap<String, DungeonMechanic>(dungeonRoomInfo.getMechanics()); int index = 0; for (DungeonDoor door : doors) { - if (door.isExist()) cached.put((door.isRequiresKey() ? "withergate" : "gate")+"-"+(++index), new DungeonRoomDoor(door)); + if (door.getType().isExist()) cached.put((door.getType().getName())+"-"+(++index), new DungeonRoomDoor(this, door)); } } return cached; @@ -147,7 +146,7 @@ public class DungeonRoom { private RoomProcessor roomProcessor; - public DungeonRoom(List<Point> points, short shape, byte color, BlockPos min, BlockPos max, DungeonContext context) { + public DungeonRoom(List<Point> points, short shape, byte color, BlockPos min, BlockPos max, DungeonContext context, Set<Tuple<Vector2d, EDungeonDoorType>> doorsAndStates) { this.unitPoints = points; this.shape = shape; this.color = color; @@ -177,7 +176,7 @@ public class DungeonRoom { lenz = maxz - minz; arr = new long[lenx *leny * lenz * 2 / 8];; - buildDoors(); + buildDoors(doorsAndStates); buildRoom(); nodeProcessorDungeonRoom = new NodeProcessorDungeonRoom(this); updateRoomProcessor(); @@ -187,19 +186,17 @@ public class DungeonRoom { private static final Set<Vector2d> directions = Sets.newHashSet(new Vector2d(0,16), new Vector2d(0, -16), new Vector2d(16, 0), new Vector2d(-16 , 0)); - private void buildDoors() { - Set<BlockPos> positions = new HashSet<BlockPos>(); - for (Point p:unitPoints) { - BlockPos pos = context.getMapProcessor().roomPointToWorldPoint(p).add(16,0,16); - for (Vector2d vector2d : directions){ - BlockPos doorLoc = pos.add(vector2d.x, 0, vector2d.y); - if (positions.contains(doorLoc)) positions.remove(doorLoc); - else positions.add(doorLoc); - } + private void buildDoors(Set<Tuple<Vector2d, EDungeonDoorType>> doorsAndStates) { + Set<Tuple<BlockPos, EDungeonDoorType>> positions = new HashSet<>(); + BlockPos pos = context.getMapProcessor().roomPointToWorldPoint(minRoomPt).add(16,0,16); + for (Tuple<Vector2d, EDungeonDoorType> doorsAndState : doorsAndStates) { + Vector2d vector2d = doorsAndState.getFirst(); + BlockPos neu = pos.add(vector2d.x * 32, 0, vector2d.y * 32); + positions.add(new Tuple<>(neu, doorsAndState.getSecond())); } - for (BlockPos door : positions) { - doors.add(new DungeonDoor(context.getWorld(), door)); + for (Tuple<BlockPos, EDungeonDoorType> door : positions) { + doors.add(new DungeonDoor(context.getWorld(), door.getFirst(), door.getSecond())); } } @@ -270,6 +267,8 @@ public class DungeonRoom { Point roomPt = mapProcessor.worldPointToRoomPoint(pos); roomPt.translate(-minRoomPt.x, -minRoomPt.y); + DungeonsGuide.sendDebugChat(new ChatComponentText(pos+"? "+((shape >>(roomPt.y *4 +roomPt.x) & 0x1) > 0))); + return (shape >>(roomPt.y *4 +roomPt.x) & 0x1) > 0; } public boolean canAccessRelative(int x, int z) { |