use of com.mraof.minestuck.network.MinestuckPacket in project Minestuck by mraof.
the class GuiGristSelector method mouseClicked.
@Override
protected void mouseClicked(int xcor, int ycor, int mouseButton) throws IOException {
super.mouseClicked(xcor, ycor, mouseButton);
if (mouseButton == 0) {
int xOffset = (width - guiWidth) / 2;
int yOffset = (height - guiHeight) / 2;
List<GristType> types = new ArrayList<>(GristType.REGISTRY.getValues());
Collections.sort(types);
types = types.stream().skip(page * rows * columns).limit(rows * columns).collect(Collectors.toList());
int offset = 0;
for (GristType type : types) {
int row = offset / columns;
int column = offset % columns;
int gristXOffset = xOffset + gristIconX + (gristDisplayXOffset * column - column);
int gristYOffset = yOffset + gristIconY + (gristDisplayYOffset * row - row);
if (isPointInRegion(gristXOffset, gristYOffset, 16, 16, xcor, ycor)) {
otherGui.te.selectedGrist = type;
otherGui.width = this.width;
otherGui.height = this.height;
mc.currentScreen = otherGui;
MinestuckPacket packet = MinestuckPacket.makePacket(Type.MACHINE_STATE, type);
MinestuckChannelHandler.sendToServer(packet);
break;
}
offset++;
}
}
}
use of com.mraof.minestuck.network.MinestuckPacket in project Minestuck by mraof.
the class GuiMachine method actionPerformed.
@Override
protected void actionPerformed(GuiButton guibutton) {
if (guibutton == goButton) {
if (Mouse.getEventButton() == 0 && !te.overrideStop) {
// Tell the machine to go once
MinestuckPacket packet = MinestuckPacket.makePacket(Type.GOBUTTON, true, false);
MinestuckChannelHandler.sendToServer(packet);
te.ready = true;
te.overrideStop = false;
goButton.displayString = I18n.format("gui.buttonGo");
} else if (Mouse.getEventButton() == 1 && te.allowOverrideStop()) {
// Tell the machine to go until stopped
MinestuckPacket packet = MinestuckPacket.makePacket(Type.GOBUTTON, true, !te.overrideStop);
MinestuckChannelHandler.sendToServer(packet);
te.overrideStop = !te.overrideStop;
goButton.displayString = I18n.format(te.overrideStop ? "gui.buttonStop" : "gui.buttonGo");
}
}
}
use of com.mraof.minestuck.network.MinestuckPacket in project Minestuck by mraof.
the class GuiUraniumCooker method keyTyped.
@Override
protected void keyTyped(char typedChar, int keyCode) throws IOException {
super.keyTyped(typedChar, keyCode);
if (keyCode == 28) {
this.mc.getSoundHandler().playSound(PositionedSoundRecord.getMasterRecord(SoundEvents.UI_BUTTON_CLICK, 1.0F));
boolean mode = te.allowOverrideStop() && (Keyboard.isKeyDown(42) || Keyboard.isKeyDown(54));
MinestuckPacket packet = MinestuckPacket.makePacket(Type.GOBUTTON, true, mode && !te.overrideStop);
MinestuckChannelHandler.sendToServer(packet);
if (!mode)
te.ready = true;
te.overrideStop = mode && !te.overrideStop;
goButton.displayString = I18n.format(te.overrideStop ? "gui.buttonStop" : "gui.buttonGo");
}
}
use of com.mraof.minestuck.network.MinestuckPacket in project Minestuck by mraof.
the class GuiUraniumCooker method actionPerformed.
@Override
protected void actionPerformed(GuiButton guibutton) {
if (guibutton == goButton) {
if (Mouse.getEventButton() == 0 && !te.overrideStop) {
// Tell the machine to go once
MinestuckPacket packet = MinestuckPacket.makePacket(Type.GOBUTTON, true, false);
MinestuckChannelHandler.sendToServer(packet);
te.ready = true;
te.overrideStop = false;
goButton.displayString = I18n.format(te.overrideStop ? "gui.buttonStop" : "gui.buttonGo");
} else if (Mouse.getEventButton() == 1 && te.allowOverrideStop()) {
// Tell the machine to go until stopped
MinestuckPacket packet = MinestuckPacket.makePacket(Type.GOBUTTON, true, !te.overrideStop);
MinestuckChannelHandler.sendToServer(packet);
te.overrideStop = !te.overrideStop;
goButton.displayString = I18n.format(te.overrideStop ? "gui.buttonStop" : "gui.buttonGo");
}
}
}
Aggregations