diff options
15 files changed, 706 insertions, 21 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/DungeonListener.java b/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/DungeonListener.java index 06f0e0bb..1b9dd350 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/DungeonListener.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/DungeonListener.java @@ -33,6 +33,7 @@ import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.client.event.RenderWorldLastEvent; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.living.LivingEvent; +import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.fml.common.eventhandler.EventPriority; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.InputEvent; @@ -110,7 +111,7 @@ public class DungeonListener { return; } if (isOnSkyblock) { - if (isOnDungeon && skyblockStatus.isOnDungeon()) { + if (skyblockStatus.getContext() != null) { skyblockStatus.getContext().tick(); } else if (skyblockStatus.isOnDungeon()){ skyblockStatus.setContext(new DungeonContext(Minecraft.getMinecraft().thePlayer.worldObj)); @@ -372,4 +373,35 @@ public class DungeonListener { } else ec.reopen(); } } + @SubscribeEvent + public void onInteract(PlayerInteractEvent keyInputEvent) { + try { + SkyblockStatus skyblockStatus = (SkyblockStatus) e.getDungeonsGuide().getSkyblockStatus(); + if (!skyblockStatus.isOnDungeon()) return; + + DungeonContext context = skyblockStatus.getContext(); + + if (skyblockStatus.getContext() != null) { + EntityPlayerSP thePlayer = Minecraft.getMinecraft().thePlayer; + Point roomPt = context.getMapProcessor().worldPointToRoomPoint(thePlayer.getPosition()); + + if (context.getBossfightProcessor() != null) { + context.getBossfightProcessor().onInteractBlock(keyInputEvent); + } + RoomProcessor roomProcessor = null; + try { + DungeonRoom dungeonRoom = context.getRoomMapper().get(roomPt); + if (dungeonRoom != null) { + if (dungeonRoom.getRoomProcessor() != null) { + dungeonRoom.getRoomProcessor().onInteractBlock(keyInputEvent); + } + } + } catch (Throwable t) { + t.printStackTrace(); + } + } + } catch (Throwable e) { + e.printStackTrace(); + } + } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/GeneralRoomProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/GeneralRoomProcessor.java index 6d605283..17c1c05b 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/GeneralRoomProcessor.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/GeneralRoomProcessor.java @@ -45,11 +45,13 @@ public class GeneralRoomProcessor implements RoomProcessor { @Override public void drawScreen(float partialTicks) { FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - Entity e = Minecraft.getMinecraft().objectMouseOver.entityHit; - if (e != null && e instanceof EntityArmorStand) { - fr.drawString(e.getInventory()[4].getTagCompound() +"", 0, 0, 0xFFFFFFFF); +// Entity e = Minecraft.getMinecraft().objectMouseOver.entityHit; +// if (e != null && e instanceof EntityArmorStand) { + +// fr.drawString( +// Minecraft.getMinecraft().objectMouseOver +"", 0, 0, 0xFFFFFFFF); // System.out.println(e.getInventory()[4].getTagCompound()); - } +// } } @Override @@ -128,9 +130,9 @@ public class GeneralRoomProcessor implements RoomProcessor { public void onEntitySpawn(LivingEvent.LivingUpdateEvent updateEvent) { if (updateEvent.entityLiving instanceof EntityArmorStand) { // updateEvent.entityLiving.setInvisible(false); - byte b0 = updateEvent.entityLiving.getDataWatcher().getWatchableObjectByte(10); - b0 = (byte)(b0 & -17); - updateEvent.entityLiving.getDataWatcher().updateObject(10, Byte.valueOf(b0)); +// byte b0 = updateEvent.entityLiving.getDataWatcher().getWatchableObjectByte(10); +// b0 = (byte)(b0 & -17); +// updateEvent.entityLiving.getDataWatcher().updateObject(10, Byte.valueOf(b0)); } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/RoomProcessorBombDefuseSolver.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/RoomProcessorBombDefuseSolver.java index 8e2d1732..7ba75676 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/RoomProcessorBombDefuseSolver.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/RoomProcessorBombDefuseSolver.java @@ -1,31 +1,30 @@ package kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse; -import com.google.common.io.ByteArrayDataOutput; -import com.google.common.io.ByteStreams; import com.sun.org.apache.xerces.internal.impl.dv.util.Base64; -import kr.syeyoung.dungeonsguide.Keybinds; 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.e; import kr.syeyoung.dungeonsguide.events.PlayerInteractEntityEvent; import kr.syeyoung.dungeonsguide.roomprocessor.GeneralRoomProcessor; -import kr.syeyoung.dungeonsguide.roomprocessor.RoomProcessorBlazeSolver; import kr.syeyoung.dungeonsguide.roomprocessor.RoomProcessorGenerator; import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.BDChamber; import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.BombDefuseChamberGenerator; import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.DummyDefuseChamberProcessor; import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.arrow.ArrowProcessorMatcher; +import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.bugged.ImpossibleMatcher; import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.color.ColorProcessorMatcher; import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.creeper.CreeperProcessorMatcher; +import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.goldenpath.GoldenPathProcessorMatcher; +import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.maze.MazeProcessorMatcher; import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.number.NumberProcessorMatcher; +import kr.syeyoung.dungeonsguide.utils.RenderUtils; import kr.syeyoung.dungeonsguide.utils.TextUtils; import lombok.AllArgsConstructor; import lombok.Data; import lombok.Getter; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.ScaledResolution; import net.minecraft.nbt.CompressedStreamTools; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.BlockPos; @@ -35,9 +34,7 @@ import net.minecraftforge.client.event.GuiScreenEvent; import net.minecraftforge.event.entity.living.LivingEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.fml.common.gameevent.InputEvent; -import org.lwjgl.input.Keyboard; -import java.awt.*; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; @@ -58,9 +55,14 @@ public class RoomProcessorBombDefuseSolver extends GeneralRoomProcessor { chamberGenerators.add(new ColorProcessorMatcher()); chamberGenerators.add(new CreeperProcessorMatcher()); chamberGenerators.add(new NumberProcessorMatcher()); + chamberGenerators.add(new GoldenPathProcessorMatcher()); + chamberGenerators.add(new MazeProcessorMatcher()); + chamberGenerators.add(new ImpossibleMatcher()); } private boolean bugged = false; + private boolean maze = false; + private boolean impossible = false; public RoomProcessorBombDefuseSolver(DungeonRoom dungeonRoom) { super(dungeonRoom); @@ -110,7 +112,9 @@ public class RoomProcessorBombDefuseSolver extends GeneralRoomProcessor { set.setChamberGen(bdcg); set.getLeft().setProcessor(bdcg.createLeft(set.getLeft(), this)); set.getRight().setProcessor(bdcg.createRight(set.getRight(), this)); - System.out.println("Marched "+bdcg.getName()+" with "+set.getRight().getLevel()); + if (bdcg instanceof ImpossibleMatcher) impossible=true; + if (bdcg instanceof MazeProcessorMatcher) maze = true; + System.out.println("Matched "+bdcg.getName()+" with "+set.getLeft().getLevel()); break; } } @@ -120,11 +124,15 @@ public class RoomProcessorBombDefuseSolver extends GeneralRoomProcessor { set.getRight().setProcessor(new DummyDefuseChamberProcessor(this, set.getRight())); } } + + OffsetPoint warning1 = (OffsetPoint) dungeonRoom.getDungeonRoomInfo().getProperties().get("Warning"); + if (warning1 != null) warning = warning1.getBlockPos(dungeonRoom); } public BDChamber buildChamber(OffsetPointSet ops, int level, boolean left) { return new BDChamber(getDungeonRoom(), ops, left, level, null); } + BlockPos warning; public void communicate(NBTTagCompound compound) { @@ -241,6 +249,14 @@ public class RoomProcessorBombDefuseSolver extends GeneralRoomProcessor { } } } + + if ((maze || impossible) && warning != null) { + if (impossible) { + RenderUtils.drawTextAtWorld("Warning: This Bomb Defuse is bugged and Impossible" , warning.getX()+ 0.5f, warning.getY(), warning.getZ()+ 0.5f, 0xFF00FF00, 0.03F, false, false, partialTicks); + } else { + RenderUtils.drawTextAtWorld("Warning: This Bomb Defuse contains maze which can be only done with 2 ppl" , warning.getX()+ 0.5f, warning.getY(), warning.getZ()+ 0.5f, 0xFF00FF00, 0.03F, false, false, partialTicks); + } + } } @Override diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/arrow/ArrowLeftProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/arrow/ArrowLeftProcessor.java new file mode 100644 index 00000000..6b81cae6 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/arrow/ArrowLeftProcessor.java @@ -0,0 +1,120 @@ +package kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.arrow; + +import com.google.common.collect.BiMap; +import com.google.common.collect.HashBiMap; +import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.RoomProcessorBombDefuseSolver; +import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.BDChamber; +import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.GeneralDefuseChamberProcessor; +import kr.syeyoung.dungeonsguide.utils.RenderUtils; +import net.minecraft.entity.item.EntityArmorStand; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.util.BlockPos; + +import java.util.HashMap; +import java.util.Map; + +public class ArrowLeftProcessor extends GeneralDefuseChamberProcessor { + public ArrowLeftProcessor(RoomProcessorBombDefuseSolver solver, BDChamber chamber) { + super(solver, chamber); + + for (int i = 0; i < 9; i++) { + grid[i] = chamber.getBlockPos(7,1 + (i / 3),1 + (i % 3)); + } + } + + @Override + public String getName() { + return "arrowLeft"; + } + + + private int answer = -1; + private int[] answers = new int[9]; + private BlockPos[] grid = new BlockPos[9]; + @Override + public void tick() { + super.tick(); + if (answer != -1) return; + for (int i = 0; i < 9; i++) + answers[i] = match(getChamber().getEntityAt(EntityArmorStand.class, grid[i].add(0, -1, 0))); + + answer = 0; + for (int i =0; i < 9; i++) { + answer = answer * 10 + answers[i]; + } + } + + @Override + public void drawScreen(float partialTicks) { + if (answer == -1) return; + drawPressKey(); + } + + @Override + public void drawWorld(float partialTicks) { + super.drawWorld(partialTicks); + + if (answer == -1) return; + for (int i = 0; i < 9; i++) { + BlockPos pos = grid[i]; + int direction = answers[i]; + String charac = arrows.get(direction); + + RenderUtils.drawTextAtWorld(charac, pos.getX()+ 0.5f, pos.getY()+ 0.5f, pos.getZ()+ 0.5f, 0xFFFFFFFF, 0.05F, false, false, partialTicks); + } + } + + @Override + public void onSendData() { + if (answer == -1) return; + NBTTagCompound nbt = new NBTTagCompound(); + nbt.setString("a", "c"); + nbt.setInteger("b", answer); + getSolver().communicate(nbt); + } + + @Override + public void onDataRecieve(NBTTagCompound compound) { + if ("c".equals(compound.getString("a"))) { + answer = compound.getInteger("b"); + for (int i = 8; i >= 0; i--) { + answers[i] = answer % 10; + answer = answer / 10; + } + answer = compound.getInteger("b"); + } + } + + private int match(EntityArmorStand armorStand) { + if (armorStand == null) return -1; + ItemStack item = armorStand.getInventory()[4]; + NBTTagList list = item.getTagCompound().getCompoundTag("SkullOwner").getCompoundTag("Properties").getTagList("textures", 10); + String str = ((NBTTagCompound)list.get(0)).getString("Value"); + return !integers.containsKey(str) ? -1 : integers.get(str); + } + + private static final BiMap<String, Integer> integers = HashBiMap.create(8); + private static final Map<Integer, String> arrows = new HashMap<Integer, String>(); + { + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNDczZTFmZTBmZmNkNTQ2YzIxYjYzZWFhOTEwYWI1YzkzMTMyYTY0ZTY0NDE3OWZjY2FhMjFkYzhiYzY2MCJ9fX0=", 1); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNThmZTI1MWE0MGU0MTY3ZDM1ZDA4MWMyNzg2OWFjMTUxYWY5NmI2YmQxNmRkMjgzNGQ1ZGM3MjM1ZjQ3NzkxZCJ9fX0=", 2); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNTc3ZWM0NGZiNzUwM2RlNmFmZTNiZGQ3ZTU4M2M3YjkzOTc5ZjU5ZjZkNjM0YjZiNmE1YWY3ZjNhMWM1ODUxNSJ9fX0=", 3); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjJmM2EyZGZjZTBjM2RhYjdlZTEwZGIzODVlNTIyOWYxYTM5NTM0YThiYTI2NDYxNzhlMzdjNGZhOTNiIn19fQ==", 4); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOGUxY2U5YzBkMzMyMzZmOTkyMWQyMmM0ZWM0YmY1MDkyMzdhZWY2NzZiNWQxZDJiYWNjOTNmNWE4MTk0ODAifX19", 5); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOWI3Y2U2ODNkMDg2OGFhNDM3OGFlYjYwY2FhNWVhODA1OTZiY2ZmZGFiNmI1YWYyZDEyNTk1ODM3YTg0ODUzIn19fQ==", 6); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNTI2NTFlY2QzNzgwY2Y2ZTQ1MWVjYWNjZGVlNjk3MTVjMDhjYWU3Y2Q0NTA5MDg0NDYyY2RjZDk2M2E2YjMyMiJ9fX0=", 7); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYmIwZjZlOGFmNDZhYzZmYWY4ODkxNDE5MWFiNjZmMjYxZDY3MjZhNzk5OWM2MzdjZjJlNDE1OWZlMWZjNDc3In19fQ==", 8); + + arrows.put(0, "?"); + arrows.put(1, "↖"); + arrows.put(2, "↑"); + arrows.put(3, "↗"); + arrows.put(4, "→"); + arrows.put(5, "↘"); + arrows.put(6, "↓"); + arrows.put(7, "↙"); + arrows.put(8, "←"); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/arrow/ArrowProcessorMatcher.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/arrow/ArrowProcessorMatcher.java index e4f64917..dddbe9c8 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/arrow/ArrowProcessorMatcher.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/arrow/ArrowProcessorMatcher.java @@ -24,11 +24,11 @@ public class ArrowProcessorMatcher implements BombDefuseChamberGenerator { @Override public ChamberProcessor createLeft(BDChamber left, RoomProcessorBombDefuseSolver solver) { - return null; + return new ArrowLeftProcessor(solver, left); } @Override public ChamberProcessor createRight(BDChamber right, RoomProcessorBombDefuseSolver solver) { - return null; + return new ArrowRightProcessor(solver, right); } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/arrow/ArrowRightProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/arrow/ArrowRightProcessor.java new file mode 100644 index 00000000..b597b1ae --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/arrow/ArrowRightProcessor.java @@ -0,0 +1,122 @@ +package kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.arrow; + +import com.google.common.collect.BiMap; +import com.google.common.collect.HashBiMap; +import kr.syeyoung.dungeonsguide.events.PlayerInteractEntityEvent; +import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.RoomProcessorBombDefuseSolver; +import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.BDChamber; +import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.GeneralDefuseChamberProcessor; +import kr.syeyoung.dungeonsguide.utils.RenderUtils; +import net.minecraft.entity.item.EntityArmorStand; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.util.BlockPos; + +import java.util.HashMap; +import java.util.Map; + +public class ArrowRightProcessor extends GeneralDefuseChamberProcessor { + public ArrowRightProcessor(RoomProcessorBombDefuseSolver solver, BDChamber chamber) { + super(solver, chamber); + + for (int i = 0; i < 9; i++) { + grid[i] = chamber.getBlockPos(1,1 + (i / 3),1 + (2 - (i % 3))); + } + + center = chamber.getBlockPos(4,4,4); + } + + @Override + public String getName() { + return "arrowRight"; + } + + + private int answer = -1; + private int[] correctAnswers = new int[9]; + private int[] currentAnswers = new int[9]; + private BlockPos[] grid = new BlockPos[9]; + private BlockPos center; + @Override + public void tick() { + super.tick(); + for (int i = 0; i < 9; i++) + currentAnswers[i] = match(getChamber().getEntityAt(EntityArmorStand.class, grid[i].add(0, -1, 0))); + } + + @Override + public void drawWorld(float partialTicks) { + super.drawWorld(partialTicks); + + RenderUtils.drawTextAtWorld(answer == -1 ? "Answer not received yet. Visit left room to obtain solution" : "" , center.getX()+ 0.5f, center.getY(), center.getZ()+ 0.5f, 0xFFFFFFFF, 0.03F, false, false, partialTicks); + + for (int i = 0; i < 9; i++) { + BlockPos pos = grid[i]; + int direction = correctAnswers[i]; + int direction2 = currentAnswers[i]; + String charac = arrows.get(direction); + String car2 = arrows.get(direction2); + + RenderUtils.drawTextAtWorld(car2, pos.getX()+ 0.5f, pos.getY()+ 0.6f, pos.getZ()+ 0.5f, direction == direction2 ? 0xFF00FF00 : 0xFFFF0000, 0.03F, false, false, partialTicks); + RenderUtils.drawTextAtWorld(charac, pos.getX()+ 0.5f, pos.getY()+ 0.2f, pos.getZ()+ 0.5f, 0xFFFFFF00, 0.03F, false, false, partialTicks); + } + } + + @Override + public void onDataRecieve(NBTTagCompound compound) { + if ("c".equals(compound.getString("a"))) { + answer = compound.getInteger("b"); + for (int i = 8; i >= 0; i--) { + correctAnswers[i] = answer % 10; + answer = answer / 10; + } + answer = compound.getInteger("b"); + } + } + + @Override + public void onInteract(PlayerInteractEntityEvent event) { + if (answer == -1) return; + if (event.getEntity() instanceof EntityArmorStand) { + BlockPos pos = event.getEntity().getPosition(); + for (int i = 0; i < 9; i++) { + if (currentAnswers[i] == correctAnswers[i] && pos.equals(grid[i].add(0, -1, 0))) event.setCanceled(true); + } + + System.out.println(" block ? "+event.isCanceled()); + } + } + + private int match(EntityArmorStand armorStand) { + if (armorStand == null) return -1; + ItemStack item = armorStand.getInventory()[4]; + NBTTagList list = item.getTagCompound().getCompoundTag("SkullOwner").getCompoundTag("Properties").getTagList("textures", 10); + String str = ((NBTTagCompound)list.get(0)).getString("Value"); + return !integers.containsKey(str) ? -1 : integers.get(str); + } + + private static final BiMap<String, Integer> integers = HashBiMap.create(8); + private static final Map<Integer, String> arrows = new HashMap<Integer, String>(); + { + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvODY1NDI2YTMzZGY1OGI0NjVmMDYwMWRkOGI5YmVjMzY5MGIyMTkzZDFmOTUwM2MyY2FhYjc4ZjZjMjQzOCJ9fX0=", 1); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMzA0MGZlODM2YTZjMmZiZDJjN2E5YzhlYzZiZTUxNzRmZGRmMWFjMjBmNTVlMzY2MTU2ZmE1ZjcxMmUxMCJ9fX0=", 2); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOTBlMGE0ZDQ4Y2Q4MjlhNmQ1ODY4OTA5ZDY0M2ZhNGFmZmQzOWU4YWU2Y2FhZjZlYzc5NjA5Y2Y3NjQ5YjFjIn19fQ==", 3); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMTliZjMyOTJlMTI2YTEwNWI1NGViYTcxM2FhMWIxNTJkNTQxYTFkODkzODgyOWM1NjM2NGQxNzhlZDIyYmYifX19", 4); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMzVjYmRiMjg5OTFhMTZlYjJjNzkzNDc0ZWY3ZDBmNDU4YTVkMTNmZmZjMjgzYzRkNzRkOTI5OTQxYmIxOTg5In19fQ==", 5); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNzQzNzM0NmQ4YmRhNzhkNTI1ZDE5ZjU0MGE5NWU0ZTc5ZGFlZGE3OTVjYmM1YTEzMjU2MjM2MzEyY2YifX19", 6); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMzU0Y2U4MTU3ZTcxZGNkNWI2YjE2NzRhYzViZDU1NDkwNzAyMDI3YzY3NWU1Y2RjZWFjNTVkMmZiYmQ1YSJ9fX0=", 7); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYmQ2OWUwNmU1ZGFkZmQ4NGU1ZjNkMWMyMTA2M2YyNTUzYjJmYTk0NWVlMWQ0ZDcxNTJmZGM1NDI1YmMxMmE5In19fQ==", 8); + + + arrows.put(0, "?"); + arrows.put(1, "↖"); + arrows.put(2, "↑"); + arrows.put(3, "↗"); + arrows.put(4, "→"); + arrows.put(5, "↘"); + arrows.put(6, "↓"); + arrows.put(7, "↙"); + arrows.put(8, "←"); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/bugged/ImpossibleMatcher.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/bugged/ImpossibleMatcher.java new file mode 100644 index 00000000..398f5fb6 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/bugged/ImpossibleMatcher.java @@ -0,0 +1,29 @@ +package kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.bugged; + +import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.RoomProcessorBombDefuseSolver; +import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.BDChamber; +import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.BombDefuseChamberGenerator; +import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.ChamberProcessor; +import net.minecraft.init.Blocks; + +public class ImpossibleMatcher implements BombDefuseChamberGenerator { + @Override + public boolean match(BDChamber left, BDChamber right) { + return left.getBlock(1,1,1).getBlock() == Blocks.barrier; + } + + @Override + public String getName() { + return "buggedMazeMatcher"; + } + + @Override + public ChamberProcessor createLeft(BDChamber left, RoomProcessorBombDefuseSolver solver) { + return null; + } + + @Override + public ChamberProcessor createRight(BDChamber right, RoomProcessorBombDefuseSolver solver) { + return null; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/creeper/CreeperLeftProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/creeper/CreeperLeftProcessor.java index 705d710e..6f2a94c1 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/creeper/CreeperLeftProcessor.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/creeper/CreeperLeftProcessor.java @@ -59,7 +59,9 @@ public class CreeperLeftProcessor extends GeneralDefuseChamberProcessor { super.drawWorld(partialTicks); for (int i = 0; i < 9; i++) { if (((answer >> i) & 0x01) != 0) { - RenderUtils.highlightBlock(poses[answer], Color.green, partialTicks, false); + RenderUtils.highlightBlock(poses[i], new Color(255,0,0,100), partialTicks, false); + } else { + RenderUtils.highlightBlock(poses[i], new Color(0,255,0,100), partialTicks, false); } } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/creeper/CreeperRightProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/creeper/CreeperRightProcessor.java index ab9b3392..ba5266c6 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/creeper/CreeperRightProcessor.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/creeper/CreeperRightProcessor.java @@ -51,8 +51,8 @@ public class CreeperRightProcessor extends GeneralDefuseChamberProcessor { RenderUtils.drawTextAtWorld(answer == -1 ? "Answer not received yet. Visit left room to obtain solution" : "" , center.getX()+ 0.5f, center.getY(), center.getZ()+ 0.5f, 0xFFFFFFFF, 0.03F, false, false, partialTicks); if (answer != -1) { for (int i = 0; i < 9; i++) { - if (((answer >> i) & 0x01) != 0) { - RenderUtils.highlightBlock(poses[answer], Color.green, partialTicks, false); + if (((answer >> i) & 0x01) == 0) { + RenderUtils.highlightBlock(poses[i], new Color(0,255,0, 50), partialTicks, false); } } } @@ -71,6 +71,7 @@ public class CreeperRightProcessor extends GeneralDefuseChamberProcessor { event.setCanceled(true); } } + System.out.println(event.isCanceled()); } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/goldenpath/GoldenPathLeftProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/goldenpath/GoldenPathLeftProcessor.java new file mode 100644 index 00000000..780c1c2e --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/goldenpath/GoldenPathLeftProcessor.java @@ -0,0 +1,111 @@ +package kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.goldenpath; + +import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.RoomProcessorBombDefuseSolver; +import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.BDChamber; +import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.GeneralDefuseChamberProcessor; +import kr.syeyoung.dungeonsguide.utils.RenderUtils; +import net.minecraft.init.Blocks; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.BlockPos; + +import javax.vecmath.Vector2f; +import java.awt.*; +import java.util.*; +import java.util.List; + +public class GoldenPathLeftProcessor extends GeneralDefuseChamberProcessor { + public GoldenPathLeftProcessor(RoomProcessorBombDefuseSolver solver, BDChamber chamber) { + super(solver, chamber); + + } + + @Override + public String getName() { + return "goldenPathLeft"; + } + + + private long answer = -1; + // 1 up 2 right 3 down 4 left + private static final Point vectors[] = new Point[] { + new Point(0,1), + new Point(-1,0), + new Point(0, -1), + new Point(1, 0) + }; + + private LinkedList<BlockPos> blocksolution = new LinkedList<BlockPos>(); + @Override + public void tick() { + super.tick(); + if (answer != -1) return; + + List<Integer> solution = new ArrayList<Integer>(); + Set<BlockPos> visited = new HashSet<BlockPos>(); + BlockPos lastLoc = new BlockPos(4,0,0); + blocksolution.add(getChamber().getBlockPos(4,1,0)); + BlockPos target = new BlockPos(4,0,5); + while (!lastLoc.equals(target)) { + for (int i =0; i<vectors.length; i++) { + BlockPos target2 = lastLoc.add(vectors[i].x, 0, vectors[i].y); + if (visited.contains(target2)) continue; + if (target2.getX() < 0 || target2.getZ() < 0 || target2.getX() > 8 || target2.getZ() > 5) continue; + + visited.add(target2); + if (getChamber().getBlock(target2.getX(), 0, target2.getZ()).getBlock() == Blocks.hardened_clay + || getChamber().getBlock(target2.getX(), 0, target2.getZ()).getBlock() == Blocks.stained_hardened_clay) { + lastLoc = target2; + blocksolution.add(getChamber().getBlockPos(lastLoc.getX(), 1, lastLoc.getZ())); + solution.add(i); + break; + } + } + } + + answer = 0; + for (Integer inte:solution) { + answer *= 4; + answer += inte; + } + } + + @Override + public void drawScreen(float partialTicks) { + if (answer == -1) return; + drawPressKey(); + } + + @Override + public void drawWorld(float partialTicks) { + super.drawWorld(partialTicks); + RenderUtils.drawLines(blocksolution, Color.green, partialTicks, false); + } + + @Override + public void onSendData() { + if (answer == -1) return; + NBTTagCompound nbt = new NBTTagCompound(); + nbt.setString("a", "d"); + nbt.setLong("b", answer); + getSolver().communicate(nbt); + } + + @Override + public void onDataRecieve(NBTTagCompound compound) { + if ("d".equals(compound.getString("a"))) { + answer = compound.getInteger("b"); + + blocksolution.clear(); + BlockPos lastLoc = new BlockPos(4,0,0); + blocksolution.addFirst(getChamber().getBlockPos(4,1,0)); + while (answer != 0) { + int dir = (int) (answer % 4); + lastLoc = lastLoc.add(vectors[dir].x, 0, vectors[dir].y); + blocksolution.add(getChamber().getBlockPos(lastLoc.getX(), 1, lastLoc.getZ())); + answer /= 4; + } + + answer = compound.getInteger("b"); + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/goldenpath/GoldenPathProcessorMatcher.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/goldenpath/GoldenPathProcessorMatcher.java new file mode 100644 index 00000000..cd2fb4ea --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/goldenpath/GoldenPathProcessorMatcher.java @@ -0,0 +1,31 @@ +package kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.goldenpath; + +import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.RoomProcessorBombDefuseSolver; +import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.BDChamber; +import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.BombDefuseChamberGenerator; +import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.ChamberProcessor; +import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.creeper.CreeperLeftProcessor; +import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.creeper.CreeperRightProcessor; +import net.minecraft.init.Blocks; + +public class GoldenPathProcessorMatcher implements BombDefuseChamberGenerator { + @Override + public boolean match(BDChamber left, BDChamber right) { + return left.getBlock(4,0,0).getBlock() == Blocks.hardened_clay + || left.getBlock(4,0,0).getBlock() == Blocks.stained_hardened_clay; + } + + @Override + public String getName() { + return "goldPath"; + } + @Override + public ChamberProcessor createLeft(BDChamber left, RoomProcessorBombDefuseSolver solver) { + return new GoldenPathLeftProcessor(solver, left); + } + + @Override + public ChamberProcessor createRight(BDChamber right, RoomProcessorBombDefuseSolver solver) { + return new GoldenPathRightProcessor(solver, right); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/goldenpath/GoldenPathRightProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/goldenpath/GoldenPathRightProcessor.java new file mode 100644 index 00000000..e3a1ae04 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/goldenpath/GoldenPathRightProcessor.java @@ -0,0 +1,65 @@ +package kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.goldenpath; + +import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.RoomProcessorBombDefuseSolver; +import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.BDChamber; +import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.GeneralDefuseChamberProcessor; +import kr.syeyoung.dungeonsguide.utils.RenderUtils; +import net.minecraft.init.Blocks; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.BlockPos; + +import java.awt.*; +import java.util.List; +import java.util.*; + +public class GoldenPathRightProcessor extends GeneralDefuseChamberProcessor { + public GoldenPathRightProcessor(RoomProcessorBombDefuseSolver solver, BDChamber chamber) { + super(solver, chamber); + + center = chamber.getBlockPos(4,4,4); + } + + @Override + public String getName() { + return "goldenPathRight"; + } + + + private long answer = -1; + private BlockPos center; + // 1 up 2 right 3 down 4 left + private static final Point vectors[] = new Point[] { + new Point(0,1), + new Point(-1,0), + new Point(0, -1), + new Point(1, 0) + }; + + private LinkedList<BlockPos> blocksolution = new LinkedList<BlockPos>(); + + @Override + public void drawWorld(float partialTicks) { + super.drawWorld(partialTicks); + RenderUtils.drawTextAtWorld(answer == -1 ? "Answer not received yet. Visit left room to obtain solution" : "" , center.getX()+ 0.5f, center.getY(), center.getZ()+ 0.5f, 0xFFFFFFFF, 0.03F, false, false, partialTicks); + RenderUtils.drawLines(blocksolution, Color.green, partialTicks, false); + } + + @Override + public void onDataRecieve(NBTTagCompound compound) { + if ("d".equals(compound.getString("a"))) { + answer = compound.getInteger("b"); + + blocksolution.clear(); + BlockPos lastLoc = new BlockPos(4,0,0); + blocksolution.addFirst(getChamber().getBlockPos(4,1,0)); + while (answer != 0) { + int dir = (int) (answer % 4); + lastLoc = lastLoc.add(vectors[dir].x, 0, vectors[dir].y); + blocksolution.add(getChamber().getBlockPos(lastLoc.getX(), 1, lastLoc.getZ())); + answer /= 4; + } + + answer = compound.getInteger("b"); + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/maze/MazeLeftProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/maze/MazeLeftProcessor.java new file mode 100644 index 00000000..96a8ec93 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/maze/MazeLeftProcessor.java @@ -0,0 +1,63 @@ +package kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.maze; + +import kr.syeyoung.dungeonsguide.Keybinds; +import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.RoomProcessorBombDefuseSolver; +import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.BDChamber; +import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.GeneralDefuseChamberProcessor; +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.client.gui.ScaledResolution; +import net.minecraft.init.Blocks; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.BlockPos; +import net.minecraft.util.MovingObjectPosition; +import org.lwjgl.input.Keyboard; + +import java.awt.*; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Set; + +public class MazeLeftProcessor extends GeneralDefuseChamberProcessor { + public MazeLeftProcessor(RoomProcessorBombDefuseSolver solver, BDChamber chamber) { + super(solver, chamber); + } + + @Override + public String getName() { + return "mazeLeft"; + } + + + @Override + public void drawScreen(float partialTicks) { + if (Minecraft.getMinecraft().objectMouseOver == null ) return; + MovingObjectPosition pos = Minecraft.getMinecraft().objectMouseOver; + if (pos.typeOfHit != MovingObjectPosition.MovingObjectType.BLOCK) return; + + BlockPos block = pos.getBlockPos(); + Block b = getChamber().getRoom().getContext().getWorld().getBlockState(block).getBlock(); + + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft()); + String str = "Press "+ Keyboard.getKeyName(Keybinds.sendBombdefuse.getKeyCode()) + " to request open "+b.getLocalizedName(); + fr.drawString(str, (sr.getScaledWidth() - fr.getStringWidth(str)) / 2, (sr.getScaledHeight() - fr.FONT_HEIGHT) / 2, 0xFFFFFFFF); + } + + @Override + public void onSendData() { + if (Minecraft.getMinecraft().objectMouseOver == null ) return; + MovingObjectPosition pos = Minecraft.getMinecraft().objectMouseOver; + if (pos.typeOfHit != MovingObjectPosition.MovingObjectType.BLOCK) return; + + BlockPos block = pos.getBlockPos(); + Block b = getChamber().getRoom().getContext().getWorld().getBlockState(block).getBlock(); + + NBTTagCompound nbt = new NBTTagCompound(); + nbt.setString("a", "e"); + nbt.setInteger("b", Block.getIdFromBlock(b)); + getSolver().communicate(nbt); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/maze/MazeProcessorMatcher.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/maze/MazeProcessorMatcher.java new file mode 100644 index 00000000..629f7b6d --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/maze/MazeProcessorMatcher.java @@ -0,0 +1,30 @@ +package kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.maze; + +import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.RoomProcessorBombDefuseSolver; +import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.BDChamber; +import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.BombDefuseChamberGenerator; +import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.ChamberProcessor; +import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.goldenpath.GoldenPathLeftProcessor; +import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.goldenpath.GoldenPathRightProcessor; +import net.minecraft.init.Blocks; + +public class MazeProcessorMatcher implements BombDefuseChamberGenerator { + @Override + public boolean match(BDChamber left, BDChamber right) { + return left.getBlock(1,0,1).getBlock() == Blocks.iron_block; + } + + @Override + public String getName() { + return "mazeMatch"; + } + @Override + public ChamberProcessor createLeft(BDChamber left, RoomProcessorBombDefuseSolver solver) { + return new MazeLeftProcessor(solver, left); + } + + @Override + public ChamberProcessor createRight(BDChamber right, RoomProcessorBombDefuseSolver solver) { + return new MazeRightProcessor(solver, right); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/maze/MazeRightProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/maze/MazeRightProcessor.java new file mode 100644 index 00000000..bee47b05 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/maze/MazeRightProcessor.java @@ -0,0 +1,61 @@ +package kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.maze; + +import kr.syeyoung.dungeonsguide.Keybinds; +import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.RoomProcessorBombDefuseSolver; +import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.BDChamber; +import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.GeneralDefuseChamberProcessor; +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.client.gui.ScaledResolution; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.BlockPos; +import net.minecraft.util.MovingObjectPosition; +import org.lwjgl.input.Keyboard; + +import java.awt.*; +import java.util.HashMap; +import java.util.Map; + +public class MazeRightProcessor extends GeneralDefuseChamberProcessor { + public MazeRightProcessor(RoomProcessorBombDefuseSolver solver, BDChamber chamber) { + super(solver, chamber); + center = chamber.getBlockPos(4,4,4); + + for (int x = 0; x < 9; x++) { + for (int y =0; y< 6; y++) { + Block b = chamber.getBlock(x,0,y).getBlock(); + BlockPos pos = chamber.getBlockPos(x,0,y); + blockToBlockPosMap.put(b, pos); + } + } + } + + private BlockPos center; + private Map<Block, BlockPos> blockToBlockPosMap = new HashMap<Block, BlockPos>(); + @Override + public String getName() { + return "mazeRight"; + } + + + private Block latestRequest = null; + + @Override + public void drawWorld(float partialTicks) { + super.drawWorld(partialTicks); + RenderUtils.drawTextAtWorld(latestRequest == null ? "Request not received yet" : "Requested received "+latestRequest.getLocalizedName() , center.getX()+ 0.5f, center.getY(), center.getZ()+ 0.5f, 0xFFFFFFFF, 0.03F, false, false, partialTicks); + BlockPos pos = blockToBlockPosMap.get(latestRequest); + if (pos == null) return; + RenderUtils.highlightBlock(pos, new Color(0,255,0,100), partialTicks, false); + } + + @Override + public void onDataRecieve(NBTTagCompound compound) { + if ("e".equals(compound.getString("a"))) { + int latestRequestid = compound.getInteger("b"); + latestRequest = Block.getBlockById(latestRequestid); + } + } +} |