Did another massive chunk of changes
And still many more to got through. Sigh.
This commit is contained in:
parent
0174899d2e
commit
d28c48c3c7
28 changed files with 595 additions and 1862 deletions
|
@ -10,20 +10,19 @@ import com.zixiken.dimdoors.dungeon.DungeonData;
|
|||
import com.zixiken.dimdoors.helpers.DungeonHelper;
|
||||
import com.zixiken.dimdoors.world.PocketBuilder;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import com.zixiken.dimdoors.core.NewDimData;
|
||||
|
||||
public class CommandCreateDungeonRift extends DDCommandBase
|
||||
{
|
||||
public class CommandCreateDungeonRift extends DDCommandBase {
|
||||
private static CommandCreateDungeonRift instance = null;
|
||||
|
||||
private CommandCreateDungeonRift()
|
||||
{
|
||||
private CommandCreateDungeonRift() {
|
||||
super("dd-rift", "<dungeon name>");
|
||||
}
|
||||
|
||||
public static CommandCreateDungeonRift instance()
|
||||
{
|
||||
public static CommandCreateDungeonRift instance() {
|
||||
if (instance == null)
|
||||
instance = new CommandCreateDungeonRift();
|
||||
|
||||
|
@ -31,79 +30,67 @@ public class CommandCreateDungeonRift extends DDCommandBase
|
|||
}
|
||||
|
||||
@Override
|
||||
protected DDCommandResult processCommand(EntityPlayer sender, String[] command)
|
||||
{
|
||||
protected DDCommandResult processCommand(EntityPlayer sender, String[] command) {
|
||||
NewDimData dimension;
|
||||
DungeonHelper dungeonHelper = DungeonHelper.instance();
|
||||
|
||||
if (command.length == 0)
|
||||
{
|
||||
if (command.length == 0) {
|
||||
return DDCommandResult.TOO_FEW_ARGUMENTS;
|
||||
}
|
||||
if (command.length > 1)
|
||||
{
|
||||
} if (command.length > 1) {
|
||||
return DDCommandResult.TOO_MANY_ARGUMENTS;
|
||||
}
|
||||
|
||||
DimLink link;
|
||||
DungeonData result;
|
||||
int x = MathHelper.floor_double(sender.posX);
|
||||
int y = MathHelper.floor_double(sender.posY);
|
||||
int z = MathHelper.floor_double (sender.posZ);
|
||||
int orientation = MathHelper.floor_double((sender.rotationYaw + 180.0F) * 4.0F / 360.0F - 0.5D) & 3;
|
||||
|
||||
BlockPos pos = new BlockPos(MathHelper.floor_double(sender.posX), MathHelper.floor_double(sender.posY), MathHelper.floor_double (sender.posZ));
|
||||
|
||||
EnumFacing facing = EnumFacing.fromAngle(sender.rotationYaw).getOpposite();
|
||||
|
||||
result = findDungeonByPartialName(command[0], dungeonHelper.getRegisteredDungeons());
|
||||
if (result == null)
|
||||
{
|
||||
|
||||
if (result == null) {
|
||||
result = findDungeonByPartialName(command[0], dungeonHelper.getUntaggedDungeons());
|
||||
}
|
||||
|
||||
// Check if we found any matches
|
||||
if (result != null)
|
||||
{
|
||||
if (result != null) {
|
||||
dimension = PocketManager.getDimensionData(sender.worldObj);
|
||||
link = dimension.createLink(x, y + 1, z, LinkType.DUNGEON, orientation);
|
||||
link = dimension.createLink(pos.up(), LinkType.DUNGEON, facing);
|
||||
|
||||
if (PocketBuilder.generateSelectedDungeonPocket(link, DimDoors.properties, result))
|
||||
{
|
||||
if (PocketBuilder.generateSelectedDungeonPocket(link, DimDoors.properties, result)) {
|
||||
// Create a rift to our selected dungeon and notify the player
|
||||
sender.worldObj.setBlock(x, y + 1, z, DimDoors.blockRift, 0, 3);
|
||||
sender.worldObj.setBlockState(pos.up(), DimDoors.blockRift.getDefaultState());
|
||||
sendChat(sender, "Created a rift to \"" + result.schematicName() + "\" dungeon (Dimension ID = " + link.destination().getDimension() + ").");
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
// Dungeon generation failed somehow. Notify the user and remove the useless link.
|
||||
dimension.deleteLink(link);
|
||||
sendChat(sender, "Dungeon generation failed unexpectedly!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
//No matches!
|
||||
return new DDCommandResult("Error: The specified dungeon was not found. Use 'dd-list' to see a list of the available dungeons.");
|
||||
}
|
||||
return DDCommandResult.SUCCESS;
|
||||
}
|
||||
|
||||
private static DungeonData findDungeonByPartialName(String query, Collection<DungeonData> dungeons)
|
||||
{
|
||||
private static DungeonData findDungeonByPartialName(String query, Collection<DungeonData> dungeons) {
|
||||
//Search for the shortest dungeon name that contains the lowercase query string.
|
||||
String dungeonName;
|
||||
String normalQuery = query.toLowerCase();
|
||||
DungeonData bestMatch = null;
|
||||
int matchLength = Integer.MAX_VALUE;
|
||||
|
||||
for (DungeonData dungeon : dungeons)
|
||||
{
|
||||
for (DungeonData dungeon : dungeons) {
|
||||
//We need to extract the file's name. Comparing against schematicPath could
|
||||
//yield false matches if the query string is contained within the path.
|
||||
dungeonName = dungeon.schematicName().toLowerCase();
|
||||
if (dungeonName.length() < matchLength && dungeonName.contains(normalQuery))
|
||||
{
|
||||
if (dungeonName.length() < matchLength && dungeonName.contains(normalQuery)) {
|
||||
matchLength = dungeonName.length();
|
||||
bestMatch = dungeon;
|
||||
}
|
||||
}
|
||||
|
||||
return bestMatch;
|
||||
}
|
||||
}
|
|
@ -3,17 +3,14 @@ package com.zixiken.dimdoors.commands;
|
|||
import com.zixiken.dimdoors.helpers.DungeonHelper;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
public class CommandCreatePocket extends DDCommandBase
|
||||
{
|
||||
public class CommandCreatePocket extends DDCommandBase {
|
||||
private static CommandCreatePocket instance = null;
|
||||
|
||||
private CommandCreatePocket()
|
||||
{
|
||||
private CommandCreatePocket() {
|
||||
super("dd-create", "");
|
||||
}
|
||||
|
||||
public static CommandCreatePocket instance()
|
||||
{
|
||||
public static CommandCreatePocket instance() {
|
||||
if (instance == null)
|
||||
instance = new CommandCreatePocket();
|
||||
|
||||
|
@ -21,10 +18,8 @@ public class CommandCreatePocket extends DDCommandBase
|
|||
}
|
||||
|
||||
@Override
|
||||
protected DDCommandResult processCommand(EntityPlayer sender, String[] command)
|
||||
{
|
||||
if (command.length > 0)
|
||||
{
|
||||
protected DDCommandResult processCommand(EntityPlayer sender, String[] command) {
|
||||
if (command.length > 0) {
|
||||
return DDCommandResult.TOO_MANY_ARGUMENTS;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,21 +12,20 @@ import com.zixiken.dimdoors.dungeon.DungeonData;
|
|||
import com.zixiken.dimdoors.helpers.DungeonHelper;
|
||||
import com.zixiken.dimdoors.world.PocketBuilder;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import com.zixiken.dimdoors.core.NewDimData;
|
||||
|
||||
public class CommandCreateRandomRift extends DDCommandBase
|
||||
{
|
||||
public class CommandCreateRandomRift extends DDCommandBase {
|
||||
private static CommandCreateRandomRift instance = null;
|
||||
private static Random random = new Random();
|
||||
|
||||
private CommandCreateRandomRift()
|
||||
{
|
||||
private CommandCreateRandomRift() {
|
||||
super("dd-random", "<dungeon name>");
|
||||
}
|
||||
|
||||
public static CommandCreateRandomRift instance()
|
||||
{
|
||||
public static CommandCreateRandomRift instance() {
|
||||
if (instance == null)
|
||||
instance = new CommandCreateRandomRift();
|
||||
|
||||
|
@ -34,60 +33,46 @@ public class CommandCreateRandomRift extends DDCommandBase
|
|||
}
|
||||
|
||||
@Override
|
||||
protected DDCommandResult processCommand(EntityPlayer sender, String[] command)
|
||||
{
|
||||
protected DDCommandResult processCommand(EntityPlayer sender, String[] command) {
|
||||
NewDimData dimension;
|
||||
DungeonHelper dungeonHelper = DungeonHelper.instance();
|
||||
|
||||
if (command.length > 1)
|
||||
{
|
||||
return DDCommandResult.TOO_MANY_ARGUMENTS;
|
||||
{return DDCommandResult.TOO_MANY_ARGUMENTS;
|
||||
}
|
||||
|
||||
DimLink link;
|
||||
DungeonData result;
|
||||
int x = MathHelper.floor_double(sender.posX);
|
||||
int y = MathHelper.floor_double(sender.posY);
|
||||
int z = MathHelper.floor_double (sender.posZ);
|
||||
int orientation = MathHelper.floor_double((sender.rotationYaw + 180.0F) * 4.0F / 360.0F - 0.5D) & 3;
|
||||
BlockPos pos = new BlockPos(MathHelper.floor_double(sender.posX), MathHelper.floor_double(sender.posY), MathHelper.floor_double(sender.posZ));
|
||||
EnumFacing facing = EnumFacing.fromAngle(sender.rotationYaw).getOpposite();
|
||||
|
||||
if (command.length == 0)
|
||||
{
|
||||
if (command.length == 0) {
|
||||
dimension = PocketManager.getDimensionData(sender.worldObj);
|
||||
link = dimension.createLink(x, y + 1, z, LinkType.DUNGEON, orientation);
|
||||
link = dimension.createLink(pos.up(), LinkType.DUNGEON, facing);
|
||||
|
||||
sender.worldObj.setBlock(x, y + 1, z, DimDoors.blockRift, 0, 3);
|
||||
sender.worldObj.setBlockState(pos.up(), DimDoors.blockRift.getDefaultState());
|
||||
sendChat(sender, "Created a rift to a random dungeon.");
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
result = getRandomDungeonByPartialName(command[0], dungeonHelper.getRegisteredDungeons());
|
||||
if (result == null)
|
||||
{
|
||||
if (result == null) {
|
||||
result = getRandomDungeonByPartialName(command[0], dungeonHelper.getUntaggedDungeons());
|
||||
}
|
||||
|
||||
// Check if we found any matches
|
||||
if (result != null)
|
||||
{
|
||||
if (result != null) {
|
||||
dimension = PocketManager.getDimensionData(sender.worldObj);
|
||||
link = dimension.createLink(x, y + 1, z, LinkType.DUNGEON, orientation);
|
||||
link = dimension.createLink(pos.up(), LinkType.DUNGEON, facing);
|
||||
|
||||
if (PocketBuilder.generateSelectedDungeonPocket(link, DimDoors.properties, result))
|
||||
{
|
||||
if (PocketBuilder.generateSelectedDungeonPocket(link, DimDoors.properties, result)) {
|
||||
// Create a rift to our selected dungeon and notify the player
|
||||
sender.worldObj.setBlock(x, y + 1, z, DimDoors.blockRift, 0, 3);
|
||||
sender.worldObj.setBlockState(pos.up(), DimDoors.blockRift.getDefaultState());
|
||||
sendChat(sender, "Created a rift to \"" + result.schematicName() + "\" dungeon (Dimension ID = " + link.destination().getDimension() + ").");
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
// Dungeon generation failed somehow. Notify the user and remove the useless link.
|
||||
dimension.deleteLink(link);
|
||||
sendChat(sender, "Dungeon generation failed unexpectedly!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
//No matches!
|
||||
return new DDCommandResult("Error: The specified dungeon was not found. Use 'list' to see a list of the available dungeons.");
|
||||
}
|
||||
|
@ -95,25 +80,20 @@ public class CommandCreateRandomRift extends DDCommandBase
|
|||
return DDCommandResult.SUCCESS;
|
||||
}
|
||||
|
||||
private static DungeonData getRandomDungeonByPartialName(String query, Collection<DungeonData> dungeons)
|
||||
{
|
||||
private static DungeonData getRandomDungeonByPartialName(String query, Collection<DungeonData> dungeons) {
|
||||
// Search for all dungeons that contain the lowercase query string.
|
||||
String dungeonName;
|
||||
String normalQuery = query.toLowerCase();
|
||||
ArrayList<DungeonData> matches = new ArrayList<DungeonData>();
|
||||
|
||||
for (DungeonData dungeon : dungeons)
|
||||
{
|
||||
for (DungeonData dungeon : dungeons) {
|
||||
// We need to extract the file's name. Comparing against schematicPath could
|
||||
// yield false matches if the query string is contained within the path.
|
||||
dungeonName = dungeon.schematicName().toLowerCase();
|
||||
if (dungeonName.contains(normalQuery))
|
||||
{
|
||||
if (dungeonName.contains(normalQuery)) {
|
||||
matches.add(dungeon);
|
||||
}
|
||||
}
|
||||
if (matches.isEmpty())
|
||||
{
|
||||
} if (matches.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return matches.get( random.nextInt(matches.size()) );
|
||||
|
|
|
@ -5,20 +5,19 @@ import java.io.File;
|
|||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import com.zixiken.dimdoors.config.DDProperties;
|
||||
import com.zixiken.dimdoors.helpers.DungeonHelper;
|
||||
import net.minecraft.util.BlockPos;
|
||||
|
||||
public class CommandExportDungeon extends DDCommandBase
|
||||
{
|
||||
private static CommandExportDungeon instance = null;
|
||||
|
||||
private CommandExportDungeon()
|
||||
{
|
||||
private CommandExportDungeon() {
|
||||
super("dd-export", new String[] {
|
||||
"<dungeon type> <dungeon name> <'open' | 'closed'> [weight]",
|
||||
"<schematic name> override" } );
|
||||
}
|
||||
|
||||
public static CommandExportDungeon instance()
|
||||
{
|
||||
public static CommandExportDungeon instance() {
|
||||
if (instance == null)
|
||||
instance = new CommandExportDungeon();
|
||||
|
||||
|
@ -26,8 +25,7 @@ public class CommandExportDungeon extends DDCommandBase
|
|||
}
|
||||
|
||||
@Override
|
||||
protected DDCommandResult processCommand(EntityPlayer sender, String[] command)
|
||||
{
|
||||
protected DDCommandResult processCommand(EntityPlayer sender, String[] command) {
|
||||
/*
|
||||
* There are two versions of this command. One version takes 3 to 4 arguments consisting
|
||||
* of the information needed for a proper schematic name.
|
||||
|
@ -39,23 +37,18 @@ public class CommandExportDungeon extends DDCommandBase
|
|||
|
||||
DungeonHelper dungeonHelper = DungeonHelper.instance();
|
||||
|
||||
if (command.length < 2)
|
||||
{
|
||||
if (command.length < 2) {
|
||||
return DDCommandResult.TOO_FEW_ARGUMENTS;
|
||||
}
|
||||
if (command.length > 4)
|
||||
{
|
||||
if (command.length > 4) {
|
||||
return DDCommandResult.TOO_MANY_ARGUMENTS;
|
||||
}
|
||||
|
||||
//Check if we received the 2-argument version
|
||||
if (command.length == 2)
|
||||
{
|
||||
if (command[1].equalsIgnoreCase("override"))
|
||||
{
|
||||
if (command.length == 2) {
|
||||
if (command[1].equalsIgnoreCase("override")) {
|
||||
//Check that the schematic name is a legal name
|
||||
if (DungeonHelper.SCHEMATIC_NAME_PATTERN.matcher(command[0]).matches())
|
||||
{
|
||||
if (DungeonHelper.SCHEMATIC_NAME_PATTERN.matcher(command[0]).matches()) {
|
||||
//Export the schematic
|
||||
return exportDungeon(sender, command[0]);
|
||||
}
|
||||
|
@ -71,80 +64,70 @@ public class CommandExportDungeon extends DDCommandBase
|
|||
//TODO: This validation should be in DungeonHelper or in another class. We should move it
|
||||
//during the save file format rewrite. ~SenseiKiwi
|
||||
|
||||
if (!dungeonHelper.validateDungeonType(command[0], dungeonHelper.getDungeonPack("ruins")))
|
||||
{
|
||||
if (!dungeonHelper.validateDungeonType(command[0], dungeonHelper.getDungeonPack("ruins"))) {
|
||||
return new DDCommandResult("Error: Invalid dungeon type. Please use one of the existing types.");
|
||||
}
|
||||
if (!DungeonHelper.DUNGEON_NAME_PATTERN.matcher(command[1]).matches())
|
||||
{
|
||||
} if (!DungeonHelper.DUNGEON_NAME_PATTERN.matcher(command[1]).matches()) {
|
||||
return new DDCommandResult("Error: Invalid dungeon name. Please use only letters, numbers, and dashes.");
|
||||
}
|
||||
if (!command[2].equalsIgnoreCase("open") && !command[2].equalsIgnoreCase("closed"))
|
||||
{
|
||||
} if (!command[2].equalsIgnoreCase("open") && !command[2].equalsIgnoreCase("closed")) {
|
||||
return new DDCommandResult("Error: Please specify whether the dungeon is 'open' or 'closed'.");
|
||||
}
|
||||
|
||||
//If there are no more arguments, export the dungeon.
|
||||
if (command.length == 3)
|
||||
{
|
||||
if (command.length == 3) {
|
||||
return exportDungeon(sender, join(command, "_", 0, 3));
|
||||
}
|
||||
|
||||
//Validate the weight argument
|
||||
try
|
||||
{
|
||||
try {
|
||||
int weight = Integer.parseInt(command[3]);
|
||||
if (weight >= DungeonHelper.MIN_DUNGEON_WEIGHT && weight <= DungeonHelper.MAX_DUNGEON_WEIGHT)
|
||||
{
|
||||
if (weight >= DungeonHelper.MIN_DUNGEON_WEIGHT && weight <= DungeonHelper.MAX_DUNGEON_WEIGHT) {
|
||||
return exportDungeon(sender, join(command, "_", 0, 4));
|
||||
}
|
||||
}
|
||||
catch (Exception e) { }
|
||||
} catch (Exception e) { }
|
||||
|
||||
//If we've reached this point, then we must have an invalid weight.
|
||||
return new DDCommandResult("Invalid dungeon weight. Please specify a weight between "
|
||||
+ DungeonHelper.MIN_DUNGEON_WEIGHT + " and " + DungeonHelper.MAX_DUNGEON_WEIGHT + ", inclusive.");
|
||||
}
|
||||
|
||||
private static DDCommandResult exportDungeon(EntityPlayer player, String name)
|
||||
{
|
||||
private static DDCommandResult exportDungeon(EntityPlayer player, String name) {
|
||||
DDProperties properties = DDProperties.instance();
|
||||
DungeonHelper dungeonHelper = DungeonHelper.instance();
|
||||
|
||||
int x = (int) player.posX;
|
||||
int y = (int) player.posY;
|
||||
int z = (int) player.posZ;
|
||||
BlockPos pos = new BlockPos((int) player.posX, (int) player.posY, (int) player.posZ);
|
||||
String exportPath = properties.CustomSchematicDirectory + File.separator + name + ".schematic";
|
||||
if (dungeonHelper.exportDungeon(player.worldObj, x, y, z, exportPath))
|
||||
{
|
||||
|
||||
if (dungeonHelper.exportDungeon(player.worldObj, pos, exportPath)) {
|
||||
sendChat(player,("Saved dungeon schematic in " + exportPath));
|
||||
dungeonHelper.registerDungeon(exportPath, dungeonHelper.getDungeonPack("ruins"), false, true);
|
||||
return DDCommandResult.SUCCESS;
|
||||
}
|
||||
|
||||
return new DDCommandResult("Error: Failed to save dungeon schematic!");
|
||||
}
|
||||
|
||||
private static String join(String[] source, String delimiter, int start, int end)
|
||||
{
|
||||
private static String join(String[] source, String delimiter, int start, int end) {
|
||||
//TODO: This function should be moved to a helper, but we have several single-function helpers as is.
|
||||
//I find that to be worse than keeping this private. ~SenseiKiwi
|
||||
|
||||
int index;
|
||||
int length = 0;
|
||||
StringBuilder buffer;
|
||||
for (index = start; index < end; index++)
|
||||
{
|
||||
|
||||
for (index = start; index < end; index++) {
|
||||
length += source[index].length();
|
||||
}
|
||||
|
||||
length += (end - start - 1) * delimiter.length();
|
||||
|
||||
buffer = new StringBuilder(length);
|
||||
buffer.append(source[start]);
|
||||
for (index = start + 1; index < end; index++)
|
||||
{
|
||||
|
||||
for (index = start + 1; index < end; index++) {
|
||||
buffer.append(delimiter);
|
||||
buffer.append(source[index]);
|
||||
}
|
||||
|
||||
return buffer.toString();
|
||||
}
|
||||
}
|
|
@ -5,17 +5,14 @@ import java.util.ArrayList;
|
|||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import com.zixiken.dimdoors.helpers.DungeonHelper;
|
||||
|
||||
public class CommandListDungeons extends DDCommandBase
|
||||
{
|
||||
public class CommandListDungeons extends DDCommandBase {
|
||||
private static CommandListDungeons instance = null;
|
||||
|
||||
private CommandListDungeons()
|
||||
{
|
||||
private CommandListDungeons() {
|
||||
super("dd-list", "<page>");
|
||||
}
|
||||
|
||||
public static CommandListDungeons instance()
|
||||
{
|
||||
public static CommandListDungeons instance() {
|
||||
if (instance == null)
|
||||
instance = new CommandListDungeons();
|
||||
|
||||
|
@ -23,46 +20,42 @@ public class CommandListDungeons extends DDCommandBase
|
|||
}
|
||||
|
||||
@Override
|
||||
protected DDCommandResult processCommand(EntityPlayer sender, String[] command)
|
||||
{
|
||||
protected DDCommandResult processCommand(EntityPlayer sender, String[] command) {
|
||||
int page;
|
||||
int index;
|
||||
int limit;
|
||||
int pageCount;
|
||||
ArrayList<String> dungeonNames;
|
||||
|
||||
if (command.length > 1)
|
||||
{
|
||||
if (command.length > 1) {
|
||||
return DDCommandResult.TOO_MANY_ARGUMENTS;
|
||||
}
|
||||
if (command.length == 0)
|
||||
{
|
||||
|
||||
if (command.length == 0) {
|
||||
page = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
} else {
|
||||
try {
|
||||
page = Integer.parseInt(command[0]);
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
} catch (NumberFormatException e) {
|
||||
return DDCommandResult.INVALID_ARGUMENTS;
|
||||
}
|
||||
}
|
||||
|
||||
dungeonNames = DungeonHelper.instance().getDungeonNames();
|
||||
pageCount = (dungeonNames.size() - 1) / 10 + 1;
|
||||
if (page < 1 || page > pageCount)
|
||||
{
|
||||
|
||||
if (page < 1 || page > pageCount) {
|
||||
return DDCommandResult.INVALID_ARGUMENTS;
|
||||
}
|
||||
|
||||
sendChat(sender, "List of dungeons (page " + page + " of " + pageCount + "):");
|
||||
index = (page - 1) * 10;
|
||||
limit = Math.min(index + 10, dungeonNames.size());
|
||||
for (; index < limit; index++)
|
||||
{
|
||||
|
||||
for (; index < limit; index++) {
|
||||
sendChat(sender, dungeonNames.get(index));
|
||||
}
|
||||
|
||||
sendChat(sender, "");
|
||||
|
||||
return DDCommandResult.SUCCESS;
|
||||
|
|
|
@ -10,17 +10,14 @@ import com.zixiken.dimdoors.core.LinkType;
|
|||
import com.zixiken.dimdoors.core.NewDimData;
|
||||
import com.zixiken.dimdoors.core.PocketManager;
|
||||
|
||||
public class CommandResetDungeons extends DDCommandBase
|
||||
{
|
||||
public class CommandResetDungeons extends DDCommandBase {
|
||||
private static CommandResetDungeons instance = null;
|
||||
|
||||
private CommandResetDungeons()
|
||||
{
|
||||
private CommandResetDungeons() {
|
||||
super("dd-resetdungeons", "");
|
||||
}
|
||||
|
||||
public static CommandResetDungeons instance()
|
||||
{
|
||||
public static CommandResetDungeons instance() {
|
||||
if (instance == null)
|
||||
instance = new CommandResetDungeons();
|
||||
|
||||
|
@ -28,10 +25,8 @@ public class CommandResetDungeons extends DDCommandBase
|
|||
}
|
||||
|
||||
@Override
|
||||
protected DDCommandResult processCommand(EntityPlayer sender, String[] command)
|
||||
{
|
||||
if (command.length > 0)
|
||||
{
|
||||
protected DDCommandResult processCommand(EntityPlayer sender, String[] command) {
|
||||
if (command.length > 0) {
|
||||
return DDCommandResult.TOO_MANY_ARGUMENTS;
|
||||
}
|
||||
|
||||
|
@ -44,8 +39,8 @@ public class CommandResetDungeons extends DDCommandBase
|
|||
// Copy the list of dimensions to iterate over the copy. Otherwise,
|
||||
// we would trigger an exception by modifying the original list.
|
||||
ArrayList<NewDimData> dimensions = new ArrayList<NewDimData>();
|
||||
for (NewDimData dimension : PocketManager.getDimensions())
|
||||
{
|
||||
|
||||
for (NewDimData dimension : PocketManager.getDimensions()) {
|
||||
|
||||
dimensions.add(dimension);
|
||||
}
|
||||
|
@ -53,48 +48,35 @@ public class CommandResetDungeons extends DDCommandBase
|
|||
// Iterate over the list of dimensions. Check which ones are dungeons.
|
||||
// If a dungeon is found, try to delete it. If it can't be deleted,
|
||||
// then it must be loaded and needs to be updated to prevent bugs.
|
||||
for (NewDimData dimension : dimensions)
|
||||
{
|
||||
if (dimension.type() == DimensionType.DUNGEON)
|
||||
{
|
||||
for (NewDimData dimension : dimensions) {
|
||||
if (dimension.type() == DimensionType.DUNGEON) {
|
||||
dungeonCount++;
|
||||
id = dimension.id();
|
||||
if (PocketManager.deletePocket(dimension, true))
|
||||
{
|
||||
|
||||
if (PocketManager.deletePocket(dimension, true)) {
|
||||
resetCount++;
|
||||
deletedDimensions.add(id);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
loadedDungeons.add(dimension);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Modify the loaded dungeons to prevent bugs
|
||||
for (NewDimData dungeon : loadedDungeons)
|
||||
{
|
||||
for (NewDimData dungeon : loadedDungeons) {
|
||||
// Find top-most loaded dungeons and update their parents.
|
||||
// They will automatically update their children.
|
||||
// Dungeons with non-dungeon parents don't need to be fixed.
|
||||
if (dungeon.parent() == null)
|
||||
{
|
||||
if (dungeon.parent() == null) {
|
||||
dungeon.setParentToRoot();
|
||||
}
|
||||
|
||||
// Links to any deleted dungeons must be replaced
|
||||
for (DimLink link : dungeon.links())
|
||||
{
|
||||
if (link.hasDestination() && deletedDimensions.contains(link.destination().getDimension()))
|
||||
{
|
||||
|
||||
if (link.linkType() == LinkType.DUNGEON)
|
||||
{
|
||||
for (DimLink link : dungeon.links()) {
|
||||
if (link.hasDestination() && deletedDimensions.contains(link.destination().getDimension())) {
|
||||
if (link.linkType() == LinkType.DUNGEON) {
|
||||
dungeon.createLink(link.source(), LinkType.DUNGEON, link.orientation(), null);
|
||||
}
|
||||
else if (link.linkType() == LinkType.REVERSE)
|
||||
{
|
||||
} else if (link.linkType() == LinkType.REVERSE) {
|
||||
dungeon.createLink(link.source(), LinkType.DUNGEON_EXIT, link.orientation(), null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,26 +2,24 @@ package com.zixiken.dimdoors.commands;
|
|||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import com.zixiken.dimdoors.core.DDTeleporter;
|
||||
import com.zixiken.dimdoors.core.NewDimData;
|
||||
import com.zixiken.dimdoors.core.PocketManager;
|
||||
import com.zixiken.dimdoors.util.Point4D;
|
||||
|
||||
public class CommandTeleportPlayer extends DDCommandBase
|
||||
{
|
||||
public class CommandTeleportPlayer extends DDCommandBase {
|
||||
private static CommandTeleportPlayer instance = null;
|
||||
|
||||
private CommandTeleportPlayer()
|
||||
{
|
||||
private CommandTeleportPlayer() {
|
||||
super("dd-tp", new String[] {
|
||||
"<player name> <dimension number>",
|
||||
"<player name> <x> <y> <z>",
|
||||
"<player name> <dimension number> <x> <y> <z>"} );
|
||||
}
|
||||
|
||||
public static CommandTeleportPlayer instance()
|
||||
{
|
||||
public static CommandTeleportPlayer instance() {
|
||||
if (instance == null)
|
||||
instance = new CommandTeleportPlayer();
|
||||
|
||||
|
@ -29,11 +27,8 @@ public class CommandTeleportPlayer extends DDCommandBase
|
|||
}
|
||||
|
||||
@Override
|
||||
protected DDCommandResult processCommand(EntityPlayer sender, String[] command)
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
int z;
|
||||
protected DDCommandResult processCommand(EntityPlayer sender, String[] command) {
|
||||
BlockPos pos;
|
||||
World world;
|
||||
int dimensionID;
|
||||
Point4D destination;
|
||||
|
@ -41,45 +36,36 @@ public class CommandTeleportPlayer extends DDCommandBase
|
|||
boolean checkOrientation;
|
||||
EntityPlayer targetPlayer;
|
||||
|
||||
if (command.length < 2)
|
||||
{
|
||||
if (command.length < 2) {
|
||||
return DDCommandResult.TOO_FEW_ARGUMENTS;
|
||||
}
|
||||
if (command.length > 5)
|
||||
{
|
||||
if (command.length > 5) {
|
||||
return DDCommandResult.TOO_MANY_ARGUMENTS;
|
||||
}
|
||||
if (command.length == 3)
|
||||
{
|
||||
if (command.length == 3) {
|
||||
return DDCommandResult.INVALID_ARGUMENTS;
|
||||
}
|
||||
|
||||
// Check that all arguments after the username are integers
|
||||
for (int k = 1; k < command.length; k++)
|
||||
{
|
||||
if (!isInteger(command[k]))
|
||||
{
|
||||
for (int k = 1; k < command.length; k++) {
|
||||
if (!isInteger(command[k])) {
|
||||
return DDCommandResult.INVALID_ARGUMENTS;
|
||||
}
|
||||
}
|
||||
// Check if the target player is logged in
|
||||
targetPlayer = MinecraftServer.getServer().getConfigurationManager().func_152612_a(command[0]);
|
||||
if (targetPlayer == null)
|
||||
{
|
||||
targetPlayer = MinecraftServer.getServer().getConfigurationManager().getPlayerByUsername(command[0]);
|
||||
if (targetPlayer == null) {
|
||||
return DDCommandResult.PLAYER_OFFLINE;
|
||||
}
|
||||
// If a dimension ID was provided, try to load it
|
||||
if (command.length != 4)
|
||||
{
|
||||
if (command.length != 4) {
|
||||
dimensionID = Integer.parseInt(command[1]);
|
||||
world = PocketManager.loadDimension(dimensionID);
|
||||
if (world == null)
|
||||
{
|
||||
if (world == null) {
|
||||
return DDCommandResult.UNREGISTERED_DIMENSION;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dimensionID = targetPlayer.worldObj.provider.dimensionId;
|
||||
} else {
|
||||
dimensionID = targetPlayer.worldObj.provider.getDimensionId();
|
||||
world = targetPlayer.worldObj;
|
||||
}
|
||||
|
||||
|
@ -91,55 +77,45 @@ public class CommandTeleportPlayer extends DDCommandBase
|
|||
// The Y coordinate must be increased by 1 because of the way that
|
||||
// DDTeleporter considers destination points. It assumes that the
|
||||
// point provided is the upper block of a door.
|
||||
if (command.length == 2)
|
||||
{
|
||||
if (command.length == 2) {
|
||||
// Check if the destination is a pocket dimension
|
||||
dimension = PocketManager.createDimensionData(world);
|
||||
if (dimension.isPocketDimension())
|
||||
{
|
||||
if (dimension.isPocketDimension()) {
|
||||
// The destination is a pocket dimension.
|
||||
// Teleport the player to its original entrance (the origin).
|
||||
destination = dimension.origin();
|
||||
checkOrientation = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
// The destination is not a pocket dimension, which means we
|
||||
// don't automatically know a safe location where we can send
|
||||
// the player. Send the player to (0, Y, 0), where Y is chosen
|
||||
// by searching. Add 2 to place the player ABOVE the top block.
|
||||
y = world.getTopSolidOrLiquidBlock(0, 0) + 2;
|
||||
destination = new Point4D(0, y, 0, dimensionID);
|
||||
|
||||
destination = new Point4D(world.getTopSolidOrLiquidBlock(BlockPos.ORIGIN).up(2), dimensionID);
|
||||
}
|
||||
}
|
||||
else if (command.length == 4)
|
||||
{
|
||||
x = Integer.parseInt(command[1]);
|
||||
y = Integer.parseInt(command[2]) + 1; // Correct the Y value
|
||||
z = Integer.parseInt(command[3]);
|
||||
destination = new Point4D(x, y, z, dimensionID);
|
||||
}
|
||||
else
|
||||
{
|
||||
x = Integer.parseInt(command[2]);
|
||||
y = Integer.parseInt(command[3]) + 1; // Correct the Y value
|
||||
z = Integer.parseInt(command[4]);
|
||||
destination = new Point4D(x, y, z, dimensionID);
|
||||
else if (command.length == 4) {
|
||||
pos = new BlockPos(Integer.parseInt(command[1]),
|
||||
Integer.parseInt(command[2]) + 1, // Correct the Y value
|
||||
Integer.parseInt(command[3]));
|
||||
destination = new Point4D(pos, dimensionID);
|
||||
} else {
|
||||
pos = new BlockPos(Integer.parseInt(command[2]),
|
||||
Integer.parseInt(command[3]) + 1, // Correct the Y value
|
||||
Integer.parseInt(command[4]));
|
||||
destination = new Point4D(pos, dimensionID);
|
||||
}
|
||||
|
||||
// Teleport!
|
||||
DDTeleporter.teleportEntity(targetPlayer, destination, checkOrientation);
|
||||
return DDCommandResult.SUCCESS;
|
||||
}
|
||||
|
||||
private static boolean isInteger(String input)
|
||||
{
|
||||
try
|
||||
{
|
||||
private static boolean isInteger(String input) {
|
||||
try {
|
||||
Integer.parseInt(input);
|
||||
return true;
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
} catch(Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.zixiken.dimdoors.commands;
|
|||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.ICommand;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.command.PlayerNotFoundException;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
|
||||
|
@ -62,10 +63,15 @@ public abstract class DDCommandBase extends CommandBase
|
|||
* to provide the sending player directly.
|
||||
*/
|
||||
@Override
|
||||
public final void processCommand(ICommandSender sender, String[] command)
|
||||
{
|
||||
public final void processCommand(ICommandSender sender, String[] command) {
|
||||
//Forward the command
|
||||
EntityPlayer player = getCommandSenderAsPlayer(sender);
|
||||
EntityPlayer player = null;
|
||||
try {
|
||||
player = getCommandSenderAsPlayer(sender);
|
||||
} catch (PlayerNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
DDCommandResult result = processCommand(player, command);
|
||||
|
||||
//If the command failed, send the player a status message.
|
||||
|
@ -99,10 +105,4 @@ public abstract class DDCommandBase extends CommandBase
|
|||
{
|
||||
return this.getCommandName().compareTo(command.getCommandName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Object other)
|
||||
{
|
||||
return this.compareTo((ICommand) other);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,40 +17,33 @@ public class DDCommandResult {
|
|||
private String message;
|
||||
private boolean printUsage;
|
||||
|
||||
private DDCommandResult(int code, String message, boolean printUsage)
|
||||
{
|
||||
private DDCommandResult(int code, String message, boolean printUsage) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
this.printUsage = printUsage;
|
||||
}
|
||||
|
||||
public DDCommandResult(String message)
|
||||
{
|
||||
public DDCommandResult(String message) {
|
||||
this(CUSTOM_ERROR_CODE, message, false);
|
||||
}
|
||||
|
||||
public DDCommandResult(String message, boolean printUsage)
|
||||
{
|
||||
public DDCommandResult(String message, boolean printUsage) {
|
||||
this(CUSTOM_ERROR_CODE, message, printUsage);
|
||||
}
|
||||
|
||||
public boolean failed()
|
||||
{
|
||||
public boolean failed() {
|
||||
return (code != 0);
|
||||
}
|
||||
|
||||
public int getCode()
|
||||
{
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getMessage()
|
||||
{
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public boolean shouldPrintUsage()
|
||||
{
|
||||
public boolean shouldPrintUsage() {
|
||||
return printUsage;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,8 +6,7 @@ import com.zixiken.dimdoors.dungeon.pack.DungeonType;
|
|||
import com.zixiken.dimdoors.helpers.DungeonHelper;
|
||||
import com.zixiken.dimdoors.schematic.InvalidSchematicException;
|
||||
|
||||
public class DungeonData
|
||||
{
|
||||
public class DungeonData {
|
||||
private final int weight;
|
||||
private final boolean isOpen;
|
||||
private final boolean isInternal;
|
||||
|
@ -15,8 +14,7 @@ public class DungeonData
|
|||
private final String schematicName;
|
||||
private final DungeonType dungeonType;
|
||||
|
||||
public DungeonData(String schematicPath, boolean isInternal, DungeonType dungeonType, boolean isOpen, int weight)
|
||||
{
|
||||
public DungeonData(String schematicPath, boolean isInternal, DungeonType dungeonType, boolean isOpen, int weight) {
|
||||
this.schematicPath = schematicPath;
|
||||
this.schematicName = getSchematicName(schematicPath);
|
||||
this.dungeonType = dungeonType;
|
||||
|
@ -25,8 +23,7 @@ public class DungeonData
|
|||
this.weight = weight;
|
||||
}
|
||||
|
||||
private static String getSchematicName(String schematicPath)
|
||||
{
|
||||
private static String getSchematicName(String schematicPath) {
|
||||
int indexA = schematicPath.lastIndexOf('\\');
|
||||
int indexB = schematicPath.lastIndexOf('/');
|
||||
indexA = Math.max(indexA, indexB) + 1;
|
||||
|
@ -34,44 +31,34 @@ public class DungeonData
|
|||
return schematicPath.substring(indexA, schematicPath.length() - DungeonHelper.SCHEMATIC_FILE_EXTENSION.length());
|
||||
}
|
||||
|
||||
public int weight()
|
||||
{
|
||||
public int weight() {
|
||||
return weight;
|
||||
}
|
||||
|
||||
public boolean isOpen()
|
||||
{
|
||||
public boolean isOpen() {
|
||||
return isOpen;
|
||||
}
|
||||
|
||||
public boolean isInternal()
|
||||
{
|
||||
public boolean isInternal() {
|
||||
return isInternal;
|
||||
}
|
||||
|
||||
public String schematicPath()
|
||||
{
|
||||
public String schematicPath() {
|
||||
return schematicPath;
|
||||
}
|
||||
|
||||
public DungeonType dungeonType()
|
||||
{
|
||||
public DungeonType dungeonType() {
|
||||
return dungeonType;
|
||||
}
|
||||
|
||||
public String schematicName()
|
||||
{
|
||||
public String schematicName() {
|
||||
return schematicName;
|
||||
}
|
||||
|
||||
public DungeonSchematic loadSchematic() throws InvalidSchematicException, FileNotFoundException
|
||||
{
|
||||
if (isInternal)
|
||||
{
|
||||
public DungeonSchematic loadSchematic() throws InvalidSchematicException, FileNotFoundException {
|
||||
if (isInternal) {
|
||||
return DungeonSchematic.readFromResource(schematicPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return DungeonSchematic.readFromFile(schematicPath);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,15 +13,19 @@ import com.zixiken.dimdoors.config.DDProperties;
|
|||
import com.zixiken.dimdoors.core.DimLink;
|
||||
import com.zixiken.dimdoors.core.LinkType;
|
||||
import com.zixiken.dimdoors.core.PocketManager;
|
||||
import com.zixiken.dimdoors.helpers.BlockPosHelper;
|
||||
import com.zixiken.dimdoors.helpers.EnumFacingHelper;
|
||||
import com.zixiken.dimdoors.ticking.CustomLimboPopulator;
|
||||
import com.zixiken.dimdoors.ticking.MobMonolith;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntitySign;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
import com.zixiken.dimdoors.core.NewDimData;
|
||||
|
@ -93,7 +97,7 @@ public class DungeonSchematic extends Schematic {
|
|||
Blocks.end_portal_frame, Blocks.sandstone);applyFilter(finder);
|
||||
|
||||
//Flip the entrance's orientation to get the dungeon's orientation
|
||||
orientation = BlockRotator.transformMetadata(finder.getEntranceOrientation(), 2, Blocks.oak_door);
|
||||
orientation = EnumFacingHelper.getFacingFromBlockState(BlockRotator.transform(Blocks.oak_door.getDefaultState(), 2));
|
||||
|
||||
entranceDoorLocation = finder.getEntranceDoorLocation();
|
||||
exitDoorLocations = finder.getExitDoorLocations();
|
||||
|
@ -108,8 +112,7 @@ public class DungeonSchematic extends Schematic {
|
|||
applyFilter(standardizer);
|
||||
}
|
||||
|
||||
public void applyExportFilters(DDProperties properties)
|
||||
{
|
||||
public void applyExportFilters(DDProperties properties) {
|
||||
//Check if some block IDs assigned by Forge differ from our standard IDs
|
||||
//If so, change the IDs to standard values
|
||||
CompoundFilter standardizer = new CompoundFilter();
|
||||
|
@ -121,16 +124,12 @@ public class DungeonSchematic extends Schematic {
|
|||
applyFilter(standardizer);
|
||||
}
|
||||
|
||||
public static DungeonSchematic copyFromWorld(World world, int x, int y, int z, short width, short height, short length, boolean doCompactBounds)
|
||||
{
|
||||
return new DungeonSchematic(Schematic.copyFromWorld(world, x, y, z, width, height, length, doCompactBounds));
|
||||
public static DungeonSchematic copyFromWorld(World world, BlockPos pos, BlockPos size, boolean doCompactBounds) {
|
||||
return new DungeonSchematic(Schematic.copyFromWorld(world, pos, size, doCompactBounds));
|
||||
}
|
||||
|
||||
public void copyToWorld(World world, BlockPos pocketCenter, int targetOrientation, DimLink entryLink,
|
||||
Random random, DDProperties properties, boolean notifyClients)
|
||||
{
|
||||
if (notifyClients)
|
||||
{
|
||||
public void copyToWorld(World world, BlockPos pocketCenter, EnumFacing targetOrientation, DimLink entryLink, Random random, DDProperties properties, boolean notifyClients) {
|
||||
if (notifyClients) {
|
||||
copyToWorld(world, pocketCenter, targetOrientation, entryLink, random, properties, new WorldBlockSetter(false, true, false));
|
||||
}
|
||||
else
|
||||
|
@ -139,39 +138,32 @@ public class DungeonSchematic extends Schematic {
|
|||
}
|
||||
}
|
||||
|
||||
public void copyToWorld(World world, BlockPos pocketCenter, int targetOrientation, DimLink entryLink, Random random, DDProperties properties, IBlockSetter blockSetter)
|
||||
{
|
||||
public void copyToWorld(World world, BlockPos pocketCenter, EnumFacing targetOrientation, DimLink entryLink, Random random, DDProperties properties, IBlockSetter blockSetter) {
|
||||
//TODO: This function is an improvised solution so we can get the release moving. In the future,
|
||||
//we should generalize block transformations and implement support for them at the level of Schematic,
|
||||
//then just use that support from DungeonSchematic instead of making this local fix.
|
||||
//It might be easiest to support transformations using a WorldOperation
|
||||
|
||||
final int turnAngle = targetOrientation - this.orientation;
|
||||
EnumFacing turnAngle = EnumFacing.getHorizontal(targetOrientation.getHorizontalIndex() - orientation.getHorizontalIndex());
|
||||
|
||||
int index;
|
||||
int count;
|
||||
Block block;
|
||||
int blockMeta;
|
||||
IBlockState state;
|
||||
int dx, dy, dz;
|
||||
BlockPos pocketPoint = new BlockPos(0, 0, 0);
|
||||
|
||||
//Copy blocks and metadata into the world
|
||||
index = 0;
|
||||
for (dy = 0; dy < height; dy++)
|
||||
{
|
||||
for (dz = 0; dz < length; dz++)
|
||||
{
|
||||
for (dx = 0; dx < width; dx++)
|
||||
{
|
||||
pocketPoint.setX(dx);
|
||||
pocketPoint.setY(dy);
|
||||
pocketPoint.setZ(dz);
|
||||
block = blocks[index];
|
||||
for (dy = 0; dy < volume.getY(); dy++) {
|
||||
for (dz = 0; dz < volume.getZ(); dz++) {
|
||||
for (dx = 0; dx < volume.getX(); dx++) {
|
||||
pocketPoint = new BlockPos(dx, dy, dz);
|
||||
state = states[index];
|
||||
BlockRotator.transformPoint(pocketPoint, entranceDoorLocation, turnAngle, pocketCenter);
|
||||
blockMeta = BlockRotator.transformMetadata(metadata[index], turnAngle, block);
|
||||
state = BlockRotator.transform(states[index], turnAngle.getHorizontalIndex());
|
||||
|
||||
//In the future, we might want to make this more efficient by building whole chunks at a time
|
||||
blockSetter.setBlock(world, pocketPoint.getX(), pocketPoint.getY(), pocketPoint.getZ(), block, blockMeta);
|
||||
blockSetter.setBlock(world, pocketPoint, state);
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
@ -182,25 +174,23 @@ public class DungeonSchematic extends Schematic {
|
|||
{
|
||||
NBTTagCompound tileTag = (NBTTagCompound) tileEntities.getCompoundTagAt(index);
|
||||
//Rewrite its location to be in world coordinates
|
||||
pocketPoint.setX(tileTag.getInteger("x"));
|
||||
pocketPoint.setY(tileTag.getInteger("y"));
|
||||
pocketPoint.setZ(tileTag.getInteger("z"));
|
||||
pocketPoint = new BlockPos(tileTag.getInteger("x"), tileTag.getInteger("y"), tileTag.getInteger("z"));
|
||||
BlockRotator.transformPoint(pocketPoint, entranceDoorLocation, turnAngle, pocketCenter);
|
||||
tileTag.setInteger("x", pocketPoint.getX());
|
||||
tileTag.setInteger("y", pocketPoint.getY());
|
||||
tileTag.setInteger("z", pocketPoint.getZ());
|
||||
//Load the tile entity and put it in the world
|
||||
world.setTileEntity(pocketPoint.getX(), pocketPoint.getY(), pocketPoint.getZ(), TileEntity.createAndLoadEntity(tileTag));
|
||||
world.setTileEntity(pocketPoint, TileEntity.createAndLoadEntity(tileTag));
|
||||
}
|
||||
|
||||
setUpDungeon(PocketManager.createDimensionData(world), world, pocketCenter, turnAngle, entryLink, random, properties, blockSetter);
|
||||
}
|
||||
|
||||
private void setUpDungeon(NewDimData dimension, World world, BlockPos pocketCenter, int turnAngle, DimLink entryLink, Random random, DDProperties properties, IBlockSetter blockSetter)
|
||||
private void setUpDungeon(NewDimData dimension, World world, BlockPos pocketCenter, EnumFacing turnAngle, DimLink entryLink, Random random, DDProperties properties, IBlockSetter blockSetter)
|
||||
{
|
||||
//Transform dungeon corners
|
||||
BlockPos minCorner = new BlockPos(0, 0, 0);
|
||||
BlockPos maxCorner = new BlockPos(width - 1, height - 1, length - 1);
|
||||
BlockPos maxCorner = new BlockPos(volume.subtract(BlockPosHelper.posFromSingleValue(1)));
|
||||
transformCorners(entranceDoorLocation, pocketCenter, turnAngle, minCorner, maxCorner);
|
||||
|
||||
//Fill empty chests and dispensers
|
||||
|
@ -211,21 +201,18 @@ public class DungeonSchematic extends Schematic {
|
|||
createEntranceReverseLink(world, dimension, pocketCenter, entryLink);
|
||||
|
||||
//Set up link data for dimensional doors
|
||||
for (BlockPos location : dimensionalDoorLocations)
|
||||
{
|
||||
for (BlockPos location : dimensionalDoorLocations) {
|
||||
createDimensionalDoorLink(world, dimension, location, entranceDoorLocation, turnAngle, pocketCenter);
|
||||
}
|
||||
|
||||
//Set up link data for exit door
|
||||
for (BlockPos location : exitDoorLocations)
|
||||
{
|
||||
for (BlockPos location : exitDoorLocations) {
|
||||
createExitDoorLink(world, dimension, location, entranceDoorLocation, turnAngle, pocketCenter, blockSetter);
|
||||
}
|
||||
|
||||
//Remove end portal frames and spawn Monoliths, if allowed
|
||||
boolean canSpawn = CustomLimboPopulator.isMobSpawningAllowed();
|
||||
for (BlockPos location : monolithSpawnLocations)
|
||||
{
|
||||
for (BlockPos location : monolithSpawnLocations) {
|
||||
spawnMonolith(world, location, entranceDoorLocation, turnAngle, pocketCenter, canSpawn, blockSetter);
|
||||
}
|
||||
|
||||
|
@ -234,82 +221,66 @@ public class DungeonSchematic extends Schematic {
|
|||
// approach to check - if the dungeon is rooted in the Nether, then it SHOULD be a Nether dungeon.
|
||||
// This isn't necessarily true if someone uses dd-rift to spawn a dungeon, but it should work under
|
||||
// normal use of the mod.
|
||||
if (dimension.root().id() == NETHER_DIMENSION_ID)
|
||||
{
|
||||
if (dimension.root().id() == NETHER_DIMENSION_ID) {
|
||||
writeDepthSign(world, pocketCenter, dimension.depth());
|
||||
}
|
||||
}
|
||||
|
||||
private static void transformCorners(BlockPos schematicEntrance, BlockPos pocketCenter, EnumFacing turnAngle, BlockPos minCorner, BlockPos maxCorner) {
|
||||
int temp;
|
||||
BlockPos temp;
|
||||
BlockRotator.transformPoint(minCorner, schematicEntrance, turnAngle, pocketCenter);
|
||||
BlockRotator.transformPoint(maxCorner, schematicEntrance, turnAngle, pocketCenter);
|
||||
if (minCorner.getX() > maxCorner.getX()) {
|
||||
temp = minCorner.getX();
|
||||
minCorner = new BlockPos(maxCorner.getX(), minCorner.getY(), minCorner.getZ());
|
||||
maxCorner = new BlockPos(temp, maxCorner.getY(), maxCorner.getZ());
|
||||
} if (minCorner.getY() > maxCorner.getY()) {
|
||||
temp = minCorner.getY();
|
||||
minCorner.setY(maxCorner.getY());
|
||||
maxCorner.setY(temp);
|
||||
} if (minCorner.getZ() > maxCorner.getZ()) {
|
||||
temp = minCorner.getZ();
|
||||
minCorner.setZ(maxCorner.getZ());
|
||||
maxCorner.setZ(temp);
|
||||
}
|
||||
|
||||
temp = BlockPosHelper.min(minCorner, maxCorner);
|
||||
maxCorner = BlockPosHelper.max(minCorner, maxCorner);
|
||||
minCorner = temp;
|
||||
}
|
||||
|
||||
private static void createEntranceReverseLink(World world, NewDimData dimension, BlockPos pocketCenter, DimLink entryLink)
|
||||
{
|
||||
int orientation = world.getBlockMetadata(pocketCenter.getX(), pocketCenter.getY() - 1, pocketCenter.getZ());
|
||||
DimLink reverseLink = dimension.createLink(pocketCenter.getX(), pocketCenter.getY(), pocketCenter.getZ(), LinkType.REVERSE, orientation);
|
||||
private static void createEntranceReverseLink(World world, NewDimData dimension, BlockPos pocketCenter, DimLink entryLink) {
|
||||
EnumFacing orientation = EnumFacingHelper.getFacingFromBlockState(world.getBlockState(pocketCenter.down()));
|
||||
DimLink reverseLink = dimension.createLink(pocketCenter, LinkType.REVERSE, orientation);
|
||||
Point4D destination = entryLink.source();
|
||||
NewDimData prevDim = PocketManager.getDimensionData(destination.getDimension());
|
||||
prevDim.setLinkDestination(reverseLink, destination.getX(), destination.getY(), destination.getZ());
|
||||
prevDim.setLinkDestination(reverseLink, destination.toBlockPos());
|
||||
initDoorTileEntity(world, pocketCenter);
|
||||
}
|
||||
|
||||
private static void createExitDoorLink(World world, NewDimData dimension, BlockPos point, BlockPos entrance, EnumFacing rotation, BlockPos pocketCenter, IBlockSetter blockSetter)
|
||||
private static void createExitDoorLink(World world, NewDimData dimension, BlockPos point, BlockPos entrance, EnumFacing rotation, BlockPos pocketCenter, IBlockSetter blockSetter) {
|
||||
//Transform the door's location to the pocket coordinate system
|
||||
BlockPos location = point;
|
||||
BlockRotator.transformPoint(location, entrance, rotation, pocketCenter);
|
||||
EnumFacing orientation = EnumFacingHelper.getFacingFromBlockState(world.getBlockState(location.down()));
|
||||
dimension.createLink(location, LinkType.DUNGEON_EXIT, orientation);
|
||||
//Replace the sandstone block under the exit door with the same block as the one underneath it
|
||||
location = location.down(3);
|
||||
|
||||
if (location.getY() >= 0) {
|
||||
IBlockState state = world.getBlockState(location);
|
||||
blockSetter.setBlock(world, location.up(), state);
|
||||
}
|
||||
|
||||
initDoorTileEntity(world, location);
|
||||
}
|
||||
|
||||
private static void createDimensionalDoorLink(World world, NewDimData dimension, BlockPos point, BlockPos entrance, EnumFacing rotation, BlockPos pocketCenter)
|
||||
{
|
||||
//Transform the door's location to the pocket coordinate system
|
||||
BlockPos location = point;
|
||||
BlockRotator.transformPoint(location, entrance, rotation, pocketCenter);
|
||||
int orientation = world.getBlockMetadata(location.getX(), location.getY() - 1, location.getZ());
|
||||
dimension.createLink(location.getX(), location.getY(), location.getZ(), LinkType.DUNGEON_EXIT, orientation);
|
||||
//Replace the sandstone block under the exit door with the same block as the one underneath it
|
||||
int x = location.getX();
|
||||
int y = location.getY() - 3;
|
||||
int z = location.getZ();
|
||||
if (y >= 0)
|
||||
{
|
||||
Block block = world.getBlock(x, y, z);
|
||||
int metadata = world.getBlockMetadata(x, y, z);
|
||||
blockSetter.setBlock(world, x, y + 1, z, block, metadata);
|
||||
}
|
||||
initDoorTileEntity(world, location);
|
||||
}
|
||||
|
||||
private static void createDimensionalDoorLink(World world, NewDimData dimension, BlockPos point, BlockPos entrance, int rotation, BlockPos pocketCenter)
|
||||
{
|
||||
//Transform the door's location to the pocket coordinate system
|
||||
BlockPos location = point.clone();
|
||||
BlockRotator.transformPoint(location, entrance, rotation, pocketCenter);
|
||||
int orientation = world.getBlockMetadata(location.getX(), location.getY() - 1, location.getZ());
|
||||
EnumFacing orientation = EnumFacingHelper.getFacingFromBlockState(world.getBlockState(location.down()));
|
||||
|
||||
dimension.createLink(location.getX(), location.getY(), location.getZ(), LinkType.DUNGEON, orientation);
|
||||
dimension.createLink(location, LinkType.DUNGEON, orientation);
|
||||
initDoorTileEntity(world, location);
|
||||
}
|
||||
|
||||
private static void spawnMonolith(World world, BlockPos point, BlockPos entrance, int rotation, BlockPos pocketCenter, boolean canSpawn, IBlockSetter blockSetter)
|
||||
{
|
||||
private static void spawnMonolith(World world, BlockPos point, BlockPos entrance, EnumFacing rotation, BlockPos pocketCenter, boolean canSpawn, IBlockSetter blockSetter) {
|
||||
//Transform the frame block's location to the pocket coordinate system
|
||||
BlockPos location = point.clone();
|
||||
BlockPos location = point;
|
||||
BlockRotator.transformPoint(location, entrance, rotation, pocketCenter);
|
||||
//Remove frame block
|
||||
blockSetter.setBlock(world, location.getX(), location.getY(), location.getZ(), Blocks.air, 0);
|
||||
blockSetter.setBlock(world, location, Blocks.air.getDefaultState());
|
||||
//Spawn Monolith
|
||||
if (canSpawn)
|
||||
{
|
||||
if (canSpawn) {
|
||||
Entity mob = new MobMonolith(world);
|
||||
mob.setLocationAndAngles(location.getX(), location.getY(), location.getZ(), 1, 1);
|
||||
world.spawnEntityInWorld(mob);
|
||||
|
@ -318,43 +289,34 @@ public class DungeonSchematic extends Schematic {
|
|||
|
||||
private static void initDoorTileEntity(World world, BlockPos point)
|
||||
{
|
||||
Block door = world.getBlock(point.getX(), point.getY(), point.getZ());
|
||||
Block door2 = world.getBlock(point.getX(), point.getY() - 1, point.getZ());
|
||||
IBlockState door = world.getBlockState(point);
|
||||
IBlockState door2 = world.getBlockState(point.down());
|
||||
|
||||
if (door instanceof IDimDoor && door2 instanceof IDimDoor)
|
||||
{
|
||||
((IDimDoor) door).initDoorTE(world, point.getX(), point.getY(), point.getZ());
|
||||
((IDimDoor) door).initDoorTE(world, point.getX(), point.getY() - 1, point.getZ());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (door instanceof IDimDoor && door2 instanceof IDimDoor) {
|
||||
((IDimDoor) door).initDoorTE(world, point);
|
||||
((IDimDoor) door).initDoorTE(world, point.down());
|
||||
} else {
|
||||
throw new IllegalArgumentException("Tried to init a dim door TE on a block that isnt a Dim Door!!");
|
||||
}
|
||||
}
|
||||
|
||||
private static void writeDepthSign(World world, BlockPos pocketCenter, int depth)
|
||||
{
|
||||
private static void writeDepthSign(World world, BlockPos pocketCenter, int depth) {
|
||||
final int SEARCH_RANGE = 6;
|
||||
|
||||
int x, y, z;
|
||||
BlockPos pos;
|
||||
Block block;
|
||||
int dx, dy, dz;
|
||||
|
||||
for (dy = SEARCH_RANGE; dy >= -SEARCH_RANGE; dy--)
|
||||
{
|
||||
for (dz = -SEARCH_RANGE; dz <= SEARCH_RANGE; dz++)
|
||||
{
|
||||
for (dx = -SEARCH_RANGE; dx <= SEARCH_RANGE; dx++)
|
||||
{
|
||||
x = pocketCenter.getX() + dx;
|
||||
y = pocketCenter.getY() + dy;
|
||||
z = pocketCenter.getZ() + dz;
|
||||
block = world.getBlock(x, y, z);
|
||||
if (block == Blocks.wall_sign || block == Blocks.standing_sign)
|
||||
{
|
||||
for (dy = SEARCH_RANGE; dy >= -SEARCH_RANGE; dy--) {
|
||||
for (dz = -SEARCH_RANGE; dz <= SEARCH_RANGE; dz++) {
|
||||
for (dx = -SEARCH_RANGE; dx <= SEARCH_RANGE; dx++) {
|
||||
pos = pocketCenter.add(dx, dy, dz);
|
||||
|
||||
block = world.getBlockState(pos).getBlock();
|
||||
if (block == Blocks.wall_sign || block == Blocks.standing_sign) {
|
||||
TileEntitySign signEntity = new TileEntitySign();
|
||||
signEntity.signText[1] = "Level " + depth;
|
||||
world.setTileEntity(x, y, z, signEntity);
|
||||
signEntity.signText[1] = new ChatComponentText("Level " + depth);
|
||||
world.setTileEntity(pocketCenter, signEntity);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,52 +4,45 @@ import java.util.Random;
|
|||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityChest;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import com.zixiken.dimdoors.DDLoot;
|
||||
import com.zixiken.dimdoors.config.DDProperties;
|
||||
import com.zixiken.dimdoors.schematic.WorldOperation;
|
||||
|
||||
public class FillContainersOperation extends WorldOperation
|
||||
{
|
||||
public class FillContainersOperation extends WorldOperation {
|
||||
private Random random;
|
||||
private DDProperties properties;
|
||||
|
||||
private static final int GRAVE_CHEST_CHANCE = 1;
|
||||
private static final int MAX_GRAVE_CHEST_CHANCE = 6;
|
||||
|
||||
public FillContainersOperation(Random random, DDProperties properties)
|
||||
{
|
||||
public FillContainersOperation(Random random, DDProperties properties) {
|
||||
super("FillContainersOperation");
|
||||
this.random = random;
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean applyToBlock(World world, int x, int y, int z)
|
||||
{
|
||||
Block block = world.getBlock(x, y, z);
|
||||
protected boolean applyToBlock(World world, BlockPos pos) {
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
|
||||
// Fill empty chests and dispensers
|
||||
if (block instanceof BlockContainer)
|
||||
{
|
||||
TileEntity tileEntity = world.getTileEntity(x, y, z);
|
||||
if (state.getBlock() instanceof BlockContainer) {
|
||||
TileEntity tileEntity = world.getTileEntity(pos);
|
||||
|
||||
// Fill chests
|
||||
if (tileEntity instanceof TileEntityChest)
|
||||
{
|
||||
if (tileEntity instanceof TileEntityChest) {
|
||||
TileEntityChest chest = (TileEntityChest) tileEntity;
|
||||
if (isInventoryEmpty(chest))
|
||||
{
|
||||
if (isInventoryEmpty(chest)) {
|
||||
// Randomly choose whether this will be a regular dungeon chest or a grave chest
|
||||
if (random.nextInt(MAX_GRAVE_CHEST_CHANCE) < GRAVE_CHEST_CHANCE)
|
||||
{
|
||||
if (random.nextInt(MAX_GRAVE_CHEST_CHANCE) < GRAVE_CHEST_CHANCE) {
|
||||
DDLoot.fillGraveChest(chest, random, properties);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
DDLoot.generateChestContents(DDLoot.dungeonChestInfo, chest, random);
|
||||
}
|
||||
}
|
||||
|
@ -58,13 +51,10 @@ public class FillContainersOperation extends WorldOperation
|
|||
return true;
|
||||
}
|
||||
|
||||
private static boolean isInventoryEmpty(IInventory inventory)
|
||||
{
|
||||
private static boolean isInventoryEmpty(IInventory inventory) {
|
||||
int size = inventory.getSizeInventory();
|
||||
for (int index = 0; index < size; index++)
|
||||
{
|
||||
if (inventory.getStackInSlot(index) != null)
|
||||
{
|
||||
for (int index = 0; index < size; index++) {
|
||||
if (inventory.getStackInSlot(index) != null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,8 +11,7 @@ public class ModBlockFilter extends SchematicFilter {
|
|||
private List<Block> exceptions;
|
||||
private IBlockState replacementState;
|
||||
|
||||
public ModBlockFilter(List<Block> exceptions, IBlockState state)
|
||||
{
|
||||
public ModBlockFilter(List<Block> exceptions, IBlockState state) {
|
||||
super("ModBlockFilter");
|
||||
this.exceptions = exceptions;
|
||||
this.replacementState = state;
|
||||
|
@ -38,8 +37,7 @@ public class ModBlockFilter extends SchematicFilter {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected boolean terminates()
|
||||
{
|
||||
protected boolean terminates() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,9 +2,6 @@ package com.zixiken.dimdoors.helpers;
|
|||
|
||||
import net.minecraft.util.BlockPos;
|
||||
|
||||
/**
|
||||
* Created by Jared Johnson on 6/22/2016.
|
||||
*/
|
||||
public class BlockPosHelper {
|
||||
public static boolean between(BlockPos pos, BlockPos min, BlockPos max) {
|
||||
return ((min.getX() <= pos.getX() && pos.getX() <= max.getX()) &&
|
||||
|
@ -27,4 +24,12 @@ public class BlockPosHelper {
|
|||
public static boolean lessThan(BlockPos a, BlockPos b) {
|
||||
return (a.getX() < b.getX() && a.getY() < b.getY() && a.getZ() < b.getZ());
|
||||
}
|
||||
|
||||
public static boolean lessThanOrEqual(BlockPos a, BlockPos b) {
|
||||
return (a.getX() <= b.getX() && a.getY() <= b.getY() && a.getZ() <= b.getZ());
|
||||
}
|
||||
|
||||
public static BlockPos posFromSingleValue(int value) {
|
||||
return new BlockPos(value, value, value);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,410 +0,0 @@
|
|||
package com.zixiken.dimdoors.helpers;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
|
||||
public class BlockRotationHelper
|
||||
{
|
||||
public HashMap<Integer,HashMap<Block,HashMap<Integer,Integer>>> rotationMappings = new HashMap<Integer,HashMap<Block,HashMap<Integer,Integer>>>();
|
||||
|
||||
public BlockRotationHelper()
|
||||
{
|
||||
this.InitializeRotationMap();
|
||||
}
|
||||
|
||||
public void InitializeRotationMap()
|
||||
{
|
||||
HashMap<Block,HashMap<Integer, Integer>> orientation0 = new HashMap<Block,HashMap<Integer, Integer>>();
|
||||
|
||||
HashMap<Integer,Integer> stairs0 = new HashMap<Integer,Integer>();
|
||||
|
||||
stairs0.put(0, 2);
|
||||
stairs0.put(1, 3);
|
||||
stairs0.put(2, 1);
|
||||
stairs0.put(3, 0);
|
||||
stairs0.put(7, 4);
|
||||
stairs0.put(6, 5);
|
||||
stairs0.put(5, 7);
|
||||
stairs0.put(4, 6);
|
||||
|
||||
HashMap<Integer,Integer> chestsLadders0 = new HashMap<Integer,Integer>();
|
||||
|
||||
chestsLadders0.put(2, 5);
|
||||
chestsLadders0.put(3, 4);
|
||||
chestsLadders0.put(4, 2);
|
||||
chestsLadders0.put(5, 3);
|
||||
|
||||
HashMap<Integer,Integer> vine0 = new HashMap<Integer,Integer>();
|
||||
|
||||
vine0.put(1, 2);
|
||||
vine0.put(2, 4);
|
||||
vine0.put(4, 8);
|
||||
vine0.put(8, 1);
|
||||
|
||||
HashMap<Integer,Integer> leverButtonTorch0 = new HashMap<Integer,Integer>();
|
||||
|
||||
leverButtonTorch0.put(12, 9);
|
||||
leverButtonTorch0.put(11, 10);
|
||||
leverButtonTorch0.put(10, 12);
|
||||
leverButtonTorch0.put(9, 11);
|
||||
leverButtonTorch0.put(2, 4);
|
||||
leverButtonTorch0.put(3, 2);
|
||||
leverButtonTorch0.put(1, 3);
|
||||
leverButtonTorch0.put(4, 1);
|
||||
|
||||
HashMap<Integer,Integer> pistonDropperDispenser0 = new HashMap<Integer,Integer>();
|
||||
|
||||
pistonDropperDispenser0.put(4, 2);
|
||||
pistonDropperDispenser0.put(5, 3);
|
||||
pistonDropperDispenser0.put(13, 11);
|
||||
pistonDropperDispenser0.put(3, 4);
|
||||
pistonDropperDispenser0.put(2, 5);
|
||||
pistonDropperDispenser0.put(11, 12);
|
||||
pistonDropperDispenser0.put(10, 13);
|
||||
pistonDropperDispenser0.put(12, 10);
|
||||
|
||||
HashMap<Integer,Integer> repeaterComparatorDoorTripwire0 = new HashMap<Integer,Integer>();
|
||||
|
||||
repeaterComparatorDoorTripwire0.put(0, 1);
|
||||
repeaterComparatorDoorTripwire0.put(1, 2);
|
||||
repeaterComparatorDoorTripwire0.put(2, 3);
|
||||
repeaterComparatorDoorTripwire0.put(3, 0);
|
||||
repeaterComparatorDoorTripwire0.put(4, 5);
|
||||
repeaterComparatorDoorTripwire0.put(5, 6);
|
||||
repeaterComparatorDoorTripwire0.put(6, 7);
|
||||
repeaterComparatorDoorTripwire0.put(7, 4);
|
||||
repeaterComparatorDoorTripwire0.put(8, 9);
|
||||
repeaterComparatorDoorTripwire0.put(9, 10);
|
||||
repeaterComparatorDoorTripwire0.put(10, 11);
|
||||
repeaterComparatorDoorTripwire0.put(11, 8);
|
||||
repeaterComparatorDoorTripwire0.put(12, 13);
|
||||
repeaterComparatorDoorTripwire0.put(13, 14);
|
||||
repeaterComparatorDoorTripwire0.put(14, 15);
|
||||
repeaterComparatorDoorTripwire0.put(15, 12);
|
||||
|
||||
HashMap<Integer,Integer> rails0 = new HashMap<Integer,Integer>();
|
||||
rails0.put(0, 1);
|
||||
rails0.put(1, 0);
|
||||
rails0.put(8, 9);
|
||||
rails0.put(9, 6);
|
||||
rails0.put(6, 7);
|
||||
rails0.put(7, 8);
|
||||
|
||||
|
||||
HashMap<Integer,Integer> railsSpecial0 = new HashMap<Integer,Integer>();
|
||||
railsSpecial0.put(0, 1);
|
||||
railsSpecial0.put(1, 0);
|
||||
railsSpecial0.put(8, 9);
|
||||
railsSpecial0.put(9, 8);
|
||||
|
||||
|
||||
HashMap<Block,HashMap<Integer, Integer>> orientation1 = new HashMap<Block,HashMap<Integer, Integer>>();
|
||||
|
||||
HashMap<Integer,Integer> stairs1 = new HashMap<Integer,Integer>();
|
||||
|
||||
stairs1.put(0, 1);
|
||||
stairs1.put(1, 0);
|
||||
stairs1.put(2, 3);
|
||||
stairs1.put(3, 2);
|
||||
stairs1.put(7, 6);
|
||||
stairs1.put(6, 7);
|
||||
stairs1.put(5, 4);
|
||||
stairs1.put(4, 5);
|
||||
|
||||
HashMap<Integer,Integer> chestsLadders1 = new HashMap<Integer,Integer>();
|
||||
|
||||
chestsLadders1.put(2, 3);
|
||||
chestsLadders1.put(3, 2);
|
||||
chestsLadders1.put(4, 5);
|
||||
chestsLadders1.put(5, 4);
|
||||
|
||||
HashMap<Integer,Integer> vine1 = new HashMap<Integer,Integer>();
|
||||
|
||||
vine1.put(1, 4);
|
||||
vine1.put(2, 8);
|
||||
vine1.put(4, 1);
|
||||
vine1.put(8, 2);
|
||||
|
||||
HashMap<Integer,Integer> leverButtonTorch1 = new HashMap<Integer,Integer>();
|
||||
|
||||
leverButtonTorch1.put(12, 9);
|
||||
leverButtonTorch1.put(11, 10);
|
||||
leverButtonTorch1.put(10, 12);
|
||||
leverButtonTorch1.put(9, 11);
|
||||
leverButtonTorch1.put(2, 4);
|
||||
leverButtonTorch1.put(3, 2);
|
||||
leverButtonTorch1.put(1, 3);
|
||||
leverButtonTorch1.put(4, 1);
|
||||
|
||||
HashMap<Integer,Integer> pistonDropperDispenser1 = new HashMap<Integer,Integer>();
|
||||
|
||||
pistonDropperDispenser1.put(12, 11);
|
||||
pistonDropperDispenser1.put(11, 12);
|
||||
pistonDropperDispenser1.put(10, 9);
|
||||
pistonDropperDispenser1.put(9, 10);
|
||||
pistonDropperDispenser1.put(2, 1);
|
||||
pistonDropperDispenser1.put(3, 4);
|
||||
pistonDropperDispenser1.put(1, 2);
|
||||
pistonDropperDispenser1.put(4,3);
|
||||
|
||||
|
||||
HashMap<Integer,Integer> repeaterComparatorDoorTripwire1 = new HashMap<Integer,Integer>();
|
||||
|
||||
repeaterComparatorDoorTripwire1.put(0, 2);
|
||||
repeaterComparatorDoorTripwire1.put(1, 3);
|
||||
repeaterComparatorDoorTripwire1.put(2, 0);
|
||||
repeaterComparatorDoorTripwire1.put(3, 1);
|
||||
repeaterComparatorDoorTripwire1.put(4, 6);
|
||||
repeaterComparatorDoorTripwire1.put(5, 7);
|
||||
repeaterComparatorDoorTripwire1.put(6, 4);
|
||||
repeaterComparatorDoorTripwire1.put(7, 5);
|
||||
repeaterComparatorDoorTripwire1.put(8, 10);
|
||||
repeaterComparatorDoorTripwire1.put(9, 11);
|
||||
repeaterComparatorDoorTripwire1.put(10, 8);
|
||||
repeaterComparatorDoorTripwire1.put(11, 9);
|
||||
repeaterComparatorDoorTripwire1.put(12, 14);
|
||||
repeaterComparatorDoorTripwire1.put(13, 15);
|
||||
repeaterComparatorDoorTripwire1.put(14, 12);
|
||||
repeaterComparatorDoorTripwire1.put(15, 13);
|
||||
|
||||
HashMap<Integer,Integer> rails1 = new HashMap<Integer,Integer>();
|
||||
rails1.put(0, 0);
|
||||
rails1.put(1, 1);
|
||||
rails1.put(8, 6);
|
||||
rails1.put(9, 7);
|
||||
rails1.put(6, 8);
|
||||
rails1.put(7, 9);
|
||||
|
||||
|
||||
HashMap<Integer,Integer> railsSpecial1 = new HashMap<Integer,Integer>();
|
||||
railsSpecial1.put(1, 1);
|
||||
railsSpecial1.put(0, 0);
|
||||
railsSpecial1.put(8, 8);
|
||||
railsSpecial1.put(9, 9);
|
||||
|
||||
HashMap<Block,HashMap<Integer, Integer>> orientation2 = new HashMap<Block,HashMap<Integer, Integer>>();
|
||||
|
||||
HashMap<Integer,Integer> stairs2 = new HashMap<Integer,Integer>();
|
||||
|
||||
stairs2.put(2, 0);
|
||||
stairs2.put(3, 1);
|
||||
stairs2.put(1, 2);
|
||||
stairs2.put(0, 3);
|
||||
stairs2.put(4, 7);
|
||||
stairs2.put(5, 6);
|
||||
stairs2.put(7, 5);
|
||||
stairs2.put(6, 4);
|
||||
|
||||
HashMap<Integer,Integer> chestsLadders2 = new HashMap<Integer,Integer>();
|
||||
|
||||
chestsLadders2.put(2, 4);
|
||||
chestsLadders2.put(3, 5);
|
||||
chestsLadders2.put(4, 3);
|
||||
chestsLadders2.put(5, 2);
|
||||
|
||||
HashMap<Integer,Integer> vine2 = new HashMap<Integer,Integer>();
|
||||
|
||||
vine2.put(1, 8);
|
||||
vine2.put(2, 1);
|
||||
vine2.put(4, 2);
|
||||
vine2.put(8, 4);
|
||||
|
||||
HashMap<Integer,Integer> leverButtonTorch2 = new HashMap<Integer,Integer>();
|
||||
|
||||
leverButtonTorch2.put(9, 12);
|
||||
leverButtonTorch2.put(10, 11);
|
||||
leverButtonTorch2.put(12, 10);
|
||||
leverButtonTorch2.put(11, 9);
|
||||
leverButtonTorch2.put(4, 2);
|
||||
leverButtonTorch2.put(2, 3);
|
||||
leverButtonTorch2.put(3, 1);
|
||||
leverButtonTorch2.put(1, 4);
|
||||
|
||||
HashMap<Integer,Integer> pistonDropperDispenser2 = new HashMap<Integer,Integer>();
|
||||
|
||||
pistonDropperDispenser2.put(2, 4);
|
||||
pistonDropperDispenser2.put(3, 5);
|
||||
pistonDropperDispenser2.put(11, 13);
|
||||
pistonDropperDispenser2.put(10, 12);
|
||||
pistonDropperDispenser2.put(4, 3);
|
||||
pistonDropperDispenser2.put(5, 2);
|
||||
pistonDropperDispenser2.put(12, 11);
|
||||
pistonDropperDispenser2.put(13,10);
|
||||
|
||||
|
||||
HashMap<Integer,Integer> repeaterComparatorDoorTripwire2 = new HashMap<Integer,Integer>();
|
||||
|
||||
repeaterComparatorDoorTripwire2.put(1, 0);
|
||||
repeaterComparatorDoorTripwire2.put(2, 1);
|
||||
repeaterComparatorDoorTripwire2.put(3, 2);
|
||||
repeaterComparatorDoorTripwire2.put(0, 3);
|
||||
repeaterComparatorDoorTripwire2.put(5, 4);
|
||||
repeaterComparatorDoorTripwire2.put(6, 5);
|
||||
repeaterComparatorDoorTripwire2.put(7, 6);
|
||||
repeaterComparatorDoorTripwire2.put(4, 7);
|
||||
repeaterComparatorDoorTripwire2.put(9, 8);
|
||||
repeaterComparatorDoorTripwire2.put(10, 9);
|
||||
repeaterComparatorDoorTripwire2.put(11, 10);
|
||||
repeaterComparatorDoorTripwire2.put(8, 11);
|
||||
repeaterComparatorDoorTripwire2.put(13, 12);
|
||||
repeaterComparatorDoorTripwire2.put(14, 13);
|
||||
repeaterComparatorDoorTripwire2.put(15, 14);
|
||||
repeaterComparatorDoorTripwire2.put(12, 15);
|
||||
|
||||
HashMap<Integer,Integer> rails2 = new HashMap<Integer,Integer>();
|
||||
rails2.put(0, 1);
|
||||
rails2.put(1, 0);
|
||||
rails2.put(8, 7);
|
||||
rails2.put(9, 8);
|
||||
rails2.put(6, 9);
|
||||
rails2.put(7, 6);
|
||||
|
||||
|
||||
HashMap<Integer,Integer> railsSpecial2 = new HashMap<Integer,Integer>();
|
||||
railsSpecial2.put(0, 1);
|
||||
railsSpecial2.put(1, 0);
|
||||
railsSpecial2.put(8, 9);
|
||||
railsSpecial2.put(9, 8);
|
||||
|
||||
|
||||
|
||||
|
||||
orientation0.put(Blocks.brick_stairs, stairs0);
|
||||
orientation0.put(Blocks.stone_stairs, stairs0);
|
||||
orientation0.put(Blocks.nether_brick_stairs, stairs0);
|
||||
orientation0.put(Blocks.quartz_stairs, stairs0);
|
||||
orientation0.put(Blocks.sandstone_stairs, stairs0);
|
||||
orientation0.put(Blocks.stone_brick_stairs, stairs0);
|
||||
orientation0.put(Blocks.birch_stairs, stairs0);
|
||||
orientation0.put(Blocks.jungle_stairs, stairs0);
|
||||
orientation0.put(Blocks.oak_stairs, stairs0);
|
||||
orientation0.put(Blocks.spruce_stairs, stairs0);
|
||||
orientation0.put(Blocks.brick_stairs, stairs0);
|
||||
orientation0.put(Blocks.vine, vine0);
|
||||
orientation0.put(Blocks.chest, chestsLadders0);
|
||||
orientation0.put(Blocks.trapped_chest, chestsLadders0);
|
||||
orientation0.put(Blocks.ladder, chestsLadders0);
|
||||
orientation0.put(Blocks.lever, leverButtonTorch0);
|
||||
orientation0.put(Blocks.stone_button, leverButtonTorch0);
|
||||
orientation0.put(Blocks.wooden_button, leverButtonTorch0);
|
||||
orientation0.put(Blocks.redstone_torch, leverButtonTorch0);
|
||||
orientation0.put(Blocks.unlit_redstone_torch, leverButtonTorch0);
|
||||
orientation0.put(Blocks.torch, leverButtonTorch0);
|
||||
orientation0.put(Blocks.piston,pistonDropperDispenser0);
|
||||
orientation0.put(Blocks.piston_head,pistonDropperDispenser0);
|
||||
orientation0.put(Blocks.piston_extension,pistonDropperDispenser0);
|
||||
orientation0.put(Blocks.sticky_piston,pistonDropperDispenser0);
|
||||
orientation0.put(Blocks.dropper,pistonDropperDispenser0);
|
||||
orientation0.put(Blocks.dispenser,pistonDropperDispenser0);
|
||||
orientation0.put(Blocks.powered_comparator,pistonDropperDispenser0);
|
||||
orientation0.put(Blocks.unpowered_comparator,pistonDropperDispenser0);
|
||||
orientation0.put(Blocks.powered_repeater,pistonDropperDispenser0);
|
||||
orientation0.put(Blocks.unpowered_repeater,pistonDropperDispenser0);
|
||||
orientation0.put(Blocks.wooden_door,pistonDropperDispenser0);
|
||||
orientation0.put(Blocks.iron_door,pistonDropperDispenser0);
|
||||
orientation0.put(Blocks.tripwire_hook,pistonDropperDispenser0);
|
||||
orientation0.put(Blocks.detector_rail,railsSpecial0);
|
||||
orientation0.put(Blocks.activator_rail,railsSpecial0);
|
||||
orientation0.put(Blocks.golden_rail,railsSpecial0);
|
||||
orientation0.put(Blocks.rail,rails0);
|
||||
|
||||
orientation1.put(Blocks.brick_stairs, stairs1);
|
||||
orientation1.put(Blocks.stone_stairs, stairs1);
|
||||
orientation1.put(Blocks.nether_brick_stairs, stairs1);
|
||||
orientation1.put(Blocks.quartz_stairs, stairs1);
|
||||
orientation1.put(Blocks.sandstone_stairs, stairs1);
|
||||
orientation1.put(Blocks.stone_brick_stairs, stairs1);
|
||||
orientation1.put(Blocks.birch_stairs, stairs1);
|
||||
orientation1.put(Blocks.jungle_stairs, stairs1);
|
||||
orientation1.put(Blocks.oak_stairs, stairs1);
|
||||
orientation1.put(Blocks.spruce_stairs, stairs1);
|
||||
orientation1.put(Blocks.vine, vine1);
|
||||
orientation1.put(Blocks.chest, chestsLadders1);
|
||||
orientation1.put(Blocks.trapped_chest, chestsLadders1);
|
||||
orientation1.put(Blocks.ladder, chestsLadders1);
|
||||
orientation1.put(Blocks.lever, leverButtonTorch1);
|
||||
orientation1.put(Blocks.stone_button, leverButtonTorch1);
|
||||
orientation1.put(Blocks.wooden_button, leverButtonTorch1);
|
||||
orientation1.put(Blocks.redstone_torch, leverButtonTorch1);
|
||||
orientation1.put(Blocks.unlit_redstone_torch, leverButtonTorch1);
|
||||
orientation1.put(Blocks.torch, leverButtonTorch1);
|
||||
orientation1.put(Blocks.piston,pistonDropperDispenser1);
|
||||
orientation1.put(Blocks.piston_head,pistonDropperDispenser1);
|
||||
orientation1.put(Blocks.piston_extension,pistonDropperDispenser1);
|
||||
orientation1.put(Blocks.sticky_piston,pistonDropperDispenser1);
|
||||
orientation1.put(Blocks.dropper,pistonDropperDispenser1);
|
||||
orientation1.put(Blocks.dispenser,pistonDropperDispenser1);
|
||||
orientation1.put(Blocks.powered_comparator,pistonDropperDispenser1);
|
||||
orientation1.put(Blocks.unpowered_comparator,pistonDropperDispenser1);
|
||||
orientation1.put(Blocks.powered_repeater,pistonDropperDispenser1);
|
||||
orientation1.put(Blocks.unpowered_repeater,pistonDropperDispenser1);
|
||||
orientation1.put(Blocks.wooden_door,pistonDropperDispenser1);
|
||||
orientation1.put(Blocks.iron_door,pistonDropperDispenser1);
|
||||
orientation1.put(Blocks.tripwire_hook,pistonDropperDispenser1);
|
||||
orientation1.put(Blocks.detector_rail,railsSpecial1);
|
||||
orientation1.put(Blocks.activator_rail,railsSpecial1);
|
||||
orientation1.put(Blocks.golden_rail,railsSpecial1);
|
||||
orientation1.put(Blocks.rail,rails1);
|
||||
|
||||
orientation2.put(Blocks.brick_stairs, stairs2);
|
||||
orientation2.put(Blocks.stone_stairs, stairs2);
|
||||
orientation2.put(Blocks.nether_brick_stairs, stairs2);
|
||||
orientation2.put(Blocks.quartz_stairs, stairs2);
|
||||
orientation2.put(Blocks.sandstone_stairs, stairs2);
|
||||
orientation2.put(Blocks.stone_brick_stairs, stairs2);
|
||||
orientation2.put(Blocks.birch_stairs, stairs2);
|
||||
orientation2.put(Blocks.jungle_stairs, stairs2);
|
||||
orientation2.put(Blocks.oak_stairs, stairs2);
|
||||
orientation2.put(Blocks.spruce_stairs, stairs2);
|
||||
orientation2.put(Blocks.vine, vine2);
|
||||
orientation2.put(Blocks.trapped_chest, chestsLadders2);
|
||||
orientation2.put(Blocks.ladder, chestsLadders2);
|
||||
orientation2.put(Blocks.lever, leverButtonTorch2);
|
||||
orientation2.put(Blocks.stone_button, leverButtonTorch2);
|
||||
orientation2.put(Blocks.wooden_button, leverButtonTorch2);
|
||||
orientation2.put(Blocks.redstone_torch, leverButtonTorch2);
|
||||
orientation2.put(Blocks.unlit_redstone_torch, leverButtonTorch2);
|
||||
orientation2.put(Blocks.torch, leverButtonTorch2);
|
||||
orientation2.put(Blocks.piston,pistonDropperDispenser2);
|
||||
orientation2.put(Blocks.piston_head,pistonDropperDispenser2);
|
||||
orientation2.put(Blocks.piston_extension,pistonDropperDispenser2);
|
||||
orientation2.put(Blocks.sticky_piston,pistonDropperDispenser2);
|
||||
orientation2.put(Blocks.dropper,pistonDropperDispenser2);
|
||||
orientation2.put(Blocks.dispenser,pistonDropperDispenser2);
|
||||
orientation2.put(Blocks.powered_comparator,pistonDropperDispenser2);
|
||||
orientation2.put(Blocks.unpowered_comparator,pistonDropperDispenser2);
|
||||
orientation2.put(Blocks.powered_repeater,pistonDropperDispenser2);
|
||||
orientation2.put(Blocks.unpowered_repeater,pistonDropperDispenser2);
|
||||
orientation2.put(Blocks.wooden_door,pistonDropperDispenser2);
|
||||
orientation2.put(Blocks.iron_door,pistonDropperDispenser2);
|
||||
orientation2.put(Blocks.tripwire_hook,pistonDropperDispenser2);
|
||||
orientation2.put(Blocks.detector_rail,railsSpecial2);
|
||||
orientation2.put(Blocks.activator_rail,railsSpecial2);
|
||||
orientation2.put(Blocks.golden_rail,railsSpecial2);
|
||||
orientation2.put(Blocks.rail,rails2);
|
||||
|
||||
this.rotationMappings.put(2, orientation2);
|
||||
this.rotationMappings.put(1, orientation1);
|
||||
this.rotationMappings.put(0, orientation0);
|
||||
}
|
||||
|
||||
public int getRotatedBlock(int metaData, int desiredOrientation, int blockID)
|
||||
{
|
||||
if(this.rotationMappings.containsKey(desiredOrientation))
|
||||
{
|
||||
if(this.rotationMappings.get(desiredOrientation).containsKey(blockID))
|
||||
{
|
||||
if(this.rotationMappings.get(desiredOrientation).get(blockID).containsKey(metaData))
|
||||
{
|
||||
return this.rotationMappings.get(desiredOrientation).get(blockID).get(metaData);
|
||||
}
|
||||
}
|
||||
}
|
||||
return metaData ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -40,12 +40,10 @@ public class ChunkLoaderHelper implements LoadingCallback {
|
|||
}
|
||||
}
|
||||
|
||||
public static Ticket createTicket(BlockPos pos, World world)
|
||||
{
|
||||
public static Ticket createTicket(BlockPos pos, World world) {
|
||||
NBTTagCompound data;
|
||||
Ticket ticket = ForgeChunkManager.requestTicket(DimDoors.instance, world, Type.NORMAL);
|
||||
if (ticket != null)
|
||||
{
|
||||
if (ticket != null) {
|
||||
data = ticket.getModData();
|
||||
data.setInteger("goldDimDoorX", pos.getX());
|
||||
data.setInteger("goldDimDoorY", pos.getY());
|
||||
|
|
|
@ -12,6 +12,7 @@ import com.zixiken.dimdoors.core.NewDimData;
|
|||
import com.zixiken.dimdoors.util.Point4D;
|
||||
import com.zixiken.dimdoors.watcher.ClientLinkData;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
public class Compactor
|
||||
{
|
||||
|
@ -72,7 +73,7 @@ public class Compactor
|
|||
for (int h = 0; h < linkCount; h++) {
|
||||
ClientLinkData link = ClientLinkData.read(input);
|
||||
Point4D source = link.point;
|
||||
dimension.createLink(source.getX(), source.getY(), source.getZ(), LinkType.CLIENT,0);
|
||||
dimension.createLink(source.toBlockPos(), LinkType.CLIENT, EnumFacing.getHorizontal(0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,8 @@ import com.zixiken.dimdoors.dungeon.pack.DungeonPack;
|
|||
import com.zixiken.dimdoors.dungeon.pack.DungeonPackConfig;
|
||||
import com.zixiken.dimdoors.dungeon.pack.DungeonPackConfigReader;
|
||||
import com.zixiken.dimdoors.items.ItemDimensionalDoor;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.WeightedRandom;
|
||||
import net.minecraft.world.World;
|
||||
import com.zixiken.dimdoors.core.NewDimData;
|
||||
|
@ -35,8 +37,7 @@ import com.zixiken.dimdoors.dungeon.pack.DungeonType;
|
|||
import com.zixiken.dimdoors.util.FileFilters;
|
||||
import com.zixiken.dimdoors.util.WeightedContainer;
|
||||
|
||||
public class DungeonHelper
|
||||
{
|
||||
public class DungeonHelper {
|
||||
private static DungeonHelper instance = null;
|
||||
private static DDProperties properties = null;
|
||||
|
||||
|
@ -62,9 +63,7 @@ public class DungeonHelper
|
|||
public static final int MAX_DUNGEON_WEIGHT = 10000; //Used to prevent overflows and math breaking down
|
||||
|
||||
private static final int MAX_EXPORT_RADIUS = 50;
|
||||
public static final short MAX_DUNGEON_WIDTH = 2 * MAX_EXPORT_RADIUS + 1;
|
||||
public static final short MAX_DUNGEON_HEIGHT = MAX_DUNGEON_WIDTH;
|
||||
public static final short MAX_DUNGEON_LENGTH = MAX_DUNGEON_WIDTH;
|
||||
public static final BlockPos MAX_DUNGEON_SIZE = BlockPosHelper.posFromSingleValue(2 * MAX_EXPORT_RADIUS + 1);
|
||||
|
||||
private ArrayList<DungeonData> untaggedDungeons = new ArrayList<DungeonData>();
|
||||
private ArrayList<DungeonData> registeredDungeons = new ArrayList<DungeonData>();
|
||||
|
@ -76,8 +75,7 @@ public class DungeonHelper
|
|||
|
||||
private DungeonData defaultError;
|
||||
|
||||
private DungeonHelper()
|
||||
{
|
||||
private DungeonHelper() {
|
||||
//Load our reference to the DDProperties singleton
|
||||
if (properties == null)
|
||||
properties = DDProperties.instance();
|
||||
|
@ -85,24 +83,18 @@ public class DungeonHelper
|
|||
registerDungeons();
|
||||
}
|
||||
|
||||
public static DungeonHelper initialize()
|
||||
{
|
||||
if (instance == null)
|
||||
{
|
||||
public static DungeonHelper initialize() {
|
||||
if (instance == null) {
|
||||
instance = new DungeonHelper();
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
throw new IllegalStateException("Cannot initialize DungeonHelper twice");
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static DungeonHelper instance()
|
||||
{
|
||||
if (instance == null)
|
||||
{
|
||||
public static DungeonHelper instance() {
|
||||
if (instance == null) {
|
||||
//This is to prevent some frustrating bugs that could arise when classes
|
||||
//are loaded in the wrong order. Trust me, I had to squash a few...
|
||||
throw new IllegalStateException("Instance of DungeonHelper requested before initialization");
|
||||
|
@ -110,11 +102,9 @@ public class DungeonHelper
|
|||
return instance;
|
||||
}
|
||||
|
||||
private void registerDungeons()
|
||||
{
|
||||
private void registerDungeons() {
|
||||
File file = new File(properties.CustomSchematicDirectory);
|
||||
if (file.exists() || file.mkdir())
|
||||
{
|
||||
if (file.exists() || file.mkdir()) {
|
||||
copyfile.copyFile(DUNGEON_CREATION_GUIDE_SOURCE_PATH, file.getAbsolutePath() + "/How_to_add_dungeons.txt");
|
||||
}
|
||||
|
||||
|
@ -123,39 +113,30 @@ public class DungeonHelper
|
|||
registerCustomDungeons(properties.CustomSchematicDirectory, reader);
|
||||
}
|
||||
|
||||
private static DungeonPackConfig loadDungeonPackConfig(String configPath, String name, boolean isInternal, DungeonPackConfigReader reader)
|
||||
{
|
||||
try
|
||||
{
|
||||
private static DungeonPackConfig loadDungeonPackConfig(String configPath, String name, boolean isInternal, DungeonPackConfigReader reader) {
|
||||
try {
|
||||
DungeonPackConfig config;
|
||||
if (isInternal)
|
||||
{
|
||||
if (isInternal) {
|
||||
config = reader.readFromResource(configPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
config = reader.readFromFile(configPath);
|
||||
}
|
||||
config.setName(name);
|
||||
return config;
|
||||
}
|
||||
catch (FileNotFoundException e)
|
||||
{
|
||||
} catch (FileNotFoundException e) {
|
||||
System.err.println("Could not find a dungeon pack config file: " + configPath);
|
||||
}
|
||||
catch (Exception e) // handles IOException and ConfigurationProcessingException
|
||||
} catch (Exception e) // handles IOException and ConfigurationProcessingException
|
||||
{
|
||||
System.err.println(e.getMessage());
|
||||
if (e.getCause() != null)
|
||||
{
|
||||
if (e.getCause() != null) {
|
||||
System.err.println(e.getCause());
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private DungeonPack registerDungeonPack(String directory, Iterable<String> schematics, boolean isInternal, boolean verbose, DungeonPackConfigReader reader)
|
||||
{
|
||||
private DungeonPack registerDungeonPack(String directory, Iterable<String> schematics, boolean isInternal, boolean verbose, DungeonPackConfigReader reader) {
|
||||
//First determine the pack's name and validate it
|
||||
File packDirectory = new File(directory);
|
||||
String name = packDirectory.getName().toUpperCase();
|
||||
|
@ -166,22 +147,19 @@ public class DungeonHelper
|
|||
//or if a user is running Linux and has two directories with names differing only by capitalization.
|
||||
|
||||
DungeonPack pack = dungeonPackMapping.get(name);
|
||||
if (pack == null)
|
||||
{
|
||||
if (pack == null) {
|
||||
//Load the pack's configuration file
|
||||
|
||||
String configPath;
|
||||
if (isInternal)
|
||||
{
|
||||
if (isInternal) {
|
||||
configPath = directory + "/" + STANDARD_CONFIG_FILE_NAME;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
configPath = directory + File.separator + STANDARD_CONFIG_FILE_NAME;
|
||||
}
|
||||
|
||||
DungeonPackConfig config = loadDungeonPackConfig(configPath, name, isInternal, reader);
|
||||
if (config == null)
|
||||
{
|
||||
|
||||
if (config == null) {
|
||||
System.err.println("Could not load config file: " + configPath);
|
||||
return null;
|
||||
}
|
||||
|
@ -190,9 +168,7 @@ public class DungeonHelper
|
|||
pack = new DungeonPack(config);
|
||||
dungeonPackMapping.put(name, pack);
|
||||
dungeonPackList.add(pack);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
//Show a warning that there is a naming conflict but keep going. People can use this to extend
|
||||
//our built-in packs with custom schematics without tampering with our mod's JAR file.
|
||||
System.err.println("A dungeon pack has the same name as another pack that has already been loaded: " + directory);
|
||||
|
@ -200,119 +176,96 @@ public class DungeonHelper
|
|||
}
|
||||
|
||||
//Register the dungeons! ^_^
|
||||
for (String schematicPath : schematics)
|
||||
{
|
||||
for (String schematicPath : schematics) {
|
||||
registerDungeon(schematicPath, pack, isInternal, verbose);
|
||||
}
|
||||
|
||||
return pack;
|
||||
}
|
||||
|
||||
public List<DungeonData> getRegisteredDungeons()
|
||||
{
|
||||
public List<DungeonData> getRegisteredDungeons() {
|
||||
return Collections.unmodifiableList(this.registeredDungeons);
|
||||
}
|
||||
|
||||
public List<DungeonData> getUntaggedDungeons()
|
||||
{
|
||||
public List<DungeonData> getUntaggedDungeons() {
|
||||
return Collections.unmodifiableList(this.untaggedDungeons);
|
||||
}
|
||||
|
||||
public DungeonData getDefaultErrorDungeon()
|
||||
{
|
||||
public DungeonData getDefaultErrorDungeon() {
|
||||
return defaultError;
|
||||
}
|
||||
|
||||
public DungeonPack getDungeonPack(String name)
|
||||
{
|
||||
public DungeonPack getDungeonPack(String name) {
|
||||
//TODO: This function might be obsolete after the new save format is implemented.
|
||||
return dungeonPackMapping.get(name.toUpperCase());
|
||||
}
|
||||
|
||||
private DungeonPack getDimDungeonPack(NewDimData dimension)
|
||||
{
|
||||
private DungeonPack getDimDungeonPack(NewDimData dimension) {
|
||||
// TODO: Drop support for dim-based packs and switch to embedding the pack
|
||||
// in the link data itself. That would solve the dungeon pre-generation issue.
|
||||
// Gateways should dictate which packs are being used, not the dimensions.
|
||||
|
||||
DungeonPack pack;
|
||||
DungeonData dungeon = dimension.dungeon();
|
||||
if (dungeon != null)
|
||||
{
|
||||
|
||||
if (dungeon != null) {
|
||||
pack = dungeon.dungeonType().Owner;
|
||||
|
||||
//Make sure the pack isn't null. This can happen for dungeons with the special UNKNOWN type.
|
||||
if (pack == null)
|
||||
{
|
||||
if (pack == null) {
|
||||
pack = RuinsPack;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (dimension.id() == NETHER_DIMENSION_ID)
|
||||
{
|
||||
} else {
|
||||
if (dimension.id() == NETHER_DIMENSION_ID) {
|
||||
pack = NetherPack;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
pack = RuinsPack;
|
||||
}
|
||||
}
|
||||
return pack;
|
||||
}
|
||||
|
||||
public DimLink createCustomDungeonDoor(World world, int x, int y, int z)
|
||||
{
|
||||
public DimLink createCustomDungeonDoor(World world, BlockPos pos) {
|
||||
//Create a link above the specified position. Link to a new pocket dimension.
|
||||
NewDimData dimension = PocketManager.getDimensionData(world);
|
||||
DimLink link = dimension.createLink(x, y + 1, z, LinkType.POCKET, 3);
|
||||
DimLink link = dimension.createLink(pos.up(), LinkType.POCKET, EnumFacing.NORTH);
|
||||
|
||||
//Place a Warp Door linked to that pocket
|
||||
ItemDimensionalDoor.placeDoorBlock(world, x, y, z, 3, DimDoors.warpDoor);
|
||||
ItemDimensionalDoor.placeDoor(world, pos, EnumFacing.NORTH, DimDoors.warpDoor);
|
||||
|
||||
return link;
|
||||
}
|
||||
|
||||
public boolean validateDungeonType(String type, DungeonPack pack)
|
||||
{
|
||||
public boolean validateDungeonType(String type, DungeonPack pack) {
|
||||
return pack.isKnownType(type);
|
||||
}
|
||||
|
||||
public boolean validateSchematicName(String name, DungeonPack pack)
|
||||
{
|
||||
public boolean validateSchematicName(String name, DungeonPack pack) {
|
||||
String[] dungeonData;
|
||||
|
||||
if (!name.endsWith(SCHEMATIC_FILE_EXTENSION))
|
||||
return false;
|
||||
if (!name.endsWith(SCHEMATIC_FILE_EXTENSION)) return false;
|
||||
|
||||
dungeonData = name.substring(0, name.length() - SCHEMATIC_FILE_EXTENSION.length()).split("_");
|
||||
|
||||
//Check for a valid number of parts
|
||||
if (dungeonData.length < 3 || dungeonData.length > 4)
|
||||
return false;
|
||||
if (dungeonData.length < 3 || dungeonData.length > 4) return false;
|
||||
|
||||
//Check if the dungeon type is valid
|
||||
if (!validateDungeonType(dungeonData[0], pack))
|
||||
return false;
|
||||
if (!validateDungeonType(dungeonData[0], pack)) return false;
|
||||
|
||||
//Check if the name is valid
|
||||
if (!SCHEMATIC_NAME_PATTERN.matcher(dungeonData[1]).matches())
|
||||
return false;
|
||||
if (!SCHEMATIC_NAME_PATTERN.matcher(dungeonData[1]).matches()) return false;
|
||||
|
||||
//Check if the open/closed flag is present
|
||||
if (!dungeonData[2].equalsIgnoreCase("open") && !dungeonData[2].equalsIgnoreCase("closed"))
|
||||
return false;
|
||||
if (!dungeonData[2].equalsIgnoreCase("open") && !dungeonData[2].equalsIgnoreCase("closed")) return false;
|
||||
|
||||
//If the weight is present, check that it is valid
|
||||
if (dungeonData.length == 4)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (dungeonData.length == 4) {
|
||||
try {
|
||||
int weight = Integer.parseInt(dungeonData[3]);
|
||||
if (weight < MIN_DUNGEON_WEIGHT || weight > MAX_DUNGEON_WEIGHT)
|
||||
return false;
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
} catch (NumberFormatException e) {
|
||||
//Not a number
|
||||
return false;
|
||||
}
|
||||
|
@ -320,8 +273,7 @@ public class DungeonHelper
|
|||
return true;
|
||||
}
|
||||
|
||||
public void registerDungeon(String schematicPath, DungeonPack pack, boolean isInternal, boolean verbose)
|
||||
{
|
||||
public void registerDungeon(String schematicPath, DungeonPack pack, boolean isInternal, boolean verbose) {
|
||||
//We use schematicPath as the real path for internal files (inside our JAR) because it seems
|
||||
//that File tries to interpret it as a local drive path and mangles it.
|
||||
File schematicFile = new File(schematicPath);
|
||||
|
@ -329,8 +281,7 @@ public class DungeonHelper
|
|||
String path = isInternal ? schematicPath : schematicFile.getAbsolutePath();
|
||||
try
|
||||
{
|
||||
if (validateSchematicName(name, pack))
|
||||
{
|
||||
if (validateSchematicName(name, pack)) {
|
||||
//Strip off the file extension while splitting the file name
|
||||
String[] dungeonData = name.substring(0, name.length() - SCHEMATIC_FILE_EXTENSION.length()).split("_");
|
||||
|
||||
|
@ -343,30 +294,20 @@ public class DungeonHelper
|
|||
|
||||
pack.addDungeon(dungeon);
|
||||
registeredDungeons.add(dungeon);
|
||||
if (verbose)
|
||||
{
|
||||
System.out.println("Registered dungeon: " + name);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (verbose)
|
||||
{
|
||||
System.out.println("The following dungeon name is invalid for its given pack. It will not be generated naturally: " + schematicPath);
|
||||
}
|
||||
if (verbose) System.out.println("Registered dungeon: " + name);
|
||||
} else {
|
||||
if (verbose) System.out.println("The following dungeon name is invalid for its given pack. It will not be generated naturally: " + schematicPath);
|
||||
|
||||
untaggedDungeons.add(new DungeonData(path, isInternal, DungeonType.UNKNOWN_TYPE, true, DEFAULT_DUNGEON_WEIGHT));
|
||||
System.out.println("Registered untagged dungeon: " + name);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
} catch (Exception e) {
|
||||
System.err.println("Failed to register dungeon: " + name);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void registerCustomDungeons(String path, DungeonPackConfigReader reader)
|
||||
{
|
||||
private void registerCustomDungeons(String path, DungeonPackConfigReader reader) {
|
||||
File[] schematics;
|
||||
File[] packDirectories;
|
||||
File[] packFiles;
|
||||
|
@ -375,60 +316,44 @@ public class DungeonHelper
|
|||
FileFilter schematicFileFilter = new FileFilters.FileExtensionFilter(SCHEMATIC_FILE_EXTENSION);
|
||||
|
||||
//Check that the Ruins pack has been loaded
|
||||
if (RuinsPack == null)
|
||||
{
|
||||
throw new IllegalStateException("Cannot register custom dungeons without first loading the Ruins dungeon pack.");
|
||||
}
|
||||
if (RuinsPack == null) throw new IllegalStateException("Cannot register custom dungeons without first loading the Ruins dungeon pack.");
|
||||
|
||||
//Load stray dungeons directly in the custom dungeons folder
|
||||
schematics = directory.listFiles(schematicFileFilter);
|
||||
if (schematics != null)
|
||||
{
|
||||
for (File schematicFile : schematics)
|
||||
{
|
||||
if (schematics != null) {
|
||||
for (File schematicFile : schematics) {
|
||||
registerDungeon(schematicFile.getPath(), RuinsPack, false, true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
System.err.println("Could not retrieve the list of schematics stored in the custom dungeons directory!");
|
||||
}
|
||||
schematics = null; //Release memory
|
||||
|
||||
//Load the custom dungeon packs
|
||||
packDirectories = directory.listFiles(new FileFilters.DirectoryFilter());
|
||||
if (packDirectories != null)
|
||||
{
|
||||
if (packDirectories != null) {
|
||||
//Loop through each directory, which is assumed to be a dungeon pack
|
||||
for (File packDirectory : packDirectories)
|
||||
{
|
||||
for (File packDirectory : packDirectories) {
|
||||
//List the schematics within the dungeon pack directory
|
||||
packFiles = packDirectory.listFiles(schematicFileFilter);
|
||||
if (packFiles != null)
|
||||
{
|
||||
if (packFiles != null) {
|
||||
//Copy the pack files' paths into an ArrayList for use with registerDungeonPack()
|
||||
packFilePaths = new ArrayList<String>(packFiles.length);
|
||||
for (File packFile : packFiles)
|
||||
{
|
||||
for (File packFile : packFiles) {
|
||||
packFilePaths.add(packFile.getPath());
|
||||
}
|
||||
|
||||
registerDungeonPack(packDirectory.getAbsolutePath(), packFilePaths, false, true, reader);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
System.err.println("Could not retrieve the list of schematics in a dungeon pack: " + packDirectory.getPath());
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
System.err.println("Could not retrieve the list of dungeon pack directories in the custom dungeons directory!");
|
||||
}
|
||||
}
|
||||
|
||||
private void registerBundledDungeons(DungeonPackConfigReader reader)
|
||||
{
|
||||
private void registerBundledDungeons(DungeonPackConfigReader reader) {
|
||||
//Register the core schematics
|
||||
//These are used for debugging and in case of unusual errors while loading dungeons
|
||||
defaultError = new DungeonData(DEFAULT_ERROR_SCHEMATIC_PATH, true, DungeonType.UNKNOWN_TYPE, true, DEFAULT_DUNGEON_WEIGHT);
|
||||
|
@ -440,98 +365,73 @@ public class DungeonHelper
|
|||
System.out.println("Finished registering bundled dungeon packs");
|
||||
}
|
||||
|
||||
private DungeonPack registerBundledPack(String name, DungeonPackConfigReader reader)
|
||||
{
|
||||
private DungeonPack registerBundledPack(String name, DungeonPackConfigReader reader) {
|
||||
System.out.println("Registering bundled dungeon pack: " + name);
|
||||
|
||||
String packPath = BUNDLED_PACK_BASE_PATH + name.toLowerCase();
|
||||
String listPath = packPath + ".txt";
|
||||
InputStream listStream = this.getClass().getResourceAsStream(listPath);
|
||||
|
||||
if (listStream == null)
|
||||
{
|
||||
throw new IllegalStateException("Failed to open the list of bundled dungeon schematics for " + name);
|
||||
}
|
||||
if (listStream == null) throw new IllegalStateException("Failed to open the list of bundled dungeon schematics for " + name);
|
||||
|
||||
ArrayList<String> schematics = new ArrayList<String>();
|
||||
try
|
||||
{
|
||||
|
||||
try {
|
||||
// Read the list of schematics that come with a bundled pack
|
||||
BufferedReader listReader = new BufferedReader(new InputStreamReader(listStream));
|
||||
String schematicPath = listReader.readLine();
|
||||
while (schematicPath != null)
|
||||
{
|
||||
while (schematicPath != null) {
|
||||
schematicPath = schematicPath.trim();
|
||||
if (!schematicPath.isEmpty())
|
||||
{
|
||||
schematics.add(schematicPath);
|
||||
}
|
||||
if (!schematicPath.isEmpty()) schematics.add(schematicPath);
|
||||
|
||||
schematicPath = listReader.readLine();
|
||||
}
|
||||
|
||||
listReader.close();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("An unexpected error occured while trying to read the list of schematics for the " + name + " bundled dungeon pack. This would inevitably cause Dimensional Doors to crash during runtime.", e);
|
||||
}
|
||||
|
||||
// Register the pack
|
||||
DungeonPack pack = registerDungeonPack(packPath, schematics, true, false, reader);
|
||||
if (pack == null)
|
||||
{
|
||||
throw new RuntimeException("Failed to load the " + name + " bundled dungeon pack. This would inevitably cause Dimensional Doors to crash during runtime.");
|
||||
}
|
||||
if (pack == null) throw new RuntimeException("Failed to load the " + name + " bundled dungeon pack. This would inevitably cause Dimensional Doors to crash during runtime.");
|
||||
|
||||
return pack;
|
||||
}
|
||||
|
||||
public boolean exportDungeon(World world, int centerX, int centerY, int centerZ, String exportPath)
|
||||
{
|
||||
public boolean exportDungeon(World world, BlockPos center, String exportPath) {
|
||||
//Write schematic data to a file
|
||||
try
|
||||
{
|
||||
DungeonSchematic dungeon = DungeonSchematic.copyFromWorld(world,
|
||||
centerX - MAX_EXPORT_RADIUS, centerY - MAX_EXPORT_RADIUS, centerZ - MAX_EXPORT_RADIUS,
|
||||
MAX_DUNGEON_WIDTH, MAX_DUNGEON_HEIGHT, MAX_DUNGEON_LENGTH, true);
|
||||
try {
|
||||
DungeonSchematic dungeon = (DungeonSchematic) DungeonSchematic.copyFromWorld(world, center.subtract(BlockPosHelper.posFromSingleValue(MAX_EXPORT_RADIUS)), MAX_DUNGEON_SIZE, true);
|
||||
dungeon.applyExportFilters(properties);
|
||||
dungeon.writeToFile(exportPath);
|
||||
return true;
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public DungeonData selectNextDungeon(NewDimData parent, Random random)
|
||||
{
|
||||
public DungeonData selectNextDungeon(NewDimData parent, Random random) {
|
||||
DungeonPack pack = getDimDungeonPack(parent);
|
||||
DungeonData selection;
|
||||
DungeonPackConfig config;
|
||||
DungeonPack selectedPack;
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
config = pack.getConfig();
|
||||
selectedPack = pack;
|
||||
|
||||
// Are we allowed to switch to another dungeon pack?
|
||||
if (config.allowPackChangeOut())
|
||||
{
|
||||
if (config.allowPackChangeOut()) {
|
||||
// Calculate the chance of switching to a different pack type
|
||||
int packSwitchChance;
|
||||
if (parent.isPocketDimension())
|
||||
{
|
||||
packSwitchChance = MIN_PACK_SWITCH_CHANCE + parent.packDepth() * PACK_SWITCH_CHANCE_PER_LEVEL;
|
||||
}
|
||||
else
|
||||
{
|
||||
packSwitchChance = START_PACK_SWITCH_CHANCE;
|
||||
}
|
||||
|
||||
if (parent.isPocketDimension()) packSwitchChance = MIN_PACK_SWITCH_CHANCE + parent.packDepth() * PACK_SWITCH_CHANCE_PER_LEVEL;
|
||||
else packSwitchChance = START_PACK_SWITCH_CHANCE;
|
||||
|
||||
// Decide randomly whether to switch packs or not
|
||||
if (random.nextInt(MAX_PACK_SWITCH_CHANCE) < packSwitchChance)
|
||||
{
|
||||
if (random.nextInt(MAX_PACK_SWITCH_CHANCE) < packSwitchChance) {
|
||||
// Find another pack
|
||||
selectedPack = getRandomDungeonPack(pack, random);
|
||||
}
|
||||
|
@ -539,18 +439,13 @@ public class DungeonHelper
|
|||
|
||||
//Pick the next dungeon
|
||||
selection = selectedPack.getNextDungeon(parent, random);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
} catch (Exception e) {
|
||||
System.err.println("An exception occurred while selecting a dungeon:");
|
||||
e.printStackTrace();
|
||||
|
||||
if (!pack.isEmpty())
|
||||
{
|
||||
if (!pack.isEmpty()) {
|
||||
selection = pack.getRandomDungeon(random);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
selection = defaultError;
|
||||
}
|
||||
}
|
||||
|
@ -558,30 +453,24 @@ public class DungeonHelper
|
|||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private DungeonPack getRandomDungeonPack(DungeonPack current, Random random)
|
||||
{
|
||||
private DungeonPack getRandomDungeonPack(DungeonPack current, Random random) {
|
||||
DungeonPack selection = current;
|
||||
ArrayList<WeightedContainer<DungeonPack>> packs = new ArrayList<WeightedContainer<DungeonPack>>(dungeonPackList.size());
|
||||
|
||||
//Load up a list of weighted items with any usable dungeon packs that is not the current pack
|
||||
for (DungeonPack pack : dungeonPackList)
|
||||
{
|
||||
for (DungeonPack pack : dungeonPackList) {
|
||||
DungeonPackConfig config = pack.getConfig();
|
||||
if (pack != current && config.allowPackChangeIn() && !pack.isEmpty())
|
||||
{
|
||||
if (pack != current && config.allowPackChangeIn() && !pack.isEmpty()) {
|
||||
packs.add(new WeightedContainer<DungeonPack>(pack, config.getPackWeight()));
|
||||
}
|
||||
}
|
||||
if (!packs.isEmpty())
|
||||
{
|
||||
} if (!packs.isEmpty()) {
|
||||
//Pick a random dungeon pack
|
||||
selection = ((WeightedContainer<DungeonPack>) WeightedRandom.getRandomItem(random, packs)).getData();
|
||||
}
|
||||
return selection;
|
||||
}
|
||||
|
||||
public ArrayList<String> getDungeonNames()
|
||||
{
|
||||
public ArrayList<String> getDungeonNames() {
|
||||
// Use a HashSet to guarantee that all dungeon names will be distinct.
|
||||
// This shouldn't be necessary if we keep proper lists without repetitions,
|
||||
// but it's a fool-proof workaround.
|
||||
|
@ -595,14 +484,12 @@ public class DungeonHelper
|
|||
return sortedNames;
|
||||
}
|
||||
|
||||
private static ArrayList<String> parseDungeonNames(ArrayList<DungeonData> dungeons)
|
||||
{
|
||||
private static ArrayList<String> parseDungeonNames(ArrayList<DungeonData> dungeons) {
|
||||
String name;
|
||||
File schematic;
|
||||
ArrayList<String> names = new ArrayList<String>(dungeons.size());
|
||||
|
||||
for (DungeonData dungeon : dungeons)
|
||||
{
|
||||
for (DungeonData dungeon : dungeons) {
|
||||
//Retrieve the file name and strip off the file extension
|
||||
schematic = new File(dungeon.schematicPath());
|
||||
name = schematic.getName();
|
||||
|
@ -619,19 +506,15 @@ public class DungeonHelper
|
|||
* @param maxSize - the maximum number of dungeons that can be listed
|
||||
* @return a list of dungeons used in a given chain
|
||||
*/
|
||||
public static ArrayList<DungeonData> getDungeonChainHistory(NewDimData start, DungeonPack pack, int maxSize)
|
||||
{
|
||||
if (start == null)
|
||||
{
|
||||
throw new IllegalArgumentException("dimension cannot be null.");
|
||||
}
|
||||
public static ArrayList<DungeonData> getDungeonChainHistory(NewDimData start, DungeonPack pack, int maxSize) {
|
||||
if (start == null) throw new IllegalArgumentException("dimension cannot be null.");
|
||||
|
||||
int count = 0;
|
||||
NewDimData current = start;
|
||||
DungeonData dungeon = current.dungeon();
|
||||
ArrayList<DungeonData> history = new ArrayList<DungeonData>();
|
||||
|
||||
while (count < maxSize && dungeon != null && dungeon.dungeonType().Owner == pack)
|
||||
{
|
||||
while (count < maxSize && dungeon != null && dungeon.dungeonType().Owner == pack) {
|
||||
history.add(dungeon);
|
||||
current = current.parent();
|
||||
dungeon = current.dungeon();
|
||||
|
@ -647,8 +530,7 @@ public class DungeonHelper
|
|||
* @param maxSize - the maximum number of dungeons that can be listed
|
||||
* @return a list of the dungeons used in a given dungeon tree
|
||||
*/
|
||||
public static ArrayList<DungeonData> listDungeonsInTree(NewDimData root, DungeonPack pack, int maxSize)
|
||||
{
|
||||
public static ArrayList<DungeonData> listDungeonsInTree(NewDimData root, DungeonPack pack, int maxSize) {
|
||||
int count = 0;
|
||||
NewDimData current;
|
||||
DungeonData dungeon;
|
||||
|
@ -657,17 +539,15 @@ public class DungeonHelper
|
|||
pendingDimensions.add(root);
|
||||
|
||||
// Perform a breadth-first search through the dungeon graph
|
||||
while (dungeons.size() < maxSize && !pendingDimensions.isEmpty())
|
||||
{
|
||||
while (dungeons.size() < maxSize && !pendingDimensions.isEmpty()) {
|
||||
current = pendingDimensions.remove();
|
||||
dungeon = current.dungeon();
|
||||
// Check that this is a dungeon, and if so, that it belongs to the pack that we want
|
||||
if (dungeon != null && dungeon.dungeonType().Owner == pack)
|
||||
{
|
||||
|
||||
if (dungeon != null && dungeon.dungeonType().Owner == pack) {
|
||||
dungeons.add(dungeon);
|
||||
// Add all child dungeons for checking later
|
||||
for (NewDimData child : current.children())
|
||||
{
|
||||
for (NewDimData child : current.children()) {
|
||||
pendingDimensions.add(child);
|
||||
}
|
||||
}
|
||||
|
@ -682,8 +562,7 @@ public class DungeonHelper
|
|||
* @param maxLevels - the maximum number of ancestors to check
|
||||
* @return the highest ancestor that belongs to the specified pack within the specified levels, or <code>null</code> if none exists
|
||||
*/
|
||||
public static NewDimData getAncestor(NewDimData dimension, DungeonPack pack, int maxLevels)
|
||||
{
|
||||
public static NewDimData getAncestor(NewDimData dimension, DungeonPack pack, int maxLevels) {
|
||||
// Find the ancestor of a dimension located a specified number of levels up.
|
||||
NewDimData parent = dimension;
|
||||
NewDimData current = null;
|
||||
|
@ -691,16 +570,13 @@ public class DungeonHelper
|
|||
// We solve this inductively. We begin with null as the first valid ancestor,
|
||||
// like a kind of virtual child dimension. Then "current" references the
|
||||
// highest valid ancestor found so far and "parent" references its parent
|
||||
for (int levels = 0; levels <= maxLevels; levels++)
|
||||
{
|
||||
if (parent == null || parent.dungeon() == null ||
|
||||
parent.dungeon().dungeonType().Owner != pack)
|
||||
{
|
||||
break;
|
||||
}
|
||||
for (int levels = 0; levels <= maxLevels; levels++) {
|
||||
if (parent == null || parent.dungeon() == null || parent.dungeon().dungeonType().Owner != pack) break;
|
||||
|
||||
current = parent;
|
||||
parent = parent.parent();
|
||||
}
|
||||
|
||||
return current;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package com.zixiken.dimdoors.helpers;
|
||||
|
||||
import net.minecraft.block.BlockDoor;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.properties.PropertyDirection;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
public class EnumFacingHelper {
|
||||
public static EnumFacing getFacingFromBlockState(IBlockState state) {
|
||||
for (IProperty prop : (java.util.Set<IProperty>)state.getProperties().keySet()) {
|
||||
if (prop.getName().equals("facing") || prop.getName().equals("rotation")) {
|
||||
return state.getValue((PropertyDirection) prop);
|
||||
}
|
||||
}
|
||||
return EnumFacing.NORTH;
|
||||
}
|
||||
}
|
|
@ -3,6 +3,7 @@ package com.zixiken.dimdoors.schematic;
|
|||
import com.zixiken.dimdoors.DimDoors;
|
||||
import net.minecraft.block.*;
|
||||
import com.zixiken.dimdoors.Point3D;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.BlockPos;
|
||||
|
@ -11,501 +12,29 @@ import net.minecraft.util.EnumFacing;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class BlockRotator
|
||||
{
|
||||
//This class is temporary. It's just a place in which to hold the old block rotation and transformation code
|
||||
//until we can rewrite it.
|
||||
|
||||
public final static int EAST_DOOR_METADATA = 0;
|
||||
private final static int BLOCK_ID_COUNT = 4096;
|
||||
|
||||
//Provides a fast lookup table for whether blocks have orientations
|
||||
private final static Map<Block, Boolean> hasOrientations = new HashMap<Block, Boolean>();
|
||||
|
||||
public static void setupOrientations()
|
||||
{
|
||||
hasOrientations.put(Blocks.dispenser, true);
|
||||
hasOrientations.put(Blocks.dropper, true);
|
||||
hasOrientations.put(Blocks.stone_brick_stairs, true);
|
||||
hasOrientations.put(Blocks.lever, true);
|
||||
hasOrientations.put(Blocks.stone_button, true);
|
||||
hasOrientations.put(Blocks.wooden_button, true);
|
||||
hasOrientations.put(Blocks.unpowered_repeater, true);
|
||||
hasOrientations.put(Blocks.powered_repeater, true);
|
||||
hasOrientations.put(Blocks.tripwire_hook, true);
|
||||
hasOrientations.put(Blocks.torch, true);
|
||||
hasOrientations.put(Blocks.redstone_torch, true);
|
||||
hasOrientations.put(Blocks.unlit_redstone_torch, true);
|
||||
hasOrientations.put(Blocks.iron_door, true);
|
||||
hasOrientations.put(Blocks.wooden_door, true);
|
||||
hasOrientations.put(Blocks.piston, true);
|
||||
hasOrientations.put(Blocks.sticky_piston, true);
|
||||
hasOrientations.put(Blocks.piston_head, true);
|
||||
hasOrientations.put(Blocks.powered_comparator, true);
|
||||
hasOrientations.put(Blocks.unpowered_comparator, true);
|
||||
hasOrientations.put(Blocks.standing_sign, true);
|
||||
hasOrientations.put(Blocks.wall_sign, true);
|
||||
hasOrientations.put(Blocks.skull, true);
|
||||
hasOrientations.put(Blocks.ladder, true);
|
||||
hasOrientations.put(Blocks.vine, true);
|
||||
hasOrientations.put(Blocks.anvil, true);
|
||||
hasOrientations.put(Blocks.chest, true);
|
||||
hasOrientations.put(Blocks.trapped_chest, true);
|
||||
hasOrientations.put(Blocks.hopper, true);
|
||||
hasOrientations.put(Blocks.nether_brick_stairs, true);
|
||||
hasOrientations.put(Blocks.stone_stairs, true);
|
||||
hasOrientations.put(Blocks.quartz_stairs, true);
|
||||
hasOrientations.put(Blocks.sandstone_stairs, true);
|
||||
hasOrientations.put(Blocks.brick_stairs, true);
|
||||
hasOrientations.put(Blocks.birch_stairs, true);
|
||||
hasOrientations.put(Blocks.oak_stairs, true);
|
||||
hasOrientations.put(Blocks.jungle_stairs, true);
|
||||
hasOrientations.put(Blocks.spruce_stairs, true);
|
||||
hasOrientations.put(Blocks.log, true);
|
||||
hasOrientations.put(Blocks.log2, true);
|
||||
hasOrientations.put(Blocks.quartz_block, true);
|
||||
hasOrientations.put(Blocks.rail, true);
|
||||
hasOrientations.put(Blocks.activator_rail, true);
|
||||
hasOrientations.put(Blocks.detector_rail, true);
|
||||
hasOrientations.put(Blocks.golden_rail, true);
|
||||
hasOrientations.put(Blocks.furnace, true);
|
||||
hasOrientations.put(Blocks.lit_furnace, true);
|
||||
hasOrientations.put(Blocks.bed, true);
|
||||
|
||||
hasOrientations.put(DimDoors.dimensionalDoor, true);
|
||||
hasOrientations.put(DimDoors.warpDoor, true);
|
||||
hasOrientations.put(DimDoors.goldenDimensionalDoor, true);
|
||||
hasOrientations.put(DimDoors.personalDimDoor, true);
|
||||
}
|
||||
|
||||
public static IBlockState transformMetadata(IBlockState state, int turns, Block block)
|
||||
{
|
||||
public class BlockRotator {
|
||||
public static IBlockState transform(IBlockState state, int turns) {
|
||||
//I changed rotations to reduce the monstrous code we had. It might be
|
||||
//slightly less efficient, but it's easier to maintain for now. ~SenseiKiwi
|
||||
|
||||
//Correct negative turns and get the minimum number of rotations needed
|
||||
turns += 1 << 16;
|
||||
turns %= 4;
|
||||
|
||||
if (hasOrientations.containsKey(block) && hasOrientations.get(block))
|
||||
{
|
||||
while (turns > 0)
|
||||
{
|
||||
state = rotateMetadataBy90(state, block);
|
||||
turns--;
|
||||
|
||||
while (turns > 0) {
|
||||
for (IProperty prop : (java.util.Set<IProperty>)state.getProperties().keySet()) {
|
||||
if (prop.getName().equals("facing") || prop.getName().equals("rotation")) {
|
||||
state.cycleProperty(prop);
|
||||
}
|
||||
}
|
||||
|
||||
turns--;
|
||||
}
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
private static IBlockState rotateMetadataBy90(IBlockState state, Block block)
|
||||
{
|
||||
//TODO: Replace this horrible function with something prettier. We promise we will for the next version,
|
||||
//after switching to MC 1.6. PADRE, PLEASE FORGIVE OUR SINS.
|
||||
|
||||
if (block == Blocks.log || block == Blocks.log2)
|
||||
{
|
||||
if (metadata >= 4 && metadata < 12)
|
||||
{
|
||||
metadata = (metadata % 8) + 4;
|
||||
}
|
||||
}
|
||||
else if (block == Blocks.quartz_block)
|
||||
{
|
||||
if (metadata == 3 || metadata == 4)
|
||||
{
|
||||
metadata = (metadata - 2) % 2 + 3;
|
||||
}
|
||||
}
|
||||
else if (block == Blocks.golden_rail || block == Blocks.detector_rail || block == Blocks.activator_rail)
|
||||
{
|
||||
switch (metadata)
|
||||
{
|
||||
//Powered Track/Detector Track/Activator Track (off)
|
||||
case 0:
|
||||
metadata = 1;
|
||||
break;
|
||||
case 1:
|
||||
metadata = 0;
|
||||
break;
|
||||
case 2:
|
||||
metadata = 5;
|
||||
break;
|
||||
case 3:
|
||||
metadata = 4;
|
||||
break;
|
||||
case 4:
|
||||
metadata = 2;
|
||||
break;
|
||||
case 5:
|
||||
metadata = 3;
|
||||
break;
|
||||
|
||||
//Powered Track/Detector Track/Activator Track (on)
|
||||
case 8:
|
||||
metadata = 9;
|
||||
break;
|
||||
case 9:
|
||||
metadata = 8;
|
||||
break;
|
||||
case 10:
|
||||
metadata = 13;
|
||||
break;
|
||||
case 11:
|
||||
metadata = 12;
|
||||
break;
|
||||
case 12:
|
||||
metadata = 10;
|
||||
break;
|
||||
case 13:
|
||||
metadata = 11;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (block==Blocks.rail)
|
||||
{
|
||||
switch (metadata)
|
||||
{
|
||||
case 0:
|
||||
metadata = 1;
|
||||
break;
|
||||
case 1:
|
||||
metadata = 0;
|
||||
break;
|
||||
case 8:
|
||||
metadata = 9;
|
||||
break;
|
||||
case 9:
|
||||
metadata = 6;
|
||||
break;
|
||||
case 6:
|
||||
metadata = 7;
|
||||
break;
|
||||
case 7:
|
||||
metadata = 8;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (block==Blocks.bed)
|
||||
{
|
||||
switch (metadata)
|
||||
{
|
||||
case 2:
|
||||
metadata = 1;
|
||||
break;
|
||||
case 1:
|
||||
metadata = 0;
|
||||
break;
|
||||
case 0:
|
||||
metadata = 3;
|
||||
break;
|
||||
case 3:
|
||||
metadata = 2;
|
||||
break;
|
||||
case 10:
|
||||
metadata = 9;
|
||||
break;
|
||||
case 9:
|
||||
metadata = 8;
|
||||
break;
|
||||
case 8:
|
||||
metadata = 11;
|
||||
break;
|
||||
case 11:
|
||||
metadata = 10;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (block instanceof BlockStairs)
|
||||
{
|
||||
|
||||
switch (metadata)
|
||||
{
|
||||
case 0:
|
||||
metadata = 2;
|
||||
break;
|
||||
case 1:
|
||||
metadata = 3;
|
||||
break;
|
||||
case 2:
|
||||
metadata = 1;
|
||||
break;
|
||||
case 3:
|
||||
metadata = 0;
|
||||
break;
|
||||
case 7:
|
||||
metadata = 4;
|
||||
break;
|
||||
case 6:
|
||||
metadata = 5;
|
||||
break;
|
||||
case 5:
|
||||
metadata = 7;
|
||||
break;
|
||||
case 4:
|
||||
metadata = 6;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (block == Blocks.chest || block == Blocks.trapped_chest || block == Blocks.ladder || block == Blocks.lit_furnace || block == Blocks.furnace)
|
||||
{
|
||||
switch (metadata)
|
||||
{
|
||||
case 2:
|
||||
metadata = 5;
|
||||
break;
|
||||
case 3:
|
||||
metadata = 4;
|
||||
break;
|
||||
case 4:
|
||||
metadata = 2;
|
||||
break;
|
||||
case 5:
|
||||
metadata = 3;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (block == Blocks.hopper)
|
||||
{
|
||||
switch (metadata)
|
||||
{
|
||||
case 2:
|
||||
metadata = 5;
|
||||
break;
|
||||
case 3:
|
||||
metadata = 4;
|
||||
break;
|
||||
case 4:
|
||||
metadata = 2;
|
||||
break;
|
||||
case 5:
|
||||
metadata = 3;
|
||||
break;
|
||||
case 10:
|
||||
metadata = 13;
|
||||
break;
|
||||
case 11:
|
||||
metadata = 12;
|
||||
break;
|
||||
case 12:
|
||||
metadata = 10;
|
||||
break;
|
||||
case 13:
|
||||
metadata = 11;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (block==Blocks.vine)
|
||||
{
|
||||
switch (metadata)
|
||||
{
|
||||
|
||||
case 1:
|
||||
metadata = 2;
|
||||
break;
|
||||
case 2:
|
||||
metadata = 4;
|
||||
break;
|
||||
case 4:
|
||||
metadata = 8;
|
||||
break;
|
||||
case 8:
|
||||
metadata = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (block==Blocks.wall_sign)
|
||||
{
|
||||
switch (metadata)
|
||||
{
|
||||
|
||||
case 3:
|
||||
metadata = 4;
|
||||
break;
|
||||
case 2:
|
||||
metadata = 5;
|
||||
break;
|
||||
case 4:
|
||||
metadata = 2;
|
||||
break;
|
||||
case 5:
|
||||
metadata = 3;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (block==Blocks.standing_sign)
|
||||
{
|
||||
switch (metadata)
|
||||
{
|
||||
case 0:
|
||||
metadata = 4;
|
||||
break;
|
||||
case 1:
|
||||
metadata = 5;
|
||||
break;
|
||||
case 2:
|
||||
metadata = 6;
|
||||
break;
|
||||
case 3:
|
||||
metadata = 7;
|
||||
break;
|
||||
case 4:
|
||||
metadata = 8;
|
||||
break;
|
||||
case 5:
|
||||
metadata = 9;
|
||||
break;
|
||||
case 6:
|
||||
metadata = 10;
|
||||
break;
|
||||
case 7:
|
||||
metadata = 11;
|
||||
break;
|
||||
case 8:
|
||||
metadata = 12;
|
||||
break;
|
||||
case 9:
|
||||
metadata = 13;
|
||||
break;
|
||||
case 10:
|
||||
metadata = 14;
|
||||
break;
|
||||
case 11:
|
||||
metadata = 15;
|
||||
break;
|
||||
case 12:
|
||||
metadata = 0;
|
||||
break;
|
||||
case 13:
|
||||
metadata = 1;
|
||||
break;
|
||||
case 14:
|
||||
metadata = 2;
|
||||
break;
|
||||
case 15:
|
||||
metadata = 3;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if(block== Blocks.lever || block == Blocks.stone_button || block == Blocks.wooden_button || block== Blocks.torch||block== Blocks.unlit_redstone_torch||block== Blocks.redstone_torch)
|
||||
{
|
||||
switch (metadata)
|
||||
{
|
||||
case 12:
|
||||
metadata = 9;
|
||||
break;
|
||||
case 11:
|
||||
metadata = 10;
|
||||
break;
|
||||
case 10:
|
||||
metadata = 12;
|
||||
break;
|
||||
case 9:
|
||||
metadata = 11;
|
||||
break;
|
||||
case 2:
|
||||
metadata = 4;
|
||||
break;
|
||||
case 3:
|
||||
metadata = 2;
|
||||
break;
|
||||
case 1:
|
||||
metadata = 3;
|
||||
break;
|
||||
case 4:
|
||||
metadata = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if(block== Blocks.piston||block==Blocks.piston_head||block==Blocks.sticky_piston || block == Blocks.dispenser || block == Blocks.dropper)
|
||||
{
|
||||
switch (metadata)
|
||||
{
|
||||
case 4:
|
||||
metadata = 2;
|
||||
break;
|
||||
case 5:
|
||||
metadata = 3;
|
||||
break;
|
||||
case 13:
|
||||
metadata = 11;
|
||||
break;
|
||||
case 12:
|
||||
metadata = 10;
|
||||
break;
|
||||
case 3:
|
||||
metadata = 4;
|
||||
break;
|
||||
case 2:
|
||||
metadata = 5;
|
||||
break;
|
||||
case 11:
|
||||
metadata = 12;
|
||||
break;
|
||||
case 10:
|
||||
metadata = 13;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (block instanceof BlockRedstoneRepeater || block instanceof BlockDoor || block== Blocks.tripwire_hook || block instanceof BlockRedstoneComparator)
|
||||
{
|
||||
switch (metadata)
|
||||
{
|
||||
case 0:
|
||||
metadata = 1;
|
||||
break;
|
||||
case 1:
|
||||
metadata = 2;
|
||||
break;
|
||||
case 2:
|
||||
metadata = 3;
|
||||
break;
|
||||
case 3:
|
||||
metadata = 0;
|
||||
break;
|
||||
case 4:
|
||||
metadata = 5;
|
||||
break;
|
||||
case 5:
|
||||
metadata = 6;
|
||||
break;
|
||||
case 6:
|
||||
metadata = 7;
|
||||
break;
|
||||
case 7:
|
||||
metadata = 4;
|
||||
break;
|
||||
case 8:
|
||||
metadata = 9;
|
||||
break;
|
||||
case 9:
|
||||
metadata = 10;
|
||||
break;
|
||||
case 10:
|
||||
metadata = 11;
|
||||
break;
|
||||
case 11:
|
||||
metadata = 8;
|
||||
break;
|
||||
case 12:
|
||||
metadata = 13;
|
||||
break;
|
||||
case 13:
|
||||
metadata = 14;
|
||||
break;
|
||||
case 14:
|
||||
metadata = 15;
|
||||
break;
|
||||
case 15:
|
||||
metadata = 12;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return metadata;
|
||||
}
|
||||
|
||||
public static void transformPoint(BlockPos position, BlockPos srcOrigin, EnumFacing angle, BlockPos destOrigin)
|
||||
{
|
||||
public static void transformPoint(BlockPos position, BlockPos srcOrigin, EnumFacing angle, BlockPos destOrigin) {
|
||||
//This function receives a position (e.g. point in schematic space), translates it relative
|
||||
//to a source coordinate system (e.g. the point that will be the center of a schematic),
|
||||
//then rotates and translates it to obtain the corresponding point in a destination
|
||||
|
|
|
@ -26,12 +26,12 @@ import net.minecraft.world.World;
|
|||
public class Schematic {
|
||||
|
||||
protected BlockPos volume;
|
||||
protected IBlockState[] state;
|
||||
protected IBlockState[] states;
|
||||
protected NBTTagList tileEntities;
|
||||
|
||||
protected Schematic(BlockPos volume, IBlockState[] state, NBTTagList tileEntities) {
|
||||
this.volume = volume;
|
||||
this.state = state;
|
||||
this.states = state;
|
||||
this.tileEntities = tileEntities;
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ public class Schematic {
|
|||
//Shallow copy constructor - critical for code reuse in derived classes since
|
||||
//source's fields will be inaccessible if the derived class is in another package.
|
||||
this.volume = source.volume;
|
||||
this.state = source.state;
|
||||
this.states = source.states;
|
||||
this.tileEntities = source.tileEntities;
|
||||
}
|
||||
|
||||
|
@ -73,11 +73,11 @@ public class Schematic {
|
|||
}
|
||||
|
||||
public Block getBlock(BlockPos pos) {
|
||||
return state[calculateIndex(pos)].getBlock();
|
||||
return states[calculateIndex(pos)].getBlock();
|
||||
}
|
||||
|
||||
public IBlockState getBlockState(BlockPos pos) {
|
||||
return state[calculateIndex(pos)];
|
||||
return states[calculateIndex(pos)];
|
||||
}
|
||||
|
||||
public NBTTagList getTileEntities() {
|
||||
|
@ -197,7 +197,7 @@ public class Schematic {
|
|||
}
|
||||
|
||||
protected NBTTagCompound writeToNBT(boolean copyTileEntities) {
|
||||
return writeToNBT(volume, state, tileEntities, copyTileEntities);
|
||||
return writeToNBT(volume, states, tileEntities, copyTileEntities);
|
||||
}
|
||||
|
||||
protected static NBTTagCompound writeToNBT(BlockPos volume, IBlockState[] state, NBTTagList tileEntities, boolean copyTileEntities) {
|
||||
|
@ -245,7 +245,7 @@ public class Schematic {
|
|||
}
|
||||
|
||||
public boolean applyFilter(SchematicFilter filter) {
|
||||
return filter.apply(this, this.state);
|
||||
return filter.apply(this, this.states);
|
||||
}
|
||||
|
||||
public void copyToWorld(World world, BlockPos pos, boolean notifyClients, boolean ignoreAir) {
|
||||
|
@ -268,7 +268,7 @@ public class Schematic {
|
|||
for (dy = 0; dy < volume.getY(); dy++) {
|
||||
for (dz = 0; dz < volume.getZ(); dz++) {
|
||||
for (dx = 0; dx < volume.getX(); dx++) {
|
||||
blockSetter.setBlock(world, pos.add(dx, dy, dz), state[index]);
|
||||
blockSetter.setBlock(world, pos.add(dx, dy, dz), states[index]);
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,32 +4,28 @@ import java.util.ArrayList;
|
|||
import java.util.EnumSet;
|
||||
|
||||
import com.zixiken.dimdoors.core.DDTeleporter;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
||||
public class ServerTickHandler implements IRegularTickSender
|
||||
{
|
||||
public class ServerTickHandler implements IRegularTickSender {
|
||||
private static final String PROFILING_LABEL = "Dimensional Doors: Server Tick";
|
||||
|
||||
private int tickCount = 0;
|
||||
private ArrayList<RegularTickReceiverInfo> receivers;
|
||||
|
||||
public ServerTickHandler()
|
||||
{
|
||||
public ServerTickHandler() {
|
||||
this.receivers = new ArrayList<RegularTickReceiverInfo>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerReceiver(IRegularTickReceiver receiver, int interval, boolean onTickStart)
|
||||
{
|
||||
public void registerReceiver(IRegularTickReceiver receiver, int interval, boolean onTickStart) {
|
||||
RegularTickReceiverInfo info = new RegularTickReceiverInfo(receiver, interval, onTickStart);
|
||||
receivers.add(info);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregisterReceivers()
|
||||
{
|
||||
public void unregisterReceivers() {
|
||||
receivers.clear();
|
||||
}
|
||||
|
||||
|
@ -45,12 +41,9 @@ public class ServerTickHandler implements IRegularTickSender
|
|||
}
|
||||
|
||||
private void tickStart(TickEvent.Type type) {
|
||||
if (type.equals(EnumSet.of(TickEvent.Type.SERVER)))
|
||||
{
|
||||
for (RegularTickReceiverInfo info : receivers)
|
||||
{
|
||||
if (info.OnTickStart && tickCount % info.Interval == 0)
|
||||
{
|
||||
if (type.equals(EnumSet.of(TickEvent.Type.SERVER))) {
|
||||
for (RegularTickReceiverInfo info : receivers) {
|
||||
if (info.OnTickStart && tickCount % info.Interval == 0) {
|
||||
info.RegularTickReceiver.notifyTick();
|
||||
}
|
||||
}
|
||||
|
@ -58,18 +51,14 @@ public class ServerTickHandler implements IRegularTickSender
|
|||
|
||||
//TODO: Stuck this in here because it's already rather hackish.
|
||||
//We should standardize this as an IRegularTickReceiver in the future. ~SenseiKiwi
|
||||
if (DDTeleporter.cooldown > 0)
|
||||
{
|
||||
if (DDTeleporter.cooldown > 0) {
|
||||
DDTeleporter.cooldown--;
|
||||
}
|
||||
}
|
||||
|
||||
private void tickEnd(TickEvent.Type type)
|
||||
{
|
||||
for (RegularTickReceiverInfo info : receivers)
|
||||
{
|
||||
if (!info.OnTickStart && tickCount % info.Interval == 0)
|
||||
{
|
||||
private void tickEnd(TickEvent.Type type) {
|
||||
for (RegularTickReceiverInfo info : receivers) {
|
||||
if (!info.OnTickStart && tickCount % info.Interval == 0) {
|
||||
info.RegularTickReceiver.notifyTick();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.util.Random;
|
|||
|
||||
import com.zixiken.dimdoors.DimDoors;
|
||||
import com.zixiken.dimdoors.core.DimLink;
|
||||
import com.zixiken.dimdoors.helpers.BlockPosHelper;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
|
@ -71,30 +72,22 @@ public class PocketBuilder
|
|||
return true;
|
||||
}
|
||||
|
||||
public static boolean generateSelectedDungeonPocket(DimLink link, DDProperties properties, DungeonData dungeon)
|
||||
{
|
||||
if (link == null)
|
||||
{
|
||||
public static boolean generateSelectedDungeonPocket(DimLink link, DDProperties properties, DungeonData dungeon) {
|
||||
if (link == null) {
|
||||
throw new IllegalArgumentException("link cannot be null.");
|
||||
}
|
||||
if (properties == null)
|
||||
{
|
||||
} if (properties == null) {
|
||||
throw new IllegalArgumentException("properties cannot be null.");
|
||||
}
|
||||
if (link.hasDestination())
|
||||
{
|
||||
} if (link.hasDestination()) {
|
||||
throw new IllegalArgumentException("link cannot have a destination assigned already.");
|
||||
}
|
||||
if (dungeon == null)
|
||||
{
|
||||
} if (dungeon == null) {
|
||||
throw new IllegalArgumentException("dungeon cannot be null.");
|
||||
}
|
||||
|
||||
// Try to load up the schematic
|
||||
DungeonSchematic schematic = null;
|
||||
schematic = loadAndValidateDungeon(dungeon, properties);
|
||||
if (schematic == null)
|
||||
{
|
||||
|
||||
if (schematic == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -105,8 +98,7 @@ public class PocketBuilder
|
|||
//Load a world
|
||||
World world = PocketManager.loadDimension(dimension.id());
|
||||
|
||||
if (world == null || world.provider == null)
|
||||
{
|
||||
if (world == null || world.provider == null) {
|
||||
System.err.println("Could not initialize dimension for a dungeon!");
|
||||
return false;
|
||||
}
|
||||
|
@ -115,30 +107,26 @@ public class PocketBuilder
|
|||
}
|
||||
|
||||
|
||||
public static boolean generateNewDungeonPocket(DimLink link, DDProperties properties)
|
||||
{
|
||||
if (link == null)
|
||||
{
|
||||
public static boolean generateNewDungeonPocket(DimLink link, DDProperties properties) {
|
||||
if (link == null) {
|
||||
throw new IllegalArgumentException("link cannot be null.");
|
||||
}
|
||||
if (properties == null)
|
||||
{
|
||||
} if (properties == null) {
|
||||
throw new IllegalArgumentException("properties cannot be null.");
|
||||
}
|
||||
|
||||
if (link.hasDestination())
|
||||
{
|
||||
if (link.hasDestination()) {
|
||||
throw new IllegalArgumentException("link cannot have a destination assigned already.");
|
||||
}
|
||||
|
||||
//Choose a dungeon to generate
|
||||
NewDimData parent = PocketManager.getDimensionData(link.source().getDimension());
|
||||
Pair<DungeonData, DungeonSchematic> pair = selectNextDungeon(parent, random, properties);
|
||||
if (pair == null)
|
||||
{
|
||||
|
||||
if (pair == null) {
|
||||
System.err.println("Could not select a dungeon for generation!");
|
||||
return false;
|
||||
}
|
||||
|
||||
DungeonData dungeon = pair.getFirst();
|
||||
DungeonSchematic schematic = pair.getSecond();
|
||||
|
||||
|
@ -148,8 +136,7 @@ public class PocketBuilder
|
|||
//Load a world
|
||||
World world = PocketManager.loadDimension(dimension.id());
|
||||
|
||||
if (world == null || world.provider == null)
|
||||
{
|
||||
if (world == null || world.provider == null) {
|
||||
System.err.println("Could not initialize dimension for a dungeon!");
|
||||
return false;
|
||||
}
|
||||
|
@ -158,8 +145,7 @@ public class PocketBuilder
|
|||
}
|
||||
|
||||
|
||||
private static BlockPos calculateNoisyDestination(Point4D source, NewDimData dimension, DungeonData dungeon, int orientation)
|
||||
{
|
||||
private static BlockPos calculateNoisyDestination(Point4D source, NewDimData dimension, DungeonData dungeon, EnumFacing facing) {
|
||||
int depth = NewDimData.calculatePackDepth(dimension.parent(), dungeon);
|
||||
int forwardNoise = MathHelper.getRandomIntegerInRange(random, 10 * depth, 130 * depth);
|
||||
int sidewaysNoise = MathHelper.getRandomIntegerInRange(random, -10 * depth, 10 * depth);
|
||||
|
@ -170,100 +156,80 @@ public class PocketBuilder
|
|||
BlockPos linkDestination = new BlockPos(forwardNoise, 0, sidewaysNoise);
|
||||
BlockPos sourcePoint = new BlockPos(source.getX(), source.getY(), source.getZ());
|
||||
BlockPos zeroPoint = new BlockPos(0, 0, 0);
|
||||
BlockRotator.transformPoint(linkDestination, zeroPoint, orientation - BlockRotator.EAST_DOOR_METADATA, sourcePoint);
|
||||
BlockRotator.transformPoint(linkDestination, zeroPoint, facing, sourcePoint);
|
||||
return linkDestination;
|
||||
}
|
||||
|
||||
private static Pair<DungeonData, DungeonSchematic> selectNextDungeon(NewDimData parent, Random random, DDProperties properties)
|
||||
{
|
||||
private static Pair<DungeonData, DungeonSchematic> selectNextDungeon(NewDimData parent, Random random, DDProperties properties) {
|
||||
DungeonData dungeon = null;
|
||||
DungeonSchematic schematic = null;
|
||||
|
||||
dungeon = DungeonHelper.instance().selectNextDungeon(parent, random);
|
||||
|
||||
if (dungeon != null)
|
||||
{
|
||||
if (dungeon != null) {
|
||||
schematic = loadAndValidateDungeon(dungeon, properties);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
System.err.println("Could not select a dungeon at all!");
|
||||
}
|
||||
|
||||
if (schematic == null)
|
||||
{
|
||||
if (schematic == null) {
|
||||
//TODO: In the future, remove this dungeon from the generation lists altogether.
|
||||
//That will have to wait until our code is updated to support that more easily.
|
||||
try
|
||||
{
|
||||
try {
|
||||
System.err.println("Loading the default error dungeon instead...");
|
||||
dungeon = DungeonHelper.instance().getDefaultErrorDungeon();
|
||||
schematic = loadAndValidateDungeon(dungeon, properties);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return new Pair<DungeonData, DungeonSchematic>(dungeon, schematic);
|
||||
}
|
||||
|
||||
private static DungeonSchematic loadAndValidateDungeon(DungeonData dungeon, DDProperties properties)
|
||||
{
|
||||
try
|
||||
{
|
||||
private static DungeonSchematic loadAndValidateDungeon(DungeonData dungeon, DDProperties properties) {
|
||||
try {
|
||||
DungeonSchematic schematic = dungeon.loadSchematic();
|
||||
|
||||
//Validate the dungeon's dimensions
|
||||
if (hasValidDimensions(schematic))
|
||||
{
|
||||
if (hasValidDimensions(schematic)) {
|
||||
schematic.applyImportFilters(properties);
|
||||
|
||||
//Check that the dungeon has an entrance or we'll have a crash
|
||||
if (schematic.getEntranceDoorLocation() == null)
|
||||
{
|
||||
if (schematic.getEntranceDoorLocation() == null) {
|
||||
System.err.println("The following schematic file does not have an entrance: " + dungeon.schematicPath());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
System.err.println("The following schematic file has dimensions that exceed the maximum permitted dimensions for dungeons: " + dungeon.schematicPath());
|
||||
return null;
|
||||
}
|
||||
|
||||
return schematic;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
} catch (Exception e) {
|
||||
System.err.println("An error occurred while loading the following schematic: " + dungeon.schematicPath());
|
||||
System.err.println(e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean hasValidDimensions(DungeonSchematic schematic)
|
||||
{
|
||||
return (schematic.getWidth() <= DungeonHelper.MAX_DUNGEON_WIDTH &&
|
||||
schematic.getHeight() <= DungeonHelper.MAX_DUNGEON_HEIGHT &&
|
||||
schematic.getLength() <= DungeonHelper.MAX_DUNGEON_LENGTH);
|
||||
private static boolean hasValidDimensions(DungeonSchematic schematic) {
|
||||
return BlockPosHelper.lessThanOrEqual(schematic.getVolume(), DungeonHelper.MAX_DUNGEON_SIZE);
|
||||
}
|
||||
|
||||
public static boolean generateNewPocket(DimLink link, DDProperties properties, Block door, DimensionType type)
|
||||
{
|
||||
public static boolean generateNewPocket(DimLink link, DDProperties properties, Block door, DimensionType type) {
|
||||
return generateNewPocket(link, DEFAULT_POCKET_SIZE, DEFAULT_POCKET_WALL_THICKNESS, properties, door, type);
|
||||
}
|
||||
|
||||
private static int getDoorOrientation(Point4D source, DDProperties properties)
|
||||
{
|
||||
private static int getDoorOrientation(Point4D source, DDProperties properties) {
|
||||
World world = DimensionManager.getWorld(source.getDimension());
|
||||
if (world == null)
|
||||
{
|
||||
throw new IllegalStateException("The link's source world should be loaded!");
|
||||
}
|
||||
|
||||
if (world == null) throw new IllegalStateException("The link's source world should be loaded!");
|
||||
|
||||
|
||||
//Check if the block below that point is actually a door
|
||||
Block block = world.getBlock(source.getX(), source.getY() - 1, source.getZ());
|
||||
Block block = world.getBlock(source.getX().getX(), source.getY() - 1, source.getZ());
|
||||
if (block==null || !(block instanceof IDimDoor))
|
||||
{
|
||||
throw new IllegalStateException("The link's source is not a door block. It should be impossible to traverse a rift without a door!");
|
||||
|
|
|
@ -5,81 +5,55 @@ import java.util.List;
|
|||
import com.zixiken.dimdoors.core.NewDimData;
|
||||
import com.zixiken.dimdoors.core.PocketManager;
|
||||
import com.zixiken.dimdoors.ticking.CustomLimboPopulator;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.EnumCreatureType;
|
||||
import net.minecraft.world.ChunkPosition;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.chunk.ChunkPrimer;
|
||||
import net.minecraft.world.chunk.IChunkProvider;
|
||||
import net.minecraft.world.gen.ChunkProviderGenerate;
|
||||
|
||||
public class PocketGenerator extends ChunkProviderGenerate
|
||||
{
|
||||
public class PocketGenerator extends ChunkProviderGenerate {
|
||||
private World worldObj;
|
||||
|
||||
private CustomLimboPopulator spawner;
|
||||
|
||||
public PocketGenerator(World par1World, long par2, boolean par4, CustomLimboPopulator spawner)
|
||||
{
|
||||
super(par1World, par2, par4);
|
||||
public PocketGenerator(World par1World, long par2, boolean par4, CustomLimboPopulator spawner) {
|
||||
super(par1World, par2, par4, null);
|
||||
this.worldObj = par1World;
|
||||
|
||||
this.spawner = spawner;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void func_147424_a(int par1, int par2, Block[] blocks)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean unloadQueuedChunks()
|
||||
{
|
||||
public boolean unloadQueuedChunks() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Chunk provideChunk(int chunkX, int chunkZ)
|
||||
{
|
||||
Block[] var3 = new Block[32768];
|
||||
Chunk chunk = new Chunk(worldObj, var3, chunkX, chunkZ);
|
||||
public Chunk provideChunk(int chunkX, int chunkZ) {
|
||||
Chunk chunk = new Chunk(worldObj, new ChunkPrimer(), chunkX, chunkZ);
|
||||
|
||||
if(!chunk.isTerrainPopulated)
|
||||
{
|
||||
chunk.isTerrainPopulated = true;
|
||||
spawner.registerChunkForPopulation(worldObj.provider.dimensionId, chunkX, chunkZ);
|
||||
if(!chunk.isTerrainPopulated()) {
|
||||
chunk.setTerrainPopulated(true);
|
||||
spawner.registerChunkForPopulation(worldObj.provider.getDimensionId(), chunkX, chunkZ);
|
||||
}
|
||||
return chunk;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Chunk loadChunk(int var1, int var2)
|
||||
{
|
||||
return this.provideChunk(var1, var2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void populate(IChunkProvider chunkProvider, int chunkX, int chunkZ)
|
||||
{
|
||||
public void populate(IChunkProvider chunkProvider, int chunkX, int chunkZ) {
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Override
|
||||
public List getPossibleCreatures(EnumCreatureType var1, int var2, int var3, int var4)
|
||||
{
|
||||
public List getPossibleCreatures(EnumCreatureType type, BlockPos pos) {
|
||||
NewDimData dimension = PocketManager.createDimensionData(this.worldObj);
|
||||
if (dimension != null && dimension.dungeon() != null && !dimension.dungeon().isOpen())
|
||||
{
|
||||
return this.worldObj.getBiomeGenForCoords(var2, var3).getSpawnableList(var1);
|
||||
if (dimension != null && dimension.dungeon() != null && !dimension.dungeon().isOpen()) {
|
||||
return this.worldObj.getBiomeGenForCoords(pos).getSpawnableList(type);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChunkPosition func_147416_a(World var1, String var2, int var3, int var4, int var5)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -7,6 +7,7 @@ import com.zixiken.dimdoors.core.PocketManager;
|
|||
import com.zixiken.dimdoors.ticking.CustomLimboPopulator;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.WorldProvider;
|
||||
import net.minecraft.world.biome.WorldChunkManagerHell;
|
||||
|
@ -14,17 +15,15 @@ import net.minecraft.world.chunk.IChunkProvider;
|
|||
import net.minecraftforge.client.IRenderHandler;
|
||||
import com.zixiken.dimdoors.CloudRenderBlank;
|
||||
import com.zixiken.dimdoors.core.DimensionType;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;;
|
||||
|
||||
public class PocketProvider extends WorldProvider
|
||||
{
|
||||
public class PocketProvider extends WorldProvider {
|
||||
private DDProperties properties;
|
||||
protected CustomLimboPopulator spawner;
|
||||
protected IRenderHandler skyRenderer;
|
||||
|
||||
public PocketProvider()
|
||||
{
|
||||
public PocketProvider() {
|
||||
this.hasNoSky = true;
|
||||
this.skyRenderer = new PocketSkyProvider();
|
||||
|
||||
|
@ -33,8 +32,7 @@ public class PocketProvider extends WorldProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void registerWorldChunkManager()
|
||||
{
|
||||
protected void registerWorldChunkManager() {
|
||||
super.worldChunkMgr = new WorldChunkManagerHell(DimDoors.pocketBiome, 1);
|
||||
}
|
||||
|
||||
|
@ -45,75 +43,65 @@ public class PocketProvider extends WorldProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
public Vec3 getSkyColor(Entity cameraEntity, float partialTicks)
|
||||
{
|
||||
public Vec3 getSkyColor(Entity cameraEntity, float partialTicks) {
|
||||
setCloudRenderer( new CloudRenderBlank());
|
||||
return Vec3.createVectorHelper(0d, 0d, 0d);
|
||||
return new Vec3(0d, 0d, 0d);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public Vec3 getFogColor(float par1, float par2)
|
||||
{
|
||||
return Vec3.createVectorHelper(0d, 0d, 0d);
|
||||
public Vec3 getFogColor(float par1, float par2) {
|
||||
return new Vec3(0d, 0d, 0d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getHorizon()
|
||||
{
|
||||
public double getHorizon() {
|
||||
return worldObj.getHeight();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IChunkProvider createChunkGenerator()
|
||||
{
|
||||
public IChunkProvider createChunkGenerator() {
|
||||
return new PocketGenerator(worldObj, dimensionId, false, spawner);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSnowAt(int x, int y, int z, boolean light)
|
||||
{
|
||||
public boolean canSnowAt(BlockPos pos, boolean light) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBlockFreeze(int x, int y, int z, boolean byWater)
|
||||
{
|
||||
public boolean canBlockFreeze(BlockPos pos, boolean byWater) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public float calculateCelestialAngle(long par1, float par3)
|
||||
{
|
||||
public float calculateCelestialAngle(long par1, float par3) {
|
||||
return .5F;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void generateLightBrightnessTable()
|
||||
{
|
||||
if (!PocketManager.isLoaded())
|
||||
{
|
||||
protected void generateLightBrightnessTable() {
|
||||
if (!PocketManager.isLoaded()) {
|
||||
super.generateLightBrightnessTable();
|
||||
return;
|
||||
}
|
||||
|
||||
NewDimData data = PocketManager.getDimensionData(this.dimensionId);
|
||||
if(data == null || data.type() == DimensionType.POCKET)
|
||||
{
|
||||
if(data == null || data.type() == DimensionType.POCKET) {
|
||||
super.generateLightBrightnessTable();
|
||||
return;
|
||||
}
|
||||
|
||||
float modifier = 0.0F;
|
||||
|
||||
for (int steps = 0; steps <= 15; ++steps)
|
||||
{
|
||||
for (int steps = 0; steps <= 15; ++steps) {
|
||||
float var3 = (float) (Math.pow(steps,1.5) / Math.pow(15.0F,1.5));
|
||||
this.lightBrightnessTable[15-steps] = var3;
|
||||
System.out.println( this.lightBrightnessTable[steps]+"light");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDimensionName()
|
||||
{
|
||||
public String getDimensionName() {
|
||||
//TODO: This should be a proper name. We need to show people proper names for things whenever possible.
|
||||
//The question is whether this should be "Pocket Dimension" or "Pocket Dimension #" -- I'm not going to change
|
||||
//it out of concern that it could break something. ~SenseiKiwi
|
||||
|
@ -121,16 +109,17 @@ public class PocketProvider extends WorldProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
public int getRespawnDimension(EntityPlayerMP player)
|
||||
{
|
||||
public String getInternalNameSuffix() {
|
||||
return "_pocket";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRespawnDimension(EntityPlayerMP player) {
|
||||
int respawnDim;
|
||||
|
||||
if (properties.LimboEnabled)
|
||||
{
|
||||
if (properties.LimboEnabled) {
|
||||
respawnDim = properties.LimboDimensionID;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
respawnDim = PocketManager.getDimensionData(this.dimensionId).root().id();
|
||||
}
|
||||
// TODO: Are we sure we need to load the dimension as well? Why can't the game handle that?
|
||||
|
@ -139,14 +128,12 @@ public class PocketProvider extends WorldProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canRespawnHere()
|
||||
{
|
||||
public boolean canRespawnHere() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getActualHeight()
|
||||
{
|
||||
public int getActualHeight() {
|
||||
return 256;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.zixiken.dimdoors.world.gateways;
|
||||
|
||||
import com.zixiken.dimdoors.config.DDProperties;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
|
||||
|
@ -16,27 +17,21 @@ public abstract class BaseGateway
|
|||
/**
|
||||
* Generates the gateway centered on the given coordinates
|
||||
* @param world - the world in which to generate the gateway
|
||||
* @param x - the x-coordinate at which to center the gateway; usually where the door is placed
|
||||
* @param y - the y-coordinate of the block on which the gateway may be built
|
||||
* @param z - the z-coordinate at which to center the gateway; usually where the door is placed
|
||||
* @param pos - the coordinate at which to center the gateway; usually where the door is placed
|
||||
*/
|
||||
public abstract boolean generate(World world, int x, int y, int z);
|
||||
public abstract boolean generate(World world, BlockPos pos);
|
||||
|
||||
/**
|
||||
* Determines whether the specified biome is a valid biome in which to generate this gateway
|
||||
* @param biome - the biome to be checked
|
||||
* @return <code>true</code> true if the specified biome is a valid for generating this gateway, otherwise <code>false</code>
|
||||
*/
|
||||
protected boolean isBiomeValid(BiomeGenBase biome)
|
||||
{
|
||||
protected boolean isBiomeValid(BiomeGenBase biome) {
|
||||
String biomeName = biome.biomeName.toLowerCase();
|
||||
String[] keywords = this.getBiomeKeywords();
|
||||
if (keywords != null)
|
||||
{
|
||||
for (String keyword : keywords)
|
||||
{
|
||||
if (biomeName.contains(keyword))
|
||||
{
|
||||
if (keywords != null) {
|
||||
for (String keyword : keywords) {
|
||||
if (biomeName.contains(keyword)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -48,14 +43,11 @@ public abstract class BaseGateway
|
|||
/**
|
||||
* Determines whether the specified world and coordinates are a valid location for generating this gateway
|
||||
* @param world - the world in which to generate the gateway
|
||||
* @param x - the x-coordinate at which to center the gateway; usually where the door is placed
|
||||
* @param y - the y-coordinate of the block on which the gateway may be built
|
||||
* @param z - the z-coordinate at which to center the gateway; usually where the door is placed
|
||||
* @param pos - the coordinate at which to center the gateway; usually where the door is placed
|
||||
* @return <code>true</code> if the location is valid, otherwise <code>false</code>
|
||||
*/
|
||||
public boolean isLocationValid(World world, int x, int y, int z)
|
||||
{
|
||||
return isBiomeValid(world.getBiomeGenForCoords(x, z));
|
||||
public boolean isLocationValid(World world, BlockPos pos) {
|
||||
return isBiomeValid(world.getBiomeGenForCoords(pos));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -71,8 +63,7 @@ public abstract class BaseGateway
|
|||
* Gets the lowercase keywords to be used in checking whether a given biome is a valid location for this gateway
|
||||
* @return an array of biome keywords to match against
|
||||
*/
|
||||
public String[] getBiomeKeywords()
|
||||
{
|
||||
public String[] getBiomeKeywords() {
|
||||
return new String[] { "" };
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,26 +6,23 @@ import com.zixiken.dimdoors.core.LinkType;
|
|||
import com.zixiken.dimdoors.core.PocketManager;
|
||||
import com.zixiken.dimdoors.dungeon.DungeonSchematic;
|
||||
import com.zixiken.dimdoors.schematic.InvalidSchematicException;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.Vec3i;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public abstract class BaseSchematicGateway extends BaseGateway
|
||||
{
|
||||
public BaseSchematicGateway(DDProperties properties)
|
||||
{
|
||||
public abstract class BaseSchematicGateway extends BaseGateway {
|
||||
public BaseSchematicGateway(DDProperties properties) {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean generate(World world, int x, int y, int z)
|
||||
{
|
||||
public boolean generate(World world, BlockPos pos) {
|
||||
DungeonSchematic schematic;
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
schematic = DungeonSchematic.readFromResource(this.getSchematicPath());
|
||||
}
|
||||
catch (InvalidSchematicException e)
|
||||
{
|
||||
} catch (InvalidSchematicException e) {
|
||||
System.err.println("Could not load the schematic for a gateway. The following exception occurred:");
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
|
@ -37,14 +34,14 @@ public abstract class BaseSchematicGateway extends BaseGateway
|
|||
schematic.applyImportFilters(properties);
|
||||
|
||||
BlockPos doorLocation = gatewayFilter.getEntranceDoorLocation();
|
||||
int orientation = gatewayFilter.getEntranceOrientation();
|
||||
EnumFacing orientation = gatewayFilter.getEntranceOrientation();
|
||||
|
||||
// Build the gateway into the world
|
||||
schematic.copyToWorld(world, x - doorLocation.getX(), y, z - doorLocation.getZ(), true, true);
|
||||
this.generateRandomBits(world, x, y, z);
|
||||
schematic.copyToWorld(world, pos.subtract(new Vec3i(doorLocation.getX(), 0, doorLocation.getZ())), true, true);
|
||||
this.generateRandomBits(world, pos);
|
||||
|
||||
// Generate a dungeon link in the door
|
||||
PocketManager.getDimensionData(world).createLink(x, y + doorLocation.getY(), z, LinkType.DUNGEON, orientation);
|
||||
PocketManager.getDimensionData(world).createLink(pos.add(0, doorLocation.getY(), 0), LinkType.DUNGEON, orientation);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -52,11 +49,10 @@ public abstract class BaseSchematicGateway extends BaseGateway
|
|||
/**
|
||||
* Generates randomized portions of the gateway structure (e.g. rubble, foliage)
|
||||
* @param world - the world in which to generate the gateway
|
||||
* @param x - the x-coordinate at which to center the gateway; usually where the door is placed
|
||||
* @param y - the y-coordinate of the block on which the gateway may be built
|
||||
* @param z - the z-coordinate at which to center the gateway; usually where the door is placed
|
||||
* @param pos - the coordinate at which to center the gateway; usually where the door is placed
|
||||
*/
|
||||
protected void generateRandomBits(World world, int x, int y, int z) { }
|
||||
protected void generateRandomBits(World world, BlockPos pos) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the path for the schematic file to be used for this gateway. Subsequent calls to this method may return other schematic paths.
|
||||
|
|
|
@ -1,30 +1,29 @@
|
|||
package com.zixiken.dimdoors.world.gateways;
|
||||
|
||||
import com.zixiken.dimdoors.DimDoors;
|
||||
import com.zixiken.dimdoors.blocks.DimensionalDoor;
|
||||
import com.zixiken.dimdoors.blocks.TransientDoor;
|
||||
import com.zixiken.dimdoors.blocks.WarpDoor;
|
||||
import com.zixiken.dimdoors.schematic.Schematic;
|
||||
import com.zixiken.dimdoors.schematic.SchematicFilter;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
public class GatewayBlockFilter extends SchematicFilter {
|
||||
|
||||
private static final short STANDARD_WARP_DOOR_ID = 1975;
|
||||
private static final short STANDARD_DIMENSIONAL_DOOR_ID = 1970;
|
||||
private static final short STANDARD_TRANSIENT_DOOR_ID = 1979;
|
||||
|
||||
private int entranceOrientation;
|
||||
private EnumFacing entranceOrientation;
|
||||
private Schematic schematic;
|
||||
private BlockPos entranceDoorLocation;
|
||||
|
||||
public GatewayBlockFilter()
|
||||
{
|
||||
public GatewayBlockFilter() {
|
||||
super("GatewayEntranceFinder");
|
||||
this.entranceDoorLocation = null;
|
||||
this.entranceOrientation = 0;
|
||||
this.entranceOrientation = EnumFacing.NORTH;
|
||||
this.schematic = null;
|
||||
}
|
||||
|
||||
public int getEntranceOrientation() {
|
||||
public EnumFacing getEntranceOrientation() {
|
||||
return entranceOrientation;
|
||||
}
|
||||
|
||||
|
@ -33,44 +32,33 @@ public class GatewayBlockFilter extends SchematicFilter {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected boolean initialize(Schematic schematic, Block[] blocks, byte[] metadata)
|
||||
{
|
||||
protected boolean initialize(Schematic schematic, IBlockState[] states) {
|
||||
this.schematic = schematic;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean applyToBlock(int index, Block[] blocks, byte[] metadata)
|
||||
{
|
||||
protected boolean applyToBlock(int index, IBlockState[] states) {
|
||||
int indexBelow;
|
||||
int indexDoubleBelow;
|
||||
if (blocks[index] == DimDoors.dimensionalDoor)
|
||||
{
|
||||
if (states[index] == DimDoors.dimensionalDoor) {
|
||||
indexBelow = schematic.calculateIndexBelow(index);
|
||||
if (indexBelow >= 0 && blocks[indexBelow] == DimDoors.dimensionalDoor)
|
||||
{
|
||||
if (indexBelow >= 0 && states[indexBelow] == DimDoors.dimensionalDoor) {
|
||||
entranceDoorLocation = schematic.calculatePoint(index);
|
||||
entranceOrientation = (metadata[indexBelow] & 3);
|
||||
entranceOrientation = states[indexBelow].getValue(DimensionalDoor.FACING);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (blocks[index] == DimDoors.transientDoor)
|
||||
{
|
||||
} if (states[index] == DimDoors.transientDoor) {
|
||||
indexBelow = schematic.calculateIndexBelow(index);
|
||||
if (indexBelow >= 0 && blocks[indexBelow] == DimDoors.transientDoor)
|
||||
{
|
||||
if (indexBelow >= 0 && states[indexBelow] == DimDoors.transientDoor) {
|
||||
entranceDoorLocation = schematic.calculatePoint(index);
|
||||
entranceOrientation = (metadata[indexBelow] & 3);
|
||||
entranceOrientation = states[indexBelow].getValue(TransientDoor.FACING);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (blocks[index] == DimDoors.warpDoor)
|
||||
{
|
||||
} if (states[index] == DimDoors.warpDoor) {
|
||||
indexBelow = schematic.calculateIndexBelow(index);
|
||||
if (indexBelow >= 0 && blocks[indexBelow] == DimDoors.warpDoor)
|
||||
{
|
||||
if (indexBelow >= 0 && states[indexBelow] == DimDoors.warpDoor) {
|
||||
entranceDoorLocation = schematic.calculatePoint(index);
|
||||
entranceOrientation = (metadata[indexBelow] & 3);
|
||||
entranceOrientation = states[indexBelow].getValue(WarpDoor.FACING);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -78,8 +66,7 @@ public class GatewayBlockFilter extends SchematicFilter {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected boolean terminates()
|
||||
{
|
||||
protected boolean terminates() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue