net.minecraft.block.BlockContainer Java Examples

The following examples show how to use net.minecraft.block.BlockContainer. 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: CraftBlock.java    From Kettle with GNU General Public License v3.0 6 votes vote down vote up
public boolean setTypeIdAndData(final int type, final byte data, final boolean applyPhysics) {
    IBlockState blockData = getNMSBlock(type).getStateFromMeta(data);
    BlockPos position = new BlockPos(x, y, z);

    // SPIGOT-611: need to do this to prevent glitchiness. Easier to handle this here (like /setblock) than to fix weirdness in tile entity cleanup
    if (type != 0 && blockData.getBlock() instanceof BlockContainer && type != getTypeId()) {
        chunk.getHandle().getWorld().setBlockState(position, Blocks.AIR.getDefaultState(), 0);
    }

    if (applyPhysics) {
        return chunk.getHandle().getWorld().setBlockState(position, blockData, 3);
    } else {
        IBlockState old = chunk.getHandle().getBlockState(position);
        boolean success = chunk.getHandle().getWorld().setBlockState(position, blockData, 18); // NOTIFY | NO_OBSERVER
        if (success) {
            chunk.getHandle().getWorld().notifyBlockUpdate(
                    position,
                    old,
                    blockData,
                    3
            );
        }
        return success;
    }
}
 
Example #2
Source File: BlockGarden.java    From GardenCollection with MIT License 6 votes vote down vote up
public boolean isPlantValidForSlot (World world, int x, int y, int z, int slot, PlantItem plant) {
    if (plant == null)
        return false;

    if (plant.getPlantBlock() instanceof BlockContainer)
        return false;

    if (!slotProfile.isPlantValidForSlot(world, x, y, z, slot, plant))
        return false;

    if (!enoughSpaceAround(world, x, y, z, slot, plant))
        return false;

    if (!isPlantValidForSubstrate(getGardenSubstrate(world, x, y, z, slot), plant))
        return false;

    if (canSustainPlantIndependently(world, x, y, z, plant))
        return false;

    return true;
}