本文整理汇总了Java中net.minecraft.item.ItemStack.setStackDisplayName方法的典型用法代码示例。如果您正苦于以下问题:Java ItemStack.setStackDisplayName方法的具体用法?Java ItemStack.setStackDisplayName怎么用?Java ItemStack.setStackDisplayName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.item.ItemStack
的用法示例。
在下文中一共展示了ItemStack.setStackDisplayName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: copyName
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
private void copyName(IInventory craftMatrix, ItemStack newItem) // Does the weapon have a custom name? If so then we're transfering that to the new item
{
// Step 1, find the actual item (It's possible that this is not a reloading action, meaning there is no weapon to copy the name from)
int slot = 0;
while (slot < 9)
{
ItemStack stack = craftMatrix.getStackInSlot(slot);
if (stack != null && stack.getItem() instanceof _WeaponBase) // Found it. Does it have a name tag?
{
if (stack.hasDisplayName() && !newItem.hasDisplayName()) { newItem.setStackDisplayName(stack.getDisplayName()); }
// else, has no custom display name or the new item already has one. Fine with me either way.
return; // Either way, we're done here
}
// else, either doesn't exist or not what I'm looking for
slot += 1;
}
}
示例2: updateItemName
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
* used by the Anvil GUI to update the Item Name being typed by the player
*/
public void updateItemName(String newName)
{
this.repairedItemName = newName;
if (this.getSlot(2).getHasStack())
{
ItemStack itemstack = this.getSlot(2).getStack();
if (StringUtils.isBlank(newName))
{
itemstack.clearCustomName();
}
else
{
itemstack.setStackDisplayName(this.repairedItemName);
}
}
this.updateRepairOutput();
}
示例3: breakBlock
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public void breakBlock(World worldIn, BlockPos pos, IBlockState state) {
TileEntityBloodVessel te = (TileEntityBloodVessel) worldIn.getTileEntity(pos);
int amount = te.getPossibleRemove();
int max = te.getMax();
worldIn.removeTileEntity(pos);
ItemStack stack = new ItemStack(this);
if(amount != 0)
{
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setInteger("BloodLevel", amount);
stack.setTagCompound(nbttagcompound);
stack.setStackDisplayName("�r" + getLocalizedName() + " [" + amount + "/" + max + "]");
}
if(!creativeBreakMap.containsKey(pos) || !creativeBreakMap.get(pos))
worldIn.spawnEntity(new EntityItem(worldIn, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, stack));
creativeBreakMap.remove(pos);
}
示例4: killMinecart
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public void killMinecart(DamageSource source)
{
this.setDead();
if (this.worldObj.getGameRules().getBoolean("doEntityDrops"))
{
ItemStack itemstack = new ItemStack(Items.MINECART, 1);
if (this.getName() != null)
{
itemstack.setStackDisplayName(this.getName());
}
this.entityDropItem(itemstack, 0.0F);
}
}
示例5: killMinecart
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public void killMinecart(DamageSource p_94095_1_)
{
this.setDead();
if (this.worldObj.getGameRules().getBoolean("doEntityDrops"))
{
ItemStack itemstack = new ItemStack(Items.minecart, 1);
if (this.entityName != null)
{
itemstack.setStackDisplayName(this.entityName);
}
this.entityDropItem(itemstack, 0.0F);
}
}
示例6: onDeath
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public void onDeath(DamageSource par1DamageSource) {
for (int i = 0; i < inventory.getSlots(); i++) {
if (!inventory.getStackInSlot(i).isEmpty()) {
entityDropItem(inventory.getStackInSlot(i), 0);
inventory.setStackInSlot(i, ItemStack.EMPTY);
}
}
if (naturallySpawned) {
} else {
ItemStack drone = getDroppedStack();
if (hasCustomName()) drone.setStackDisplayName(getCustomNameTag());
entityDropItem(drone, 0);
if (!world.isRemote) {
EntityPlayer owner = getOwner();
if (owner != null) {
int x = (int) Math.floor(posX);
int y = (int) Math.floor(posY);
int z = (int) Math.floor(posZ);
if (hasCustomName()) {
owner.sendStatusMessage(new TextComponentTranslation("death.drone.named", getCustomNameTag(), x, y, z), false);
} else {
owner.sendStatusMessage(new TextComponentTranslation("death.drone", x, y, z), false);
}
}
}
}
if (!world.isRemote) getFakePlayer().interactionManager.cancelDestroyingBlock();
super.onDeath(par1DamageSource);
}
示例7: setName
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public void setName(String string) {
droneName = string;
if (drone != null) {
drone.setCustomNameTag(droneName);
}
ItemStack stack = inventory.getStackInSlot(0).copy();
if (!stack.isEmpty()) {
stack.setStackDisplayName(string);
inventory.setStackInSlot(0, stack);
}
}
示例8: onEnable
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public void onEnable()
{
// check gamemode
if(!WMinecraft.getPlayer().capabilities.isCreativeMode)
{
ChatUtils.error("Creative mode only.");
setEnabled(false);
return;
}
// check held item
ItemStack heldStack = WMinecraft.getPlayer().inventory.getCurrentItem();
if(heldStack == null || !(heldStack.getItem() instanceof ItemNameTag))
{
ChatUtils.error("You need a nametag in your hand.");
setEnabled(false);
return;
}
// modify held item
StringBuilder stackName = new StringBuilder();
for(int i = 0; i < 18000; i++)
stackName.append('#');
heldStack.setStackDisplayName(stackName.toString());
// open & close the inventory
// for some reason that's needed for the item to update
mc.displayGuiScreen(new GuiInventory(WMinecraft.getPlayer()));
WMinecraft.getPlayer().closeScreen();
ChatUtils.message("Nametag modified.");
setEnabled(false);
}
示例9: createUnreadBook
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public static ItemStack createUnreadBook() {
ItemStack book = new ItemStack(Items.WRITTEN_BOOK, 1);
NBTTagCompound bookNbt = new NBTTagCompound();
bookNbt.setTag(NBT_UNREAD_DISCOVERY, new NBTTagInt(nextBookID++));
book.setTagCompound(bookNbt);
book.setStackDisplayName("Unread Nemesis Book");
return book;
}
示例10: copyProps
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public static void copyProps(IInventory craftMatrix, ItemStack newItem)
{
// Step 1, find the actual item (It's possible that this is not a reloading action, meaning there is no weapon to copy the name from)
int slot = 0;
while (slot < 9)
{
ItemStack stack = craftMatrix.getStackInSlot(slot);
if (stack != null && stack.getItem() instanceof _WeaponBase) // Found it. Does it have a name tag?
{
if (stack.hasDisplayName() && !newItem.hasDisplayName()) { newItem.setStackDisplayName(stack.getDisplayName()); }
// else, has no custom display name or the new item already has one. Fine with me either way.
// Upgrades
if (stack.hasTagCompound() && stack.getTagCompound().getBoolean("hasEmeraldMuzzle"))
{
if (!newItem.hasTagCompound()) { newItem.setTagCompound(new NBTTagCompound()); } // Init
newItem.getTagCompound().setBoolean("hasEmeraldMuzzle", true); // Keeping the upgrade
}
return; // Either way, we're done here
}
// else, either doesn't exist or not what I'm looking for
slot += 1;
}
}
示例11: onEnable
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public void onEnable()
{
// check gamemode
if(!WMinecraft.getPlayer().capabilities.isCreativeMode)
{
ChatUtils.error("Creative mode only.");
setEnabled(false);
return;
}
// generate potion
ItemStack stack = InventoryUtils.createSplashPotion();
NBTTagList effects = new NBTTagList();
for(int i = 1; i <= 23; i++)
{
NBTTagCompound effect = new NBTTagCompound();
effect.setInteger("Amplifier", Integer.MAX_VALUE);
effect.setInteger("Duration", Integer.MAX_VALUE);
effect.setInteger("Id", i);
effects.appendTag(effect);
}
stack.setTagInfo("CustomPotionEffects", effects);
stack.setStackDisplayName("�rSplash Potion of Trolling");
// give potion
if(InventoryUtils.placeStackInHotbar(stack))
ChatUtils.message("Potion created.");
else
ChatUtils.error("Please clear a slot in your hotbar.");
setEnabled(false);
}
示例12: getCraftingResult
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
* Returns an Item that is the result of this recipe
*/
public ItemStack getCraftingResult(InventoryCrafting inv)
{
int i = 0;
ItemStack itemstack = null;
for (int j = 0; j < inv.getSizeInventory(); ++j)
{
ItemStack itemstack1 = inv.getStackInSlot(j);
if (itemstack1 != null)
{
if (itemstack1.getItem() == Items.filled_map)
{
if (itemstack != null)
{
return null;
}
itemstack = itemstack1;
}
else
{
if (itemstack1.getItem() != Items.map)
{
return null;
}
++i;
}
}
}
if (itemstack != null && i >= 1)
{
ItemStack itemstack2 = new ItemStack(Items.filled_map, i + 1, itemstack.getMetadata());
if (itemstack.hasDisplayName())
{
itemstack2.setStackDisplayName(itemstack.getDisplayName());
}
return itemstack2;
}
else
{
return null;
}
}
示例13: getUnlocalizedName
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public String getUnlocalizedName(ItemStack stack) {
stack.setStackDisplayName(getName(stack));
return super.getUnlocalizedName(stack);
}
示例14: getCraftingResult
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
* Returns an Item that is the result of this recipe
*/
public ItemStack getCraftingResult(InventoryCrafting inv)
{
int i = 0;
ItemStack itemstack = null;
for (int j = 0; j < inv.getSizeInventory(); ++j)
{
ItemStack itemstack1 = inv.getStackInSlot(j);
if (itemstack1 != null)
{
if (itemstack1.getItem() == Items.written_book)
{
if (itemstack != null)
{
return null;
}
itemstack = itemstack1;
}
else
{
if (itemstack1.getItem() != Items.writable_book)
{
return null;
}
++i;
}
}
}
if (itemstack != null && i >= 1 && ItemEditableBook.getGeneration(itemstack) < 2)
{
ItemStack itemstack2 = new ItemStack(Items.written_book, i);
itemstack2.setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy());
itemstack2.getTagCompound().setInteger("generation", ItemEditableBook.getGeneration(itemstack) + 1);
if (itemstack.hasDisplayName())
{
itemstack2.setStackDisplayName(itemstack.getDisplayName());
}
return itemstack2;
}
else
{
return null;
}
}
示例15: getCraftingResult
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
* Returns an Item that is the result of this recipe
*/
public ItemStack getCraftingResult(InventoryCrafting inv)
{
int i = 0;
ItemStack itemstack = ItemStack.field_190927_a;
for (int j = 0; j < inv.getSizeInventory(); ++j)
{
ItemStack itemstack1 = inv.getStackInSlot(j);
if (!itemstack1.func_190926_b())
{
if (itemstack1.getItem() == Items.WRITTEN_BOOK)
{
if (!itemstack.func_190926_b())
{
return ItemStack.field_190927_a;
}
itemstack = itemstack1;
}
else
{
if (itemstack1.getItem() != Items.WRITABLE_BOOK)
{
return ItemStack.field_190927_a;
}
++i;
}
}
}
if (!itemstack.func_190926_b() && itemstack.hasTagCompound() && i >= 1 && ItemWrittenBook.getGeneration(itemstack) < 2)
{
ItemStack itemstack2 = new ItemStack(Items.WRITTEN_BOOK, i);
itemstack2.setTagCompound(itemstack.getTagCompound().copy());
itemstack2.getTagCompound().setInteger("generation", ItemWrittenBook.getGeneration(itemstack) + 1);
if (itemstack.hasDisplayName())
{
itemstack2.setStackDisplayName(itemstack.getDisplayName());
}
return itemstack2;
}
else
{
return ItemStack.field_190927_a;
}
}