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-21 13:17:04 -04:00
|
|
|
import net.minecraft.util.ResourceLocation;
|
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
|
|
|
|
{
|
2016-08-31 21:05:29 -04:00
|
|
|
public int dungeonWeight = 1;
|
2016-08-21 13:17:04 -04:00
|
|
|
public Map<String, BlockPos> structureMap = new HashMap<String, BlockPos>();
|
2016-08-20 14:00:08 -04:00
|
|
|
|
2016-08-21 13:17:04 -04:00
|
|
|
public Map<EnumFacing, List<BlockPos>> doorMap = new HashMap<EnumFacing, List<BlockPos>>(); //Map of doors. The EnumFacing indicates what way this door faces.
|
|
|
|
public List<AreaDescriptor.Rectangle> descriptorList = new ArrayList<AreaDescriptor.Rectangle>();
|
2016-08-20 17:16:07 -04:00
|
|
|
|
2016-08-21 13:17:04 -04:00
|
|
|
public DungeonRoom(Map<String, BlockPos> structureMap, Map<EnumFacing, List<BlockPos>> doorMap, List<AreaDescriptor.Rectangle> descriptorList)
|
2016-08-20 17:16:07 -04:00
|
|
|
{
|
|
|
|
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-21 13:17:04 -04:00
|
|
|
for (Entry<String, BlockPos> entry : structureMap.entrySet())
|
2016-08-20 17:16:07 -04:00
|
|
|
{
|
2016-08-21 13:17:04 -04:00
|
|
|
ResourceLocation location = new ResourceLocation(entry.getKey());
|
|
|
|
DungeonStructure structure = new DungeonStructure(location);
|
2016-08-20 17:16:07 -04:00
|
|
|
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
|
|
|
}
|
|
|
|
}
|