PaperMC/paper-server/patches/sources/net/minecraft/world/item/EnderEyeItem.java.patch
CraftBukkit/Spigot 1cb6ba6942 Configurable dragon death and wither spawn sounds
By: drXor <mcyoungsota@gmail.com>
2014-03-29 13:44:25 -04:00

42 lines
2.6 KiB
Diff

--- a/net/minecraft/world/item/EnderEyeItem.java
+++ b/net/minecraft/world/item/EnderEyeItem.java
@@ -62,7 +62,25 @@
}
}
- world.globalLevelEvent(1038, blockposition1.offset(1, 0, 1), 0);
+ // CraftBukkit start - Use relative location for far away sounds
+ // world.globalLevelEvent(1038, blockposition1.offset(1, 0, 1), 0);
+ int viewDistance = world.getCraftServer().getViewDistance() * 16;
+ BlockPos soundPos = blockposition1.offset(1, 0, 1);
+ for (ServerPlayer player : world.getServer().getPlayerList().players) {
+ double deltaX = soundPos.getX() - player.getX();
+ double deltaZ = soundPos.getZ() - player.getZ();
+ double distanceSquared = deltaX * deltaX + deltaZ * deltaZ;
+ if (world.spigotConfig.endPortalSoundRadius > 0 && distanceSquared > world.spigotConfig.endPortalSoundRadius * world.spigotConfig.endPortalSoundRadius) continue; // Spigot
+ if (distanceSquared > viewDistance * viewDistance) {
+ double deltaLength = Math.sqrt(distanceSquared);
+ double relativeX = player.getX() + (deltaX / deltaLength) * viewDistance;
+ double relativeZ = player.getZ() + (deltaZ / deltaLength) * viewDistance;
+ player.connection.send(new net.minecraft.network.protocol.game.ClientboundLevelEventPacket(1038, new BlockPos((int) relativeX, (int) soundPos.getY(), (int) relativeZ), 0, true));
+ } else {
+ player.connection.send(new net.minecraft.network.protocol.game.ClientboundLevelEventPacket(1038, soundPos, 0, true));
+ }
+ }
+ // CraftBukkit end
}
return InteractionResult.SUCCESS;
@@ -99,7 +117,11 @@
entityendersignal.setItem(itemstack);
entityendersignal.signalTo(blockposition);
world.gameEvent((Holder) GameEvent.PROJECTILE_SHOOT, entityendersignal.position(), GameEvent.Context.of((Entity) user));
- world.addFreshEntity(entityendersignal);
+ // CraftBukkit start
+ if (!world.addFreshEntity(entityendersignal)) {
+ return InteractionResult.FAIL;
+ }
+ // CraftBukkit end
if (user instanceof ServerPlayer) {
ServerPlayer entityplayer = (ServerPlayer) user;