blob: 18f37b09c4f3ed14403eba26f498ec77081d5294 (
plain)
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
|
package kr.syeyoung.dungeonsguide.commands;
import kr.syeyoung.dungeonsguide.DungeonsGuide;
import kr.syeyoung.dungeonsguide.SkyblockStatus;
import kr.syeyoung.dungeonsguide.dungeon.DungeonContext;
import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom;
import kr.syeyoung.dungeonsguide.roomedit.EditingContext;
import kr.syeyoung.dungeonsguide.roomedit.gui.GuiDungeonRoomEdit;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;
import net.minecraft.util.ChatComponentText;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
import net.minecraftforge.fml.relauncher.Side;
import java.awt.*;
public class CommandEditRoom extends CommandBase {
@Override
public String getCommandName() {
return "editsession";
}
@Override
public String getCommandUsage(ICommandSender sender) {
return "editsession";
}
@Override
public void processCommand(ICommandSender sender, String[] args) {
SkyblockStatus skyblockStatus = (SkyblockStatus) DungeonsGuide.getDungeonsGuide().getSkyblockStatus();
if (!skyblockStatus.isOnDungeon()) {
sender.addChatMessage(new ChatComponentText("You're not in dungeons"));
return;
}
if (skyblockStatus.getContext() == null) {
sender.addChatMessage(new ChatComponentText("Dungeon Context is null"));
return;
}
DungeonContext context = skyblockStatus.getContext();
EntityPlayerSP thePlayer = Minecraft.getMinecraft().thePlayer;
Point roomPt = context.getMapProcessor().worldPointToRoomPoint(thePlayer.getPosition());
DungeonRoom dungeonRoom = context.getRoomMapper().get(roomPt);
if (dungeonRoom == null) {
sender.addChatMessage(new ChatComponentText("Can't determine the dungeon room you're in"));
return;
}
if (EditingContext.getEditingContext() != null) {
sender.addChatMessage(new ChatComponentText("There is an editing session currently open."));
return;
}
EditingContext.createEditingContext(dungeonRoom);
openGuiReq = true;
}
private boolean openGuiReq = false;
@SubscribeEvent
public void tick(TickEvent.ClientTickEvent tick){
if ( openGuiReq &&tick.phase == TickEvent.Phase.END && tick.side == Side.CLIENT && tick.type == TickEvent.Type.CLIENT) {
DungeonRoom dr = EditingContext.getEditingContext().getRoom();
EditingContext.getEditingContext().openGui(new GuiDungeonRoomEdit(dr));
openGuiReq = false;
}
}
@Override
public int getRequiredPermissionLevel() {
return 0;
}
}
|