Search in sources :

Example 11 with MinestuckPacket

use of com.mraof.minestuck.network.MinestuckPacket in project Minestuck by mraof.

the class GuiTransportalizer method actionPerformed.

@Override
protected void actionPerformed(GuiButton button) {
    if (button.id == 0 && this.destinationTextField.getText().length() == 4) {
        // Debug.print("Sending transportalizer packet with destination of " + this.destinationTextField.getText());
        MinestuckPacket packet = new TransportalizerPacket();
        packet.generatePacket(te.getPos().getX(), te.getPos().getY(), te.getPos().getZ(), this.destinationTextField.getText().toUpperCase());
        MinestuckChannelHandler.sendToServer(packet);
        this.mc.displayGuiScreen((GuiScreen) null);
    }
}
Also used : TransportalizerPacket(com.mraof.minestuck.network.TransportalizerPacket) MinestuckPacket(com.mraof.minestuck.network.MinestuckPacket)

Example 12 with MinestuckPacket

use of com.mraof.minestuck.network.MinestuckPacket in project Minestuck by mraof.

the class HashmapGuiHandler method updateContent.

@Override
public void updateContent() {
    NonNullList<ItemStack> stacks = modus.getItems();
    this.cards.clear();
    this.maxWidth = Math.max(mapWidth, 10 + (stacks.size() * CARD_WIDTH + (stacks.size() - 1) * 5));
    this.maxHeight = mapHeight;
    super.updateContent();
    int start = Math.max(5, (mapWidth - (stacks.size() * CARD_WIDTH + (stacks.size() - 1) * 5)) / 2);
    for (int i = 0; i < stacks.size(); i++) this.cards.add(new GuiCard(stacks.get(i), this, i, start + i * (CARD_WIDTH + 5), (mapHeight - CARD_HEIGHT) / 2) {

        @Override
        public void onClick(int mouseButton) {
            if (this.item == null && mouseButton == 1) {
                MinestuckPacket packet = MinestuckPacket.makePacket(Type.CAPTCHA, CaptchaDeckPacket.GET, this.index, true);
                MinestuckChannelHandler.sendToServer(packet);
            } else
                super.onClick(mouseButton);
        }
    });
}
Also used : ItemStack(net.minecraft.item.ItemStack) MinestuckPacket(com.mraof.minestuck.network.MinestuckPacket)

Example 13 with MinestuckPacket

use of com.mraof.minestuck.network.MinestuckPacket in project Minestuck by mraof.

the class ConnectionListener method onServerConnectionCreated.

@SubscribeEvent
public void onServerConnectionCreated(FMLNetworkEvent.ServerConnectionFromClientEvent event) {
    MinestuckPacket packet = MinestuckPacket.makePacket(Type.LANDREGISTER);
    MinestuckChannelHandler.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.DISPATCHER);
    MinestuckChannelHandler.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(event.getManager().channel().attr(NetworkDispatcher.FML_DISPATCHER).get());
    MinestuckChannelHandler.channels.get(Side.SERVER).writeOutbound(packet);
}
Also used : MinestuckPacket(com.mraof.minestuck.network.MinestuckPacket) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 14 with MinestuckPacket

use of com.mraof.minestuck.network.MinestuckPacket in project Minestuck by mraof.

the class MinestuckPlayerTracker method updateEcheladder.

public static void updateEcheladder(EntityPlayer player, boolean jump) {
    Echeladder echeladder = MinestuckPlayerData.getData(player).echeladder;
    MinestuckPacket packet = MinestuckPacket.makePacket(Type.PLAYER_DATA, PlayerDataPacket.ECHELADDER, echeladder.getRung(), MinestuckConfig.echeladderProgress ? echeladder.getProgress() : 0F, jump);
    MinestuckChannelHandler.sendToPlayer(packet, player);
}
Also used : MinestuckPacket(com.mraof.minestuck.network.MinestuckPacket)

Example 15 with MinestuckPacket

use of com.mraof.minestuck.network.MinestuckPacket in project Minestuck by mraof.

the class MinestuckPlayerTracker method updateGristCache.

/**
 * Uses an "encoded" username as parameter.
 */
public static void updateGristCache(PlayerIdentifier player) {
    GristSet gristSet = MinestuckPlayerData.getGristSet(player);
    // The player
    EntityPlayerMP playerMP = player.getPlayer();
    if (playerMP != null) {
        MinestuckPacket packet = MinestuckPacket.makePacket(Type.GRISTCACHE, gristSet, false);
        MinestuckChannelHandler.sendToPlayer(packet, playerMP);
    }
    // The editing player, if there is any.
    SburbConnection c = SkaianetHandler.getClientConnection(player);
    if (c != null && ServerEditHandler.getData(c) != null) {
        EntityPlayerMP editor = ServerEditHandler.getData(c).getEditor();
        MinestuckPacket packet = MinestuckPacket.makePacket(Type.GRISTCACHE, gristSet, true);
        MinestuckChannelHandler.sendToPlayer(packet, editor);
    }
}
Also used : EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) MinestuckPacket(com.mraof.minestuck.network.MinestuckPacket) SburbConnection(com.mraof.minestuck.network.skaianet.SburbConnection)

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