当前位置: 首页>>代码示例>>Java>>正文


Java EntityPlayerMP类代码示例

本文整理汇总了Java中net.minecraft.entity.player.EntityPlayerMP的典型用法代码示例。如果您正苦于以下问题:Java EntityPlayerMP类的具体用法?Java EntityPlayerMP怎么用?Java EntityPlayerMP使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


EntityPlayerMP类属于net.minecraft.entity.player包,在下文中一共展示了EntityPlayerMP类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onClientLogIn

import net.minecraft.entity.player.EntityPlayerMP; //导入依赖的package包/类
@SubscribeEvent
public void onClientLogIn(net.minecraftforge.fml.common.gameevent.PlayerEvent.PlayerLoggedInEvent event)
{
    // Should be always true but mods can throw this event at any time...
    if (event.player instanceof EntityPlayerMP)
    {
        if (FMLCommonHandler.instance().getMinecraftServerInstance().isDedicatedServer())
        {
            SettingsManager.restoreAllClientData();
        }
        else
        {
            SettingsManager.sendSettingsToClient((EntityPlayerMP) event.player);
        }
    }
}
 
开发者ID:V0idWa1k3r,项目名称:ExPetrum,代码行数:17,代码来源:ExPHandlerServer.java

示例2: onItemUse

import net.minecraft.entity.player.EntityPlayerMP; //导入依赖的package包/类
@Override
public EnumActionResult onItemUse (EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    ItemStack stack = player.getHeldItem(hand);
    IBlockState state = worldIn.getBlockState(pos);

    if (facing != EnumFacing.UP)
        return EnumActionResult.FAIL;
    if (!player.canPlayerEdit(pos.offset(facing), facing, stack))
        return EnumActionResult.FAIL;
    if (!state.getBlock().canSustainPlant(state, worldIn, pos, EnumFacing.UP, this))
        return EnumActionResult.FAIL;
    if (!worldIn.isAirBlock(pos.up()))
        return EnumActionResult.FAIL;

    worldIn.setBlockState(pos.up(), ModBlocks.candelilla.getDefaultState());
    if (player instanceof EntityPlayerMP)
        CriteriaTriggers.PLACED_BLOCK.trigger((EntityPlayerMP)player, pos.up(), stack);

    stack.shrink(1);
    return EnumActionResult.SUCCESS;
}
 
开发者ID:jaquadro,项目名称:GardenStuff,代码行数:22,代码来源:ItemCandelillaSeeds.java

示例3: execute

import net.minecraft.entity.player.EntityPlayerMP; //导入依赖的package包/类
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
	try {
		
		EntityPlayerMP entityplayermp = args.length > 0 ? getPlayer(server, sender, args[0])
				: getCommandSenderAsPlayer(sender);
		entityplayermp.getCapability(TF2weapons.PLAYER_CAP, null).highestBossLevel.clear();
		Chunk chunk=entityplayermp.world.getChunkFromBlockCoords(entityplayermp.getPosition());
		int australium=0;
		for(int x=0;x<16;x++){
			for(int y=0;y<128;y++){
				for(int z=0;z<16;z++){
					if(chunk.getBlockState(x, y, z).getBlock()==TF2weapons.blockAustraliumOre)
						australium++;
				}
			}
		}
		notifyCommandListener(sender, this, "commands.resetbossstat.success",entityplayermp.getName());
	} catch (Exception e) {
		throw new WrongUsageException(getUsage(sender), new Object[0]);
	}
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:23,代码来源:CommandResetStat.java

示例4: transferPlayerToDimension

import net.minecraft.entity.player.EntityPlayerMP; //导入依赖的package包/类
public void transferPlayerToDimension(EntityPlayerMP player, int dimensionIn, net.minecraft.world.Teleporter teleporter)
{
    int i = player.dimension;
    WorldServer worldserver = this.mcServer.worldServerForDimension(player.dimension);
    player.dimension = dimensionIn;
    WorldServer worldserver1 = this.mcServer.worldServerForDimension(player.dimension);
    player.connection.sendPacket(new SPacketRespawn(player.dimension, worldserver1.getDifficulty(), worldserver1.getWorldInfo().getTerrainType(), player.interactionManager.getGameType()));
    this.updatePermissionLevel(player);
    worldserver.removeEntityDangerously(player);
    player.isDead = false;
    this.transferEntityToWorld(player, i, worldserver, worldserver1, teleporter);
    this.preparePlayer(player, worldserver);
    player.connection.setPlayerLocation(player.posX, player.posY, player.posZ, player.rotationYaw, player.rotationPitch);
    player.interactionManager.setWorld(worldserver1);
    player.connection.sendPacket(new SPacketPlayerAbilities(player.capabilities));
    this.updateTimeAndWeatherForPlayer(player, worldserver1);
    this.syncPlayerInventory(player);

    for (PotionEffect potioneffect : player.getActivePotionEffects())
    {
        player.connection.sendPacket(new SPacketEntityEffect(player.getEntityId(), potioneffect));
    }
    net.minecraftforge.fml.common.FMLCommonHandler.instance().firePlayerChangedDimensionEvent(player, i, dimensionIn);
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:25,代码来源:PlayerList.java

示例5: sendMessageToAllTeamMembers

import net.minecraft.entity.player.EntityPlayerMP; //导入依赖的package包/类
public void sendMessageToAllTeamMembers(EntityPlayer player, ITextComponent message)
{
    Team team = player.getTeam();

    if (team != null)
    {
        for (String s : team.getMembershipCollection())
        {
            EntityPlayerMP entityplayermp = this.getPlayerByUsername(s);

            if (entityplayermp != null && entityplayermp != player)
            {
                entityplayermp.addChatMessage(message);
            }
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:18,代码来源:PlayerList.java

示例6: sendMessageToTeamOrEvryPlayer

import net.minecraft.entity.player.EntityPlayerMP; //导入依赖的package包/类
public void sendMessageToTeamOrEvryPlayer(EntityPlayer player, IChatComponent message)
{
    Team team = player.getTeam();

    if (team == null)
    {
        this.sendChatMsg(message);
    }
    else
    {
        for (int i = 0; i < this.playerEntityList.size(); ++i)
        {
            EntityPlayerMP entityplayermp = (EntityPlayerMP)this.playerEntityList.get(i);

            if (entityplayermp.getTeam() != team)
            {
                entityplayermp.addChatMessage(message);
            }
        }
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:22,代码来源:ServerConfigurationManager.java

示例7: onOpen

import net.minecraft.entity.player.EntityPlayerMP; //导入依赖的package包/类
@Override
public boolean onOpen(INetwork network, EntityPlayer player, EnumHand hand) {
    if (RSAddons.INSTANCE.config.wirelessCraftingGridUsesEnergy && stack.getItemDamage() != ItemWirelessCraftingGrid.TYPE_CREATIVE && stack.getCapability(CapabilityEnergy.ENERGY, null).getEnergyStored() <= RSAddons.INSTANCE.config.wirelessCraftingGridOpenUsage) {
        return false;
    }

    if (!network.getSecurityManager().hasPermission(Permission.MODIFY, player)) {
        WorldUtils.sendNoPermissionMessage(player);

        return false;
    }

    RSAddons.RSAPI.openWirelessGrid(player, hand, network.world().provider.getDimension(), WirelessCraftingGrid.ID);

    network.sendItemStorageToClient((EntityPlayerMP) player);

    drainEnergy(RSAddons.INSTANCE.config.wirelessCraftingGridOpenUsage);

    return true;
}
 
开发者ID:raoulvdberge,项目名称:refinedstorageaddons,代码行数:21,代码来源:NetworkItemWirelessCraftingGrid.java

示例8: sendToAllNearExcept

import net.minecraft.entity.player.EntityPlayerMP; //导入依赖的package包/类
/**
 * params: srcPlayer,x,y,z,r,dimension. The packet is not sent to the srcPlayer, but all other players within the
 * search radius
 */
public void sendToAllNearExcept(EntityPlayer p_148543_1_, double x, double y, double z, double radius, int dimension, Packet p_148543_11_)
{
    for (int i = 0; i < this.playerEntityList.size(); ++i)
    {
        EntityPlayerMP entityplayermp = (EntityPlayerMP)this.playerEntityList.get(i);

        if (entityplayermp != p_148543_1_ && entityplayermp.dimension == dimension)
        {
            double d0 = x - entityplayermp.posX;
            double d1 = y - entityplayermp.posY;
            double d2 = z - entityplayermp.posZ;

            if (d0 * d0 + d1 * d1 + d2 * d2 < radius * radius)
            {
                entityplayermp.playerNetServerHandler.sendPacket(p_148543_11_);
            }
        }
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:24,代码来源:ServerConfigurationManager.java

示例9: removePlayer

import net.minecraft.entity.player.EntityPlayerMP; //导入依赖的package包/类
/**
 * Removes an EntityPlayerMP from the PlayerManager.
 */
public void removePlayer(EntityPlayerMP player)
{
    int i = (int)player.managedPosX >> 4;
    int j = (int)player.managedPosZ >> 4;

    for (int k = i - this.playerViewRadius; k <= i + this.playerViewRadius; ++k)
    {
        for (int l = j - this.playerViewRadius; l <= j + this.playerViewRadius; ++l)
        {
            PlayerChunkMapEntry playerchunkmapentry = this.getEntry(k, l);

            if (playerchunkmapentry != null)
            {
                playerchunkmapentry.removePlayer(player);
            }
        }
    }

    this.players.remove(player);
    this.markSortPending();
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:25,代码来源:PlayerChunkMap.java

示例10: continueExecuting

import net.minecraft.entity.player.EntityPlayerMP; //导入依赖的package包/类
/**
 * Returns whether an in-progress EntityAIBase should continue executing
 */
public boolean continueExecuting()
{
    EntityLivingBase entitylivingbase = this.field_179442_b.getAttackTarget();

    if (entitylivingbase == null)
    {
        return false;
    }
    else if (!entitylivingbase.isEntityAlive())
    {
        return false;
    }
    else
    {
        double d0 = this.func_179438_f();
        return this.field_179442_b.getDistanceSqToEntity(entitylivingbase) > d0 * d0 ? false : !(entitylivingbase instanceof EntityPlayerMP) || !((EntityPlayerMP)entitylivingbase).theItemInWorldManager.isCreative();
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:22,代码来源:EntityAIFindEntityNearest.java

示例11: teleportToDimension

import net.minecraft.entity.player.EntityPlayerMP; //导入依赖的package包/类
public static void teleportToDimension(EntityPlayer player, int dimension, double x, double y, double z) {
    int oldDimension = player.getEntityWorld().provider.getDimension();
    EntityPlayerMP entityPlayerMP = (EntityPlayerMP) player;
    MinecraftServer server = player.getEntityWorld().getMinecraftServer();
    WorldServer worldServer = server.getWorld(dimension);
    player.addExperienceLevel(0);


    worldServer.getMinecraftServer().getPlayerList().transferPlayerToDimension(entityPlayerMP, dimension, new RfToolsTeleporter(worldServer, x, y, z));
    player.setPositionAndUpdate(x, y, z);
    if (oldDimension == 1) {
        // For some reason teleporting out of the end does weird things.
        player.setPositionAndUpdate(x, y, z);
        worldServer.spawnEntity(player);
        worldServer.updateEntityWithOptionalForce(player, false);
    }
}
 
开发者ID:elytra,项目名称:tp-plus,代码行数:18,代码来源:CommandTPP.java

示例12: buildAchievementStats

import net.minecraft.entity.player.EntityPlayerMP; //导入依赖的package包/类
/** Builds the basic achievement world data to be used as observation signals by the listener.
 * @param json a JSON object into which the achievement stats will be added.
 */
public static void buildAchievementStats(JsonObject json, EntityPlayerMP player)
{
    StatFileWriter sfw = player.getStatFile();
    json.addProperty("DistanceTravelled", 
            sfw.readStat((StatBase)StatList.distanceWalkedStat) 
            + sfw.readStat((StatBase)StatList.distanceSwumStat) 
            + sfw.readStat((StatBase)StatList.distanceDoveStat) 
            + sfw.readStat((StatBase)StatList.distanceFallenStat) 
            ); // TODO: there are many other ways of moving!
    json.addProperty("TimeAlive", sfw.readStat((StatBase)StatList.timeSinceDeathStat));
    json.addProperty("MobsKilled", sfw.readStat((StatBase)StatList.mobKillsStat));
    json.addProperty("PlayersKilled", sfw.readStat((StatBase)StatList.playerKillsStat));
    json.addProperty("DamageTaken", sfw.readStat((StatBase)StatList.damageTakenStat));

    /* Other potential reinforcement signals that may be worth researching:
    json.addProperty("BlocksDestroyed", sfw.readStat((StatBase)StatList.objectBreakStats) - but objectBreakStats is an array of 32000 StatBase objects - indexed by block type.);
    json.addProperty("Blocked", ev.player.isMovementBlocked()) - but isMovementBlocker() is a protected method (can get round this with reflection)
    */
}
 
开发者ID:Yarichi,项目名称:Proyecto-DASI,代码行数:23,代码来源:JSONWorldDataHelper.java

示例13: setExtraData

import net.minecraft.entity.player.EntityPlayerMP; //导入依赖的package包/类
public void setExtraData(net.minecraft.nbt.NBTTagCompound nbttagcompound) {
    if (!nbttagcompound.hasKey("bukkit")) {
        nbttagcompound.setTag("bukkit", new net.minecraft.nbt.NBTTagCompound());
    }

    net.minecraft.nbt.NBTTagCompound data = nbttagcompound.getCompoundTag("bukkit");
    net.minecraft.entity.player.EntityPlayerMP handle = getHandle();
    data.setInteger("newExp", handle.newExp);
    data.setInteger("newTotalExp", handle.newTotalExp);
    data.setInteger("newLevel", handle.newLevel);
    data.setInteger("expToDrop", handle.expToDrop);
    data.setBoolean("keepLevel", handle.keepLevel);
    data.setLong("firstPlayed", getFirstPlayed());
    data.setLong("lastPlayed", System.currentTimeMillis());
    data.setString("lastKnownName", handle.getCommandSenderName());
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:17,代码来源:CraftPlayer.java

示例14: throwProjectile

import net.minecraft.entity.player.EntityPlayerMP; //导入依赖的package包/类
private void throwProjectile(EntityPlayer player, EnumHand hand, World world) {
    ItemStack heldItem = player.getHeldItem(hand);

    int charge = getCharge(heldItem);
    if (charge <= 0) {
        MeeCreepsMessages.INSTANCE.sendTo(new PacketShowBalloonToClient("message.meecreeps.gun_no_charge"), (EntityPlayerMP) player);
        return;
    }
    setCharge(heldItem, charge-1);

    List<TeleportDestination> destinations = getDestinations(heldItem);
    int current = getCurrentDestination(heldItem);
    if (current == -1) {
        MeeCreepsMessages.INSTANCE.sendTo(new PacketShowBalloonToClient("message.meecreeps.gun_no_destination"), (EntityPlayerMP) player);
    } else if (destinations.get(current) == null) {
        MeeCreepsMessages.INSTANCE.sendTo(new PacketShowBalloonToClient("message.meecreeps.gun_bad_destination"), (EntityPlayerMP) player);
    } else {
        EntityProjectile projectile = new EntityProjectile(world, player);
        projectile.setDestination(destinations.get(current));
        projectile.setPlayerId(player.getUniqueID());
        projectile.shoot(player, player.rotationPitch, player.rotationYaw, 0.0F, 1.5F, 1.0F);
        world.spawnEntity(projectile);
    }
}
 
开发者ID:McJty,项目名称:MeeCreeps,代码行数:25,代码来源:PortalGunItem.java

示例15: spawnParticle

import net.minecraft.entity.player.EntityPlayerMP; //导入依赖的package包/类
/**
 * Spawns the desired particle and sends the necessary packets to the relevant connected players.
 */
public void spawnParticle(EnumParticleTypes particleType, boolean longDistance, double xCoord, double yCoord, double zCoord, int numberOfParticles, double xOffset, double yOffset, double zOffset, double particleSpeed, int... p_180505_18_)
{
    Packet packet = new S2APacketParticles(particleType, longDistance, (float)xCoord, (float)yCoord, (float)zCoord, (float)xOffset, (float)yOffset, (float)zOffset, (float)particleSpeed, numberOfParticles, p_180505_18_);

    for (int i = 0; i < this.playerEntities.size(); ++i)
    {
        EntityPlayerMP entityplayermp = (EntityPlayerMP)this.playerEntities.get(i);
        BlockPos blockpos = entityplayermp.getPosition();
        double d0 = blockpos.distanceSq(xCoord, yCoord, zCoord);

        if (d0 <= 256.0D || longDistance && d0 <= 65536.0D)
        {
            entityplayermp.playerNetServerHandler.sendPacket(packet);
        }
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:20,代码来源:WorldServer.java


注:本文中的net.minecraft.entity.player.EntityPlayerMP类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。