diff options
Diffstat (limited to 'src/main')
8 files changed, 155 insertions, 6 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/EventListener.java b/src/main/java/kr/syeyoung/dungeonsguide/EventListener.java index fd210c82..fca29550 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/EventListener.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/EventListener.java @@ -27,8 +27,8 @@ public class EventListener { public void onTick(TickEvent.ClientTickEvent e) { if (e.phase == TickEvent.Phase.START) { timerTick ++; + SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); if (timerTick % 5 == 0) { - SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); boolean isOnDungeon = skyblockStatus.isOnDungeon(); // System.out.println(isOnDungeon); skyblockStatus.updateStatus(); @@ -40,6 +40,19 @@ public class EventListener { if (isOnDungeon) skyblockStatus.getContext().tick(); else skyblockStatus.setContext(new DungeonContext(Minecraft.getMinecraft().thePlayer.worldObj)); } + + if (!skyblockStatus.isOnDungeon()) return; + + if (skyblockStatus.getContext() != null) { + DungeonContext context = skyblockStatus.getContext(); + EntityPlayerSP thePlayer = Minecraft.getMinecraft().thePlayer; + Point roomPt = context.getMapProcessor().worldPointToRoomPoint(thePlayer.getPosition()); + + DungeonRoom dungeonRoom = context.getRoomMapper().get(roomPt); + if (dungeonRoom != null && dungeonRoom.getRoomProcessor() != null) { + dungeonRoom.getRoomProcessor().tick(); + } + } } } @@ -70,7 +83,10 @@ public class EventListener { fontRenderer.drawString("you're in the room... "+dungeonRoom.getColor()+" / "+dungeonRoom.getShape(), 5, 128, 0xFFFFFF); fontRenderer.drawString("room uuid: "+dungeonRoom.getDungeonRoomInfo().getUuid() + (dungeonRoom.getDungeonRoomInfo().isRegistered() ?"":" (not registered)"), 5, 138, 0xFFFFFF); fontRenderer.drawString("room name: "+dungeonRoom.getDungeonRoomInfo().getName(), 5, 148, 0xFFFFFF); + if (dungeonRoom.getRoomProcessor() != null) + dungeonRoom.getRoomProcessor().drawScreen(); } + } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/DungeonRoomInfo.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/DungeonRoomInfo.java index b998fb27..abe3e263 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/DungeonRoomInfo.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/DungeonRoomInfo.java @@ -4,6 +4,8 @@ import lombok.Getter; import lombok.Setter; import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; import java.util.UUID; @Getter @@ -28,4 +30,6 @@ public class DungeonRoomInfo implements Serializable { private String name; private String processorId = "default"; + + private Map<String, Object> properties = new HashMap<String, Object>(); } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/OffsetPoint.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/OffsetPoint.java new file mode 100644 index 00000000..49775537 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/OffsetPoint.java @@ -0,0 +1,57 @@ +package kr.syeyoung.dungeonsguide.dungeon.data; + +import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.utils.VectorUtils; +import lombok.AllArgsConstructor; +import lombok.Data; +import net.minecraft.block.Block; +import net.minecraft.util.BlockPos; + +import javax.vecmath.Vector2d; + +@Data +@AllArgsConstructor +public class OffsetPoint { + private int x; + private int y; + private int z; + + public OffsetPoint(DungeonRoom dungeonRoom, BlockPos pos) { + Vector2d vector2d = new Vector2d(pos.getX(), pos.getZ()); + for (int i = 0; i < dungeonRoom.getRoomMatcher().getRotation(); i++) + vector2d = VectorUtils.rotateClockwise(vector2d); + + if (vector2d.x < 0) vector2d.x += dungeonRoom.getDungeonRoomInfo().getBlocks()[0].length - 1; + if (vector2d.y < 0) vector2d.y += dungeonRoom.getDungeonRoomInfo().getBlocks().length - 1; + + this.x = (int) vector2d.x; + this.z = (int) vector2d.y; + this.y = dungeonRoom.getMin().getY() + pos.getY(); + } + + public BlockPos toRotatedRelBlockPos(DungeonRoom dungeonRoom) { + int rot = dungeonRoom.getRoomMatcher().getRotation(); + Vector2d rot2 = new Vector2d(x,z); + for (int i = 0; i < dungeonRoom.getRoomMatcher().getRotation(); i++) { + rot2 = VectorUtils.rotateCounterClockwise(rot2); + } + if (rot2.x < 0) rot2.x += dungeonRoom.getMax().getX() - dungeonRoom.getMin().getX() + 2; + if (rot2.y < 0) rot2.y += dungeonRoom.getMax().getZ() - dungeonRoom.getMin().getZ() + 2; + + return new BlockPos(rot2.x, y, rot2.y); + } + + public Block getBlock(DungeonRoom dungeonRoom) { + BlockPos relBp = toRotatedRelBlockPos(dungeonRoom); + + Block b = dungeonRoom.getRelativeBlockAt(relBp.getX(), relBp.getY(), relBp.getZ()); + return b; + } + + public int getData(DungeonRoom dungeonRoom) { + BlockPos relBp = toRotatedRelBlockPos(dungeonRoom); + + int b = dungeonRoom.getRelativeBlockDataAt(relBp.getX(), relBp.getY(), relBp.getZ()); + return b; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/OffsetPointSet.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/OffsetPointSet.java new file mode 100644 index 00000000..a381ac49 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/OffsetPointSet.java @@ -0,0 +1,11 @@ +package kr.syeyoung.dungeonsguide.dungeon.data; + +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; + +@Data +public class OffsetPointSet { + private List<OffsetPoint> offsetPointList = new ArrayList<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 7e8c43e0..41e2fb6f 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoom.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoom.java @@ -108,7 +108,7 @@ public class DungeonRoom { public Block getRelativeBlockAt(int x, int y, int z) { // validate x y z's if (canAccessRelative(x,z)) { - BlockPos pos = new BlockPos(x,y,z).add(min.getX(),0,min.getZ()); + BlockPos pos = new BlockPos(x,y,z).add(min.getX(),min.getZ(),min.getZ()); return this.context.getWorld().getChunkFromBlockCoords(pos).getBlock(pos); } return null; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/RoomMatcher.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/RoomMatcher.java index 626b75b4..46337480 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/RoomMatcher.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/RoomMatcher.java @@ -51,12 +51,11 @@ public class RoomMatcher { System.out.println("Trying to match "+dungeonRoomInfo.getUuid().toString()+" / "+dungeonRoomInfo.getName()+"... at rotation "+rotation); - int y = dungeonRoom.getMin().getY(); for (int z = 0; z < res.length; z ++) { for (int x = 0; x < res[0].length; x++) { int data = res[z][x]; if (data == -1) continue; - Block b = dungeonRoom.getRelativeBlockAt(x,y,z); + Block b = dungeonRoom.getRelativeBlockAt(x,0,z); if (b == null || Block.getIdFromBlock(b) != data) { System.out.println("Match failed at offset X"+x+" / Z"+z+". expected "+data+" but found "+b +" ("+Block.getIdFromBlock(b)+")"); return false; @@ -74,7 +73,6 @@ public class RoomMatcher { int maxZ = dungeonRoom.getMax().getZ(); int minX = dungeonRoom.getMin().getX(); int minZ = dungeonRoom.getMin().getZ(); - int y = dungeonRoom.getMin().getY(); int widthX = maxX - minX + 2; int heightZ = maxZ - minZ + 2; int[][] data = new int[dungeonRoom.getMax().getZ() - dungeonRoom.getMin().getZ() +2][dungeonRoom.getMax().getX() - dungeonRoom.getMin().getX() + 2]; @@ -90,7 +88,7 @@ public class RoomMatcher { continue; } - Block b = dungeonRoom.getRelativeBlockAt(x,y,z); + Block b = dungeonRoom.getRelativeBlockAt(x,0,z); if (b == null) { data[z][x] = -1; } else { diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorBlazeSolver.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorBlazeSolver.java new file mode 100644 index 00000000..7574b79c --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorBlazeSolver.java @@ -0,0 +1,51 @@ +package kr.syeyoung.dungeonsguide.roomprocessor; + +import com.google.common.base.Predicate; +import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.entity.Entity; +import net.minecraft.entity.monster.EntityBlaze; +import net.minecraft.util.BlockPos; +import net.minecraft.world.World; +import org.jetbrains.annotations.Nullable; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; + +public class RoomProcessorBlazeSolver implements RoomProcessor { + + private DungeonRoom dungeonRoom; + private boolean highToLow = false; + + private List<Entity> entityList = new ArrayList<Entity>(); + public RoomProcessorBlazeSolver(DungeonRoom dungeonRoom) { + this.dungeonRoom = dungeonRoom; + Object highToLow = dungeonRoom.getDungeonRoomInfo().getProperties().get("order"); + if (highToLow == null) this.highToLow = false; + else this.highToLow = (Boolean) highToLow; + } + + @Override + public void tick() { + World w = dungeonRoom.getContext().getWorld(); + final BlockPos low = dungeonRoom.getMin(); + final BlockPos high = dungeonRoom.getMax(); + entityList = new ArrayList<Entity>(w.getEntities(EntityBlaze.class, new Predicate<EntityBlaze>() { + @Override + public boolean apply(@Nullable EntityBlaze input) { + BlockPos pos = input.getPosition(); + return low.getX() < pos.getX() && pos.getX() < high.getX() + && low.getZ() < pos.getZ() && pos.getZ() < high.getZ(); + } + })); + } + + @Override + public void drawScreen() { + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + fr.drawString("hehe blaze solver here", 100, 100, 0xFFFFFFFF); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/utils/VectorUtils.java b/src/main/java/kr/syeyoung/dungeonsguide/utils/VectorUtils.java new file mode 100644 index 00000000..89a4e7d1 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/utils/VectorUtils.java @@ -0,0 +1,12 @@ +package kr.syeyoung.dungeonsguide.utils; + +import javax.vecmath.Vector2d; + +public class VectorUtils { + public static Vector2d rotateCounterClockwise(Vector2d vector2d) { + return new Vector2d(-vector2d.y, vector2d.x); + } + public static Vector2d rotateClockwise(Vector2d vector2d) { + return new Vector2d(vector2d.y, -vector2d.x); + } +} |