public static Set<MaterialData> getBlockStates(Material material) { ImmutableSet.Builder<MaterialData> materials = ImmutableSet.builder(); Block nmsBlock = CraftMagicNumbers.getBlock(material); List<IBlockData> states = nmsBlock.s().a(); if(states != null) { for(IBlockData state : states) { int data = nmsBlock.toLegacyData(state); materials.add(material.getNewData((byte) data)); } } return materials.build(); }
public void setDisplayBlock(MaterialData material) { if(material != null) { IBlockData block = CraftMagicNumbers.getBlock(material.getItemTypeId()).fromLegacyData(material.getData()); this.getHandle().setDisplayBlock(block); } else { // Set block to air (default) and set the flag to not have a display block. this.getHandle().setDisplayBlock(Blocks.AIR.getBlockData()); this.getHandle().a(false); } }
public boolean update(boolean force, boolean applyPhysics) { requirePlaced(); Block block = getBlock(); if (block.getType() != getType()) { if (!force) { return false; } } BlockPosition pos = new BlockPosition(x, y, z); IBlockData newBlock = CraftMagicNumbers.getBlock(getType()).fromLegacyData(getRawData()); block.setTypeIdAndData(getTypeId(), getRawData(), applyPhysics); world.getHandle().notify( pos, CraftMagicNumbers.getBlock(block).fromLegacyData(block.getData()), newBlock, 3 ); // Update levers etc if (applyPhysics && getData() instanceof Attachable) { world.getHandle().applyPhysics(pos.shift(CraftBlock.blockFaceToNotch(((Attachable) getData()).getAttachedFace())), newBlock.getBlock()); } return true; }
public MaterialData getDisplayBlock() { IBlockData blockData = getHandle().getDisplayBlock(); return CraftMagicNumbers.getMaterial(blockData.getBlock()).getNewData((byte) blockData.getBlock().toLegacyData(blockData)); }
public MaterialData getCarriedMaterial() { IBlockData blockData = getHandle().getCarried(); return CraftMagicNumbers.getMaterial(blockData.getBlock()).getNewData((byte) blockData.getBlock().toLegacyData(blockData)); }
public MaterialData getCarriedMaterial() { IBlockData blockData = getHandle().getCarried(); return (blockData == null) ? Material.AIR.getNewData((byte) 0) : CraftMagicNumbers.getMaterial(blockData.getBlock()).getNewData((byte) blockData.getBlock().toLegacyData(blockData)); }
public void setTypeUpdate(BlockPosition position, IBlockData data) { setTypeAndData(position.getX(), position.getY(), position.getZ(), data.getBlock(), data.getBlock().toLegacyData(data), 0); }