Search in sources :

Example 56 with GameProfile

use of com.mojang.authlib.GameProfile in project Pearcel-Mod by MiningMark48.

the class TileEntityPearcelBeacon method update.

@Override
public void update() {
    Random rand = new Random();
    World world = getWorld();
    BlockPos pos = getPos();
    int x = pos.getX();
    int y = pos.getY();
    int z = pos.getZ();
    int range = ConfigurationHandler.pearcelBeaconRange;
    float damage = ConfigurationHandler.pearcelBeaconDamage;
    if (!world.isBlockPowered(pos)) {
        isActive = true;
        int num = rand.nextInt(2);
        switch(num) {
            default:
                break;
            case 0:
                world.spawnParticle(EnumParticleTypes.SPELL_MOB, x + 0.5, y + 1.875, z + 0.5, 4.47368D, 1.0D, 0.0D);
                break;
        }
        List<EntityPlayer> players = world.getEntitiesWithinAABB(EntityPlayer.class, new AxisAlignedBB(x - range, y - range, z - range, x + range, y + range, z + range));
        List<EntityCreature> mobs = world.getEntitiesWithinAABB(EntityCreature.class, new AxisAlignedBB(x - range, y - range, z - range, x + range, y + range, z + range));
        for (EntityPlayer e : players) {
            e.addPotionEffect(new PotionEffect(MobEffects.SPEED, 200, 0, true, false));
            e.addPotionEffect(new PotionEffect(MobEffects.JUMP_BOOST, 200, 0, true, false));
            e.addPotionEffect(new PotionEffect(MobEffects.ABSORPTION, 200, 0, true, false));
            e.addPotionEffect(new PotionEffect(MobEffects.RESISTANCE, 200, 0, true, false));
        }
        for (EntityCreature e : mobs) {
            if (e.isCreatureType(EnumCreatureType.MONSTER, false)) {
                int num2 = rand.nextInt(10);
                if (num2 == 0) {
                    if (fakePlayer == null) {
                        if (!world.isRemote) {
                            fakePlayer = FakePlayerFactory.get((WorldServer) world, new GameProfile(UUID.randomUUID(), ModBlocks.pearcel_beacon.getLocalizedName()));
                        }
                    }
                    if (e.getMaxHealth() >= 100) {
                        e.attackEntityFrom(DamageSource.causePlayerDamage(fakePlayer), damage * 15);
                    } else {
                        e.attackEntityFrom(DamageSource.causePlayerDamage(fakePlayer), damage);
                    }
                }
                world.spawnParticle(EnumParticleTypes.SPELL_MOB, e.posX, e.posY + 0.5, e.posZ, 1.0D, 0.0D, 0.0D);
            }
        }
    } else {
        isActive = false;
    }
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) PotionEffect(net.minecraft.potion.PotionEffect) WorldServer(net.minecraft.world.WorldServer) World(net.minecraft.world.World) Random(java.util.Random) GameProfile(com.mojang.authlib.GameProfile) EntityPlayer(net.minecraft.entity.player.EntityPlayer) BlockPos(net.minecraft.util.math.BlockPos) EntityCreature(net.minecraft.entity.EntityCreature)

Example 57 with GameProfile

use of com.mojang.authlib.GameProfile in project minecolonies by Minecolonies.

the class Permissions method restoreOwnerIfNull.

/**
     * Restores the owner from other variables if he is null on loading.
     */
public void restoreOwnerIfNull() {
    final Map.Entry<UUID, Player> owner = getOwnerEntry();
    if (owner == null && ownerUUID != null) {
        final GameProfile player = FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerProfileCache().getProfileByUUID(ownerUUID);
        if (player != null) {
            players.put(ownerUUID, new Player(ownerUUID, player.getName(), Rank.OWNER));
        }
    }
    markDirty();
}
Also used : Player(com.minecolonies.api.colony.permissions.Player) EntityPlayer(net.minecraft.entity.player.EntityPlayer) GameProfile(com.mojang.authlib.GameProfile)

Example 58 with GameProfile

use of com.mojang.authlib.GameProfile in project Railcraft by Railcraft.

the class ItemLocomotive method addInformation.

//    @Override
//    @SideOnly(Side.CLIENT)
//    public IIcon getIcon(ItemStack stack, int pass) {
//        String rendererTag = getModel(stack);
//        LocomotiveModelRenderer renderer = renderType.getRenderer(rendererTag);
//        if (renderer == null)
//            return RenderTools.getMissingTexture();
//        IIcon[] icons = renderer.getItemIcons();
//        if (pass >= icons.length || icons[pass] == null)
//            return blankIcon;
//        return renderer.getItemIcons()[pass];
//    }
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List<String> info, boolean adv) {
    super.addInformation(stack, player, info, adv);
    GameProfile owner = getOwner(stack);
    if (owner.getName() != null && !owner.getName().equals("[Unknown]")) {
        String format = LocalizationPlugin.translate("gui.railcraft.locomotive.tips.item.owner");
        info.add(String.format(format, owner.getName()));
    }
    String model = getModel(stack);
    LocomotiveModelRenderer renderer = renderType.getRenderer(model);
    String modelName;
    if (renderer != null)
        modelName = renderer.getDisplayName();
    else
        modelName = LocalizationPlugin.translate("gui.railcraft.locomotive.tips.item.model.default");
    String format = LocalizationPlugin.translate("gui.railcraft.locomotive.tips.item.model");
    info.add(String.format(format, modelName));
    EnumColor primary = getPrimaryColor(stack);
    format = LocalizationPlugin.translate("gui.railcraft.locomotive.tips.item.primary");
    info.add(String.format(format, primary.getTranslatedName()));
    EnumColor secondary = getSecondaryColor(stack);
    format = LocalizationPlugin.translate("gui.railcraft.locomotive.tips.item.secondary");
    info.add(String.format(format, secondary.getTranslatedName()));
    float whistle = getWhistlePitch(stack);
    format = LocalizationPlugin.translate("gui.railcraft.locomotive.tips.item.whistle");
    info.add(String.format(format, whistle < 0 ? "???" : String.format("%.2f", whistle)));
    String emblemIdent = getEmblem(stack);
    if (emblemIdent != null && !emblemIdent.isEmpty() && EmblemToolsClient.packageManager != null) {
        Emblem emblem = EmblemToolsClient.packageManager.getEmblem(emblemIdent);
        if (emblem != null) {
            format = LocalizationPlugin.translate("gui.railcraft.locomotive.tips.item.emblem");
            info.add(String.format(format, emblem.displayName));
        }
    }
}
Also used : EnumColor(mods.railcraft.common.plugins.color.EnumColor) GameProfile(com.mojang.authlib.GameProfile) Emblem(mods.railcraft.client.emblems.Emblem) LocomotiveModelRenderer(mods.railcraft.api.carts.locomotive.LocomotiveModelRenderer)

Example 59 with GameProfile

use of com.mojang.authlib.GameProfile in project BKCommonLib by bergerhealer.

the class CommonUtil method getGameProfile.

/**
     * Get the game profile from a name.
     *
     * @param name to get game profile from.
     * @return Player's GameProfile, OfflinePlayer profile used if player not
     * found.
     */
public static GameProfile getGameProfile(String name) {
    Player player = Bukkit.getPlayer(name);
    if (player != null) {
        //The right way
        return PlayerUtil.getGameProfile(player);
    }
    UUID uuid = UUID.nameUUIDFromBytes(("OfflinePlayer:" + name).getBytes(Charsets.UTF_8));
    return new GameProfile(uuid, name);
}
Also used : Player(org.bukkit.entity.Player) GameProfile(com.mojang.authlib.GameProfile)

Aggregations

GameProfile (com.mojang.authlib.GameProfile)59 Property (com.mojang.authlib.properties.Property)28 PlayerProfile (net.aufdemrand.denizen.nms.util.PlayerProfile)16 UUID (java.util.UUID)11 EntityPlayer (net.minecraft.entity.player.EntityPlayer)6 BigInteger (java.math.BigInteger)4 MessageDigest (java.security.MessageDigest)4 Player (com.minecolonies.api.colony.permissions.Player)3 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)3 WorldServer (net.minecraft.world.WorldServer)3 Scoreboard (org.bukkit.scoreboard.Scoreboard)3 Team (org.bukkit.scoreboard.Team)3 FakeDedicatedServer (com.builtbroken.mc.testing.junit.server.FakeDedicatedServer)2 TestPlayer (com.builtbroken.mc.testing.junit.testers.TestPlayer)2 File (java.io.File)2 NBTTagList (net.minecraft.nbt.NBTTagList)2 NBTTagString (net.minecraft.nbt.NBTTagString)2 NetHandlerPlayServer (net.minecraft.network.NetHandlerPlayServer)2 NetworkManager (net.minecraft.network.NetworkManager)2 PotionEffect (net.minecraft.potion.PotionEffect)2