Search in sources :

Example 6 with MinestuckPacket

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

the class CaptchaDeckHandler method dropSylladex.

public static void dropSylladex(EntityPlayer player) {
    Modus modus = getModus(player);
    if (modus == null)
        return;
    NonNullList<ItemStack> stacks = modus.getItems();
    int size = modus.getSize();
    int cardsToKeep = MinestuckConfig.sylladexDropMode == 2 ? 0 : MinestuckConfig.initialModusSize;
    if (!MinestuckConfig.dropItemsInCards || MinestuckConfig.sylladexDropMode == 0) {
        for (ItemStack stack : stacks) if (!stack.isEmpty())
            player.dropItem(stack, true, false);
    } else
        for (ItemStack stack : stacks) if (!stack.isEmpty())
            if (size > cardsToKeep) {
                ItemStack card = AlchemyRecipeHandler.createCard(stack, false);
                player.dropItem(card, true, false);
                size--;
            } else
                player.dropItem(stack, true, false);
    int stackLimit = MinestuckItems.captchaCard.getItemStackLimit(new ItemStack(MinestuckItems.captchaCard));
    if (MinestuckConfig.sylladexDropMode >= 1)
        for (; size > cardsToKeep; size = Math.max(size - stackLimit, cardsToKeep)) player.dropItem(new ItemStack(MinestuckItems.captchaCard, Math.min(stackLimit, size - cardsToKeep)), true, false);
    if (MinestuckConfig.sylladexDropMode == 2) {
        // TODO Add a method to the modus to get the itemstack instead
        player.dropItem(getItem(getType(modus.getClass())), true, false);
        setModus(player, null);
    } else
        modus.initModus(null, size);
    MinestuckPacket packet = MinestuckPacket.makePacket(MinestuckPacket.Type.CAPTCHA, CaptchaDeckPacket.DATA, writeToNBT(getModus(player)));
    MinestuckChannelHandler.sendToPlayer(packet, player);
}
Also used : ItemStack(net.minecraft.item.ItemStack) MinestuckPacket(com.mraof.minestuck.network.MinestuckPacket)

Example 7 with MinestuckPacket

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

the class HashmapModus method onChatMessage.

public void onChatMessage(String str) {
    if (!ejectByChat && MinestuckConfig.hashmapChatModusSetting != 1 || MinestuckConfig.hashmapChatModusSetting == 2)
        return;
    boolean isPrevLetter = false;
    String number = "";
    for (int i = 0; i < str.length(); i++) {
        char c = str.charAt(i);
        if (Character.isLetter(c))
            isPrevLetter = true;
        else if (Character.isDigit(c) || (number.isEmpty() && c == '-')) {
            if (!isPrevLetter)
                number = number + c;
            continue;
        } else {
            isPrevLetter = false;
            if (!number.isEmpty())
                handleNumber(number);
        }
        number = "";
    }
    if (!number.isEmpty())
        handleNumber(number);
    MinestuckPacket packet = MinestuckPacket.makePacket(MinestuckPacket.Type.CAPTCHA, CaptchaDeckPacket.DATA, CaptchaDeckHandler.writeToNBT(this));
    MinestuckChannelHandler.sendToPlayer(packet, player);
}
Also used : MinestuckPacket(com.mraof.minestuck.network.MinestuckPacket)

Example 8 with MinestuckPacket

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

the class SkaiaClient method sendConnectRequest.

public static // Used for both connect, open server and resume
void sendConnectRequest(// Used for both connect, open server and resume
TileEntityComputer te, // Used for both connect, open server and resume
int otherPlayer, // Used for both connect, open server and resume
boolean isClient) {
    MinestuckPacket packet = MinestuckPacket.makePacket(Type.SBURB_CONNECT, ComputerData.createData(te), otherPlayer, isClient);
    MinestuckChannelHandler.sendToServer(packet);
}
Also used : MinestuckPacket(com.mraof.minestuck.network.MinestuckPacket)

Example 9 with MinestuckPacket

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

the class SkaianetHandler method updatePlayer.

private static void updatePlayer(PlayerIdentifier player) {
    PlayerIdentifier[] iden = infoToSend.get(player);
    EntityPlayerMP playerMP = player.getPlayer();
    if (// If the player disconnected
    iden == null || playerMP == null)
        return;
    for (SburbConnection c : connections) if (c.isActive && (c.getClientIdentifier().equals(player) || c.getServerIdentifier().equals(player))) {
        // playerMP.addStat(MinestuckAchievementHandler.setupConnection);
        break;
    }
    for (PlayerIdentifier i : iden) if (i != null) {
        MinestuckPacket packet = MinestuckPacket.makePacket(Type.SBURB_INFO, generateClientInfo(i));
        MinestuckChannelHandler.sendToPlayer(packet, playerMP);
    }
}
Also used : EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) PlayerIdentifier(com.mraof.minestuck.util.IdentifierHandler.PlayerIdentifier) MinestuckPacket(com.mraof.minestuck.network.MinestuckPacket)

Example 10 with MinestuckPacket

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

the class GuiMachine 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)

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