Paper/CraftBukkit-Patches/0101-Implement-Silenceable-Lightning-API.patch
Zach Brown cab333b217 Rebase (Update) from upstream SpigotMC
Don't send requests of every player was found in the global api cache SpigotMC/Spigot@841270ff1e
Correctly set the response code for the cached lookups and return the ... SpigotMC/Spigot@f170b7899c
Don't try and re-set the global api cache on reload SpigotMC/Spigot@b410a00a66
Use a compile time sneaky throw hack. SpigotMC/Spigot@508462b96b
Fix a missed rename in WorldGenGroundBush SpigotMC/Spigot@0614d8fae9
2014-11-28 14:19:07 -06:00

106 lines
3.8 KiB
Diff

From 6182a213539516f890da8bf03125138801557cbb Mon Sep 17 00:00:00 2001
From: drXor <mcyoungsota@gmail.com>
Date: Sun, 23 Feb 2014 16:16:59 -0400
Subject: [PATCH] Implement Silenceable Lightning API
diff --git a/src/main/java/net/minecraft/server/EntityLightning.java b/src/main/java/net/minecraft/server/EntityLightning.java
index 66402a0..0671659 100644
--- a/src/main/java/net/minecraft/server/EntityLightning.java
+++ b/src/main/java/net/minecraft/server/EntityLightning.java
@@ -13,6 +13,8 @@ public class EntityLightning extends EntityWeather {
// CraftBukkit start
public boolean isEffect = false;
+ public boolean isSilent = false; // Spigot
+
public EntityLightning(World world, double d0, double d1, double d2) {
this(world, d0, d1, d2, false);
}
@@ -60,9 +62,17 @@ public class EntityLightning extends EntityWeather {
}
}
+ // Spigot start
+ public EntityLightning(World world, double d0, double d1, double d2, boolean isEffect, boolean isSilent)
+ {
+ this( world, d0, d1, d2, isEffect );
+ this.isSilent = isSilent;
+ }
+ // Spigot end
+
public void h() {
super.h();
- if (this.lifeTicks == 2) {
+ if (!isSilent && this.lifeTicks == 2) { // Spigot
// CraftBukkit start - Use relative location for far away sounds
//this.world.makeSound(this.locX, this.locY, this.locZ, "ambient.weather.thunder", 10000.0F, 0.8F + this.random.nextFloat() * 0.2F);
float pitch = 0.8F + this.random.nextFloat() * 0.2F;
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index 53a5d37..92f7188 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -1361,6 +1361,22 @@ public class CraftWorld implements World {
{
CraftWorld.this.playEffect( location, effect, 0 );
}
+
+ @Override
+ public LightningStrike strikeLightning(Location loc, boolean isSilent)
+ {
+ EntityLightning lightning = new EntityLightning( world, loc.getX(), loc.getY(), loc.getZ(), false, isSilent );
+ world.strikeLightning( lightning );
+ return new CraftLightningStrike( server, lightning );
+ }
+
+ @Override
+ public LightningStrike strikeLightningEffect(Location loc, boolean isSilent)
+ {
+ EntityLightning lightning = new EntityLightning( world, loc.getX(), loc.getY(), loc.getZ(), true, isSilent );
+ world.strikeLightning( lightning );
+ return new CraftLightningStrike( server, lightning );
+ }
};
public Spigot spigot()
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLightningStrike.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLightningStrike.java
index 64e346d..be4f10f 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLightningStrike.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLightningStrike.java
@@ -1,7 +1,9 @@
package org.bukkit.craftbukkit.entity;
import net.minecraft.server.EntityLightning;
+
import org.bukkit.craftbukkit.CraftServer;
+import org.bukkit.entity.Arrow;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LightningStrike;
@@ -27,4 +29,22 @@ public class CraftLightningStrike extends CraftEntity implements LightningStrike
public EntityType getType() {
return EntityType.LIGHTNING;
}
+
+ // Spigot start
+ private final LightningStrike.Spigot spigot = new LightningStrike.Spigot()
+ {
+
+ @Override
+ public boolean isSilent()
+ {
+ return getHandle().isSilent;
+ }
+
+ };
+
+ public LightningStrike.Spigot spigot()
+ {
+ return this.spigot;
+ }
+ // Spigot end
}
--
1.9.1