Search in sources :

Example 16 with MinestuckPacket

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

the class MinestuckPlayerTracker method sendConfigPacket.

public static void sendConfigPacket(EntityPlayerMP player, boolean mode) {
    MinestuckPacket packet;
    if (mode)
        packet = MinestuckPacket.makePacket(Type.CONFIG, true);
    else {
        boolean permission = MinestuckConfig.getDataCheckerPermissionFor(player);
        packet = MinestuckPacket.makePacket(Type.CONFIG, false, permission);
        if (permission)
            dataCheckerPermission.add(player.getName());
        else
            dataCheckerPermission.remove(player.getName());
    }
    MinestuckChannelHandler.sendToPlayer(packet, player);
}
Also used : MinestuckPacket(com.mraof.minestuck.network.MinestuckPacket)

Example 17 with MinestuckPacket

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

the class SburbServer method onButtonPressed.

@Override
public void onButtonPressed(TileEntityComputer te, String buttonName, Object[] data) {
    if (buttonName.equals("computer.buttonEdit") || buttonName.equals("computer.buttonGive")) {
        MinestuckPacket packet = MinestuckPacket.makePacket(MinestuckPacket.Type.CLIENT_EDIT, te.ownerId, te.getData(getId()).getInteger("connectedClient"));
        MinestuckChannelHandler.sendToServer(packet);
    } else if (buttonName.equals("computer.buttonResume"))
        SkaiaClient.sendConnectRequest(te, SkaiaClient.getAssociatedPartner(te.ownerId, false), false);
    else if (buttonName.equals("computer.buttonOpen"))
        SkaiaClient.sendConnectRequest(te, -1, false);
    else if (buttonName.equals("computer.buttonClose"))
        SkaiaClient.sendCloseRequest(te, te.getData(getId()).getBoolean("isOpen") ? -1 : te.getData(getId()).getInteger("connectedClient"), false);
}
Also used : MinestuckPacket(com.mraof.minestuck.network.MinestuckPacket)

Example 18 with MinestuckPacket

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

the class MinestuckPlayerTracker method updateTitle.

public static void updateTitle(EntityPlayer player) {
    PlayerIdentifier identifier = IdentifierHandler.encode(player);
    Title newTitle = MinestuckPlayerData.getTitle(identifier);
    if (newTitle == null)
        return;
    MinestuckPacket packet = MinestuckPacket.makePacket(Type.PLAYER_DATA, PlayerDataPacket.TITLE, newTitle.getHeroClass(), newTitle.getHeroAspect());
    MinestuckChannelHandler.sendToPlayer(packet, player);
}
Also used : PlayerIdentifier(com.mraof.minestuck.util.IdentifierHandler.PlayerIdentifier) MinestuckPacket(com.mraof.minestuck.network.MinestuckPacket)

Example 19 with MinestuckPacket

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

the class MinestuckPlayerTracker method updateLands.

public static void updateLands(EntityPlayer player) {
    MinestuckPacket packet = MinestuckPacket.makePacket(Type.LANDREGISTER);
    Debug.debugf("Sending land packets to %s.", player == null ? "all players" : player.getName());
    if (player == null)
        MinestuckChannelHandler.sendToAllPlayers(packet);
    else
        MinestuckChannelHandler.sendToPlayer(packet, player);
}
Also used : MinestuckPacket(com.mraof.minestuck.network.MinestuckPacket)

Example 20 with MinestuckPacket

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

the class MinestuckPlayerTracker method onPlayerLogin.

@SubscribeEvent
public void onPlayerLogin(PlayerEvent.PlayerLoggedInEvent event) {
    EntityPlayer player = event.player;
    Debug.debug(player.getName() + " joined the game. Sending packets.");
    MinecraftServer server = player.getServer();
    if (!server.isDedicatedServer() && IdentifierHandler.host == null)
        IdentifierHandler.host = event.player.getName();
    IdentifierHandler.playerLoggedIn(player);
    PlayerIdentifier identifier = IdentifierHandler.encode(player);
    sendConfigPacket((EntityPlayerMP) player, true);
    sendConfigPacket((EntityPlayerMP) player, false);
    SkaianetHandler.playerConnected(player);
    boolean firstTime = false;
    if (MinestuckPlayerData.getGristSet(identifier) == null) {
        Debug.debugf("Grist set is null for player %s. Handling it as first time in this world.", player.getName());
        MinestuckPlayerData.setGrist(identifier, new GristSet(GristType.Build, 20));
        firstTime = true;
    }
    MinestuckPlayerData.getData(identifier).echeladder.updateEcheladderBonuses(player);
    if (CaptchaDeckHandler.getModus(player) == null && MinestuckConfig.defaultModusTypes.length > 0 && !MinestuckPlayerData.getData(player).givenModus) {
        int index = player.world.rand.nextInt(MinestuckConfig.defaultModusTypes.length);
        Modus modus = CaptchaDeckHandler.createInstance(new ResourceLocation(MinestuckConfig.defaultModusTypes[index]), Side.SERVER);
        if (modus != null) {
            modus.player = player;
            modus.initModus(null, MinestuckConfig.initialModusSize);
            CaptchaDeckHandler.setModus(player, modus);
        } else
            Debug.warnf("Couldn't create a modus by the name %s.", MinestuckConfig.defaultModusTypes[index]);
    }
    if (CaptchaDeckHandler.getModus(player) != null) {
        Modus modus = CaptchaDeckHandler.getModus(player);
        modus.player = player;
        MinestuckChannelHandler.sendToPlayer(MinestuckPacket.makePacket(Type.CAPTCHA, CaptchaDeckPacket.DATA, CaptchaDeckHandler.writeToNBT(modus)), player);
    }
    updateGristCache(identifier);
    updateTitle(player);
    updateEcheladder(player, true);
    MinestuckChannelHandler.sendToPlayer(MinestuckPacket.makePacket(Type.PLAYER_DATA, PlayerDataPacket.BOONDOLLAR, MinestuckPlayerData.getData(identifier).boondollars), player);
    ServerEditHandler.onPlayerLoggedIn((EntityPlayerMP) player);
    if (firstTime)
        MinestuckChannelHandler.sendToPlayer(MinestuckPacket.makePacket(Type.PLAYER_DATA, PlayerDataPacket.COLOR), player);
    else {
        MinestuckPacket packet = MinestuckPacket.makePacket(Type.PLAYER_DATA, PlayerDataPacket.COLOR, MinestuckPlayerData.getData(player).color);
        MinestuckChannelHandler.sendToPlayer(packet, player);
    }
    if (UpdateChecker.outOfDate)
        player.sendMessage(new TextComponentString("New version of Minestuck: " + UpdateChecker.latestVersion + "\nChanges: " + UpdateChecker.updateChanges));
}
Also used : Modus(com.mraof.minestuck.inventory.captchalouge.Modus) ResourceLocation(net.minecraft.util.ResourceLocation) EntityPlayer(net.minecraft.entity.player.EntityPlayer) PlayerIdentifier(com.mraof.minestuck.util.IdentifierHandler.PlayerIdentifier) MinestuckPacket(com.mraof.minestuck.network.MinestuckPacket) MinecraftServer(net.minecraft.server.MinecraftServer) TextComponentString(net.minecraft.util.text.TextComponentString) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

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