1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
|
package kr.syeyoung.dungeonsguide.dungeon;
import kr.syeyoung.dungeonsguide.SkyblockStatus;
import kr.syeyoung.dungeonsguide.dungeon.doorfinder.DungeonSpecificDataProvider;
import kr.syeyoung.dungeonsguide.dungeon.doorfinder.DungeonSpecificDataProviderRegistry;
import kr.syeyoung.dungeonsguide.dungeon.events.*;
import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom;
import kr.syeyoung.dungeonsguide.e;
import kr.syeyoung.dungeonsguide.events.BossroomEnterEvent;
import kr.syeyoung.dungeonsguide.features.FeatureRegistry;
import kr.syeyoung.dungeonsguide.features.impl.dungeon.FeatureDungeonMap;
import kr.syeyoung.dungeonsguide.roomprocessor.RoomProcessor;
import kr.syeyoung.dungeonsguide.roomprocessor.bossfight.BossfightProcessor;
import kr.syeyoung.dungeonsguide.utils.TextUtils;
import lombok.Getter;
import lombok.Setter;
import net.minecraft.client.Minecraft;
import net.minecraft.client.network.NetworkPlayerInfo;
import net.minecraft.scoreboard.ScorePlayerTeam;
import net.minecraft.util.BlockPos;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.IChatComponent;
import net.minecraft.world.World;
import net.minecraftforge.client.event.ClientChatReceivedEvent;
import net.minecraftforge.common.MinecraftForge;
import java.awt.*;
import java.util.*;
import java.util.List;
public class DungeonContext {
@Getter
private World world;
@Getter
private MapProcessor mapProcessor;
@Getter
@Setter
private BlockPos dungeonMin;
@Getter
private Map<Point, DungeonRoom> roomMapper = new HashMap<Point, DungeonRoom>();
@Getter
private List<DungeonRoom> dungeonRoomList = new ArrayList<DungeonRoom>();
@Getter
private List<RoomProcessor> globalRoomProcessors = new ArrayList<RoomProcessor>();
@Getter
private Map<String, Integer> deaths = new HashMap<String, Integer>();
@Getter
private List<String[]> milestoneReached = new ArrayList<String[]>();
@Getter
@Setter
private int BossRoomEnterSeconds = -1;
@Getter
@Setter
private BlockPos bossroomSpawnPos = null;
@Getter
@Setter
private boolean trapRoomGen = false;
@Getter
private boolean gotMimic = false;
private int latestSecretCnt = 0;
private int latestTotalSecret = 0;
private int latestCrypts = 0;
public void setGotMimic(boolean gotMimic) {
this.gotMimic = gotMimic;
createEvent(new DungeonNodataEvent("MIMIC_KILLED"));
}
@Getter
@Setter
private BossfightProcessor bossfightProcessor;
@Getter
private Set<String> players = new HashSet<String>();
private List<DungeonEvent> events = new ArrayList<DungeonEvent>();
public DungeonContext(World world) {
this.world = world;
createEvent(new DungeonNodataEvent("DUNGEON_CONTEXT_CREATION"));
mapProcessor = new MapProcessor(this);
DungeonSpecificDataProvider doorFinder = DungeonSpecificDataProviderRegistry.getDoorFinder(((SkyblockStatus) e.getDungeonsGuide().getSkyblockStatus()).getDungeonName());
trapRoomGen = doorFinder.isTrapSpawn(e.getDungeonsGuide().getSkyblockStatus().getDungeonName());
}
public void createEvent(DungeonEventData eventData) {
events.add(new DungeonEvent(eventData));
}
private final Rectangle roomBoundary = new Rectangle(0,0,128,128);
public void tick() {
mapProcessor.tick();
if (mapProcessor.isInitialized() && BossRoomEnterSeconds == -1 && !roomBoundary.contains(mapProcessor.worldPointToMapPoint(Minecraft.getMinecraft().thePlayer.getPositionVector()))) {
BossRoomEnterSeconds = FeatureRegistry.DUNGEON_SBTIME.getTimeElapsed() / 1000;
bossroomSpawnPos = Minecraft.getMinecraft().thePlayer.getPosition();
MinecraftForge.EVENT_BUS.post(new BossroomEnterEvent());
createEvent(new DungeonNodataEvent("BOSSROOM_ENTER"));
DungeonSpecificDataProvider doorFinder = DungeonSpecificDataProviderRegistry.getDoorFinder(((SkyblockStatus) e.getDungeonsGuide().getSkyblockStatus()).getDungeonName());
if (doorFinder != null) {
bossfightProcessor = doorFinder.createBossfightProcessor(world, e.getDungeonsGuide().getSkyblockStatus().getDungeonName());
} else {
e.sendDebugChat(new ChatComponentText("Error:: Null Data Providier"));
}
}
List<NetworkPlayerInfo> list = FeatureDungeonMap.field_175252_a.sortedCopy(Minecraft.getMinecraft().thePlayer.sendQueue.getPlayerInfoMap());
try {
for (int i = 1; i < 20; i++) {
NetworkPlayerInfo networkPlayerInfo = list.get(i);
String name = networkPlayerInfo.getDisplayName() != null ? networkPlayerInfo.getDisplayName().getFormattedText() : ScorePlayerTeam.formatPlayerName(networkPlayerInfo.getPlayerTeam(), networkPlayerInfo.getGameProfile().getName());
if (name.trim().equals("§r") || name.startsWith("§r ")) continue;
players.add(TextUtils.stripColor(name).trim().split(" ")[0]);
}
} catch (Exception e) {}
if (latestSecretCnt != FeatureRegistry.DUNGEON_SECRETS.getSecretsFound()) {
int newSecretCnt = FeatureRegistry.DUNGEON_SECRETS.getSecretsFound();
createEvent(new DungeonSecretCountChangeEvent(latestSecretCnt, newSecretCnt, latestTotalSecret, FeatureRegistry.DUNGEON_SECRETS.sureOfTotalSecrets()));
latestSecretCnt = newSecretCnt;
}
if (latestTotalSecret != FeatureRegistry.DUNGEON_SECRETS.getTotalSecretsInt()) {
latestTotalSecret = FeatureRegistry.DUNGEON_SECRETS.getTotalSecretsInt();
createEvent(new DungeonSecretCountChangeEvent(latestSecretCnt, latestSecretCnt, latestTotalSecret, FeatureRegistry.DUNGEON_SECRETS.sureOfTotalSecrets()));
}
if (latestCrypts != FeatureRegistry.DUNGEON_TOMBS.getTombsFound()) {
int newlatestCrypts = FeatureRegistry.DUNGEON_TOMBS.getTombsFound();
createEvent(new DungeonCryptBrokenEvent(latestCrypts, newlatestCrypts));
this.latestCrypts = newlatestCrypts;
}
}
public void onChat(ClientChatReceivedEvent event) {
IChatComponent component = event.message;
String formatted = component.getFormattedText();
if (formatted.contains("$DG-Comm")) {
event.setCanceled(true);
String data = component.getFormattedText().substring(component.getFormattedText().indexOf("$DG-Comm"));
String actual = TextUtils.stripColor(data);
String coords = actual.split(" ")[1];
String secrets = actual.split(" ")[2];
int x = Integer.parseInt(coords.split("/")[0]);
int z = Integer.parseInt(coords.split("/")[1]);
int secrets2 = Integer.parseInt(secrets);
Point roomPt = mapProcessor.worldPointToRoomPoint(new BlockPos(x,70,z));
e.sendDebugChat(new ChatComponentText("Message from Other dungeons guide :: "+roomPt.x+" / " + roomPt.y + " total secrets "+secrets2));
DungeonRoom dr = roomMapper.get(roomPt);
if (dr != null) {
dr.setTotalSecrets(secrets2);
}
} else if (formatted.contains("$DG-Mimic")) {
setGotMimic(true);
} else if (formatted.startsWith("§r§c§lPUZZLE FAIL! ") && formatted.endsWith(" §r§4Y§r§ci§r§6k§r§ee§r§as§r§2!§r")) {
createEvent(new DungeonPuzzleFailureEvent(TextUtils.stripColor(formatted.split(" ")[2]), formatted));
} else if (formatted.contains("§6> §e§lEXTRA STATS §6<")) {
createEvent(new DungeonNodataEvent("DUNGEON_END"));
}
}
}
|