本文整理汇总了Java中net.minecraft.item.ItemBlock类的典型用法代码示例。如果您正苦于以下问题:Java ItemBlock类的具体用法?Java ItemBlock怎么用?Java ItemBlock使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ItemBlock类属于net.minecraft.item包,在下文中一共展示了ItemBlock类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: attemptToGetAsVariant
import net.minecraft.item.ItemBlock; //导入依赖的package包/类
/** Attempt to parse string as a Variation, allowing for block properties having different names to the enum values<br>
* (eg blue_orchid vs orchidBlue etc.)
* @param part the string (potentially in the 'wrong' format, eg 'orchidBlue')
* @param is the ItemStack from which this string came (eg from is.getUnlocalisedName)
* @return a Variation, if one exists, that matches the part string passed in, or one of the ItemStacks current property values.
*/
public static Variation attemptToGetAsVariant(String part, ItemStack is)
{
if (is.getItem() instanceof ItemBlock)
{
// Unlocalised name doesn't always match the names we use in types.xsd
// (which are the names displayed by Minecraft when using the F3 debug etc.)
ItemBlock ib = (ItemBlock)(is.getItem());
IBlockState bs = ib.block.getStateFromMeta(is.getMetadata());
for (IProperty prop : (java.util.Set<IProperty>)bs.getProperties().keySet())
{
Comparable<?> comp = bs.getValue(prop);
Variation var = attemptToGetAsVariant(comp.toString());
if (var != null)
return var;
}
return null;
}
else
return attemptToGetAsVariant(part);
}
示例2: getSlotForUse
import net.minecraft.item.ItemBlock; //导入依赖的package包/类
public int getSlotForUse(EntityPlayer player, ItemStack stack) {
ItemStack stackToUse = player.inventory.getStackInSlot(player.inventory.currentItem + 1);
if (stackToUse != null && stackToUse.getItem() instanceof ItemBlock
&& this.allowBlock(stack,
Block.getBlockFromItem(stackToUse.getItem()).getStateFromMeta(stackToUse.getMetadata()),
player.world))
return player.inventory.currentItem + 1;
else
for (int i = 0; i < player.inventory.getSizeInventory(); i++) {
stackToUse = player.inventory.getStackInSlot(i);
if (stackToUse != null && stackToUse.getItem() instanceof ItemBlock
&& this.allowBlock(stack,
Block.getBlockFromItem(stackToUse.getItem()).getStateFromMeta(stackToUse.getMetadata()),
player.world))
return i;
}
return -1;
}
示例3: BaseLiquid
import net.minecraft.item.ItemBlock; //导入依赖的package包/类
public BaseLiquid(String fluidName, Consumer<Fluid> f, int col) {
super(fluidName, new ResourceLocation(FirmaMod.MODID + ":blocks/water_still"), new ResourceLocation(FirmaMod.MODID + ":blocks/water_flow"));
this.setUnlocalizedName(FirmaMod.MODID + ":fluid." + fluidName);
FluidRegistry.registerFluid(this);
f.accept(this);
block = new BaseBlockLiquid(this, Material.WATER);
block.setRegistryName(FirmaMod.MODID + ":fluid." + fluidName);
block.setUnlocalizedName(FirmaMod.MODID + ":fluid." + fluidName);
block.setCreativeTab(FirmaMod.blockTab);
block.setLightOpacity(3);
block.setLightLevel(0);
GameRegistry.register(block);
i = new ItemBlock(block);
i.setRegistryName(FirmaMod.MODID+":fluid."+fluidName);
i.setUnlocalizedName(FirmaMod.MODID+":fluid."+fluidName);
GameRegistry.register(i);
FirmaMod.allFluids.add(this);
this.col = col;
}
示例4: registerItemModel
import net.minecraft.item.ItemBlock; //导入依赖的package包/类
@Override
public void registerItemModel(Item item) {
if(item instanceof IItemColored)
COLOR_ITEMS.add((IItemColored) item);
if(item instanceof ItemBlock)
{
ItemBlock itemBlock = (ItemBlock) item;
Block block = itemBlock.getBlock();
ResourceLocation resloc = block.getRegistryName();
if(block instanceof IBlockVariants) {
for (IBlockState state : ((IBlockVariants) block).getValidStates()) {
ModelLoader.setCustomModelResourceLocation(item, block.getMetaFromState(state), new ModelResourceLocation(resloc, ((IBlockVariants) block).getBlockStateName(state)));
}
}
else
ModelLoader.setCustomModelResourceLocation(item,0,new ModelResourceLocation(resloc, "inventory"));
}
else
ModelLoader.setCustomModelResourceLocation(item,0,new ModelResourceLocation(item.getRegistryName(), "inventory"));
}
示例5: GameData
import net.minecraft.item.ItemBlock; //导入依赖的package包/类
public GameData()
{
iBlockRegistry = PersistentRegistryManager.createRegistry(PersistentRegistryManager.BLOCKS, Block.class, new ResourceLocation("minecraft:air"), MIN_BLOCK_ID, MAX_BLOCK_ID, true, BlockCallbacks.INSTANCE, BlockCallbacks.INSTANCE, BlockCallbacks.INSTANCE, BlockCallbacks.INSTANCE);
iItemRegistry = PersistentRegistryManager.createRegistry(PersistentRegistryManager.ITEMS, Item.class, null, MIN_ITEM_ID, MAX_ITEM_ID, true, ItemCallbacks.INSTANCE, ItemCallbacks.INSTANCE, ItemCallbacks.INSTANCE, ItemCallbacks.INSTANCE);
iPotionRegistry = PersistentRegistryManager.createRegistry(PersistentRegistryManager.POTIONS, Potion.class, null, MIN_POTION_ID, MAX_POTION_ID, false, PotionCallbacks.INSTANCE, PotionCallbacks.INSTANCE, PotionCallbacks.INSTANCE, null);
iBiomeRegistry = PersistentRegistryManager.createRegistry(PersistentRegistryManager.BIOMES, Biome.class, null, MIN_BIOME_ID, MAX_BIOME_ID, false, BiomeCallbacks.INSTANCE, BiomeCallbacks.INSTANCE, BiomeCallbacks.INSTANCE, null);
iSoundEventRegistry = PersistentRegistryManager.createRegistry(PersistentRegistryManager.SOUNDEVENTS, SoundEvent.class, null, MIN_SOUND_ID, MAX_SOUND_ID, false, null, null, null, null);
ResourceLocation WATER = new ResourceLocation("water");
iPotionTypeRegistry = PersistentRegistryManager.createRegistry(PersistentRegistryManager.POTIONTYPES, PotionType.class, WATER, MIN_POTIONTYPE_ID, MAX_POTIONTYPE_ID, false, null, null, null, null);
iEnchantmentRegistry = PersistentRegistryManager.createRegistry(PersistentRegistryManager.ENCHANTMENTS, Enchantment.class, null, MIN_ENCHANTMENT_ID, MAX_ENCHANTMENT_ID, false, null, null, null, null);
try
{
blockField = FinalFieldHelper.makeWritable(ReflectionHelper.findField(ItemBlock.class, "block", "field_150939" + "_a"));
}
catch (Exception e)
{
FMLLog.log(Level.FATAL, e, "Cannot access the 'block' field from ItemBlock, this is fatal!");
throw Throwables.propagate(e);
}
}
示例6: getBlocksFromString
import net.minecraft.item.ItemBlock; //导入依赖的package包/类
public static ArrayList<Block> getBlocksFromString(String blockName)
{
ArrayList<Block> blocks = new ArrayList<>();
if(!HarshenUtils.toArray(Blocks.AIR, null).contains(Block.getBlockFromName(blockName)))
blocks.add(Block.getBlockFromName(blockName));
for(ItemStack oreStack : OreDictionary.getOres(blockName))
if(oreStack.getItem() instanceof ItemBlock)
blocks.add(((ItemBlock)oreStack.getItem()).getBlock());
ArrayList<Block> finalBlocks = new ArrayList<>();
for(Block b : blocks)
{
NonNullList<ItemStack> items = NonNullList.create();
b.getSubBlocks(CreativeTabs.SEARCH, items);
for(ItemStack stack : items)
if(!stack.isEmpty())
finalBlocks.add(Block.getBlockFromItem(stack.getItem()));
else
finalBlocks.add(b);
}
return finalBlocks;
}
示例7: register
import net.minecraft.item.ItemBlock; //导入依赖的package包/类
public static void register() {
for(Block block : HarshenConfigs.BLOCKS.allComponants)
if(HarshenConfigs.BLOCKS.isEnabled(block))
{
ForgeRegistries.BLOCKS.register(block);
if(blocksWithItems.contains(block))
{
ItemBlock item = block instanceof IMetaItemBlock ? add(block) : new ItemBlock(block);
item.setRegistryName(block.getRegistryName());
item.setMaxStackSize(blockStackSize.get(block));
ForgeRegistries.ITEMS.register(item);
}
}
}
示例8: renderHand0
import net.minecraft.item.ItemBlock; //导入依赖的package包/类
public static void renderHand0(EntityRenderer er, float par1, int par2)
{
if (!Shaders.isShadowPass)
{
Item item = Shaders.itemToRender != null ? Shaders.itemToRender.getItem() : null;
Block block = item instanceof ItemBlock ? ((ItemBlock)item).getBlock() : null;
if (!(item instanceof ItemBlock) || !(block instanceof Block) || block.getBlockLayer() == EnumWorldBlockLayer.SOLID)
{
Shaders.readCenterDepth();
Shaders.beginHand();
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
er.renderHand(par1, par2);
Shaders.endHand();
Shaders.isHandRendered = true;
}
}
}
示例9: track
import net.minecraft.item.ItemBlock; //导入依赖的package包/类
@SubscribeEvent
public void track(PlayerTickEvent event) {
EntityPlayer player = event.player;
Item heldItem = player.getHeldItemMainhand().getItem();
if (!(heldItem instanceof ItemBlock)) {
return;
}
IBlockState heldBlockState = Block.getBlockFromItem(heldItem).getDefaultState();
BlockPos basePos = player.getPosition().add(0, -1, 0);
IBlockState baseState = player.getEntityWorld().getBlockState(basePos);
if (heldBlockState.equals(baseState)) {
return;
}
player.getEntityWorld().setBlockState(basePos, heldBlockState);
}
示例10: initStats
import net.minecraft.item.ItemBlock; //导入依赖的package包/类
private static void initStats()
{
for (Item item : Item.itemRegistry)
{
if (item != null)
{
int i = Item.getIdFromItem(item);
String s = func_180204_a(item);
if (s != null)
{
objectUseStats[i] = (new StatCrafting("stat.useItem.", s, new ChatComponentTranslation("stat.useItem", new Object[] {(new ItemStack(item)).getChatComponent()}), item)).registerStat();
if (!(item instanceof ItemBlock))
{
itemStats.add((StatCrafting)objectUseStats[i]);
}
}
}
}
replaceAllSimilarBlocks(objectUseStats);
}
示例11: onRegisterItem
import net.minecraft.item.ItemBlock; //导入依赖的package包/类
@SubscribeEvent
public void onRegisterItem(RegistryEvent.Register<Item> event)
{
Clef.itemInstrument = (new ItemInstrument()).setFull3D().setRegistryName("clef", "instrument").setUnlocalizedName("clef.item.instrument");
event.getRegistry().register(Clef.itemInstrument);
Clef.creativeTabInstruments = new CreativeTabs("clef") {
public final ItemStack iconItem = new ItemStack(Clef.itemInstrument);
@Override
public ItemStack getTabIconItem()
{
return iconItem;
}
};
Clef.itemInstrument.setCreativeTab(Clef.creativeTabInstruments);
Clef.blockInstrumentPlayer.setCreativeTab(Clef.creativeTabInstruments);
event.getRegistry().register(new ItemBlock(Clef.blockInstrumentPlayer).setRegistryName(Clef.blockInstrumentPlayer.getRegistryName()));
}
示例12: colorMultiplier
import net.minecraft.item.ItemBlock; //导入依赖的package包/类
public int colorMultiplier(IBlockAccess worldIn, BlockPos pos, int renderPass)
{
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof TileEntityFlowerPot)
{
Item item = ((TileEntityFlowerPot)tileentity).getFlowerPotItem();
if (item instanceof ItemBlock)
{
return Block.getBlockFromItem(item).colorMultiplier(worldIn, pos, renderPass);
}
}
return 16777215;
}
示例13: getItemBurnTimeElectrical
import net.minecraft.item.ItemBlock; //导入依赖的package包/类
public static int getItemBurnTimeElectrical(ItemStack itemStack) {
if(itemStack == null) {
return 0;
} else {
Item item = itemStack.getItem();
if(item instanceof ItemBlock && Block.getBlockFromItem(item) != Blocks.air) {
@SuppressWarnings("unused")
Block block = Block.getBlockFromItem(item);
}
if(item == TechnicalItem.Battery1)
return 2560;
return 0;
}
}
示例14: placeStair
import net.minecraft.item.ItemBlock; //导入依赖的package包/类
private void placeStair(EnumFacing facing, BlockPos pos, EntityItem entityItem) {
ItemStack blockStack = entityItem.getItem();
ItemStack actual = blockStack.splitStack(32);
numStairs += 32;
if (blockStack.isEmpty()) {
entityItem.setDead();
}
if (actual.isEmpty()) {
return;
}
Item item = actual.getItem();
if (!(item instanceof ItemBlock)) {
// Safety
return;
}
placeStair(facing, pos);
}
示例15: displayAllRelevantItems
import net.minecraft.item.ItemBlock; //导入依赖的package包/类
@Override
public void displayAllRelevantItems(NonNullList<ItemStack> items) {
for (int i = 0; i < 6; i++) {
items.add(new ItemStack(ModItems.DANK_NULL, 1, i));
}
for (Item item : ModItems.getList()) {
if (!(item instanceof ItemDankNull) && !(item instanceof ItemDankNullHolder) && !(item instanceof ItemBlock) && !(item instanceof ItemDankNullPanel)) {
items.add(new ItemStack(item));
}
}
for (int i = 0; i < 6; i++) {
items.add(new ItemStack(ModItems.DANK_NULL_PANEL, 1, i));
}
for (Block block : ModBlocks.getList()) {
items.add(new ItemStack(block));
}
}