mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-08 11:50:32 +01:00
SPIGOT-4352: MoistureChangeEvent
This commit is contained in:
parent
226db0eae7
commit
3123a069bf
@ -12,7 +12,21 @@
|
|||||||
public class BlockSoil extends Block {
|
public class BlockSoil extends Block {
|
||||||
|
|
||||||
public static final BlockStateInteger MOISTURE = BlockProperties.ai;
|
public static final BlockStateInteger MOISTURE = BlockProperties.ai;
|
||||||
@@ -63,14 +68,37 @@
|
@@ -51,26 +56,49 @@
|
||||||
|
|
||||||
|
if (!a((IWorldReader) world, blockposition) && !world.isRainingAt(blockposition.up())) {
|
||||||
|
if (i > 0) {
|
||||||
|
- world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockSoil.MOISTURE, Integer.valueOf(i - 1)), 2);
|
||||||
|
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleMoistureChangeEvent(world, blockposition, (IBlockData) iblockdata.set(BlockSoil.MOISTURE, Integer.valueOf(i - 1)), 2); // CraftBukkit
|
||||||
|
} else if (!a((IBlockAccess) world, blockposition)) {
|
||||||
|
b(iblockdata, world, blockposition);
|
||||||
|
}
|
||||||
|
} else if (i < 7) {
|
||||||
|
- world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockSoil.MOISTURE, Integer.valueOf(7)), 2);
|
||||||
|
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleMoistureChangeEvent(world, blockposition, (IBlockData) iblockdata.set(BlockSoil.MOISTURE, Integer.valueOf(7)), 2); // CraftBukkit
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void fallOn(World world, BlockPosition blockposition, Entity entity, float f) {
|
public void fallOn(World world, BlockPosition blockposition, Entity entity, float f) {
|
||||||
|
@ -373,6 +373,19 @@ public class CraftEventFactory {
|
|||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean handleMoistureChangeEvent(World world, BlockPosition pos, IBlockData newBlock, int flag) {
|
||||||
|
CraftBlockState state = CraftBlockState.getBlockState(world, pos, flag);
|
||||||
|
state.setData(newBlock);
|
||||||
|
|
||||||
|
MoistureChangeEvent event = new MoistureChangeEvent(state.getBlock(), state);
|
||||||
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
|
||||||
|
if (!event.isCancelled()) {
|
||||||
|
state.update(true);
|
||||||
|
}
|
||||||
|
return !event.isCancelled();
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean handleBlockSpreadEvent(World world, BlockPosition source, BlockPosition target, IBlockData block) {
|
public static boolean handleBlockSpreadEvent(World world, BlockPosition source, BlockPosition target, IBlockData block) {
|
||||||
return handleBlockSpreadEvent(world, source, target, block, 2);
|
return handleBlockSpreadEvent(world, source, target, block, 2);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user