From bd0f47c3253ec01507c0d09a898465c025a3540a Mon Sep 17 00:00:00 2001 From: Anuken Date: Thu, 7 Jan 2021 15:18:44 -0500 Subject: [PATCH] Faster weapon copy --- core/src/mindustry/type/Weapon.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/core/src/mindustry/type/Weapon.java b/core/src/mindustry/type/Weapon.java index f98150c85d..af5f63050b 100644 --- a/core/src/mindustry/type/Weapon.java +++ b/core/src/mindustry/type/Weapon.java @@ -9,9 +9,8 @@ import mindustry.entities.*; import mindustry.entities.bullet.*; import mindustry.gen.*; import mindustry.graphics.*; -import mindustry.io.*; -public class Weapon{ +public class Weapon implements Cloneable{ /** displayed weapon region */ public String name = ""; /** bullet shot */ @@ -98,9 +97,11 @@ public class Weapon{ } public Weapon copy(){ - Weapon out = new Weapon(); - JsonIO.json().copyFields(this, out); - return out; + try{ + return (Weapon)clone(); + }catch(CloneNotSupportedException suck){ + throw new RuntimeException("very good language design", suck); + } } public void load(){