From 21c77a2fc8bef3112c1689a0b13a3b97913cd734 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Mon, 9 Jan 2017 14:39:55 +1100 Subject: [PATCH] Fixes #391 --- .../object/brush/heightmap/ScalableHeightMap.java | 9 +++++++-- .../com/sk89q/worldedit/command/RegionCommands.java | 12 +++++++----- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/core/src/main/java/com/boydti/fawe/object/brush/heightmap/ScalableHeightMap.java b/core/src/main/java/com/boydti/fawe/object/brush/heightmap/ScalableHeightMap.java index d6cff00b..f4b82eff 100644 --- a/core/src/main/java/com/boydti/fawe/object/brush/heightmap/ScalableHeightMap.java +++ b/core/src/main/java/com/boydti/fawe/object/brush/heightmap/ScalableHeightMap.java @@ -2,6 +2,7 @@ package com.boydti.fawe.object.brush.heightmap; import com.boydti.fawe.object.IntegerPair; import com.boydti.fawe.object.PseudoRandom; +import com.boydti.fawe.util.MainUtil; import com.boydti.fawe.util.MathMan; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.MaxChangedBlocksException; @@ -145,8 +146,12 @@ public class ScalableHeightMap { Region region = new CuboidRegion(session.getWorld(), min, max); HeightMap heightMap = new HeightMap(session, region, true); if (smooth) { - HeightMapFilter filter = new HeightMapFilter(new GaussianKernel(5, 1)); - newData = filter.filter(newData, diameter, diameter); + try { + HeightMapFilter filter = (HeightMapFilter) HeightMapFilter.class.getConstructors()[0].newInstance(GaussianKernel.class.getConstructors()[0].newInstance(5, 1)); + newData = filter.filter(newData, diameter, diameter); + } catch (Throwable e) { + MainUtil.handleError(e); + } } heightMap.apply(newData); } diff --git a/core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java b/core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java index ef044d0f..10099680 100644 --- a/core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java +++ b/core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java @@ -474,11 +474,13 @@ public class RegionCommands { @Logging(REGION) public void smooth(Player player, EditSession editSession, @Selection Region region, @Optional("1") int iterations, @Switch('n') boolean affectNatural) throws WorldEditException { HeightMap heightMap = new HeightMap(editSession, region, affectNatural); - HeightMapFilter filter = new HeightMapFilter(new GaussianKernel(5, 1.0)); - int affected = heightMap.applyFilter(filter, iterations); - - BBC.VISITOR_BLOCK.send(player, affected); - + try { + HeightMapFilter filter = (HeightMapFilter) HeightMapFilter.class.getConstructors()[0].newInstance(GaussianKernel.class.getConstructors()[0].newInstance(5, 1)); + int affected = heightMap.applyFilter(filter, iterations); + BBC.VISITOR_BLOCK.send(player, affected); + } catch (Throwable e) { + throw new RuntimeException(e); + } } @Command(