Fix rift subregistry being written before riftRegistry is loaded, fix missing square root
This commit is contained in:
parent
a936a4280f
commit
b9a0736072
2 changed files with 3 additions and 2 deletions
|
@ -66,7 +66,7 @@ import java.util.Set;
|
|||
double coordDistance = Math.sqrt(sq(otherVirtualLocation.getX() - virtualLocationHere.getX())
|
||||
+ sq(otherVirtualLocation.getZ() - virtualLocationHere.getZ()));
|
||||
double depthFactor = depthDifference > 0 ? positiveDepthFactor : negativeDepthFactor;
|
||||
double distance = sq(coordFactor * coordDistance) + sq(depthFactor * depthDifference);
|
||||
double distance = Math.sqrt(sq(coordFactor * coordDistance) + sq(depthFactor * depthDifference));
|
||||
|
||||
// Calculate the weight as 4m/pi w/(m^2/d + d)^2. This is similar to how gravitational/electromagnetic attraction
|
||||
// works in physics (G m1 m2/d^2 and k_e m1 m2/d^2). Even though we add a depth dimension to the world, we keep
|
||||
|
|
|
@ -42,7 +42,6 @@ public class RiftRegistry extends WorldSavedData {
|
|||
|
||||
// <editor-fold defaultstate="collapsed" desc="Code for reading/writing/getting the registry">
|
||||
|
||||
|
||||
public static class RiftSubregistry extends WorldSavedData {
|
||||
private int dim;
|
||||
|
||||
|
@ -57,6 +56,7 @@ public class RiftRegistry extends WorldSavedData {
|
|||
@Override public void readFromNBT(NBTTagCompound nbt) {
|
||||
// Registry is already loaded
|
||||
if (riftRegistry.subregistries.get(dim) != null) return;
|
||||
if (riftRegistry == null) RiftRegistry.instance();
|
||||
|
||||
// Read rifts in this dimension
|
||||
NBTTagList riftsNBT = (NBTTagList) nbt.getTag("rifts");
|
||||
|
@ -95,6 +95,7 @@ public class RiftRegistry extends WorldSavedData {
|
|||
// method rather than RiftSubregistry) and save each in the appropriate registry, we can't do this because it is not
|
||||
// always the case that all worlds will be saved at once.
|
||||
@Override public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
|
||||
if (riftRegistry == null) RiftRegistry.instance();
|
||||
// Write rifts in this dimension
|
||||
NBTTagList riftsNBT = new NBTTagList();
|
||||
NBTTagList pocketsNBT = new NBTTagList();
|
||||
|
|
Loading…
Reference in a new issue