aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/kr
diff options
context:
space:
mode:
authorsyeyoung <cyong06@naver.com>2021-07-25 22:27:22 +0900
committersyeyoung <cyong06@naver.com>2021-07-25 22:28:49 +0900
commit932399472cb653f5a8fdc1095fa941656a729650 (patch)
tree6049fdf96de7b2967c56d1d6ea62a6c473845c0a /src/main/java/kr
parenta6b8e47c879ce5a1c69d0552cdb26a3b3e95e4b6 (diff)
downloadSkyblock-Dungeons-Guide-932399472cb653f5a8fdc1095fa941656a729650.tar.gz
Skyblock-Dungeons-Guide-932399472cb653f5a8fdc1095fa941656a729650.tar.bz2
Skyblock-Dungeons-Guide-932399472cb653f5a8fdc1095fa941656a729650.zip
Creating Fake Dungeons.
Diffstat (limited to 'src/main/java/kr')
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/SkyblockStatus.java10
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/commands/CommandDungeonsGuide.java93
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/dungeon/MapProcessor.java6
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/dungeon/doorfinder/DungeonSpecificDataProviderRegistry.java2
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/RoomMatcher.java30
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/eventlistener/DungeonListener.java4
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonRoomEdit.java2
7 files changed, 132 insertions, 15 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/SkyblockStatus.java b/src/main/java/kr/syeyoung/dungeonsguide/SkyblockStatus.java
index bb4f2f40..a58bfb26 100755
--- a/src/main/java/kr/syeyoung/dungeonsguide/SkyblockStatus.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/SkyblockStatus.java
@@ -46,9 +46,15 @@ import java.util.regex.Pattern;
public class SkyblockStatus {
@Getter
private boolean isOnSkyblock;
- @Getter
private boolean isOnDungeon;
+ public boolean isOnDungeon() {
+ return forceIsOnDungeon || isOnDungeon;
+ }
+
+ @Getter @Setter
+ private boolean forceIsOnDungeon;
+
@Getter
@Setter
private DungeonContext context;
@@ -57,7 +63,7 @@ public class SkyblockStatus {
@Setter
private int percentage;
- @Getter
+ @Getter @Setter
private String dungeonName;
public boolean isOnHypixel() {
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandDungeonsGuide.java b/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandDungeonsGuide.java
index a5991e0f..28bc50bc 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandDungeonsGuide.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandDungeonsGuide.java
@@ -20,12 +20,17 @@ package kr.syeyoung.dungeonsguide.commands;
import com.google.gson.JsonObject;
import kr.syeyoung.dungeonsguide.DungeonsGuide;
+import kr.syeyoung.dungeonsguide.SkyblockStatus;
import kr.syeyoung.dungeonsguide.config.guiconfig.nyu.GuiConfigV2;
import kr.syeyoung.dungeonsguide.config.guiconfig.old.GuiConfig;
import kr.syeyoung.dungeonsguide.cosmetics.CosmeticsManager;
import kr.syeyoung.dungeonsguide.dungeon.DungeonContext;
+import kr.syeyoung.dungeonsguide.dungeon.MapProcessor;
import kr.syeyoung.dungeonsguide.dungeon.data.DungeonRoomInfo;
import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint;
+import kr.syeyoung.dungeonsguide.dungeon.doorfinder.CatacombMasterDataProvider;
+import kr.syeyoung.dungeonsguide.dungeon.doorfinder.DungeonSpecificDataProvider;
+import kr.syeyoung.dungeonsguide.dungeon.doorfinder.DungeonSpecificDataProviderRegistry;
import kr.syeyoung.dungeonsguide.dungeon.events.DungeonEventHolder;
import kr.syeyoung.dungeonsguide.dungeon.mechanics.*;
import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom;
@@ -35,33 +40,50 @@ import kr.syeyoung.dungeonsguide.features.FeatureRegistry;
import kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.FeatureViewPlayerOnJoin;
import kr.syeyoung.dungeonsguide.features.impl.party.api.ApiFetchur;
import kr.syeyoung.dungeonsguide.party.PartyManager;
+import kr.syeyoung.dungeonsguide.roomedit.EditingContext;
+import kr.syeyoung.dungeonsguide.roomedit.gui.GuiDungeonRoomEdit;
import kr.syeyoung.dungeonsguide.roomprocessor.GeneralRoomProcessor;
+import kr.syeyoung.dungeonsguide.roomprocessor.bossfight.BossfightProcessor;
import kr.syeyoung.dungeonsguide.stomp.*;
import kr.syeyoung.dungeonsguide.utils.AhUtils;
import kr.syeyoung.dungeonsguide.utils.MapUtils;
+import kr.syeyoung.dungeonsguide.utils.ShortUtils;
import kr.syeyoung.dungeonsguide.wsresource.StaticResourceCache;
+import net.minecraft.block.Block;
+import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;
+import net.minecraft.nbt.CompressedStreamTools;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.server.MinecraftServer;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.BlockPos;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.ChatStyle;
+import net.minecraft.world.World;
+import net.minecraft.world.chunk.Chunk;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
import org.json.JSONObject;
+import sun.misc.Unsafe;
import javax.crypto.BadPaddingException;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
+import javax.vecmath.Vector2d;
import java.awt.*;
import java.io.*;
import java.security.*;
import java.security.cert.CertificateException;
import java.text.SimpleDateFormat;
+import java.util.Arrays;
import java.util.Date;
import java.util.Map;
import java.util.UUID;
+import java.util.regex.Pattern;
public class CommandDungeonsGuide extends CommandBase {
@Override
@@ -397,6 +419,77 @@ public class CommandDungeonsGuide extends CommandBase {
StaticResourceCache.INSTANCE.getResource(uid).thenAccept(a -> {
sender.addChatMessage(new ChatComponentText(a.getResourceID()+": "+a.getValue()+": "+a.isExists()));
});
+ } else if (args[0].equals("createFakeRoom")&& Minecraft.getMinecraft().getSession().getPlayerID().replace("-", "").equals("e686fe0aab804a71ac7011dc8c2b534c")) {
+
+ // load schematic
+ File f=new File(DungeonsGuide.getDungeonsGuide().getConfigDir(), "schematics/Pillars-9fa09d68-c483-4320-872e-9e07b049ee37-a92c0ec6-e125-451a-8518-56e68d9cb463.schematic");
+ NBTTagCompound compound;
+ try {
+ compound = CompressedStreamTools.readCompressed(new FileInputStream(f));
+ } catch (IOException e) {
+ e.printStackTrace();
+ return;
+ }
+
+ byte[] blocks = compound.getByteArray("Blocks");
+ byte[] meta = compound.getByteArray("Data");
+ for (int x = 0; x < compound.getShort("Width"); x++) {
+ for (int y = 0; y < compound.getShort("Height"); y++) {
+ for (int z = 0; z < compound.getShort("Length"); z++) {
+ int index = x + (y * compound.getShort("Length") + z) * compound.getShort("Width");
+ BlockPos pos = new BlockPos(x,y,z);
+ World w = MinecraftServer.getServer().getEntityWorld();
+ w.setBlockState(pos, Block.getBlockById(blocks[index] & 0xFF).getStateFromMeta(meta[index] & 0xFF), 2);
+ }
+ }
+ }
+
+
+ DungeonSpecificDataProviderRegistry.doorFinders.put(Pattern.compile("TEST DG"), new DungeonSpecificDataProvider() {
+ @Override
+ public BlockPos findDoor(World w, String dungeonName) {
+ return new BlockPos(0,0,0);
+ }
+
+ @Override
+ public Vector2d findDoorOffset(World w, String dungeonName) {
+ return null;
+ }
+
+ @Override
+ public BossfightProcessor createBossfightProcessor(World w, String dungeonName) {
+ return null;
+ }
+
+ @Override
+ public boolean isTrapSpawn(String dungeonName) {
+ return false;
+ }
+ });
+ SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus();
+ skyblockStatus.setDungeonName("TEST DG");
+ DungeonContext fakeContext = new DungeonContext(Minecraft.getMinecraft().theWorld);
+ skyblockStatus.setContext(fakeContext);
+ skyblockStatus.setForceIsOnDungeon(true);
+ MapProcessor mapProcessor = fakeContext.getMapProcessor();
+ mapProcessor.setUnitRoomDimension(new Dimension(16,16));
+ mapProcessor.setBugged(false);
+ mapProcessor.setDoorDimension(new Dimension(4,4));
+ mapProcessor.setTopLeftMapPoint(new Point(0,0));
+ fakeContext.setDungeonMin(new BlockPos(0,70,0));
+
+ DungeonRoom dungeonRoom = new DungeonRoom(Arrays.asList(new Point(0,0)), ShortUtils.topLeftifyInt((short) 1), (byte) 63, new BlockPos(0,70,0), new BlockPos(31,70,31), fakeContext);
+
+ fakeContext.getDungeonRoomList().add(dungeonRoom);
+ for (Point p:Arrays.asList(new Point(0,0))) {
+ fakeContext.getRoomMapper().put(p, dungeonRoom);
+ }
+
+ EditingContext.createEditingContext(dungeonRoom);
+ EditingContext.getEditingContext().openGui(new GuiDungeonRoomEdit(dungeonRoom));
+ } else if (args[0].equals("CloseContext")) {
+ DungeonsGuide.getDungeonsGuide().getSkyblockStatus().setForceIsOnDungeon(false);
+ DungeonsGuide.getDungeonsGuide().getSkyblockStatus().setContext(null);
} else {
sender.addChatMessage(new ChatComponentText("§eDungeons Guide §7:: §e/dg §7-§fOpens configuration gui"));
sender.addChatMessage(new ChatComponentText("§eDungeons Guide §7:: §e/dg gui §7-§fOpens configuration gui"));
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/MapProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/MapProcessor.java
index a86a5326..3bea78f8 100755
--- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/MapProcessor.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/MapProcessor.java
@@ -60,11 +60,11 @@ public class MapProcessor {
@Getter
private final BiMap<String, String> mapIconToPlayerMap = HashBiMap.create();
- @Getter
+ @Getter @Setter
private Dimension unitRoomDimension;
- @Getter
+ @Getter @Setter
private Dimension doorDimension; // width: width of door, height: gap between rooms
- @Getter
+ @Getter @Setter
private Point topLeftMapPoint;
@Setter
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/doorfinder/DungeonSpecificDataProviderRegistry.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/doorfinder/DungeonSpecificDataProviderRegistry.java
index a92d7a03..6ee6f9ee 100755
--- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/doorfinder/DungeonSpecificDataProviderRegistry.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/doorfinder/DungeonSpecificDataProviderRegistry.java
@@ -23,7 +23,7 @@ import java.util.Map;
import java.util.regex.Pattern;
public class DungeonSpecificDataProviderRegistry {
- private static final Map<Pattern, DungeonSpecificDataProvider> doorFinders = new HashMap<Pattern, DungeonSpecificDataProvider>();
+ public static final Map<Pattern, DungeonSpecificDataProvider> doorFinders = new HashMap<Pattern, DungeonSpecificDataProvider>();
static {
doorFinders.put(Pattern.compile("The Catacombs (?:F[0-9]|E0)"), new CatacombDataProvider());
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/RoomMatcher.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/RoomMatcher.java
index d7bc1c64..9c20bdf9 100755
--- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/RoomMatcher.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/RoomMatcher.java
@@ -67,24 +67,36 @@ public class RoomMatcher {
shape = ShortUtils.topLeftifyInt(shape);
List<DungeonRoomInfo> roomInfoList = DungeonRoomInfoRegistry.getByShape(shape);
+ int lowestcost = Integer.MAX_VALUE;
+ DungeonRoomInfo bestMatch = null;
for (DungeonRoomInfo roomInfo : roomInfoList) {
- if (tryMatching(roomInfo, rotation)) {
- match = roomInfo;
- this.rotation = rotation;
- return match;
+ int cost = tryMatching(roomInfo, rotation);
+// if () {
+// match = roomInfo;
+// this.rotation = rotation;
+// return match;
+// }
+ if (cost < lowestcost) {
+ lowestcost = cost;
+ bestMatch = roomInfo;
+ if (cost == 0) break;
}
}
+ match = bestMatch;
+ this.rotation = rotation;
+ return bestMatch;
}
return null;
}
- private boolean tryMatching(DungeonRoomInfo dungeonRoomInfo, int rotation) {
- if (dungeonRoomInfo.getColor() != dungeonRoom.getColor()) return false;
+ private int tryMatching(DungeonRoomInfo dungeonRoomInfo, int rotation) {
+ if (dungeonRoomInfo.getColor() != dungeonRoom.getColor()) return Integer.MAX_VALUE;
int[][] res = dungeonRoomInfo.getBlocks();
for (int i = 0; i < rotation; i++)
res = ArrayUtils.rotateCounterClockwise(res);
+ int wrongs = 0;
for (int z = 0; z < res.length; z ++) {
for (int x = 0; x < res[0].length; x++) {
int data = res[z][x];
@@ -92,11 +104,13 @@ public class RoomMatcher {
Block b = dungeonRoom.getRelativeBlockAt(x,0,z);
if (b == null || Block.getIdFromBlock(b) != data) {
- return false;
+ wrongs++;
+
+ if (wrongs > 10) return wrongs;
}
}
}
- return true;
+ return wrongs;
}
private static final int offset = 3;
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/DungeonListener.java b/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/DungeonListener.java
index d08a46a9..bbf28adc 100755
--- a/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/DungeonListener.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/DungeonListener.java
@@ -66,6 +66,8 @@ import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.InputEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
+import net.minecraftforge.fml.relauncher.Side;
+import net.minecraftforge.fml.relauncher.SideOnly;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL14;
@@ -138,6 +140,7 @@ public class DungeonListener {
@SubscribeEvent
public void onTick(TickEvent.ClientTickEvent ev) throws Throwable {
try {
+ if (ev.side == Side.SERVER) return;
if (ev.phase == TickEvent.Phase.START) {
@@ -486,6 +489,7 @@ public class DungeonListener {
@SubscribeEvent
public void onInteract(PlayerInteractEvent keyInputEvent) {
try {
+ if (!keyInputEvent.world.isRemote) return;
SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus();
if (!skyblockStatus.isOnDungeon()) return;
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonRoomEdit.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonRoomEdit.java
index fee71b54..18c05ae5 100755
--- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonRoomEdit.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonRoomEdit.java
@@ -70,6 +70,6 @@ public class GuiDungeonRoomEdit extends MGui {
public void initGui() {
super.initGui();
// update bounds
- getMainPanel().setBounds(new Rectangle(10, Math.min((Minecraft.getMinecraft().displayHeight - 300) / 2, Minecraft.getMinecraft().displayHeight),200,300));
+ getMainPanel().setBounds(new Rectangle(Math.min((Minecraft.getMinecraft().displayWidth - 500) / 2, Minecraft.getMinecraft().displayWidth), Math.min((Minecraft.getMinecraft().displayHeight - 300) / 2, Minecraft.getMinecraft().displayHeight),500,300));
}
}