diff options
author | syeyoung <42869671+cyoung06@users.noreply.github.com> | 2020-11-28 15:37:36 +0900 |
---|---|---|
committer | syeyoung <42869671+cyoung06@users.noreply.github.com> | 2020-11-28 15:37:36 +0900 |
commit | bb507052d573c2754289a0de58de88fc72eade3a (patch) | |
tree | daa20283c1bbcdcff70c4caa0c42ea3b9bfc80b0 /src | |
parent | 832eb22f6320540c8f9c2c12dec5e8466bbe87f1 (diff) | |
download | Skyblock-Dungeons-Guide-bb507052d573c2754289a0de58de88fc72eade3a.tar.gz Skyblock-Dungeons-Guide-bb507052d573c2754289a0de58de88fc72eade3a.tar.bz2 Skyblock-Dungeons-Guide-bb507052d573c2754289a0de58de88fc72eade3a.zip |
puzzle solvers and bug fixes
Diffstat (limited to 'src')
10 files changed, 457 insertions, 11 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/DungeonsGuide.java b/src/main/java/kr/syeyoung/dungeonsguide/DungeonsGuide.java index d15b1583..7936fbe3 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/DungeonsGuide.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/DungeonsGuide.java @@ -3,6 +3,7 @@ package kr.syeyoung.dungeonsguide; import kr.syeyoung.dungeonsguide.commands.CommandEditRoom; import kr.syeyoung.dungeonsguide.commands.CommandLoadData; import kr.syeyoung.dungeonsguide.commands.CommandSaveData; +import kr.syeyoung.dungeonsguide.commands.CommandToggleDebug; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoomInfoRegistry; import lombok.Getter; import net.minecraft.client.Minecraft; @@ -46,7 +47,7 @@ public class DungeonsGuide MinecraftForge.EVENT_BUS.register(cc); ClientCommandHandler.instance.registerCommand(new CommandLoadData()); ClientCommandHandler.instance.registerCommand(new CommandSaveData()); - ClientCommandHandler.instance.registerCommand(new CommandDebug()); + ClientCommandHandler.instance.registerCommand(new CommandToggleDebug()); //noinspection ResultOfMethodCallIgnored configDir.mkdirs(); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/EventListener.java b/src/main/java/kr/syeyoung/dungeonsguide/EventListener.java index 39abefee..8856dd81 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/EventListener.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/EventListener.java @@ -30,13 +30,11 @@ import org.lwjgl.opengl.GL11; import java.awt.*; public class EventListener { - private int timerTick = 0; @SubscribeEvent public void onTick(TickEvent.ClientTickEvent e) { if (e.phase == TickEvent.Phase.START) { - timerTick ++; SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); - if (timerTick % 5 == 0) { + { boolean isOnDungeon = skyblockStatus.isOnDungeon(); // System.out.println(isOnDungeon); skyblockStatus.updateStatus(); @@ -115,10 +113,10 @@ public class EventListener { Point roomPt = context.getMapProcessor().worldPointToRoomPoint(thePlayer.getPosition()); DungeonRoom dungeonRoom = context.getRoomMapper().get(roomPt); - FontRenderer fontRenderer = Minecraft.getMinecraft().fontRendererObj; if (dungeonRoom != null) { - if (dungeonRoom.getRoomProcessor() != null) + if (dungeonRoom.getRoomProcessor() != null) { dungeonRoom.getRoomProcessor().chatReceived(clientChatReceivedEvent.message); + } } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/ProcessorFactory.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/ProcessorFactory.java index 23976fbd..d3b685c8 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/ProcessorFactory.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/ProcessorFactory.java @@ -24,7 +24,12 @@ public class ProcessorFactory { static { registerRoomProcessor("default", new GeneralRoomProcessor.Generator()); - registerRoomProcessor("puzzle_blaze_solver", new RoomProcessorBlazeSolver.Generator()); registerRoomProcessor("puzzle_water_solver", new RoomProcessorWaterPuzzle.Generator()); + registerRoomProcessor("puzzle_teleport_solver", new RoomProcessorTeleportMazeSolver.Generator()); + registerRoomProcessor("puzzle_riddle_solver", new RoomProcessorRiddle.Generator()); + registerRoomProcessor("puzzle_creeper_solver", new RoomProcessorCreeperSolver.Generator()); + registerRoomProcessor("puzzle_tictactoe_solver", new RoomProcessorTicTacToeSolver.Generator()); + + registerRoomProcessor("puzzle_blaze_solver", new RoomProcessorBlazeSolver.Generator()); } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorCreeperSolver.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorCreeperSolver.java new file mode 100644 index 00000000..af075f2b --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorCreeperSolver.java @@ -0,0 +1,106 @@ +package kr.syeyoung.dungeonsguide.roomprocessor; + +import com.google.common.base.Predicate; +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPointSet; +import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.utils.RenderUtils; +import kr.syeyoung.dungeonsguide.utils.TextUtils; +import net.minecraft.block.Block; +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityArmorStand; +import net.minecraft.entity.monster.EntityCreeper; +import net.minecraft.init.Blocks; +import net.minecraft.util.BlockPos; +import net.minecraft.util.Vec3; +import net.minecraft.world.World; +import org.jetbrains.annotations.Nullable; + +import java.awt.*; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +public class RoomProcessorCreeperSolver extends GeneralRoomProcessor { + + private List<BlockPos[]> poses = new ArrayList<BlockPos[]>(); + + public RoomProcessorCreeperSolver(DungeonRoom dungeonRoom) { + super(dungeonRoom); + World w = dungeonRoom.getContext().getWorld(); + Set<BlockPos> prismarines = new HashSet<BlockPos>(); + final BlockPos low = dungeonRoom.getMin(); + final BlockPos high = dungeonRoom.getMax(); + 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() && input.getName().toLowerCase().contains("blaze"); + } + }); + if (creeepr.isEmpty()) return; + EntityCreeper creeper = creeepr.get(0); + Vec3 position = creeper.getPositionVector().addVector(0,1.5,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 = 0; 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) { + opposite = pos3; + } + } + if (opposite == null) continue; + + BlockPos otherPrismarine = null; + for (BlockPos inBox : BlockPos.getAllInBox(opposite.add(-2, -3, -2), opposite.add(2, 3, 2))) { + Block b3 = w.getChunkFromBlockCoords(inBox).getBlock(inBox); + if (b3 == Blocks.prismarine ||b == Blocks.sea_lantern) { + otherPrismarine = inBox; + break; + } + } + if (otherPrismarine == null) continue; + + prismarines.add(otherPrismarine); + poses.add(new BlockPos[] {allInBox, otherPrismarine}); + } + } + + } + + + + @Override + public void drawWorld(float partialTicks) { + super.drawWorld(partialTicks); + World w = getDungeonRoom().getContext().getWorld(); + for (BlockPos[] poset:poses) { +// if (w.getChunkFromBlockCoords(poset[0]).getBlock(poset[0]) != Blocks.sea_lantern && +// w.getChunkFromBlockCoords(poset[1]).getBlock(poset[1]) != Blocks.sea_lantern) { +// continue; +// } + RenderUtils.drawLine(poset[0], poset[1], new Color(0,255,255,255), partialTicks); + } + } + + public static class Generator implements RoomProcessorGenerator<RoomProcessorCreeperSolver> { + @Override + public RoomProcessorCreeperSolver createNew(DungeonRoom dungeonRoom) { + RoomProcessorCreeperSolver defaultRoomProcessor = new RoomProcessorCreeperSolver(dungeonRoom); + return defaultRoomProcessor; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorRiddle.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorRiddle.java new file mode 100644 index 00000000..01c04d60 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorRiddle.java @@ -0,0 +1,29 @@ +package kr.syeyoung.dungeonsguide.roomprocessor; + +import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; +import net.minecraft.util.IChatComponent; + +public class RoomProcessorRiddle extends GeneralRoomProcessor { + + public RoomProcessorRiddle(DungeonRoom dungeonRoom) { + super(dungeonRoom); + } + + @Override + public void chatReceived(IChatComponent chat) { + System.out.println("event! +"+chat); + super.chatReceived(chat); + String ch2 = chat.getUnformattedText(); + System.out.println("hey::"+ch2); + + } + + + public static class Generator implements RoomProcessorGenerator<RoomProcessorRiddle> { + @Override + public RoomProcessorRiddle createNew(DungeonRoom dungeonRoom) { + RoomProcessorRiddle defaultRoomProcessor = new RoomProcessorRiddle(dungeonRoom); + return defaultRoomProcessor; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorTeleportMazeSolver.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorTeleportMazeSolver.java new file mode 100644 index 00000000..3d3083c5 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorTeleportMazeSolver.java @@ -0,0 +1,70 @@ +package kr.syeyoung.dungeonsguide.roomprocessor; + +import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.utils.RenderUtils; +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.init.Blocks; +import net.minecraft.util.BlockPos; +import net.minecraft.world.World; + +import java.awt.*; +import java.util.ArrayList; +import java.util.List; + +public class RoomProcessorTeleportMazeSolver extends GeneralRoomProcessor { + private BlockPos lastPlayerLocation; + + public RoomProcessorTeleportMazeSolver(DungeonRoom dungeonRoom) { + super(dungeonRoom); + } + + private List<BlockPos> visitedPortals = new ArrayList<BlockPos>(); + + @Override + public void tick() { + super.tick(); + + World w = getDungeonRoom().getContext().getWorld(); + BlockPos pos2 = Minecraft.getMinecraft().thePlayer.getPosition(); + Block b = w.getChunkFromBlockCoords(pos2).getBlock(pos2); + if (b == Blocks.stone_slab || b == Blocks.stone_slab2) { + boolean teleport = false; + for (BlockPos allInBox : BlockPos.getAllInBox(lastPlayerLocation, pos2)) { + if (w.getChunkFromBlockCoords(allInBox).getBlock(allInBox) == Blocks.iron_bars) { + teleport = true; + break; + } + } + for (BlockPos allInBox : BlockPos.getAllInBox(pos2.add(-1, 0, -1), pos2.add(1, 0, 1))) { + if (w.getChunkFromBlockCoords(allInBox).getBlock(allInBox) == Blocks.end_portal_frame) { + visitedPortals.add(allInBox); + break; + } + } + for (BlockPos allInBox : BlockPos.getAllInBox(lastPlayerLocation.add(-1, -1, -1), lastPlayerLocation.add(1, 1, 1))) { + if (w.getChunkFromBlockCoords(allInBox).getBlock(allInBox) == Blocks.end_portal_frame) { + visitedPortals.add(allInBox); + break; + } + } + } + + lastPlayerLocation = pos2; + } + + @Override + public void drawWorld(float partialTicks) { + super.drawWorld(partialTicks); + for (BlockPos bpos:visitedPortals) { + RenderUtils.highlightBlock(bpos, new Color(255,0,0,100), partialTicks); + } + } + public static class Generator implements RoomProcessorGenerator<RoomProcessorTeleportMazeSolver> { + @Override + public RoomProcessorTeleportMazeSolver createNew(DungeonRoom dungeonRoom) { + RoomProcessorTeleportMazeSolver defaultRoomProcessor = new RoomProcessorTeleportMazeSolver(dungeonRoom); + return defaultRoomProcessor; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorTicTacToeSolver.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorTicTacToeSolver.java new file mode 100644 index 00000000..79cd4992 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorTicTacToeSolver.java @@ -0,0 +1,196 @@ +package kr.syeyoung.dungeonsguide.roomprocessor; + +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPointSet; +import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.utils.RenderUtils; +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.entity.item.EntityItemFrame; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemMap; +import net.minecraft.item.ItemStack; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.BlockPos; +import net.minecraft.util.MinecraftError; +import net.minecraft.world.World; +import net.minecraft.world.storage.MapData; + +import java.awt.*; +import java.util.List; + +public class RoomProcessorTicTacToeSolver extends GeneralRoomProcessor { + + private OffsetPointSet board; + private byte[][] lastBoard; + public RoomProcessorTicTacToeSolver(DungeonRoom dungeonRoom) { + super(dungeonRoom); + + board = (OffsetPointSet) dungeonRoom.getDungeonRoomInfo().getProperties().get("board"); + } + + // -1 com, 1 pla, 0 emp + private byte[][] buildBoardState() { + byte[][] board = new byte[3][3]; + World w= getDungeonRoom().getContext().getWorld(); + for (int x = 0; x < 3; x++) { + for (int y = 0; y < 3; y++) { + OffsetPoint op = this.board.getOffsetPointList().get(x * 3 + y); + BlockPos bpos = op.getBlockPos(getDungeonRoom()); + Block b = w.getChunkFromBlockCoords(bpos).getBlock(bpos); + if (b == Blocks.stone_button) { + board[y][x] = 0; + } else if (b == Blocks.air){ + AxisAlignedBB abab = AxisAlignedBB.fromBounds(bpos.getX() , bpos.getY(), bpos.getZ(), bpos.getX() +1, bpos.getY() +1, bpos.getZ() +1); + List<EntityItemFrame> frames = getDungeonRoom().getContext().getWorld().getEntitiesWithinAABB(EntityItemFrame.class, abab); + if (frames.isEmpty()) board[y][x] = 0; + else { + ItemStack displayedItem = frames.get(0).getDisplayedItem(); + if (displayedItem == null || displayedItem.getItem() == null || !displayedItem.getItem().isMap()) { + board[y][x] = 0; + continue; + } + MapData mapData = ((ItemMap)displayedItem.getItem()).getMapData(displayedItem, w); + byte center = mapData.colors[64 * 128+64]; + if (center == 114) + board[y][x] = -1; + else + board[y][x] = 1; + } + } + } + } + return board; + } + + private byte checkWinner(byte[][] board) { + for (int y = 0; y <3; y++) { + byte potentialWinner = board[y][0]; + if (potentialWinner == 0) continue; + boolean found = false; + for (int x = 0; x < 3; x++) { + if (potentialWinner != board[y][x]) { + found = true; + break; + } + } + if (!found) { + return potentialWinner; + } + } + for (int x = 0; x <3; x++) { + byte potentialWinner = board[0][x]; + if (potentialWinner == 0) continue; + boolean found = false; + for (int y = 0; y < 3; y++) { + if (potentialWinner != board[y][x]) { + found = true; + break; + } + } + if (!found) { + return potentialWinner; + } + } + if (board[0][0] == board[1][1] && board[1][1] == board[2][2] && board[0][0] != 0) { + return board[0][0]; + } + if (board[0][2] == board[1][1] && board[1][1] == board[2][0] && board[0][2] != 0) { + return board[0][2]; + } + return 0; + } + + private int chosePos = -1; + private int minimax(byte[][] board, byte player) { + byte winner = checkWinner(board); + if (winner != 0) { + return winner * player; + } + + int move = -1; + int score = -2; + for (int i = 0; i < 9; i++) { + if (board[i % 3][i / 3] == 0) { + byte[][] cloned = new byte[3][]; + for(int k = 0; k < 3; k++) + cloned[k] = board[k].clone(); + + cloned[i % 3][i/3] = player; + int scoreForMove = -minimax(cloned, (byte) -player); + if (scoreForMove > score) { + score = scoreForMove; + move = i; + } + } + } + chosePos = move; + if (move == -1) { + return 0; + } + + return score; + } + + private boolean gameEnded = false; + + @Override + public void tick() { + super.tick(); + if (board == null) return; + if (gameEnded) return; + byte[][] board = buildBoardState(); + if (checkWinner(board) != 0) { + gameEnded = true; + return; + } + if (lastBoard != null) { + boolean yesdoit = false; + label: + for (int y = 0; y < 3; y++) + for (int x = 0; x < 3; x++) + if (board[y][x] != lastBoard[y][x]) { + yesdoit = true; + break label; + } + if (!yesdoit) return; + } + lastBoard = board; + + minimax(board, (byte) 1); + if (chosePos == -1) { + gameEnded = true; + return; + } + } + + @Override + public void drawWorld(float partialTicks) { + super.drawWorld(partialTicks); + if (chosePos != -1) { + BlockPos block = board.getOffsetPointList().get(chosePos).getBlockPos(getDungeonRoom()); + RenderUtils.highlightBlock(block, new Color(0,255,255,50), partialTicks); + } + } + + @Override + public void drawScreen(float partialTicks) { + super.drawScreen(partialTicks); + if (lastBoard == null) return; + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + for (int y = 0; y < 3; y++){ + for(int x = 0; x < 3; x++) { + fr.drawString(lastBoard[y][x]+"", x * 2 *fr.FONT_HEIGHT, y * fr.FONT_HEIGHT, (x *3 +y) == chosePos ?0xFF00FF00 :0xFFFFFF); + } + } + } + + public static class Generator implements RoomProcessorGenerator<RoomProcessorTicTacToeSolver> { + @Override + public RoomProcessorTicTacToeSolver createNew(DungeonRoom dungeonRoom) { + RoomProcessorTicTacToeSolver defaultRoomProcessor = new RoomProcessorTicTacToeSolver(dungeonRoom); + return defaultRoomProcessor; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/WaterBoard.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/WaterBoard.java index 7894af26..a2da9b23 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/WaterBoard.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/WaterBoard.java @@ -255,8 +255,9 @@ public class WaterBoard { int data= pos.getData(waterPuzzle.getDungeonRoom()); node = new WaterNodeEnd(id+":"+data, front.getBlockPos(waterPuzzle.getDungeonRoom()),x,y); waterNodeEndMap.put(id+":"+data, (WaterNodeEnd) node); - } else if (y == 3) { - waterNodeStart = (WaterNodeStart) (node = new WaterNodeStart(front.getBlockPos(waterPuzzle.getDungeonRoom()),x,y)); + } else if (y == 1) { + waterNodeStart = (WaterNodeStart) (node = new WaterNodeStart(front.getBlockPos(waterPuzzle.getDungeonRoom()), + frontId != 0 ^ validSwitches.get("mainStream").getCurrentState(),x,y)); } else { node = new WaterNodeAir(front.getBlockPos(waterPuzzle.getDungeonRoom()),x,y); } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/nodes/WaterNodeStart.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/nodes/WaterNodeStart.java index 7c7d8e91..8ea7ca6c 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/nodes/WaterNodeStart.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/nodes/WaterNodeStart.java @@ -13,7 +13,8 @@ import net.minecraft.world.World; @AllArgsConstructor public class WaterNodeStart implements WaterNode { - BlockPos blockPos; + private BlockPos blockPos; + private boolean isReversed; @Override public boolean canWaterGoThrough() { @@ -22,7 +23,7 @@ public class WaterNodeStart implements WaterNode { @Override public WaterCondition getCondition() { - return new WaterCondition("mainStream", true); + return new WaterCondition("mainStream", !isReversed); } @Override diff --git a/src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java b/src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java index c985cf42..158793b3 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java @@ -93,6 +93,45 @@ public class RenderUtils { } + public static void drawLine(BlockPos pos1, BlockPos pos2, Color c, float partialTicks) { + + Entity viewing_from = Minecraft.getMinecraft().getRenderViewEntity(); + + double x_fix = viewing_from.lastTickPosX + ((viewing_from.posX - viewing_from.lastTickPosX) * partialTicks); + double y_fix = viewing_from.lastTickPosY + ((viewing_from.posY - viewing_from.lastTickPosY) * partialTicks); + double z_fix = viewing_from.lastTickPosZ + ((viewing_from.posZ - viewing_from.lastTickPosZ) * partialTicks); + + GlStateManager.pushMatrix(); + GlStateManager.pushAttrib(); + GlStateManager.translate(-x_fix, -y_fix, -z_fix); + + GlStateManager.disableLighting(); + GlStateManager.enableBlend(); + GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.disableTexture2D(); + + GL11.glDisable(GL11.GL_DEPTH_TEST); + GL11.glDepthMask(false); + GL11.glColor4ub((byte)c.getRed(), (byte)c.getGreen(), (byte)c.getBlue(), (byte)c.getAlpha()); + + GL11.glBegin(GL11.GL_LINES); + + GL11.glVertex3f(pos1.getX(), pos1.getY(), pos1.getZ()); + GL11.glVertex3f(pos1.getX(),pos1.getY(),pos1.getZ()); + + + GL11.glEnd(); + + + GL11.glEnable(GL11.GL_DEPTH_TEST); + GL11.glDepthMask(true); + GlStateManager.enableTexture2D(); + GlStateManager.disableBlend(); + GlStateManager.enableLighting(); + GlStateManager.popMatrix(); + GlStateManager.popAttrib(); + } + public static void highlightBlock(BlockPos blockpos, Color c, float partialTicks) { Entity viewing_from = Minecraft.getMinecraft().getRenderViewEntity(); |