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;
}
}
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();
}
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));
}
}
}
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);
}
Aggregations