From 24457ebe36991545b8f4f479abda54b90597a9c8 Mon Sep 17 00:00:00 2001 From: Electroblob <35599699+Electroblob77@users.noreply.github.com> Date: Wed, 20 Jun 2018 23:32:14 +0100 Subject: [PATCH] Add error prevention and console warning for trying to spawn particles on the server side using ParticleBuilder --- .../electroblob/wizardry/util/ParticleBuilder.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/electroblob/wizardry/util/ParticleBuilder.java b/src/main/java/electroblob/wizardry/util/ParticleBuilder.java index a4ea6725..06f1313b 100644 --- a/src/main/java/electroblob/wizardry/util/ParticleBuilder.java +++ b/src/main/java/electroblob/wizardry/util/ParticleBuilder.java @@ -17,7 +17,8 @@ import net.minecraft.world.World; * types in wizardry made the method overloads in the proxies very cumbersome and inevitably resulted in redundant * parameters, which made the code messy and hard to read. Those methods have now been removed. *

- * It also goes without saying that this class should only ever be used client-side. + * It also goes without saying that this class should only ever be used client-side. Attempting to spawn particles + * on the server side will not work and will print a warning to the console. *

* {@link ParticleBuilder#instance} retrieves the static instance of the particle builder. Use * {@link ParticleBuilder#particle(Type)} to start building a particle, or alternatively use the static @@ -335,6 +336,14 @@ public final class ParticleBuilder { if(y < 0 && entity == null) Wizardry.logger.warn("Spawning particle below y = 0 - are you sure the position/entity" + "has been set correctly?"); + if(!world.isRemote){ + Wizardry.logger.warn("ParticleBuilder.spawn(...) called on the server side! ParticleBuilder has prevented a" + + "server crash, but calling it on the server will do nothing. Consider adding a world.isRemote check."); + // Must stop here because the line after this if statement would crash the server! + reset(); + return; + } + electroblob.wizardry.client.particle.ParticleWizardry particle = Wizardry.proxy.createParticle(type, world, x, y, z); if(particle == null){