f4653d0522
Improved DungeonSchematic to the point that it can replace SchematicLoader as our method of loading dungeons. Some of the code was copied over rather than refactored to save time. It's been subdivided so make it much more readable. Also, we can reimplement portions of it as WorldOperations later on further remove redudancy. Testing shows that there is one problem left to fix: door blocks are not being set up correctly at the moment. Rifts are being set up properly and attaching doors to rifts will show that dungeons continue to generate fine. Added classes to support DungeonSchematic and its additional filtering logic on import and export. SpecialBlockFinder handles listing the entrance, other doors in the dungeon, and end portal frames. FillContainersOperation is a WorldOperation that fills chests and dispensers. BlockRotator is a temporary class to hold transformMetadata() and transformPoint() until we rewrite that code later. Stripped out most of the code from SchematicLoader to ensure it's no longer used. The only remaining function sets up dungeon pockets. We can phase it out in a later version so as not to delay our release. Removed references to SchematicLoader in mod_pocketDim since it no longer needs to be instantiated.
76 lines
1.6 KiB
Java
76 lines
1.6 KiB
Java
package StevenDimDoors.mod_pocketDim.schematic;
|
|
|
|
import StevenDimDoors.mod_pocketDim.Point3D;
|
|
import net.minecraft.world.World;
|
|
|
|
public abstract class WorldOperation {
|
|
|
|
private String name;
|
|
|
|
public WorldOperation(String name)
|
|
{
|
|
this.name = name;
|
|
}
|
|
|
|
protected boolean initialize(World world, int x, int y, int z, int width, int height, int length)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
protected abstract boolean applyToBlock(World world, int x, int y, int z);
|
|
|
|
protected boolean finish()
|
|
{
|
|
return true;
|
|
}
|
|
|
|
public boolean apply(World world, Point3D minCorner, Point3D maxCorner)
|
|
{
|
|
int x = minCorner.getX();
|
|
int y = minCorner.getY();
|
|
int z = minCorner.getZ();
|
|
int width = maxCorner.getX() - x + 1;
|
|
int height = maxCorner.getY() - y + 1;
|
|
int length = maxCorner.getZ() - z + 1;
|
|
return apply(world, x, y, z, width, height, length);
|
|
}
|
|
|
|
public boolean apply(World world, int x, int y, int z, int width, int height, int length)
|
|
{
|
|
if (!initialize(world, x, y, z, width, height, length))
|
|
return false;
|
|
|
|
int cx, cy, cz;
|
|
int limitX = x + width;
|
|
int limitY = y + height;
|
|
int limitZ = z + length;
|
|
|
|
//The order of these loops is important. Don't change it! It's used to avoid calculating
|
|
//indeces in some schematic operations. The proper order is YZX.
|
|
for (cy = y; cy < limitY; cy++)
|
|
{
|
|
for (cz = z; cz < limitZ; cz++)
|
|
{
|
|
for (cx = x; cx < limitX; cx++)
|
|
{
|
|
if (!applyToBlock(world, cx, cy, cz))
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
|
|
return finish();
|
|
}
|
|
|
|
|
|
public String getName()
|
|
{
|
|
return name;
|
|
}
|
|
|
|
@Override
|
|
public String toString()
|
|
{
|
|
return name;
|
|
}
|
|
}
|