Rewrite Continued #84

Merged
SenseiKiwi merged 11 commits from rewrite into DevBranch 2013-09-06 02:57:33 +00:00
5 changed files with 37 additions and 35 deletions
Showing only changes of commit 03660699cf - Show all commits

View File

@@ -192,12 +192,7 @@ public class DDTeleporter
if (difDest)
{
// Destination isn't loaded? Then we need to load it.
newWorld = DimensionManager.getWorld(destination.getDimension());
if (newWorld == null)
{
DimensionManager.initDimension(destination.getDimension());
newWorld = DimensionManager.getWorld(destination.getDimension());
}
newWorld = PocketManager.loadDimension(destination.getDimension());
}
else
{
@@ -230,10 +225,10 @@ public class DDTeleporter
oldWorld.getPlayerManager().removePlayer(player);
newWorld.getPlayerManager().addPlayer(player);
player.theItemInWorldManager.setWorld((WorldServer)newWorld);
player.theItemInWorldManager.setWorld(newWorld);
// Synchronize with the server so the client knows what time it is and what it's holding.
player.mcServer.getConfigurationManager().updateTimeAndWeatherForPlayer(player, (WorldServer)newWorld);
player.mcServer.getConfigurationManager().updateTimeAndWeatherForPlayer(player, newWorld);
player.mcServer.getConfigurationManager().syncPlayerInventory(player);
for(Object potionEffect : player.getActivePotionEffects())
{
@@ -304,7 +299,7 @@ public class DDTeleporter
DDTeleporter.placeInPortal(entity, newWorld, destination, properties);
return entity;
}
/**
* Primary function used to teleport the player using doors. Performs numerous null checks, and also generates the destination door/pocket if it has not done so already.
* Also ensures correct orientation relative to the door.
@@ -347,7 +342,7 @@ public class DDTeleporter
if (link.linkType() == LinkTypes.RANDOM)
{
Point4D randomDestination = getRandomDestination();
Point4D randomDestination = prepareRandomDestination();
if (randomDestination != null)
{
entity = teleportEntity(entity, randomDestination);
@@ -364,6 +359,7 @@ public class DDTeleporter
private static boolean initializeDestination(DimLink link, DDProperties properties)
{
//FIXME: Change this later to support rooms that have been wiped and must be regenerated.
//We might need to implement regeneration for REVERSE links as well.
if (link.hasDestination())
{
return true;
@@ -378,7 +374,13 @@ public class DDTeleporter
return PocketBuilder.generateNewDungeonPocket(link, properties);
case LinkTypes.POCKET:
return PocketBuilder.generateNewPocket(link, properties);
case LinkTypes.SAFE_EXIT:
case LinkTypes.DUNGEON_EXIT:
return ;
case LinkTypes.UNSAFE_EXIT:
return ;
case LinkTypes.NORMAL:
case LinkTypes.REVERSE:
case LinkTypes.RANDOM:
return true;
default:
@@ -386,9 +388,9 @@ public class DDTeleporter
}
}
private static Point4D getRandomDestination()
private static Point4D prepareRandomDestination()
{
// Our aim is to return a point near a random link's source
// Our aim is to return a random link's source point
// so that a link of type RANDOM can teleport a player there.
// Restrictions:

View File

@@ -5,7 +5,7 @@ public class LinkTypes
private LinkTypes() { }
public static final int ENUM_MIN = 0;
public static final int ENUM_MAX = 6;
public static final int ENUM_MAX = 7;
public static final int CLIENT_SIDE = -1337;
@@ -17,4 +17,5 @@ public class LinkTypes
public static final int DUNGEON_EXIT = 4;
public static final int SAFE_EXIT = 5;
public static final int UNSAFE_EXIT = 6;
public static final int REVERSE = 7;
}

View File

@@ -7,6 +7,7 @@ import java.io.IOException;
import java.util.HashMap;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraftforge.common.DimensionManager;
import StevenDimDoors.mod_pocketDim.DDProperties;
import StevenDimDoors.mod_pocketDim.helpers.Compactor;
@@ -281,6 +282,22 @@ public class PocketManager
isSaving = false;
}
}
public static WorldServer loadDimension(int id)
{
WorldServer world = DimensionManager.getWorld(id);
if (world == null)
{
DimensionManager.initDimension(id);
world = DimensionManager.getWorld(id);
}
else if (world.provider == null)
{
DimensionManager.initDimension(id);
world = DimensionManager.getWorld(id);
}
return world;
}
public static NewDimData registerDimension(World world)
{

View File

@@ -285,7 +285,7 @@ public class DungeonSchematic extends Schematic {
private static void createEntranceReverseLink(NewDimData dimension, Point3D pocketCenter, DimLink entryLink)
{
DimLink reverseLink = dimension.createLink(pocketCenter.getX(), pocketCenter.getY(), pocketCenter.getZ(), LinkTypes.NORMAL);
DimLink reverseLink = dimension.createLink(pocketCenter.getX(), pocketCenter.getY(), pocketCenter.getZ(), LinkTypes.REVERSE);
Point4D destination = entryLink.source();
NewDimData prevDim = PocketManager.getDimensionData(destination.getDimension());
prevDim.setDestination(reverseLink, destination.getX(), destination.getY(), destination.getZ());

View File

@@ -61,17 +61,8 @@ public class PocketBuilder
NewDimData dimension = PocketManager.registerPocket(parent, true);
//Load a world
World world = DimensionManager.getWorld(dimension.id());
World world = PocketManager.loadDimension(dimension.id());
if (world == null)
{
DimensionManager.initDimension(dimension.id());
world = DimensionManager.getWorld(dimension.id());
}
if (world != null && world.provider == null)
{
DimensionManager.initDimension(dimension.id());
}
if (world == null || world.provider == null)
{
System.err.println("Could not initialize dimension for a dungeon!");
@@ -282,17 +273,8 @@ public class PocketBuilder
NewDimData dimension = PocketManager.registerPocket(parent, false);
//Load a world
World world = DimensionManager.getWorld(dimension.id());
World world = PocketManager.loadDimension(dimension.id());
if (world == null)
{
DimensionManager.initDimension(dimension.id());
world = DimensionManager.getWorld(dimension.id());
}
if (world != null && world.provider == null)
{
DimensionManager.initDimension(dimension.id());
}
if (world == null || world.provider == null)
{
System.err.println("Could not initialize dimension for a pocket!");
@@ -305,7 +287,7 @@ public class PocketBuilder
int orientation = getDoorOrientation(source, properties);
//Place a link leading back out of the pocket
DimLink reverseLink = dimension.createLink(source.getX(), destinationY, source.getZ(), LinkTypes.NORMAL);
DimLink reverseLink = dimension.createLink(source.getX(), destinationY, source.getZ(), LinkTypes.REVERSE);
parent.setDestination(reverseLink, source.getX(), source.getY(), source.getZ());
//Build the actual pocket area