Java Code Examples for net.minecraft.item.ItemBlock#getBlock()
The following examples show how to use
net.minecraft.item.ItemBlock#getBlock() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WorldEventsCommon.java From Valkyrien-Skies with Apache License 2.0 | 7 votes |
@SubscribeEvent public void onAttachCapabilityEventItem(AttachCapabilitiesEvent event) { if (event.getObject() instanceof ItemStack) { ItemStack stack = (ItemStack) event.getObject(); Item item = stack.getItem(); if (item instanceof ItemValkyriumCrystal) { event.addCapability( new ResourceLocation(ValkyrienSkiesWorld.MOD_ID, "AntiGravityValue"), new AntiGravityCapabilityProvider(VSConfig.valkyriumCrystalForce)); } if (stack.getItem() instanceof ItemBlock) { ItemBlock blockItem = (ItemBlock) stack.getItem(); if (blockItem.getBlock() instanceof BlockValkyriumOre) { event.addCapability( new ResourceLocation(ValkyrienSkiesWorld.MOD_ID, "AntiGravityValue"), new AntiGravityCapabilityProvider(VSConfig.valkyriumOreForce)); } } } }
Example 2
Source File: WorldEventsCommon.java From Valkyrien-Skies with Apache License 2.0 | 6 votes |
@SubscribeEvent public void playerTick(PlayerTickEvent event) { if (event.phase == Phase.START) { EntityPlayer player = event.player; //TODO: fix the fall damage // @thebest108: what fall damage? // --DaPorkchop_, 28/03/2017 if (VSConfig.doValkyriumLifting && !player.isCreative()) { for (NonNullList<ItemStack> stackArray : player.inventory.allInventories) { for (ItemStack stack : stackArray) { if (stack != null) { if (stack.getItem() instanceof ItemBlock) { ItemBlock blockItem = (ItemBlock) stack.getItem(); if (blockItem.getBlock() instanceof BlockValkyriumOre) { player.addVelocity(0, .0025D * stack.stackSize * VSConfig.valkyriumOreForce, 0); } } else if (stack.getItem() instanceof ItemValkyriumCrystal) { player.addVelocity(0, .0025D * stack.stackSize * VSConfig.valkyriumCrystalForce, 0); } } } } } } }
Example 3
Source File: NoCrystalModule.java From seppuku with GNU General Public License v3.0 | 5 votes |
private boolean hasStack(Block type) { if (mc.player.inventory.getCurrentItem().getItem() instanceof ItemBlock) { final ItemBlock block = (ItemBlock) mc.player.inventory.getCurrentItem().getItem(); return block.getBlock() == type; } return false; }
Example 4
Source File: NoCrystalModule.java From seppuku with GNU General Public License v3.0 | 5 votes |
private boolean slotEqualsBlock (int slot, Block type) { if (mc.player.inventory.getStackInSlot(slot).getItem() instanceof ItemBlock) { final ItemBlock block = (ItemBlock) mc.player.inventory.getStackInSlot(slot).getItem(); return block.getBlock() == type; } return false; }
Example 5
Source File: NoCrystalModule.java From seppuku with GNU General Public License v3.0 | 5 votes |
private int findStackHotbar(Block type) { for (int i = 0; i < 9; i++) { final ItemStack stack = Minecraft.getMinecraft().player.inventory.getStackInSlot(i); if (stack.getItem() instanceof ItemBlock) { final ItemBlock block = (ItemBlock) stack.getItem(); if (block.getBlock() == type) { return i; } } } return -1; }
Example 6
Source File: RailReplacerEventHandler.java From Signals with GNU General Public License v3.0 | 5 votes |
private static BlockRailBase getRailBlock(ItemStack stack){ if(stack.getItem() instanceof ItemBlock) { ItemBlock item = (ItemBlock)stack.getItem(); return item.getBlock() instanceof BlockRailBase ? (BlockRailBase)item.getBlock() : null; //Only allow simple registered IRails to be placed } return null; }
Example 7
Source File: TileEntityDrawbridge.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
@Nullable private IBlockState getPlacementStateForPosition(int position, World world, BlockPos pos, FakePlayer player, ItemStack stack) { if (this.blockInfoTaken[position] != null) { return this.blockInfoTaken[position].getState(); } // The Normal variant shouldn't place blocks into positions it didn't take them from, // unless it hasn't taken any blocks but was instead extended with inserted-only items. if ((this.isAdvanced() || this.numTaken == 0) && stack.isEmpty() == false && stack.getItem() instanceof ItemBlock) { ItemBlock itemBlock = (ItemBlock) stack.getItem(); Block block = itemBlock.getBlock(); if (block != null && block != Blocks.AIR) { int meta = itemBlock.getMetadata(stack.getMetadata()); player.rotationYaw = this.getFacing().getHorizontalAngle(); return block.getStateForPlacement(world, pos, EnumFacing.UP, 0.5f, 1f, 0.5f, meta, player, EnumHand.MAIN_HAND); } } return null; }
Example 8
Source File: CraftingHelper.java From malmo with MIT License | 4 votes |
/** * Little utility method for dumping out a list of all the Minecraft items, plus as many useful attributes as * we can find for them. This is primarily used by decision_tree_test.py but might be useful for real-world applications too. * * @param filename location to save the dumped list. * @throws IOException */ public static void dumpItemProperties(String filename) throws IOException { FileOutputStream fos = new FileOutputStream("..//..//build//install//Python_Examples//item_database.json"); OutputStreamWriter osw = new OutputStreamWriter(fos, "utf-8"); BufferedWriter writer = new BufferedWriter(osw); JsonArray itemTypes = new JsonArray(); for (ResourceLocation i : Item.REGISTRY.getKeys()) { Item item = Item.REGISTRY.getObject(i); if (item != null) { JsonObject json = new JsonObject(); json.addProperty("type", Item.REGISTRY.getNameForObject(item).toString().replace("minecraft:", "")); json.addProperty("damageable", item.isDamageable()); json.addProperty("rendersIn3D", item.isFull3D()); json.addProperty("repairable", item.isRepairable()); CreativeTabs tab = item.getCreativeTab(); json.addProperty("tab", ((tab != null) ? item.getCreativeTab().getTabLabel() : "none")); ItemStack is = item.getDefaultInstance(); json.addProperty("stackable", is.isStackable()); json.addProperty("enchantable", is.isItemEnchantable()); json.addProperty("rare", (is.getRarity() == EnumRarity.RARE)); // Enum has four types, but only two (COMMON and RARE) appear to be used. json.addProperty("action", is.getItemUseAction().toString()); json.addProperty("hasSubtypes", item.getHasSubtypes()); json.addProperty("maxDamage", is.getMaxDamage()); json.addProperty("maxUseDuration", is.getMaxItemUseDuration()); json.addProperty("block", item instanceof ItemBlock); json.addProperty("hasContainerItem", item.hasContainerItem()); if (item instanceof ItemBlock) { ItemBlock ib = (ItemBlock) item; Block b = ib.getBlock(); IBlockState bs = b.getDefaultState(); json.addProperty("slipperiness", b.slipperiness); json.addProperty("hardness", bs.getBlockHardness(null, null)); json.addProperty("causesSuffocation", bs.causesSuffocation()); json.addProperty("canProvidePower", bs.canProvidePower()); json.addProperty("translucent", bs.isTranslucent()); Material mat = bs.getMaterial(); if (mat != null) { json.addProperty("canBurn", mat.getCanBurn()); json.addProperty("isLiquid", mat.isLiquid()); json.addProperty("blocksMovement", mat.blocksMovement()); json.addProperty("needsNoTool", mat.isToolNotRequired()); json.addProperty("isReplaceable", mat.isReplaceable()); json.addProperty("pistonPushable", mat.getMobilityFlag() == EnumPushReaction.NORMAL); json.addProperty("woodenMaterial", mat == Material.WOOD); json.addProperty("ironMaterial", mat == Material.IRON); json.addProperty("glassyMaterial", mat == Material.GLASS); json.addProperty("clothMaterial", mat == Material.CLOTH); } boolean hasDirection = false; boolean hasColour = false; boolean hasVariant = false; for (IProperty prop : bs.getProperties().keySet()) { System.out.println(Item.REGISTRY.getNameForObject(item).toString() + " -- " + prop); if (prop instanceof PropertyDirection) hasDirection = true; if (prop instanceof PropertyEnum && prop.getName().equals("color")) hasColour = true; if (prop instanceof PropertyEnum && prop.getName().equals("variant")) { hasVariant = true; json.addProperty("variant", bs.getValue(prop).toString()); } } json.addProperty("hasDirection", hasDirection); json.addProperty("hasColour", hasColour); json.addProperty("hasVariant", hasVariant); } itemTypes.add(json); } } writer.write(itemTypes.toString()); writer.close(); }