Search in sources :

Example 26 with MinestuckPacket

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++;
        }
    }
}
Also used : ArrayList(java.util.ArrayList) MinestuckPacket(com.mraof.minestuck.network.MinestuckPacket) GristType(com.mraof.minestuck.util.GristType)

Example 27 with MinestuckPacket

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");
        }
    }
}
Also used : MinestuckPacket(com.mraof.minestuck.network.MinestuckPacket)

Example 28 with MinestuckPacket

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");
    }
}
Also used : MinestuckPacket(com.mraof.minestuck.network.MinestuckPacket)

Example 29 with MinestuckPacket

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");
        }
    }
}
Also used : MinestuckPacket(com.mraof.minestuck.network.MinestuckPacket)

Aggregations

MinestuckPacket (com.mraof.minestuck.network.MinestuckPacket)29 ItemStack (net.minecraft.item.ItemStack)5 SburbConnection (com.mraof.minestuck.network.skaianet.SburbConnection)3 PlayerIdentifier (com.mraof.minestuck.util.IdentifierHandler.PlayerIdentifier)3 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)3 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)3 EntityDecoy (com.mraof.minestuck.entity.EntityDecoy)2 NBTTagList (net.minecraft.nbt.NBTTagList)2 ResourceLocation (net.minecraft.util.ResourceLocation)2 TextComponentString (net.minecraft.util.text.TextComponentString)2 EditData (com.mraof.minestuck.editmode.EditData)1 Modus (com.mraof.minestuck.inventory.captchalouge.Modus)1 TransportalizerPacket (com.mraof.minestuck.network.TransportalizerPacket)1 GristType (com.mraof.minestuck.util.GristType)1 MinestuckPlayerData (com.mraof.minestuck.util.MinestuckPlayerData)1 ArrayList (java.util.ArrayList)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1 MinecraftServer (net.minecraft.server.MinecraftServer)1