Java Code Examples for org.bukkit.Material#getId()

The following examples show how to use org.bukkit.Material#getId() . 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: Schematic.java    From askyblock with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @param playerSpawnBlock the playerSpawnBlock to set
 * @return true if block is found otherwise false
 */
@SuppressWarnings("deprecation")
public boolean setPlayerSpawnBlock(Material playerSpawnBlock) {
    if (bedrock == null) {
        return false;
    }
    playerSpawn = null;
    // Run through the schematic and try and find the spawnBlock
    for (IslandBlock islandBlock : islandBlocks) {
        if (islandBlock.getTypeId() == playerSpawnBlock.getId()) {
            playerSpawn = islandBlock.getVector().subtract(bedrock).add(new Vector(0.5D,-1D,0.5D));
            // Set the block to air
            islandBlock.setTypeId((short)0);
            return true;
        }
    }
    return false;
}
 
Example 2
Source File: PacketPlayOutBlockChange.java    From NovaGuilds with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Creates the packet
 *
 * @param location location
 * @param material material
 * @param data     data byte (color, type etc.)
 * @throws IllegalAccessException    when something goes wrong
 * @throws InvocationTargetException when something goes wrong
 * @throws InstantiationException    when something goes wrong
 */
public PacketPlayOutBlockChange(Location location, Material material, int data) throws IllegalAccessException, InstantiationException, InvocationTargetException {
	packet = packetPlayOutBlockChangeClass.newInstance();

	xField.set(packet, location.getBlockX());
	yField.set(packet, location.getBlockY());
	zField.set(packet, location.getBlockZ());

	Object block;
	if(material == null) {
		block = getBlockAtMethod.invoke(
				Reflections.getHandle(location.getWorld()),
				location.getBlockX(),
				location.getBlockY(),
				location.getBlockZ()
		);
	}
	else {
		Object id = material.getId();
		block = getByIdMethod.invoke(null, id);
	}

	blockField.set(packet, block);
	dataField.set(packet, data);
}
 
Example 3
Source File: CraftStatistic.java    From Thermos with GNU General Public License v3.0 6 votes vote down vote up
public static net.minecraft.stats.StatBase getMaterialStatistic(org.bukkit.Statistic stat, Material material) {
    try {
        if (stat == Statistic.MINE_BLOCK) {
            return StatList.mineBlockStatArray[material.getId()];
        }
        if (stat == Statistic.CRAFT_ITEM) {
            return StatList.objectCraftStats[material.getId()];
        }
        if (stat == Statistic.USE_ITEM) {
            return StatList.objectUseStats[material.getId()];
        }
        if (stat == Statistic.BREAK_ITEM) {
            return StatList.objectBreakStats[material.getId()];
        }
    } catch (ArrayIndexOutOfBoundsException e) {
        return null;
    }
    return null;
}
 
Example 4
Source File: PacketPlayOutBlockChange.java    From NovaGuilds with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Creates the packet
 *
 * @param location location
 * @param material material
 * @param data     data byte (color, type etc.)
 * @throws IllegalAccessException    when something goes wrong
 * @throws InvocationTargetException when something goes wrong
 * @throws InstantiationException    when something goes wrong
 */
public PacketPlayOutBlockChange(Location location, Material material, int data) throws IllegalAccessException, InstantiationException, InvocationTargetException {
	packet = packetPlayOutBlockChangeClass.newInstance();

	xField.set(packet, location.getBlockX());
	yField.set(packet, location.getBlockY());
	zField.set(packet, location.getBlockZ());

	Object block;
	if(material == null) {
		block = getBlockAtMethod.invoke(
				Reflections.getHandle(location.getWorld()),
				location.getBlockX(),
				location.getBlockY(),
				location.getBlockZ()
		);
	}
	else {
		Object id = material.getId();
		block = getByIdMethod.invoke(null, id);
	}

	blockField.set(packet, block);
	dataField.set(packet, data);
}
 
Example 5
Source File: CraftBlockState.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
public CraftBlockState(Material material) {
    world = null;
    type = material.getId();
    chunk = null;
    x = y = z = 0;
    this.nbt = null;
}
 
Example 6
Source File: PaperPatch.java    From ViaVersion with MIT License 5 votes vote down vote up
private boolean isPlacable(Material material) {
    if (!material.isSolid()) return true;
    // signs and banners
    switch (material.getId()) {
        case 63:
        case 68:
        case 176:
        case 177:
            return true;
        default:
            return false;
    }
}
 
Example 7
Source File: ParticleEffect.java    From Crazy-Crates with MIT License 5 votes vote down vote up
/**
 * Construct a new particle data
 *
 * @param material Material of the item/block
 * @param data Data value of the item/block
 */
@SuppressWarnings("deprecation")
public ParticleData(Material material, byte data) {
    this.material = material;
    this.data = data;
    this.packetData = new int[] {material.getId(), data};
}
 
Example 8
Source File: CompatibilityUtils.java    From NovaGuilds with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Gets material by id
 *
 * @param id id
 * @return material enum
 */
public static Material getMaterial(int id) {
	for(Material material : Material.values()) {
		if(material.getId() == id) {
			return material;
		}
	}

	return null;
}
 
Example 9
Source File: ParticleEffect.java    From NovaGuilds with GNU General Public License v3.0 5 votes vote down vote up
/**
 * The constructor
 *
 * @param material material
 * @param data     data byte
 */
public ParticleData(Material material, byte data) {
	this.material = material;
	this.data = data;
	this.packetData = new int[]{
			material.getId(),
			data
	};
}
 
Example 10
Source File: FaweAdapter_1_12.java    From FastAsyncWorldedit with GNU General Public License v3.0 4 votes vote down vote up
public int getBlockId(Material material)
{
    return material.getId();
}
 
Example 11
Source File: ItemManager.java    From civcraft with GNU General Public License v2.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
public static int getId(Material material) {
	return material.getId();
}
 
Example 12
Source File: FaweAdapter_All.java    From FastAsyncWorldedit with GNU General Public License v3.0 4 votes vote down vote up
@Override
public int getBlockId(Material material) {
    return material.getId();
}
 
Example 13
Source File: FaweAdapter_1_11.java    From FastAsyncWorldedit with GNU General Public License v3.0 4 votes vote down vote up
public int getBlockId(Material material)
{
    return material.getId();
}
 
Example 14
Source File: FaweAdapter_1_9.java    From FastAsyncWorldedit with GNU General Public License v3.0 4 votes vote down vote up
public int getBlockId(Material material)
{
    return material.getId();
}
 
Example 15
Source File: FaweAdapter_1_10.java    From FastAsyncWorldedit with GNU General Public License v3.0 4 votes vote down vote up
public int getBlockId(Material material)
{
    return material.getId();
}
 
Example 16
Source File: ItemStack.java    From Kettle with GNU General Public License v3.0 2 votes vote down vote up
/**
 * An item stack with no extra data
 *
 * @param type   item material
 * @param amount stack size
 */
public ItemStack(final Material type, final int amount) {
    this(type.getId(), amount);
}
 
Example 17
Source File: MaterialData.java    From Kettle with GNU General Public License v3.0 2 votes vote down vote up
/**
 * @param type the type
 * @param data the raw data value
 * @deprecated Magic value
 */
@Deprecated
public MaterialData(final Material type, final byte data) {
    this(type.getId(), data);
}
 
Example 18
Source File: ItemStack.java    From Kettle with GNU General Public License v3.0 2 votes vote down vote up
/**
 * @param type   the type
 * @param amount the amount in the stack
 * @param damage the damage value of the item
 * @param data   the data value or null
 * @deprecated this method uses an ambiguous data byte object
 */
@Deprecated
public ItemStack(final Material type, final int amount, final short damage, final Byte data) {
    this(type.getId(), amount, damage, data);
}
 
Example 19
Source File: ItemStack.java    From Kettle with GNU General Public License v3.0 2 votes vote down vote up
/**
 * An item stack with the specified damage / durability
 *
 * @param type   item material
 * @param amount stack size
 * @param damage durability / damage
 */
public ItemStack(final Material type, final int amount, final short damage) {
    this(type.getId(), amount, damage);
}