Gradle and travis improvements
- Simplify pocket schematic generation logic - Make pocket generator work without having to start Minecraft - Add `gradlew generatePocketSchematics` task - Fix travis double-build
This commit is contained in:
parent
70b35a2f5e
commit
3d50cd8fdf
42 changed files with 204 additions and 122 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -28,3 +28,4 @@ libs
|
||||||
forge-*-changelog.txt
|
forge-*-changelog.txt
|
||||||
.DS_Store
|
.DS_Store
|
||||||
Thumbs.db
|
Thumbs.db
|
||||||
|
logs
|
||||||
|
|
|
@ -2,8 +2,8 @@ language: java
|
||||||
notifications:
|
notifications:
|
||||||
email: false
|
email: false
|
||||||
before_install: chmod +x gradlew
|
before_install: chmod +x gradlew
|
||||||
install: "./gradlew setupCIWorkspace -s"
|
install: "./gradlew setupCIWorkspace"
|
||||||
script: "./gradlew build -s"
|
script: "./gradlew build"
|
||||||
jdk:
|
jdk:
|
||||||
- oraclejdk8
|
- oraclejdk8
|
||||||
before_cache:
|
before_cache:
|
||||||
|
@ -18,7 +18,8 @@ deploy:
|
||||||
provider: releases
|
provider: releases
|
||||||
api_key:
|
api_key:
|
||||||
secure: A26twoR4XbarXTCxNIlKr4zbDRw6B+u879+6BWEKmavgAnjhGkPb9PkmR3tPm7iQDp9K9dlkez5KGUJEX/tCMYqL2gQnjlt9BfcVu7YJ4SXhZ6Zcck1/+1jhDox8QHLT2zvgYhmmEWdDD78FHJfO+2+ejhdxDMt6xxVtn47426rs0d0I1L9KDlC8EVoe42c+142Dedk5IaI2GCU07nOKaZFtAnR0NIk/Cf5P7rtecd+jNR3kaAu24U/WPoUMH2cCCf1+ViK/oJgu4FgdEGp1kec0gZnwWqJ+bYvywGiohmbN9B0JsjrwVixYgmzEw00cvdcV8uZHY/RXfOVtDh3ex9xaQYu6Fiq7L8pnw/pN6wsr7kFE0HvhSDAILIAOHFt5jlocAUfjEV/wFQyZUhxZx6Qclx7rdwYt4+iwtB+DPXR71JaaeSLtuQ7Q6HbFxrnjo1biS2ERkdOJobNBHEZvH2A9O1+bx4q9z1+LAP/XXxK2+KpzVZzkDXVUMl81oyAycuipXZQVTyDQdp9XB+waj7xclL57Cibs/DfwOw9l8DKR981h2Q784jBVlJyv/s+vZDgouxLqeTJdsK2cKOuYKl/fMhio6FIJs7p8U7l2OiXbvAg5jY1sJj69ePn7hTiMn2QHVihVM0t3W3/ppp7U0XKo++hB2VXwT/fSS8E5aXs=
|
secure: A26twoR4XbarXTCxNIlKr4zbDRw6B+u879+6BWEKmavgAnjhGkPb9PkmR3tPm7iQDp9K9dlkez5KGUJEX/tCMYqL2gQnjlt9BfcVu7YJ4SXhZ6Zcck1/+1jhDox8QHLT2zvgYhmmEWdDD78FHJfO+2+ejhdxDMt6xxVtn47426rs0d0I1L9KDlC8EVoe42c+142Dedk5IaI2GCU07nOKaZFtAnR0NIk/Cf5P7rtecd+jNR3kaAu24U/WPoUMH2cCCf1+ViK/oJgu4FgdEGp1kec0gZnwWqJ+bYvywGiohmbN9B0JsjrwVixYgmzEw00cvdcV8uZHY/RXfOVtDh3ex9xaQYu6Fiq7L8pnw/pN6wsr7kFE0HvhSDAILIAOHFt5jlocAUfjEV/wFQyZUhxZx6Qclx7rdwYt4+iwtB+DPXR71JaaeSLtuQ7Q6HbFxrnjo1biS2ERkdOJobNBHEZvH2A9O1+bx4q9z1+LAP/XXxK2+KpzVZzkDXVUMl81oyAycuipXZQVTyDQdp9XB+waj7xclL57Cibs/DfwOw9l8DKR981h2Q784jBVlJyv/s+vZDgouxLqeTJdsK2cKOuYKl/fMhio6FIJs7p8U7l2OiXbvAg5jY1sJj69ePn7hTiMn2QHVihVM0t3W3/ppp7U0XKo++hB2VXwT/fSS8E5aXs=
|
||||||
file: "./build/libs/dimdoors-1.12.2-3.0.0-a4.jar"
|
file: "./build/libs/dimdoors.jar"
|
||||||
on:
|
on:
|
||||||
repo: DimensionalDevelopment/DimDoors
|
repo: DimensionalDevelopment/DimDoors
|
||||||
branch: 1.12-WIP
|
branch: 1.12-WIP
|
||||||
|
tags: false
|
||||||
|
|
|
@ -24,6 +24,7 @@ ext.forgeversion = "14.23.1.2555"
|
||||||
version = mcversion + "-" + modversion
|
version = mcversion + "-" + modversion
|
||||||
group = "com.zixiken.dimdoors" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
group = "com.zixiken.dimdoors" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||||
archivesBaseName = "dimdoors"
|
archivesBaseName = "dimdoors"
|
||||||
|
jar.archiveName = "dimdoors.jar" // Constant name for travis
|
||||||
|
|
||||||
sourceCompatibility = targetCompatibility = "1.8" // Need this here so eclipse task generates correctly.
|
sourceCompatibility = targetCompatibility = "1.8" // Need this here so eclipse task generates correctly.
|
||||||
compileJava {
|
compileJava {
|
||||||
|
@ -70,3 +71,10 @@ processResources {
|
||||||
exclude 'mcmod.info'
|
exclude 'mcmod.info'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
task generatePocketSchematics(dependsOn: jar, type: JavaExec, group: "dimdoors") {
|
||||||
|
classpath = files('build/libs/dimdoors.jar')
|
||||||
|
classpath += sourceSets.main.runtimeClasspath
|
||||||
|
main = "com.zixiken.dimdoors.shared.util.PocketSchematicGenerator"
|
||||||
|
args "src/main/resources/assets/dimdoors/pockets/schematic"
|
||||||
|
}
|
||||||
|
|
4
gradle/wrapper/gradle-wrapper.properties
vendored
4
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -1,6 +1,6 @@
|
||||||
#Sat Dec 16 20:23:21 EST 2017
|
#Tue Dec 19 19:32:34 EST 2017
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
|
||||||
|
|
|
@ -6,12 +6,10 @@ import com.zixiken.dimdoors.shared.entities.EntityMonolith;
|
||||||
import com.zixiken.dimdoors.shared.items.ModItems;
|
import com.zixiken.dimdoors.shared.items.ModItems;
|
||||||
import com.zixiken.dimdoors.shared.sound.ModSounds;
|
import com.zixiken.dimdoors.shared.sound.ModSounds;
|
||||||
import com.zixiken.dimdoors.shared.tileentities.*;
|
import com.zixiken.dimdoors.shared.tileentities.*;
|
||||||
import com.zixiken.dimdoors.shared.util.DefaultSchematicGenerator;
|
|
||||||
import com.zixiken.dimdoors.shared.world.DimDoorDimensions;
|
import com.zixiken.dimdoors.shared.world.DimDoorDimensions;
|
||||||
import com.zixiken.dimdoors.shared.world.ModBiomes;
|
import com.zixiken.dimdoors.shared.world.ModBiomes;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.world.WorldProvider;
|
import net.minecraft.world.WorldProvider;
|
||||||
import net.minecraft.world.biome.Biome;
|
|
||||||
import net.minecraftforge.client.IRenderHandler;
|
import net.minecraftforge.client.IRenderHandler;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||||
|
@ -30,23 +28,23 @@ public abstract class DDProxyCommon implements IDDProxy {
|
||||||
MinecraftForge.EVENT_BUS.register(ModSounds.class);
|
MinecraftForge.EVENT_BUS.register(ModSounds.class);
|
||||||
MinecraftForge.EVENT_BUS.register(ModBiomes.class);
|
MinecraftForge.EVENT_BUS.register(ModBiomes.class);
|
||||||
|
|
||||||
|
registerTileEntities();
|
||||||
DimDoorDimensions.registerDimensions();
|
DimDoorDimensions.registerDimensions();
|
||||||
|
|
||||||
GameRegistry.registerTileEntity(TileEntityVerticalEntranceRift.class, "TileEntityVerticalEntranceRift"); // TODO: new forge registry system?
|
|
||||||
GameRegistry.registerTileEntity(TileEntityFloatingRift.class, "TileEntityFloatingRift");
|
|
||||||
GameRegistry.registerTileEntity(TileEntityHorizontalEntranceRift.class, "TileEntityHorizontalEntranceRift");
|
|
||||||
|
|
||||||
EntityRegistry.registerModEntity(new ResourceLocation(DimDoors.MODID, "mob_monolith"), EntityMonolith.class, "monolith", 0, DimDoors.instance, 70, 1, true);
|
EntityRegistry.registerModEntity(new ResourceLocation(DimDoors.MODID, "mob_monolith"), EntityMonolith.class, "monolith", 0, DimDoors.instance, 70, 1, true);
|
||||||
EntityRegistry.registerEgg(new ResourceLocation(DimDoors.MODID, "mob_monolith"), 0, 0xffffff);
|
EntityRegistry.registerEgg(new ResourceLocation(DimDoors.MODID, "mob_monolith"), 0, 0xffffff);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInitialization(FMLInitializationEvent event) {
|
public void onInitialization(FMLInitializationEvent event) {
|
||||||
|
|
||||||
SchematicHandler.INSTANCE.loadSchematics();
|
SchematicHandler.INSTANCE.loadSchematics();
|
||||||
DefaultSchematicGenerator.generateDefaultSchematics();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void registerTileEntities() { // TODO: new registry system
|
||||||
|
GameRegistry.registerTileEntity(TileEntityVerticalEntranceRift.class, "TileEntityVerticalEntranceRift"); // TODO: new forge registry system?
|
||||||
|
GameRegistry.registerTileEntity(TileEntityFloatingRift.class, "TileEntityFloatingRift");
|
||||||
|
GameRegistry.registerTileEntity(TileEntityHorizontalEntranceRift.class, "TileEntityHorizontalEntranceRift");
|
||||||
|
}
|
||||||
|
|
||||||
abstract public void setCloudRenderer(WorldProvider provider, IRenderHandler renderer);
|
abstract public void setCloudRenderer(WorldProvider provider, IRenderHandler renderer);
|
||||||
|
|
||||||
|
|
|
@ -1,92 +0,0 @@
|
||||||
package com.zixiken.dimdoors.shared.util;
|
|
||||||
|
|
||||||
import com.zixiken.dimdoors.DimDoors;
|
|
||||||
import com.zixiken.dimdoors.shared.SchematicHandler;
|
|
||||||
import com.zixiken.dimdoors.shared.blocks.BlockFabric;
|
|
||||||
import com.zixiken.dimdoors.shared.blocks.ModBlocks;
|
|
||||||
import com.zixiken.dimdoors.shared.rifts.RiftDestination;
|
|
||||||
import com.zixiken.dimdoors.shared.rifts.TileEntityRift;
|
|
||||||
import com.zixiken.dimdoors.shared.rifts.WeightedRiftDestination;
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.block.BlockDoor;
|
|
||||||
import net.minecraft.block.state.IBlockState;
|
|
||||||
import net.minecraft.init.Blocks;
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Robijnvogel
|
|
||||||
*/
|
|
||||||
public class DefaultSchematicGenerator {
|
|
||||||
public static void generateDefaultSchematics() {
|
|
||||||
for (int pocketSize = 0; pocketSize < 8; pocketSize++) {
|
|
||||||
generateDefaultSchematic("defaultPublic", pocketSize, ModBlocks.FABRIC.getDefaultState().withProperty(BlockFabric.TYPE, BlockFabric.EnumType.ANCIENT), ModBlocks.FABRIC.getDefaultState().withProperty(BlockFabric.TYPE, BlockFabric.EnumType.REALITY), ModBlocks.DIMENSIONAL_DOOR, RiftDestination.PocketExitDestination.builder().build());
|
|
||||||
generateDefaultSchematic("defaultPrivate", pocketSize, ModBlocks.FABRIC.getDefaultState().withProperty(BlockFabric.TYPE, BlockFabric.EnumType.ANCIENT_ALTERED), ModBlocks.FABRIC.getDefaultState().withProperty(BlockFabric.TYPE, BlockFabric.EnumType.ALTERED), ModBlocks.PERSONAL_DIMENSIONAL_DOOR, RiftDestination.PrivatePocketExitDestination.builder().build());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void generateDefaultSchematic(String baseName, int pocketSize, IBlockState outerWallBlockState, IBlockState innerWallBlockState, Block doorBlock, RiftDestination exitDest) {
|
|
||||||
int maxbound = (pocketSize + 1) * 16 - 1;
|
|
||||||
|
|
||||||
Schematic schematic = new Schematic();
|
|
||||||
schematic.version = 1;
|
|
||||||
schematic.author = "Robijnvogel"; //@todo set in build.gradle ${modID}
|
|
||||||
schematic.schematicName = baseName + "_" + pocketSize;
|
|
||||||
schematic.creationDate = System.currentTimeMillis();
|
|
||||||
schematic.requiredMods = new String[1];
|
|
||||||
schematic.requiredMods[0] = DimDoors.MODID;
|
|
||||||
schematic.width = (short) maxbound;
|
|
||||||
schematic.height = (short) maxbound;
|
|
||||||
schematic.length = (short) maxbound;
|
|
||||||
schematic.offset = new int[]{0, 0, 0};
|
|
||||||
|
|
||||||
schematic.paletteMax = 4;
|
|
||||||
schematic.pallette = new ArrayList<>();
|
|
||||||
schematic.pallette.add(Blocks.AIR.getDefaultState());
|
|
||||||
schematic.pallette.add(outerWallBlockState);
|
|
||||||
schematic.pallette.add(innerWallBlockState);
|
|
||||||
schematic.pallette.add(doorBlock.getDefaultState().withProperty(BlockDoor.HALF, BlockDoor.EnumDoorHalf.LOWER)); //bottom
|
|
||||||
schematic.pallette.add(doorBlock.getDefaultState().withProperty(BlockDoor.HALF, BlockDoor.EnumDoorHalf.UPPER)); //top
|
|
||||||
|
|
||||||
schematic.blockData = new int[maxbound][maxbound][maxbound]; //[x][y][z]
|
|
||||||
for (int x = 0; x < maxbound; x++) {
|
|
||||||
for (int y = 0; y < maxbound; y++) {
|
|
||||||
for (int z = 0; z < maxbound; z++) {
|
|
||||||
if (x == 0 || x == maxbound - 1
|
|
||||||
|| y == 0 || y == maxbound - 1
|
|
||||||
|| z == 0 || z == maxbound - 1) {
|
|
||||||
schematic.blockData[x][y][z] = 1; //outer dim wall
|
|
||||||
} else if (MathUtils.withinDistanceOf(new int[]{x, y, z}, 5, new int[]{0, maxbound})) {
|
|
||||||
if (z == 4 && x == (maxbound - 1) / 2 && y > 4 && y < 7) {
|
|
||||||
if (y == 5) {
|
|
||||||
schematic.blockData[x][y][z] = 3; //door bottom
|
|
||||||
} else { // y == 6
|
|
||||||
schematic.blockData[x][y][z] = 4; //door top
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
schematic.blockData[x][y][z] = 2; //inner dim wall
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
schematic.blockData[x][y][z] = 0; //air
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
schematic.tileEntities = new ArrayList<>();
|
|
||||||
TileEntityRift rift = (TileEntityRift) doorBlock.createTileEntity(null, doorBlock.getDefaultState());
|
|
||||||
rift.setSingleDestination(RiftDestination.PocketEntranceDestination.builder()
|
|
||||||
.ifDestinations(MathUtils.listFrom(new WeightedRiftDestination(exitDest, 1, 0)))
|
|
||||||
.build());
|
|
||||||
|
|
||||||
NBTTagCompound tileNBT = rift.serializeNBT();
|
|
||||||
tileNBT.setInteger("x", (maxbound - 1) / 2);
|
|
||||||
tileNBT.setInteger("y", 5);
|
|
||||||
tileNBT.setInteger("z", 4);
|
|
||||||
schematic.tileEntities.add(tileNBT);
|
|
||||||
|
|
||||||
SchematicHandler.INSTANCE.saveSchematic(schematic, schematic.schematicName);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,166 @@
|
||||||
|
package com.zixiken.dimdoors.shared.util;
|
||||||
|
|
||||||
|
import com.zixiken.dimdoors.DimDoors;
|
||||||
|
import com.zixiken.dimdoors.server.DDProxyServer;
|
||||||
|
import com.zixiken.dimdoors.shared.blocks.BlockFabric;
|
||||||
|
import com.zixiken.dimdoors.shared.blocks.ModBlocks;
|
||||||
|
import com.zixiken.dimdoors.shared.rifts.RiftDestination;
|
||||||
|
import com.zixiken.dimdoors.shared.rifts.TileEntityRift;
|
||||||
|
import com.zixiken.dimdoors.shared.rifts.WeightedRiftDestination;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.block.BlockDoor;
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.init.Blocks;
|
||||||
|
import net.minecraft.init.Bootstrap;
|
||||||
|
import net.minecraft.nbt.CompressedStreamTools;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraftforge.event.RegistryEvent;
|
||||||
|
import net.minecraftforge.fml.common.DummyModContainer;
|
||||||
|
import net.minecraftforge.fml.common.Loader;
|
||||||
|
import net.minecraftforge.fml.common.ModContainer;
|
||||||
|
import net.minecraftforge.fml.common.ModMetadata;
|
||||||
|
import net.minecraftforge.registries.GameData;
|
||||||
|
import net.minecraftforge.registries.RegistryManager;
|
||||||
|
|
||||||
|
import java.io.DataOutputStream;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Robijnvogel
|
||||||
|
*/
|
||||||
|
public class PocketSchematicGenerator {
|
||||||
|
|
||||||
|
// Run "gradlew generatePocketSchematics" to generate the pocket schematics
|
||||||
|
@SuppressWarnings("UseOfSystemOutOrSystemErr")
|
||||||
|
public static void main(String... args) throws IOException, NoSuchMethodException, NoSuchFieldException, IllegalAccessException {
|
||||||
|
// Register blocks and tile entities to be able to run this without starting Minecraft
|
||||||
|
Bootstrap.register();
|
||||||
|
ModMetadata md = new ModMetadata();
|
||||||
|
md.modId = DimDoors.MODID;
|
||||||
|
ModContainer mc = new DummyModContainer(md);
|
||||||
|
Loader.instance().setupTestHarness(mc);
|
||||||
|
Loader.instance().setActiveModContainer(mc);
|
||||||
|
ModBlocks.registerBlocks(new RegistryEvent.Register(GameData.BLOCKS, RegistryManager.ACTIVE.getRegistry(GameData.BLOCKS)));
|
||||||
|
new DDProxyServer().registerTileEntities();
|
||||||
|
Loader.instance().setActiveModContainer(null);
|
||||||
|
|
||||||
|
// Parse arguments
|
||||||
|
File schematicDir;
|
||||||
|
if (args.length > 1) {
|
||||||
|
System.err.println("Too many arguments!");
|
||||||
|
return;
|
||||||
|
} else if (args.length == 1) {
|
||||||
|
schematicDir = new File(args[0]);
|
||||||
|
if (!schematicDir.isDirectory()) {
|
||||||
|
System.err.print("The directory " + args[0] + " couldn't be found!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
schematicDir = new File("schematics/");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Generate the schematics
|
||||||
|
List<Schematic> schematics = generatePocketSchematics(8);
|
||||||
|
|
||||||
|
// Save the schematics
|
||||||
|
boolean isPublic = true;
|
||||||
|
for (Schematic schematic : schematics) {
|
||||||
|
NBTTagCompound schematicNBT = Schematic.saveToNBT(schematic);
|
||||||
|
File saveFile = new File(schematicDir, (isPublic ? "public/" : "private/") + schematic.schematicName + ".schem");
|
||||||
|
saveFile.getParentFile().mkdirs();
|
||||||
|
DataOutputStream schematicDataStream = new DataOutputStream(new FileOutputStream(saveFile));
|
||||||
|
CompressedStreamTools.writeCompressed(schematicNBT, schematicDataStream);
|
||||||
|
schematicDataStream.flush();
|
||||||
|
schematicDataStream.close();
|
||||||
|
isPublic = !isPublic;
|
||||||
|
}
|
||||||
|
// TODO: also generate JSON files
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<Schematic> generatePocketSchematics(int maxPocketSize) {
|
||||||
|
List<Schematic> schematics = new ArrayList<>();
|
||||||
|
for (int pocketSize = 0; pocketSize < maxPocketSize; pocketSize++) {
|
||||||
|
schematics.add(generatePocketSchematic(
|
||||||
|
"public_pocket", // base name
|
||||||
|
pocketSize, // size
|
||||||
|
ModBlocks.FABRIC.getDefaultState().withProperty(BlockFabric.TYPE, BlockFabric.EnumType.ANCIENT), // outer wall
|
||||||
|
ModBlocks.FABRIC.getDefaultState().withProperty(BlockFabric.TYPE, BlockFabric.EnumType.REALITY), // inner wall
|
||||||
|
ModBlocks.DIMENSIONAL_DOOR, // door
|
||||||
|
RiftDestination.PocketExitDestination.builder().build())); // exit rift destination
|
||||||
|
schematics.add(generatePocketSchematic(
|
||||||
|
"private_pocket", // base name
|
||||||
|
pocketSize, // size
|
||||||
|
ModBlocks.FABRIC.getDefaultState().withProperty(BlockFabric.TYPE, BlockFabric.EnumType.ANCIENT_ALTERED), // outer wall
|
||||||
|
ModBlocks.FABRIC.getDefaultState().withProperty(BlockFabric.TYPE, BlockFabric.EnumType.ALTERED), // inner wall
|
||||||
|
ModBlocks.PERSONAL_DIMENSIONAL_DOOR, // door
|
||||||
|
RiftDestination.PrivatePocketExitDestination.builder().build())); // exit rift destination
|
||||||
|
}
|
||||||
|
return schematics;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Schematic generatePocketSchematic(String baseName, int pocketSize, IBlockState outerWallBlockState, IBlockState innerWallBlockState, Block doorBlock, RiftDestination exitDest) {
|
||||||
|
int size = (pocketSize + 1) * 16 - 1; // -1 so that the door can be centered
|
||||||
|
|
||||||
|
// Set schematic info
|
||||||
|
Schematic schematic = new Schematic();
|
||||||
|
schematic.version = 1;
|
||||||
|
schematic.author = "Robijnvogel"; //@todo set in build.gradle ${modID}
|
||||||
|
schematic.schematicName = baseName + "_" + pocketSize;
|
||||||
|
schematic.creationDate = System.currentTimeMillis();
|
||||||
|
schematic.requiredMods = new String[1];
|
||||||
|
schematic.requiredMods[0] = DimDoors.MODID;
|
||||||
|
schematic.width = (short) size;
|
||||||
|
schematic.height = (short) size;
|
||||||
|
schematic.length = (short) size;
|
||||||
|
schematic.offset = new int[]{0, 0, 0}; // TODO: center pockets
|
||||||
|
|
||||||
|
// Generate the pallette
|
||||||
|
schematic.paletteMax = 4;
|
||||||
|
schematic.pallette = new ArrayList<>();
|
||||||
|
schematic.pallette.add(Blocks.AIR.getDefaultState());
|
||||||
|
schematic.pallette.add(outerWallBlockState);
|
||||||
|
schematic.pallette.add(innerWallBlockState);
|
||||||
|
schematic.pallette.add(doorBlock.getDefaultState().withProperty(BlockDoor.HALF, BlockDoor.EnumDoorHalf.LOWER)); //bottom
|
||||||
|
schematic.pallette.add(doorBlock.getDefaultState().withProperty(BlockDoor.HALF, BlockDoor.EnumDoorHalf.UPPER)); //top
|
||||||
|
|
||||||
|
// Set block data
|
||||||
|
schematic.blockData = new int[size][size][size]; //[x][y][z]
|
||||||
|
for (int x = 0; x < size; x++) {
|
||||||
|
for (int y = 0; y < size; y++) {
|
||||||
|
for (int z = 0; z < size; z++) {
|
||||||
|
int layer = Collections.min(Arrays.asList(x, y, z, size - x, size - y, size - z));
|
||||||
|
if (layer == 0) {
|
||||||
|
schematic.blockData[x][y][z] = 1; // outer wall
|
||||||
|
} else if (layer < 5) {
|
||||||
|
schematic.blockData[x][y][z] = 2; // inner wall
|
||||||
|
} else {
|
||||||
|
schematic.blockData[x][y][z] = 0; // air
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
schematic.blockData[(size - 1)/2][5][4] = 3; // door bottom
|
||||||
|
schematic.blockData[(size - 1)/2][6][4] = 4; // door top
|
||||||
|
|
||||||
|
// Generate the rift TileEntities
|
||||||
|
schematic.tileEntities = new ArrayList<>();
|
||||||
|
TileEntityRift rift = (TileEntityRift) doorBlock.createTileEntity(null, doorBlock.getDefaultState());
|
||||||
|
rift.setSingleDestination(RiftDestination.PocketEntranceDestination.builder()
|
||||||
|
.ifDestinations(MathUtils.listFrom(new WeightedRiftDestination(exitDest, 1, 0)))
|
||||||
|
.build());
|
||||||
|
NBTTagCompound tileNBT = rift.serializeNBT();
|
||||||
|
tileNBT.setInteger("x", (size - 1) / 2);
|
||||||
|
tileNBT.setInteger("y", 5);
|
||||||
|
tileNBT.setInteger("z", 4);
|
||||||
|
schematic.tileEntities.add(tileNBT);
|
||||||
|
|
||||||
|
return schematic;
|
||||||
|
}
|
||||||
|
}
|
|
@ -28,7 +28,7 @@ public class TeleportUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Entity teleport(Entity entity, BlockPos pos, float yaw, float pitch) {
|
public static Entity teleport(Entity entity, BlockPos pos, float yaw, float pitch) {
|
||||||
return teleport(entity, WorldUtils.getDim(entity.getEntityWorld()), pos.getX(), pos.getY(), pos.getZ(), yaw, pitch);
|
return teleport(entity, WorldUtils.getDim(entity.getEntityWorld()), pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5, yaw, pitch);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Entity teleport(Entity entity, double x, double y, double z, float yaw, float pitch) {
|
public static Entity teleport(Entity entity, double x, double y, double z, float yaw, float pitch) {
|
||||||
|
|
|
@ -3,56 +3,56 @@
|
||||||
"pocketType" : 0,
|
"pocketType" : 0,
|
||||||
"variations": [
|
"variations": [
|
||||||
{
|
{
|
||||||
"variantName": "defaultPrivate_0",
|
"variantName": "private_pocket_0",
|
||||||
"size": 0,
|
"size": 0,
|
||||||
"minDepth": 0,
|
"minDepth": 0,
|
||||||
"maxDepth": 0,
|
"maxDepth": 0,
|
||||||
"weights": [100]
|
"weights": [100]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"variantName": "defaultPrivate_1",
|
"variantName": "private_pocket_1",
|
||||||
"size": 1,
|
"size": 1,
|
||||||
"minDepth": 0,
|
"minDepth": 0,
|
||||||
"maxDepth": 0,
|
"maxDepth": 0,
|
||||||
"weights": [100]
|
"weights": [100]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"variantName": "defaultPrivate_2",
|
"variantName": "private_pocket_2",
|
||||||
"size": 2,
|
"size": 2,
|
||||||
"minDepth": 0,
|
"minDepth": 0,
|
||||||
"maxDepth": 0,
|
"maxDepth": 0,
|
||||||
"weights": [100]
|
"weights": [100]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"variantName": "defaultPrivate_3",
|
"variantName": "private_pocket_3",
|
||||||
"size": 3,
|
"size": 3,
|
||||||
"minDepth": 0,
|
"minDepth": 0,
|
||||||
"maxDepth": 0,
|
"maxDepth": 0,
|
||||||
"weights": [100]
|
"weights": [100]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"variantName": "defaultPrivate_4",
|
"variantName": "private_pocket_4",
|
||||||
"size": 4,
|
"size": 4,
|
||||||
"minDepth": 0,
|
"minDepth": 0,
|
||||||
"maxDepth": 0,
|
"maxDepth": 0,
|
||||||
"weights": [100]
|
"weights": [100]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"variantName": "defaultPrivate_5",
|
"variantName": "private_pocket_5",
|
||||||
"size": 5,
|
"size": 5,
|
||||||
"minDepth": 0,
|
"minDepth": 0,
|
||||||
"maxDepth": 0,
|
"maxDepth": 0,
|
||||||
"weights": [100]
|
"weights": [100]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"variantName": "defaultPrivate_6",
|
"variantName": "private_pocket_6",
|
||||||
"size": 6,
|
"size": 6,
|
||||||
"minDepth": 0,
|
"minDepth": 0,
|
||||||
"maxDepth": 0,
|
"maxDepth": 0,
|
||||||
"weights": [100]
|
"weights": [100]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"variantName": "defaultPrivate_7",
|
"variantName": "private_pocket_7",
|
||||||
"size": 7,
|
"size": 7,
|
||||||
"minDepth": 0,
|
"minDepth": 0,
|
||||||
"maxDepth": 0,
|
"maxDepth": 0,
|
||||||
|
|
|
@ -3,56 +3,56 @@
|
||||||
"pocketType" : 1,
|
"pocketType" : 1,
|
||||||
"variations": [
|
"variations": [
|
||||||
{
|
{
|
||||||
"variantName": "defaultPublic_0",
|
"variantName": "public_pocket_0",
|
||||||
"size": 0,
|
"size": 0,
|
||||||
"minDepth": 0,
|
"minDepth": 0,
|
||||||
"maxDepth": 0,
|
"maxDepth": 0,
|
||||||
"weights": [100]
|
"weights": [100]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"variantName": "defaultPublic_1",
|
"variantName": "public_pocket_1",
|
||||||
"size": 1,
|
"size": 1,
|
||||||
"minDepth": 0,
|
"minDepth": 0,
|
||||||
"maxDepth": 0,
|
"maxDepth": 0,
|
||||||
"weights": [100]
|
"weights": [100]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"variantName": "defaultPublic_2",
|
"variantName": "public_pocket_2",
|
||||||
"size": 2,
|
"size": 2,
|
||||||
"minDepth": 0,
|
"minDepth": 0,
|
||||||
"maxDepth": 0,
|
"maxDepth": 0,
|
||||||
"weights": [100]
|
"weights": [100]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"variantName": "defaultPublic_3",
|
"variantName": "public_pocket_3",
|
||||||
"size": 3,
|
"size": 3,
|
||||||
"minDepth": 0,
|
"minDepth": 0,
|
||||||
"maxDepth": 0,
|
"maxDepth": 0,
|
||||||
"weights": [100]
|
"weights": [100]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"variantName": "defaultPublic_4",
|
"variantName": "public_pocket_4",
|
||||||
"size": 4,
|
"size": 4,
|
||||||
"minDepth": 0,
|
"minDepth": 0,
|
||||||
"maxDepth": 0,
|
"maxDepth": 0,
|
||||||
"weights": [100]
|
"weights": [100]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"variantName": "defaultPublic_5",
|
"variantName": "public_pocket_5",
|
||||||
"size": 5,
|
"size": 5,
|
||||||
"minDepth": 0,
|
"minDepth": 0,
|
||||||
"maxDepth": 0,
|
"maxDepth": 0,
|
||||||
"weights": [100]
|
"weights": [100]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"variantName": "defaultPublic_6",
|
"variantName": "public_pocket_6",
|
||||||
"size": 6,
|
"size": 6,
|
||||||
"minDepth": 0,
|
"minDepth": 0,
|
||||||
"maxDepth": 0,
|
"maxDepth": 0,
|
||||||
"weights": [100]
|
"weights": [100]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"variantName": "defaultPublic_7",
|
"variantName": "public_pocket_7",
|
||||||
"size": 7,
|
"size": 7,
|
||||||
"minDepth": 0,
|
"minDepth": 0,
|
||||||
"maxDepth": 0,
|
"maxDepth": 0,
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in a new issue