From f7bf4dd0ebc7022d9b9dd0dae17927f56c4cb523 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 26 Jun 2021 15:30:36 +0200 Subject: [PATCH] Fix HellsBells distribution --- .../de/steamwar/fightsystem/event/HellsBells.java | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/event/HellsBells.java b/FightSystem_Main/src/de/steamwar/fightsystem/event/HellsBells.java index 6461d3e..a863b98 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/event/HellsBells.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/event/HellsBells.java @@ -79,8 +79,8 @@ public class HellsBells { AtomicInteger length = new AtomicInteger(10 + random.nextInt(direction.getLength(zLength, xLength) - 10)); int width = 5 + random.nextInt(5); - int xOffset = getWidthStart(direction.getLength(xLength, zLength), direction.getLength(length.get(), width)); - int zOffset = getLengthStart(direction.getLength(zLength, xLength), direction.getLength(width, length.get())); + int xOffset = getStart(direction.getLength(xLength, zLength), direction.getLength(length.get(), width)); + int zOffset = getStart(direction.getLength(zLength, xLength), direction.getLength(width, length.get())); int yOffset = getHeightStart(); Point redStart; @@ -112,12 +112,9 @@ public class HellsBells { }, 0L, 4L); } - private int getLengthStart(int regionSize, int length) { - return random.nextInt(regionSize - length); - } - - private int getWidthStart(int regionSize, int length) { - return random.nextInt(regionSize - length); + private int getStart(int regionSize, int length) { + double randomNumber = (random.nextDouble() - random.nextDouble()) / 2 + 0.5; + return (int) (randomNumber * (regionSize - length)); } private int getHeightStart() {