fixed commands and rift orientation
This commit is contained in:
parent
8dd1d85e6e
commit
8fbb41a588
11 changed files with 149 additions and 57 deletions
|
@ -230,13 +230,13 @@ public class DDProperties
|
|||
"Sets the chance (out of " + MonolithSpawner.MAX_MONOLITH_SPAWNING_CHANCE + ") that Monoliths will " +
|
||||
"spawn in a given Limbo chunk. The default chance is 28.").getInt();
|
||||
|
||||
ClusterGenerationChance = config.get(Configuration.CATEGORY_GENERAL, "Cluster Generation Chance", 3,
|
||||
ClusterGenerationChance = config.get(Configuration.CATEGORY_GENERAL, "Cluster Generation Chance", 2,
|
||||
"Sets the chance (out of " + GatewayGenerator.MAX_CLUSTER_GENERATION_CHANCE + ") that a cluster of rifts will " +
|
||||
"generate in a given chunk. The default chance is 3.").getInt();
|
||||
"generate in a given chunk. The default chance is 2.").getInt();
|
||||
|
||||
GatewayGenerationChance = config.get(Configuration.CATEGORY_GENERAL, "Gateway Generation Chance", 10,
|
||||
GatewayGenerationChance = config.get(Configuration.CATEGORY_GENERAL, "Gateway Generation Chance", 15,
|
||||
"Sets the chance (out of " + GatewayGenerator.MAX_GATEWAY_GENERATION_CHANCE + ") that a Rift Gateway will " +
|
||||
"generate in a given chunk. The default chance is 10.").getInt();
|
||||
"generate in a given chunk. The default chance is 15.").getInt();
|
||||
|
||||
LimboBiomeID = config.get(CATEGORY_BIOME, "Limbo Biome ID", 251).getInt();
|
||||
PocketBiomeID = config.get(CATEGORY_BIOME, "Pocket Biome ID", 250).getInt();
|
||||
|
|
|
@ -96,7 +96,7 @@ public class TransTrapdoor extends BlockTrapDoor implements IDimDoor, ITileEntit
|
|||
DimLink link = dimension.getLink(x, y, z);
|
||||
if (link == null && dimension.isPocketDimension())
|
||||
{
|
||||
dimension.createLink(x, y, z, LinkTypes.UNSAFE_EXIT);
|
||||
dimension.createLink(x, y, z, LinkTypes.UNSAFE_EXIT,0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
|||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
import StevenDimDoors.mod_pocketDim.dungeon.DungeonData;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.DungeonHelper;
|
||||
import StevenDimDoors.mod_pocketDim.world.PocketBuilder;
|
||||
|
||||
public class CommandCreateDungeonRift extends DDCommandBase
|
||||
{
|
||||
|
@ -70,7 +71,7 @@ public class CommandCreateDungeonRift extends DDCommandBase
|
|||
{
|
||||
|
||||
dimension = PocketManager.getDimensionData(sender.worldObj);
|
||||
link = dimension.createLink(x, y + 1, z, LinkTypes.DUNGEON);
|
||||
link = dimension.createLink(x, y + 1, z, LinkTypes.DUNGEON,orientation);
|
||||
sender.worldObj.setBlock(x, y + 1, z,mod_pocketDim.blockRift.blockID,0,3);
|
||||
|
||||
sender.sendChatToPlayer("Created a rift to a random dungeon.");
|
||||
|
@ -88,8 +89,9 @@ public class CommandCreateDungeonRift extends DDCommandBase
|
|||
//Create a rift to our selected dungeon and notify the player
|
||||
//TODO currently crashes, need to create the dimension first
|
||||
dimension = PocketManager.getDimensionData(sender.worldObj);
|
||||
link = dimension.createLink(x, y + 1, z, LinkTypes.DUNGEON);
|
||||
PocketManager.getDimensionData(link.destination().getDimension()).initializeDungeon(x, y + 1, z, orientation,link, result);
|
||||
link = dimension.createLink(x, y + 1, z, LinkTypes.DUNGEON,orientation);
|
||||
PocketBuilder.generateSelectedDungeonPocket(link, mod_pocketDim.properties, result);
|
||||
|
||||
sender.worldObj.setBlock(x, y + 1, z,mod_pocketDim.blockRift.blockID,0,3);
|
||||
sender.sendChatToPlayer("Created a rift to \"" + result.schematicName() + "\" dungeon (Dimension ID = " + link.destination().getDimension() + ").");
|
||||
}
|
||||
|
|
|
@ -244,10 +244,7 @@ public abstract class NewDimData
|
|||
{
|
||||
return Math.abs(i) + Math.abs(j) + Math.abs(k);
|
||||
}
|
||||
public DimLink createLink(int x, int y, int z, int linkType)
|
||||
{
|
||||
return createLink(new Point4D(x, y, z, id), linkType,0);
|
||||
}
|
||||
|
||||
public DimLink createLink(int x, int y, int z, int linkType,int orientation)
|
||||
{
|
||||
return createLink(new Point4D(x, y, z, id), linkType,orientation);
|
||||
|
|
|
@ -27,6 +27,7 @@ import StevenDimDoors.mod_pocketDim.saving.PackedLinkData;
|
|||
import StevenDimDoors.mod_pocketDim.saving.PackedLinkTail;
|
||||
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
||||
import StevenDimDoors.mod_pocketDim.watcher.ClientDimData;
|
||||
import StevenDimDoors.mod_pocketDim.watcher.ClientLinkData;
|
||||
import StevenDimDoors.mod_pocketDim.watcher.IUpdateSource;
|
||||
import StevenDimDoors.mod_pocketDim.watcher.IUpdateWatcher;
|
||||
import StevenDimDoors.mod_pocketDim.watcher.UpdateWatcherProxy;
|
||||
|
@ -153,18 +154,20 @@ public class PocketManager
|
|||
}
|
||||
}
|
||||
|
||||
private static class ClientLinkWatcher implements IUpdateWatcher<Point4D>
|
||||
private static class ClientLinkWatcher implements IUpdateWatcher<ClientLinkData>
|
||||
{
|
||||
@Override
|
||||
public void onCreated(Point4D source)
|
||||
public void onCreated(ClientLinkData link)
|
||||
{
|
||||
Point4D source = link.point;
|
||||
NewDimData dimension = getDimensionData(source.getDimension());
|
||||
dimension.createLink(source.getX(), source.getY(), source.getZ(), LinkTypes.CLIENT_SIDE);
|
||||
dimension.createLink(source.getX(), source.getY(), source.getZ(), LinkTypes.CLIENT_SIDE,link.orientation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeleted(Point4D source)
|
||||
public void onDeleted(ClientLinkData link)
|
||||
{
|
||||
Point4D source = link.point;
|
||||
NewDimData dimension = getDimensionData(source.getDimension());
|
||||
dimension.deleteLink(source.getX(), source.getY(), source.getZ());
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import StevenDimDoors.mod_pocketDim.core.IDimRegistrationCallback;
|
|||
import StevenDimDoors.mod_pocketDim.core.LinkTypes;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
||||
import StevenDimDoors.mod_pocketDim.watcher.ClientLinkData;
|
||||
|
||||
public class Compactor
|
||||
{
|
||||
|
@ -75,8 +76,9 @@ public class Compactor
|
|||
int linkCount = input.readInt();
|
||||
for (int h = 0; h < linkCount; h++)
|
||||
{
|
||||
Point4D source = Point4D.read(input);
|
||||
dimension.createLink(source.getX(), source.getY(), source.getZ(), LinkTypes.CLIENT_SIDE);
|
||||
ClientLinkData link = ClientLinkData.read(input);
|
||||
Point4D source = link.point;
|
||||
dimension.createLink(source.getX(), source.getY(), source.getZ(), LinkTypes.CLIENT_SIDE,link.orientation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
38
StevenDimDoors/mod_pocketDim/watcher/ClientLinkData.java
Normal file
38
StevenDimDoors/mod_pocketDim/watcher/ClientLinkData.java
Normal file
|
@ -0,0 +1,38 @@
|
|||
package StevenDimDoors.mod_pocketDim.watcher;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
||||
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
||||
|
||||
public class ClientLinkData
|
||||
{
|
||||
public Point4D point;
|
||||
public int orientation;
|
||||
|
||||
public ClientLinkData(DimLink link)
|
||||
{
|
||||
this.point= link.source();
|
||||
this.orientation=link.orientation();
|
||||
}
|
||||
|
||||
public ClientLinkData(Point4D point, int orientation)
|
||||
{
|
||||
this.point = point;
|
||||
this.orientation=orientation;
|
||||
}
|
||||
|
||||
public void write(DataOutputStream output) throws IOException
|
||||
{
|
||||
Point4D.write(point, output);
|
||||
output.writeInt(orientation);
|
||||
}
|
||||
|
||||
public static ClientLinkData read(DataInputStream input) throws IOException
|
||||
{
|
||||
return new ClientLinkData(Point4D.read(input), input.readInt());
|
||||
}
|
||||
|
||||
}
|
|
@ -4,5 +4,5 @@ import StevenDimDoors.mod_pocketDim.util.Point4D;
|
|||
|
||||
public interface IUpdateSource
|
||||
{
|
||||
public void registerWatchers(IUpdateWatcher<ClientDimData> dimWatcher, IUpdateWatcher<Point4D> linkWatcher);
|
||||
public void registerWatchers(IUpdateWatcher<ClientDimData> dimWatcher, IUpdateWatcher<ClientLinkData> linkWatcher);
|
||||
}
|
||||
|
|
|
@ -100,7 +100,7 @@ public class GatewayGenerator implements IWorldGenerator
|
|||
if (link == null)
|
||||
{
|
||||
dimension = PocketManager.getDimensionData(world);
|
||||
link = dimension.createLink(x, y + 1, z, LinkTypes.DUNGEON);
|
||||
link = dimension.createLink(x, y + 1, z, LinkTypes.DUNGEON,0);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -135,7 +135,7 @@ public class GatewayGenerator implements IWorldGenerator
|
|||
{
|
||||
//Create a partial link to a dungeon.
|
||||
dimension = PocketManager.getDimensionData(world);
|
||||
link = dimension.createLink(x, y + 1, z, LinkTypes.DUNGEON);
|
||||
link = dimension.createLink(x, y + 1, z, LinkTypes.DUNGEON,0);
|
||||
|
||||
//If the current dimension isn't Limbo, build a Rift Gateway out of Stone Bricks
|
||||
if (dimension.id() != properties.LimboDimensionID)
|
||||
|
|
|
@ -118,6 +118,85 @@ public class PocketBuilder
|
|||
|
||||
|
||||
}
|
||||
|
||||
private static boolean buildDungeonPocket(DungeonData dungeon, NewDimData dimension, DimLink link, DungeonSchematic schematic,World world, DDProperties properties)
|
||||
{
|
||||
|
||||
//Calculate the destination point
|
||||
DungeonPackConfig packConfig = dungeon.dungeonType().Owner != null ? dungeon.dungeonType().Owner.getConfig() : null;
|
||||
Point4D source = link.source();
|
||||
int orientation = link.orientation();
|
||||
Point3D destination;
|
||||
|
||||
if (packConfig != null && packConfig.doDistortDoorCoordinates())
|
||||
{
|
||||
destination = calculateNoisyDestination(source, dimension, dungeon, orientation);
|
||||
}
|
||||
else
|
||||
{
|
||||
destination = new Point3D(source.getX(), source.getY(), source.getZ());
|
||||
}
|
||||
|
||||
destination.setY( yCoordHelper.adjustDestinationY(destination.getY(), world.getHeight(), schematic.getEntranceDoorLocation().getY(), schematic.getHeight()) );
|
||||
|
||||
//Generate the dungeon
|
||||
schematic.copyToWorld(world, destination, orientation, link, random);
|
||||
|
||||
//Finish up destination initialization
|
||||
dimension.initializeDungeon(destination.getX(), destination.getY(), destination.getZ(), orientation, link, dungeon);
|
||||
dimension.setFilled(true);
|
||||
return true;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static boolean generateSelectedDungeonPocket(DimLink link, DDProperties properties,DungeonData data)
|
||||
{
|
||||
if (link == null)
|
||||
{
|
||||
throw new IllegalArgumentException("link cannot be null.");
|
||||
}
|
||||
if (properties == null)
|
||||
{
|
||||
throw new IllegalArgumentException("properties cannot be null.");
|
||||
}
|
||||
|
||||
if (link.hasDestination())
|
||||
{
|
||||
throw new IllegalArgumentException("link cannot have a destination assigned already.");
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Register a new dimension
|
||||
NewDimData parent = PocketManager.getDimensionData(link.source().getDimension());
|
||||
NewDimData dimension = PocketManager.registerPocket(parent, true);
|
||||
|
||||
//Load a world
|
||||
World world = PocketManager.loadDimension(dimension.id());
|
||||
|
||||
if (world == null || world.provider == null)
|
||||
{
|
||||
System.err.println("Could not initialize dimension for a dungeon!");
|
||||
return false;
|
||||
}
|
||||
|
||||
DungeonData dungeon = null;
|
||||
DungeonSchematic schematic = null;
|
||||
|
||||
dungeon = data;
|
||||
if (data == null)
|
||||
{
|
||||
System.err.println("Could not select a dungeon for generation!");
|
||||
return false;
|
||||
}
|
||||
schematic = loadAndValidateDungeon(dungeon,properties);
|
||||
|
||||
return PocketBuilder.buildDungeonPocket(dungeon, dimension, link, schematic, world, properties);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static boolean generateNewDungeonPocket(DimLink link, DDProperties properties)
|
||||
{
|
||||
if (link == null)
|
||||
|
@ -135,8 +214,7 @@ public class PocketBuilder
|
|||
}
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
//Register a new dimension
|
||||
NewDimData parent = PocketManager.getDimensionData(link.source().getDimension());
|
||||
NewDimData dimension = PocketManager.registerPocket(parent, true);
|
||||
|
@ -160,36 +238,7 @@ public class PocketBuilder
|
|||
DungeonData dungeon = pair.getFirst();
|
||||
DungeonSchematic schematic = pair.getSecond();
|
||||
|
||||
//Calculate the destination point
|
||||
DungeonPackConfig packConfig = dungeon.dungeonType().Owner != null ? dungeon.dungeonType().Owner.getConfig() : null;
|
||||
Point4D source = link.source();
|
||||
int orientation = getDoorOrientation(source, properties);
|
||||
Point3D destination;
|
||||
|
||||
if (packConfig != null && packConfig.doDistortDoorCoordinates())
|
||||
{
|
||||
destination = calculateNoisyDestination(source, dimension, dungeon, orientation);
|
||||
}
|
||||
else
|
||||
{
|
||||
destination = new Point3D(source.getX(), source.getY(), source.getZ());
|
||||
}
|
||||
|
||||
destination.setY( yCoordHelper.adjustDestinationY(destination.getY(), world.getHeight(), schematic.getEntranceDoorLocation().getY(), schematic.getHeight()) );
|
||||
|
||||
//Generate the dungeon
|
||||
schematic.copyToWorld(world, destination, orientation, link, random);
|
||||
|
||||
//Finish up destination initialization
|
||||
dimension.initializeDungeon(destination.getX(), destination.getY(), destination.getZ(), orientation, link, dungeon);
|
||||
dimension.setFilled(true);
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
return buildDungeonPocket(dungeon, dimension, link, schematic, world, properties);
|
||||
}
|
||||
|
||||
private static Point3D calculateNoisyDestination(Point4D source, NewDimData dimension, DungeonData dungeon, int orientation)
|
||||
|
|
|
@ -10,6 +10,7 @@ import StevenDimDoors.mod_pocketDim.PacketConstants;
|
|||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
||||
import StevenDimDoors.mod_pocketDim.watcher.ClientDimData;
|
||||
import StevenDimDoors.mod_pocketDim.watcher.ClientLinkData;
|
||||
import StevenDimDoors.mod_pocketDim.watcher.IUpdateSource;
|
||||
import StevenDimDoors.mod_pocketDim.watcher.IUpdateWatcher;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
|
@ -19,7 +20,7 @@ import cpw.mods.fml.relauncher.Side;
|
|||
|
||||
public class ClientPacketHandler implements IPacketHandler, IUpdateSource
|
||||
{
|
||||
private IUpdateWatcher<Point4D> linkWatcher;
|
||||
private IUpdateWatcher<ClientLinkData> linkWatcher;
|
||||
private IUpdateWatcher<ClientDimData> dimWatcher;
|
||||
|
||||
public ClientPacketHandler()
|
||||
|
@ -28,7 +29,7 @@ public class ClientPacketHandler implements IPacketHandler, IUpdateSource
|
|||
}
|
||||
|
||||
@Override
|
||||
public void registerWatchers(IUpdateWatcher<ClientDimData> dimWatcher, IUpdateWatcher<Point4D> linkWatcher)
|
||||
public void registerWatchers(IUpdateWatcher<ClientDimData> dimWatcher, IUpdateWatcher<ClientLinkData> linkWatcher)
|
||||
{
|
||||
this.dimWatcher = dimWatcher;
|
||||
this.linkWatcher = linkWatcher;
|
||||
|
@ -58,13 +59,13 @@ public class ClientPacketHandler implements IPacketHandler, IUpdateSource
|
|||
dimWatcher.onCreated( ClientDimData.read(input) );
|
||||
break;
|
||||
case PacketConstants.CREATE_LINK_PACKET_ID:
|
||||
linkWatcher.onCreated( Point4D.read(input) );
|
||||
linkWatcher.onCreated( ClientLinkData.read(input) );
|
||||
break;
|
||||
case PacketConstants.DELETE_DIM_PACKET_ID:
|
||||
dimWatcher.onDeleted( ClientDimData.read(input) );
|
||||
break;
|
||||
case PacketConstants.DELETE_LINK_PACKET_ID:
|
||||
linkWatcher.onDeleted( Point4D.read(input) );
|
||||
linkWatcher.onDeleted( ClientLinkData.read(input) );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue