Default pockets

-Added (auto-generated) default private and public pockets and changed
the jsons,
-Commented out auto-generation code at the bottom of Schematic.java.
-Fixed a stupid method call mistake in PocketRegistry that made stuff
fail miserably.
-Made sure that a size 0 pocket schematic can be 16 blocks.
This commit is contained in:
Mathijs Riezebos 2017-02-25 06:34:09 +01:00
parent 5d26f6f854
commit 4519886063
29 changed files with 150 additions and 23 deletions

View file

@ -5,6 +5,7 @@ import com.zixiken.dimdoors.shared.blocks.ModBlocks;
import com.zixiken.dimdoors.shared.items.ModItems;
import com.zixiken.dimdoors.shared.tileentities.TileEntityDimDoor;
import com.zixiken.dimdoors.shared.tileentities.TileEntityDimDoorGold;
import com.zixiken.dimdoors.shared.tileentities.TileEntityDimDoorPersonal;
import com.zixiken.dimdoors.shared.tileentities.TileEntityRift;
import com.zixiken.dimdoors.shared.tileentities.TileEntityTransTrapdoor;
import com.zixiken.dimdoors.shared.world.DimDoorDimensions;
@ -31,6 +32,8 @@ public abstract class DDProxyCommon implements IDDProxy {
GameRegistry.registerTileEntity(TileEntityRift.class, "TileEntityRift");
GameRegistry.registerTileEntity(TileEntityTransTrapdoor.class, "TileEntityDimHatch");
GameRegistry.registerTileEntity(TileEntityDimDoorGold.class, "TileEntityDimDoorGold");
GameRegistry.registerTileEntity(TileEntityDimDoorPersonal.class, "TileEntityDimDoorPersonal");
//@todo register other TileEntities
}
@Override

View file

@ -5,6 +5,7 @@
*/
package com.zixiken.dimdoors.shared;
import com.zixiken.dimdoors.DimDoors;
import com.zixiken.dimdoors.shared.tileentities.DDTileEntityBase;
import com.zixiken.dimdoors.shared.tileentities.TileEntityDimDoorWarp;
import com.zixiken.dimdoors.shared.util.Location;
@ -17,6 +18,7 @@ import net.minecraft.nbt.NBTTagInt;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.nbt.NBTTagString;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.WorldServer;
/**
*
@ -47,8 +49,14 @@ public class Pocket {
PocketRegistry.Instance.registerNewPocket(this, typeID);
for (int riftID : riftIDs) {
DDTileEntityBase rift = (DDTileEntityBase) RiftRegistry.Instance.getRiftLocation(riftID).getTileEntity();
rift.setPocketID(this.ID); //set the rift's pocket ID to this pocket's pocket ID;
Location riftLocation = RiftRegistry.Instance.getRiftLocation(riftID);
WorldServer worldServer = DimDoors.proxy.getWorldServer(riftLocation.getDimensionID());
if (!worldServer.isRemote) {
DDTileEntityBase rift = (DDTileEntityBase) riftLocation.getTileEntity();
rift.setPocket(this.ID, this.typeID); //set the rift's pocket ID to this pocket's pocket ID;
}
}
}
@ -119,7 +127,7 @@ public class Pocket {
doorsTagList.appendTag(doorTag);
}
pocketNBT.setTag("doorIDs", doorsTagList);
NBTTagCompound depthZeroLocCompound = Location.writeToNBT(pocket.depthZeroLocation);
pocketNBT.setTag("depthZeroLocation", depthZeroLocCompound);
@ -128,8 +136,8 @@ public class Pocket {
NBTTagString playerTag = new NBTTagString(pocket.playerUUIDs.get(i));
playersTagList.appendTag(playerTag);
}
pocketNBT.setTag("playerUUIDs", playersTagList);
pocketNBT.setTag("playerUUIDs", playersTagList);
return pocketNBT;
}

View file

@ -204,7 +204,7 @@ public class PocketRegistry {
int z = getSimpleZ(nextUnusedID, typeID);;
int dimID = DimDoorDimensions.getPocketDimensionType(typeID).getId();
Location location = new Location(x, y, z, dimID);
Location location = new Location(dimID, x, y, z);
return location;
}

View file

@ -87,14 +87,13 @@ public class PocketTemplate { //there is exactly one pocket placer for each diff
int zBase = shortenedZ * gridSize * 16;
if (schematic == null) {
DimDoors.log(this.getClass(), "The schematic for variant " + variantName + " somehow didn't load correctly against despite all precautions.");
DimDoors.log(this.getClass(), "The schematic for variant " + variantName + " somehow didn't load correctly despite all precautions.");
return null;
}
//@todo make sure that the door tile entities get registered!
WorldServer world = DimDoors.proxy.getWorldServer(dimID);
//Place the Dungeon content structure
List<IBlockState> palette = schematic.getPallette();
int[][][] blockData = schematic.getBlockData();
for (int x = 0; x < blockData.length; x++) {

View file

@ -234,7 +234,7 @@ public class RiftRegistry {
return lastBrokenRift;
}
public boolean teleportEntityToRift(Entity entity, int pairedRiftID) {
public boolean teleportEntityToRift(Entity entity, int pairedRiftID) { //@todo implement this code in the sending rift tiles instead
DimDoors.log(this.getClass(), "RiftID of rift that the entity trying to teleport to is " + pairedRiftID + ".");
if (pairedRiftID < 0) {
DimDoors.warn(this.getClass(), "RiftID of rift that entity " + entity + " is trying to teleport to seems to be lower than 0 and it shouldn't.");

View file

@ -68,7 +68,7 @@ public class SchematicHandler {
}
public void loadSchematics() {
personalPocketTemplate = loadTemplatesFromJson("defaultPersonal", PocketRegistry.Instance.getPrivatePocketSize()).get(0);
personalPocketTemplate = loadTemplatesFromJson("defaultPrivate", PocketRegistry.Instance.getPrivatePocketSize()).get(0);
publicPocketTemplate = loadTemplatesFromJson("defaultPublic", PocketRegistry.Instance.getPublicPocketSize()).get(0);
dungeonTemplates = new ArrayList();
List<String> dungeonSchematicNameStrings = DDConfig.getDungeonSchematicNames();
@ -183,9 +183,9 @@ public class SchematicHandler {
}
if (schematic != null
&& (schematic.getWidth() > (template.getSize()) * 16 || schematic.getLength() > (template.getSize()) * 16)) {
&& (schematic.getWidth() > (template.getSize() + 1) * 16 || schematic.getLength() > (template.getSize() + 1) * 16)) {
schematic = null;
DimDoors.log(Schematic.class, "Schematic " + template.getName() + " was bigger than specified in " + nameString + ".json and therefore wasn't loaded");
DimDoors.log(SchematicHandler.class, "Schematic " + template.getName() + " was bigger than specified in " + nameString + ".json and therefore wasn't loaded");
}
template.setSchematic(schematic);
}

View file

@ -43,7 +43,7 @@ public class BlockDimWall extends Block {
setHardness(0.1F);
setUnlocalizedName(ID);
setRegistryName(ID);
setDefaultState(blockState.getBaseState().withProperty(TYPE, EnumType.FABRIC));
setDefaultState(blockState.getBaseState().withProperty(TYPE, EnumType.REALITY));
setSoundType(SoundType.STONE);
}
@ -141,7 +141,7 @@ public class BlockDimWall extends Block {
}
public static enum EnumType implements IStringSerializable {
FABRIC("fabric"),
REALITY("fabric"),
ANCIENT("ancient"),
ALTERED("altered");

View file

@ -130,8 +130,10 @@ public abstract class DDTileEntityBase extends TileEntity {
public abstract boolean tryTeleport(Entity entity);
public void setPocketID(int ID) {
public void setPocket(int ID, EnumPocketType type) {
pocketID = ID;
pocketType = type;
isInPocket = true;
}
public void setIsInPocket() {

View file

@ -1,10 +1,12 @@
package com.zixiken.dimdoors.shared.util;
import com.zixiken.dimdoors.DimDoors;
import net.minecraft.block.state.IBlockState;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.WorldProvider;
import net.minecraft.world.WorldServer;
import net.minecraftforge.common.DimensionManager;
@ -47,7 +49,7 @@ public class Location {
}
public WorldServer getWorld() {
return DimensionManager.getWorld(dimensionID);
return DimDoors.proxy.getWorldServer(dimensionID);
}
public int getDimensionID() {
@ -78,5 +80,10 @@ public class Location {
BlockPos blockPos = new BlockPos(x, y, z);
return new Location(worldID, blockPos);
}
@Override
public String toString() {
return "Location: dimID: " + this.dimensionID + " position: " + this.pos.toString();
}
}

View file

@ -403,4 +403,84 @@ public class Schematic {
}
return null;
}
/*
public static void TempGenerateDefaultSchematics() {
for (int pocketSize = 0; pocketSize < 8; pocketSize++) {
generateDefaultSchematic("defaultPublic", pocketSize, ModBlocks.blockDimWall.getDefaultState().withProperty(BlockDimWall.TYPE, BlockDimWall.EnumType.REALITY), ModBlocks.blockDimDoor);
generateDefaultSchematic("defaultPrivate", pocketSize, ModBlocks.blockDimWall.getDefaultState().withProperty(BlockDimWall.TYPE, BlockDimWall.EnumType.ALTERED), ModBlocks.blockDimDoorPersonal);
}
}
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.blockDimWall.getDefaultState().withProperty(BlockDimWall.TYPE, BlockDimWall.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 (withinDistanceOf(new int[]{x, y, z}, 6, 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 {
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);
}
*/
private static boolean withinDistanceOf(int[] setOne, int difference, int[] setTwo) { //@todo add to a utilityclass
for (int One : setOne) {
for (int Two : setTwo) {
if ((Math.max(One, Two) - Math.min(One, Two)) < difference) {
return true;
}
}
}
return false;
}
}

View file

@ -3,46 +3,60 @@
"pocketType" : 0,
"variations": [
{
"variantName": "defaultPersonal_0",
"variantName": "defaultPrivate_0",
"size": 0,
"minDepth": 0,
"maxDepth": 0,
"weights": [100]
},
{
"variantName": "defaultPersonal_1",
"variantName": "defaultPrivate_1",
"size": 1,
"minDepth": 0,
"maxDepth": 0,
"weights": [100]
},
{
"variantName": "defaultPersonal_2",
"variantName": "defaultPrivate_2",
"size": 2,
"minDepth": 0,
"maxDepth": 0,
"weights": [100]
},
{
"variantName": "defaultPersonal_3",
"variantName": "defaultPrivate_3",
"size": 3,
"minDepth": 0,
"maxDepth": 0,
"weights": [100]
},
{
"variantName": "defaultPersonal_4",
"variantName": "defaultPrivate_4",
"size": 4,
"minDepth": 0,
"maxDepth": 0,
"weights": [100]
},
{
"variantName": "defaultPersonal_5",
{
"variantName": "defaultPrivate_5",
"size": 5,
"minDepth": 0,
"maxDepth": 0,
"weights": [100]
},
{
"variantName": "defaultPrivate_6",
"size": 6,
"minDepth": 0,
"maxDepth": 0,
"weights": [100]
},
{
"variantName": "defaultPrivate_7",
"size": 7,
"minDepth": 0,
"maxDepth": 0,
"weights": [100]
}
]
}

View file

@ -43,6 +43,20 @@
"minDepth": 0,
"maxDepth": 0,
"weights": [100]
},
{
"variantName": "defaultPublic_6",
"size": 6,
"minDepth": 0,
"maxDepth": 0,
"weights": [100]
},
{
"variantName": "defaultPublic_7",
"size": 7,
"minDepth": 0,
"maxDepth": 0,
"weights": [100]
}
]
}