本文整理汇总了Java中net.minecraft.util.StringUtils.isNullOrEmpty方法的典型用法代码示例。如果您正苦于以下问题:Java StringUtils.isNullOrEmpty方法的具体用法?Java StringUtils.isNullOrEmpty怎么用?Java StringUtils.isNullOrEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.util.StringUtils
的用法示例。
在下文中一共展示了StringUtils.isNullOrEmpty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleUpdateScore
import net.minecraft.util.StringUtils; //导入方法依赖的package包/类
/**
* Either updates the score with a specified value or removes the score for an objective
*/
public void handleUpdateScore(SPacketUpdateScore packetIn)
{
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
Scoreboard scoreboard = this.clientWorldController.getScoreboard();
ScoreObjective scoreobjective = scoreboard.getObjective(packetIn.getObjectiveName());
if (packetIn.getScoreAction() == SPacketUpdateScore.Action.CHANGE)
{
Score score = scoreboard.getOrCreateScore(packetIn.getPlayerName(), scoreobjective);
score.setScorePoints(packetIn.getScoreValue());
}
else if (packetIn.getScoreAction() == SPacketUpdateScore.Action.REMOVE)
{
if (StringUtils.isNullOrEmpty(packetIn.getObjectiveName()))
{
scoreboard.removeObjectiveFromEntity(packetIn.getPlayerName(), (ScoreObjective)null);
}
else if (scoreobjective != null)
{
scoreboard.removeObjectiveFromEntity(packetIn.getPlayerName(), scoreobjective);
}
}
}
示例2: handleUpdateScore
import net.minecraft.util.StringUtils; //导入方法依赖的package包/类
/**
* Either updates the score with a specified value or removes the score for an
* objective
*/
public void handleUpdateScore(S3CPacketUpdateScore packetIn) {
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
Scoreboard scoreboard = this.clientWorldController.getScoreboard();
ScoreObjective scoreobjective = scoreboard.getObjective(packetIn.getObjectiveName());
if (packetIn.getScoreAction() == S3CPacketUpdateScore.Action.CHANGE) {
Score score = scoreboard.getValueFromObjective(packetIn.getPlayerName(), scoreobjective);
score.setScorePoints(packetIn.getScoreValue());
} else if (packetIn.getScoreAction() == S3CPacketUpdateScore.Action.REMOVE) {
if (StringUtils.isNullOrEmpty(packetIn.getObjectiveName())) {
scoreboard.removeObjectiveFromEntity(packetIn.getPlayerName(), (ScoreObjective) null);
} else if (scoreobjective != null) {
scoreboard.removeObjectiveFromEntity(packetIn.getPlayerName(), scoreobjective);
}
}
}
示例3: save
import net.minecraft.util.StringUtils; //导入方法依赖的package包/类
public boolean save(boolean p_189712_1_)
{
if (this.mode == TileEntityStructure.Mode.SAVE && !this.world.isRemote && !StringUtils.isNullOrEmpty(this.name))
{
BlockPos blockpos = this.getPos().add(this.position);
WorldServer worldserver = (WorldServer)this.world;
MinecraftServer minecraftserver = this.world.getMinecraftServer();
TemplateManager templatemanager = worldserver.getStructureTemplateManager();
Template template = templatemanager.getTemplate(minecraftserver, new ResourceLocation(this.name));
template.takeBlocksFromWorld(this.world, blockpos, this.size, !this.ignoreEntities, Blocks.STRUCTURE_VOID);
template.setAuthor(this.author);
return !p_189712_1_ || templatemanager.writeTemplate(minecraftserver, new ResourceLocation(this.name));
}
else
{
return false;
}
}
示例4: getStringUUIDFromName
import net.minecraft.util.StringUtils; //导入方法依赖的package包/类
public static String getStringUUIDFromName(String p_152719_0_)
{
if (!StringUtils.isNullOrEmpty(p_152719_0_) && p_152719_0_.length() <= 16)
{
final MinecraftServer minecraftserver = MinecraftServer.getServer();
GameProfile gameprofile = minecraftserver.getPlayerProfileCache().getGameProfileForUsername(p_152719_0_);
if (gameprofile != null && gameprofile.getId() != null)
{
return gameprofile.getId().toString();
}
else if (!minecraftserver.isSinglePlayer() && minecraftserver.isServerInOnlineMode())
{
final List<GameProfile> list = Lists.<GameProfile>newArrayList();
ProfileLookupCallback profilelookupcallback = new ProfileLookupCallback()
{
public void onProfileLookupSucceeded(GameProfile p_onProfileLookupSucceeded_1_)
{
minecraftserver.getPlayerProfileCache().addEntry(p_onProfileLookupSucceeded_1_);
list.add(p_onProfileLookupSucceeded_1_);
}
public void onProfileLookupFailed(GameProfile p_onProfileLookupFailed_1_, Exception p_onProfileLookupFailed_2_)
{
PreYggdrasilConverter.LOGGER.warn((String)("Could not lookup user whitelist entry for " + p_onProfileLookupFailed_1_.getName()), (Throwable)p_onProfileLookupFailed_2_);
}
};
lookupNames(minecraftserver, Lists.newArrayList(new String[] {p_152719_0_}), profilelookupcallback);
return list.size() > 0 && ((GameProfile)list.get(0)).getId() != null ? ((GameProfile)list.get(0)).getId().toString() : "";
}
else
{
return EntityPlayer.getUUID(new GameProfile((UUID)null, p_152719_0_)).toString();
}
}
else
{
return p_152719_0_;
}
}
示例5: writeToNBT
import net.minecraft.util.StringUtils; //导入方法依赖的package包/类
public void writeToNBT(NBTTagCompound nbt)
{
String s = this.getEntityNameToSpawn();
if (!StringUtils.isNullOrEmpty(s))
{
nbt.setString("EntityId", s);
nbt.setShort("Delay", (short)this.spawnDelay);
nbt.setShort("MinSpawnDelay", (short)this.minSpawnDelay);
nbt.setShort("MaxSpawnDelay", (short)this.maxSpawnDelay);
nbt.setShort("SpawnCount", (short)this.spawnCount);
nbt.setShort("MaxNearbyEntities", (short)this.maxNearbyEntities);
nbt.setShort("RequiredPlayerRange", (short)this.activatingRangeFromPlayer);
nbt.setShort("SpawnRange", (short)this.spawnRange);
if (this.getRandomEntity() != null)
{
nbt.setTag("SpawnData", this.getRandomEntity().nbtData.copy());
}
if (this.getRandomEntity() != null || this.minecartToSpawn.size() > 0)
{
NBTTagList nbttaglist = new NBTTagList();
if (this.minecartToSpawn.size() > 0)
{
for (MobSpawnerBaseLogic.WeightedRandomMinecart mobspawnerbaselogic$weightedrandomminecart : this.minecartToSpawn)
{
nbttaglist.appendTag(mobspawnerbaselogic$weightedrandomminecart.toNBT());
}
}
else
{
nbttaglist.appendTag(this.getRandomEntity().toNBT());
}
nbt.setTag("SpawnPotentials", nbttaglist);
}
}
}
示例6: updateGameprofile
import net.minecraft.util.StringUtils; //导入方法依赖的package包/类
public static GameProfile updateGameprofile(GameProfile input)
{
if (input != null && !StringUtils.isNullOrEmpty(input.getName()))
{
if (input.isComplete() && input.getProperties().containsKey("textures"))
{
return input;
}
else if (MinecraftServer.getServer() == null)
{
return input;
}
else
{
GameProfile gameprofile = MinecraftServer.getServer().getPlayerProfileCache().getGameProfileForUsername(input.getName());
if (gameprofile == null)
{
return input;
}
else
{
Property property = (Property)Iterables.getFirst(gameprofile.getProperties().get("textures"), null);
if (property == null)
{
gameprofile = MinecraftServer.getServer().getMinecraftSessionService().fillProfileProperties(gameprofile, true);
}
return gameprofile;
}
}
}
else
{
return input;
}
}
示例7: getItemStackDisplayName
import net.minecraft.util.StringUtils; //导入方法依赖的package包/类
public String getItemStackDisplayName(ItemStack stack)
{
if (stack.hasTagCompound())
{
NBTTagCompound nbttagcompound = stack.getTagCompound();
String s = nbttagcompound.getString("title");
if (!StringUtils.isNullOrEmpty(s))
{
return s;
}
}
return super.getItemStackDisplayName(stack);
}
示例8: apply
import net.minecraft.util.StringUtils; //导入方法依赖的package包/类
public boolean apply(@Nullable String p_apply_1_)
{
if (StringUtils.isNullOrEmpty(p_apply_1_))
{
return true;
}
else
{
String[] astring = p_apply_1_.split(":");
if (astring.length == 0)
{
return true;
}
else
{
try
{
String s = IDN.toASCII(astring[0]);
return true;
}
catch (IllegalArgumentException var4)
{
return false;
}
}
}
}
示例9: convertMobOwnerIfNeeded
import net.minecraft.util.StringUtils; //导入方法依赖的package包/类
public static String convertMobOwnerIfNeeded(final MinecraftServer server, String username)
{
if (!StringUtils.isNullOrEmpty(username) && username.length() <= 16)
{
GameProfile gameprofile = server.getPlayerProfileCache().getGameProfileForUsername(username);
if (gameprofile != null && gameprofile.getId() != null)
{
return gameprofile.getId().toString();
}
else if (!server.isSinglePlayer() && server.isServerInOnlineMode())
{
final List<GameProfile> list = Lists.<GameProfile>newArrayList();
ProfileLookupCallback profilelookupcallback = new ProfileLookupCallback()
{
public void onProfileLookupSucceeded(GameProfile p_onProfileLookupSucceeded_1_)
{
server.getPlayerProfileCache().addEntry(p_onProfileLookupSucceeded_1_);
list.add(p_onProfileLookupSucceeded_1_);
}
public void onProfileLookupFailed(GameProfile p_onProfileLookupFailed_1_, Exception p_onProfileLookupFailed_2_)
{
PreYggdrasilConverter.LOGGER.warn("Could not lookup user whitelist entry for {}", new Object[] {p_onProfileLookupFailed_1_.getName(), p_onProfileLookupFailed_2_});
}
};
lookupNames(server, Lists.newArrayList(new String[] {username}), profilelookupcallback);
return !list.isEmpty() && ((GameProfile)list.get(0)).getId() != null ? ((GameProfile)list.get(0)).getId().toString() : "";
}
else
{
return EntityPlayer.getUUID(new GameProfile((UUID)null, username)).toString();
}
}
else
{
return username;
}
}
示例10: readGameProfileFromNBT
import net.minecraft.util.StringUtils; //导入方法依赖的package包/类
/**
* Reads and returns a GameProfile that has been saved to the passed in NBTTagCompound
*/
public static GameProfile readGameProfileFromNBT(NBTTagCompound compound)
{
String s = null;
String s1 = null;
if (compound.hasKey("Name", 8))
{
s = compound.getString("Name");
}
if (compound.hasKey("Id", 8))
{
s1 = compound.getString("Id");
}
if (StringUtils.isNullOrEmpty(s) && StringUtils.isNullOrEmpty(s1))
{
return null;
}
else
{
UUID uuid;
try
{
uuid = UUID.fromString(s1);
}
catch (Throwable var12)
{
uuid = null;
}
GameProfile gameprofile = new GameProfile(uuid, s);
if (compound.hasKey("Properties", 10))
{
NBTTagCompound nbttagcompound = compound.getCompoundTag("Properties");
for (String s2 : nbttagcompound.getKeySet())
{
NBTTagList nbttaglist = nbttagcompound.getTagList(s2, 10);
for (int i = 0; i < nbttaglist.tagCount(); ++i)
{
NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);
String s3 = nbttagcompound1.getString("Value");
if (nbttagcompound1.hasKey("Signature", 8))
{
gameprofile.getProperties().put(s2, new Property(s2, s3, nbttagcompound1.getString("Signature")));
}
else
{
gameprofile.getProperties().put(s2, new Property(s2, s3));
}
}
}
}
return gameprofile;
}
}
示例11: writeGameProfile
import net.minecraft.util.StringUtils; //导入方法依赖的package包/类
/**
* Writes a GameProfile to an NBTTagCompound.
*/
public static NBTTagCompound writeGameProfile(NBTTagCompound tagCompound, GameProfile profile)
{
if (!StringUtils.isNullOrEmpty(profile.getName()))
{
tagCompound.setString("Name", profile.getName());
}
if (profile.getId() != null)
{
tagCompound.setString("Id", profile.getId().toString());
}
if (!profile.getProperties().isEmpty())
{
NBTTagCompound nbttagcompound = new NBTTagCompound();
for (String s : profile.getProperties().keySet())
{
NBTTagList nbttaglist = new NBTTagList();
for (Property property : profile.getProperties().get(s))
{
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
nbttagcompound1.setString("Value", property.getValue());
if (property.hasSignature())
{
nbttagcompound1.setString("Signature", property.getSignature());
}
nbttaglist.appendTag(nbttagcompound1);
}
nbttagcompound.setTag(s, nbttaglist);
}
tagCompound.setTag("Properties", nbttagcompound);
}
return tagCompound;
}
示例12: updateTick
import net.minecraft.util.StringUtils; //导入方法依赖的package包/类
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
if (!worldIn.isRemote)
{
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof TileEntityCommandBlock)
{
TileEntityCommandBlock tileentitycommandblock = (TileEntityCommandBlock)tileentity;
CommandBlockBaseLogic commandblockbaselogic = tileentitycommandblock.getCommandBlockLogic();
boolean flag = !StringUtils.isNullOrEmpty(commandblockbaselogic.getCommand());
TileEntityCommandBlock.Mode tileentitycommandblock$mode = tileentitycommandblock.getMode();
boolean flag1 = !tileentitycommandblock.isConditional() || this.isNextToSuccessfulCommandBlock(worldIn, pos, state);
boolean flag2 = tileentitycommandblock.isConditionMet();
boolean flag3 = false;
if (tileentitycommandblock$mode != TileEntityCommandBlock.Mode.SEQUENCE && flag2 && flag)
{
commandblockbaselogic.trigger(worldIn);
flag3 = true;
}
if (tileentitycommandblock.isPowered() || tileentitycommandblock.isAuto())
{
if (tileentitycommandblock$mode == TileEntityCommandBlock.Mode.SEQUENCE && flag1 && flag)
{
commandblockbaselogic.trigger(worldIn);
flag3 = true;
}
if (tileentitycommandblock$mode == TileEntityCommandBlock.Mode.AUTO)
{
worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn));
if (flag1)
{
this.propagateUpdate(worldIn, pos);
}
}
}
if (!flag3)
{
commandblockbaselogic.setSuccessCount(0);
}
tileentitycommandblock.setConditionMet(flag1);
worldIn.updateComparatorOutputLevel(pos, this);
}
}
}
示例13: readGameProfileFromNBT
import net.minecraft.util.StringUtils; //导入方法依赖的package包/类
/**
* Reads and returns a GameProfile that has been saved to the passed in NBTTagCompound
*/
@Nullable
public static GameProfile readGameProfileFromNBT(NBTTagCompound compound)
{
String s = null;
String s1 = null;
if (compound.hasKey("Name", 8))
{
s = compound.getString("Name");
}
if (compound.hasKey("Id", 8))
{
s1 = compound.getString("Id");
}
if (StringUtils.isNullOrEmpty(s) && StringUtils.isNullOrEmpty(s1))
{
return null;
}
else
{
UUID uuid;
try
{
uuid = UUID.fromString(s1);
}
catch (Throwable var12)
{
uuid = null;
}
GameProfile gameprofile = new GameProfile(uuid, s);
if (compound.hasKey("Properties", 10))
{
NBTTagCompound nbttagcompound = compound.getCompoundTag("Properties");
for (String s2 : nbttagcompound.getKeySet())
{
NBTTagList nbttaglist = nbttagcompound.getTagList(s2, 10);
for (int i = 0; i < nbttaglist.tagCount(); ++i)
{
NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);
String s3 = nbttagcompound1.getString("Value");
if (nbttagcompound1.hasKey("Signature", 8))
{
gameprofile.getProperties().put(s2, new Property(s2, s3, nbttagcompound1.getString("Signature")));
}
else
{
gameprofile.getProperties().put(s2, new Property(s2, s3));
}
}
}
}
return gameprofile;
}
}
示例14: doRenderLayer
import net.minecraft.util.StringUtils; //导入方法依赖的package包/类
public void doRenderLayer(EntityLivingBase entitylivingbaseIn, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale)
{
ItemStack itemstack = entitylivingbaseIn.getItemStackFromSlot(EntityEquipmentSlot.HEAD);
if (itemstack != null && itemstack.getItem() != null)
{
Item item = itemstack.getItem();
Minecraft minecraft = Minecraft.getMinecraft();
GlStateManager.pushMatrix();
if (entitylivingbaseIn.isSneaking())
{
GlStateManager.translate(0.0F, 0.2F, 0.0F);
}
boolean flag = entitylivingbaseIn instanceof EntityVillager || entitylivingbaseIn instanceof EntityZombie && ((EntityZombie)entitylivingbaseIn).isVillager();
if (entitylivingbaseIn.isChild() && !(entitylivingbaseIn instanceof EntityVillager))
{
float f = 2.0F;
float f1 = 1.4F;
GlStateManager.translate(0.0F, 0.5F * scale, 0.0F);
GlStateManager.scale(0.7F, 0.7F, 0.7F);
GlStateManager.translate(0.0F, 16.0F * scale, 0.0F);
}
this.modelRenderer.postRender(0.0625F);
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
if (item == Items.SKULL)
{
float f2 = 1.1875F;
GlStateManager.scale(1.1875F, -1.1875F, -1.1875F);
if (flag)
{
GlStateManager.translate(0.0F, 0.0625F, 0.0F);
}
GameProfile gameprofile = null;
if (itemstack.hasTagCompound())
{
NBTTagCompound nbttagcompound = itemstack.getTagCompound();
if (nbttagcompound.hasKey("SkullOwner", 10))
{
gameprofile = NBTUtil.readGameProfileFromNBT(nbttagcompound.getCompoundTag("SkullOwner"));
}
else if (nbttagcompound.hasKey("SkullOwner", 8))
{
String s = nbttagcompound.getString("SkullOwner");
if (!StringUtils.isNullOrEmpty(s))
{
gameprofile = TileEntitySkull.updateGameprofile(new GameProfile((UUID)null, s));
nbttagcompound.setTag("SkullOwner", NBTUtil.writeGameProfile(new NBTTagCompound(), gameprofile));
}
}
}
TileEntitySkullRenderer.instance.renderSkull(-0.5F, 0.0F, -0.5F, EnumFacing.UP, 180.0F, itemstack.getMetadata(), gameprofile, -1, limbSwing);
}
else if (!(item instanceof ItemArmor) || ((ItemArmor)item).getEquipmentSlot() != EntityEquipmentSlot.HEAD)
{
float f3 = 0.625F;
GlStateManager.translate(0.0F, -0.25F, 0.0F);
GlStateManager.rotate(180.0F, 0.0F, 1.0F, 0.0F);
GlStateManager.scale(0.625F, -0.625F, -0.625F);
if (flag)
{
GlStateManager.translate(0.0F, 0.1875F, 0.0F);
}
minecraft.getItemRenderer().renderItem(entitylivingbaseIn, itemstack, ItemCameraTransforms.TransformType.HEAD);
}
GlStateManager.popMatrix();
}
}
示例15: doRenderLayer
import net.minecraft.util.StringUtils; //导入方法依赖的package包/类
public void doRenderLayer(EntityLivingBase entitylivingbaseIn, float p_177141_2_, float p_177141_3_, float partialTicks, float p_177141_5_, float p_177141_6_, float p_177141_7_, float scale)
{
ItemStack itemstack = entitylivingbaseIn.getCurrentArmor(3);
if (itemstack != null && itemstack.getItem() != null)
{
Item item = itemstack.getItem();
Minecraft minecraft = Minecraft.getMinecraft();
GlStateManager.pushMatrix();
if (entitylivingbaseIn.isSneaking())
{
GlStateManager.translate(0.0F, 0.2F, 0.0F);
}
boolean flag = entitylivingbaseIn instanceof EntityVillager || entitylivingbaseIn instanceof EntityZombie && ((EntityZombie)entitylivingbaseIn).isVillager();
if (!flag && entitylivingbaseIn.isChild())
{
float f = 2.0F;
float f1 = 1.4F;
GlStateManager.scale(f1 / f, f1 / f, f1 / f);
GlStateManager.translate(0.0F, 16.0F * scale, 0.0F);
}
this.field_177209_a.postRender(0.0625F);
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
if (item instanceof ItemBlock)
{
float f2 = 0.625F;
GlStateManager.translate(0.0F, -0.25F, 0.0F);
GlStateManager.rotate(180.0F, 0.0F, 1.0F, 0.0F);
GlStateManager.scale(f2, -f2, -f2);
if (flag)
{
GlStateManager.translate(0.0F, 0.1875F, 0.0F);
}
minecraft.getItemRenderer().renderItem(entitylivingbaseIn, itemstack, ItemCameraTransforms.TransformType.HEAD);
}
else if (item == Items.skull)
{
float f3 = 1.1875F;
GlStateManager.scale(f3, -f3, -f3);
if (flag)
{
GlStateManager.translate(0.0F, 0.0625F, 0.0F);
}
GameProfile gameprofile = null;
if (itemstack.hasTagCompound())
{
NBTTagCompound nbttagcompound = itemstack.getTagCompound();
if (nbttagcompound.hasKey("SkullOwner", 10))
{
gameprofile = NBTUtil.readGameProfileFromNBT(nbttagcompound.getCompoundTag("SkullOwner"));
}
else if (nbttagcompound.hasKey("SkullOwner", 8))
{
String s = nbttagcompound.getString("SkullOwner");
if (!StringUtils.isNullOrEmpty(s))
{
gameprofile = TileEntitySkull.updateGameprofile(new GameProfile((UUID)null, s));
nbttagcompound.setTag("SkullOwner", NBTUtil.writeGameProfile(new NBTTagCompound(), gameprofile));
}
}
}
TileEntitySkullRenderer.instance.renderSkull(-0.5F, 0.0F, -0.5F, EnumFacing.UP, 180.0F, itemstack.getMetadata(), gameprofile, -1);
}
GlStateManager.popMatrix();
}
}