2016-08-20 14:00:08 -04:00
|
|
|
package WayofTime.bloodmagic.structures;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
2016-08-20 17:16:07 -04:00
|
|
|
import java.util.Map.Entry;
|
|
|
|
import java.util.Random;
|
2016-08-20 14:00:08 -04:00
|
|
|
|
2016-08-20 17:16:07 -04:00
|
|
|
import net.minecraft.util.EnumFacing;
|
2016-08-20 14:00:08 -04:00
|
|
|
import net.minecraft.util.math.BlockPos;
|
2016-08-20 17:16:07 -04:00
|
|
|
import net.minecraft.world.WorldServer;
|
2016-08-20 14:00:08 -04:00
|
|
|
import net.minecraft.world.gen.structure.template.PlacementSettings;
|
2016-08-20 17:16:07 -04:00
|
|
|
import net.minecraft.world.gen.structure.template.Template;
|
2016-08-20 14:00:08 -04:00
|
|
|
import WayofTime.bloodmagic.api.ritual.AreaDescriptor;
|
|
|
|
|
|
|
|
public class DungeonRoom
|
|
|
|
{
|
|
|
|
protected Map<DungeonStructure, BlockPos> structureMap = new HashMap<DungeonStructure, BlockPos>();
|
|
|
|
|
2016-08-20 17:16:07 -04:00
|
|
|
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)
|
|
|
|
{
|
|
|
|
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)
|
2016-08-20 14:00:08 -04:00
|
|
|
{
|
2016-08-20 17:16:07 -04:00
|
|
|
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;
|
2016-08-20 14:00:08 -04:00
|
|
|
}
|
|
|
|
}
|