Browse Source

Added work so far

master
Thomas Johnson 2 years ago
commit
2b2e25530a
  1. 30
      .gitignore
  2. 127
      build.gradle
  3. 4
      gradle.properties
  4. BIN
      gradle/wrapper/gradle-wrapper.jar
  5. 5
      gradle/wrapper/gradle-wrapper.properties
  6. 172
      gradlew
  7. 84
      gradlew.bat
  8. 73
      src/main/java/t/j/dual/CommandDimension.java
  9. 70
      src/main/java/t/j/dual/Dual.java
  10. 254
      src/main/java/t/j/dual/WorldProviderPeace.java
  11. 16
      src/main/resources/mcmod.info
  12. 7
      src/main/resources/pack.mcmeta

30
.gitignore

@ -0,0 +1,30 @@
# eclipse
bin
*.launch
.settings
.metadata
.classpath
.project
# idea
out
*.ipr
*.iws
*.iml
.idea
# gradle
build
.gradle
# other
eclipse
run
CREDITS-forge.txt
LICENSE-Paulscode IBXM Library.txt
LICENSE-Paulscode SoundSystem CodecIBXM.txt
LICENSE-forge.txt
README-forge.txt
# Files from Forge MDK
forge*changelog.txt

127
build.gradle

@ -0,0 +1,127 @@
buildscript {
repositories {
maven { url = 'https://files.minecraftforge.net/maven' }
jcenter()
mavenCentral()
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:3.+'
}
}
apply plugin: 'net.minecraftforge.gradle'
// Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
apply plugin: 'eclipse'
//apply plugin: 'maven-publish'
version = '1.0'
group = 't.j' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = 'dual'
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.
allprojects {
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
}
}
}
minecraft {
// The mappings can be changed at any time, and must be in the following format.
// snapshot_YYYYMMDD Snapshot are built nightly.
// stable_# Stables are built at the discretion of the MCP team.
// Use non-default mappings at your own risk. they may not always work.
// Simply re-run your setup task after changing the mappings to update your workspace.
//mappings channel: 'snapshot', version: '20171003-1.12'
mappings channel: 'snapshot', version: '20171003-1.12'
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
// accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
// Default run configurations.
// These can be tweaked, removed, or duplicated as needed.
runs {
client {
workingDirectory project.file('run')
// Recommended logging data for a userdev environment
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
// Recommended logging level for the console
property 'forge.logging.console.level', 'debug'
}
server {
// Recommended logging data for a userdev environment
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
// Recommended logging level for the console
property 'forge.logging.console.level', 'debug'
//args 'nogui'
}
}
}
dependencies {
// Specify the version of Minecraft to use, If this is any group other then 'net.minecraft' it is assumed
// that the dep is a ForgeGradle 'patcher' dependency. And it's patches will be applied.
// The userdev artifact is a special name and will get all sorts of transformations applied to it.
minecraft 'net.minecraftforge:forge:1.12.2-14.23.5.2854'
// You may put jars on which you depend on in ./libs or you may define them like so..
// compile "some.group:artifact:version:classifier"
// compile "some.group:artifact:version"
// Real examples
// compile 'com.mod-buildcraft:buildcraft:6.0.8:dev' // adds buildcraft to the dev env
// compile 'com.googlecode.efficient-java-matrix-library:ejml:0.24' // adds ejml to the dev env
// The 'provided' configuration is for optional dependencies that exist at compile-time but might not at runtime.
// provided 'com.mod-buildcraft:buildcraft:6.0.8:dev'
// These dependencies get remapped to your current MCP mappings
// deobf 'com.mod-buildcraft:buildcraft:6.0.8:dev'
// For more info...
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
// http://www.gradle.org/docs/current/userguide/dependency_management.html
}
// Example for how to get properties into the manifest for reading by the runtime..
jar {
manifest {
attributes([
"Specification-Title": "dual",
"Specification-Vendor": "cosi?",
"Specification-Version": "1", // We are version 1 of ourselves
"Implementation-Title": project.name,
"Implementation-Version": "${version}",
"Implementation-Vendor" :"cosi?",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
])
}
}
// Example configuration to allow publishing using the maven-publish task
// This is the preferred method to reobfuscate your jar file
jar.finalizedBy('reobfJar')
// However if you are in a multi-project build, dev time needs unobfed jar files, so you can delay the obfuscation until publishing by doing
//publish.dependsOn('reobfJar')
//publishing {
// publications {
// mavenJava(MavenPublication) {
// artifact jar
// }
// }
// repositories {
// maven {
// url "file:///${project.projectDir}/mcmodsrepo"
// }
// }
//}

4
gradle.properties

@ -0,0 +1,4 @@
# Sets default memory used for gradle commands. Can be overridden by user or command line properties.
# This is required to provide enough memory for the Minecraft decompilation process.
org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false

BIN
gradle/wrapper/gradle-wrapper.jar

5
gradle/wrapper/gradle-wrapper.properties

@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-bin.zip

172
gradlew

@ -0,0 +1,172 @@
#!/usr/bin/env sh
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn () {
echo "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=$(save "$@")
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi
exec "$JAVACMD" "$@"

84
gradlew.bat

@ -0,0 +1,84 @@
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

73
src/main/java/t/j/dual/CommandDimension.java

@ -0,0 +1,73 @@
package t.j.dual;
import java.util.Iterator;
import net.minecraftforge.common.util.ITeleporter;
import net.minecraftforge.common.DimensionManager;
import net.minecraft.world.World;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.server.MinecraftServer;
import net.minecraft.command.CommandBase;
import net.minecraft.command.CommandException;
import net.minecraft.command.SyntaxErrorException;
import net.minecraft.command.ICommandSender;
import org.apache.logging.log4j.Logger;
public class CommandDimension extends CommandBase {
Logger logger;
ITeleporter itp;
public CommandDimension(Logger logger) {
this.logger = logger;
this.itp = new CommandITeleporter(logger);
}
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
String argcat = "";
for (String arg : args) {
argcat += arg + " ";
}
logger.info("" + sender + " is executing /dimension: " + argcat);
if (sender instanceof EntityPlayerMP) {
EntityPlayerMP player = (EntityPlayerMP) sender;
if (args.length != 1) {
throw new SyntaxErrorException();
}
int dimid = CommandBase.parseInt(args[0]);
if (!DimensionManager.isDimensionRegistered(dimid)) {
throw new CommandException("That dimension isn't registered!");
}
server.getPlayerList().transferPlayerToDimension(player, dimid, itp);
}
}
@Override
public String getName() {
return "dimension";
}
@Override
public String getUsage(ICommandSender sender) {
if (sender instanceof EntityPlayer) {
return "/dimension <id>";
} else {
return "/dimension <selector> <id>";
}
}
}
class CommandITeleporter implements ITeleporter {
Logger logger;
public CommandITeleporter(Logger l) {
this.logger = l;
}
@Override
public void placeEntity(World world, Entity entity, float yaw) {
}
}

70
src/main/java/t/j/dual/Dual.java

@ -0,0 +1,70 @@
package t.j.dual;
import net.minecraft.init.Blocks;
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraft.world.WorldServerMulti;
import net.minecraft.profiler.Profiler;
import net.minecraft.world.DimensionType;
import net.minecraft.command.CommandHandler;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
import net.minecraftforge.fml.common.thread.SidedThreadGroups;
import net.minecraftforge.common.WorldSpecificSaveHandler;
import net.minecraftforge.common.DimensionManager;
import org.apache.logging.log4j.Logger;
import t.j.dual.WorldProviderPeace;
import t.j.dual.CommandDimension;
@Mod(modid = Dual.MODID, name = Dual.NAME, version = Dual.VERSION)
public class Dual
{
public static final String MODID = "dual";
public static final String NAME = "Dual";
public static final String VERSION = "1.0";
private static Logger logger;
DimensionType peace_dt;
@EventHandler
public void preInit(FMLPreInitializationEvent event)
{
logger = event.getModLog();
}
@EventHandler
public void init(FMLInitializationEvent event)
{
peace_dt = DimensionType.register("Peace", "_peace", 2, WorldProviderPeace.class, false);
WorldProviderPeace.dimType = peace_dt;
WorldProviderPeace.logger = logger;
DimensionManager.registerDimension(peace_dt.getId(), peace_dt);
for (DimensionType dt : DimensionType.values()) {
logger.info("dimension: " + dt.getId() + " " + dt.getName() + " " + dt.getSuffix());
}
}
@EventHandler
public void serverStarting(FMLServerStartingEvent event) {
logger.info("starting SERVER right now!");
ThreadGroup currentGroup = Thread.currentThread().getThreadGroup();
if (currentGroup == SidedThreadGroups.SERVER) {
logger.info("running as a SERVER thread");
} else if (currentGroup == SidedThreadGroups.CLIENT) {
logger.info("running as a CLIENT thread");
}
MinecraftServer server = event.getServer();
for (WorldServer w : server.worlds) {
logger.info("found a world: " + w);
logger.info("its save handler: " + w.getSaveHandler());
}
CommandHandler sch = (CommandHandler) server.getCommandManager();
sch.registerCommand(new CommandDimension(logger));
}
}

254
src/main/java/t/j/dual/WorldProviderPeace.java

@ -0,0 +1,254 @@
package t.j.dual;
import java.util.Collection;
import java.util.List;
import java.util.ArrayList;
import java.util.Random;
import java.util.Iterator;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraft.world.DimensionType;
import net.minecraft.world.WorldProvider;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.ChunkPrimer;
import net.minecraft.world.gen.IChunkGenerator;
import net.minecraft.util.math.*;
import net.minecraft.world.biome.Biome;
import net.minecraft.entity.EnumCreatureType;
import net.minecraft.block.state.IBlockState;
import net.minecraft.block.properties.IProperty;
import net.minecraft.init.Blocks;
import org.apache.logging.log4j.Logger;
public class WorldProviderPeace extends WorldProvider {
public static DimensionType dimType;
public static Logger logger;
public WorldProviderPeace() {
super();
}
@Override
public IChunkGenerator createChunkGenerator() {
return new BedrockChunkGenerator(world);
}
public DimensionType getDimensionType() {
return dimType;
}
}
class BedrockChunkGenerator implements IChunkGenerator {
World world;
Random random;
PointWorld pointworld;
public BedrockChunkGenerator(World w) {
world = w;
this.pointworld = new PointWorld(world.getSeed());
this.random = new Random();
}
public Chunk generateChunk(int X, int Z) {
WorldProviderPeace.logger.info("bedrock: " + X + " " + Z);
ChunkPrimer primer = new ChunkPrimer();
for (int x = 0; x < 16; x++) {
for (int z = 0; z < 16; z++) {
primer.setBlockState(x, 0, z, Blocks.BEDROCK.getDefaultState());
}
}
WorldProviderPeace.logger.info("points:" + X + " " + Z);
List<Vec3d> points = pointworld.pointsInAABB(random, new Vec3d(8 * X, 0, 8 * Z), new Vec3d(8 * X + 8, 8 * 16, 8 * Z + 8));
WorldProviderPeace.logger.info("blocks: " + X + " " + Z);
int i = 0;
for (Vec3d point: points) {
i++;
primer.setBlockState((int) (2 * (point.x - 8 * X)), (int) (2 * point.y), (int) (2 * (point.z - 8 * Z)), Blocks.REDSTONE_BLOCK.getDefaultState());
}
WorldProviderPeace.logger.info("(generated " + i + " blocks): " + X + " " + Z);
WorldProviderPeace.logger.info("chunk: " + X + " " + Z);
primer.setBlockState(0, 255, 0, Blocks.GOLD_BLOCK.getDefaultState());
primer.setBlockState(15, 255, 0, Blocks.GOLD_BLOCK.getDefaultState());
primer.setBlockState(15, 255, 15, Blocks.GOLD_BLOCK.getDefaultState());
primer.setBlockState(0, 255, 15, Blocks.GOLD_BLOCK.getDefaultState());
Chunk chunk = new Chunk(world, primer, X, Z);
//chunk.generateSkylightMap();
WorldProviderPeace.logger.info("done: " + X + " " + Z);
return chunk;
}
public boolean generateStructures(Chunk chunkIn, int x, int z) {
return true;
}
public BlockPos getNearestStructurePos(World worldIn, String stuctureName, BlockPos position, boolean findUnexplored) {
return null;
}
public List<Biome.SpawnListEntry> getPossibleCreatures(EnumCreatureType creatureType, BlockPos pos) {
return new ArrayList<Biome.SpawnListEntry>();
}
public boolean isInsideStructure(World worldIn, String structureName, BlockPos pos) {
return false;
}
public void populate(int x, int z) {
}
public void recreateStructures(Chunk chunkIn, int x, int y) {
}
private float[] verticalWeightMap(int x, int z) {
float[] map = new float[256];
return map;
}
}
class Utilities {
public static int drawPoisson(Random random, float mean) {
float target = (float) Math.exp(-mean);
float l = 1.0f;
int result = 0;
while (l > target) {
result += 1;
l *= random.nextFloat();
}
return result - 1;
}
public static boolean inBoundingBox(Vec3d point, Vec3d origin, Vec3d remote) {
return origin.x < point.x && point.x < remote.x &&
origin.y < point.y && point.y < remote.y &&
origin.z < point.z && point.z < remote.z;
}
}
interface PointList {
int numPoints();
Vec3d nth(int idx);
Vec3d center();
public Iterator<Vec3d> iterator();
// bounding box:
Vec3d origin();
Vec3d remote();
}
class PointGrid implements PointList {
public Vec3d origin;
public Vec3d step;
public Vec3i extent;
public class Iter implements Iterator<Vec3d> {
public PointGrid grid;
int x, y, z;
public Iter(PointGrid grid) {
this.x = 0;
this.y = 0;
this.z = 0;
this.grid = grid;
}
public boolean hasNext() {
return z < grid.extent.getZ();
}
public Vec3d next() {
Vec3d result = new Vec3d(origin.x + x * step.x, origin.y + y * step.y, origin.z + z * step.z);
x += 1;
if (x == grid.extent.getX()) {
x = 0;
y += 1;
if (y == grid.extent.getY()) {
y = 0;
z += 1;
}
}
return result;
}
}
public PointGrid(Vec3d origin, Vec3i extent, Vec3d step) {
this.origin = origin;
this.extent = extent;
this.step = step;
}
public PointGrid(Vec3d origin, Vec3d remote, Vec3i extent) {
this.origin = origin;
this.extent = extent;
Vec3d size = remote.subtract(origin);
Vec3d divisor = new Vec3d(extent.getX() - 1, extent.getY() - 1, extent.getZ() - 1);
this.step = new Vec3d(size.x / divisor.x, size.y / divisor.y, size.z / divisor.z);
}
public int numPoints() {
return extent.getX() * extent.getY() * extent.getZ();
}
public Vec3d nth(int idx) {
int coordX = idx / (extent.getY() * extent.getZ());
int remX = idx % (extent.getY() * extent.getZ());
int coordY = remX / extent.getZ();
int coordZ = remX % extent.getZ();
return new Vec3d(origin.x + coordX * step.x, origin.y + coordY * step.y, origin.z + coordZ * step.z);
}
public Iterator<Vec3d> iterator() {
return new Iter(this);
}
public Vec3d center() {
return new Vec3d(origin.x + (extent.getX() - 1) * step.x / 2.0, origin.y + (extent.getY() - 1) * step.y / 2.0, origin.z + (extent.getZ() - 1) * step.z / 2.0);
}
public Vec3d origin() {
return origin;
}
public Vec3d remote() {
return new Vec3d(origin.x + (extent.getX() - 1) * step.x, origin.y + (extent.getY() - 1) * step.y, origin.z + (extent.getZ() - 1) * step.z);
}
}
class PointWorld {
long seed;
public PointWorld(long seed) {
this.seed = seed;
}
public Vec3d[] pointsInCell(Random random, Vec3i cell) {
random.setSeed(seed ^ cell.hashCode());
int nPoints = Utilities.drawPoisson(random, 1.0f);
Vec3d[] points = new Vec3d[nPoints];
for (int i = 0; i < nPoints; i++) {
points[i] = new Vec3d(cell.getX() + random.nextDouble(), cell.getY() + random.nextDouble(), cell.getZ() + random.nextDouble());
}
return points;
}
public ArrayList<Vec3d> pointsInAABB(Random random, Vec3d origin, Vec3d remote) {
ArrayList<Vec3d> points = new ArrayList<Vec3d>();
for (int x = (int) Math.floor(origin.x); x <= (int) Math.ceil(remote.x); x++) {
for (int y = (int) Math.floor(origin.y); y <= (int) Math.ceil(remote.y); y++) {
for (int z = (int) Math.floor(origin.z); z <= (int) Math.ceil(remote.z); z++) {
for (Vec3d point : pointsInCell(random, new Vec3i(x, y, z))) {
if (Utilities.inBoundingBox(point, origin, remote)) {
points.add(point);
}
}
}
}
}
return points;
}
public double[][] voronoiNoise(Random random, PointList evalAt) {
return new double[0][0];
}
}

16
src/main/resources/mcmod.info

@ -0,0 +1,16 @@
[
{
"modid": "dual",
"name": "Dual",
"description": "Mod that creates two overworld-like dimensions.",
"version": "${version}",
"mcversion": "${mcversion}",
"url": "",
"updateUrl": "",
"authorList": ["thajohns"],
"credits": "A little bit of me, but mostly the folks who write Forge documentation and examples.",
"logoFile": "",
"screenshots": [],
"dependencies": []
}
]

7
src/main/resources/pack.mcmeta

@ -0,0 +1,7 @@
{
"pack": {
"description": "examplemod resources",
"pack_format": 3,
"_comment": "A pack_format of 3 should be used starting with Minecraft 1.11. All resources, including language files, should be lowercase (eg: en_us.lang). A pack_format of 2 will load your mod resources with LegacyV2Adapter, which requires language files to have uppercase letters (eg: en_US.lang)."
}
}
Loading…
Cancel
Save