2016-02-29 21:33:06 +00:00
|
|
|
From a2322f4d7c0497bb172db22586539e2cfa7f22ab Mon Sep 17 00:00:00 2001
|
2014-07-21 20:46:54 +00:00
|
|
|
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
|
2016-02-29 21:33:06 +00:00
|
|
|
index 35a0bdc..e507302 100644
|
2014-07-21 20:46:54 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/EntityLightning.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/EntityLightning.java
|
2016-02-29 21:33:06 +00:00
|
|
|
@@ -11,6 +11,7 @@ public class EntityLightning extends EntityWeather {
|
|
|
|
private int c;
|
|
|
|
private final boolean d;
|
|
|
|
public boolean isEffect; // CraftBukkit
|
2014-07-21 20:46:54 +00:00
|
|
|
+ public boolean isSilent = false; // Spigot
|
2016-02-29 21:33:06 +00:00
|
|
|
|
|
|
|
public EntityLightning(World world, double d0, double d1, double d2, boolean flag) {
|
|
|
|
super(world);
|
|
|
|
@@ -46,13 +47,21 @@ public class EntityLightning extends EntityWeather {
|
|
|
|
|
2014-07-21 20:46:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
+ // 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;
|
2016-02-29 21:33:06 +00:00
|
|
|
+ }
|
2014-07-21 20:46:54 +00:00
|
|
|
+ // Spigot end
|
2016-02-29 21:33:06 +00:00
|
|
|
+
|
|
|
|
public SoundCategory bz() {
|
|
|
|
return SoundCategory.WEATHER;
|
|
|
|
}
|
2014-11-28 01:17:45 +00:00
|
|
|
|
2016-02-29 21:33:06 +00:00
|
|
|
public void m() {
|
|
|
|
super.m();
|
2014-07-21 20:46:54 +00:00
|
|
|
- if (this.lifeTicks == 2) {
|
|
|
|
+ if (!isSilent && this.lifeTicks == 2) { // Spigot
|
|
|
|
// CraftBukkit start - Use relative location for far away sounds
|
2016-02-29 21:33:06 +00:00
|
|
|
// this.world.a((EntityHuman) null, this.locX, this.locY, this.locZ, SoundEffects.dc, SoundCategory.d, 10000.0F, 0.8F + this.random.nextFloat() * 0.2F);
|
2014-07-21 20:46:54 +00:00
|
|
|
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
|
2016-02-29 21:33:06 +00:00
|
|
|
index 2063185..2b3569d 100644
|
2014-07-21 20:46:54 +00:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
2016-02-29 21:33:06 +00:00
|
|
|
@@ -1518,6 +1518,22 @@ public class CraftWorld implements World {
|
2014-07-21 20:46:54 +00:00
|
|
|
{
|
|
|
|
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
|
2014-11-28 01:17:45 +00:00
|
|
|
index 243e8e5..0bacc83 100644
|
2014-07-21 20:46:54 +00:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLightningStrike.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLightningStrike.java
|
2014-11-28 01:17:45 +00:00
|
|
|
@@ -31,6 +31,11 @@ public class CraftLightningStrike extends CraftEntity implements LightningStrike
|
|
|
|
// Spigot start
|
|
|
|
private final LightningStrike.Spigot spigot = new LightningStrike.Spigot() {
|
|
|
|
|
2014-07-21 20:46:54 +00:00
|
|
|
+ @Override
|
|
|
|
+ public boolean isSilent()
|
|
|
|
+ {
|
|
|
|
+ return getHandle().isSilent;
|
|
|
|
+ }
|
2014-11-28 01:17:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
@Override
|
2014-07-21 20:46:54 +00:00
|
|
|
--
|
2016-02-29 21:33:06 +00:00
|
|
|
2.5.0
|
2014-07-21 20:46:54 +00:00
|
|
|
|