feat: decouple orbit size from border size

This commit is contained in:
Timo Ley 2024-08-25 20:17:31 +02:00
parent 90abf4fcde
commit 7afa5d5964
4 changed files with 109 additions and 50 deletions

View file

@ -11,11 +11,14 @@ buildscript {
}
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT'
classpath ('com.anatawa12.forge:ForgeGradle:1.2-1.0.+') {
changing = true
}
}
}
apply plugin: 'forge'
apply plugin: 'maven-publish'
// define the properties file
ext.configFile = file "build.properties"
@ -35,7 +38,7 @@ sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
minecraft {
version = config.minecraft_version + "-" + config.forge_version
version = "1.7.10-10.13.4.1614-1.7.10"
runDir = "run"
// replacing
@ -68,18 +71,9 @@ processResources {
exclude '**/*.pdn'
exclude '**/*.psd'
// replace stuff in mcmod.info, nothing else
from(sourceSets.main.resources.srcDirs) {
include 'mcmod.info'
// replace version and mcversion
filesMatching('mcmod.info') {
expand 'version':project.version, 'mcversion':project.minecraft.version
}
// copy everything else, thats not the mcmod.info
from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'
}
}
//copies the commons folder to all instances
@ -116,16 +110,48 @@ jar {
destinationDir = file 'output'
}
idea {
module {
inheritOutputDirs = true
}
}
runClient {
jvmArgs "-Xmx2048m", "-Xms1024m", "-ea"
}
runServer {
jvmArgs "-Xmx2048m", "-Xms1024m", "-ea"
}
task deobfJar(type: Jar) {
from sourceSets.main.output
classifier = 'deobf'
}
task sourcesJar(type: Jar) {
from sourceSets.main.allSource
classifier = 'sources'
}
publishing {
tasks.publish.dependsOn 'build'
publications {
mavenJava(MavenPublication) {
artifactId = project.archivesBaseName
artifact deobfJar
artifact sourcesJar
artifact jar
}
}
repositories {
if (project.hasProperty('mvnURL')) {
maven {
credentials {
username findProperty("mvnUsername")
password findProperty("mvnPassword")
}
url = findProperty("mvnURL")
}
}
else {
mavenLocal()
}
}
}

View file

@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.0-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.1-bin.zip

View file

@ -50,6 +50,7 @@ public class CelestialObject implements Cloneable, IStringSerializable, ICelesti
private boolean isParentResolved;
protected int parentCenterX, parentCenterZ;
public int orbitRadiusX, orbitRadiusZ;
public int borderRadiusX, borderRadiusZ;
private String displayName;
@ -81,6 +82,7 @@ public class CelestialObject implements Cloneable, IStringSerializable, ICelesti
public CelestialObject(final int parDimensionId, final int parDimensionCenterX, final int parDimensionCenterZ,
final int parBorderRadiusX, final int parBorderRadiusZ,
final int parOrbitRadiusX, final int parOrbitRadiusZ,
final String parParentId, final int parParentCenterX, final int parParentCenterZ) {
isVirtual = false;
isParentResolved = false;
@ -89,6 +91,8 @@ public class CelestialObject implements Cloneable, IStringSerializable, ICelesti
dimensionCenterZ = parDimensionCenterZ;
borderRadiusX = parBorderRadiusX;
borderRadiusZ = parBorderRadiusZ;
orbitRadiusX = parOrbitRadiusX;
orbitRadiusZ = parOrbitRadiusZ;
parentId = parParentId;
parentCenterX = parParentCenterX;
parentCenterZ = parParentCenterZ;
@ -112,6 +116,17 @@ public class CelestialObject implements Cloneable, IStringSerializable, ICelesti
WarpDrive.logger.info("- found Celestial object " + id);
// get required size element
{
final List<Element> listElements = XmlFileManager.getChildrenElementByTagName(elementCelestialObject, "size");
if (listElements.size() != 1) {
throw new InvalidXmlException(String.format("Celestial object %s requires exactly one size element", id));
}
final Element elementSize = listElements.get(0);
borderRadiusX = Integer.parseInt(elementSize.getAttribute("x")) / 2;
borderRadiusZ = Integer.parseInt(elementSize.getAttribute("z")) / 2;
}
// get optional parent element, defaulting to parent defined by element hierarchy
parentId = parentElementId;
final List<Element> listParents = XmlFileManager.getChildrenElementByTagName(elementCelestialObject,"parent");
@ -128,25 +143,33 @@ public class CelestialObject implements Cloneable, IStringSerializable, ICelesti
}
// get required center element
final List<Element> listElements = XmlFileManager.getChildrenElementByTagName(elementParent, "center");
if (listElements.size() != 1) {
throw new InvalidXmlException(String.format("Celestial object %s parent requires exactly one center element", id));
{
final List<Element> listElements = XmlFileManager.getChildrenElementByTagName(elementParent, "center");
if (listElements.size() != 1) {
throw new InvalidXmlException(String.format("Celestial object %s parent requires exactly one center element", id));
}
final Element elementCenter = listElements.get(0);
parentCenterX = Integer.parseInt(elementCenter.getAttribute("x"));
parentCenterZ = Integer.parseInt(elementCenter.getAttribute("z"));
}
// get optional size element
{
final List<Element> listElements = XmlFileManager.getChildrenElementByTagName(elementParent, "size");
if (listElements.size() > 1) {
throw new InvalidXmlException(String.format("Celestial object %s parent can only have up to one size element", id));
} else if (listElements.size() == 1) {
final Element elementSize = listElements.get(0);
orbitRadiusX = Integer.parseInt(elementSize.getAttribute("x")) / 2;
orbitRadiusZ = Integer.parseInt(elementSize.getAttribute("z")) / 2;
} else {
orbitRadiusX = borderRadiusX;
orbitRadiusZ = borderRadiusZ;
}
}
final Element elementCenter = listElements.get(0);
parentCenterX = Integer.parseInt(elementCenter.getAttribute("x"));
parentCenterZ = Integer.parseInt(elementCenter.getAttribute("z"));
}
// get required size element
{
final List<Element> listElements = XmlFileManager.getChildrenElementByTagName(elementCelestialObject, "size");
if (listElements.size() != 1) {
throw new InvalidXmlException(String.format("Celestial object %s requires exactly one size element", id));
}
final Element elementSize = listElements.get(0);
borderRadiusX = Integer.parseInt(elementSize.getAttribute("x")) / 2;
borderRadiusZ = Integer.parseInt(elementSize.getAttribute("z")) / 2;
}
// get optional name elements
{
@ -393,7 +416,7 @@ public class CelestialObject implements Cloneable, IStringSerializable, ICelesti
@SuppressWarnings("CloneDoesntCallSuperClone")
@Override
public CelestialObject clone() {
return new CelestialObject(dimensionId, dimensionCenterX, dimensionCenterZ, borderRadiusX, borderRadiusZ, parentId, parentCenterX, parentCenterZ);
return new CelestialObject(dimensionId, dimensionCenterX, dimensionCenterZ, borderRadiusX, borderRadiusZ, orbitRadiusX, orbitRadiusZ, parentId, parentCenterX, parentCenterZ);
}
public StructureGroup getRandomStructure(final Random random, final int x, final int z) {
@ -462,8 +485,8 @@ public class CelestialObject implements Cloneable, IStringSerializable, ICelesti
@Override
public AxisAlignedBB getAreaInParent() {
return AxisAlignedBB.getBoundingBox(
(parentCenterX - borderRadiusX), 0, (parentCenterZ - borderRadiusZ),
(parentCenterX + borderRadiusX), 8, (parentCenterZ + borderRadiusZ) );
(parentCenterX - orbitRadiusX), 0, (parentCenterZ - orbitRadiusZ),
(parentCenterX + orbitRadiusX), 8, (parentCenterZ + orbitRadiusZ) );
}
/**
@ -537,13 +560,13 @@ public class CelestialObject implements Cloneable, IStringSerializable, ICelesti
return Double.POSITIVE_INFINITY;
}
// are we in orbit?
if ( (Math.abs(x - parentCenterX) <= borderRadiusX)
&& (Math.abs(z - parentCenterZ) <= borderRadiusZ) ) {
if ( (Math.abs(x - parentCenterX) <= orbitRadiusX)
&& (Math.abs(z - parentCenterZ) <= orbitRadiusZ) ) {
return 0.0D;
}
// do the maths
final double dx = Math.max(0.0D, Math.abs(x - parentCenterX) - borderRadiusX);
final double dz = Math.max(0.0D, Math.abs(z - parentCenterZ) - borderRadiusZ);
final double dx = Math.max(0.0D, Math.abs(x - parentCenterX) - orbitRadiusX);
final double dz = Math.max(0.0D, Math.abs(z - parentCenterZ) - orbitRadiusZ);
return dx * dx + dz * dz;
}
@ -562,8 +585,8 @@ public class CelestialObject implements Cloneable, IStringSerializable, ICelesti
return false;
}
// are we in orbit?
return (Math.abs(x - parentCenterX) <= borderRadiusX)
&& (Math.abs(z - parentCenterZ) <= borderRadiusZ);
return (Math.abs(x - parentCenterX) <= orbitRadiusX)
&& (Math.abs(z - parentCenterZ) <= orbitRadiusZ);
}
public void readFromNBT(final NBTTagCompound tagCompound) {
@ -577,6 +600,11 @@ public class CelestialObject implements Cloneable, IStringSerializable, ICelesti
borderRadiusX = tagCompound.getInteger("borderRadiusX");
borderRadiusZ = tagCompound.getInteger("borderRadiusZ");
if (tagCompound.hasKey("orbitRadiusX") && tagCompound.hasKey("orbitRadiusZ")) {
orbitRadiusX = tagCompound.getInteger("orbitRadiusX");
orbitRadiusZ = tagCompound.getInteger("orbitRadiusZ");
}
displayName = tagCompound.getString("displayName");
description = tagCompound.getString("description");
@ -627,6 +655,9 @@ public class CelestialObject implements Cloneable, IStringSerializable, ICelesti
tagCompound.setInteger("borderRadiusX", borderRadiusX);
tagCompound.setInteger("borderRadiusZ", borderRadiusZ);
tagCompound.setInteger("orbitRadiusX", orbitRadiusX);
tagCompound.setInteger("orbitRadiusZ", orbitRadiusZ);
if (displayName != null && !displayName.isEmpty()) {
tagCompound.setString("displayName", displayName);
@ -677,6 +708,8 @@ public class CelestialObject implements Cloneable, IStringSerializable, ICelesti
&& dimensionCenterZ == celestialObject.dimensionCenterZ
&& borderRadiusX == celestialObject.borderRadiusX
&& borderRadiusZ == celestialObject.borderRadiusZ
&& orbitRadiusX == celestialObject.orbitRadiusX
&& orbitRadiusZ == celestialObject.orbitRadiusZ
&& parentId.equals(celestialObject.parentId)
&& parentCenterX == celestialObject.parentCenterX
&& parentCenterZ == celestialObject.parentCenterZ;

View file

@ -233,10 +233,10 @@ public class CelestialObjectManager extends XmlFileManager {
celestialObject1.id,
celestialObject1.parentId));
}
} else if ( celestialObject1.parentCenterX - celestialObject1.borderRadiusX < celestialObjectParent.dimensionCenterX - celestialObjectParent.borderRadiusX
|| celestialObject1.parentCenterZ - celestialObject1.borderRadiusZ < celestialObjectParent.dimensionCenterZ - celestialObjectParent.borderRadiusZ
|| celestialObject1.parentCenterX + celestialObject1.borderRadiusX > celestialObjectParent.dimensionCenterX + celestialObjectParent.borderRadiusX
|| celestialObject1.parentCenterZ + celestialObject1.borderRadiusZ > celestialObjectParent.dimensionCenterZ + celestialObjectParent.borderRadiusZ ) {
} else if ( celestialObject1.parentCenterX - celestialObject1.orbitRadiusX < celestialObjectParent.dimensionCenterX - celestialObjectParent.borderRadiusX
|| celestialObject1.parentCenterZ - celestialObject1.orbitRadiusZ < celestialObjectParent.dimensionCenterZ - celestialObjectParent.borderRadiusZ
|| celestialObject1.parentCenterX + celestialObject1.orbitRadiusX > celestialObjectParent.dimensionCenterX + celestialObjectParent.borderRadiusX
|| celestialObject1.parentCenterZ + celestialObject1.orbitRadiusZ > celestialObjectParent.dimensionCenterZ + celestialObjectParent.borderRadiusZ ) {
countErrors++;
WarpDrive.logger.error(String.format("CelestiaObjects validation error #%d\nCelestial object %s is outside its parent border.\n%s\n%s\n%s's area in parent %s is outside %s's border %s",
countErrors,
@ -251,8 +251,8 @@ public class CelestialObjectManager extends XmlFileManager {
}
if ( celestialObject1.dimensionCenterX - celestialObject1.borderRadiusX < -30000000
|| celestialObject1.dimensionCenterZ - celestialObject1.borderRadiusZ < -30000000
|| celestialObject1.dimensionCenterX + celestialObject1.borderRadiusX >= 30000000
|| celestialObject1.dimensionCenterZ + celestialObject1.borderRadiusZ >= 30000000 ) {
|| celestialObject1.dimensionCenterX + celestialObject1.borderRadiusX > 30000000
|| celestialObject1.dimensionCenterZ + celestialObject1.borderRadiusZ > 30000000 ) {
countErrors++;
WarpDrive.logger.error(String.format("CelestiaObjects validation error #%d\nCelestial object %s is outside the game border +/-30000000.\n%s\n%s border is %s",
countErrors,