Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-20 05:20:07 +01:00
Refactored some code from nms to ob for minimal diffs
Dieser Commit ist enthalten in:
Ursprung
1e8bbbfbd5
Commit
f165d4082d
@ -1,8 +1,7 @@
|
|||||||
package net.minecraft.server;
|
package net.minecraft.server;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||||
import org.bukkit.event.block.BlockFadeEvent; // CraftBukkit
|
|
||||||
|
|
||||||
public class BlockIce extends BlockBreakable {
|
public class BlockIce extends BlockBreakable {
|
||||||
|
|
||||||
@ -28,13 +27,7 @@ public class BlockIce extends BlockBreakable {
|
|||||||
public void a(World world, int i, int j, int k, Random random) {
|
public void a(World world, int i, int j, int k, Random random) {
|
||||||
if (world.a(EnumSkyBlock.BLOCK, i, j, k) > 11 - Block.q[this.id]) {
|
if (world.a(EnumSkyBlock.BLOCK, i, j, k) > 11 - Block.q[this.id]) {
|
||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
org.bukkit.block.BlockState blockState = world.getWorld().getBlockAt(i, j, k).getState();
|
if (CraftEventFactory.callBlockFadeEvent(world.getWorld().getBlockAt(i, j, k), Block.STATIONARY_WATER.id).isCancelled()) {
|
||||||
blockState.setTypeId(Block.STATIONARY_WATER.id);
|
|
||||||
|
|
||||||
BlockFadeEvent event = new BlockFadeEvent(blockState.getBlock(), blockState);
|
|
||||||
world.getServer().getPluginManager().callEvent(event);
|
|
||||||
|
|
||||||
if (event.isCancelled()) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
package net.minecraft.server;
|
package net.minecraft.server;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||||
import org.bukkit.event.block.BlockFadeEvent; // CraftBukkit
|
|
||||||
|
|
||||||
public class BlockSnow extends Block {
|
public class BlockSnow extends Block {
|
||||||
|
|
||||||
@ -78,13 +77,7 @@ public class BlockSnow extends Block {
|
|||||||
public void a(World world, int i, int j, int k, Random random) {
|
public void a(World world, int i, int j, int k, Random random) {
|
||||||
if (world.a(EnumSkyBlock.BLOCK, i, j, k) > 11) {
|
if (world.a(EnumSkyBlock.BLOCK, i, j, k) > 11) {
|
||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
org.bukkit.block.BlockState blockState = world.getWorld().getBlockAt(i, j, k).getState();
|
if (CraftEventFactory.callBlockFadeEvent(world.getWorld().getBlockAt(i, j, k), 0).isCancelled()) {
|
||||||
blockState.setTypeId(0);
|
|
||||||
|
|
||||||
BlockFadeEvent event = new BlockFadeEvent(blockState.getBlock(), blockState);
|
|
||||||
world.getServer().getPluginManager().callEvent(event);
|
|
||||||
|
|
||||||
if (event.isCancelled()) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
|
@ -37,17 +37,10 @@ import org.bukkit.entity.AnimalTamer;
|
|||||||
import org.bukkit.entity.CreatureType;
|
import org.bukkit.entity.CreatureType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Event.Type;
|
import org.bukkit.event.Event.Type;
|
||||||
import org.bukkit.event.block.Action;
|
import org.bukkit.event.block.*;
|
||||||
import org.bukkit.event.block.BlockDamageEvent;
|
import org.bukkit.event.entity.*;
|
||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
|
||||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
|
||||||
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
||||||
import org.bukkit.event.entity.EntityTameEvent;
|
import org.bukkit.event.player.*;
|
||||||
import org.bukkit.event.entity.ItemSpawnEvent;
|
|
||||||
import org.bukkit.event.player.PlayerBucketEmptyEvent;
|
|
||||||
import org.bukkit.event.player.PlayerBucketFillEvent;
|
|
||||||
import org.bukkit.event.player.PlayerEvent;
|
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
|
||||||
|
|
||||||
public class CraftEventFactory {
|
public class CraftEventFactory {
|
||||||
private static boolean canBuild(CraftWorld world, Player player, int x, int z) {
|
private static boolean canBuild(CraftWorld world, Player player, int x, int z) {
|
||||||
@ -260,4 +253,16 @@ public class CraftEventFactory {
|
|||||||
craftServer.getPluginManager().callEvent(event);
|
craftServer.getPluginManager().callEvent(event);
|
||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* BlockFadeEvent
|
||||||
|
*/
|
||||||
|
public static BlockFadeEvent callBlockFadeEvent(Block block, int type) {
|
||||||
|
BlockState state = block.getState();
|
||||||
|
state.setTypeId(type);
|
||||||
|
|
||||||
|
BlockFadeEvent event = new BlockFadeEvent(block, state);
|
||||||
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
return event;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren