Java Code Examples for org.bukkit.block.BlockState#setTypeId()

The following examples show how to use org.bukkit.block.BlockState#setTypeId() . 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: BlockImage.java    From PGM with GNU Affero General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
public BlockState getState(BlockVector pos) {
  int offset = this.offset(pos);
  BlockState state = pos.toLocation(this.world).getBlock().getState();
  state.setTypeId(this.blockIds[offset]);
  state.setRawData(this.blockData[offset]);
  return state;
}
 
Example 2
Source File: CraftEventFactory.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
/**
 * BlockFadeEvent
 */
public static BlockFadeEvent callBlockFadeEvent(Block block, net.minecraft.block.Block type) {
    BlockState state = block.getState();
    state.setTypeId(net.minecraft.block.Block.getIdFromBlock(type));

    BlockFadeEvent event = new BlockFadeEvent(block, state);
    Bukkit.getPluginManager().callEvent(event);
    return event;
}
 
Example 3
Source File: CraftEventFactory.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
public static boolean handleBlockSpreadEvent(Block block, Block source, net.minecraft.block.Block type, int data) {
    BlockState state = block.getState();
    state.setTypeId(net.minecraft.block.Block.getIdFromBlock(type));
    state.setRawData((byte) data);

    BlockSpreadEvent event = new BlockSpreadEvent(block, source, state);
    Bukkit.getPluginManager().callEvent(event);

    if (!event.isCancelled()) {
        state.update(true);
    }
    return !event.isCancelled();
}
 
Example 4
Source File: StructureGrowDelegate.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
public boolean setRawTypeIdAndData(int x, int y, int z, int type, int data) {
    BlockState state = world.getBlockAt(x, y, z).getState();
    state.setTypeId(type);
    state.setData(new MaterialData(type, (byte) data));
    blocks.add(state);
    return true;
}
 
Example 5
Source File: BlockImage.java    From ProjectAres with GNU Affero General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
public BlockState getState(BlockVector pos) {
    int offset = this.offset(pos);
    BlockState state = pos.toLocation(this.world).getBlock().getState();
    state.setTypeId(this.blockIds[offset]);
    state.setRawData(this.blockData[offset]);
    return state;
}
 
Example 6
Source File: BlockMaterialMap.java    From ProjectAres with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public BlockState next() {
    Block block = BlockUtils.blockAt(world, iter.key());
    if(block == null) return null;
    BlockState state = block.getState();
    state.setTypeId(decodeTypeId(iter.value()));
    state.setRawData(decodeMetadata(iter.value()));
    return state;
}
 
Example 7
Source File: CraftEventFactory.java    From Thermos with GNU General Public License v3.0 5 votes vote down vote up
/**
 * BlockFadeEvent
 */
public static BlockFadeEvent callBlockFadeEvent(Block block, net.minecraft.block.Block type) {
    BlockState state = block.getState();
    state.setTypeId(net.minecraft.block.Block.getIdFromBlock(type));

    BlockFadeEvent event = new BlockFadeEvent(block, state);
    Bukkit.getPluginManager().callEvent(event);
    return event;
}
 
Example 8
Source File: CraftEventFactory.java    From Thermos with GNU General Public License v3.0 5 votes vote down vote up
public static void handleBlockSpreadEvent(Block block, Block source, net.minecraft.block.Block type, int data) {
    BlockState state = block.getState();
    state.setTypeId(net.minecraft.block.Block.getIdFromBlock(type));
    state.setRawData((byte) data);

    BlockSpreadEvent event = new BlockSpreadEvent(block, source, state);
    Bukkit.getPluginManager().callEvent(event);

    if (!event.isCancelled()) {
        state.update(true);
    }
}
 
Example 9
Source File: StructureGrowDelegate.java    From Thermos with GNU General Public License v3.0 5 votes vote down vote up
public boolean setRawTypeIdAndData(int x, int y, int z, int type, int data) {
    BlockState state = world.getBlockAt(x, y, z).getState();
    state.setTypeId(type);
    state.setData(new MaterialData(type, (byte) data));
    blocks.add(state);
    return true;
}
 
Example 10
Source File: BlockStateListPopulator.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public void setTypeAndData(int x, int y, int z, Block block, int data, int light) {
    BlockState state = world.getBlockAt(x, y, z).getState();
    state.setTypeId(Block.getIdFromBlock(block));
    state.setRawData((byte) data);
    list.add(state);
}
 
Example 11
Source File: BlockStateListPopulator.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public void setTypeId(int x, int y, int z, int type) {
    BlockState state = world.getBlockAt(x, y, z).getState();
    state.setTypeId(type);
    list.add(state);
}
 
Example 12
Source File: BlockStateListPopulator.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public void setType(int x, int y, int z, Block block) {
    BlockState state = world.getBlockAt(x, y, z).getState();
    state.setTypeId(Block.getIdFromBlock(block));
    list.add(state);
}
 
Example 13
Source File: BlockStateListPopulator.java    From Thermos with GNU General Public License v3.0 4 votes vote down vote up
public void setTypeId(int x, int y, int z, int type) {
    BlockState state = world.getBlockAt(x, y, z).getState();
    state.setTypeId(type);
    list.add(state);
}
 
Example 14
Source File: BlockStateListPopulator.java    From Thermos with GNU General Public License v3.0 4 votes vote down vote up
public void setType(int x, int y, int z, net.minecraft.block.Block block) {
    BlockState state = world.getBlockAt(x, y, z).getState();
    state.setTypeId(net.minecraft.block.Block.getIdFromBlock(block));
    list.add(state);
}
 
Example 15
Source File: ItemManager.java    From civcraft with GNU General Public License v2.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
public static void setTypeId(BlockState block, int typeId) {
	block.setTypeId(typeId);
}
 
Example 16
Source File: BlockFire.java    From Carbon with GNU Lesser General Public License v3.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
public void a(World world, int i, int j, int k, Random random) {
	if(world.getGameRules().getBoolean("doFireTick")) {
		boolean flag = world.getType(i, j - 1, k) == Blocks.NETHERRACK;
		if(((world.worldProvider instanceof WorldProviderTheEnd)) && (world.getType(i, j - 1, k) == Blocks.BEDROCK)) {
			flag = true;
		}
		if(!canPlace(world, i, j, k)) {
			fireExtinguished(world, i, j, k);
		}
		if((!flag) && (world.Q()) && ((world.isRainingAt(i, j, k)) || (world.isRainingAt(i - 1, j, k)) || (world.isRainingAt(i + 1, j, k)) || (world.isRainingAt(i, j, k - 1)) || (world.isRainingAt(i, j, k + 1)))) {
			fireExtinguished(world, i, j, k);
		}
		else {
			int l = world.getData(i, j, k);
			if(l < 15) {
				world.setData(i, j, k, l + random.nextInt(3) / 2, 4);
			}
			world.a(i, j, k, this, a(world) + random.nextInt(10));
			if((!flag) && (!e(world, i, j, k))) {
				if((!World.a(world, i, j - 1, k)) || (l > 3)) {
					fireExtinguished(world, i, j, k);
				}
			}
			else if((!flag) && (!e(world, i, j - 1, k)) && (l == 15) && (random.nextInt(4) == 0)) {
				fireExtinguished(world, i, j, k);
			}
			else {
				boolean flag1 = world.z(i, j, k);
				byte b0 = 0;
				if(flag1) {
					b0 = -50;
				}
				a(world, i + 1, j, k, 300 + b0, random, l);
				a(world, i - 1, j, k, 300 + b0, random, l);
				a(world, i, j - 1, k, 250 + b0, random, l);
				a(world, i, j + 1, k, 250 + b0, random, l);
				a(world, i, j, k - 1, 300 + b0, random, l);
				a(world, i, j, k + 1, 300 + b0, random, l);
				for(int i1 = i - 1; i1 <= i + 1; i1++) {
					for(int j1 = k - 1; j1 <= k + 1; j1++) {
						for(int k1 = j - 1; k1 <= j + 4; k1++) {
							if((i1 != i) || (k1 != j) || (j1 != k)) {
								int l1 = 100;
								if(k1 > j + 1) {
									l1 += (k1 - (j + 1)) * 100;
								}
								int i2 = m(world, i1, k1, j1);
								if(i2 > 0) {
									int j2 = (i2 + 40 + world.difficulty.a() * 7) / (l + 30);
									if(flag1) {
										j2 /= 2;
									}
									if((j2 > 0) && (random.nextInt(l1) <= j2) && ((!world.Q()) || (!world.isRainingAt(i1, k1, j1))) && (!world.isRainingAt(i1 - 1, k1, k)) && (!world.isRainingAt(i1 + 1, k1, j1)) && (!world.isRainingAt(i1, k1, j1 - 1)) && (!world.isRainingAt(i1, k1, j1 + 1))) {
										int k2 = l + random.nextInt(5) / 4;
										if(k2 > 15) {
											k2 = 15;
										}
										if((world.getType(i1, k1, j1) != this) && (!CraftEventFactory.callBlockIgniteEvent(world, i1, k1, j1, i, j, k).isCancelled())) {
											Server server = world.getServer();
											org.bukkit.World bworld = world.getWorld();
											BlockState blockState = bworld.getBlockAt(i1, k1, j1).getState();
											blockState.setTypeId(Block.getId(this));
											blockState.setData(new MaterialData(Block.getId(this), (byte) k2));

											BlockSpreadEvent spreadEvent = new BlockSpreadEvent(blockState.getBlock(), bworld.getBlockAt(i, j, k), blockState);
											server.getPluginManager().callEvent(spreadEvent);
											if(!spreadEvent.isCancelled()) {
												blockState.update(true);
											}
										}
									}
								}
							}
						}
					}
				}
			}
		}
	}
}