This commit is contained in:
Runemoro 2017-12-06 23:54:43 -05:00
parent 55dd7ef607
commit 4f911fa0db
9 changed files with 264 additions and 379 deletions

View file

@ -3,7 +3,7 @@ notifications:
email: false
before_install: chmod +x gradlew
install: "./gradlew setupCIWorkspace -s"
script: "./gradlew build -s && find ."
script: "./gradlew build -s && find $HOME"
jdk:
- oraclejdk8
before_cache:
@ -17,7 +17,7 @@ deploy:
provider: releases
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=
file: "./build/libs/dimdoors-1.12.2-3.0.0-a4.jar"
file: "$HOME/build/libs/dimdoors-1.12.2-3.0.0-a4.jar"
on:
repo: DimensionalDevelopment/DimDoors
branch: 1.12-WIP

View file

@ -7,6 +7,12 @@ buildscript {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
}
}
plugins {
id 'io.franzbecker.gradle-lombok' version '1.11'
id 'java'
}
apply plugin: 'net.minecraftforge.gradle.forge'
//Only edit below this line, the above code adds and enables the nessasary things for Forge to be setup.

View file

@ -14,6 +14,8 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import lombok.Getter;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
@ -28,10 +30,10 @@ public class PocketRegistry {
// Privates
//Need to be saved:
private int gridSize; //determines how much pockets in their dimension are spaced
private int maxPocketSize;
private int privatePocketSize;
private int publicPocketSize;
@Getter private int gridSize; //determines how much pockets in their dimension are spaced
@Getter private int maxPocketSize;
@Getter private int privatePocketSize;
@Getter private int publicPocketSize;
private final Map<EnumPocketType, Integer> nextUnusedIDs;
private final Map<String, Integer> privatePockets; //maps the UUID's of players to their private pocket's ID (ID for EnumPocketType.PRIVATE in pocketLists)
private final Map<EnumPocketType, Map<Integer, Pocket>> pocketLists;
@ -51,22 +53,6 @@ public class PocketRegistry {
pocketListsPerDepth = new ArrayList<>();
}
public int getGridSize() {
return gridSize;
}
public int getMaxPocketSize() {
return maxPocketSize;
}
public int getPrivatePocketSize() {
return privatePocketSize;
}
public int getPublicPocketSize() {
return publicPocketSize;
}
public void reset() {
for (EnumPocketType pocketType : EnumPocketType.values()) {
nextUnusedIDs.put(pocketType, 0);
@ -262,60 +248,6 @@ public class PocketRegistry {
return new Location(dimID, x, y, z);
}
/*
private int getSimpleX(int ID) {
//@todo check for smaller than 0
if (ID == 0) {
return 0;
} else {
int baseX = getSimpleX(ID - 1);
int group = getDiffToPreviousGroup(ID);
if (group % 2 == 0) {//even
return baseX;
} else { //uneven
if (group % 4 == 1) { //power of four + 1
return baseX + 1;
} else { //power of four - 1
return baseX - 1;
}
}
}
}
private int getSimpleZ(int ID) {
if (ID == 0) {
return 0;
} else {
int baseZ = getSimpleZ(ID - 1);
int group = getDiffToPreviousGroup(ID);
if (group % 2 == 1) {//uneven
return baseZ;
} else { //uneven
if (group % 4 == 0) { //power of four
return baseZ - 1;
} else { //"4-uneven"
return baseZ + 1;
}
}
}
}
private static int getDiffToPreviousGroup(int ID) {
int temp = 0;
int group;
for (group = 1; temp <= ID; group++) {
temp += group * 2;
}
if (temp - group < ID) {
group *= 2;
} else {
group = (group * 2) - 1;
}
return group;
}
*/
public int getPocketIDFromCoords(Location location) {
final int dimID = location.getDimensionID();
if (DimDoorDimensions.isPocketDimensionID(dimID)) {

View file

@ -13,6 +13,10 @@ import com.zixiken.dimdoors.shared.tileentities.TileEntityDimDoor;
import com.zixiken.dimdoors.shared.util.Location;
import java.util.ArrayList;
import java.util.List;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;
import net.minecraft.block.state.IBlockState;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
@ -26,22 +30,22 @@ import net.minecraft.world.WorldServer;
public class PocketTemplate { //there is exactly one pocket placer for each different schematic that is loaded into the game (a Json might load several schematics though)
//generation parameters
private Schematic schematic;
private final int size;
private final EnumPocketType typeID;
@Getter @Setter(value = AccessLevel.PACKAGE) private Schematic schematic; // TODO: access level
@Getter private final int size;
@Getter private final EnumPocketType typeID;
//selection parameters
private final String groupName;
private final String variantName;
@Getter private final String groupName;
@Getter private final String name;
private String variantType;
private final int minDepth;
private final int maxDepth;
@Getter private final int minDepth;
@Getter private final int maxDepth;
private final int[] weights; //weights for chanced generation of dungeons per depth level | weights[0] is the weight for depth "minDepth"
//this class should contain the actual schematic info, as well as some of the Json info (placement of Rifts and stuff)
public PocketTemplate(String groupName, String variantName, Schematic schematic, int size,
public PocketTemplate(String groupName, String name, Schematic schematic, int size,
EnumPocketType typeID, int minDepth, int maxDepth, int[] weights) {
this.groupName = groupName;
this.variantName = variantName;
this.name = name;
this.weights = weights; //chance that this Pocket will get generated
this.minDepth = minDepth; //pocket will only be generated from this Pocket-depth
this.maxDepth = maxDepth; //to this pocket depth
@ -50,21 +54,9 @@ public class PocketTemplate { //there is exactly one pocket placer for each diff
this.typeID = typeID;
}
public PocketTemplate(String groupName, String variantName, int size,
public PocketTemplate(String groupName, String name, int size,
EnumPocketType typeID, int minDepth, int maxDepth, int[] weights) {
this(groupName, variantName, null, size, typeID, minDepth, maxDepth, weights);
}
int getSize() {
return size;
}
int getMinDepth() {
return minDepth;
}
int getMaxDepth() {
return maxDepth;
this(groupName, name, null, size, typeID, minDepth, maxDepth, weights);
}
int getWeight(int depth) {
@ -75,26 +67,6 @@ public class PocketTemplate { //there is exactly one pocket placer for each diff
return weights[weights.length - 1]; // return last weight
}
String getGroupName() {
return groupName;
}
public String getName() {
return variantName;
}
public String getType() {
return variantType;
}
Schematic getSchematic() {
return schematic;
}
void setSchematic(Schematic schematic) {
this.schematic = schematic;
}
//@todo make sure that the "pocketID" parameter gets used, or remove it.
public Pocket place(int shortenedX, int yBase, int shortenedZ, int gridSize, int dimID, int pocketID, int depth, EnumPocketType pocketTypeID, Location depthZeroLocation) { //returns the riftID of the entrance DimDoor
int xBase = shortenedX * gridSize * 16;
@ -103,7 +75,7 @@ public class PocketTemplate { //there is exactly one pocket placer for each diff
DimDoors.log(getClass(), "Name of new pocket schematic is " + schematic.getSchematicName());
if (schematic == null) {
DimDoors.log(getClass(), "The schematic for variant " + variantName + " somehow didn't load correctly despite all precautions.");
DimDoors.log(getClass(), "The schematic for variant " + name + " somehow didn't load correctly despite all precautions.");
return null;
}
//@todo make sure that the door tile entities get registered!

View file

@ -0,0 +1,86 @@
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 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 net.minecraft.tileentity.TileEntity;
import java.util.ArrayList;
/**
*
* @author Robijnvogel
*/
public class DefaultSchematicGenerator {
public static void tempGenerateDefaultSchematics() {
for (int pocketSize = 0; pocketSize < 8; pocketSize++) {
generateDefaultSchematic("defaultPublic", pocketSize, ModBlocks.FABRIC.getDefaultState().withProperty(BlockFabric.TYPE, BlockFabric.EnumType.REALITY), ModBlocks.DIMENSIONAL_DOOR);
generateDefaultSchematic("defaultPrivate", pocketSize, ModBlocks.FABRIC.getDefaultState().withProperty(BlockFabric.TYPE, BlockFabric.EnumType.ALTERED), ModBlocks.PERSONAL_DIMENSIONAL_DOOR);
}
}
private static void generateDefaultSchematic(String baseName, int pocketSize, IBlockState innerWallBlockState, Block doorBlock) {
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(ModBlocks.FABRIC.getDefaultState().withProperty(BlockFabric.TYPE, BlockFabric.EnumType.ANCIENT));
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<>();
TileEntity tileEntity = doorBlock.createTileEntity(DimDoors.proxy.getDefWorld(), doorBlock.getDefaultState());
NBTTagCompound tileNBT = tileEntity.serializeNBT();
tileNBT.setInteger("x", (maxbound - 1) / 2);
tileNBT.setInteger("y", 6);
tileNBT.setInteger("z", 4);
schematic.tileEntities.add(tileNBT);
SchematicHandler.INSTANCE.saveSchematic(schematic, schematic.schematicName);
}
}

View file

@ -3,6 +3,8 @@ package com.zixiken.dimdoors.shared.util;
import com.zixiken.dimdoors.DimDoors;
import java.io.Serializable;
import java.util.Objects;
import lombok.Getter;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.nbt.NBTTagCompound;
@ -17,8 +19,8 @@ import net.minecraft.world.WorldServer;
*/
public class Location implements Serializable {
private int dimensionID;
private BlockPos pos;
@Getter private int dimensionID;
@Getter private BlockPos pos;
public Location(World world, BlockPos pos) {
this(world.provider.getDimension(), pos);
@ -45,18 +47,10 @@ public class Location implements Serializable {
return getWorld().getBlockState(getPos());
}
public BlockPos getPos() {
return pos;
}
public WorldServer getWorld() {
return DimDoors.proxy.getWorldServer(dimensionID);
}
public int getDimensionID() {
return dimensionID;
}
public static Location getLocation(TileEntity tileEntity) {
World world = tileEntity.getWorld();
BlockPos blockPos = tileEntity.getPos();

View file

@ -15,6 +15,7 @@ import java.util.Map.Entry;
import com.zixiken.dimdoors.shared.SchematicHandler;
import com.zixiken.dimdoors.shared.blocks.BlockFabric;
import com.zixiken.dimdoors.shared.blocks.ModBlocks;
import lombok.Getter;
import net.minecraft.block.Block;
import net.minecraft.block.BlockDoor;
import net.minecraft.block.properties.IProperty;
@ -34,38 +35,24 @@ import net.minecraftforge.fml.common.registry.ForgeRegistries;
*/
public class Schematic {
private static final String[] OLDDIMDOORBLOCKNAMES = {
"Dimensional Door",
"Fabric of Reality",
"transientDoor", //only used in the two old Overworld gateway (worldgen) structures
"Warp Door"};
private static final String[] NEWDIMDOORBLOCKNAMES = {
"dimensional_door",
"fabric", //[type=fabric] is the default blockstate
"transient_dimensional_door",
"warp_dimensional_door"};
int version = Integer.parseInt("1"); //@todo set in build.gradle ${spongeSchematicVersion}
String author = "DimDoors"; //@todo set in build.gradle ${modID}
String schematicName = "Unknown";
long creationDate;
String[] requiredMods = {};
short width;
short height;
short length;
int[] offset = {0, 0, 0};
int paletteMax;
List<IBlockState> pallette = new ArrayList<>();
int[][][] blockData; //[x][y][z]
List<NBTTagCompound> tileEntities = new ArrayList<>();
private Schematic() {
}
// TODO: make public?
@Getter int version = Integer.parseInt("1"); //@todo set in build.gradle ${spongeSchematicVersion}
@Getter String author = "DimDoors"; //@todo set in build.gradle ${modID}
@Getter String schematicName = "Unknown";
@Getter long creationDate;
@Getter String[] requiredMods = {};
@Getter short width;
@Getter short height;
@Getter short length;
@Getter int[] offset = {0, 0, 0};
@Getter int paletteMax;
@Getter List<IBlockState> pallette = new ArrayList<>();
@Getter int[][][] blockData; //[x][y][z]
@Getter List<NBTTagCompound> tileEntities = new ArrayList<>();
public static Schematic loadFromNBT(NBTTagCompound nbt, String parName) {
if (!nbt.hasKey("Version")) {
return loadOldDimDoorSchematicFromNBT(nbt, parName);
return SchematicConverter.loadOldDimDoorSchematicFromNBT(nbt, parName);
}
Schematic schematic = new Schematic();
@ -206,7 +193,7 @@ public class Schematic {
return nbt;
}
private static IBlockState getBlockStateWithProperties(Block block, String[] properties) {
static IBlockState getBlockStateWithProperties(Block block, String[] properties) {
Map<String, String> propertyAndBlockStringsMap = new HashMap<>();
for (String property : properties) {
String[] propertyAndBlockStrings = property.split("=");
@ -258,217 +245,4 @@ public class Schematic {
return totalString;
}
public int getVersion() {
return version;
}
public String getAuthor() {
return author;
}
public String getSchematicName() {
return schematicName;
}
public long getCreationDate() {
return creationDate;
}
public String[] getRequiredMods() {
return requiredMods;
}
public short getWidth() {
return width;
}
public short getHeight() {
return height;
}
public short getLength() {
return length;
}
public int[] getOffset() {
return offset;
}
public int getPaletteMax() {
return paletteMax;
}
public List<IBlockState> getPallette() {
return pallette;
}
public int[][][] getBlockData() {
return blockData;
}
public List<NBTTagCompound> getTileEntities() {
return tileEntities;
}
public static Schematic loadOldDimDoorSchematicFromNBT(NBTTagCompound nbt, String parName) { //@todo, maybe make this a separate class, so values can be final so they HAVE TO be set in a newly designed constructor?
Schematic schematic = new Schematic();
//schematic.version = 1; //already the default value
//schematic.author = "DimDoors"; //already the default value
schematic.schematicName = parName.equals("") ? "Auto-converted-DimDoors-for-MC-1.7.10-schematic" : parName;
schematic.creationDate = System.currentTimeMillis();
schematic.requiredMods = new String[]{DimDoors.MODID};
schematic.width = nbt.getShort("Width");
schematic.height = nbt.getShort("Height");
schematic.length = nbt.getShort("Length");
//schematic.offset = new int[]{0, 0, 0}; //already the default value
NBTTagList paletteNBT = (NBTTagList) nbt.getTag("Palette");
for (int i = 0; i < paletteNBT.tagCount(); i++) {
//DimDoors.log(Schematic.class, "reading pallete from schematic... i = " + i);
String blockString = paletteNBT.getStringTagAt(i);
boolean isAncientFabric = false;
if (blockString.startsWith("dimdoors")) {
String dimdoorsBlockName = blockString.split(":")[1];
if (dimdoorsBlockName.equals("Fabric of RealityPerm")) { //only special case, because this is now another state of another block
isAncientFabric = true;
} else {
dimdoorsBlockName = convertOldDimDoorsBlockNameToNewDimDoorsBlockName(dimdoorsBlockName);
blockString = "dimdoors:" + dimdoorsBlockName;
}
}
IBlockState blockstate;
if (!isAncientFabric) {
Block block = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(blockString));
blockstate = block.getDefaultState();
} else {
Block block = ForgeRegistries.BLOCKS.getValue(new ResourceLocation("dimdoors:FABRIC"));
blockstate = getBlockStateWithProperties(block, new String[]{"type=ancient"});
}
schematic.pallette.add(blockstate);
}
byte[] blockIntArray = nbt.getByteArray("Blocks");
byte[] dataIntArray = nbt.getByteArray("Data");
schematic.blockData = new int[schematic.width][schematic.height][schematic.length];
for (int x = 0; x < schematic.width; x++) {
for (int y = 0; y < schematic.height; y++) {
for (int z = 0; z < schematic.length; z++) {
int blockInt = blockIntArray[x + z * schematic.width + y * schematic.width * schematic.length]; //according to the documentation on https://github.com/SpongePowered/Schematic-Specification/blob/master/versions/schematic-1.md
int metadata = dataIntArray[x + z * schematic.width + y * schematic.width * schematic.length]; //according to the documentation on https://github.com/SpongePowered/Schematic-Specification/blob/master/versions/schematic-1.md
IBlockState baseState = schematic.pallette.get(blockInt); //this is the default blockstate except for ancient fabric
if (baseState == baseState.getBlock().getDefaultState()) { //should only be false if {@code baseState} is ancient fabric
IBlockState additionalState = baseState.getBlock().getStateFromMeta(metadata); // TODO: this was getStateFromMeta(metadata), but that method got deprecated and just calls getDefaultState(). Is this right?
if (schematic.pallette.contains(additionalState)) { //check whether or not this blockstate is already in the list
blockInt = schematic.pallette.indexOf(additionalState);
} else {
schematic.pallette.add(additionalState);
DimDoors.log(Schematic.class, "New blockstate detected. Original blockInt = " + blockInt + " and baseState is " + baseState);
blockInt = schematic.pallette.size() - 1;
}
} else { //if this is ancient fabric
//DimDoors.log(Schematic.class, "Non-default blockstate in palette detected. Original blockInt = " + blockInt + " and baseState is " + baseState.toString()); //@todo should only print a line on load of ancient fabric
blockInt = schematic.pallette.indexOf(baseState);
}
schematic.blockData[x][y][z] = blockInt;
}
}
}
schematic.paletteMax = schematic.pallette.size() - 1;
NBTTagList tileEntitiesTagList = (NBTTagList) nbt.getTag("TileEntities");
for (int i = 0; i < tileEntitiesTagList.tagCount(); i++) {
NBTTagCompound tileEntityTagCompound = tileEntitiesTagList.getCompoundTagAt(i);
schematic.tileEntities.add(tileEntityTagCompound);
}
return schematic;
}
private static String convertOldDimDoorsBlockNameToNewDimDoorsBlockName(String dimdoorsBlockName) {
if (OLDDIMDOORBLOCKNAMES.length != NEWDIMDOORBLOCKNAMES.length) {
DimDoors.warn(Schematic.class, "The array of old DimDoors block names somehow isn't the same length as the array of new names, therefore the dimdoors blocks in this schematic will not be loaded. This is a bug in the DimDoors mod itself.");
return null;
}
int i = 0;
for (; i < OLDDIMDOORBLOCKNAMES.length; i++) {
if (OLDDIMDOORBLOCKNAMES[i].equals(dimdoorsBlockName)) {
return NEWDIMDOORBLOCKNAMES[i];
} else {
if (i == OLDDIMDOORBLOCKNAMES.length - 1) {
DimDoors.warn(Schematic.class, dimdoorsBlockName + " as an old dimdoors block name is unknown.");
}
}
}
return null;
}
public static void tempGenerateDefaultSchematics() {
for (int pocketSize = 0; pocketSize < 8; pocketSize++) {
generateDefaultSchematic("defaultPublic", pocketSize, ModBlocks.FABRIC.getDefaultState().withProperty(BlockFabric.TYPE, BlockFabric.EnumType.REALITY), ModBlocks.DIMENSIONAL_DOOR);
generateDefaultSchematic("defaultPrivate", pocketSize, ModBlocks.FABRIC.getDefaultState().withProperty(BlockFabric.TYPE, BlockFabric.EnumType.ALTERED), ModBlocks.PERSONAL_DIMENSIONAL_DOOR);
}
}
private static void generateDefaultSchematic(String baseName, int pocketSize, IBlockState innerWallBlockState, Block doorBlock) {
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(ModBlocks.FABRIC.getDefaultState().withProperty(BlockFabric.TYPE, BlockFabric.EnumType.ANCIENT));
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<>();
TileEntity tileEntity = doorBlock.createTileEntity(DimDoors.proxy.getDefWorld(), doorBlock.getDefaultState());
NBTTagCompound tileNBT = tileEntity.serializeNBT();
tileNBT.setInteger("x", (maxbound - 1) / 2);
tileNBT.setInteger("y", 6);
tileNBT.setInteger("z", 4);
schematic.tileEntities.add(tileNBT);
SchematicHandler.INSTANCE.saveSchematic(schematic, schematic.schematicName);
}
}

View file

@ -0,0 +1,123 @@
package com.zixiken.dimdoors.shared.util;
import com.zixiken.dimdoors.DimDoors;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.common.registry.ForgeRegistries;
/**
*
* @author Robijnvogel
*/
public class SchematicConverter {
private static final String[] OLDDIMDOORBLOCKNAMES = {
"Dimensional Door",
"Fabric of Reality",
"transientDoor", //only used in the two old Overworld gateway (worldgen) structures
"Warp Door"};
private static final String[] NEWDIMDOORBLOCKNAMES = {
"dimensional_door",
"fabric", //[type=fabric] is the default blockstate
"transient_dimensional_door",
"warp_dimensional_door"};
public static Schematic loadOldDimDoorSchematicFromNBT(NBTTagCompound nbt, String parName) { //@todo, maybe make this a separate class, so values can be final so they HAVE TO be set in a newly designed constructor?
Schematic schematic = new Schematic();
//schematic.version = 1; //already the default value
//schematic.author = "DimDoors"; //already the default value
schematic.schematicName = parName.equals("") ? "Auto-converted-DimDoors-for-MC-1.7.10-schematic" : parName;
schematic.creationDate = System.currentTimeMillis();
schematic.requiredMods = new String[]{DimDoors.MODID};
schematic.width = nbt.getShort("Width");
schematic.height = nbt.getShort("Height");
schematic.length = nbt.getShort("Length");
//schematic.offset = new int[]{0, 0, 0}; //already the default value
NBTTagList paletteNBT = (NBTTagList) nbt.getTag("Palette");
for (int i = 0; i < paletteNBT.tagCount(); i++) {
//DimDoors.log(Schematic.class, "reading pallete from schematic... i = " + i);
String blockString = paletteNBT.getStringTagAt(i);
boolean isAncientFabric = false;
if (blockString.startsWith("dimdoors")) {
String dimdoorsBlockName = blockString.split(":")[1];
if (dimdoorsBlockName.equals("Fabric of RealityPerm")) { //only special case, because this is now another state of another block
isAncientFabric = true;
} else {
dimdoorsBlockName = convertOldDimDoorsBlockNameToNewDimDoorsBlockName(dimdoorsBlockName);
blockString = "dimdoors:" + dimdoorsBlockName;
}
}
IBlockState blockstate;
if (!isAncientFabric) {
Block block = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(blockString));
blockstate = block.getDefaultState();
} else {
Block block = ForgeRegistries.BLOCKS.getValue(new ResourceLocation("dimdoors:FABRIC"));
blockstate = Schematic.getBlockStateWithProperties(block, new String[]{"type=ancient"});
}
schematic.pallette.add(blockstate);
}
byte[] blockIntArray = nbt.getByteArray("Blocks");
byte[] dataIntArray = nbt.getByteArray("Data");
schematic.blockData = new int[schematic.width][schematic.height][schematic.length];
for (int x = 0; x < schematic.width; x++) {
for (int y = 0; y < schematic.height; y++) {
for (int z = 0; z < schematic.length; z++) {
int blockInt = blockIntArray[x + z * schematic.width + y * schematic.width * schematic.length]; //according to the documentation on https://github.com/SpongePowered/Schematic-Specification/blob/master/versions/schematic-1.md
int metadata = dataIntArray[x + z * schematic.width + y * schematic.width * schematic.length]; //according to the documentation on https://github.com/SpongePowered/Schematic-Specification/blob/master/versions/schematic-1.md
IBlockState baseState = schematic.pallette.get(blockInt); //this is the default blockstate except for ancient fabric
if (baseState == baseState.getBlock().getDefaultState()) { //should only be false if {@code baseState} is ancient fabric
IBlockState additionalState = baseState.getBlock().getStateFromMeta(metadata); // TODO: this was getStateFromMeta(metadata), but that method got deprecated and just calls getDefaultState(). Is this right?
if (schematic.pallette.contains(additionalState)) { //check whether or not this blockstate is already in the list
blockInt = schematic.pallette.indexOf(additionalState);
} else {
schematic.pallette.add(additionalState);
DimDoors.log(Schematic.class, "New blockstate detected. Original blockInt = " + blockInt + " and baseState is " + baseState);
blockInt = schematic.pallette.size() - 1;
}
} else { //if this is ancient fabric
//DimDoors.log(Schematic.class, "Non-default blockstate in palette detected. Original blockInt = " + blockInt + " and baseState is " + baseState.toString()); //@todo should only print a line on load of ancient fabric
blockInt = schematic.pallette.indexOf(baseState);
}
schematic.blockData[x][y][z] = blockInt;
}
}
}
schematic.paletteMax = schematic.pallette.size() - 1;
NBTTagList tileEntitiesTagList = (NBTTagList) nbt.getTag("TileEntities");
for (int i = 0; i < tileEntitiesTagList.tagCount(); i++) {
NBTTagCompound tileEntityTagCompound = tileEntitiesTagList.getCompoundTagAt(i);
schematic.tileEntities.add(tileEntityTagCompound);
}
return schematic;
}
private static String convertOldDimDoorsBlockNameToNewDimDoorsBlockName(String dimdoorsBlockName) {
if (OLDDIMDOORBLOCKNAMES.length != NEWDIMDOORBLOCKNAMES.length) {
DimDoors.warn(Schematic.class, "The array of old DimDoors block names somehow isn't the same length as the array of new names, therefore the dimdoors blocks in this schematic will not be loaded. This is a bug in the DimDoors mod itself.");
return null;
}
int i = 0;
for (; i < OLDDIMDOORBLOCKNAMES.length; i++) {
if (OLDDIMDOORBLOCKNAMES[i].equals(dimdoorsBlockName)) {
return NEWDIMDOORBLOCKNAMES[i];
} else {
if (i == OLDDIMDOORBLOCKNAMES.length - 1) {
DimDoors.warn(Schematic.class, dimdoorsBlockName + " as an old dimdoors block name is unknown.");
}
}
}
return null;
}
}

View file

@ -9,18 +9,16 @@ import net.minecraft.util.ResourceLocation;
*/
public class LimboSkyProvider extends CustomSkyProvider {
private static final ResourceLocation limboMoonResourceLoc = new ResourceLocation(DimDoors.MODID + ":textures/other/limbo_moon.png");
private static final ResourceLocation limboSunResourceLoc = new ResourceLocation(DimDoors.MODID + ":textures/other/limbo_sun.png");
private static final ResourceLocation moonRenderPath = new ResourceLocation(DimDoors.MODID + ":textures/other/limbo_moon.png");
private static final ResourceLocation sunRenderPath = new ResourceLocation(DimDoors.MODID + ":textures/other/limbo_sun.png");
@Override
public ResourceLocation getMoonRenderPath() {
return limboMoonResourceLoc;
return moonRenderPath;
}
@Override
public ResourceLocation getSunRenderPath() {
return limboSunResourceLoc;
return sunRenderPath;
}
}