本文整理了Java中net.minecraft.item.ItemStack.clearCustomName()
方法的一些代码示例,展示了ItemStack.clearCustomName()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ItemStack.clearCustomName()
方法的具体详情如下:
包路径:net.minecraft.item.ItemStack
类名称:ItemStack
方法名:clearCustomName
暂无
代码示例来源:origin: SquidDev-CC/plethora
@Override
public boolean setLabel(@Nonnull ItemStack stack, String name) {
if (name == null) {
stack.clearCustomName();
} else {
stack.setStackDisplayName(name);
}
return true;
}
代码示例来源:origin: CyclopsMC/IntegratedDynamics
public void setItemStackName(String name) {
ItemStack itemStack = getItemStack();
if(!itemStack.isEmpty()) {
if (StringUtils.isBlank(name)) {
itemStack.clearCustomName();
} else {
itemStack.setStackDisplayName(name);
}
}
}
}
代码示例来源:origin: SleepyTrousers/EnderIO
public void writeToNBT(@Nonnull ItemStack stack) {
writeToNBT(NbtValue.getOrCreateRoot(stack));
if (!getName().isEmpty()) {
stack.setStackDisplayName(getName());
} else {
stack.clearCustomName();
}
}
代码示例来源:origin: Esteemed-Innovation/Esteemed-Innovation
/**
* used by the Anvil GUI to update the Item Name being typed by the player
*/
public void updateItemName(String s) {
hammer.itemName = s;
Slot slot = getSlot(2);
if (slot.getHasStack()) {
ItemStack itemstack = slot.getStack();
assert itemstack != null;
if (StringUtils.isBlank(s)) {
itemstack.clearCustomName();
} else {
itemstack.setStackDisplayName(hammer.itemName);
}
}
this.updateRepairOutput();
}
}
代码示例来源:origin: SleepyTrousers/EnderIO
@SuppressWarnings("null")
@Override
public @Nonnull ItemStack getCraftingResult(@Nonnull InventoryCrafting inv) {
ItemStack result = super.getCraftingResult(inv);
for (int x = 0; x < inv.getSizeInventory(); x++) {
ItemStack slot = inv.getStackInSlot(x);
if (Prep.isValid(slot) && result.getItem() == slot.getItem() && slot.hasTagCompound()) {
result.setTagCompound(slot.getTagCompound().copy());
result.clearCustomName();
return result;
}
}
return result;
}
代码示例来源:origin: MrCrayfish/MrCrayfishDeviceMod
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
{
if(!world.isRemote)
{
ItemStack heldItem = player.getHeldItem(hand);
if(player.isSneaking())
{
heldItem.clearCustomName();
heldItem.setTagCompound(null);
return new ActionResult<>(EnumActionResult.SUCCESS, heldItem);
}
}
return super.onItemRightClick(world, player, hand);
}
代码示例来源:origin: SleepyTrousers/EnderIO
@SuppressWarnings("null")
@Override
public @Nonnull ItemStack getCraftingResult(@Nonnull InventoryCrafting inv) {
ItemStack craftingResult = super.getCraftingResult(inv);
// Pass 1: Same item, different meta
for (int x = 0; x < inv.getSizeInventory(); x++) {
ItemStack slot = inv.getStackInSlot(x);
if (Prep.isValid(slot) && craftingResult.getItem() == slot.getItem() && slot.hasTagCompound()) {
craftingResult.setTagCompound(slot.getTagCompound().copy());
craftingResult.clearCustomName();
return craftingResult;
}
}
// Pass 2: Different item, both ours (better not define upgrade recipes that take 2 of our items that have nbt...)
if (ModObjectRegistry.getModObject(craftingResult.getItem()) != null) {
for (int x = 0; x < inv.getSizeInventory(); x++) {
ItemStack slot = inv.getStackInSlot(x);
if (ModObjectRegistry.getModObject(slot.getItem()) != null && slot.hasTagCompound()) {
craftingResult.setTagCompound(slot.getTagCompound().copy());
craftingResult.clearCustomName();
return craftingResult;
}
}
}
return craftingResult;
}
代码示例来源:origin: SleepyTrousers/EnderIO
@SuppressWarnings("null")
@Override
public @Nonnull ItemStack getCraftingResult(@Nonnull InventoryCrafting inv) {
ItemStack craftingResult = super.getCraftingResult(inv);
// Pass 1: Same item, different meta
for (int x = 0; x < inv.getSizeInventory(); x++) {
ItemStack slot = inv.getStackInSlot(x);
if (Prep.isValid(slot) && craftingResult.getItem() == slot.getItem() && slot.hasTagCompound()) {
craftingResult.setTagCompound(slot.getTagCompound().copy());
craftingResult.clearCustomName();
return craftingResult;
}
}
// Pass 2: Different item, both ours (better not define upgrade recipes that take 2 of our items that have nbt...)
if (ModObjectRegistry.getModObject(craftingResult.getItem()) != null) {
for (int x = 0; x < inv.getSizeInventory(); x++) {
ItemStack slot = inv.getStackInSlot(x);
if (ModObjectRegistry.getModObject(slot.getItem()) != null && slot.hasTagCompound()) {
craftingResult.setTagCompound(slot.getTagCompound().copy());
craftingResult.clearCustomName();
return craftingResult;
}
}
}
return craftingResult;
}
代码示例来源:origin: SleepyTrousers/EnderIO
@SuppressWarnings("null")
@Override
public @Nonnull ItemStack getCraftingResult(@Nonnull InventoryCrafting inv) {
ItemStack result = super.getCraftingResult(inv);
// Pass 1: Same item, different meta
for (int x = 0; x < inv.getSizeInventory(); x++) {
ItemStack slot = inv.getStackInSlot(x);
if (Prep.isValid(slot) && result.getItem() == slot.getItem() && slot.hasTagCompound()) {
result.setTagCompound(slot.getTagCompound().copy());
result.clearCustomName();
return result;
}
}
// Pass 2: Different item, both ours (better not define upgrade recipes that take 2 of our items that have nbt...)
if (ModObjectRegistry.getModObject(result.getItem()) != null) {
for (int x = 0; x < inv.getSizeInventory(); x++) {
ItemStack slot = inv.getStackInSlot(x);
if (ModObjectRegistry.getModObject(slot.getItem()) != null && slot.hasTagCompound()) {
result.setTagCompound(slot.getTagCompound().copy());
result.clearCustomName();
return result;
}
}
}
return result;
}
代码示例来源:origin: OpenMods/OpenModsLib
k = 1;
i += k;
itemstack1.clearCustomName();
代码示例来源:origin: Esteemed-Innovation/Esteemed-Innovation
j = itemstack.isItemStackDamageable() ? 7 : itemstack.getCount() * 5;
i += j;
itemstack1.clearCustomName();
代码示例来源:origin: SquidDev-CC/plethora
if (!Objects.equal(newLabel, label)) {
if (newLabel == null || newLabel.isEmpty()) {
stack.clearCustomName();
} else {
stack.setStackDisplayName(newLabel);
内容来源于网络,如有侵权,请联系作者删除!