More dungeon features

- Set dungeon weights
 - Implement warp door
 - Enable monoliths in dungeons
 - Set correct author on schematics (from file name)
 - Make grass in pockets less dark
 - Fix lighting bug
This commit is contained in:
Runemoro 2018-01-18 03:15:36 -05:00
parent 8fbd238fae
commit b7095dcec4
22 changed files with 586 additions and 656 deletions

View file

@ -30,7 +30,7 @@ public class Schematic {
public int version = 1;
public String author = null;
public String name = "Unknown";
public String name = null;
public long creationDate;
public String[] requiredMods = {};
public short width;
@ -43,7 +43,7 @@ public class Schematic {
public List<NBTTagCompound> tileEntities = new ArrayList<>();
public List<NBTTagCompound> entities = new ArrayList<>(); // Not in the specification, but we need this
public static Schematic loadFromNBT(NBTTagCompound nbt, String name) {
public static Schematic loadFromNBT(NBTTagCompound nbt) {
Schematic schematic = new Schematic();
schematic.version = nbt.getInteger("Version"); //Version is required
@ -54,7 +54,7 @@ public class Schematic {
schematic.author = metadataCompound.getString("Author");
}
//Name is not required (may be null)
schematic.name = (name == null || name.equals("")) && nbt.hasKey("Name") ? metadataCompound.getString("Name") : name;
schematic.name = metadataCompound.getString("Name");
if (nbt.hasKey("Date")) { //Date is not required
schematic.creationDate = metadataCompound.getLong("Date");
@ -131,8 +131,8 @@ public class Schematic {
if (nbt.hasKey("Entities")) { //Entities is not required
NBTTagList entitiesTagList = (NBTTagList) nbt.getTag("Entities");
for (int i = 0; i < entitiesTagList.tagCount(); i++) {
NBTTagCompound tileEntityTagCompound = entitiesTagList.getCompoundTagAt(i);
schematic.tileEntities.add(tileEntityTagCompound);
NBTTagCompound entityTagCompound = entitiesTagList.getCompoundTagAt(i);
schematic.entities.add(entityTagCompound);
}
}
@ -279,6 +279,7 @@ public class Schematic {
// Relight changed chunks
for (Chunk chunk : changedChunks) {
chunk.setLightPopulated(false);
chunk.setTerrainPopulated(true);
chunk.resetRelightChecks();
chunk.checkLight();
}
@ -310,17 +311,19 @@ public class Schematic {
}
}
// Set Entity data
// Spawn entities
for (NBTTagCompound entityNBT : schematic.entities) {
// Correct the position and UUID
NBTTagList posNBT = (NBTTagList) entityNBT.getTag("Pos");
NBTTagList newPosNBT = new NBTTagList();
newPosNBT.appendTag(new NBTTagDouble(posNBT.getDoubleAt(0) + xBase));
newPosNBT.appendTag(new NBTTagDouble(posNBT.getDoubleAt(1) + yBase));
newPosNBT.appendTag(new NBTTagDouble(posNBT.getDoubleAt(2) + zBase));
entityNBT.setTag("Pos", newPosNBT);
entityNBT.setUniqueId("UUID", UUID.randomUUID());
NBTTagCompound adjustedEntityNBT = entityNBT.copy();
adjustedEntityNBT.setTag("Pos", newPosNBT);
adjustedEntityNBT.setUniqueId("UUID", UUID.randomUUID());
Entity entity = EntityList.createEntityFromNBT(entityNBT, world);
Entity entity = EntityList.createEntityFromNBT(adjustedEntityNBT, world);
world.spawnEntity(entity);
}
}

View file

@ -74,7 +74,12 @@ public class DimDoors {
if (/* TODO: config option && */ entity instanceof EntityPlayerMP) {
EntityPlayerMP player = (EntityPlayerMP) entity;
player.sendStatusMessage(new TextComponentString(text), true);
} else
entity.sendMessage(new TextComponentString("[DimDoors] " + text));
} else {
chat(entity, text);
}
}
public static void chat(Entity entity, String text) {
entity.sendMessage(new TextComponentString("[DimDoors] " + text));
}
}

View file

@ -35,7 +35,7 @@ public abstract class BlockDimensionalDoor extends BlockDoor implements IRiftPro
IBlockState doorState = world.getBlockState(state.getValue(HALF) == EnumDoorHalf.UPPER ? pos.down() : pos); // .down() because only the bottom block has open=true
// Check that it's a door and that the entity portal timer is 0
if (doorState.getValue(BlockDoor.OPEN) && entity.timeUntilPortal == 0) {
if (doorState.getBlock().equals(this) && doorState.getValue(BlockDoor.OPEN) && entity.timeUntilPortal == 0) {
entity.timeUntilPortal = 50; // Disable another teleport for that entity for 2.5s
TileEntityEntranceRift rift = getRift(world, pos, state);
boolean successful = rift.teleport(entity);
@ -99,7 +99,7 @@ public abstract class BlockDimensionalDoor extends BlockDoor implements IRiftPro
return (state.isSideSolid(world, pos, EnumFacing.UP)
|| state.getBlockFaceShape(world, pos.down(), EnumFacing.UP) == BlockFaceShape.SOLID)
&& (world.getBlockState(pos).getBlock().isReplaceable(world, pos) || world.getBlockState(pos).getBlock().equals(ModBlocks.RIFT))
&& world.getBlockState(pos).getBlock().isReplaceable(world, pos.up());
&& world.getBlockState(pos.up()).getBlock().isReplaceable(world, pos.up());
}
} else {
return super.canPlaceBlockAt(world, pos);
@ -135,7 +135,6 @@ public abstract class BlockDimensionalDoor extends BlockDoor implements IRiftPro
TileEntityFloatingRift newRift = (TileEntityFloatingRift) world.getTileEntity(pos);
newRift.copyFrom(rift);
newRift.updateType();
//world.notifyBlockUpdate(rift.getPos(), state, world.getBlockState(pos), 0); // TODO: does this work?
} else {
rift.unregister();
}

View file

@ -9,7 +9,6 @@ import org.dimdev.dimdoors.shared.tileentities.TileEntityEntranceRift;
import net.minecraft.block.material.Material;
import net.minecraft.item.Item;
import net.minecraft.util.ResourceLocation;
import org.dimdev.dimdoors.shared.rifts.destinations.PocketEntranceDestination;
public class BlockDimensionalDoorTransient extends BlockDimensionalDoor { // TODO: convert to a more general entrances block (like nether portals)
@ -35,15 +34,12 @@ public class BlockDimensionalDoorTransient extends BlockDimensionalDoor { // TOD
@Override
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
return new AxisAlignedBB(0,0,0,0,0,0); //patches entities trying to pathfind through this block, however makes them spin like crazy if they end up in this block.
//NULL_AABB, the same as BlockAir, or straight up null seem to crash the server.
// Patches entities trying to pathfind through this block, however makes them spin like crazy if they end up in this block.
return new AxisAlignedBB(0, 0, 0, 0, 0, 0);
}
@Override
public void setupRift(TileEntityEntranceRift rift) {
// TODO
PocketEntranceDestination destination = PocketEntranceDestination.builder().build();
}
public void setupRift(TileEntityEntranceRift rift) {}
@Override
public boolean canBePlacedOnRift() {

View file

@ -1,14 +1,16 @@
package org.dimdev.dimdoors.shared.blocks;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import org.dimdev.dimdoors.DimDoors;
import org.dimdev.dimdoors.shared.items.ModItems;
import org.dimdev.dimdoors.shared.tileentities.TileEntityEntranceRift;
import net.minecraft.block.material.Material;
import net.minecraft.item.Item;
import net.minecraft.util.ResourceLocation;
import org.dimdev.dimdoors.DimDoors;
import org.dimdev.dimdoors.shared.items.ModItems;
import org.dimdev.dimdoors.shared.rifts.destinations.AvailableLinkDestination;
import org.dimdev.dimdoors.shared.tileentities.TileEntityEntranceRift;
import java.util.Collections;
import java.util.Random;
public class BlockDimensionalDoorWood extends BlockDimensionalDoor {
@ -34,7 +36,13 @@ public class BlockDimensionalDoorWood extends BlockDimensionalDoor {
@Override
public void setupRift(TileEntityEntranceRift rift) {
// TODO
rift.setDestination(AvailableLinkDestination.builder()
.acceptedGroups(Collections.singleton(0))
.coordFactor(1)
.negativeDepthFactor(80)
.positiveDepthFactor(Double.MAX_VALUE)
.weightMaximum(100)
.noLink(false).newRiftWeight(1).build());
}
@Override

View file

@ -73,16 +73,16 @@ public class CommandPocket extends CommandBase {
EntityPlayerMP player = getCommandSenderAsPlayer(sender);
// Make sure the player is in a pocket world
if (!ModDimensions.isDimDoorsPocketDimension(player.world)) {
DimDoors.sendMessage(player, "You must be in a pocket dimension to use this command!");
DimDoors.chat(player, "You must be in a pocket dimension to use this command!");
return;
}
// Check if the schematic exists
if (!SchematicHandler.INSTANCE.getTemplateGroups().contains(group)) {
DimDoors.sendMessage(player, "Group " + group + " not found");
DimDoors.chat(player, "Group " + group + " not found");
return;
} else if (!SchematicHandler.INSTANCE.getTemplateNames(group).contains(name)) {
DimDoors.sendMessage(player, "Schematic " + name + " not found in group " + group);
DimDoors.chat(player, "Schematic " + name + " not found in group " + group);
return;
}

View file

@ -9,7 +9,7 @@ import java.util.Random;
public final class PocketGenerator {
public static Pocket generatePocketFromTemplate(int dim, PocketTemplate pocketTemplate, VirtualLocation virtualLocation) {
DimDoors.log.info("Generating pocket from template " + pocketTemplate.getName() + " at virtual location " + virtualLocation);
DimDoors.log.info("Generating pocket from template " + pocketTemplate.getId() + " at virtual location " + virtualLocation);
PocketRegistry registry = PocketRegistry.instance(dim);
Pocket pocket = registry.newPocket();
@ -23,6 +23,7 @@ public final class PocketGenerator {
return generatePocketFromTemplate(ModDimensions.getPrivateDim(), pocketTemplate, virtualLocation);
}
// TODO: size of public pocket should increase with depth
public static Pocket generatePublicPocket(VirtualLocation virtualLocation) {
PocketTemplate pocketTemplate = SchematicHandler.INSTANCE.getPublicPocketTemplate();
return generatePocketFromTemplate(ModDimensions.getPublicDim(), pocketTemplate, virtualLocation);
@ -36,7 +37,7 @@ public final class PocketGenerator {
*/
public static Pocket generateDungeonPocket(VirtualLocation virtualLocation) {
int depth = virtualLocation.getDepth();
float netherProbability = virtualLocation.getDim() == -1 ? 1 : (float) depth / 50; // TODO: improve nether probability
float netherProbability = virtualLocation.getDim() == -1 ? 1 : (float) depth / 200; // TODO: improve nether probability
Random random = new Random();
String group = random.nextFloat() < netherProbability ? "nether" : "ruins";
PocketTemplate pocketTemplate = SchematicHandler.INSTANCE.getRandomTemplate(group, depth, Config.getMaxPocketSize(), false);

View file

@ -19,26 +19,25 @@ import net.minecraft.world.WorldServer;
/**
* @author Robijnvogel
*/
@AllArgsConstructor @RequiredArgsConstructor// TODO: use @Builder?
@AllArgsConstructor @RequiredArgsConstructor
public class PocketTemplate {
@Getter private final String groupName;
@Getter private final String group;
@Getter private final String id;
@Getter private final String type;
@Getter private final String name;
@Getter private final String author;
@Getter @Setter private Schematic schematic;
@Getter private final int size; // size in chunks (n*n chunks)
@Getter private final int minDepth;
@Getter private final int maxDepth;
@Getter private final int baseWeight;
//private final float[] weights; // weight per-level
public float getWeight(int depth) {
/*if (depth < 0) return 100; // TODO: get rid of this line later
if (maxDepth - minDepth + 1 != weights.length) throw new IllegalStateException("This PocketTemplate wasn't set up correctly!");
if (depth < minDepth) return 0;
if (depth > maxDepth) return weights[weights.length - 1];
return weights[depth - minDepth];*/
return baseWeight;
// TODO: make this actually dependend on the depth
//noinspection IfStatementWithIdenticalBranches
if (depth == -1) {
return baseWeight;
} else {
return baseWeight; // TODO: make this actually dependend on the depth
}
}
public void place(Pocket pocket) {

View file

@ -31,14 +31,13 @@ import org.dimdev.dimdoors.shared.world.ModDimensions;
/**
* @author Robijnvogel
*/
public class SchematicHandler { // TODO: make this more general (not dimdoors-related)
public class SchematicHandler {
public static final SchematicHandler INSTANCE = new SchematicHandler(); // TODO: make static
private List<PocketTemplate> templates;
private Map<String, Map<String, Integer>> nameMap; // group -> name -> index in templates
// LOADING CODE STARTS HERE <editor-fold>
public void loadSchematics() {
templates = new ArrayList<>();
@ -91,7 +90,7 @@ public class SchematicHandler { // TODO: make this more general (not dimdoors-re
String subDirectory = jsonTemplate.get("group").getAsString(); //get the subfolder in which the schematics are stored
for (PocketTemplate template : validTemplates) { //it's okay to "tap" this for-loop, even if validTemplates is empty.
String extendedTemplatelocation = subDirectory.equals("") ? template.getName() : subDirectory + "/" + template.getName(); //transform the filename accordingly
String extendedTemplatelocation = subDirectory.equals("") ? template.getId() : subDirectory + "/" + template.getId(); //transform the filename accordingly
//Initialising the possible locations/formats for the schematic file
InputStream schematicStream = DimDoors.class.getResourceAsStream(schematicJarDirectory + extendedTemplatelocation + ".schem");
@ -113,17 +112,17 @@ public class SchematicHandler { // TODO: make this more general (not dimdoors-re
schematicDataStream = new DataInputStream(new FileInputStream(schematicFile));
streamOpened = true;
} catch (FileNotFoundException ex) {
DimDoors.log.error("Schematic file " + template.getName() + ".schem did not load correctly from config folder.", ex);
DimDoors.log.error("Schematic file " + template.getId() + ".schem did not load correctly from config folder.", ex);
}
} else if (oldVersionSchematicFile.exists()) {
try {
schematicDataStream = new DataInputStream(new FileInputStream(oldVersionSchematicFile));
streamOpened = true;
} catch (FileNotFoundException ex) {
DimDoors.log.error("Schematic file " + template.getName() + ".schematic did not load correctly from config folder.", ex);
DimDoors.log.error("Schematic file " + template.getId() + ".schematic did not load correctly from config folder.", ex);
}
} else {
DimDoors.log.warn("Schematic '" + template.getName() + "' was not found in the jar or config directory, neither with the .schem extension, nor with the .schematic extension.");
DimDoors.log.warn("Schematic '" + template.getId() + "' was not found in the jar or config directory, neither with the .schem extension, nor with the .schematic extension.");
}
NBTTagCompound schematicNBT;
@ -132,13 +131,13 @@ public class SchematicHandler { // TODO: make this more general (not dimdoors-re
try {
schematicNBT = CompressedStreamTools.readCompressed(schematicDataStream);
if (!schematicNBT.hasKey("Version")) {
schematic = SchematicConverter.convertSchematic(schematicNBT, template.getName());
schematic = SchematicConverter.convertSchematic(schematicNBT, template.getName(), template.getAuthor());
} else {
schematic = Schematic.loadFromNBT(schematicNBT, template.getName());
schematic = Schematic.loadFromNBT(schematicNBT);
}
schematicDataStream.close();
} catch (IOException ex) {
Logger.getLogger(SchematicHandler.class.getName()).log(Level.SEVERE, "Schematic file for " + template.getName() + " could not be read as a valid schematic NBT file.", ex); // TODO: consistently use one type of logger for this.
Logger.getLogger(SchematicHandler.class.getName()).log(Level.SEVERE, "Schematic file for " + template.getId() + " could not be read as a valid schematic NBT file.", ex); // TODO: consistently use one type of logger for this.
} finally {
try {
schematicDataStream.close();
@ -151,10 +150,9 @@ public class SchematicHandler { // TODO: make this more general (not dimdoors-re
if (schematic != null
&& (schematic.width > (template.getSize() + 1) * 16 || schematic.length > (template.getSize() + 1) * 16)) {
schematic = null;
DimDoors.log.warn("Schematic " + template.getName() + " was bigger than specified in its json file and therefore wasn't loaded");
DimDoors.log.warn("Schematic " + template.getId() + " was bigger than specified in its json file and therefore wasn't loaded");
}
template.setSchematic(schematic);
// TODO: delete from validTemplates if schematic is null
}
return validTemplates;
}
@ -162,37 +160,21 @@ public class SchematicHandler { // TODO: make this more general (not dimdoors-re
private static List<PocketTemplate> getAllValidVariations(JsonObject jsonTemplate) {
List<PocketTemplate> pocketTemplates = new ArrayList<>();
final String directory = jsonTemplate.get("group").getAsString();
int maxSize = -1;
if (!Config.isLoadAllSchematics()) {
switch (directory) {
case "public":
maxSize = Config.getPublicPocketSize(); // TODO: hardcode?¿
break;
case "private":
maxSize = Config.getPrivatePocketSize();
break;
default:
maxSize = Config.getMaxPocketSize();
break;
}
}
final String group = jsonTemplate.get("group").getAsString();
final JsonArray variations = jsonTemplate.getAsJsonArray("variations");
final JsonArray pockets = jsonTemplate.getAsJsonArray("pockets");
//convert the variations arraylist to a list of pocket templates
for (JsonElement variationElement : variations) {
JsonObject variation = variationElement.getAsJsonObject();
String variantName = variation.get("variantName").getAsString();
int variationSize = variation.get("size").getAsInt();
if (maxSize >= 0 && variationSize > maxSize) {
continue;
}
int minDepth = variation.get("minDepth").getAsInt();
int maxDepth = variation.get("maxDepth").getAsInt();
int baseWeight = variation.get("baseWeight").getAsInt();
PocketTemplate pocketTemplate = new PocketTemplate(directory, variantName, variationSize, minDepth, maxDepth, baseWeight);
pocketTemplates.add(pocketTemplate);
for (JsonElement pocketElement : pockets) {
JsonObject pocket = pocketElement.getAsJsonObject();
String id = pocket.get("id").getAsString();
String type = pocket.has("type") ? pocket.get("type").getAsString() : null;
String name = pocket.has("name") ? pocket.get("name").getAsString() : null;
String author = pocket.has("author") ? pocket.get("author").getAsString() : null;
int size = pocket.get("size").getAsInt();
if (Config.isLoadAllSchematics() && size > Config.getMaxPocketSize()) continue;
int baseWeight = pocket.has("baseWeight") ? pocket.get("baseWeight").getAsInt() : 100;
pocketTemplates.add(new PocketTemplate(group, id, type, name, author, size, baseWeight));
}
return pocketTemplates;
@ -205,24 +187,23 @@ public class SchematicHandler { // TODO: make this more general (not dimdoors-re
Map<String, Integer> bufferedMap = null;
for (PocketTemplate template : templates) {
String dirName = template.getGroupName();
String dirName = template.getGroup();
if (dirName != null && dirName.equals(bufferedDirectory)) { //null check not needed
bufferedMap.put(template.getName(), templates.indexOf(template));
bufferedMap.put(template.getId(), templates.indexOf(template));
} else {
bufferedDirectory = dirName;
if (nameMap.containsKey(dirName)) { //this will only happen if you have two json files referring to the same directory being loaded non-consecutively
bufferedMap = nameMap.get(dirName);
bufferedMap.put(template.getName(), templates.indexOf(template));
bufferedMap.put(template.getId(), templates.indexOf(template));
} else {
bufferedMap = new HashMap<>();
bufferedMap.put(template.getName(), templates.indexOf(template));
bufferedMap.put(template.getId(), templates.indexOf(template));
nameMap.put(dirName, bufferedMap);
}
}
}
}
// LOADING CODE ENDS HERE </editor-fold>
public Set<String> getTemplateGroups() {
return nameMap.keySet();
}
@ -257,29 +238,18 @@ public class SchematicHandler { // TODO: make this more general (not dimdoors-re
/**
* Gets a random template matching certain criteria.
*
* @return A random template matching those criteria, or null if none were found
*/
public PocketTemplate getRandomTemplate(Map<String, Float> groupWeights, int depth, int maxSize, boolean getLargest) { // TODO: useful?
String group = MathUtils.weightedRandom(groupWeights);
return getRandomTemplate(group, depth, maxSize, getLargest);
}
/**
* Gets a random template matching certain criteria.
*
* @param group The template group to choose from.
* @param maxSize Maximum size the template can be.
* @param getLargest Setting this to true will always get the largest template size in that group,
* but still randomly out of the templates with that size (ex. for private and public pockets)
* @return A random template matching those criteria, or null if none were found
*/
public PocketTemplate getRandomTemplate(String group, int depth, int maxSize, boolean getLargest) {
public PocketTemplate getRandomTemplate(String group, int depth, int maxSize, boolean getLargest) { // TODO: multiple groups
// TODO: cache this for faster calls:
Map<PocketTemplate, Float> weightedTemplates = new HashMap<>();
int largestSize = 0;
for (PocketTemplate template : templates) {
if (template.getGroupName().equals(group)
&& (depth == -1 || depth >= template.getMinDepth() && (depth <= template.getMaxDepth() || template.getMaxDepth() == -1))
&& (maxSize == -1 || template.getSize() <= maxSize)) {
if (template.getGroup().equals(group) && (maxSize == -1 || template.getSize() <= maxSize)) {
if (getLargest && template.getSize() > largestSize) {
weightedTemplates = new HashMap<>();
largestSize = template.getSize();

View file

@ -3,7 +3,6 @@ package org.dimdev.dimdoors.shared.rifts;
import lombok.Getter;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.play.server.SPacketUpdateTileEntity;
@ -25,7 +24,6 @@ import org.dimdev.dimdoors.shared.blocks.BlockFloatingRift;
import org.dimdev.dimdoors.shared.rifts.registry.LinkProperties;
import org.dimdev.dimdoors.shared.rifts.registry.Rift;
import org.dimdev.dimdoors.shared.rifts.registry.RiftRegistry;
import org.dimdev.dimdoors.shared.world.ModDimensions;
import javax.annotation.Nonnull;
@ -53,6 +51,7 @@ import javax.annotation.Nonnull;
yaw = oldRift.yaw;
pitch = oldRift.pitch;
properties = oldRift.properties;
destination = oldRift.destination;
if (oldRift.isFloating() != isFloating()) updateType();
markDirty();
@ -212,7 +211,7 @@ import javax.annotation.Nonnull;
return true;
}
} catch (Exception e) {
DimDoors.sendMessage(entity, "There was an exception while teleporting!");
DimDoors.chat(entity, "There was an exception while teleporting, please report this bug.");
DimDoors.log.error("Teleporting failed with the following exception: ", e);
}
return false;

View file

@ -37,7 +37,7 @@ import org.dimdev.dimdoors.shared.rifts.RiftDestination;
@Override
public boolean teleport(RotatedLocation loc, Entity entity) {
if (entity instanceof EntityPlayer) DimDoors.sendMessage(entity, "The entrances of this dungeon has not been linked. Either this is a bug or you are in dungeon-building mode.");
if (entity instanceof EntityPlayer) DimDoors.chat(entity, "The entrances of this dungeon has not been linked. Either this is a bug or you are in dungeon-building mode.");
return false;
}
}

View file

@ -28,7 +28,7 @@ public class PocketExitDestination extends RiftDestination { // TODO: not exactl
@Override
public boolean teleport(RotatedLocation loc, Entity entity) {
if (entity instanceof EntityPlayer) DimDoors.sendMessage(entity, "The exit of this dungeon has not been linked. Either this is a bug or you are in dungeon-building mode.");
if (entity instanceof EntityPlayer) DimDoors.chat(entity, "The exit of this dungeon has not been linked. Either this is a bug or you are in dungeon-building mode.");
return false;
}
}

View file

@ -10,7 +10,7 @@ import org.dimdev.dimdoors.shared.pockets.Pocket;
import org.dimdev.dimdoors.shared.pockets.PocketGenerator;
@Getter @AllArgsConstructor @Builder(toBuilder = true) @ToString
public class PublicPocketDestination extends LinkingDestination {
public class PublicPocketDestination extends RestoringDestination {
// public PublicPocketDestination() {}
@Override public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); }

View file

@ -7,7 +7,7 @@ import org.dimdev.ddutils.RGBA;
import org.dimdev.ddutils.RotatedLocation;
import org.dimdev.dimdoors.shared.rifts.RiftDestination;
public abstract class LinkingDestination extends RiftDestination {
public abstract class RestoringDestination extends RiftDestination {
private RiftDestination wrappedDestination;

View file

@ -2,11 +2,13 @@ package org.dimdev.dimdoors.shared.tools;
import net.minecraft.block.Block;
import net.minecraft.block.BlockDoor;
import net.minecraft.block.BlockEndPortalFrame;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.*;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.ITextComponent;
@ -16,6 +18,7 @@ import org.dimdev.ddutils.schem.Schematic;
import org.dimdev.dimdoors.DimDoors;
import org.dimdev.dimdoors.shared.blocks.BlockFabric;
import org.dimdev.dimdoors.shared.blocks.ModBlocks;
import org.dimdev.dimdoors.shared.entities.EntityMonolith;
import org.dimdev.dimdoors.shared.rifts.destinations.AvailableLinkDestination;
import org.dimdev.dimdoors.shared.rifts.destinations.PocketEntranceDestination;
import org.dimdev.dimdoors.shared.rifts.destinations.PocketExitDestination;
@ -41,12 +44,12 @@ public final class SchematicConverter {
stateMap.put("minecraft:wooden_door", ModBlocks.WARP_DIMENSIONAL_DOOR.getDefaultState());
}
public static Schematic convertSchematic(NBTTagCompound nbt, String name) {
public static Schematic convertSchematic(NBTTagCompound nbt, String name, String author) {
Schematic schematic = new Schematic();
schematic.version = 1; //already the default value
schematic.author = "DimDoors"; // Old schematics didn't have an author
schematic.name = name.equals("") ? "Unknown" : name;
schematic.author = author;
schematic.name = name;
schematic.creationDate = System.currentTimeMillis();
schematic.requiredMods = new String[]{DimDoors.MODID};
@ -55,6 +58,13 @@ public final class SchematicConverter {
schematic.length = nbt.getShort("Length");
schematic.offset = new int[]{0, 0, 0};
// Schematic info
int ironDoors = 0;
int woodDoors = 0;
int sandstoneDoors = 0;
int monoliths = 0;
int chests = 0;
byte[] blockIntArray = nbt.getByteArray("Blocks");
if (nbt.hasKey("Palette")) {
NBTTagList paletteNBT = (NBTTagList) nbt.getTag("Palette");
@ -149,6 +159,8 @@ public final class SchematicConverter {
blockInt = schematic.pallette.size() - 1;
}
if (baseState.getBlock().equals(Blocks.CHEST)) chests++;
if (baseState.getBlock().equals(ModBlocks.DIMENSIONAL_DOOR) || baseState.getBlock().equals(ModBlocks.WARP_DIMENSIONAL_DOOR)) {
//DimDoors.log.info("Door found: " + baseState.getBlock().getUnlocalizedName());
if (blockState.getProperties().get(BlockDoor.HALF).equals(BlockDoor.EnumDoorHalf.LOWER)) {
@ -160,6 +172,7 @@ public final class SchematicConverter {
.linksRemaining(1).build());
if (baseState.equals(ModBlocks.DIMENSIONAL_DOOR)) {
ironDoors++;
rift.setDestination(AvailableLinkDestination.builder()
.acceptedGroups(Collections.singleton(0))
.coordFactor(1)
@ -171,10 +184,12 @@ public final class SchematicConverter {
} else { //if (baseState.equals(ModBlocks.WARP_DIMENSIONAL_DOOR))
IBlockState stateBelow = schematic.pallette.get(schematic.blockData[x][y - 1][z]);
if (stateBelow.getBlock().equals(Blocks.SANDSTONE)) {
sandstoneDoors++;
rift.setProperties(null); // TODO: this should be removed once the linking equations are made symmetric
rift.setDestination(AvailableLinkDestination.builder()
.acceptedGroups(Collections.singleton(0))
.coordFactor(1)
.negativeDepthFactor(0.00000000001)
.negativeDepthFactor(0.00000000001) // The division result is cast to an int, so Double.MIN_VALUE would cause an overflow
.positiveDepthFactor(Double.POSITIVE_INFINITY)
.weightMaximum(100)
.noLink(false)
@ -186,6 +201,7 @@ public final class SchematicConverter {
DimDoors.log.error("Someone placed a door on a sandstone block at the bottom of a schematic. This causes problems and should be remedied. Schematic name: " + schematic.name);
}
} else {
woodDoors++;
rift.setDestination(PocketEntranceDestination.builder()
.weight(1)
.ifDestination(PocketExitDestination.builder().build())
@ -201,6 +217,17 @@ public final class SchematicConverter {
schematic.tileEntities.add(rift.serializeNBT());
}
}
if (blockState.getBlock().equals(Blocks.END_PORTAL_FRAME)) {
monoliths++;
// I think it's safe to assume that air is present
blockInt = schematic.pallette.indexOf(Blocks.AIR.getDefaultState());
EntityMonolith monolith = new EntityMonolith(null);
EnumFacing facing = blockState.getValue(BlockEndPortalFrame.FACING);
monolith.setLocationAndAngles(x + 0.5d, y, z + 0.5d, facing.getHorizontalAngle(), 0);
schematic.entities.add(monolith.serializeNBT());
}
} else { // if this is ancient fabric
blockInt = schematic.pallette.indexOf(baseState);
@ -210,9 +237,10 @@ public final class SchematicConverter {
}
}
}
if (!nbt.getTag("Entities").hasNoTags()) throw new RuntimeException("Schematic contains entities, but those aren't implemented in the conversion code");
schematic.paletteMax = schematic.pallette.size() - 1;
// TODO: entities (and replace end portal frame with monoliths)
DimDoors.log.info(schematic.name + "," + ironDoors + "," + woodDoors + "," + sandstoneDoors + "," + monoliths + "," + chests);
return schematic;
}

View file

@ -35,7 +35,7 @@ public abstract class BaseSchematicGateway extends BaseGateway {
if (streamOpened) {
try {
schematicNBT = CompressedStreamTools.readCompressed(schematicDataStream);
schematic = SchematicConverter.convertSchematic(schematicNBT, name);
schematic = SchematicConverter.convertSchematic(schematicNBT, name, null);
schematicDataStream.close();
} catch (IOException ex) {
DimDoors.log.error("Schematic file for " + name + " could not be read as a valid schematic NBT file.", ex);

View file

@ -20,7 +20,7 @@ public class BiomeBlank extends Biome {
.setHeightVariation(0F)
.setRainDisabled()
.setRainfall(0)
.setWaterColor(white ? 0xFFFFFF : 0x111111));
.setWaterColor(white ? 0xFFFFFF : 0x000055));
this.white = white;
topBlock = Blocks.AIR.getDefaultState();
@ -60,12 +60,12 @@ public class BiomeBlank extends Biome {
@Override
@SideOnly(Side.CLIENT)
public int getGrassColorAtPos(BlockPos pos) {
return getModdedBiomeGrassColor(white ? 0xFFFFFF : 0x111111);
return getModdedBiomeGrassColor(white ? 0xFFFFFF : 0x003300);
}
@Override
@SideOnly(Side.CLIENT)
public int getFoliageColorAtPos(BlockPos pos) {
return getModdedBiomeFoliageColor(white ? 0xFFFFFF : 0x111111);
return getModdedBiomeFoliageColor(white ? 0xFFFFFF : 0x003300);
}
}

View file

@ -16,7 +16,7 @@ public abstract class WorldProviderPocket extends WorldProvider {
@Override
public void init() {
// TODO: save pocket registry nbt here? (see WorldProviderEnd)
//hasSkyLight = false; // TODO: this is only a temporary fix
hasSkyLight = true; // TODO: this is only a temporary fix
generateLightBrightnessTable();
DimDoors.proxy.setCloudRenderer(this, new CloudRenderBlank());
}

View file

@ -1,125 +1,152 @@
{
"group": "nether",
"pocketType" : 2,
"variations": [
"pockets": [
{
"variantName": "ComplexHall_SK-CourtyardAmbush_Open_100",
"id": "ComplexHall_SK-CourtyardAmbush_Open_100",
"type": "complex_hall",
"name": "Courtyard Ambush",
"author": "SK",
"open": true,
"size": 4,
"minDepth": 1,
"maxDepth": 1000,
"baseWeight": 10
"baseWeight": 100
},
{
"variantName": "ComplexHall_SK-Intersection_Open_100",
"id": "ComplexHall_SK-Intersection_Open_100",
"type": "complex_hall",
"name": "Intersection",
"author": "SK",
"open": true,
"size": 2,
"minDepth": 1,
"maxDepth": 1000,
"baseWeight": 10
"baseWeight": 100
},
{
"variantName": "ComplexHall_SK-SoulWastes_Open_100",
"id": "ComplexHall_SK-SoulWastes_Open_100",
"type": "complex_hall",
"name": "Soul Wastes",
"author": "SK",
"open": true,
"size": 5,
"minDepth": 1,
"maxDepth": 1000,
"baseWeight": 10
"baseWeight": 100
},
{
"variantName": "ComplexHall_SK-Starfall_Open_100",
"id": "ComplexHall_SK-Starfall_Open_100",
"type": "complex_hall",
"name": "Starfall",
"author": "SK",
"open": true,
"size": 3,
"minDepth": 1,
"maxDepth": 1000,
"baseWeight": 10
"baseWeight": 100
},
{
"variantName": "ComplexHall_SK-TheCauldron_Open_100",
"id": "ComplexHall_SK-TheCauldron_Open_100",
"type": "complex_hall",
"name": "The Cauldron",
"author": "SK",
"open": true,
"size": 4,
"minDepth": 1,
"maxDepth": 1000,
"baseWeight": 10
"baseWeight": 100
},
{
"variantName": "Maze_SK-BrimstoneMines_Open_80",
"id": "Maze_SK-BrimstoneMines_Open_80",
"type": "maze",
"name": "Brimstone Mines",
"author": "SK",
"open": true,
"size": 6,
"minDepth": 1,
"maxDepth": 1000,
"baseWeight": 10
"baseWeight": 80
},
{
"variantName": "Maze_SK-QuartzfoldCave_Open_40",
"id": "Maze_SK-QuartzfoldCave_Open_40",
"type": "maze",
"name": "Quartzfold Cave",
"author": "SK",
"open": true,
"size": 5,
"minDepth": 1,
"maxDepth": 1000,
"baseWeight": 10
"baseWeight": 40
},
{
"variantName": "Maze_SK-SwirlsUponSwirls_Open_40",
"id": "Maze_SK-SwirlsUponSwirls_Open_40",
"type": "maze",
"name": "Swirls Upon Swirls",
"author": "SK",
"open": true,
"size": 5,
"minDepth": 1,
"maxDepth": 1000,
"baseWeight": 10
"baseWeight": 40
},
{
"variantName": "Maze_SK-Tangle_Open_80",
"id": "Maze_SK-Tangle_Open_80",
"type": "maze",
"name": "Tangle",
"author": "SK",
"open": true,
"size": 3,
"minDepth": 1,
"maxDepth": 1000,
"baseWeight": 10
"baseWeight": 80
},
{
"variantName": "SimpleHall_SK-AnvilValley_Open_100",
"id": "SimpleHall_SK-AnvilValley_Open_100",
"type": "simple_hall",
"name": "Anvil Valley",
"author": "SK",
"open": true,
"size": 5,
"minDepth": 1,
"maxDepth": 1000,
"baseWeight": 10
"baseWeight": 100
},
{
"variantName": "SimpleHall_SK-Arena_Open_100",
"id": "SimpleHall_SK-Arena_Open_100",
"type": "simple_hall",
"name": "Arena",
"author": "SK",
"open": true,
"size": 3,
"minDepth": 1,
"maxDepth": 1000,
"baseWeight": 10
"baseWeight": 100
},
{
"variantName": "SimpleHall_SK-DarkPathLeft_Open_50",
"id": "SimpleHall_SK-DarkPathLeft_Open_50",
"type": "simple_hall",
"author": "SK",
"open": true,
"size": 1,
"minDepth": 1,
"maxDepth": 1000,
"baseWeight": 10
"baseWeight": 50
},
{
"variantName": "SimpleHall_SK-DarkPathRight_Open_50",
"id": "SimpleHall_SK-DarkPathRight_Open_50",
"type": "simple_hall",
"author": "SK",
"open": true,
"size": 1,
"minDepth": 1,
"maxDepth": 1000,
"baseWeight": 10
"baseWeight": 50
},
{
"variantName": "SimpleHall_SK-DiamondRoom_Open_100",
"id": "SimpleHall_SK-DiamondRoom_Open_100",
"type": "simple_hall",
"author": "SK",
"open": true,
"size": 1,
"minDepth": 1,
"maxDepth": 1000,
"baseWeight": 10
"baseWeight": 100
},
{
"variantName": "SimpleHall_SK-LongBridge_Open_100",
"id": "SimpleHall_SK-LongBridge_Open_100",
"type": "simple_hall",
"author": "SK",
"open": true,
"size": 4,
"minDepth": 1,
"maxDepth": 1000,
"baseWeight": 10
"baseWeight": 100
},
{
"variantName": "SimpleHall_SK-SpiralStairsDown_Open_100",
"id": "SimpleHall_SK-SpiralStairsDown_Open_100",
"type": "simple_hall",
"author": "SK",
"open": true,
"size": 0,
"minDepth": 1,
"maxDepth": 1000,
"baseWeight": 10
"baseWeight": 100
},
{
"variantName": "SimpleHall_SK-TheFurnace_Open_100",
"id": "SimpleHall_SK-TheFurnace_Open_100",
"type": "simple_hall",
"author": "SK",
"open": true,
"size": 3,
"minDepth": 1,
"maxDepth": 1000,
"baseWeight": 10
"baseWeight": 100
}
]
}

View file

@ -1,62 +1,37 @@
{
"group": "private",
"pocketType" : 0,
"variations": [
"pockets": [
{
"variantName": "private_pocket_0",
"size": 0,
"minDepth": 0,
"maxDepth": 0,
"baseWeight": 1
"id": "private_pocket_0",
"size": 0
},
{
"variantName": "private_pocket_1",
"size": 1,
"minDepth": 0,
"maxDepth": 0,
"baseWeight": 1
"id": "private_pocket_1",
"size": 1
},
{
"variantName": "private_pocket_2",
"size": 2,
"minDepth": 0,
"maxDepth": 0,
"baseWeight": 1
"id": "private_pocket_2",
"size": 2
},
{
"variantName": "private_pocket_3",
"size": 3,
"minDepth": 0,
"maxDepth": 0,
"baseWeight": 1
"id": "private_pocket_3",
"size": 3
},
{
"variantName": "private_pocket_4",
"size": 4,
"minDepth": 0,
"maxDepth": 0,
"baseWeight": 1
"id": "private_pocket_4",
"size": 4
},
{
"variantName": "private_pocket_5",
"size": 5,
"minDepth": 0,
"maxDepth": 0,
"baseWeight": 1
"id": "private_pocket_5",
"size": 5
},
{
"variantName": "private_pocket_6",
"size": 6,
"minDepth": 0,
"maxDepth": 0,
"baseWeight": 1
"id": "private_pocket_6",
"size": 6
},
{
"variantName": "private_pocket_7",
"size": 7,
"minDepth": 0,
"maxDepth": 0,
"baseWeight": 1
"id": "private_pocket_7",
"size": 7
}
]
}

View file

@ -1,62 +1,37 @@
{
"group": "public",
"pocketType" : 1,
"variations": [
"pockets": [
{
"variantName": "public_pocket_0",
"size": 0,
"minDepth": 0,
"maxDepth": 0,
"baseWeight": 1
"id": "public_pocket_0",
"size": 0
},
{
"variantName": "public_pocket_1",
"size": 1,
"minDepth": 0,
"maxDepth": 0,
"baseWeight": 1
"id": "public_pocket_1",
"size": 1
},
{
"variantName": "public_pocket_2",
"size": 2,
"minDepth": 0,
"maxDepth": 0,
"baseWeight": 1
"id": "public_pocket_2",
"size": 2
},
{
"variantName": "public_pocket_3",
"size": 3,
"minDepth": 0,
"maxDepth": 0,
"baseWeight": 1
"id": "public_pocket_3",
"size": 3
},
{
"variantName": "public_pocket_4",
"size": 4,
"minDepth": 0,
"maxDepth": 0,
"baseWeight": 1
"id": "public_pocket_4",
"size": 4
},
{
"variantName": "public_pocket_5",
"size": 5,
"minDepth": 0,
"maxDepth": 0,
"baseWeight": 1
"id": "public_pocket_5",
"size": 5
},
{
"variantName": "public_pocket_6",
"size": 6,
"minDepth": 0,
"maxDepth": 0,
"baseWeight": 1
"id": "public_pocket_6",
"size": 6
},
{
"variantName": "public_pocket_7",
"size": 7,
"minDepth": 0,
"maxDepth": 0,
"baseWeight": 1
"id": "public_pocket_7",
"size": 7
}
]
}