本文整理匯總了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);
}
}
}
示例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;
}
示例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]);
}
}
示例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);
}
示例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);
}
}
}
}
示例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);
}
}
}
}
示例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;
}
示例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_);
}
}
}
}
示例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();
}
示例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();
}
}
示例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);
}
}
示例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)
*/
}
示例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());
}
示例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);
}
}
示例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);
}
}
}