mirror of
https://github.com/Brettflan/WorldBorder.git
synced 2024-11-25 19:45:56 +01:00
Implemented world wrapping capability
This commit is contained in:
parent
8006e1f0fd
commit
d6bea2b616
@ -199,6 +199,19 @@ public class BorderData
|
||||
|
||||
// square border
|
||||
if (!round)
|
||||
{
|
||||
if (Config.isWrapping())
|
||||
{
|
||||
if (xLoc <= minX)
|
||||
xLoc = maxX - Config.KnockBack();
|
||||
else if (xLoc >= maxX)
|
||||
xLoc = minX + Config.KnockBack();
|
||||
if (zLoc <= minZ)
|
||||
zLoc = maxZ - Config.KnockBack();
|
||||
else if (zLoc >= maxZ)
|
||||
zLoc = minZ + Config.KnockBack();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (xLoc <= minX)
|
||||
xLoc = minX + Config.KnockBack();
|
||||
@ -209,6 +222,7 @@ public class BorderData
|
||||
else if (zLoc >= maxZ)
|
||||
zLoc = maxZ - Config.KnockBack();
|
||||
}
|
||||
}
|
||||
|
||||
// round border
|
||||
else
|
||||
@ -222,9 +236,15 @@ public class BorderData
|
||||
double dU = Math.sqrt(dX *dX + dZ * dZ); //distance of the untransformed point from the center
|
||||
double dT = Math.sqrt(dX *dX / radiusXSquared + dZ * dZ / radiusZSquared); //distance of the transformed point from the center
|
||||
double f = (1 / dT - Config.KnockBack() / dU); //"correction" factor for the distances
|
||||
if (Config.isWrapping())
|
||||
{
|
||||
xLoc = x - dX * f;
|
||||
zLoc = z - dZ * f;
|
||||
} else {
|
||||
xLoc = x + dX * f;
|
||||
zLoc = z + dZ * f;
|
||||
}
|
||||
}
|
||||
|
||||
int ixLoc = Location.locToBlock(xLoc);
|
||||
int izLoc = Location.locToBlock(zLoc);
|
||||
|
@ -40,6 +40,7 @@ public class Config
|
||||
private static boolean whooshEffect = false;
|
||||
private static boolean dynmapEnable = true;
|
||||
private static String dynmapMessage;
|
||||
private static boolean isWrapping = false;
|
||||
|
||||
// for monitoring plugin efficiency
|
||||
// public static long timeUsed = 0;
|
||||
@ -303,6 +304,9 @@ public class Config
|
||||
LogConfig("Border-checking timed task stopped.");
|
||||
}
|
||||
|
||||
public static boolean isWrapping() {
|
||||
retirn isWrapping;
|
||||
}
|
||||
|
||||
public static void StopFillTask()
|
||||
{
|
||||
@ -382,7 +386,7 @@ public class Config
|
||||
}
|
||||
|
||||
|
||||
private static final int currentCfgVersion = 6;
|
||||
private static final int currentCfgVersion = 7;
|
||||
|
||||
public static void load(WorldBorder master, boolean logIt)
|
||||
{ // load config from file
|
||||
@ -401,6 +405,7 @@ public class Config
|
||||
timerTicks = cfg.getInt("timer-delay-ticks", 5);
|
||||
dynmapEnable = cfg.getBoolean("dynmap-border-enabled", true);
|
||||
dynmapMessage = cfg.getString("dynmap-border-message", "The border of the world.");
|
||||
isWrapping = cfg.getBoolean("wrapping-world", false);
|
||||
LogConfig("Using " + (ShapeName()) + " border, knockback of " + knockBack + " blocks, and timer delay of " + timerTicks + ".");
|
||||
|
||||
StartBorderTimer();
|
||||
@ -483,6 +488,7 @@ public class Config
|
||||
cfg.set("timer-delay-ticks", timerTicks);
|
||||
cfg.set("dynmap-border-enabled", dynmapEnable);
|
||||
cfg.set("dynmap-border-message", dynmapMessage);
|
||||
cfg.set("wrapping-world", isWrapping);
|
||||
|
||||
cfg.set("worlds", null);
|
||||
Iterator world = borders.entrySet().iterator();
|
||||
|
Loading…
Reference in New Issue
Block a user