本文整理汇总了Java中net.minecraft.item.Item.getHasSubtypes方法的典型用法代码示例。如果您正苦于以下问题:Java Item.getHasSubtypes方法的具体用法?Java Item.getHasSubtypes怎么用?Java Item.getHasSubtypes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.item.Item
的用法示例。
在下文中一共展示了Item.getHasSubtypes方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createSubItems
import net.minecraft.item.Item; //导入方法依赖的package包/类
public static NonNullList<ItemStack> createSubItems(Item item, CreativeTabs creativeTab, Attribute<String> tabLabels, int[] subtypes)
{
NonNullList<ItemStack> list = NonNullList.create();
if (item.getHasSubtypes())
{
for (int meta : subtypes)
{
tabLabels.get(meta)
.ifPresent(tabLabel ->
{
if (creativeTab == null || creativeTab == CreativeTabs.SEARCH || Objects.equals(tabLabel, getTabLabel(creativeTab)))
{
list.add(new ItemStack(item, 1, meta));
}
});
}
} else
{
list.add(new ItemStack(item, 1, 0));
}
return list;
}
示例2: dropEquipment
import net.minecraft.item.Item; //导入方法依赖的package包/类
/**
* Drop the equipment for this entity.
*/
protected void dropEquipment(boolean wasRecentlyHit, int lootingModifier)
{
super.dropEquipment(wasRecentlyHit, lootingModifier);
IBlockState iblockstate = this.getHeldBlockState();
if (iblockstate != null)
{
Item item = Item.getItemFromBlock(iblockstate.getBlock());
if (item != null)
{
int i = item.getHasSubtypes() ? iblockstate.getBlock().getMetaFromState(iblockstate) : 0;
this.entityDropItem(new ItemStack(item, 1, i), 0.0F);
}
}
}
示例3: createStackedBlock
import net.minecraft.item.Item; //导入方法依赖的package包/类
@Nullable
protected ItemStack createStackedBlock(IBlockState state)
{
Item item = Item.getItemFromBlock(this);
if (item == null)
{
return null;
}
else
{
int i = 0;
if (item.getHasSubtypes())
{
i = this.getMetaFromState(state);
}
return new ItemStack(item, 1, i);
}
}
示例4: registerRenders
import net.minecraft.item.Item; //导入方法依赖的package包/类
@Load(side = Side.CLIENT)
public void registerRenders() {
for (Field field : FCRItems.class.getFields()) {
field.setAccessible(true);
RegItem anno = field.getAnnotation(RegItem.class);
try {
if (anno == null)
continue;
Item item = (Item) field.get(null);
if (item.getHasSubtypes()) {
if (item instanceof IMetadatable) {
for (int i = 0; i < ((IMetadatable) item).getMaxMetadata(); i++)
registerRender(item, i);
}
} else {
registerRender(item, 0);
}
} catch (Exception e) {
FoodCraftReloaded.getLogger().warn("Un-able to register item " + field.toGenericString(), e);
}
}
}
示例5: stackEqualsNonNBT
import net.minecraft.item.Item; //导入方法依赖的package包/类
public static boolean stackEqualsNonNBT(@Nonnull ItemStack stack, @Nonnull ItemStack other) {
if (stack.isEmpty() && other.isEmpty())
return true;
if (stack.isEmpty() || other.isEmpty())
return false;
Item sItem = stack.getItem();
Item oItem = other.getItem();
if (sItem.getHasSubtypes() || oItem.getHasSubtypes()) {
return sItem.equals(other.getItem()) &&
(stack.getItemDamage() == other.getItemDamage() ||
stack.getItemDamage() == OreDictionary.WILDCARD_VALUE ||
other.getItemDamage() == OreDictionary.WILDCARD_VALUE);
} else {
return sItem.equals(other.getItem());
}
}
示例6: createStackedBlock
import net.minecraft.item.Item; //导入方法依赖的package包/类
protected ItemStack createStackedBlock(IBlockState state)
{
int i = 0;
Item item = Item.getItemFromBlock(this);
if (item != null && item.getHasSubtypes())
{
i = this.getMetaFromState(state);
}
return new ItemStack(item, 1, i);
}
示例7: createStackedBlock
import net.minecraft.item.Item; //导入方法依赖的package包/类
protected ItemStack createStackedBlock(IBlockState state) {
int i = 0;
Item item = Item.getItemFromBlock(this);
if (item != null && item.getHasSubtypes()) {
i = this.getMetaFromState(state);
}
return new ItemStack(item, 1, i);
}
示例8: getSilkTouchDrop
import net.minecraft.item.Item; //导入方法依赖的package包/类
@Override
protected ItemStack getSilkTouchDrop(IBlockState state)
{
Item item = Item.getItemFromBlock(this);
int subtype = 0;
if (item.getHasSubtypes())
{
subtype = getSubtype(state);
}
return new ItemStack(item, 1, subtype);
}
示例9: dropEquipment
import net.minecraft.item.Item; //导入方法依赖的package包/类
/**
* Drop the equipment for this entity.
*/
protected void dropEquipment(boolean wasRecentlyHit, int lootingModifier)
{
super.dropEquipment(wasRecentlyHit, lootingModifier);
IBlockState iblockstate = this.getHeldBlockState();
if (iblockstate != null)
{
Item item = Item.getItemFromBlock(iblockstate.getBlock());
int i = item.getHasSubtypes() ? iblockstate.getBlock().getMetaFromState(iblockstate) : 0;
this.entityDropItem(new ItemStack(item, 1, i), 0.0F);
}
}
示例10: getSilkTouchDrop
import net.minecraft.item.Item; //导入方法依赖的package包/类
protected ItemStack getSilkTouchDrop(IBlockState state)
{
Item item = Item.getItemFromBlock(this);
int i = 0;
if (item.getHasSubtypes())
{
i = this.getMetaFromState(state);
}
return new ItemStack(item, 1, i);
}
示例11: execute
import net.minecraft.item.Item; //导入方法依赖的package包/类
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
EntityPlayerMP player = getCommandSenderAsPlayer(sender);
ItemStack held = player.getHeldItemMainhand();
if(held.isEmpty()) {
held = player.getHeldItemOffhand();
}
if(held.isEmpty()) {
player.sendMessage(new TextComponentTranslation("command.modularmachinery.hand.empty"));
return;
}
Item i = held.getItem();
StringBuilder sb = new StringBuilder();
sb.append(i.getRegistryName().toString());
if(i.getHasSubtypes()) {
sb.append("@").append(held.getItemDamage());
}
NBTTagCompound cmp = held.serializeNBT();
if(cmp.hasKey("tag")) {
String json = NBTJsonSerializer.serializeNBT(cmp.getTag("tag"));
if(!json.isEmpty()) {
sb.append(" (with nbt: ").append(json).append(" )");
}
}
String str = sb.toString();
player.sendMessage(new TextComponentString(str));
ModularMachinery.NET_CHANNEL.sendTo(new PktCopyToClipboard(str), player);
int burn = TileEntityFurnace.getItemBurnTime(held);
if(burn > 0) {
player.sendMessage(new TextComponentString("Fuel BurnTime: " + burn));
}
}
示例12: hasSubTypes
import net.minecraft.item.Item; //导入方法依赖的package包/类
public static boolean hasSubTypes(Item item) {
return item != null && item.getHasSubtypes();
}
示例13: drawSlot
import net.minecraft.item.Item; //导入方法依赖的package包/类
protected void drawSlot(int entryID, int insideLeft, int yPos, int insideSlotHeight, int mouseXIn, int mouseYIn)
{
FlatLayerInfo flatlayerinfo = (FlatLayerInfo)GuiCreateFlatWorld.this.theFlatGeneratorInfo.getFlatLayers().get(GuiCreateFlatWorld.this.theFlatGeneratorInfo.getFlatLayers().size() - entryID - 1);
IBlockState iblockstate = flatlayerinfo.getLayerMaterial();
Block block = iblockstate.getBlock();
Item item = Item.getItemFromBlock(block);
if (item == Items.field_190931_a)
{
if (block != Blocks.WATER && block != Blocks.FLOWING_WATER)
{
if (block == Blocks.LAVA || block == Blocks.FLOWING_LAVA)
{
item = Items.LAVA_BUCKET;
}
}
else
{
item = Items.WATER_BUCKET;
}
}
ItemStack itemstack = new ItemStack(item, 1, item.getHasSubtypes() ? block.getMetaFromState(iblockstate) : 0);
String s = item.getItemStackDisplayName(itemstack);
this.drawItem(insideLeft, yPos, itemstack);
GuiCreateFlatWorld.this.fontRendererObj.drawString(s, insideLeft + 18 + 5, yPos + 3, 16777215);
String s1;
if (entryID == 0)
{
s1 = I18n.format("createWorld.customize.flat.layer.top", new Object[] {Integer.valueOf(flatlayerinfo.getLayerCount())});
}
else if (entryID == GuiCreateFlatWorld.this.theFlatGeneratorInfo.getFlatLayers().size() - 1)
{
s1 = I18n.format("createWorld.customize.flat.layer.bottom", new Object[] {Integer.valueOf(flatlayerinfo.getLayerCount())});
}
else
{
s1 = I18n.format("createWorld.customize.flat.layer", new Object[] {Integer.valueOf(flatlayerinfo.getLayerCount())});
}
GuiCreateFlatWorld.this.fontRendererObj.drawString(s1, insideLeft + 2 + 213 - GuiCreateFlatWorld.this.fontRendererObj.getStringWidth(s1), yPos + 3, 16777215);
}