More tests with dungeon generation
This commit is contained in:
parent
f734e93921
commit
9b64e2a2f6
|
@ -1,5 +1,22 @@
|
|||
package WayofTime.bloodmagic;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Map;
|
||||
|
||||
import lombok.Getter;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.launchwrapper.Launch;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.SidedProxy;
|
||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLInterModComms;
|
||||
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
|
||||
import net.minecraftforge.fml.common.network.NetworkRegistry;
|
||||
import WayofTime.bloodmagic.annot.Handler;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.util.helper.LogHelper;
|
||||
|
@ -9,24 +26,20 @@ import WayofTime.bloodmagic.compat.ICompatibility;
|
|||
import WayofTime.bloodmagic.compat.minecraft.ICrossVersionProxy;
|
||||
import WayofTime.bloodmagic.network.BloodMagicPacketHandler;
|
||||
import WayofTime.bloodmagic.proxy.CommonProxy;
|
||||
import WayofTime.bloodmagic.registry.*;
|
||||
import WayofTime.bloodmagic.registry.ModArmourTrackers;
|
||||
import WayofTime.bloodmagic.registry.ModBlocks;
|
||||
import WayofTime.bloodmagic.registry.ModCompatibility;
|
||||
import WayofTime.bloodmagic.registry.ModEntities;
|
||||
import WayofTime.bloodmagic.registry.ModItems;
|
||||
import WayofTime.bloodmagic.registry.ModPotions;
|
||||
import WayofTime.bloodmagic.registry.ModRecipes;
|
||||
import WayofTime.bloodmagic.registry.ModRituals;
|
||||
import WayofTime.bloodmagic.registry.ModTranquilityHandlers;
|
||||
import WayofTime.bloodmagic.structures.ModDungeons;
|
||||
import WayofTime.bloodmagic.util.Utils;
|
||||
import WayofTime.bloodmagic.util.handler.IMCHandler;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import lombok.Getter;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.launchwrapper.Launch;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.SidedProxy;
|
||||
import net.minecraftforge.fml.common.event.*;
|
||||
import net.minecraftforge.fml.common.network.NetworkRegistry;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
@Mod(modid = Constants.Mod.MODID, name = Constants.Mod.NAME, version = Constants.Mod.VERSION, dependencies = Constants.Mod.DEPEND, guiFactory = "WayofTime.bloodmagic.client.gui.config.ConfigGuiFactory")
|
||||
@Getter
|
||||
|
@ -61,11 +74,7 @@ public class BloodMagic
|
|||
|
||||
@Getter
|
||||
private static ICrossVersionProxy crossVersionProxy;
|
||||
private static final Map<String, String> PROXY_MAP = ImmutableMap.of(
|
||||
"1.9.4", "WayofTime.bloodmagic.compat.minecraft.CrossVersionProxy19",
|
||||
"1.10", "WayofTime.bloodmagic.compat.minecraft.CrossVersionProxy110",
|
||||
"1.10.2", "WayofTime.bloodmagic.compat.minecraft.CrossVersionProxy110"
|
||||
);
|
||||
private static final Map<String, String> PROXY_MAP = ImmutableMap.of("1.9.4", "WayofTime.bloodmagic.compat.minecraft.CrossVersionProxy19", "1.10", "WayofTime.bloodmagic.compat.minecraft.CrossVersionProxy110", "1.10.2", "WayofTime.bloodmagic.compat.minecraft.CrossVersionProxy110");
|
||||
|
||||
static
|
||||
{
|
||||
|
@ -73,7 +82,7 @@ public class BloodMagic
|
|||
{
|
||||
String mcVersion = (String) Loader.class.getDeclaredField("MC_VERSION").get(null);
|
||||
|
||||
if(!PROXY_MAP.containsKey(mcVersion))
|
||||
if (!PROXY_MAP.containsKey(mcVersion))
|
||||
throw new IllegalStateException("Blood Magic couldn't find a cross version proxy!");
|
||||
|
||||
Class proxyClass = Class.forName(PROXY_MAP.get(mcVersion));
|
||||
|
@ -102,6 +111,7 @@ public class BloodMagic
|
|||
ModCompatibility.registerModCompat();
|
||||
ModCompatibility.loadCompat(ICompatibility.InitializationPhase.PRE_INIT);
|
||||
ModTranquilityHandlers.init();
|
||||
ModDungeons.init();
|
||||
|
||||
Utils.registerHandlers(event.getAsmData().getAll(Handler.class.getCanonicalName()));
|
||||
proxy.preInit();
|
||||
|
|
178
src/main/java/WayofTime/bloodmagic/structures/Dungeon.java
Normal file
178
src/main/java/WayofTime/bloodmagic/structures/Dungeon.java
Normal file
|
@ -0,0 +1,178 @@
|
|||
package WayofTime.bloodmagic.structures;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.Mirror;
|
||||
import net.minecraft.util.Rotation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraft.world.gen.structure.template.PlacementSettings;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import WayofTime.bloodmagic.api.ritual.AreaDescriptor;
|
||||
|
||||
public class Dungeon
|
||||
{
|
||||
public static boolean placeStructureAtPosition(Random rand, WorldServer world, BlockPos pos)
|
||||
{
|
||||
Map<EnumFacing, List<BlockPos>> availableDoorMap = new HashMap<EnumFacing, List<BlockPos>>(); //Map of doors. The EnumFacing indicates what way this door faces.
|
||||
List<AreaDescriptor> descriptorList = new ArrayList<AreaDescriptor>();
|
||||
Map<BlockPos, Pair<DungeonRoom, PlacementSettings>> roomMap = new HashMap<BlockPos, Pair<DungeonRoom, PlacementSettings>>(); // Placement positions in terms of actual positions
|
||||
|
||||
PlacementSettings settings = new PlacementSettings();
|
||||
Mirror mir = Mirror.NONE;
|
||||
|
||||
settings.setMirror(mir);
|
||||
|
||||
Rotation rot = Rotation.NONE;
|
||||
|
||||
settings.setRotation(rot);
|
||||
settings.setIgnoreEntities(true);
|
||||
settings.setChunk((ChunkPos) null);
|
||||
settings.setReplacedBlock((Block) null);
|
||||
settings.setIgnoreStructureBlock(false);
|
||||
|
||||
DungeonRoom room = getRandomRoom(rand);
|
||||
roomMap.put(pos, Pair.of(room, settings.copy()));
|
||||
descriptorList.addAll(room.getAreaDescriptors(settings, pos));
|
||||
for (EnumFacing facing : EnumFacing.VALUES)
|
||||
{
|
||||
if (availableDoorMap.containsKey(facing))
|
||||
{
|
||||
List<BlockPos> doorList = availableDoorMap.get(facing);
|
||||
doorList.addAll(room.getDoorOffsetsForFacing(settings, facing, pos));
|
||||
} else
|
||||
{
|
||||
List<BlockPos> doorList = room.getDoorOffsetsForFacing(settings, facing, pos);
|
||||
availableDoorMap.put(facing, doorList);
|
||||
}
|
||||
}
|
||||
|
||||
//Initial AreaDescriptors and door positions are initialized. Time for fun!
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
List<EnumFacing> facingList = new ArrayList<EnumFacing>();
|
||||
for (Entry<EnumFacing, List<BlockPos>> entry : availableDoorMap.entrySet())
|
||||
{
|
||||
if (entry.getValue() != null && !entry.getValue().isEmpty())
|
||||
{
|
||||
facingList.add(entry.getKey());
|
||||
}
|
||||
}
|
||||
|
||||
Collections.shuffle(facingList); //Shuffle the list so that it is random what is chosen
|
||||
|
||||
Pair<EnumFacing, BlockPos> removedDoor1 = null;
|
||||
Pair<EnumFacing, BlockPos> removedDoor2 = null;
|
||||
BlockPos roomLocation = null;
|
||||
|
||||
roomPlacement: for (EnumFacing doorFacing : facingList)
|
||||
{
|
||||
EnumFacing oppositeDoorFacing = doorFacing.getOpposite();
|
||||
List<BlockPos> availableDoorList = availableDoorMap.get(doorFacing); //May need to copy here
|
||||
Collections.shuffle(availableDoorList);
|
||||
|
||||
settings.setRotation(Rotation.values()[rand.nextInt(Rotation.values().length)]); //Same for the Mirror
|
||||
DungeonRoom testingRoom = getRandomRoom(rand);
|
||||
|
||||
List<BlockPos> otherDoorList = testingRoom.getDoorOffsetsForFacing(settings, oppositeDoorFacing, BlockPos.ORIGIN);
|
||||
if (otherDoorList != null && !otherDoorList.isEmpty())
|
||||
{
|
||||
//See if one of these doors works.
|
||||
Collections.shuffle(otherDoorList);
|
||||
BlockPos testDoor = otherDoorList.get(0);
|
||||
testDoor: for (BlockPos availableDoor : availableDoorList)
|
||||
{
|
||||
//TODO: Test if it fits, then add the doors to the list.
|
||||
roomLocation = availableDoor.subtract(testDoor).add(doorFacing.getDirectionVec());
|
||||
|
||||
List<AreaDescriptor> descriptors = testingRoom.getAreaDescriptors(settings, roomLocation);
|
||||
for (AreaDescriptor testDesc : descriptors)
|
||||
{
|
||||
for (AreaDescriptor currentDesc : descriptorList)
|
||||
{
|
||||
if (testDesc.intersects(currentDesc))
|
||||
{
|
||||
break testDoor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
roomMap.put(roomLocation, Pair.of(testingRoom, settings.copy()));
|
||||
descriptorList.addAll(descriptors);
|
||||
removedDoor1 = Pair.of(doorFacing, availableDoor);
|
||||
removedDoor2 = Pair.of(oppositeDoorFacing, testDoor.add(roomLocation));
|
||||
|
||||
room = testingRoom;
|
||||
|
||||
break roomPlacement;
|
||||
}
|
||||
}
|
||||
|
||||
// Collections.shuffle(otherDoorList);
|
||||
}
|
||||
|
||||
if (removedDoor1 != null)
|
||||
{
|
||||
for (EnumFacing facing : EnumFacing.VALUES)
|
||||
{
|
||||
if (availableDoorMap.containsKey(facing))
|
||||
{
|
||||
List<BlockPos> doorList = availableDoorMap.get(facing);
|
||||
doorList.addAll(room.getDoorOffsetsForFacing(settings, facing, roomLocation));
|
||||
} else
|
||||
{
|
||||
List<BlockPos> doorList = room.getDoorOffsetsForFacing(settings, facing, roomLocation);
|
||||
availableDoorMap.put(facing, doorList);
|
||||
}
|
||||
}
|
||||
|
||||
EnumFacing face = removedDoor1.getKey();
|
||||
if (availableDoorMap.containsKey(face))
|
||||
{
|
||||
availableDoorMap.get(face).remove(removedDoor1);
|
||||
}
|
||||
|
||||
removedDoor1 = null;
|
||||
}
|
||||
|
||||
if (removedDoor2 != null)
|
||||
{
|
||||
EnumFacing face = removedDoor2.getKey();
|
||||
if (availableDoorMap.containsKey(face))
|
||||
{
|
||||
availableDoorMap.get(face).remove(removedDoor2);
|
||||
}
|
||||
|
||||
removedDoor2 = null;
|
||||
}
|
||||
}
|
||||
|
||||
//Building what I've got
|
||||
for (Entry<BlockPos, Pair<DungeonRoom, PlacementSettings>> entry : roomMap.entrySet())
|
||||
{
|
||||
BlockPos placementPos = entry.getKey();
|
||||
DungeonRoom placedRoom = entry.getValue().getKey();
|
||||
PlacementSettings placementSettings = entry.getValue().getValue();
|
||||
|
||||
placedRoom.placeStructureAtPosition(rand, placementSettings, world, placementPos);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static DungeonRoom getRandomRoom(Random rand)
|
||||
{
|
||||
return DungeonRoomRegistry.getRandomDungeonRoom(rand);
|
||||
}
|
||||
}
|
|
@ -4,17 +4,69 @@ import java.util.ArrayList;
|
|||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraft.world.gen.structure.template.PlacementSettings;
|
||||
import net.minecraft.world.gen.structure.template.Template;
|
||||
import WayofTime.bloodmagic.api.ritual.AreaDescriptor;
|
||||
|
||||
public class DungeonRoom
|
||||
{
|
||||
protected Map<DungeonStructure, BlockPos> structureMap = new HashMap<DungeonStructure, BlockPos>();
|
||||
|
||||
public List<AreaDescriptor> getAreaDescriptors(PlacementSettings settings, BlockPos position)
|
||||
Map<EnumFacing, List<BlockPos>> doorMap = new HashMap<EnumFacing, List<BlockPos>>(); //Map of doors. The EnumFacing indicates what way this door faces.
|
||||
List<AreaDescriptor> descriptorList = new ArrayList<AreaDescriptor>();
|
||||
|
||||
public DungeonRoom(Map<DungeonStructure, BlockPos> structureMap, Map<EnumFacing, List<BlockPos>> doorMap, List<AreaDescriptor> descriptorList)
|
||||
{
|
||||
return new ArrayList<AreaDescriptor>();
|
||||
this.structureMap = structureMap;
|
||||
this.doorMap = doorMap;
|
||||
this.descriptorList = descriptorList;
|
||||
}
|
||||
|
||||
public List<AreaDescriptor> getAreaDescriptors(PlacementSettings settings, BlockPos offset)
|
||||
{
|
||||
List<AreaDescriptor> newList = new ArrayList<AreaDescriptor>();
|
||||
|
||||
for (AreaDescriptor desc : descriptorList)
|
||||
{
|
||||
newList.add(desc.rotateDescriptor(settings).offset(offset));
|
||||
}
|
||||
|
||||
return newList;
|
||||
}
|
||||
|
||||
public List<BlockPos> getDoorOffsetsForFacing(PlacementSettings settings, EnumFacing facing, BlockPos offset)
|
||||
{
|
||||
List<BlockPos> offsetList = new ArrayList<BlockPos>();
|
||||
|
||||
EnumFacing originalFacing = DungeonUtil.reverseRotate(settings.getMirror(), settings.getRotation(), facing);
|
||||
if (doorMap.containsKey(originalFacing))
|
||||
{
|
||||
List<BlockPos> doorList = doorMap.get(originalFacing);
|
||||
for (BlockPos doorPos : doorList)
|
||||
{
|
||||
offsetList.add(Template.transformedBlockPos(settings, doorPos).add(offset));
|
||||
}
|
||||
}
|
||||
|
||||
return offsetList;
|
||||
}
|
||||
|
||||
public boolean placeStructureAtPosition(Random rand, PlacementSettings settings, WorldServer world, BlockPos pos)
|
||||
{
|
||||
for (Entry<DungeonStructure, BlockPos> entry : structureMap.entrySet())
|
||||
{
|
||||
DungeonStructure structure = entry.getKey();
|
||||
BlockPos offsetPos = Template.transformedBlockPos(settings, entry.getValue());
|
||||
|
||||
structure.placeStructureAtPosition(rand, settings, world, pos.add(offsetPos));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package WayofTime.bloodmagic.structures;
|
|||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
public class DungeonRoomRegistry
|
||||
{
|
||||
|
@ -12,4 +13,13 @@ public class DungeonRoomRegistry
|
|||
dungeonWeightMap.put(room, weight);
|
||||
}
|
||||
|
||||
public static DungeonRoom getRandomDungeonRoom(Random rand)
|
||||
{
|
||||
for (DungeonRoom room : dungeonWeightMap.keySet())
|
||||
{
|
||||
return room;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,69 +1,26 @@
|
|||
package WayofTime.bloodmagic.structures;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.Mirror;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.Rotation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraft.world.gen.structure.template.PlacementSettings;
|
||||
import net.minecraft.world.gen.structure.template.Template;
|
||||
import net.minecraft.world.gen.structure.template.TemplateManager;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.ritual.AreaDescriptor;
|
||||
|
||||
public class DungeonStructure
|
||||
{
|
||||
final ResourceLocation resource;
|
||||
Map<EnumFacing, List<BlockPos>> doorMap = new HashMap<EnumFacing, List<BlockPos>>(); //Map of doors. The EnumFacing indicates what way this door faces.
|
||||
List<AreaDescriptor> descriptorList = new ArrayList<AreaDescriptor>();
|
||||
|
||||
public DungeonStructure(ResourceLocation resource, Map<EnumFacing, List<BlockPos>> doorMap, List<AreaDescriptor> descriptorList)
|
||||
public DungeonStructure(ResourceLocation resource)
|
||||
{
|
||||
this.resource = resource;
|
||||
this.doorMap = doorMap;
|
||||
this.descriptorList = descriptorList;
|
||||
}
|
||||
|
||||
public List<AreaDescriptor> getAreaDescriptors(PlacementSettings settings, BlockPos offset)
|
||||
{
|
||||
List<AreaDescriptor> newList = new ArrayList<AreaDescriptor>();
|
||||
|
||||
for (AreaDescriptor desc : descriptorList)
|
||||
{
|
||||
newList.add(desc.rotateDescriptor(settings).offset(offset));
|
||||
}
|
||||
|
||||
return newList;
|
||||
}
|
||||
|
||||
public List<BlockPos> getDoorOffsetsForFacing(PlacementSettings settings, EnumFacing facing)
|
||||
{
|
||||
List<BlockPos> offsetList = new ArrayList<BlockPos>();
|
||||
|
||||
EnumFacing originalFacing = DungeonUtil.reverseRotate(settings.getMirror(), settings.getRotation(), facing);
|
||||
if (doorMap.containsKey(originalFacing))
|
||||
{
|
||||
List<BlockPos> doorList = doorMap.get(originalFacing);
|
||||
for (BlockPos doorPos : doorList)
|
||||
{
|
||||
offsetList.add(Template.transformedBlockPos(settings, doorPos));
|
||||
}
|
||||
}
|
||||
|
||||
return offsetList;
|
||||
}
|
||||
|
||||
public boolean placeStructureAtPosition(Random rand, Mirror mirror, Rotation rotation, WorldServer world, BlockPos pos)
|
||||
public boolean placeStructureAtPosition(Random rand, PlacementSettings settings, WorldServer world, BlockPos pos)
|
||||
{
|
||||
if (pos == null)
|
||||
return false;
|
||||
|
@ -80,27 +37,6 @@ public class DungeonStructure
|
|||
return false;
|
||||
}
|
||||
|
||||
PlacementSettings settings = new PlacementSettings();
|
||||
Mirror mir = mirror;
|
||||
if (mir == null)
|
||||
{
|
||||
mir = Mirror.NONE;
|
||||
}
|
||||
|
||||
settings.setMirror(mir);
|
||||
|
||||
Rotation rot;
|
||||
|
||||
rot = rotation;
|
||||
if (rot == null)
|
||||
rot = Rotation.NONE;
|
||||
|
||||
settings.setRotation(rot);
|
||||
settings.setIgnoreEntities(true);
|
||||
settings.setChunk((ChunkPos) null);
|
||||
settings.setReplacedBlock((Block) null);
|
||||
settings.setIgnoreStructureBlock(false);
|
||||
|
||||
// settings.func_189946_a(MathHelper.clamp_float(schema.integrity, 0.0F, 1.0F));
|
||||
|
||||
BlockPos offset = Template.transformedBlockPos(settings, new BlockPos(0, 0, 0));
|
||||
|
@ -109,4 +45,9 @@ public class DungeonStructure
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
public DungeonStructure copy()
|
||||
{
|
||||
return new DungeonStructure(resource);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,74 +1,85 @@
|
|||
package WayofTime.bloodmagic.structures;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.Mirror;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.Rotation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraft.world.gen.structure.template.PlacementSettings;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.ritual.AreaDescriptor;
|
||||
|
||||
public class DungeonTester
|
||||
{
|
||||
public static void testDungeonGeneration(WorldServer world, BlockPos pos)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public static void testDungeonElementWithOutput(WorldServer world, BlockPos pos)
|
||||
{
|
||||
ResourceLocation resource = new ResourceLocation(Constants.Mod.MODID, "Corridor1");
|
||||
Map<EnumFacing, List<BlockPos>> doorMap = new HashMap<EnumFacing, List<BlockPos>>();
|
||||
List<AreaDescriptor> descriptorList = new ArrayList<AreaDescriptor>();
|
||||
descriptorList.add(new AreaDescriptor.Rectangle(new BlockPos(0, 0, 0), 5, 3, 7));
|
||||
|
||||
DungeonUtil.addRoom(doorMap, EnumFacing.NORTH, new BlockPos(3, 0, 0));
|
||||
DungeonUtil.addRoom(doorMap, EnumFacing.SOUTH, new BlockPos(3, 0, 6));
|
||||
DungeonUtil.addRoom(doorMap, EnumFacing.WEST, new BlockPos(0, 0, 3));
|
||||
|
||||
DungeonStructure structure = new DungeonStructure(resource, doorMap, descriptorList);
|
||||
|
||||
int i = 0;
|
||||
|
||||
for (Mirror mirror : Mirror.values())
|
||||
{
|
||||
Dungeon.placeStructureAtPosition(new Random(), world, pos);
|
||||
// ResourceLocation resource = new ResourceLocation(Constants.Mod.MODID, "Corridor1");
|
||||
//
|
||||
// DungeonStructure structure = new DungeonStructure(resource);
|
||||
// Map<DungeonStructure, BlockPos> structureMap = new HashMap<DungeonStructure, BlockPos>();
|
||||
// structureMap.put(structure, new BlockPos(0, 0, 0));
|
||||
//
|
||||
// Map<EnumFacing, List<BlockPos>> doorMap = new HashMap<EnumFacing, List<BlockPos>>();
|
||||
// List<AreaDescriptor> descriptorList = new ArrayList<AreaDescriptor>();
|
||||
// descriptorList.add(new AreaDescriptor.Rectangle(new BlockPos(0, 0, 0), 5, 3, 7));
|
||||
//
|
||||
// DungeonUtil.addRoom(doorMap, EnumFacing.NORTH, new BlockPos(3, 0, 0));
|
||||
// DungeonUtil.addRoom(doorMap, EnumFacing.SOUTH, new BlockPos(3, 0, 6));
|
||||
// DungeonUtil.addRoom(doorMap, EnumFacing.WEST, new BlockPos(0, 0, 3));
|
||||
//
|
||||
// DungeonRoom room = new DungeonRoom(structureMap, doorMap, descriptorList);
|
||||
//
|
||||
// PlacementSettings settings = new PlacementSettings();
|
||||
//
|
||||
// Mirror mir = Mirror.NONE;
|
||||
// settings.setMirror(mir);
|
||||
//
|
||||
// Rotation rot = Rotation.NONE;
|
||||
// settings.setRotation(rot);
|
||||
//
|
||||
// settings.setIgnoreEntities(true);
|
||||
// settings.setChunk((ChunkPos) null);
|
||||
// settings.setReplacedBlock((Block) null);
|
||||
// settings.setIgnoreStructureBlock(false);
|
||||
//
|
||||
// int i = 0;
|
||||
//
|
||||
// for (Mirror mirror : Mirror.values())
|
||||
// {
|
||||
// System.out.print("Mirror: " + mirror + '\n');
|
||||
int j = 0;
|
||||
for (Rotation rot : Rotation.values())
|
||||
{
|
||||
// int j = 0;
|
||||
// for (Rotation rotation : Rotation.values())
|
||||
// {
|
||||
// System.out.print("Rotation: " + rot + '\n');
|
||||
PlacementSettings settings = new PlacementSettings();
|
||||
settings.setRotation(rot);
|
||||
settings.setMirror(mirror);
|
||||
|
||||
BlockPos offsetPos = pos.add(i * 16, 0, j * 16);
|
||||
structure.placeStructureAtPosition(new Random(), mirror, rot, world, offsetPos);
|
||||
|
||||
// List<AreaDescriptor> descriptors = structure.getAreaDescriptors(settings, offsetPos);
|
||||
// for (AreaDescriptor desc : descriptors)
|
||||
// {
|
||||
// List<BlockPos> posList = desc.getContainedPositions(new BlockPos(0, 0, 0));
|
||||
// for (BlockPos placePos : posList)
|
||||
// {
|
||||
// world.setBlockState(placePos, Blocks.REDSTONE_BLOCK.getDefaultState());
|
||||
// }
|
||||
// }
|
||||
|
||||
// for (EnumFacing facing : EnumFacing.HORIZONTALS)
|
||||
// {
|
||||
// List<BlockPos> doorList = structure.getDoorOffsetsForFacing(settings, facing);
|
||||
// for (BlockPos doorPos : doorList)
|
||||
// {
|
||||
// System.out.print("Door at " + doorPos + " facing " + facing + '\n');
|
||||
// }
|
||||
// }
|
||||
j++;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
// settings.setRotation(rotation);
|
||||
// settings.setMirror(mirror);
|
||||
//
|
||||
// BlockPos offsetPos = pos.add(i * 16, 0, j * 16);
|
||||
// room.placeStructureAtPosition(new Random(), settings, world, offsetPos);
|
||||
//
|
||||
//// List<AreaDescriptor> descriptors = structure.getAreaDescriptors(settings, offsetPos);
|
||||
//// for (AreaDescriptor desc : descriptors)
|
||||
//// {
|
||||
//// List<BlockPos> posList = desc.getContainedPositions(new BlockPos(0, 0, 0));
|
||||
//// for (BlockPos placePos : posList)
|
||||
//// {
|
||||
//// world.setBlockState(placePos, Blocks.REDSTONE_BLOCK.getDefaultState());
|
||||
//// }
|
||||
//// }
|
||||
//
|
||||
//// for (EnumFacing facing : EnumFacing.HORIZONTALS)
|
||||
//// {
|
||||
//// List<BlockPos> doorList = structure.getDoorOffsetsForFacing(settings, facing);
|
||||
//// for (BlockPos doorPos : doorList)
|
||||
//// {
|
||||
//// System.out.print("Door at " + doorPos + " facing " + facing + '\n');
|
||||
//// }
|
||||
//// }
|
||||
// j++;
|
||||
// }
|
||||
// i++;
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
package WayofTime.bloodmagic.structures;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.ritual.AreaDescriptor;
|
||||
|
||||
public class ModDungeons
|
||||
{
|
||||
public static void init()
|
||||
{
|
||||
ResourceLocation resource = new ResourceLocation(Constants.Mod.MODID, "Corridor1");
|
||||
|
||||
DungeonStructure structure = new DungeonStructure(resource);
|
||||
Map<DungeonStructure, BlockPos> structureMap = new HashMap<DungeonStructure, BlockPos>();
|
||||
structureMap.put(structure, new BlockPos(0, 0, 0));
|
||||
|
||||
Map<EnumFacing, List<BlockPos>> doorMap = new HashMap<EnumFacing, List<BlockPos>>();
|
||||
List<AreaDescriptor> descriptorList = new ArrayList<AreaDescriptor>();
|
||||
descriptorList.add(new AreaDescriptor.Rectangle(new BlockPos(0, 0, 0), 5, 3, 7));
|
||||
|
||||
DungeonUtil.addRoom(doorMap, EnumFacing.NORTH, new BlockPos(3, 0, 0));
|
||||
DungeonUtil.addRoom(doorMap, EnumFacing.SOUTH, new BlockPos(3, 0, 6));
|
||||
DungeonUtil.addRoom(doorMap, EnumFacing.WEST, new BlockPos(0, 0, 3));
|
||||
|
||||
DungeonRoom room = new DungeonRoom(structureMap, doorMap, descriptorList);
|
||||
|
||||
DungeonRoomRegistry.registerDungeonRoom(room, 1);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue