diff options
author | syeyoung <cyong06@naver.com> | 2021-02-01 12:32:33 +0900 |
---|---|---|
committer | syeyoung <cyong06@naver.com> | 2021-02-01 12:32:33 +0900 |
commit | b0ab5b0d5ce45aa5b961cccecc6e8462b9f3e57e (patch) | |
tree | 9ea8c7822f5152131c47288b280efe63eff80413 /src | |
parent | 4bd4e520d6d2559b0bfee97379481ecc5292cb28 (diff) | |
download | Skyblock-Dungeons-Guide-b0ab5b0d5ce45aa5b961cccecc6e8462b9f3e57e.tar.gz Skyblock-Dungeons-Guide-b0ab5b0d5ce45aa5b961cccecc6e8462b9f3e57e.tar.bz2 Skyblock-Dungeons-Guide-b0ab5b0d5ce45aa5b961cccecc6e8462b9f3e57e.zip |
creeper and number
Diffstat (limited to 'src')
11 files changed, 353 insertions, 76 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/GeneralRoomProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/GeneralRoomProcessor.java index 6bef19eb..6d605283 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/GeneralRoomProcessor.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/GeneralRoomProcessor.java @@ -22,6 +22,7 @@ import net.minecraft.util.IChatComponent; import net.minecraftforge.client.event.GuiScreenEvent; import net.minecraftforge.event.entity.living.LivingEvent; import net.minecraftforge.event.entity.player.EntityInteractEvent; +import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.fml.common.gameevent.InputEvent; import java.awt.*; @@ -43,12 +44,12 @@ 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) { -// fr.drawString(e.getInventory()[4].serializeNBT() +"", 0, 0, 0xFFFFFFFF); -// System.out.println(e.getInventory()[4].serializeNBT()); -// } + 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); +// System.out.println(e.getInventory()[4].getTagCompound()); + } } @Override @@ -125,12 +126,12 @@ public class GeneralRoomProcessor implements RoomProcessor { @Override public void onEntitySpawn(LivingEvent.LivingUpdateEvent updateEvent) { -// if (updateEvent.entityLiving instanceof EntityArmorStand) { + 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)); + } } @Override @@ -143,6 +144,11 @@ public class GeneralRoomProcessor implements RoomProcessor { } + @Override + public void onInteractBlock(PlayerInteractEvent event) { + + } + public static class Generator implements RoomProcessorGenerator<GeneralRoomProcessor> { @Override public GeneralRoomProcessor createNew(DungeonRoom dungeonRoom) { diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessor.java index fa2ed8f1..c3d50e06 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessor.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessor.java @@ -6,6 +6,7 @@ import net.minecraft.util.IChatComponent; import net.minecraftforge.client.event.GuiScreenEvent; import net.minecraftforge.event.entity.living.LivingEvent; import net.minecraftforge.event.entity.player.EntityInteractEvent; +import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.fml.common.gameevent.InputEvent; public interface RoomProcessor { @@ -23,4 +24,5 @@ public interface RoomProcessor { void onKeyPress(InputEvent.KeyInputEvent keyInputEvent); void onInteract(PlayerInteractEntityEvent event); + void onInteractBlock(PlayerInteractEvent event); }
\ No newline at end of file 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 6e18d441..8e2d1732 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/RoomProcessorBombDefuseSolver.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/RoomProcessorBombDefuseSolver.java @@ -3,10 +3,12 @@ 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; @@ -22,6 +24,8 @@ 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; @@ -29,6 +33,9 @@ import net.minecraft.util.ChatComponentText; import net.minecraft.util.IChatComponent; 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; @@ -102,7 +109,8 @@ public class RoomProcessorBombDefuseSolver extends GeneralRoomProcessor { if (bdcg.match(set.getLeft(), set.getRight())) { set.setChamberGen(bdcg); set.getLeft().setProcessor(bdcg.createLeft(set.getLeft(), this)); - set.getRight().setProcessor(bdcg.createLeft(set.getRight(), this)); + set.getRight().setProcessor(bdcg.createRight(set.getRight(), this)); + System.out.println("Marched "+bdcg.getName()+" with "+set.getRight().getLevel()); break; } } @@ -124,11 +132,12 @@ public class RoomProcessorBombDefuseSolver extends GeneralRoomProcessor { try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataOutputStream w = new DataOutputStream(baos); - CompressedStreamTools.write(compound, w); + CompressedStreamTools.writeCompressed(compound, w); w.flush(); byte[] bytes = baos.toByteArray(); String str = Base64.encode(bytes); - Minecraft.getMinecraft().thePlayer.sendChatMessage("/pc " +str); + System.out.println(str); + Minecraft.getMinecraft().thePlayer.sendChatMessage("/pc $DG-BD " +str); } catch (IOException e2) { e2.printStackTrace(); e.sendDebugChat(new ChatComponentText("Failed to send Bomb Defuse Chat")); @@ -140,10 +149,11 @@ public class RoomProcessorBombDefuseSolver extends GeneralRoomProcessor { super.chatReceived(component); if (bugged) return; - if (component.getFormattedText().contains("$DG-BD")) { + if (component.getFormattedText().contains("$DG-BD ")) { try { String data = component.getFormattedText().substring(component.getFormattedText().indexOf("$DG-BD")); - String actual = TextUtils.stripColor(data); + String actual = TextUtils.stripColor(data).trim().split(" ")[1]; + System.out.println(actual); byte[] data2 = Base64.decode(actual); NBTTagCompound compound = CompressedStreamTools.readCompressed(new ByteArrayInputStream(data2)); @@ -169,34 +179,44 @@ public class RoomProcessorBombDefuseSolver extends GeneralRoomProcessor { OffsetPoint offsetPoint = new OffsetPoint(getDungeonRoom(), new BlockPos(player.getX(), 68, player.getZ())); for (ChamberSet ch:chambers) { if (ch.getLeft() != null && ch.getLeft().getProcessor() != null) { - if (!ch.getLeft().getChamberBlocks().getOffsetPointList().contains(offsetPoint)) { + if (ch.getLeft().getChamberBlocks().getOffsetPointList().contains(offsetPoint)) { ch.getLeft().getProcessor().tick(); } } if (ch.getRight() != null && ch.getRight().getProcessor() != null) { - if (!ch.getRight().getChamberBlocks().getOffsetPointList().contains(offsetPoint)) { + if (ch.getRight().getChamberBlocks().getOffsetPointList().contains(offsetPoint)) { ch.getRight().getProcessor().tick(); } } } } + @Override public void drawScreen(float partialTicks) { super.drawScreen(partialTicks); - if (bugged) return; BlockPos player = Minecraft.getMinecraft().thePlayer.getPosition(); OffsetPoint offsetPoint = new OffsetPoint(getDungeonRoom(), new BlockPos(player.getX(), 68, player.getZ())); for (ChamberSet ch:chambers) { + if (ch.getChamberGen() == null)continue; if (ch.getLeft() != null && ch.getLeft().getProcessor() != null) { - if (!ch.getLeft().getChamberBlocks().getOffsetPointList().contains(offsetPoint)) { + if (ch.getLeft().getChamberBlocks().getOffsetPointList().contains(offsetPoint)) { ch.getLeft().getProcessor().drawScreen(partialTicks); + + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + String str = "Current: "+ch.getChamberGen().getName() + " Specific: "+ch.getLeft().getProcessor().getName(); + fr.drawString(str,0,0, 0xFFFFFFFF); } } if (ch.getRight() != null && ch.getRight().getProcessor() != null) { - if (!ch.getRight().getChamberBlocks().getOffsetPointList().contains(offsetPoint)) { + if (ch.getRight().getChamberBlocks().getOffsetPointList().contains(offsetPoint)) { ch.getRight().getProcessor().drawScreen(partialTicks); + + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + if (ch.getChamberGen() == null || ch.getRight().getProcessor() == null) continue; + String str = "Current: "+ch.getChamberGen().getName() + " Specific: "+ch.getRight().getProcessor().getName(); + fr.drawString(str,0,0, 0xFFFFFFFF); } } } @@ -211,12 +231,12 @@ public class RoomProcessorBombDefuseSolver extends GeneralRoomProcessor { OffsetPoint offsetPoint = new OffsetPoint(getDungeonRoom(), new BlockPos(player.getX(), 68, player.getZ())); for (ChamberSet ch:chambers) { if (ch.getLeft() != null && ch.getLeft().getProcessor() != null) { - if (!ch.getLeft().getChamberBlocks().getOffsetPointList().contains(offsetPoint)) { + if (ch.getLeft().getChamberBlocks().getOffsetPointList().contains(offsetPoint)) { ch.getLeft().getProcessor().drawWorld(partialTicks); } } if (ch.getRight() != null && ch.getRight().getProcessor() != null) { - if (!ch.getRight().getChamberBlocks().getOffsetPointList().contains(offsetPoint)) { + if (ch.getRight().getChamberBlocks().getOffsetPointList().contains(offsetPoint)) { ch.getRight().getProcessor().drawWorld(partialTicks); } } @@ -245,12 +265,12 @@ public class RoomProcessorBombDefuseSolver extends GeneralRoomProcessor { OffsetPoint offsetPoint = new OffsetPoint(getDungeonRoom(), new BlockPos(player.getX(), 68, player.getZ())); for (ChamberSet ch:chambers) { if (ch.getLeft() != null && ch.getLeft().getProcessor() != null) { - if (!ch.getLeft().getChamberBlocks().getOffsetPointList().contains(offsetPoint)) { + if (ch.getLeft().getChamberBlocks().getOffsetPointList().contains(offsetPoint)) { ch.getLeft().getProcessor().onPostGuiRender(event); } } if (ch.getRight() != null && ch.getRight().getProcessor() != null) { - if (!ch.getRight().getChamberBlocks().getOffsetPointList().contains(offsetPoint)) { + if (ch.getRight().getChamberBlocks().getOffsetPointList().contains(offsetPoint)) { ch.getRight().getProcessor().onPostGuiRender(event); } } @@ -266,19 +286,80 @@ public class RoomProcessorBombDefuseSolver extends GeneralRoomProcessor { OffsetPoint offsetPoint = new OffsetPoint(getDungeonRoom(), new BlockPos(player.getX(), 68, player.getZ())); for (ChamberSet ch:chambers) { if (ch.getLeft() != null && ch.getLeft().getProcessor() != null) { - if (!ch.getLeft().getChamberBlocks().getOffsetPointList().contains(offsetPoint)) { + if (ch.getLeft().getChamberBlocks().getOffsetPointList().contains(offsetPoint)) { ch.getLeft().getProcessor().onEntitySpawn(updateEvent); } } if (ch.getRight() != null && ch.getRight().getProcessor() != null) { - if (!ch.getRight().getChamberBlocks().getOffsetPointList().contains(offsetPoint)) { + if (ch.getRight().getChamberBlocks().getOffsetPointList().contains(offsetPoint)) { ch.getRight().getProcessor().onEntitySpawn(updateEvent); } } } } + @Override + public void onKeyPress(InputEvent.KeyInputEvent keyInputEvent) { + super.onKeyPress(keyInputEvent); + if (bugged) return; + + BlockPos player = Minecraft.getMinecraft().thePlayer.getPosition(); + OffsetPoint offsetPoint = new OffsetPoint(getDungeonRoom(), new BlockPos(player.getX(), 68, player.getZ())); + for (ChamberSet ch:chambers) { + if (ch.getLeft() != null && ch.getLeft().getProcessor() != null) { + if (ch.getLeft().getChamberBlocks().getOffsetPointList().contains(offsetPoint)) { + ch.getLeft().getProcessor().onKeyPress(keyInputEvent); + } + } + if (ch.getRight() != null && ch.getRight().getProcessor() != null) { + if (ch.getRight().getChamberBlocks().getOffsetPointList().contains(offsetPoint)) { + ch.getRight().getProcessor().onKeyPress(keyInputEvent); + } + } + } + } + + @Override + public void onInteract(PlayerInteractEntityEvent event) { + super.onInteract(event); + if (bugged) return; + BlockPos player = Minecraft.getMinecraft().thePlayer.getPosition(); + OffsetPoint offsetPoint = new OffsetPoint(getDungeonRoom(), new BlockPos(player.getX(), 68, player.getZ())); + for (ChamberSet ch:chambers) { + if (ch.getLeft() != null && ch.getLeft().getProcessor() != null) { + if (ch.getLeft().getChamberBlocks().getOffsetPointList().contains(offsetPoint)) { + ch.getLeft().getProcessor().onInteract(event); + } + } + if (ch.getRight() != null && ch.getRight().getProcessor() != null) { + if (ch.getRight().getChamberBlocks().getOffsetPointList().contains(offsetPoint)) { + ch.getRight().getProcessor().onInteract(event); + } + } + } + } + + @Override + public void onInteractBlock(PlayerInteractEvent event) { + super.onInteractBlock(event); + if (bugged) return; + + BlockPos player = Minecraft.getMinecraft().thePlayer.getPosition(); + OffsetPoint offsetPoint = new OffsetPoint(getDungeonRoom(), new BlockPos(player.getX(), 68, player.getZ())); + for (ChamberSet ch:chambers) { + if (ch.getLeft() != null && ch.getLeft().getProcessor() != null) { + if (ch.getLeft().getChamberBlocks().getOffsetPointList().contains(offsetPoint)) { + ch.getLeft().getProcessor().onInteractBlock(event); + } + } + if (ch.getRight() != null && ch.getRight().getProcessor() != null) { + if (ch.getRight().getChamberBlocks().getOffsetPointList().contains(offsetPoint)) { + ch.getRight().getProcessor().onInteractBlock(event); + } + } + } + } @Override public boolean readGlobalChat() { return true; } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/GeneralDefuseChamberProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/GeneralDefuseChamberProcessor.java index 92aaed64..8069e3bc 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/GeneralDefuseChamberProcessor.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/GeneralDefuseChamberProcessor.java @@ -13,6 +13,7 @@ import net.minecraft.util.IChatComponent; import net.minecraftforge.client.event.GuiScreenEvent; import net.minecraftforge.event.entity.living.LivingEvent; import net.minecraftforge.event.entity.player.EntityInteractEvent; +import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.fml.common.gameevent.InputEvent; import org.lwjgl.input.Keyboard; @@ -94,5 +95,10 @@ public abstract class GeneralDefuseChamberProcessor implements ChamberProcessor } + @Override + public void onInteractBlock(PlayerInteractEvent event) { + + } + public void onSendData() {} } 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 new file mode 100644 index 00000000..705d710e --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/creeper/CreeperLeftProcessor.java @@ -0,0 +1,82 @@ +package kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.creeper; + +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.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.util.BlockPos; +import net.minecraftforge.event.entity.player.PlayerInteractEvent; + +import java.awt.*; +import java.util.BitSet; + +public class CreeperLeftProcessor extends GeneralDefuseChamberProcessor { + public CreeperLeftProcessor(RoomProcessorBombDefuseSolver solver, BDChamber chamber) { + super(solver, chamber); + + poses = new BlockPos[9]; + for (int i = 0; i < 9; i++) { + poses[i] = chamber.getBlockPos(3+(i%3), 1, 1+(i/3)); + } + } + + @Override + public String getName() { + return "creeperLeft"; + } + + + private int answer = -1; + private BlockPos[] poses; + @Override + public void tick() { + super.tick(); + if (answer != -1) return; + answer = 0; + for (int i = 0; i < poses.length; i++) { + BlockPos pos = poses[i]; + if (getChamber().getRoom().getContext().getWorld().getBlockState(pos).getBlock() == Blocks.air) { + answer |= (1 << i); + } + } + } + + @Override + public void drawScreen(float partialTicks) { + if (answer == -1) return; + drawPressKey(); + } + + @Override + public void drawWorld(float partialTicks) { + super.drawWorld(partialTicks); + for (int i = 0; i < 9; i++) { + if (((answer >> i) & 0x01) != 0) { + RenderUtils.highlightBlock(poses[answer], Color.green, partialTicks, false); + } + } + } + + @Override + public void onSendData() { + if (answer == -1) return; + NBTTagCompound nbt = new NBTTagCompound(); + nbt.setString("a", "b"); + nbt.setInteger("b", answer); + getSolver().communicate(nbt); + } + + @Override + public void onDataRecieve(NBTTagCompound compound) { + if ("b".equals(compound.getString("a"))) { + answer = compound.getInteger("b"); + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/creeper/CreeperProcessorMatcher.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/creeper/CreeperProcessorMatcher.java index 6163272b..f2bb91c1 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/creeper/CreeperProcessorMatcher.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/creeper/CreeperProcessorMatcher.java @@ -24,11 +24,11 @@ public class CreeperProcessorMatcher implements BombDefuseChamberGenerator { } @Override public ChamberProcessor createLeft(BDChamber left, RoomProcessorBombDefuseSolver solver) { - return null; + return new CreeperLeftProcessor(solver, left); } @Override public ChamberProcessor createRight(BDChamber right, RoomProcessorBombDefuseSolver solver) { - return null; + return new CreeperRightProcessor(solver, right); } } 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 new file mode 100644 index 00000000..ab9b3392 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/creeper/CreeperRightProcessor.java @@ -0,0 +1,92 @@ +package kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.creeper; + +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 net.minecraft.world.World; +import net.minecraftforge.event.entity.player.PlayerInteractEvent; + +import java.awt.*; + +public class CreeperRightProcessor extends GeneralDefuseChamberProcessor { + public CreeperRightProcessor(RoomProcessorBombDefuseSolver solver, BDChamber chamber) { + super(solver, chamber); + + poses = new BlockPos[9]; + for (int i = 0; i < 9; i++) { + poses[i] = chamber.getBlockPos(3+(i%3), 1, 1+(i/3)); + } + center = chamber.getBlockPos(4,4,4); + } + + @Override + public String getName() { + return "creeperRight"; + } + + + private int answer = -1; + private BlockPos[] poses; + private BlockPos center; + @Override + public void tick() { + super.tick(); + if (answer != -1) return; + answer = 0; + for (int i = 0; i < poses.length; i++) { + BlockPos pos = poses[i]; + if (getChamber().getRoom().getContext().getWorld().getBlockState(pos).getBlock() == Blocks.air) { + answer |= (1 << i); + } + } + } + + @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); + if (answer != -1) { + for (int i = 0; i < 9; i++) { + if (((answer >> i) & 0x01) != 0) { + RenderUtils.highlightBlock(poses[answer], Color.green, partialTicks, false); + } + } + } + } + + @Override + public void onInteractBlock(PlayerInteractEvent event) { + BlockPos pos = event.pos; + World w = event.world; + + if (answer == -1) return; + + if (w.getBlockState(pos).getBlock() == Blocks.wooden_button) { + for (int i = 0; i < 9; i++) { + if (poses[answer] == pos && ((answer >> i) & 0x01) == 0) { + event.setCanceled(true); + } + } + } + } + + @Override + public void onSendData() { + if (answer == -1) return; + NBTTagCompound nbt = new NBTTagCompound(); + nbt.setString("a", "b"); + nbt.setInteger("b", answer); + getSolver().communicate(nbt); + } + + @Override + public void onDataRecieve(NBTTagCompound compound) { + if ("b".equals(compound.getString("a"))) { + answer = compound.getInteger("b"); + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/number/NumberLeftProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/number/NumberLeftProcessor.java index d580e525..b069a445 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/number/NumberLeftProcessor.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/number/NumberLeftProcessor.java @@ -41,10 +41,10 @@ public class NumberLeftProcessor extends GeneralDefuseChamberProcessor { public void tick() { super.tick(); if (answer != -1) return; - d4 = match(getChamber().getEntityAt(EntityArmorStand.class,d1p)); - d3 = match(getChamber().getEntityAt(EntityArmorStand.class,d2p)); - d2 = match(getChamber().getEntityAt(EntityArmorStand.class,d3p)); - d1 = match(getChamber().getEntityAt(EntityArmorStand.class,d4p)); + d1 = match(getChamber().getEntityAt(EntityArmorStand.class,d1p)); + d2 = match(getChamber().getEntityAt(EntityArmorStand.class,d2p)); + d3 = match(getChamber().getEntityAt(EntityArmorStand.class,d3p)); + d4 = match(getChamber().getEntityAt(EntityArmorStand.class,d4p)); if (d1 == -1 || d2 == -1 || d3 == -1 || d4 == -1) return; answer = d1 * 1000 + d2 * 100 + d3 * 10 + d4; @@ -59,10 +59,10 @@ public class NumberLeftProcessor extends GeneralDefuseChamberProcessor { @Override public void drawWorld(float partialTicks) { super.drawWorld(partialTicks); - RenderUtils.drawTextAtWorld(d1+"", d1p.getX()+ 0.5f, d1p.getY()+ 0.5f, d1p.getZ()+ 0.5f, 0xFFFFFFFF, 1.0F, false, false, partialTicks); - RenderUtils.drawTextAtWorld(d2+"", d2p.getX()+ 0.5f, d2p.getY()+ 0.5f, d2p.getZ()+ 0.5f, 0xFFFFFFFF, 1.0F, false, false, partialTicks); - RenderUtils.drawTextAtWorld(d3+"", d3p.getX()+ 0.5f, d3p.getY()+ 0.5f, d3p.getZ()+ 0.5f, 0xFFFFFFFF, 1.0F, false, false, partialTicks); - RenderUtils.drawTextAtWorld(d4+"", d4p.getX()+ 0.5f, d4p.getY()+ 0.5f, d4p.getZ()+ 0.5f, 0xFFFFFFFF, 1.0F, false, false, partialTicks); + RenderUtils.drawTextAtWorld(d1+"", d1p.getX()+ 0.5f, d1p.getY()+ 0.5f, d1p.getZ()+ 0.5f, 0xFFFFFFFF, 0.03F, false, false, partialTicks); + RenderUtils.drawTextAtWorld(d2+"", d2p.getX()+ 0.5f, d2p.getY()+ 0.5f, d2p.getZ()+ 0.5f, 0xFFFFFFFF, 0.03F, false, false, partialTicks); + RenderUtils.drawTextAtWorld(d3+"", d3p.getX()+ 0.5f, d3p.getY()+ 0.5f, d3p.getZ()+ 0.5f, 0xFFFFFFFF, 0.03F, false, false, partialTicks); + RenderUtils.drawTextAtWorld(d4+"", d4p.getX()+ 0.5f, d4p.getY()+ 0.5f, d4p.getZ()+ 0.5f, 0xFFFFFFFF, 0.03F, false, false, partialTicks); } @@ -70,31 +70,29 @@ public class NumberLeftProcessor extends GeneralDefuseChamberProcessor { public void onSendData() { if (answer == -1) return; NBTTagCompound nbt = new NBTTagCompound(); - nbt.setString("type", "numberMatch"); - nbt.setInteger("d1", d1); - nbt.setInteger("d2", d2); - nbt.setInteger("d3", d3); - nbt.setInteger("d4", d4); + nbt.setString("a", "a"); + nbt.setInteger("b", answer); getSolver().communicate(nbt); } @Override public void onDataRecieve(NBTTagCompound compound) { - if ("numberMatch".equals(compound.getString("type"))) { - d1 = compound.getInteger("d1"); - d2 = compound.getInteger("d2"); - d3 = compound.getInteger("d3"); - d4 = compound.getInteger("d4"); - answer = d1 * 1000 + d2 * 100 + d3 * 10 + d4; + if ("a".equals(compound.getString("a"))) { + answer = compound.getInteger("b"); + d1 = answer / 1000; + d2 = (answer % 1000) / 100; + d3 = (answer % 100) / 10; + d4 = (answer % 10); + answer = d4 * 1000 + d3 * 100 + d2 * 10 + d1; } } 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", 8); - String str = ((NBTTagString)list.get(0)).getString(); - return integers.containsKey(str) ? -1 : integers.get(str); + 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(10); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/number/NumberRightProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/number/NumberRightProcessor.java index 0882d4ad..a61c6a6c 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/number/NumberRightProcessor.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/number/NumberRightProcessor.java @@ -37,25 +37,24 @@ public class NumberRightProcessor extends GeneralDefuseChamberProcessor { @Override public void tick() { super.tick(); - a4 = match(getChamber().getEntityAt(EntityArmorStand.class,d1p)); - a3 = match(getChamber().getEntityAt(EntityArmorStand.class,d2p)); - a2 = match(getChamber().getEntityAt(EntityArmorStand.class,d3p)); - a1 = match(getChamber().getEntityAt(EntityArmorStand.class,d4p)); + a1 = match(getChamber().getEntityAt(EntityArmorStand.class,d1p)); + a2 = match(getChamber().getEntityAt(EntityArmorStand.class,d2p)); + a3 = match(getChamber().getEntityAt(EntityArmorStand.class,d3p)); + a4 = match(getChamber().getEntityAt(EntityArmorStand.class,d4p)); } @Override public void drawWorld(float partialTicks) { super.drawWorld(partialTicks); - RenderUtils.drawTextAtWorld(a1+"", d1p.getX()+ 0.5f, d1p.getY()+ 0.6f, d1p.getZ()+ 0.5f, 0xFFFFFFFF, 1.0F, false, false, partialTicks); - RenderUtils.drawTextAtWorld(a2+"", d2p.getX()+ 0.5f, d2p.getY()+ 0.6f, d2p.getZ()+ 0.5f, 0xFFFFFFFF, 1.0F, false, false, partialTicks); - RenderUtils.drawTextAtWorld(a3+"", d3p.getX()+ 0.5f, d3p.getY()+ 0.6f, d3p.getZ()+ 0.5f, 0xFFFFFFFF, 1.0F, false, false, partialTicks); - RenderUtils.drawTextAtWorld(a4+"", d4p.getX()+ 0.5f, d4p.getY()+ 0.6f, d4p.getZ()+ 0.5f, 0xFFFFFFFF, 1.0F, false, false, partialTicks); - RenderUtils.drawTextAtWorld(answer == -1 ? "Answer not received yet. Visit left room to obtain solution" : answer + "", center.getX()+ 0.5f, center.getY(), center.getZ()+ 0.5f, 0xFFFFFFFF, 1.0F, false, false, partialTicks); - - RenderUtils.drawTextAtWorld(d1+"", d1p.getX()+ 0.5f, d1p.getY()+ 0.2f, d1p.getZ()+ 0.5f, 0xFFFFFFFF, 1.0F, false, false, partialTicks); - RenderUtils.drawTextAtWorld(d2+"", d2p.getX()+ 0.5f, d2p.getY()+ 0.2f, d2p.getZ()+ 0.5f, 0xFFFFFFFF, 1.0F, false, false, partialTicks); - RenderUtils.drawTextAtWorld(d3+"", d3p.getX()+ 0.5f, d3p.getY()+ 0.2f, d3p.getZ()+ 0.5f, 0xFFFFFFFF, 1.0F, false, false, partialTicks); - RenderUtils.drawTextAtWorld(d4+"", d4p.getX()+ 0.5f, d4p.getY()+ 0.2f, d4p.getZ()+ 0.5f, 0xFFFFFFFF, 1.0F, false, false, partialTicks); + RenderUtils.drawTextAtWorld(a1+"", d1p.getX()+ 0.5f, d1p.getY()+ 0.6f, d1p.getZ()+ 0.5f, a1 == d1 ? 0xFF00FF00 : 0xFFFF0000, 0.03F, false, false, partialTicks); + RenderUtils.drawTextAtWorld(a2+"", d2p.getX()+ 0.5f, d2p.getY()+ 0.6f, d2p.getZ()+ 0.5f, a2 == d2 ? 0xFF00FF00 : 0xFFFF0000, 0.03F, false, false, partialTicks); + RenderUtils.drawTextAtWorld(a3+"", d3p.getX()+ 0.5f, d3p.getY()+ 0.6f, d3p.getZ()+ 0.5f, a3 == d3 ? 0xFF00FF00 : 0xFFFF0000, 0.03F, false, false, partialTicks); + RenderUtils.drawTextAtWorld(a4+"", d4p.getX()+ 0.5f, d4p.getY()+ 0.6f, d4p.getZ()+ 0.5f, a4 == d4 ? 0xFF00FF00 : 0xFFFF0000, 0.03F, false, false, partialTicks); + RenderUtils.drawTextAtWorld(answer == -1 ? "Answer not received yet. Visit left room to obtain solution" : ("Solution: "+answer) , center.getX()+ 0.5f, center.getY(), center.getZ()+ 0.5f, 0xFFFFFFFF, 0.03F, false, false, partialTicks); + RenderUtils.drawTextAtWorld(d1+"", d1p.getX()+ 0.5f, d1p.getY()+ 0.2f, d1p.getZ()+ 0.5f, 0xFFFFFF00, 0.03F, false, false, partialTicks); + RenderUtils.drawTextAtWorld(d2+"", d2p.getX()+ 0.5f, d2p.getY()+ 0.2f, d2p.getZ()+ 0.5f, 0xFFFFFF00, 0.03F, false, false, partialTicks); + RenderUtils.drawTextAtWorld(d3+"", d3p.getX()+ 0.5f, d3p.getY()+ 0.2f, d3p.getZ()+ 0.5f, 0xFFFFFF00, 0.03F, false, false, partialTicks); + RenderUtils.drawTextAtWorld(d4+"", d4p.getX()+ 0.5f, d4p.getY()+ 0.2f, d4p.getZ()+ 0.5f, 0xFFFFFF00, 0.03F, false, false, partialTicks); } @Override @@ -67,26 +66,31 @@ public class NumberRightProcessor extends GeneralDefuseChamberProcessor { if (a2 == d2 && pos.equals(d2p)) event.setCanceled(true); if (a3 == d3 && pos.equals(d3p)) event.setCanceled(true); if (a4 == d4 && pos.equals(d4p)) event.setCanceled(true); + + System.out.println(" block ? "+event.isCanceled()); } } @Override public void onDataRecieve(NBTTagCompound compound) { - if ("numberMatch".equals(compound.getString("type"))) { - d1 = compound.getInteger("d1"); - d2 = compound.getInteger("d2"); - d3 = compound.getInteger("d3"); - d4 = compound.getInteger("d4"); - answer = d1 * 1000 + d2 * 100 + d3 * 10 + d4; + if ("a".equals(compound.getString("a"))) { + answer = compound.getInteger("b"); + d1 = answer / 1000; + d2 = (answer % 1000) / 100; + d3 = (answer % 100) / 10; + d4 = (answer % 10); + answer = d4 * 1000 + d3 * 100 + d2 * 10 + d1; } } private int match(EntityArmorStand armorStand) { - if (armorStand == null) return -1; + if (armorStand == null) { + return -1; + } ItemStack item = armorStand.getInventory()[4]; - NBTTagList list = item.getTagCompound().getCompoundTag("SkullOwner").getCompoundTag("Properties").getTagList("textures", 8); - String str = ((NBTTagString)list.get(0)).getString(); - return integers.containsKey(str) ? -1 : integers.get(str); + 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(10); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bossfight/GeneralBossfightProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bossfight/GeneralBossfightProcessor.java index 608b1e2d..511bc62d 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bossfight/GeneralBossfightProcessor.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bossfight/GeneralBossfightProcessor.java @@ -8,6 +8,7 @@ import net.minecraft.util.IChatComponent; import net.minecraft.world.World; 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 java.util.*; @@ -99,6 +100,11 @@ public abstract class GeneralBossfightProcessor implements BossfightProcessor { } + @Override + public void onInteractBlock(PlayerInteractEvent event) { + + } + public void onPhaseChange() {} @Data diff --git a/src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java b/src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java index c9395708..cb3c762f 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java @@ -477,7 +477,7 @@ public class RenderUtils { GlStateManager.rotate(renderManager.playerViewX, 1.0f, 0.0f, 0.0f); GlStateManager.scale(-lScale, -lScale, lScale); GlStateManager.disableLighting(); - GlStateManager.depthMask(false); + GlStateManager.depthMask(false); GL11.glDisable(GL11.GL_DEPTH_TEST); GlStateManager.disableDepth(); GlStateManager.enableBlend(); GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); |