Java Code Examples for net.minecraft.entity.player.EntityPlayerMP

The following are top voted examples for showing how to use net.minecraft.entity.player.EntityPlayerMP. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: ExPetrum   File: ExPHandlerServer.java   View source code 7 votes vote down vote up
@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);
        }
    }
}
 
Example 2
Project: GardenStuff   File: ItemCandelillaSeeds.java   View source code 6 votes vote down vote up
@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;
}
 
Example 3
Project: Mods   File: CommandResetStat.java   View source code 6 votes vote down vote up
@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]);
	}
}
 
Example 4
Project: CustomWorldGen   File: PlayerList.java   View source code 6 votes vote down vote up
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);
}
 
Example 5
Project: Backmemed   File: PlayerList.java   View source code 6 votes vote down vote up
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);
            }
        }
    }
}
 
Example 6
Project: BaseClient   File: ServerConfigurationManager.java   View source code 6 votes vote down vote up
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);
            }
        }
    }
}
 
Example 7
Project: refinedstorageaddons   File: NetworkItemWirelessCraftingGrid.java   View source code 6 votes vote down vote up
@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;
}
 
Example 8
Project: BaseClient   File: ServerConfigurationManager.java   View source code 6 votes vote down vote up
/**
 * 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_);
            }
        }
    }
}
 
Example 9
Project: CustomWorldGen   File: PlayerChunkMap.java   View source code 6 votes vote down vote up
/**
 * 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();
}
 
Example 10
Project: BaseClient   File: EntityAIFindEntityNearest.java   View source code 6 votes vote down vote up
/**
 * 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();
    }
}
 
Example 11
Project: tp-plus   File: CommandTPP.java   View source code 6 votes vote down vote up
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);
    }
}
 
Example 12
Project: Proyecto-DASI   File: JSONWorldDataHelper.java   View source code 6 votes vote down vote up
/** 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)
    */
}
 
Example 13
Project: Uranium   File: CraftPlayer.java   View source code 6 votes vote down vote up
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());
}
 
Example 14
Project: MeeCreeps   File: PortalGunItem.java   View source code 6 votes vote down vote up
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);
    }
}
 
Example 15
Project: BaseClient   File: WorldServer.java   View source code 6 votes vote down vote up
/**
 * 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);
        }
    }
}
 
Example 16
Project: BaseClient   File: ServerConfigurationManager.java   View source code 5 votes vote down vote up
/**
 * also stores the NBTTags if this is an intergratedPlayerList
 */
protected void writePlayerData(EntityPlayerMP playerIn)
{
    this.playerNBTManagerObj.writePlayerData(playerIn);
    StatisticsFile statisticsfile = (StatisticsFile)this.playerStatFiles.get(playerIn.getUniqueID());

    if (statisticsfile != null)
    {
        statisticsfile.saveStatFile();
    }
}
 
Example 17
Project: FirstAid   File: MessageClientUpdate.java   View source code 5 votes vote down vote up
@Override
public IMessage onMessage(MessageClientUpdate message, MessageContext ctx) {
    EntityPlayerMP player = ctx.getServerHandler().player;
    if (message.type == Type.TUTORIAL_COMPLETE) {
        PlayerDataManager.tutorialDone.add(player.getName());
        Objects.requireNonNull(player.getServer()).addScheduledTask(() -> PlayerDataManager.getDamageModel(player).hasTutorial = true);
    } else if (message.type == Type.REQUEST_REFRESH) {
        FirstAid.NETWORKING.sendTo(new MessageResync(PlayerDataManager.getDamageModel(player)), player);
    }
    return null;
}
 
Example 18
Project: Backmemed   File: PlayerList.java   View source code 5 votes vote down vote up
private void setPlayerGameTypeBasedOnOther(EntityPlayerMP target, EntityPlayerMP source, World worldIn)
{
    if (source != null)
    {
        target.interactionManager.setGameType(source.interactionManager.getGameType());
    }
    else if (this.gameType != null)
    {
        target.interactionManager.setGameType(this.gameType);
    }

    target.interactionManager.initializeGameType(worldIn.getWorldInfo().getGameType());
}
 
Example 19
Project: DecompiledMinecraft   File: S38PacketPlayerListItem.java   View source code 5 votes vote down vote up
public S38PacketPlayerListItem(S38PacketPlayerListItem.Action actionIn, EntityPlayerMP... players)
{
    this.action = actionIn;

    for (EntityPlayerMP entityplayermp : players)
    {
        this.players.add(new S38PacketPlayerListItem.AddPlayerData(entityplayermp.getGameProfile(), entityplayermp.ping, entityplayermp.theItemInWorldManager.getGameType(), entityplayermp.getTabListDisplayName()));
    }
}
 
Example 20
Project: World-Border   File: CmdReload.java   View source code 5 votes vote down vote up
@Override
public void execute(ICommandSender sender, EntityPlayerMP player, List<String> params, String worldName)
{
    if (player != null)
        Log.info("Reloading config file at the command of player \"" + player.getDisplayName() + "\".");

    Config.load(true);

    if (player != null)
        Util.chat(sender, "WorldBorder configuration reloaded.");
}
 
Example 21
Project: MineCamera   File: MessageUpdatePitchYaw.java   View source code 5 votes vote down vote up
@Override
public IMessage onMessage(MessageUpdatePitchYaw message, MessageContext ctx) {
	if (ctx.side == Side.SERVER) {
		EntityPlayerMP player = ctx.getServerHandler().playerEntity;
		Entity entity =player.getEntityWorld()
				.getEntityByID(player.getEntityData().getInteger("renderViewCamera"));
		// entity.setDelay(message.delay);
		if (player != null && entity != null&&entity instanceof EntityTripod) {
			entity.rotationYaw = message.rotationYaw;
			entity.rotationPitch = message.rotationPitch;
		}
	}
	return null;
}
 
Example 22
Project: Backmemed   File: EntityElderGuardian.java   View source code 5 votes vote down vote up
protected void updateAITasks()
{
    super.updateAITasks();
    int i = 1200;

    if ((this.ticksExisted + this.getEntityId()) % 1200 == 0)
    {
        Potion potion = MobEffects.MINING_FATIGUE;
        List<EntityPlayerMP> list = this.world.<EntityPlayerMP>getPlayers(EntityPlayerMP.class, new Predicate<EntityPlayerMP>()
        {
            public boolean apply(@Nullable EntityPlayerMP p_apply_1_)
            {
                return EntityElderGuardian.this.getDistanceSqToEntity(p_apply_1_) < 2500.0D && p_apply_1_.interactionManager.survivalOrAdventure();
            }
        });
        int j = 2;
        int k = 6000;
        int l = 1200;

        for (EntityPlayerMP entityplayermp : list)
        {
            if (!entityplayermp.isPotionActive(potion) || entityplayermp.getActivePotionEffect(potion).getAmplifier() < 2 || entityplayermp.getActivePotionEffect(potion).getDuration() < 1200)
            {
                entityplayermp.connection.sendPacket(new SPacketChangeGameState(10, 0.0F));
                entityplayermp.addPotionEffect(new PotionEffect(potion, 6000, 2));
            }
        }
    }

    if (!this.hasHome())
    {
        this.setHomePosAndDistance(new BlockPos(this), 16);
    }
}
 
Example 23
Project: refinedstorageaddons   File: ItemNetworkPicker.java   View source code 5 votes vote down vote up
public void doPick(INetwork network, EntityPlayerMP player, ItemStack stack) {
    if (RSAddons.INSTANCE.config.networkPickerUsesEnergy && stack.getItemDamage() != ItemNetworkPicker.TYPE_CREATIVE && stack.getCapability(CapabilityEnergy.ENERGY, null).getEnergyStored() <= RSAddons.INSTANCE.config.networkPickerUsage) {
        return;
    }

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

        return;
    }

    RayTraceResult target = player.world.rayTraceBlocks(RenderUtils.getStart(player), RenderUtils.getEnd(player));

    if (target != null) {
        IBlockState state = player.world.getBlockState(target.getBlockPos());

        ItemStack toExtract = state.getBlock().getPickBlock(state, target, player.world, target.getBlockPos(), player);

        if (!toExtract.isEmpty()) {
            ItemStack result = network.extractItem(toExtract, toExtract.getMaxStackSize(), false);

            if (result != null) {
                if (!player.inventory.addItemStackToInventory(result)) {
                    network.insertItem(result, result.getCount(), false);
                }
            }
        }
    }

    if (RSAddons.INSTANCE.config.networkPickerUsesEnergy && stack.getItemDamage() != ItemNetworkPicker.TYPE_CREATIVE) {
        stack.getCapability(CapabilityEnergy.ENERGY, null).extractEnergy(RSAddons.INSTANCE.config.networkPickerUsage, false);
    }
}
 
Example 24
Project: BaseClient   File: ServerConfigurationManager.java   View source code 5 votes vote down vote up
/**
 * Saves all of the players' current states.
 */
public void saveAllPlayerData()
{
    for (int i = 0; i < this.playerEntityList.size(); ++i)
    {
        this.writePlayerData((EntityPlayerMP)this.playerEntityList.get(i));
    }
}
 
Example 25
Project: CustomWorldGen   File: PlayerList.java   View source code 5 votes vote down vote up
public List<EntityPlayerMP> getPlayersMatchingAddress(String address)
{
    List<EntityPlayerMP> list = Lists.<EntityPlayerMP>newArrayList();

    for (EntityPlayerMP entityplayermp : this.playerEntityList)
    {
        if (entityplayermp.getPlayerIP().equals(address))
        {
            list.add(entityplayermp);
        }
    }

    return list;
}
 
Example 26
Project: pnc-repressurized   File: CommandGetGlobalVariable.java   View source code 5 votes vote down vote up
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
    if (sender instanceof EntityPlayerMP) {
        if (args.length != 1) throw new WrongUsageException("command.deliverAmazon.args");
        String varName = args[0].startsWith("#") ? args[0].substring(1) : args[0];
        BlockPos pos = GlobalVariableManager.getInstance().getPos(varName);
        ItemStack stack = GlobalVariableManager.getInstance().getItem(varName);
        NetworkHandler.sendTo(new PacketCommandGetGlobalVariableOutput(varName, pos, stack), (EntityPlayerMP) sender);
    }
}
 
Example 27
Project: CraftingParadiseMod   File: EntityHandler.java   View source code 5 votes vote down vote up
@SubscribeEvent()
public void onJoinWorld(EntityJoinWorldEvent event)
{
    Entity entity = event.getEntity();
    if(entity instanceof EntityPlayer)
    {
        if(event.getWorld() != null)
        {
            if(!event.getWorld().isRemote) //Server-side
            {
                CraftingParadiseSaveData.get(event.getWorld());
                PlanetModule core = ActivePlanet.coreModule;
                PlanetModule mantle = ActivePlanet.mantleModule;
                PlanetModule crust = ActivePlanet.crustModule;
                PlanetModule land = ActivePlanet.landscapeModule;
                PlanetModule worldType = ActivePlanet.worldModule;
                PlanetModule atmos = ActivePlanet.atmosphereModule;

                int coreID = core == null ? -1 : core.moduleId;
                int mantleID = mantle == null ? -1 : mantle.moduleId;
                int crustID = crust == null ? -1 : crust.moduleId;
                int landID = land == null ? -1 : land.moduleId;
                int worldTypeID = worldType == null ? -1 : worldType.moduleId;
                int atmosID = atmos == null ? -1 : atmos.moduleId;

                PacketHandler.INSTANCE.sendTo(new MessageClientPlanetChange(coreID, mantleID, crustID, landID, worldTypeID, atmosID), (EntityPlayerMP) entity);
            }
        }
    }
}
 
Example 28
Project: Proyecto-DASI   File: JSONWorldDataHelper.java   View source code 5 votes vote down vote up
/** Builds the basic life world data to be used as observation signals by the listener.
 * @param json a JSON object into which the life stats will be added.
 */
public static void buildLifeStats(JsonObject json, EntityPlayerMP player)
{
    json.addProperty("Life", player.getHealth());
    json.addProperty("Score", player.getScore());    // Might always be the same as XP?
    json.addProperty("Food", player.getFoodStats().getFoodLevel());
    json.addProperty("XP", player.experienceTotal);
    json.addProperty("IsAlive", !player.isDead);
    json.addProperty("Air", player.getAir());
    json.addProperty("Name", player.getName());
}
 
Example 29
Project: ExPetrum   File: ExPPlayer.java   View source code 5 votes vote down vote up
public static ExPPlayer createDefaultWithOwner(final EntityPlayer owner)
{
	final ExPPlayer defaultImpl = createDefault();
	defaultImpl.owner = owner;
	defaultImpl.isRemote = !(owner instanceof EntityPlayerMP);
	return defaultImpl;
}
 
Example 30
Project: Backmemed   File: WorldServer.java   View source code 5 votes vote down vote up
private void sendPacketWithinDistance(EntityPlayerMP player, boolean longDistance, double x, double y, double z, Packet<?> packetIn)
{
    BlockPos blockpos = player.getPosition();
    double d0 = blockpos.distanceSq(x, y, z);

    if (d0 <= 1024.0D || longDistance && d0 <= 262144.0D)
    {
        player.connection.sendPacket(packetIn);
    }
}
 
Example 31
Project: Proyecto-DASI   File: ObservationFromFullStatsImplementation.java   View source code 5 votes vote down vote up
@Override
void buildJson(JsonObject json, EntityPlayerMP player, ObservationRequestMessage message, MessageContext ctx)
{
    JSONWorldDataHelper.buildAchievementStats(json, player);
    JSONWorldDataHelper.buildLifeStats(json, player);
    JSONWorldDataHelper.buildPositionStats(json, player);
    JSONWorldDataHelper.buildEnvironmentStats(json, player);
}
 
Example 32
Project: VillagerInventory   File: ModConfiguration.java   View source code 5 votes vote down vote up
@SubscribeEvent
public static void onPlayerLoggedIn(PlayerLoggedInEvent event)
{
	if (!event.player.world.isRemote)
	{
		VillagerInventoryMod.NETWORK.sendTo(new ConfigSyncMessage(), (EntityPlayerMP)event.player);
	}
}
 
Example 33
Project: pnc-repressurized   File: ItemAmadronTablet.java   View source code 5 votes vote down vote up
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) {
    if (handIn != EnumHand.MAIN_HAND) return ActionResult.newResult(EnumActionResult.PASS, playerIn.getHeldItem(handIn));
    if (!worldIn.isRemote) {
        NetworkHandler.sendTo(new PacketSyncAmadronOffers(AmadronOfferManager.getInstance().getAllOffers()), (EntityPlayerMP) playerIn);
        playerIn.openGui(PneumaticCraftRepressurized.instance, EnumGuiId.AMADRON.ordinal(), playerIn.world, (int) playerIn.posX, (int) playerIn.posY, (int) playerIn.posZ);
    }
    return ActionResult.newResult(EnumActionResult.SUCCESS, playerIn.getHeldItemMainhand());
}
 
Example 34
Project: pnc-repressurized   File: TubeModule.java   View source code 5 votes vote down vote up
public boolean onActivated(EntityPlayer player) {
    if (!player.world.isRemote && upgraded && getGuiId() != null) {
        NetworkHandler.sendTo(new PacketOpenTubeModuleGui(getGuiId().ordinal(), pressureTube.pos()), (EntityPlayerMP) player);
        return true;
    }
    return false;
}
 
Example 35
Project: minecraft-quiverbow   File: NetHelper.java   View source code 5 votes vote down vote up
public static void sendKickbackMessage(Entity user, byte strength)
{
	if (user instanceof EntityPlayerMP)
	{
		IMessage msg = new KickbackMessage(strength);
		PacketHandler.net.sendTo(msg, (EntityPlayerMP) user);
	}
}
 
Example 36
Project: pnc-repressurized   File: TileEntityProgrammableController.java   View source code 5 votes vote down vote up
@Override
public EntityPlayerMP getFakePlayer() {
    if (fakePlayer == null) initializeFakePlayer();
    if (droneItems != null) {
        for (int i = 0; i < droneItems.getSlots(); i++) {
            fakePlayer.inventory.setInventorySlotContents(i, droneItems.getStackInSlot(i).copy());
        }
        droneItems = null;
    }
    return fakePlayer;
}
 
Example 37
Project: BaseClient   File: EntityTrackerEntry.java   View source code 5 votes vote down vote up
/**
 * Remove a tracked player from our list and tell the tracked player to destroy us from their world.
 */
public void removeTrackedPlayerSymmetric(EntityPlayerMP playerMP)
{
    if (this.trackingPlayers.contains(playerMP))
    {
        this.trackingPlayers.remove(playerMP);
        playerMP.removeEntity(this.trackedEntity);
    }
}
 
Example 38
Project: Scripty   File: ScriptyBlock.java   View source code 5 votes vote down vote up
public void parse() {
    if (isParsing() || owner == null) {
        System.out.println("not parsing because no owner/already parsing");
        return;
    }
    setParsing(true);
    ListenableFuture<Object> future = owner.getServer().addScheduledTask(() -> {
        try {
            String content = getContent();
            ScriptLanguage language = getLanguage();
            if (language.getEngine() == null) {
                System.out.println("WARNING: " + language + " has no engine associated.");
            } else {
                language.getEngine().eval(content);
            }
        } catch (ScriptException e) {
            throw new RuntimeException(e);
        }
    });
    Futures.addCallback(future, new FutureCallback<Object>() {
        @Override
        public void onSuccess(@Nullable Object result) {
            setParsing(false);
            if (owner != null) {
                ScriptyNetworkHandler.sendContentMessage((EntityPlayerMP) owner, pos, content, language, parsing);
            }
        }

        @Override
        public void onFailure(Throwable t) {
            setParsing(false);
            if (owner != null) {
                ScriptyNetworkHandler.sendContentMessage((EntityPlayerMP) owner, pos, content, language, parsing);
            }
        }
    });
}
 
Example 39
Project: BaseClient   File: EntityTracker.java   View source code 5 votes vote down vote up
public void removePlayerFromTrackers(EntityPlayerMP p_72787_1_)
{
    for (EntityTrackerEntry entitytrackerentry : this.trackedEntities)
    {
        entitytrackerentry.removeTrackedPlayerSymmetric(p_72787_1_);
    }
}
 
Example 40
Project: Minecoprocessors   File: MessageProcessorAction.java   View source code 5 votes vote down vote up
@Override
public IMessage onMessage(final MessageProcessorAction message, MessageContext ctx) {
  if (message.action == null) {
    return null;
  }
  final EntityPlayerMP payer = ctx.getServerHandler().player;
  payer.getServerWorld().addScheduledTask(new Worker(payer, message));
  return null;
}