Search in sources :

Example 1 with Modus

use of com.mraof.minestuck.inventory.captchalouge.Modus in project Minestuck by mraof.

the class MinestuckPlayerTracker method onPlayerRespawn.

@SubscribeEvent
public void onPlayerRespawn(PlayerEvent.PlayerRespawnEvent event) {
    MinestuckPlayerData.getData(event.player).echeladder.updateEcheladderBonuses(event.player);
    Modus modus = MinestuckPlayerData.getData(event.player).modus;
    if (modus != null)
        modus.player = event.player;
}
Also used : Modus(com.mraof.minestuck.inventory.captchalouge.Modus) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 2 with Modus

use of com.mraof.minestuck.inventory.captchalouge.Modus in project Minestuck by mraof.

the class MinestuckPlayerTracker method onPlayerLogout.

// Editmode players need to be reset before nei handles the event
@SubscribeEvent(priority = EventPriority.HIGH)
public void onPlayerLogout(PlayerEvent.PlayerLoggedOutEvent event) {
    ServerEditHandler.onPlayerExit(event.player);
    Modus modus = CaptchaDeckHandler.getModus(event.player);
    if (modus != null)
        modus.player = null;
    dataCheckerPermission.remove(event.player.getName());
}
Also used : Modus(com.mraof.minestuck.inventory.captchalouge.Modus) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 3 with Modus

use of com.mraof.minestuck.inventory.captchalouge.Modus 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)

Example 4 with Modus

use of com.mraof.minestuck.inventory.captchalouge.Modus in project Minestuck by mraof.

the class GuiCaptchaDeck method actionPerformed.

@Override
protected void actionPerformed(GuiButton button) {
    if (button == this.modusButton && !container.inventory.getStackInSlot(0).isEmpty()) {
        ItemStack stack = container.inventory.getStackInSlot(0);
        if (!(stack.getItem() instanceof ItemCaptchaCard)) {
            Modus newModus = CaptchaDeckHandler.createInstance(CaptchaDeckHandler.getType(stack), Side.CLIENT);
            if (newModus != null && CaptchaDeckHandler.clientSideModus != null && newModus.getClass() != CaptchaDeckHandler.clientSideModus.getClass() && !newModus.canSwitchFrom(CaptchaDeckHandler.clientSideModus)) {
                mc.currentScreen = new GuiYesNo(this, I18n.format("gui.emptySylladex1"), I18n.format("gui.emptySylladex2"), 0) {

                    @Override
                    public void onGuiClosed() {
                        mc.currentScreen = (GuiScreen) parentScreen;
                        mc.player.closeScreen();
                    }
                };
                mc.currentScreen.setWorldAndResolution(mc, width, height);
                return;
            }
        }
        MinestuckChannelHandler.sendToServer(MinestuckPacket.makePacket(Type.CAPTCHA, CaptchaDeckPacket.MODUS));
    } else if (button == this.sylladexMap && CaptchaDeckHandler.clientSideModus != null) {
        mc.player.connection.sendPacket(new CPacketCloseWindow(mc.player.openContainer.windowId));
        mc.player.inventory.setItemStack(ItemStack.EMPTY);
        mc.displayGuiScreen(CaptchaDeckHandler.clientSideModus.getGuiHandler());
        mc.player.openContainer = mc.player.inventoryContainer;
    }
}
Also used : Modus(com.mraof.minestuck.inventory.captchalouge.Modus) GuiYesNo(net.minecraft.client.gui.GuiYesNo) ItemCaptchaCard(com.mraof.minestuck.item.ItemCaptchaCard) GuiScreen(net.minecraft.client.gui.GuiScreen) CPacketCloseWindow(net.minecraft.network.play.client.CPacketCloseWindow) ItemStack(net.minecraft.item.ItemStack)

Aggregations

Modus (com.mraof.minestuck.inventory.captchalouge.Modus)4 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)3 ItemCaptchaCard (com.mraof.minestuck.item.ItemCaptchaCard)1 MinestuckPacket (com.mraof.minestuck.network.MinestuckPacket)1 PlayerIdentifier (com.mraof.minestuck.util.IdentifierHandler.PlayerIdentifier)1 GuiScreen (net.minecraft.client.gui.GuiScreen)1 GuiYesNo (net.minecraft.client.gui.GuiYesNo)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 ItemStack (net.minecraft.item.ItemStack)1 CPacketCloseWindow (net.minecraft.network.play.client.CPacketCloseWindow)1 MinecraftServer (net.minecraft.server.MinecraftServer)1 ResourceLocation (net.minecraft.util.ResourceLocation)1 TextComponentString (net.minecraft.util.text.TextComponentString)1