Search in sources :

Example 91 with EntityPlayerMP

use of net.minecraft.entity.player.EntityPlayerMP in project MorePlanets by SteveKunG.

the class SlotBlackHoleStorageSchematic method onSlotChanged.

@Override
public void onSlotChanged() {
    if (this.player instanceof EntityPlayerMP) {
        int dimID = GCCoreUtil.getDimensionID(this.player.world);
        GCCoreUtil.sendToAllAround(new PacketSimple(EnumSimplePacket.C_SPAWN_SPARK_PARTICLES, dimID, new Object[] { this.pos }), this.player.world, dimID, this.pos, 20);
    }
}
Also used : PacketSimple(micdoodle8.mods.galacticraft.core.network.PacketSimple) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP)

Example 92 with EntityPlayerMP

use of net.minecraft.entity.player.EntityPlayerMP in project SecurityCraft by Geforce132.

the class BlockPortableRadar method searchForPlayers.

public static void searchForPlayers(World par1World, int par2, int par3, int par4, double searchRadius) {
    if (!par1World.isRemote) {
        double d0 = (searchRadius);
        AxisAlignedBB axisalignedbb = AxisAlignedBB.getBoundingBox(par2, par3, par4, par2 + 1, par3 + 1, par4 + 1).expand(d0, d0, d0);
        axisalignedbb.maxY = par1World.getHeight();
        List<?> list = par1World.getEntitiesWithinAABB(EntityPlayer.class, axisalignedbb);
        Iterator<?> iterator = list.iterator();
        EntityPlayer entityplayer;
        if (list.isEmpty())
            if (par1World.getTileEntity(par2, par3, par4) != null && par1World.getTileEntity(par2, par3, par4) instanceof TileEntityPortableRadar && ((CustomizableSCTE) par1World.getTileEntity(par2, par3, par4)).hasModule(EnumCustomModules.REDSTONE) && par1World.getBlockMetadata(par2, par3, par4) == 1) {
                togglePowerOutput(par1World, par2, par3, par4, false);
                return;
            }
        while (iterator.hasNext()) {
            EntityPlayerMP entityplayermp = MinecraftServer.getServer().getConfigurationManager().getPlayerByUsername(((TileEntityPortableRadar) par1World.getTileEntity(par2, par3, par4)).getOwner().getName());
            entityplayer = (EntityPlayer) iterator.next();
            if (par1World.getTileEntity(par2, par3, par4) == null || !(par1World.getTileEntity(par2, par3, par4) instanceof CustomizableSCTE))
                continue;
            if (((CustomizableSCTE) par1World.getTileEntity(par2, par3, par4)).hasModule(EnumCustomModules.WHITELIST) && ModuleUtils.getPlayersFromModule(par1World, par2, par3, par4, EnumCustomModules.WHITELIST).contains(entityplayermp.getCommandSenderName().toLowerCase()))
                continue;
            if (PlayerUtils.isPlayerOnline(((TileEntityPortableRadar) par1World.getTileEntity(par2, par3, par4)).getOwner().getName())) {
                if (!((TileEntityPortableRadar) par1World.getTileEntity(par2, par3, par4)).shouldSendMessage(entityplayer))
                    continue;
                PlayerUtils.sendMessageToPlayer(entityplayermp, StatCollector.translateToLocal("tile.portableRadar.name"), ((INameable) par1World.getTileEntity(par2, par3, par4)).hasCustomName() ? (StatCollector.translateToLocal("messages.portableRadar.withName").replace("#p", EnumChatFormatting.ITALIC + entityplayer.getCommandSenderName() + EnumChatFormatting.RESET).replace("#n", EnumChatFormatting.ITALIC + ((INameable) par1World.getTileEntity(par2, par3, par4)).getCustomName() + EnumChatFormatting.RESET)) : (StatCollector.translateToLocal("messages.portableRadar.withoutName").replace("#p", EnumChatFormatting.ITALIC + entityplayer.getCommandSenderName() + EnumChatFormatting.RESET).replace("#l", Utils.getFormattedCoordinates(par2, par3, par4))), EnumChatFormatting.BLUE);
                ((TileEntityPortableRadar) par1World.getTileEntity(par2, par3, par4)).setSentMessage();
            }
            if (par1World.getTileEntity(par2, par3, par4) != null && par1World.getTileEntity(par2, par3, par4) instanceof TileEntityPortableRadar && ((CustomizableSCTE) par1World.getTileEntity(par2, par3, par4)).hasModule(EnumCustomModules.REDSTONE))
                togglePowerOutput(par1World, par2, par3, par4, true);
        }
    }
}
Also used : AxisAlignedBB(net.minecraft.util.AxisAlignedBB) CustomizableSCTE(net.geforcemods.securitycraft.api.CustomizableSCTE) INameable(net.geforcemods.securitycraft.api.INameable) TileEntityPortableRadar(net.geforcemods.securitycraft.tileentity.TileEntityPortableRadar) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP)

Example 93 with EntityPlayerMP

use of net.minecraft.entity.player.EntityPlayerMP in project SecurityCraft by Geforce132.

the class BlockPortableRadar method searchForPlayers.

public static void searchForPlayers(World par1World, BlockPos pos, IBlockState state) {
    if (!par1World.isRemote) {
        double d0 = (SecurityCraft.config.portableRadarSearchRadius);
        AxisAlignedBB axisalignedbb = AxisAlignedBB.fromBounds(pos.getX(), pos.getY(), pos.getZ(), pos.getX() + 1, pos.getY() + 1, pos.getZ() + 1).expand(d0, d0, d0).addCoord(0.0D, par1World.getHeight(), 0.0D);
        List<?> list = par1World.getEntitiesWithinAABB(EntityPlayer.class, axisalignedbb);
        Iterator<?> iterator = list.iterator();
        EntityPlayer entityplayer;
        if (list.isEmpty())
            if (par1World.getTileEntity(pos) != null && par1World.getTileEntity(pos) instanceof TileEntityPortableRadar && ((CustomizableSCTE) par1World.getTileEntity(pos)).hasModule(EnumCustomModules.REDSTONE) && ((Boolean) state.getValue(POWERED)).booleanValue()) {
                togglePowerOutput(par1World, pos, false);
                return;
            }
        if (!((CustomizableSCTE) par1World.getTileEntity(pos)).hasModule(EnumCustomModules.REDSTONE))
            togglePowerOutput(par1World, pos, false);
        while (iterator.hasNext()) {
            EntityPlayerMP entityplayermp = MinecraftServer.getServer().getConfigurationManager().getPlayerByUsername(((TileEntityPortableRadar) par1World.getTileEntity(pos)).getOwner().getName());
            entityplayer = (EntityPlayer) iterator.next();
            if (entityplayermp != null && ((CustomizableSCTE) par1World.getTileEntity(pos)).hasModule(EnumCustomModules.WHITELIST) && ModuleUtils.getPlayersFromModule(par1World, pos, EnumCustomModules.WHITELIST).contains(entityplayermp.getCommandSenderName().toLowerCase()))
                continue;
            if (PlayerUtils.isPlayerOnline(((TileEntityPortableRadar) par1World.getTileEntity(pos)).getOwner().getName())) {
                if (!((TileEntityPortableRadar) par1World.getTileEntity(pos)).shouldSendMessage(entityplayer))
                    continue;
                PlayerUtils.sendMessageToPlayer(entityplayermp, StatCollector.translateToLocal("tile.portableRadar.name"), ((INameable) par1World.getTileEntity(pos)).hasCustomName() ? (StatCollector.translateToLocal("messages.portableRadar.withName").replace("#p", EnumChatFormatting.ITALIC + entityplayer.getCommandSenderName() + EnumChatFormatting.RESET).replace("#n", EnumChatFormatting.ITALIC + ((INameable) par1World.getTileEntity(pos)).getCustomName() + EnumChatFormatting.RESET)) : (StatCollector.translateToLocal("messages.portableRadar.withoutName").replace("#p", EnumChatFormatting.ITALIC + entityplayer.getCommandSenderName() + EnumChatFormatting.RESET).replace("#l", Utils.getFormattedCoordinates(pos))), EnumChatFormatting.BLUE);
                ((TileEntityPortableRadar) par1World.getTileEntity(pos)).setSentMessage();
            }
            if (par1World.getTileEntity(pos) != null && par1World.getTileEntity(pos) instanceof TileEntityPortableRadar && ((CustomizableSCTE) par1World.getTileEntity(pos)).hasModule(EnumCustomModules.REDSTONE))
                togglePowerOutput(par1World, pos, true);
        }
    }
}
Also used : AxisAlignedBB(net.minecraft.util.AxisAlignedBB) CustomizableSCTE(net.geforcemods.securitycraft.api.CustomizableSCTE) INameable(net.geforcemods.securitycraft.api.INameable) TileEntityPortableRadar(net.geforcemods.securitycraft.tileentity.TileEntityPortableRadar) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP)

Example 94 with EntityPlayerMP

use of net.minecraft.entity.player.EntityPlayerMP in project Almura by AlmuraDev.

the class ServerNickManager method onChangeNickname.

@Listener(order = Order.POST)
public void onChangeNickname(final NucleusChangeNicknameEvent event, @Getter("getTargetUser") final Player player) throws IllegalAccessException {
    final EntityPlayerMP mcPlayer = (EntityPlayerMP) player;
    final String oldNick = mcPlayer.getDisplayNameString();
    final String newNick = TextSerializers.LEGACY_FORMATTING_CODE.serialize(event.getNewNickname());
    if (!oldNick.equals(newNick)) {
        // Tell the Forge mods
        final String modNick = ForgeEventFactory.getPlayerDisplayName(mcPlayer, newNick);
        final Text finalNick = TextSerializers.LEGACY_FORMATTING_CODE.deserialize(modNick);
        if (!newNick.equals(modNick)) {
            // Mod says our nick needs to be something else
            this.game.getServiceManager().provide(NucleusNicknameService.class).ifPresent((service) -> {
                try {
                    service.setNickname(player, finalNick);
                } catch (NicknameException e) {
                    e.printStackTrace();
                }
            });
        }
        displayNameField.set(mcPlayer, modNick);
        // Tell everyone about the new nick
        this.network.sendToAll(this.getMappingMessage(player, Text.of("~" + finalNick.toPlain())));
    }
}
Also used : NucleusNicknameService(io.github.nucleuspowered.nucleus.api.service.NucleusNicknameService) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) Text(org.spongepowered.api.text.Text) NicknameException(io.github.nucleuspowered.nucleus.api.exceptions.NicknameException) Listener(org.spongepowered.api.event.Listener)

Example 95 with EntityPlayerMP

use of net.minecraft.entity.player.EntityPlayerMP in project Almura by AlmuraDev.

the class SignEditFeature method interact.

@Listener
public void interact(final InteractBlockEvent.Secondary.MainHand event, @Root final Player player) {
    if (!(player instanceof EntityPlayerMP) || !player.require(Keys.IS_SNEAKING)) {
        return;
    }
    final BlockSnapshot snapshot = event.getTargetBlock();
    final BlockType type = snapshot.getState().getType();
    if (type == BlockTypes.STANDING_SIGN || type == BlockTypes.WALL_SIGN) {
        snapshot.getLocation().flatMap(Location::getTileEntity).ifPresent((be) -> {
            if (be instanceof TileEntitySign) {
                ((EntityPlayerMP) player).connection.sendPacket(new SPacketSignEditorOpen(VecHelper.toBlockPos(snapshot.getPosition())));
            }
        });
    }
}
Also used : TileEntitySign(net.minecraft.tileentity.TileEntitySign) SPacketSignEditorOpen(net.minecraft.network.play.server.SPacketSignEditorOpen) BlockType(org.spongepowered.api.block.BlockType) BlockSnapshot(org.spongepowered.api.block.BlockSnapshot) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) Listener(org.spongepowered.api.event.Listener)

Aggregations

EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)163 EntityPlayer (net.minecraft.entity.player.EntityPlayer)32 ItemStack (net.minecraft.item.ItemStack)23 TileEntity (net.minecraft.tileentity.TileEntity)18 Entity (net.minecraft.entity.Entity)17 EntityLivingBase (net.minecraft.entity.EntityLivingBase)15 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)15 ChatComponentTranslation (net.minecraft.util.ChatComponentTranslation)14 BlockPos (net.minecraft.util.math.BlockPos)14 Block (net.minecraft.block.Block)11 IBlockState (net.minecraft.block.state.IBlockState)8 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)8 World (net.minecraft.world.World)8 WrongUsageException (net.minecraft.command.WrongUsageException)7 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)7 NetHandlerPlayServer (net.minecraft.network.NetHandlerPlayServer)7 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)6 TrainPacket (club.nsdn.nyasamarailway.network.TrainPacket)5 TileEntityReceiver (club.nsdn.nyasamatelecom.api.tileentity.TileEntityReceiver)5 GenericStructure (ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure)5