Search in sources :

Example 91 with EntityPlayerSP

use of net.minecraft.client.entity.EntityPlayerSP in project Solar by Martacus.

the class GuiCategory method initGui.

@Override
public void initGui() {
    super.initGui();
    int xOffset = 20;
    int yOffset = 25;
    int x = (this.width - WIDTH) / 2;
    int y = (this.height - HEIGHT) / 2;
    EntityPlayerSP player = this.mc.player;
    PlayerData.PlayerSave save = PlayerData.getDataFromPlayer(player);
    int buttonAmount = 0;
    for (GuiPage guiPage : this.pages) {
        if (save.acquiredPages.contains(guiPage.getPageID())) {
            BookButton button = new BookButton(guiPage, x + xOffset, y + yOffset + (buttonAmount * 10), buttonAmount);
            this.addButton(button);
            buttonAmount++;
        }
    }
}
Also used : GuiPage(com.mart.solar.client.gui.pages.GuiPage) BookButton(com.mart.solar.client.gui.button.BookButton) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP) PlayerData(com.mart.solar.common.data.PlayerData)

Example 92 with EntityPlayerSP

use of net.minecraft.client.entity.EntityPlayerSP in project Wizardry by TeamWizardry.

the class PotionNullMovement method onTick.

@SubscribeEvent
@SideOnly(Side.CLIENT)
public void onTick(TickEvent.ClientTickEvent event) {
    Minecraft mc = Minecraft.getMinecraft();
    EntityPlayerSP player = mc.player;
    if (player == null)
        return;
    if (player.isPotionActive(ModPotions.NULL_MOVEMENT)) {
        if (!(player.movementInput instanceof NullMovementInput))
            player.movementInput = new NullMovementInput(player.movementInput);
    } else if (!(player.movementInput instanceof MovementInputFromOptions))
        player.movementInput = new MovementInputFromOptions(mc.gameSettings);
}
Also used : NullMovementInput(com.teamwizardry.wizardry.api.NullMovementInput) MovementInputFromOptions(net.minecraft.util.MovementInputFromOptions) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP) Minecraft(net.minecraft.client.Minecraft) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 93 with EntityPlayerSP

use of net.minecraft.client.entity.EntityPlayerSP in project artisan-worktables by codetaylor.

the class PluginGameStages method processStagedRecipes.

@SideOnly(Side.CLIENT)
private void processStagedRecipes() {
    if (!FMLCommonHandler.instance().getEffectiveSide().isClient()) {
        return;
    }
    if (PluginJEI.RECIPE_REGISTRY == null) {
        return;
    }
    EntityPlayerSP player = Minecraft.getMinecraft().player;
    Collection<String> unlockedStages = GameStagesHelper.getUnlockedStages(player);
    GameStagesRequirementContext context = (GameStagesRequirementContext) ArtisanAPI.getRequirementContext(new ResourceLocation(ModArtisanWorktables.MOD_ID, "gamestages"));
    context.setUnlockedStages(unlockedStages);
    for (String name : ArtisanAPI.getWorktableNames()) {
        RecipeRegistry registry = ArtisanAPI.getWorktableRecipeRegistry(name);
        if (registry != null) {
            for (EnumTier tier : EnumTier.values()) {
                List<IArtisanRecipe> recipeList = registry.getRecipeListByTier(new ArrayList<>(), tier);
                String uid = PluginJEI.createUID(name, tier);
                for (IArtisanRecipe recipe : recipeList) {
                    IRecipeWrapper recipeWrapper = PluginJEI.RECIPE_REGISTRY.getRecipeWrapper(recipe, uid);
                    if (recipeWrapper == null) {
                        continue;
                    }
                    IRequirement requirement = recipe.getRequirement(GameStagesRequirement.LOCATION);
                    // noinspection unchecked
                    if (requirement == null || requirement.match(context)) {
                        PluginJEI.RECIPE_REGISTRY.unhideRecipe(recipeWrapper);
                    } else {
                        PluginJEI.RECIPE_REGISTRY.hideRecipe(recipeWrapper);
                    }
                }
            }
        }
    }
}
Also used : IRequirement(com.codetaylor.mc.artisanworktables.api.recipe.requirement.IRequirement) GameStagesRequirementContext(com.codetaylor.mc.artisanworktables.modules.requirement.gamestages.requirement.GameStagesRequirementContext) ResourceLocation(net.minecraft.util.ResourceLocation) IArtisanRecipe(com.codetaylor.mc.artisanworktables.api.recipe.IArtisanRecipe) IRecipeWrapper(mezz.jei.api.recipe.IRecipeWrapper) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP) EnumTier(com.codetaylor.mc.artisanworktables.api.internal.reference.EnumTier) RecipeRegistry(com.codetaylor.mc.artisanworktables.api.internal.recipe.RecipeRegistry) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 94 with EntityPlayerSP

use of net.minecraft.client.entity.EntityPlayerSP in project SpongeForge by SpongePowered.

the class SpongeModNetworkManager method unbindChannel.

@Override
public void unbindChannel(ChannelBinding channel) {
    checkArgument(checkNotNull(channel, "channel") instanceof SpongeModChannelBinding, "Custom channel implementation not supported");
    SpongeModChannelBinding boundChannel = this.channelMap.remove(channel.getName());
    checkState(boundChannel != null, "Channel is already unbound");
    boundChannel.invalidate();
    // Remove channel from forge's registry
    NetworkRegistry.INSTANCE.channelNamesFor(Side.SERVER).remove(channel.getName());
    NetworkRegistry.INSTANCE.channelNamesFor(Side.CLIENT).remove(channel.getName());
    if (SpongeImpl.getGame().isServerAvailable()) {
        final PlayerList playerList = SpongeImpl.getServer().getPlayerList();
        if (playerList != null) {
            // Server side
            playerList.sendPacketToAllPlayers(getUnregPacket(channel.getName()));
        }
    }
    if (SpongeImpl.getGame().getPlatform().getExecutionType().isClient()) {
        EntityPlayerSP clientPlayer = Minecraft.getMinecraft().player;
        if (clientPlayer != null) {
            // Client side
            clientPlayer.connection.sendPacket(getUnregPacketClient(channel.getName()));
        }
    }
}
Also used : PlayerList(net.minecraft.server.management.PlayerList) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP)

Example 95 with EntityPlayerSP

use of net.minecraft.client.entity.EntityPlayerSP in project Cavern2 by kegare.

the class IPlayerMessage method onMessage.

@Override
default REPLY onMessage(REQ message, MessageContext ctx) {
    IThreadListener thread = FMLCommonHandler.instance().getWorldThread(ctx.netHandler);
    EntityPlayerSP player = FMLClientHandler.instance().getClientPlayerEntity();
    if (thread.isCallingFromMinecraftThread()) {
        return message.process(player);
    }
    thread.addScheduledTask(() -> {
        REPLY result = message.process(player);
        if (result != null) {
            CaveNetworkRegistry.sendToServer(result);
        }
    });
    return null;
}
Also used : IThreadListener(net.minecraft.util.IThreadListener) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP)

Aggregations

EntityPlayerSP (net.minecraft.client.entity.EntityPlayerSP)158 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)31 Minecraft (net.minecraft.client.Minecraft)29 ItemStack (net.minecraft.item.ItemStack)29 BlockPos (net.minecraft.util.math.BlockPos)27 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)23 Entity (net.minecraft.entity.Entity)21 EntityPlayer (net.minecraft.entity.player.EntityPlayer)13 TileEntity (net.minecraft.tileentity.TileEntity)13 WorldClient (net.minecraft.client.multiplayer.WorldClient)11 IBlockState (net.minecraft.block.state.IBlockState)10 Tessellator (net.minecraft.client.renderer.Tessellator)10 GCPlayerStatsClient (micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStatsClient)8 ArrayList (java.util.ArrayList)6 Block (net.minecraft.block.Block)6 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)6 Vec3d (net.minecraft.util.math.Vec3d)6 World (net.minecraft.world.World)6 UUID (java.util.UUID)5 BufferBuilder (net.minecraft.client.renderer.BufferBuilder)5