Mazes #155
@@ -12,6 +12,10 @@ import StevenDimDoors.experimental.decorators.BaseDecorator;
|
|||||||
import StevenDimDoors.experimental.decorators.DecoratorFinder;
|
import StevenDimDoors.experimental.decorators.DecoratorFinder;
|
||||||
import StevenDimDoors.mod_pocketDim.Point3D;
|
import StevenDimDoors.mod_pocketDim.Point3D;
|
||||||
import StevenDimDoors.mod_pocketDim.config.DDProperties;
|
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
|
public class MazeBuilder
|
||||||
{
|
{
|
||||||
@@ -146,10 +150,39 @@ public class MazeBuilder
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Iterate over all link plans and place links in the world
|
// 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,10 +2,12 @@ package StevenDimDoors.experimental.decorators;
|
|||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
|
import net.minecraft.item.ItemDoor;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import StevenDimDoors.experimental.LinkPlan;
|
||||||
import StevenDimDoors.experimental.RoomData;
|
import StevenDimDoors.experimental.RoomData;
|
||||||
import StevenDimDoors.mod_pocketDim.Point3D;
|
import StevenDimDoors.mod_pocketDim.Point3D;
|
||||||
|
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||||
import StevenDimDoors.mod_pocketDim.config.DDProperties;
|
import StevenDimDoors.mod_pocketDim.config.DDProperties;
|
||||||
|
|
||||||
public class DefaultDoorDecorator extends BaseDecorator
|
public class DefaultDoorDecorator extends BaseDecorator
|
||||||
@@ -19,6 +21,28 @@ public class DefaultDoorDecorator extends BaseDecorator
|
|||||||
@Override
|
@Override
|
||||||
public void decorate(RoomData room, World world, Point3D offset, Random random, DDProperties properties)
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import java.util.Random;
|
|||||||
|
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
import StevenDimDoors.experimental.LinkPlan;
|
||||||
|
import StevenDimDoors.experimental.PartitionNode;
|
||||||
import StevenDimDoors.experimental.RoomData;
|
import StevenDimDoors.experimental.RoomData;
|
||||||
import StevenDimDoors.mod_pocketDim.Point3D;
|
import StevenDimDoors.mod_pocketDim.Point3D;
|
||||||
import StevenDimDoors.mod_pocketDim.config.DDProperties;
|
import StevenDimDoors.mod_pocketDim.config.DDProperties;
|
||||||
@@ -19,6 +21,17 @@ public class LinkDestinationDecorator extends BaseDecorator
|
|||||||
@Override
|
@Override
|
||||||
public void decorate(RoomData room, World world, Point3D offset, Random random, DDProperties properties)
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,6 +63,13 @@ public class Point3D implements Serializable {
|
|||||||
this.z += z;
|
this.z += z;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void add(Point3D other)
|
||||||
|
{
|
||||||
|
this.x += other.x;
|
||||||
|
this.y += other.y;
|
||||||
|
this.z += other.z;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Point3D clone()
|
public Point3D clone()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user