aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/Keybinds.java3
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/eventlistener/DungeonListener.java62
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/eventlistener/PacketListener.java14
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/events/PlayerInteractEntityEvent.java21
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/roomprocessor/GeneralRoomProcessor.java13
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessor.java7
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/RoomProcessorBombDefuseSolver.java92
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/BDChamber.java26
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/BombDefuseChamberGenerator.java6
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/DummyDefuseChamberProcessor.java5
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/GeneralDefuseChamberProcessor.java45
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/arrow/ArrowProcessorMatcher.java5
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/color/ColorProcessorMatcher.java6
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/creeper/CreeperProcessorMatcher.java6
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/number/NumberLeftProcessor.java113
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/number/NumberProcessorMatcher.java10
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/number/NumberRightProcessor.java105
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bossfight/GeneralBossfightProcessor.java12
18 files changed, 513 insertions, 38 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/Keybinds.java b/src/main/java/kr/syeyoung/dungeonsguide/Keybinds.java
index 43e67eac..9a9451e5 100755
--- a/src/main/java/kr/syeyoung/dungeonsguide/Keybinds.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/Keybinds.java
@@ -7,11 +7,14 @@ import org.lwjgl.input.Keyboard;
public class Keybinds
{
public static KeyBinding editingSession;
+ public static KeyBinding sendBombdefuse;
public static KeyBinding ringMenuForSecretEdit;
public static void register()
{
editingSession = new KeyBinding("start editing session", Keyboard.KEY_NONE, "key.categories.misc");
ClientRegistry.registerKeyBinding(editingSession);
+ sendBombdefuse = new KeyBinding("send and save bombdefuse solution", Keyboard.KEY_F, "key.categories.misc");
+ ClientRegistry.registerKeyBinding(sendBombdefuse);
}
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/DungeonListener.java b/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/DungeonListener.java
index d59d0b3d..06f0e0bb 100755
--- a/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/DungeonListener.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/DungeonListener.java
@@ -280,6 +280,68 @@ public class DungeonListener {
e.printStackTrace();
}
}
+ @SubscribeEvent()
+ public void onKey2(InputEvent.KeyInputEvent 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().onKeyPress(keyInputEvent);
+ }
+ RoomProcessor roomProcessor = null;
+ try {
+ DungeonRoom dungeonRoom = context.getRoomMapper().get(roomPt);
+ if (dungeonRoom != null) {
+ if (dungeonRoom.getRoomProcessor() != null) {
+ dungeonRoom.getRoomProcessor().onKeyPress(keyInputEvent);
+ }
+ }
+ } catch (Throwable t) {
+ t.printStackTrace();
+ }
+ }
+ } catch (Throwable e) {
+ e.printStackTrace();
+ }
+ }
+ @SubscribeEvent()
+ public void onInteract(PlayerInteractEntityEvent interact) {
+ 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().onInteract(interact);
+ }
+ RoomProcessor roomProcessor = null;
+ try {
+ DungeonRoom dungeonRoom = context.getRoomMapper().get(roomPt);
+ if (dungeonRoom != null) {
+ if (dungeonRoom.getRoomProcessor() != null) {
+ dungeonRoom.getRoomProcessor().onInteract(interact);
+ }
+ }
+ } catch (Throwable t) {
+ t.printStackTrace();
+ }
+ }
+ } catch (Throwable e) {
+ e.printStackTrace();
+ }
+ }
@SubscribeEvent
public void onKeyInput(InputEvent.KeyInputEvent keyInputEvent) {
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/PacketListener.java b/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/PacketListener.java
index 3406f205..37e65385 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/PacketListener.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/PacketListener.java
@@ -6,10 +6,13 @@ import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelPromise;
import kr.syeyoung.dungeonsguide.SkyblockStatus;
import kr.syeyoung.dungeonsguide.e;
+import kr.syeyoung.dungeonsguide.events.PlayerInteractEntityEvent;
import kr.syeyoung.dungeonsguide.features.FeatureRegistry;
import net.minecraft.client.Minecraft;
import net.minecraft.network.Packet;
+import net.minecraft.network.play.client.C02PacketUseEntity;
import net.minecraft.network.play.server.S04PacketEntityEquipment;
+import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.network.FMLNetworkEvent;
@@ -35,6 +38,17 @@ public class PacketListener extends ChannelDuplexHandler {
@Override
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
+ Packet packet = (Packet) msg;
+ if (packet instanceof C02PacketUseEntity) {
+ C02PacketUseEntity packet2 = (C02PacketUseEntity) packet;
+ PlayerInteractEntityEvent piee;
+ if (packet2.getAction() == C02PacketUseEntity.Action.ATTACK)
+ piee = new PlayerInteractEntityEvent(true, packet2.getEntityFromWorld(Minecraft.getMinecraft().theWorld));
+ else
+ piee = new PlayerInteractEntityEvent(false, ((C02PacketUseEntity) packet).getEntityFromWorld(Minecraft.getMinecraft().theWorld));
+
+ if (MinecraftForge.EVENT_BUS.post(piee)) return;
+ }
super.write(ctx, msg, promise);
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/events/PlayerInteractEntityEvent.java b/src/main/java/kr/syeyoung/dungeonsguide/events/PlayerInteractEntityEvent.java
new file mode 100644
index 00000000..8e61b6a2
--- /dev/null
+++ b/src/main/java/kr/syeyoung/dungeonsguide/events/PlayerInteractEntityEvent.java
@@ -0,0 +1,21 @@
+package kr.syeyoung.dungeonsguide.events;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.Setter;
+import net.minecraft.entity.Entity;
+import net.minecraftforge.fml.common.eventhandler.Event;
+
+@AllArgsConstructor
+public class PlayerInteractEntityEvent extends Event {
+
+ @Getter @Setter
+ private boolean attack;
+ @Getter @Setter
+ private Entity entity;
+
+ @Override
+ public boolean isCancelable() {
+ return true;
+ }
+}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/GeneralRoomProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/GeneralRoomProcessor.java
index 07c5353a..6bef19eb 100755
--- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/GeneralRoomProcessor.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/GeneralRoomProcessor.java
@@ -6,6 +6,7 @@ import kr.syeyoung.dungeonsguide.dungeon.DungeonContext;
import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonMechanic;
import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom;
import kr.syeyoung.dungeonsguide.e;
+import kr.syeyoung.dungeonsguide.events.PlayerInteractEntityEvent;
import kr.syeyoung.dungeonsguide.features.FeatureRegistry;
import kr.syeyoung.dungeonsguide.roomedit.EditingContext;
import kr.syeyoung.dungeonsguide.roomedit.gui.GuiDungeonRoomEdit;
@@ -20,6 +21,8 @@ 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.EntityInteractEvent;
+import net.minecraftforge.fml.common.gameevent.InputEvent;
import java.awt.*;
import java.util.Map;
@@ -130,6 +133,16 @@ public class GeneralRoomProcessor implements RoomProcessor {
// }
}
+ @Override
+ public void onKeyPress(InputEvent.KeyInputEvent keyInputEvent) {
+
+ }
+
+ @Override
+ public void onInteract(PlayerInteractEntityEvent 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 aae86a48..fa2ed8f1 100755
--- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessor.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessor.java
@@ -1,9 +1,12 @@
package kr.syeyoung.dungeonsguide.roomprocessor;
import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom;
+import kr.syeyoung.dungeonsguide.events.PlayerInteractEntityEvent;
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.fml.common.gameevent.InputEvent;
public interface RoomProcessor {
void tick();
@@ -16,4 +19,8 @@ public interface RoomProcessor {
void onPostGuiRender(GuiScreenEvent.DrawScreenEvent.Post event);
void onEntitySpawn(LivingEvent.LivingUpdateEvent updateEvent);
+
+ void onKeyPress(InputEvent.KeyInputEvent keyInputEvent);
+
+ void onInteract(PlayerInteractEntityEvent 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 db47c0a9..6e18d441 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/RoomProcessorBombDefuseSolver.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/RoomProcessorBombDefuseSolver.java
@@ -3,6 +3,7 @@ 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.dungeon.data.OffsetPoint;
import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPointSet;
import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom;
import kr.syeyoung.dungeonsguide.e;
@@ -19,6 +20,7 @@ import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.number.Number
import kr.syeyoung.dungeonsguide.utils.TextUtils;
import lombok.AllArgsConstructor;
import lombok.Data;
+import lombok.Getter;
import net.minecraft.client.Minecraft;
import net.minecraft.nbt.CompressedStreamTools;
import net.minecraft.nbt.NBTTagCompound;
@@ -38,7 +40,9 @@ import java.util.List;
public class RoomProcessorBombDefuseSolver extends GeneralRoomProcessor {
+ @Getter
private List<ChamberSet> chambers = new ArrayList<ChamberSet>();
+ @Getter
private OffsetPointSet doors;
private static final List<BombDefuseChamberGenerator> chamberGenerators = new ArrayList<BombDefuseChamberGenerator>();
@@ -97,15 +101,15 @@ public class RoomProcessorBombDefuseSolver extends GeneralRoomProcessor {
for (BombDefuseChamberGenerator bdcg:chamberGenerators) {
if (bdcg.match(set.getLeft(), set.getRight())) {
set.setChamberGen(bdcg);
- set.getLeft().setProcessor(bdcg.createLeft(set.getLeft()));
- set.getRight().setProcessor(bdcg.createLeft(set.getRight()));
+ set.getLeft().setProcessor(bdcg.createLeft(set.getLeft(), this));
+ set.getRight().setProcessor(bdcg.createLeft(set.getRight(), this));
break;
}
}
if (set.getChamberGen() == null) {
set.setChamberGen(null);
- set.getLeft().setProcessor(new DummyDefuseChamberProcessor());
- set.getRight().setProcessor(new DummyDefuseChamberProcessor());
+ set.getLeft().setProcessor(new DummyDefuseChamberProcessor(this, set.getLeft()));
+ set.getRight().setProcessor(new DummyDefuseChamberProcessor(this, set.getRight()));
}
}
}
@@ -160,6 +164,21 @@ public class RoomProcessorBombDefuseSolver extends GeneralRoomProcessor {
@Override
public void tick() {
super.tick();
+ 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().tick();
+ }
+ }
+ if (ch.getRight() != null && ch.getRight().getProcessor() != null) {
+ if (!ch.getRight().getChamberBlocks().getOffsetPointList().contains(offsetPoint)) {
+ ch.getRight().getProcessor().tick();
+ }
+ }
+ }
}
@Override
@@ -167,12 +186,19 @@ public class RoomProcessorBombDefuseSolver extends GeneralRoomProcessor {
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.getLeft() != null && ch.getLeft().getProcessor() != null)
- ch.getLeft().getProcessor().drawScreen(partialTicks);
- if (ch.getRight() != null && ch.getRight().getProcessor() != null)
- ch.getRight().getProcessor().drawScreen(partialTicks);
+ if (ch.getLeft() != null && ch.getLeft().getProcessor() != null) {
+ if (!ch.getLeft().getChamberBlocks().getOffsetPointList().contains(offsetPoint)) {
+ ch.getLeft().getProcessor().drawScreen(partialTicks);
+ }
+ }
+ if (ch.getRight() != null && ch.getRight().getProcessor() != null) {
+ if (!ch.getRight().getChamberBlocks().getOffsetPointList().contains(offsetPoint)) {
+ ch.getRight().getProcessor().drawScreen(partialTicks);
+ }
+ }
}
}
@@ -181,11 +207,19 @@ public class RoomProcessorBombDefuseSolver extends GeneralRoomProcessor {
super.drawWorld(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.getLeft() != null && ch.getLeft().getProcessor() != null)
- ch.getLeft().getProcessor().drawWorld(partialTicks);
- if (ch.getRight() != null && ch.getRight().getProcessor() != null)
- ch.getRight().getProcessor().drawWorld(partialTicks);
+ if (ch.getLeft() != null && ch.getLeft().getProcessor() != null) {
+ 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)) {
+ ch.getRight().getProcessor().drawWorld(partialTicks);
+ }
+ }
}
}
@@ -207,11 +241,19 @@ public class RoomProcessorBombDefuseSolver extends GeneralRoomProcessor {
super.onPostGuiRender(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)
- ch.getLeft().getProcessor().onPostGuiRender(event);
- if (ch.getRight() != null && ch.getRight().getProcessor() != null)
- ch.getRight().getProcessor().onPostGuiRender(event);
+ if (ch.getLeft() != null && ch.getLeft().getProcessor() != null) {
+ 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)) {
+ ch.getRight().getProcessor().onPostGuiRender(event);
+ }
+ }
}
}
@@ -220,11 +262,19 @@ public class RoomProcessorBombDefuseSolver extends GeneralRoomProcessor {
super.onEntitySpawn(updateEvent);
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)
- ch.getLeft().getProcessor().onEntitySpawn(updateEvent);
- if (ch.getRight() != null && ch.getRight().getProcessor() != null)
- ch.getRight().getProcessor().onEntitySpawn(updateEvent);
+ if (ch.getLeft() != null && ch.getLeft().getProcessor() != null) {
+ 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)) {
+ ch.getRight().getProcessor().onEntitySpawn(updateEvent);
+ }
+ }
}
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/BDChamber.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/BDChamber.java
index 06e2e707..9b69b586 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/BDChamber.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/BDChamber.java
@@ -1,12 +1,18 @@
package kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers;
+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 lombok.AllArgsConstructor;
import lombok.Data;
import net.minecraft.block.state.IBlockState;
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.item.EntityArmorStand;
import net.minecraft.util.BlockPos;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.List;
@AllArgsConstructor
@Data
@@ -35,9 +41,25 @@ public class BDChamber {
}
public boolean isWithinAbsolute(int x, int y, int z) {
- return isWithinAbsolute(new BlockPos(x,y,z));
+ return isWithinAbsolute(new BlockPos(x,68,z));
}
public boolean isWithinAbsolute(BlockPos pos) {
- return chamberBlocks.getOffsetPointList().contains(new OffsetPoint(room, pos));
+ return chamberBlocks.getOffsetPointList().contains(new OffsetPoint(room, new BlockPos(pos.getX(), 68, pos.getZ())));
+ }
+
+
+ public <T extends Entity> T getEntityAt(Class<T> entity, int x, int y, int z) {
+ final BlockPos pos = getBlockPos(x,y,z);
+ return getEntityAt(entity, pos);
+ }
+ public <T extends Entity> T getEntityAt(Class<T> entity, final BlockPos pos) {
+ List<T> entities = room.getContext().getWorld().getEntities(entity, new Predicate<T>() {
+ @Override
+ public boolean apply(@Nullable T input) {
+ return input.getPosition().equals(pos);
+ }
+ });
+ if (entities.size() == 0) return null;
+ return entities.get(0);
}
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/BombDefuseChamberGenerator.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/BombDefuseChamberGenerator.java
index 92b294ac..ff33e4ad 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/BombDefuseChamberGenerator.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/BombDefuseChamberGenerator.java
@@ -1,10 +1,12 @@
package kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers;
+import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.RoomProcessorBombDefuseSolver;
+
public interface BombDefuseChamberGenerator {
public boolean match(BDChamber left, BDChamber right);
public String getName();
- public ChamberProcessor createLeft(BDChamber left);
- public ChamberProcessor createRight(BDChamber right);
+ public ChamberProcessor createLeft(BDChamber left, RoomProcessorBombDefuseSolver solver);
+ public ChamberProcessor createRight(BDChamber right, RoomProcessorBombDefuseSolver solver);
} \ No newline at end of file
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/DummyDefuseChamberProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/DummyDefuseChamberProcessor.java
index 313f79b4..bd306cdd 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/DummyDefuseChamberProcessor.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/DummyDefuseChamberProcessor.java
@@ -1,8 +1,13 @@
package kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers;
import kr.syeyoung.dungeonsguide.roomprocessor.GeneralRoomProcessor;
+import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.RoomProcessorBombDefuseSolver;
public class DummyDefuseChamberProcessor extends GeneralDefuseChamberProcessor {
+ public DummyDefuseChamberProcessor(RoomProcessorBombDefuseSolver solver, BDChamber chamber) {
+ super(solver, chamber);
+ }
+
@Override
public String getName() {
return "dummy";
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 85314d75..92aaed64 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
@@ -1,11 +1,32 @@
package kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers;
+import kr.syeyoung.dungeonsguide.Keybinds;
+import kr.syeyoung.dungeonsguide.events.PlayerInteractEntityEvent;
+import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.RoomProcessorBombDefuseSolver;
+import lombok.Getter;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.FontRenderer;
+import net.minecraft.client.gui.ScaledResolution;
+import net.minecraft.entity.item.EntityArmorStand;
import net.minecraft.nbt.NBTTagCompound;
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.fml.common.gameevent.InputEvent;
+import org.lwjgl.input.Keyboard;
+@Getter
public abstract class GeneralDefuseChamberProcessor implements ChamberProcessor{
+ private RoomProcessorBombDefuseSolver solver;
+ private BDChamber chamber;
+
+ public GeneralDefuseChamberProcessor(RoomProcessorBombDefuseSolver solver, BDChamber chamber) {
+ this.solver = solver;
+ this.chamber = chamber;
+ }
+
+
@Override
public void onDataRecieve(NBTTagCompound compound) {
@@ -50,4 +71,28 @@ public abstract class GeneralDefuseChamberProcessor implements ChamberProcessor
public void onEntitySpawn(LivingEvent.LivingUpdateEvent updateEvent) {
}
+
+ protected void drawPressKey() {
+ FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
+ ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft());
+ String str = "Press "+ Keyboard.getKeyName(Keybinds.sendBombdefuse.getKeyCode()) + " to save and send solution";
+ fr.drawString(str, (sr.getScaledWidth() - fr.getStringWidth(str)) / 2, (sr.getScaledHeight() - fr.FONT_HEIGHT) / 2, 0xFFFFFFFF);
+ }
+
+ @Override
+ public void onKeyPress(InputEvent.KeyInputEvent keyInputEvent) {
+ if (Keybinds.sendBombdefuse.isKeyDown()) {
+ if (!getChamber().isWithinAbsolute(Minecraft.getMinecraft().thePlayer.getPosition())) {
+ return;
+ }
+ onSendData();
+ }
+ }
+
+ @Override
+ public void onInteract(PlayerInteractEntityEvent event) {
+
+ }
+
+ public void onSendData() {}
}
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 29c4d9e9..e4f64917 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
@@ -1,5 +1,6 @@
package kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.arrow;
+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;
@@ -22,12 +23,12 @@ public class ArrowProcessorMatcher implements BombDefuseChamberGenerator {
}
@Override
- public ChamberProcessor createLeft(BDChamber left) {
+ public ChamberProcessor createLeft(BDChamber left, RoomProcessorBombDefuseSolver solver) {
return null;
}
@Override
- public ChamberProcessor createRight(BDChamber right) {
+ public ChamberProcessor createRight(BDChamber right, RoomProcessorBombDefuseSolver solver) {
return null;
}
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/color/ColorProcessorMatcher.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/color/ColorProcessorMatcher.java
index 3d526eee..e4f8306d 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/color/ColorProcessorMatcher.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/color/ColorProcessorMatcher.java
@@ -1,5 +1,6 @@
package kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.color;
+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;
@@ -20,14 +21,13 @@ public class ColorProcessorMatcher implements BombDefuseChamberGenerator {
public String getName() {
return "colorMatch";
}
-
@Override
- public ChamberProcessor createLeft(BDChamber left) {
+ public ChamberProcessor createLeft(BDChamber left, RoomProcessorBombDefuseSolver solver) {
return null;
}
@Override
- public ChamberProcessor createRight(BDChamber right) {
+ public ChamberProcessor createRight(BDChamber right, RoomProcessorBombDefuseSolver solver) {
return null;
}
}
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 c15f7e41..6163272b 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
@@ -1,5 +1,6 @@
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.BombDefuseChamberGenerator;
import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.ChamberProcessor;
@@ -21,14 +22,13 @@ public class CreeperProcessorMatcher implements BombDefuseChamberGenerator {
public String getName() {
return "creeperMatch";
}
-
@Override
- public ChamberProcessor createLeft(BDChamber left) {
+ public ChamberProcessor createLeft(BDChamber left, RoomProcessorBombDefuseSolver solver) {
return null;
}
@Override
- public ChamberProcessor createRight(BDChamber right) {
+ public ChamberProcessor createRight(BDChamber right, RoomProcessorBombDefuseSolver solver) {
return null;
}
}
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
new file mode 100644
index 00000000..d580e525
--- /dev/null
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/number/NumberLeftProcessor.java
@@ -0,0 +1,113 @@
+package kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.number;
+
+import com.google.common.collect.BiMap;
+import com.google.common.collect.HashBiMap;
+import kr.syeyoung.dungeonsguide.Keybinds;
+import kr.syeyoung.dungeonsguide.features.FeatureRegistry;
+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.client.Minecraft;
+import net.minecraft.client.gui.FontRenderer;
+import net.minecraft.client.gui.ScaledResolution;
+import net.minecraft.entity.item.EntityArmorStand;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.nbt.NBTTagList;
+import net.minecraft.nbt.NBTTagString;
+import net.minecraft.util.BlockPos;
+import org.lwjgl.input.Keyboard;
+
+public class NumberLeftProcessor extends GeneralDefuseChamberProcessor {
+ public NumberLeftProcessor(RoomProcessorBombDefuseSolver solver, BDChamber chamber) {
+ super(solver, chamber);
+
+ d1p = chamber.getBlockPos(1,1,4);
+ d2p = chamber.getBlockPos(2,1,4);
+ d3p = chamber.getBlockPos(6,1,4);
+ d4p = chamber.getBlockPos(7,1,4);
+ }
+
+ @Override
+ public String getName() {
+ return "numberLeft";
+ }
+
+
+ private int answer = -1, d1, d2, d3 ,d4;
+ private BlockPos d1p, d2p, d3p, d4p;
+ @Override
+ 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));
+ if (d1 == -1 || d2 == -1 || d3 == -1 || d4 == -1) return;
+
+ answer = d1 * 1000 + d2 * 100 + d3 * 10 + d4;
+ }
+
+ @Override
+ public void drawScreen(float partialTicks) {
+ if (answer == -1) return;
+ drawPressKey();
+ }
+
+ @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);
+
+ }
+
+ @Override
+ 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);
+ 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;
+ }
+ }
+
+ 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);
+ }
+
+ private static final BiMap<String, Integer> integers = HashBiMap.create(10);
+ {
+ integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMzFhOTQ2M2ZkM2M0MzNkNWUxZDlmZWM2ZDVkNGIwOWE4M2E5NzBiMGI3NGRkNTQ2Y2U2N2E3MzM0OGNhYWIifX19", 1);
+ integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYWNiNDE5ZDk4NGQ4Nzk2MzczYzk2NDYyMzNjN2EwMjY2NGJkMmNlM2ExZDM0NzZkZDliMWM1NDYzYjE0ZWJlIn19fQ==", 2);
+ integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjhlYmFiNTdiNzYxNGJiMjJhMTE3YmU0M2U4NDhiY2QxNGRhZWNiNTBlOGY1ZDA5MjZlNDg2NGRmZjQ3MCJ9fX0=", 3);
+ integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNjJiZmNmYjQ4OWRhODY3ZGNlOTZlM2MzYzE3YTNkYjdjNzljYWU4YWMxZjlhNWE4YzhhYzk1ZTRiYTMifX19", 4);
+ integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZWY0ZWNmMTEwYjBhY2VlNGFmMWRhMzQzZmIxMzZmMWYyYzIxNjg1N2RmZGE2OTYxZGVmZGJlZTdiOTUyOCJ9fX0=", 5);
+ integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjMzMWE2YTZmY2Q2OTk1YjYyMDg4ZDM1M2JmYjY4ZDliODlhZTI1ODMyNWNhZjNmMjg4NjQ2NGY1NGE3MzI5In19fQ==", 6);
+ integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDRiYTZhYzA3ZDQyMjM3N2E4NTU3OTNmMzZkZWEyZWQyNDAyMjNmNTJmZDE2NDgxODE2MTJlY2QxYTBjZmQ1In19fQ==", 7);
+ integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzYxYThhNjQxNDM3YmU5YWVhMjA3MjUzZGQzZjI1NDQwZDk1NGVhMmI1ODY2YzU1MmYzODZiMjlhYzRkMDQ5In19fQ==", 8);
+ integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYTE5MjhlMWJmZDg2YTliNzkzOTdjNGNiNGI2NWVmOTlhZjQ5YjdkNWY3OTU3YWQ2MmMwYzY5OWE2MjJjZmJlIn19fQ==", 9);
+ integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNTVhMjI0ODA3NjkzOTc4ZWQ4MzQzNTVmOWU1MTQ1ZjljNTZlZjY4Y2Y2ZjJjOWUxNzM0YTQ2ZTI0NmFhZTEifX19", 0);
+ }
+}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/number/NumberProcessorMatcher.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/number/NumberProcessorMatcher.java
index 7faa29fb..daf891d8 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/number/NumberProcessorMatcher.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/number/NumberProcessorMatcher.java
@@ -1,5 +1,6 @@
package kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.number;
+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;
@@ -22,14 +23,13 @@ public class NumberProcessorMatcher implements BombDefuseChamberGenerator {
public String getName() {
return "numberMatch";
}
-
@Override
- public ChamberProcessor createLeft(BDChamber left) {
- return null;
+ public ChamberProcessor createLeft(BDChamber left, RoomProcessorBombDefuseSolver solver) {
+ return new NumberLeftProcessor(solver, left);
}
@Override
- public ChamberProcessor createRight(BDChamber right) {
- return null;
+ public ChamberProcessor createRight(BDChamber right, RoomProcessorBombDefuseSolver solver) {
+ return new NumberRightProcessor(solver, right);
}
}
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
new file mode 100644
index 00000000..0882d4ad
--- /dev/null
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/number/NumberRightProcessor.java
@@ -0,0 +1,105 @@
+package kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.number;
+
+import com.google.common.collect.BiMap;
+import com.google.common.collect.HashBiMap;
+import kr.syeyoung.dungeonsguide.events.PlayerInteractEntityEvent;
+import kr.syeyoung.dungeonsguide.features.FeatureRegistry;
+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.nbt.NBTTagString;
+import net.minecraft.util.BlockPos;
+
+public class NumberRightProcessor extends GeneralDefuseChamberProcessor {
+ public NumberRightProcessor(RoomProcessorBombDefuseSolver solver, BDChamber chamber) {
+ super(solver, chamber);
+
+ d1p = chamber.getBlockPos(1,1,4);
+ d2p = chamber.getBlockPos(2,1,4);
+ d3p = chamber.getBlockPos(6,1,4);
+ d4p = chamber.getBlockPos(7,1,4);
+ center = chamber.getBlockPos(4,4,4);
+ }
+
+ @Override
+ public String getName() {
+ return "numberRight";
+ }
+
+
+ private int answer = -1, d1, d2, d3 ,d4, a1, a2, a3, a4;
+ private BlockPos d1p, d2p, d3p, d4p, center;
+ @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));
+ }
+
+ @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);
+ }
+
+ @Override
+ public void onInteract(PlayerInteractEntityEvent event) {
+ if (answer == -1) return;
+ if (event.getEntity() instanceof EntityArmorStand) {
+ BlockPos pos = event.getEntity().getPosition();
+ if (a1 == d1 && pos.equals(d1p)) event.setCanceled(true);
+ 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);
+ }
+ }
+
+ @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;
+ }
+ }
+
+ 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);
+ }
+
+ private static final BiMap<String, Integer> integers = HashBiMap.create(10);
+ {
+ integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNzFiYzJiY2ZiMmJkMzc1OWU2YjFlODZmYzdhNzk1ODVlMTEyN2RkMzU3ZmMyMDI4OTNmOWRlMjQxYmM5ZTUzMCJ9fX0=", 1);
+ integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNGNkOWVlZWU4ODM0Njg4ODFkODM4NDhhNDZiZjMwMTI0ODVjMjNmNzU3NTNiOGZiZTg0ODczNDE0MTk4NDcifX19", 2);
+ integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMWQ0ZWFlMTM5MzM4NjBhNmRmNWU4ZTk1NTY5M2I5NWE4YzNiMTVjMzZiOGI1ODc1MzJhYzA5OTZiYzM3ZTUifX19", 3);
+ integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDJlNzhmYjIyNDI0MjMyZGMyN2I4MWZiY2I0N2ZkMjRjMWFjZjc2MDk4NzUzZjJkOWMyODU5ODI4N2RiNSJ9fX0=", 4);
+ integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNmQ1N2UzYmM4OGE2NTczMGUzMWExNGUzZjQxZTAzOGE1ZWNmMDg5MWE2YzI0MzY0M2I4ZTU0NzZhZTIifX19", 5);
+ integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMzM0YjM2ZGU3ZDY3OWI4YmJjNzI1NDk5YWRhZWYyNGRjNTE4ZjVhZTIzZTcxNjk4MWUxZGNjNmIyNzIwYWIifX19", 6);
+ integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNmRiNmViMjVkMWZhYWJlMzBjZjQ0NGRjNjMzYjU4MzI0NzVlMzgwOTZiN2UyNDAyYTNlYzQ3NmRkN2I5In19fQ==", 7);
+ integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNTkxOTQ5NzNhM2YxN2JkYTk5NzhlZDYyNzMzODM5OTcyMjI3NzRiNDU0Mzg2YzgzMTljMDRmMWY0Zjc0YzJiNSJ9fX0=", 8);
+ integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZTY3Y2FmNzU5MWIzOGUxMjVhODAxN2Q1OGNmYzY0MzNiZmFmODRjZDQ5OWQ3OTRmNDFkMTBiZmYyZTViODQwIn19fQ==", 9);
+ integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMGViZTdlNTIxNTE2OWE2OTlhY2M2Y2VmYTdiNzNmZGIxMDhkYjg3YmI2ZGFlMjg0OWZiZTI0NzE0YjI3In19fQ==", 0);
+ }
+}
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 f7fa009b..608b1e2d 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bossfight/GeneralBossfightProcessor.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bossfight/GeneralBossfightProcessor.java
@@ -1,5 +1,6 @@
package kr.syeyoung.dungeonsguide.roomprocessor.bossfight;
+import kr.syeyoung.dungeonsguide.events.PlayerInteractEntityEvent;
import lombok.*;
import net.minecraft.entity.boss.BossStatus;
import net.minecraft.entity.boss.EntityDragon;
@@ -7,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.fml.common.gameevent.InputEvent;
import java.util.*;
@@ -87,6 +89,16 @@ public abstract class GeneralBossfightProcessor implements BossfightProcessor {
}
+ @Override
+ public void onInteract(PlayerInteractEntityEvent event) {
+
+ }
+
+ @Override
+ public void onKeyPress(InputEvent.KeyInputEvent keyInputEvent) {
+
+ }
+
public void onPhaseChange() {}
@Data