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