2012-01-14 13:50:09 +01:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
|
|
|
import java.util.Random;
|
2012-07-22 08:18:00 +02:00
|
|
|
|
|
|
|
// CraftBukkit start
|
|
|
|
import org.bukkit.block.BlockState;
|
|
|
|
import org.bukkit.event.block.BlockFadeEvent;
|
|
|
|
import org.bukkit.event.block.BlockSpreadEvent;
|
|
|
|
// CraftBukkit end
|
2012-01-14 13:50:09 +01:00
|
|
|
|
|
|
|
public class BlockMycel extends Block {
|
|
|
|
|
|
|
|
protected BlockMycel(int i) {
|
|
|
|
super(i, Material.GRASS);
|
2012-07-29 09:33:13 +02:00
|
|
|
this.b(true);
|
|
|
|
this.a(CreativeModeTab.b);
|
2012-01-14 13:50:09 +01:00
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public void a(World world, int i, int j, int k, Random random) {
|
2012-01-14 13:50:09 +01:00
|
|
|
if (!world.isStatic) {
|
2012-01-14 21:03:48 +01:00
|
|
|
if (world.getLightLevel(i, j + 1, k) < 4 && Block.lightBlock[world.getTypeId(i, j + 1, k)] > 2) {
|
2012-01-14 13:56:54 +01:00
|
|
|
// CraftBukkit start
|
|
|
|
org.bukkit.World bworld = world.getWorld();
|
2012-07-22 08:18:00 +02:00
|
|
|
BlockState blockState = bworld.getBlockAt(i, j, k).getState();
|
2012-01-14 13:56:54 +01:00
|
|
|
blockState.setTypeId(Block.DIRT.id);
|
|
|
|
|
|
|
|
BlockFadeEvent event = new BlockFadeEvent(blockState.getBlock(), blockState);
|
|
|
|
world.getServer().getPluginManager().callEvent(event);
|
|
|
|
|
|
|
|
if (!event.isCancelled()) {
|
|
|
|
blockState.update(true);
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
2012-01-14 13:50:09 +01:00
|
|
|
} else if (world.getLightLevel(i, j + 1, k) >= 9) {
|
|
|
|
for (int l = 0; l < 4; ++l) {
|
|
|
|
int i1 = i + random.nextInt(3) - 1;
|
|
|
|
int j1 = j + random.nextInt(5) - 3;
|
|
|
|
int k1 = k + random.nextInt(3) - 1;
|
|
|
|
int l1 = world.getTypeId(i1, j1 + 1, k1);
|
|
|
|
|
2012-01-14 21:03:48 +01:00
|
|
|
if (world.getTypeId(i1, j1, k1) == Block.DIRT.id && world.getLightLevel(i1, j1 + 1, k1) >= 4 && Block.lightBlock[l1] <= 2) {
|
2012-01-14 13:56:54 +01:00
|
|
|
// CraftBukkit start
|
|
|
|
org.bukkit.World bworld = world.getWorld();
|
2012-07-22 08:18:00 +02:00
|
|
|
BlockState blockState = bworld.getBlockAt(i1, j1, k1).getState();
|
2012-01-14 13:56:54 +01:00
|
|
|
blockState.setTypeId(this.id);
|
|
|
|
|
|
|
|
BlockSpreadEvent event = new BlockSpreadEvent(blockState.getBlock(), bworld.getBlockAt(i, j, k), blockState);
|
|
|
|
world.getServer().getPluginManager().callEvent(event);
|
|
|
|
|
|
|
|
if (!event.isCancelled()) {
|
|
|
|
blockState.update(true);
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
2012-01-14 13:50:09 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getDropType(int i, Random random, int j) {
|
|
|
|
return Block.DIRT.getDropType(0, random, j);
|
|
|
|
}
|
|
|
|
}
|