Mazes #155

Merged
StevenRS11 merged 11 commits from mazes into mazes 2014-04-15 11:46:00 +00:00
4 changed files with 80 additions and 3 deletions
Showing only changes of commit fa629db4fe - Show all commits

View File

@@ -12,6 +12,10 @@ import StevenDimDoors.experimental.decorators.BaseDecorator;
import StevenDimDoors.experimental.decorators.DecoratorFinder;
import StevenDimDoors.mod_pocketDim.Point3D;
import StevenDimDoors.mod_pocketDim.config.DDProperties;
import StevenDimDoors.mod_pocketDim.core.DimLink;
import StevenDimDoors.mod_pocketDim.core.LinkTypes;
import StevenDimDoors.mod_pocketDim.core.NewDimData;
import StevenDimDoors.mod_pocketDim.core.PocketManager;
public class MazeBuilder
{
@@ -146,10 +150,39 @@ public class MazeBuilder
}
}
}
// Iterate over all link plans and place links in the world
for (LinkPlan link : links)
NewDimData dimension = PocketManager.getDimensionData(world);
for (LinkPlan plan : links)
{
// TODO: Add link placement code here!
createLinkFromPlan(plan, dimension, world);
}
}
private static void createLinkFromPlan(LinkPlan plan, NewDimData dimension, World world)
{
// TODO: Support entrances! Right now we'll treat them as dungeon doors for testing
DimLink link;
Point3D source;
Point3D destination;
int orientation;
source = plan.sourcePoint();
orientation = world.getBlockMetadata(source.getX(), source.getY(), source.getZ()) & 3;
// Check the link type and set the destination accordingly
if (plan.isInternal())
{
// Create a link between sections
destination = plan.destinationPoint();
link = dimension.createLink(source.getX(), source.getY(), source.getZ(), LinkTypes.DUNGEON, orientation);
dimension.setDestination(link, destination.getX(), destination.getY(), destination.getZ());
}
else
{
// Create a dungeon link
dimension.createLink(source.getX(), source.getY(), source.getZ(), LinkTypes.DUNGEON, orientation);
}
}

View File

@@ -2,10 +2,12 @@ package StevenDimDoors.experimental.decorators;
import java.util.Random;
import net.minecraft.item.ItemDoor;
import net.minecraft.world.World;
import StevenDimDoors.experimental.LinkPlan;
import StevenDimDoors.experimental.RoomData;
import StevenDimDoors.mod_pocketDim.Point3D;
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
import StevenDimDoors.mod_pocketDim.config.DDProperties;
public class DefaultDoorDecorator extends BaseDecorator
@@ -19,6 +21,28 @@ public class DefaultDoorDecorator extends BaseDecorator
@Override
public void decorate(RoomData room, World world, Point3D offset, Random random, DDProperties properties)
{
// TODO: This is just an improvised implementation for testing
Point3D corner = room.getPartitionNode().minCorner().clone();
corner.add(offset);
int count = 0;
Point3D source = null;
for (LinkPlan plan : room.getOutboundLinks())
{
source = new Point3D(corner.getX() + 2, corner.getY() + 2, corner.getZ() + count + 1);
ItemDoor.placeDoorBlock(world, source.getX(), source.getY() - 1, source.getZ(), 0, mod_pocketDim.dimensionalDoor);
plan.setSourcePoint(source);
count++;
}
if (source == null)
{
throw new IllegalStateException("This should never happen because this decorator only applies if outbound links exist!");
}
for (LinkPlan plan : room.getInboundLinks())
{
plan.setDestinationPoint(source);
}
}

View File

@@ -4,6 +4,8 @@ import java.util.Random;
import net.minecraft.world.World;
import StevenDimDoors.experimental.LinkPlan;
import StevenDimDoors.experimental.PartitionNode;
import StevenDimDoors.experimental.RoomData;
import StevenDimDoors.mod_pocketDim.Point3D;
import StevenDimDoors.mod_pocketDim.config.DDProperties;
@@ -19,6 +21,17 @@ public class LinkDestinationDecorator extends BaseDecorator
@Override
public void decorate(RoomData room, World world, Point3D offset, Random random, DDProperties properties)
{
// Set the center of the room as the destination for all inbound links
PartitionNode<RoomData> partition = room.getPartitionNode();
Point3D destination = partition.minCorner().clone();
destination.add(
offset.getX() + partition.width() / 2,
offset.getY() + 2,
offset.getZ() + partition.length() / 2);
for (LinkPlan plan : room.getInboundLinks())
{
plan.setDestinationPoint(destination);
}
}
}

View File

@@ -63,6 +63,13 @@ public class Point3D implements Serializable {
this.z += z;
}
public void add(Point3D other)
{
this.x += other.x;
this.y += other.y;
this.z += other.z;
}
@Override
public Point3D clone()
{