@@ -0,0 +1,32 @@
|
||||
--- a/net/minecraft/world/level/gameevent/GameEventDispatcher.java
|
||||
+++ b/net/minecraft/world/level/gameevent/GameEventDispatcher.java
|
||||
@@ -11,6 +11,14 @@
|
||||
import net.minecraft.world.level.chunk.Chunk;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import net.minecraft.core.registries.BuiltInRegistries;
|
||||
+import org.bukkit.Bukkit;
|
||||
+import org.bukkit.Location;
|
||||
+import org.bukkit.craftbukkit.util.CraftNamespacedKey;
|
||||
+import org.bukkit.event.world.GenericGameEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class GameEventDispatcher {
|
||||
|
||||
private final WorldServer level;
|
||||
@@ -22,6 +30,14 @@
|
||||
public void post(GameEvent gameevent, Vec3D vec3d, GameEvent.a gameevent_a) {
|
||||
int i = gameevent.getNotificationRadius();
|
||||
BlockPosition blockposition = new BlockPosition(vec3d);
|
||||
+ // CraftBukkit start
|
||||
+ GenericGameEvent event = new GenericGameEvent(org.bukkit.GameEvent.getByKey(CraftNamespacedKey.fromMinecraft(BuiltInRegistries.GAME_EVENT.getKey(gameevent))), new Location(level.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ()), (gameevent_a.sourceEntity() == null) ? null : gameevent_a.sourceEntity().getBukkitEntity(), i, !Bukkit.isPrimaryThread());
|
||||
+ level.getCraftServer().getPluginManager().callEvent(event);
|
||||
+ if (event.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ i = event.getRadius();
|
||||
+ // CraftBukkit end
|
||||
int j = SectionPosition.blockToSectionCoord(blockposition.getX() - i);
|
||||
int k = SectionPosition.blockToSectionCoord(blockposition.getY() - i);
|
||||
int l = SectionPosition.blockToSectionCoord(blockposition.getZ() - i);
|
||||
@@ -1,11 +1,11 @@
|
||||
--- a/net/minecraft/world/level/gameevent/vibrations/VibrationListener.java
|
||||
+++ b/net/minecraft/world/level/gameevent/vibrations/VibrationListener.java
|
||||
@@ -28,6 +28,13 @@
|
||||
@@ -29,6 +29,13 @@
|
||||
import net.minecraft.world.phys.MovingObjectPosition;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import net.minecraft.core.IRegistry;
|
||||
+import net.minecraft.core.registries.BuiltInRegistries;
|
||||
+import org.bukkit.craftbukkit.block.CraftBlock;
|
||||
+import org.bukkit.craftbukkit.util.CraftNamespacedKey;
|
||||
+import org.bukkit.event.block.BlockReceiveGameEvent;
|
||||
@@ -13,65 +13,38 @@
|
||||
+
|
||||
public class VibrationListener implements GameEventListener {
|
||||
|
||||
protected final PositionSource listenerSource;
|
||||
@@ -51,7 +58,7 @@
|
||||
@VisibleForTesting
|
||||
@@ -96,7 +103,7 @@
|
||||
}), ExtraCodecs.NON_NEGATIVE_INT.fieldOf("event_delay").orElse(0).forGetter((vibrationlistener) -> {
|
||||
return vibrationlistener.travelTimeInTicks;
|
||||
})).apply(instance, (positionsource, integer, optional, ofloat, integer1) -> {
|
||||
- return new VibrationListener(positionsource, integer, vibrationlistener_b, (VibrationListener.a) optional.orElse((Object) null), ofloat, integer1);
|
||||
+ return new VibrationListener(positionsource, integer, vibrationlistener_b, (VibrationListener.a) optional.orElse(null), ofloat, integer1); // CraftBukkit - decompile error
|
||||
})).apply(instance, (positionsource, integer, optional, vibrationselector, integer1) -> {
|
||||
- return new VibrationListener(positionsource, integer, vibrationlistener_a, (VibrationInfo) optional.orElse((Object) null), vibrationselector, integer1);
|
||||
+ return new VibrationListener(positionsource, integer, vibrationlistener_a, (VibrationInfo) optional.orElse(null), vibrationselector, integer1); // CraftBukkit - decompile error
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -73,7 +80,7 @@
|
||||
@@ -138,7 +145,7 @@
|
||||
--this.travelTimeInTicks;
|
||||
if (this.travelTimeInTicks <= 0) {
|
||||
this.travelTimeInTicks = 0;
|
||||
- this.config.onSignalReceive(worldserver, this, new BlockPosition(this.receivingEvent.pos), this.receivingEvent.gameEvent, (Entity) this.receivingEvent.getEntity(worldserver).orElse((Object) null), (Entity) this.receivingEvent.getProjectileOwner(worldserver).orElse((Object) null), this.receivingDistance);
|
||||
+ this.config.onSignalReceive(worldserver, this, new BlockPosition(this.receivingEvent.pos), this.receivingEvent.gameEvent, (Entity) this.receivingEvent.getEntity(worldserver).orElse(null), (Entity) this.receivingEvent.getProjectileOwner(worldserver).orElse(null), this.receivingDistance); // CraftBukkit - decompile error
|
||||
this.receivingEvent = null;
|
||||
- this.config.onSignalReceive(worldserver, this, new BlockPosition(this.currentVibration.pos()), this.currentVibration.gameEvent(), (Entity) this.currentVibration.getEntity(worldserver).orElse((Object) null), (Entity) this.currentVibration.getProjectileOwner(worldserver).orElse((Object) null), this.currentVibration.distance());
|
||||
+ this.config.onSignalReceive(worldserver, this, new BlockPosition(this.currentVibration.pos()), this.currentVibration.gameEvent(), (Entity) this.currentVibration.getEntity(worldserver).orElse(null), (Entity) this.currentVibration.getProjectileOwner(worldserver).orElse(null), this.currentVibration.distance()); // CraftBukkit - decompile error
|
||||
this.currentVibration = null;
|
||||
}
|
||||
}
|
||||
@@ -110,7 +117,14 @@
|
||||
Vec3D vec3d = gameevent_b.source();
|
||||
Vec3D vec3d1 = (Vec3D) optional.get();
|
||||
@@ -170,7 +177,14 @@
|
||||
} else {
|
||||
Vec3D vec3d1 = (Vec3D) optional.get();
|
||||
|
||||
- if (!this.config.shouldListen(worldserver, this, new BlockPosition(vec3d), gameevent, gameevent_a)) {
|
||||
+ // CraftBukkit start
|
||||
+ boolean defaultCancel = !this.config.shouldListen(worldserver, this, new BlockPosition(vec3d), gameevent, gameevent_a);
|
||||
+ Entity entity = gameevent_a.sourceEntity();
|
||||
+ BlockReceiveGameEvent event = new BlockReceiveGameEvent(org.bukkit.GameEvent.getByKey(CraftNamespacedKey.fromMinecraft(IRegistry.GAME_EVENT.getKey(gameevent))), CraftBlock.at(worldserver, new BlockPosition(vec3d1)), (entity == null) ? null : entity.getBukkitEntity());
|
||||
+ event.setCancelled(defaultCancel);
|
||||
+ worldserver.getCraftServer().getPluginManager().callEvent(event);
|
||||
+ if (event.isCancelled()) {
|
||||
+ // CraftBukkit end
|
||||
return false;
|
||||
} else if (isOccluded(worldserver, vec3d, vec3d1)) {
|
||||
return false;
|
||||
@@ -206,7 +220,7 @@
|
||||
}), ExtraCodecs.UUID.optionalFieldOf("projectile_owner").forGetter((vibrationlistener_a) -> {
|
||||
return Optional.ofNullable(vibrationlistener_a.projectileOwnerUuid());
|
||||
})).apply(instance, (gameevent, ofloat, vec3d, optional, optional1) -> {
|
||||
- return new VibrationListener.a(gameevent, ofloat, vec3d, (UUID) optional.orElse((Object) null), (UUID) optional1.orElse((Object) null));
|
||||
+ return new VibrationListener.a(gameevent, ofloat, vec3d, (UUID) optional.orElse(null), (UUID) optional1.orElse(null)); // CraftBukkit - decompile error
|
||||
});
|
||||
});
|
||||
|
||||
@@ -233,7 +247,7 @@
|
||||
|
||||
public Optional<Entity> getEntity(WorldServer worldserver) {
|
||||
return Optional.ofNullable(this.entity).or(() -> {
|
||||
- Optional optional = Optional.ofNullable(this.uuid);
|
||||
+ Optional<UUID> optional = Optional.ofNullable(this.uuid); // CraftBukkit - decompile error
|
||||
|
||||
Objects.requireNonNull(worldserver);
|
||||
return optional.map(worldserver::getEntity);
|
||||
@@ -246,7 +260,7 @@
|
||||
}).map((entity) -> {
|
||||
return (IProjectile) entity;
|
||||
}).map(IProjectile::getOwner).or(() -> {
|
||||
- Optional optional = Optional.ofNullable(this.projectileOwnerUuid);
|
||||
+ Optional<UUID> optional = Optional.ofNullable(this.projectileOwnerUuid); // CraftBukkit - decompile error
|
||||
|
||||
Objects.requireNonNull(worldserver);
|
||||
return optional.map(worldserver::getEntity);
|
||||
- if (!this.config.shouldListen(worldserver, this, new BlockPosition(vec3d), gameevent, gameevent_a)) {
|
||||
+ // CraftBukkit start
|
||||
+ boolean defaultCancel = !this.config.shouldListen(worldserver, this, new BlockPosition(vec3d), gameevent, gameevent_a);
|
||||
+ Entity entity = gameevent_a.sourceEntity();
|
||||
+ BlockReceiveGameEvent event = new BlockReceiveGameEvent(org.bukkit.GameEvent.getByKey(CraftNamespacedKey.fromMinecraft(BuiltInRegistries.GAME_EVENT.getKey(gameevent))), CraftBlock.at(worldserver, new BlockPosition(vec3d1)), (entity == null) ? null : entity.getBukkitEntity());
|
||||
+ event.setCancelled(defaultCancel);
|
||||
+ worldserver.getCraftServer().getPluginManager().callEvent(event);
|
||||
+ if (event.isCancelled()) {
|
||||
+ // CraftBukkit end
|
||||
return false;
|
||||
} else if (isOccluded(worldserver, vec3d, vec3d1)) {
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user