Rewrite Continued #84
@@ -192,12 +192,7 @@ public class DDTeleporter
|
|||||||
if (difDest)
|
if (difDest)
|
||||||
{
|
{
|
||||||
// Destination isn't loaded? Then we need to load it.
|
// Destination isn't loaded? Then we need to load it.
|
||||||
newWorld = DimensionManager.getWorld(destination.getDimension());
|
newWorld = PocketManager.loadDimension(destination.getDimension());
|
||||||
if (newWorld == null)
|
|
||||||
{
|
|
||||||
DimensionManager.initDimension(destination.getDimension());
|
|
||||||
newWorld = DimensionManager.getWorld(destination.getDimension());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -230,10 +225,10 @@ public class DDTeleporter
|
|||||||
oldWorld.getPlayerManager().removePlayer(player);
|
oldWorld.getPlayerManager().removePlayer(player);
|
||||||
newWorld.getPlayerManager().addPlayer(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.
|
// 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);
|
player.mcServer.getConfigurationManager().syncPlayerInventory(player);
|
||||||
for(Object potionEffect : player.getActivePotionEffects())
|
for(Object potionEffect : player.getActivePotionEffects())
|
||||||
{
|
{
|
||||||
@@ -304,7 +299,7 @@ public class DDTeleporter
|
|||||||
DDTeleporter.placeInPortal(entity, newWorld, destination, properties);
|
DDTeleporter.placeInPortal(entity, newWorld, destination, properties);
|
||||||
return entity;
|
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.
|
* 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.
|
* Also ensures correct orientation relative to the door.
|
||||||
@@ -347,7 +342,7 @@ public class DDTeleporter
|
|||||||
|
|
||||||
if (link.linkType() == LinkTypes.RANDOM)
|
if (link.linkType() == LinkTypes.RANDOM)
|
||||||
{
|
{
|
||||||
Point4D randomDestination = getRandomDestination();
|
Point4D randomDestination = prepareRandomDestination();
|
||||||
if (randomDestination != null)
|
if (randomDestination != null)
|
||||||
{
|
{
|
||||||
entity = teleportEntity(entity, randomDestination);
|
entity = teleportEntity(entity, randomDestination);
|
||||||
@@ -364,6 +359,7 @@ public class DDTeleporter
|
|||||||
private static boolean initializeDestination(DimLink link, DDProperties properties)
|
private static boolean initializeDestination(DimLink link, DDProperties properties)
|
||||||
{
|
{
|
||||||
//FIXME: Change this later to support rooms that have been wiped and must be regenerated.
|
//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())
|
if (link.hasDestination())
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
@@ -378,7 +374,13 @@ public class DDTeleporter
|
|||||||
return PocketBuilder.generateNewDungeonPocket(link, properties);
|
return PocketBuilder.generateNewDungeonPocket(link, properties);
|
||||||
case LinkTypes.POCKET:
|
case LinkTypes.POCKET:
|
||||||
return PocketBuilder.generateNewPocket(link, properties);
|
return PocketBuilder.generateNewPocket(link, properties);
|
||||||
|
case LinkTypes.SAFE_EXIT:
|
||||||
|
case LinkTypes.DUNGEON_EXIT:
|
||||||
|
return ;
|
||||||
|
case LinkTypes.UNSAFE_EXIT:
|
||||||
|
return ;
|
||||||
case LinkTypes.NORMAL:
|
case LinkTypes.NORMAL:
|
||||||
|
case LinkTypes.REVERSE:
|
||||||
case LinkTypes.RANDOM:
|
case LinkTypes.RANDOM:
|
||||||
return true;
|
return true;
|
||||||
default:
|
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.
|
// so that a link of type RANDOM can teleport a player there.
|
||||||
|
|
||||||
// Restrictions:
|
// Restrictions:
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ public class LinkTypes
|
|||||||
private LinkTypes() { }
|
private LinkTypes() { }
|
||||||
|
|
||||||
public static final int ENUM_MIN = 0;
|
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;
|
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 DUNGEON_EXIT = 4;
|
||||||
public static final int SAFE_EXIT = 5;
|
public static final int SAFE_EXIT = 5;
|
||||||
public static final int UNSAFE_EXIT = 6;
|
public static final int UNSAFE_EXIT = 6;
|
||||||
|
public static final int REVERSE = 7;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import java.io.IOException;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraft.world.WorldServer;
|
||||||
import net.minecraftforge.common.DimensionManager;
|
import net.minecraftforge.common.DimensionManager;
|
||||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||||
import StevenDimDoors.mod_pocketDim.helpers.Compactor;
|
import StevenDimDoors.mod_pocketDim.helpers.Compactor;
|
||||||
@@ -281,6 +282,22 @@ public class PocketManager
|
|||||||
isSaving = false;
|
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)
|
public static NewDimData registerDimension(World world)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -285,7 +285,7 @@ public class DungeonSchematic extends Schematic {
|
|||||||
|
|
||||||
private static void createEntranceReverseLink(NewDimData dimension, Point3D pocketCenter, DimLink entryLink)
|
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();
|
Point4D destination = entryLink.source();
|
||||||
NewDimData prevDim = PocketManager.getDimensionData(destination.getDimension());
|
NewDimData prevDim = PocketManager.getDimensionData(destination.getDimension());
|
||||||
prevDim.setDestination(reverseLink, destination.getX(), destination.getY(), destination.getZ());
|
prevDim.setDestination(reverseLink, destination.getX(), destination.getY(), destination.getZ());
|
||||||
|
|||||||
@@ -61,17 +61,8 @@ public class PocketBuilder
|
|||||||
NewDimData dimension = PocketManager.registerPocket(parent, true);
|
NewDimData dimension = PocketManager.registerPocket(parent, true);
|
||||||
|
|
||||||
//Load a world
|
//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)
|
if (world == null || world.provider == null)
|
||||||
{
|
{
|
||||||
System.err.println("Could not initialize dimension for a dungeon!");
|
System.err.println("Could not initialize dimension for a dungeon!");
|
||||||
@@ -282,17 +273,8 @@ public class PocketBuilder
|
|||||||
NewDimData dimension = PocketManager.registerPocket(parent, false);
|
NewDimData dimension = PocketManager.registerPocket(parent, false);
|
||||||
|
|
||||||
//Load a world
|
//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)
|
if (world == null || world.provider == null)
|
||||||
{
|
{
|
||||||
System.err.println("Could not initialize dimension for a pocket!");
|
System.err.println("Could not initialize dimension for a pocket!");
|
||||||
@@ -305,7 +287,7 @@ public class PocketBuilder
|
|||||||
int orientation = getDoorOrientation(source, properties);
|
int orientation = getDoorOrientation(source, properties);
|
||||||
|
|
||||||
//Place a link leading back out of the pocket
|
//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());
|
parent.setDestination(reverseLink, source.getX(), source.getY(), source.getZ());
|
||||||
|
|
||||||
//Build the actual pocket area
|
//Build the actual pocket area
|
||||||
|
|||||||
Reference in New Issue
Block a user