mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-05 10:20:53 +01:00
Use CraftEventFactory for BlockFormEvent
This commit is contained in:
parent
521b64741e
commit
caf86c88a9
@ -9,21 +9,14 @@
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
public class EnchantmentFrostWalker extends Enchantment {
|
public class EnchantmentFrostWalker extends Enchantment {
|
||||||
@@ -42,8 +45,18 @@
|
@@ -42,8 +45,11 @@
|
||||||
IBlockData iblockdata1 = world.getType(blockposition_mutableblockposition1);
|
IBlockData iblockdata1 = world.getType(blockposition_mutableblockposition1);
|
||||||
|
|
||||||
if (iblockdata1.getMaterial() == Material.WATER && ((Integer) iblockdata1.get(BlockFluids.LEVEL)).intValue() == 0 && world.a(Blocks.FROSTED_ICE, blockposition_mutableblockposition1, false, EnumDirection.DOWN, (Entity) null)) {
|
if (iblockdata1.getMaterial() == Material.WATER && ((Integer) iblockdata1.get(BlockFluids.LEVEL)).intValue() == 0 && world.a(Blocks.FROSTED_ICE, blockposition_mutableblockposition1, false, EnumDirection.DOWN, (Entity) null)) {
|
||||||
- world.setTypeUpdate(blockposition_mutableblockposition1, Blocks.FROSTED_ICE.getBlockData());
|
- world.setTypeUpdate(blockposition_mutableblockposition1, Blocks.FROSTED_ICE.getBlockData());
|
||||||
- world.a(blockposition_mutableblockposition1.h(), Blocks.FROSTED_ICE, MathHelper.nextInt(entityliving.getRandom(), 60, 120));
|
- world.a(blockposition_mutableblockposition1.h(), Blocks.FROSTED_ICE, MathHelper.nextInt(entityliving.getRandom(), 60, 120));
|
||||||
+ // CraftBukkit Start - Call EntityBlockFormEvent for Frost Walker
|
+ // CraftBukkit Start - Call EntityBlockFormEvent for Frost Walker
|
||||||
+ org.bukkit.block.BlockState blockState = world.getWorld().getBlockAt(blockposition_mutableblockposition1.getX(), blockposition_mutableblockposition1.getY(), blockposition_mutableblockposition1.getZ()).getState();
|
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition_mutableblockposition1, Blocks.FROSTED_ICE, entityliving)) {
|
||||||
+ blockState.setType(CraftMagicNumbers.getMaterial(Blocks.FROSTED_ICE));
|
|
||||||
+
|
|
||||||
+ EntityBlockFormEvent event = new EntityBlockFormEvent(entityliving.bukkitEntity, blockState.getBlock(), blockState);
|
|
||||||
+ world.getServer().getPluginManager().callEvent(event);
|
|
||||||
+
|
|
||||||
+ if (!event.isCancelled()) {
|
|
||||||
+ blockState.update(true);
|
|
||||||
+ world.a(blockposition_mutableblockposition1.h(), Blocks.FROSTED_ICE, MathHelper.nextInt(entityliving.getRandom(), 60, 120));
|
+ world.a(blockposition_mutableblockposition1.h(), Blocks.FROSTED_ICE, MathHelper.nextInt(entityliving.getRandom(), 60, 120));
|
||||||
+ }
|
+ }
|
||||||
+ // CraftBukkit End
|
+ // CraftBukkit End
|
||||||
|
@ -21,22 +21,12 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!this.world.getGameRules().getBoolean("mobGriefing")) {
|
if (!this.world.getGameRules().getBoolean("mobGriefing")) {
|
||||||
@@ -73,7 +78,17 @@
|
@@ -73,7 +78,7 @@
|
||||||
BlockPosition blockposition = new BlockPosition(i, j, k);
|
BlockPosition blockposition = new BlockPosition(i, j, k);
|
||||||
|
|
||||||
if (this.world.getType(blockposition).getMaterial() == Material.AIR && this.world.getBiome(blockposition).a(blockposition) < 0.8F && Blocks.SNOW_LAYER.canPlace(this.world, blockposition)) {
|
if (this.world.getType(blockposition).getMaterial() == Material.AIR && this.world.getBiome(blockposition).a(blockposition) < 0.8F && Blocks.SNOW_LAYER.canPlace(this.world, blockposition)) {
|
||||||
- this.world.setTypeUpdate(blockposition, Blocks.SNOW_LAYER.getBlockData());
|
- this.world.setTypeUpdate(blockposition, Blocks.SNOW_LAYER.getBlockData());
|
||||||
+ // CraftBukkit start
|
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this.world, blockposition, Blocks.SNOW_LAYER, this); // CraftBukkit
|
||||||
+ org.bukkit.block.BlockState blockState = this.world.getWorld().getBlockAt(i, j, k).getState();
|
|
||||||
+ blockState.setType(CraftMagicNumbers.getMaterial(Blocks.SNOW_LAYER));
|
|
||||||
+
|
|
||||||
+ EntityBlockFormEvent event = new EntityBlockFormEvent(this.getBukkitEntity(), blockState.getBlock(), blockState);
|
|
||||||
+ this.world.getServer().getPluginManager().callEvent(event);
|
|
||||||
+
|
|
||||||
+ if(!event.isCancelled()) {
|
|
||||||
+ blockState.update(true);
|
|
||||||
+ }
|
|
||||||
+ // CraftBukkit end
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -267,39 +267,21 @@
|
|||||||
this.strikeLightning(new EntityLightning(this, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), true));
|
this.strikeLightning(new EntityLightning(this, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), true));
|
||||||
} else {
|
} else {
|
||||||
this.strikeLightning(new EntityLightning(this, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), false));
|
this.strikeLightning(new EntityLightning(this, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), false));
|
||||||
@@ -297,11 +437,29 @@
|
@@ -297,11 +437,11 @@
|
||||||
BlockPosition blockposition1 = blockposition.down();
|
BlockPosition blockposition1 = blockposition.down();
|
||||||
|
|
||||||
if (this.v(blockposition1)) {
|
if (this.v(blockposition1)) {
|
||||||
- this.setTypeUpdate(blockposition1, Blocks.ICE.getBlockData());
|
- this.setTypeUpdate(blockposition1, Blocks.ICE.getBlockData());
|
||||||
+ // CraftBukkit start
|
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this, blockposition1, Blocks.ICE, null); // CraftBukkit
|
||||||
+ BlockState blockState = this.getWorld().getBlockAt(blockposition1.getX(), blockposition1.getY(), blockposition1.getZ()).getState();
|
|
||||||
+ blockState.setTypeId(Block.getId(Blocks.ICE));
|
|
||||||
+
|
|
||||||
+ BlockFormEvent iceBlockForm = new BlockFormEvent(blockState.getBlock(), blockState);
|
|
||||||
+ this.getServer().getPluginManager().callEvent(iceBlockForm);
|
|
||||||
+ if (!iceBlockForm.isCancelled()) {
|
|
||||||
+ blockState.update(true);
|
|
||||||
+ }
|
|
||||||
+ // CraftBukkit end
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flag && this.f(blockposition, true)) {
|
if (flag && this.f(blockposition, true)) {
|
||||||
- this.setTypeUpdate(blockposition, Blocks.SNOW_LAYER.getBlockData());
|
- this.setTypeUpdate(blockposition, Blocks.SNOW_LAYER.getBlockData());
|
||||||
+ // CraftBukkit start
|
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this, blockposition, Blocks.SNOW_LAYER, null); // CraftBukkit
|
||||||
+ BlockState blockState = this.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()).getState();
|
|
||||||
+ blockState.setTypeId(Block.getId(Blocks.SNOW_LAYER));
|
|
||||||
+
|
|
||||||
+ BlockFormEvent snow = new BlockFormEvent(blockState.getBlock(), blockState);
|
|
||||||
+ this.getServer().getPluginManager().callEvent(snow);
|
|
||||||
+ if (!snow.isCancelled()) {
|
|
||||||
+ blockState.update(true);
|
|
||||||
+ }
|
|
||||||
+ // CraftBukkit end
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flag && this.getBiome(blockposition1).d()) {
|
if (flag && this.getBiome(blockposition1).d()) {
|
||||||
@@ -376,7 +534,7 @@
|
@@ -376,7 +516,7 @@
|
||||||
public boolean b(BlockPosition blockposition, Block block) {
|
public boolean b(BlockPosition blockposition, Block block) {
|
||||||
NextTickListEntry nextticklistentry = new NextTickListEntry(blockposition, block);
|
NextTickListEntry nextticklistentry = new NextTickListEntry(blockposition, block);
|
||||||
|
|
||||||
@ -308,7 +290,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void a(BlockPosition blockposition, Block block, int i) {
|
public void a(BlockPosition blockposition, Block block, int i) {
|
||||||
@@ -415,8 +573,8 @@
|
@@ -415,8 +555,8 @@
|
||||||
nextticklistentry.a(j);
|
nextticklistentry.a(j);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -319,7 +301,7 @@
|
|||||||
this.nextTickList.add(nextticklistentry);
|
this.nextTickList.add(nextticklistentry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -438,15 +596,15 @@
|
@@ -438,15 +578,15 @@
|
||||||
nextticklistentry.a((long) i + this.worldData.getTime());
|
nextticklistentry.a((long) i + this.worldData.getTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -338,7 +320,7 @@
|
|||||||
if (this.emptyTime++ >= 300) {
|
if (this.emptyTime++ >= 300) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -516,11 +674,17 @@
|
@@ -516,11 +656,17 @@
|
||||||
} else {
|
} else {
|
||||||
int i = this.nextTickList.size();
|
int i = this.nextTickList.size();
|
||||||
|
|
||||||
@ -358,7 +340,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.methodProfiler.a("cleaning");
|
this.methodProfiler.a("cleaning");
|
||||||
@@ -533,8 +697,9 @@
|
@@ -533,8 +679,9 @@
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -369,7 +351,7 @@
|
|||||||
this.U.add(nextticklistentry);
|
this.U.add(nextticklistentry);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -604,7 +769,7 @@
|
@@ -604,7 +751,7 @@
|
||||||
if (blockposition.getX() >= structureboundingbox.a && blockposition.getX() < structureboundingbox.d && blockposition.getZ() >= structureboundingbox.c && blockposition.getZ() < structureboundingbox.f) {
|
if (blockposition.getX() >= structureboundingbox.a && blockposition.getX() < structureboundingbox.d && blockposition.getZ() >= structureboundingbox.c && blockposition.getZ() < structureboundingbox.f) {
|
||||||
if (flag) {
|
if (flag) {
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
@ -378,7 +360,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
@@ -622,6 +787,7 @@
|
@@ -622,6 +769,7 @@
|
||||||
return arraylist;
|
return arraylist;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -386,7 +368,7 @@
|
|||||||
public void entityJoinedWorld(Entity entity, boolean flag) {
|
public void entityJoinedWorld(Entity entity, boolean flag) {
|
||||||
if (!this.getSpawnAnimals() && (entity instanceof EntityAnimal || entity instanceof EntityWaterAnimal)) {
|
if (!this.getSpawnAnimals() && (entity instanceof EntityAnimal || entity instanceof EntityWaterAnimal)) {
|
||||||
entity.die();
|
entity.die();
|
||||||
@@ -633,6 +799,7 @@
|
@@ -633,6 +781,7 @@
|
||||||
|
|
||||||
super.entityJoinedWorld(entity, flag);
|
super.entityJoinedWorld(entity, flag);
|
||||||
}
|
}
|
||||||
@ -394,7 +376,7 @@
|
|||||||
|
|
||||||
private boolean getSpawnNPCs() {
|
private boolean getSpawnNPCs() {
|
||||||
return this.server.getSpawnNPCs();
|
return this.server.getSpawnNPCs();
|
||||||
@@ -645,7 +812,54 @@
|
@@ -645,7 +794,54 @@
|
||||||
protected IChunkProvider n() {
|
protected IChunkProvider n() {
|
||||||
IChunkLoader ichunkloader = this.dataManager.createChunkLoader(this.worldProvider);
|
IChunkLoader ichunkloader = this.dataManager.createChunkLoader(this.worldProvider);
|
||||||
|
|
||||||
@ -450,7 +432,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean a(EntityHuman entityhuman, BlockPosition blockposition) {
|
public boolean a(EntityHuman entityhuman, BlockPosition blockposition) {
|
||||||
@@ -707,6 +921,23 @@
|
@@ -707,6 +903,23 @@
|
||||||
int j = this.worldProvider.getSeaLevel();
|
int j = this.worldProvider.getSeaLevel();
|
||||||
int k = 8;
|
int k = 8;
|
||||||
|
|
||||||
@ -474,7 +456,7 @@
|
|||||||
if (blockposition != null) {
|
if (blockposition != null) {
|
||||||
i = blockposition.getX();
|
i = blockposition.getX();
|
||||||
k = blockposition.getZ();
|
k = blockposition.getZ();
|
||||||
@@ -716,7 +947,7 @@
|
@@ -716,7 +929,7 @@
|
||||||
|
|
||||||
int l = 0;
|
int l = 0;
|
||||||
|
|
||||||
@ -483,7 +465,7 @@
|
|||||||
i += random.nextInt(64) - random.nextInt(64);
|
i += random.nextInt(64) - random.nextInt(64);
|
||||||
k += random.nextInt(64) - random.nextInt(64);
|
k += random.nextInt(64) - random.nextInt(64);
|
||||||
++l;
|
++l;
|
||||||
@@ -758,6 +989,7 @@
|
@@ -758,6 +971,7 @@
|
||||||
ChunkProviderServer chunkproviderserver = this.getChunkProviderServer();
|
ChunkProviderServer chunkproviderserver = this.getChunkProviderServer();
|
||||||
|
|
||||||
if (chunkproviderserver.e()) {
|
if (chunkproviderserver.e()) {
|
||||||
@ -491,7 +473,7 @@
|
|||||||
if (iprogressupdate != null) {
|
if (iprogressupdate != null) {
|
||||||
iprogressupdate.a("Saving level");
|
iprogressupdate.a("Saving level");
|
||||||
}
|
}
|
||||||
@@ -768,7 +1000,8 @@
|
@@ -768,7 +982,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
chunkproviderserver.a(flag);
|
chunkproviderserver.a(flag);
|
||||||
@ -501,7 +483,7 @@
|
|||||||
Iterator iterator = arraylist.iterator();
|
Iterator iterator = arraylist.iterator();
|
||||||
|
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
@@ -803,6 +1036,12 @@
|
@@ -803,6 +1018,12 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -514,7 +496,7 @@
|
|||||||
this.worldData.a(this.getWorldBorder().getSize());
|
this.worldData.a(this.getWorldBorder().getSize());
|
||||||
this.worldData.d(this.getWorldBorder().getCenterX());
|
this.worldData.d(this.getWorldBorder().getCenterX());
|
||||||
this.worldData.c(this.getWorldBorder().getCenterZ());
|
this.worldData.c(this.getWorldBorder().getCenterZ());
|
||||||
@@ -816,9 +1055,13 @@
|
@@ -816,9 +1037,13 @@
|
||||||
this.worldMaps.a();
|
this.worldMaps.a();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -530,7 +512,7 @@
|
|||||||
|
|
||||||
public void a(Collection<Entity> collection) {
|
public void a(Collection<Entity> collection) {
|
||||||
ArrayList arraylist = Lists.newArrayList(collection);
|
ArrayList arraylist = Lists.newArrayList(collection);
|
||||||
@@ -837,7 +1080,7 @@
|
@@ -837,7 +1062,7 @@
|
||||||
|
|
||||||
private boolean i(Entity entity) {
|
private boolean i(Entity entity) {
|
||||||
if (entity.dead) {
|
if (entity.dead) {
|
||||||
@ -539,7 +521,7 @@
|
|||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
UUID uuid = entity.getUniqueID();
|
UUID uuid = entity.getUniqueID();
|
||||||
@@ -849,7 +1092,7 @@
|
@@ -849,7 +1074,7 @@
|
||||||
this.f.remove(entity1);
|
this.f.remove(entity1);
|
||||||
} else {
|
} else {
|
||||||
if (!(entity instanceof EntityHuman)) {
|
if (!(entity instanceof EntityHuman)) {
|
||||||
@ -548,7 +530,7 @@
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -902,8 +1145,16 @@
|
@@ -902,8 +1127,16 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean strikeLightning(Entity entity) {
|
public boolean strikeLightning(Entity entity) {
|
||||||
@ -566,7 +548,7 @@
|
|||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
@@ -919,10 +1170,20 @@
|
@@ -919,10 +1152,20 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public Explosion createExplosion(@Nullable Entity entity, double d0, double d1, double d2, float f, boolean flag, boolean flag1) {
|
public Explosion createExplosion(@Nullable Entity entity, double d0, double d1, double d2, float f, boolean flag, boolean flag1) {
|
||||||
@ -587,7 +569,7 @@
|
|||||||
if (!flag1) {
|
if (!flag1) {
|
||||||
explosion.clearBlocks();
|
explosion.clearBlocks();
|
||||||
}
|
}
|
||||||
@@ -968,7 +1229,8 @@
|
@@ -968,7 +1211,8 @@
|
||||||
BlockActionData blockactiondata = (BlockActionData) iterator.next();
|
BlockActionData blockactiondata = (BlockActionData) iterator.next();
|
||||||
|
|
||||||
if (this.a(blockactiondata)) {
|
if (this.a(blockactiondata)) {
|
||||||
@ -597,7 +579,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -991,6 +1253,7 @@
|
@@ -991,6 +1235,7 @@
|
||||||
boolean flag = this.W();
|
boolean flag = this.W();
|
||||||
|
|
||||||
super.t();
|
super.t();
|
||||||
@ -605,7 +587,7 @@
|
|||||||
if (this.n != this.o) {
|
if (this.n != this.o) {
|
||||||
this.server.getPlayerList().a((Packet) (new PacketPlayOutGameStateChange(7, this.o)), this.worldProvider.getDimensionManager().getDimensionID());
|
this.server.getPlayerList().a((Packet) (new PacketPlayOutGameStateChange(7, this.o)), this.worldProvider.getDimensionManager().getDimensionID());
|
||||||
}
|
}
|
||||||
@@ -1009,6 +1272,21 @@
|
@@ -1009,6 +1254,21 @@
|
||||||
this.server.getPlayerList().sendAll(new PacketPlayOutGameStateChange(7, this.o));
|
this.server.getPlayerList().sendAll(new PacketPlayOutGameStateChange(7, this.o));
|
||||||
this.server.getPlayerList().sendAll(new PacketPlayOutGameStateChange(8, this.q));
|
this.server.getPlayerList().sendAll(new PacketPlayOutGameStateChange(8, this.q));
|
||||||
}
|
}
|
||||||
@ -627,7 +609,7 @@
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1038,10 +1316,20 @@
|
@@ -1038,10 +1298,20 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public void a(EnumParticle enumparticle, boolean flag, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6, int... aint) {
|
public void a(EnumParticle enumparticle, boolean flag, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6, int... aint) {
|
||||||
|
@ -5,6 +5,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.EnumMap;
|
import java.util.EnumMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.base.Functions;
|
import com.google.common.base.Functions;
|
||||||
@ -1028,4 +1029,18 @@ public class CraftEventFactory {
|
|||||||
child.world.getServer().getPluginManager().callEvent(event);
|
child.world.getServer().getPluginManager().callEvent(event);
|
||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean handleBlockFormEvent(World world, BlockPosition pos, net.minecraft.server.Block block, @Nullable Entity entity) {
|
||||||
|
BlockState blockState = world.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ()).getState();
|
||||||
|
blockState.setType(CraftMagicNumbers.getMaterial(block));
|
||||||
|
|
||||||
|
BlockFormEvent event = (entity == null) ? new BlockFormEvent(blockState.getBlock(), blockState) : new EntityBlockFormEvent(entity.getBukkitEntity(), blockState.getBlock(), blockState);
|
||||||
|
world.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
|
if (!event.isCancelled()) {
|
||||||
|
blockState.update(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return !event.isCancelled();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user