Run formatter
This commit is contained in:
parent
61c44a831b
commit
08258fd6ef
606 changed files with 13464 additions and 22975 deletions
|
@ -1,7 +1,5 @@
|
|||
package WayofTime.bloodmagic.structures;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.Mirror;
|
||||
|
@ -13,10 +11,10 @@ import net.minecraft.world.gen.structure.template.PlacementSettings;
|
|||
import net.minecraft.world.gen.structure.template.Template;
|
||||
import net.minecraft.world.gen.structure.template.TemplateManager;
|
||||
|
||||
public class BuildTestStructure
|
||||
{
|
||||
public boolean placeStructureAtPosition(Random rand, Rotation baseRotation, WorldServer world, BlockPos pos, int iteration)
|
||||
{
|
||||
import java.util.Random;
|
||||
|
||||
public class BuildTestStructure {
|
||||
public boolean placeStructureAtPosition(Random rand, Rotation baseRotation, WorldServer world, BlockPos pos, int iteration) {
|
||||
if (pos == null)
|
||||
return false;
|
||||
|
||||
|
@ -26,8 +24,7 @@ public class BuildTestStructure
|
|||
ResourceLocation resource = new ResourceLocation(BloodMagic.MODID, "Corridor1");
|
||||
Template template = templatemanager.getTemplate(minecraftserver, resource);
|
||||
|
||||
if (template == null)
|
||||
{
|
||||
if (template == null) {
|
||||
System.out.println("Invalid template for location: " + resource);
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -1,30 +1,19 @@
|
|||
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 WayofTime.bloodmagic.api.ritual.AreaDescriptor;
|
||||
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;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
public class Dungeon
|
||||
{
|
||||
public static boolean placeStructureAtPosition(Random rand, WorldServer world, BlockPos pos)
|
||||
{
|
||||
public class Dungeon {
|
||||
public static boolean placeStructureAtPosition(Random rand, WorldServer world, BlockPos pos) {
|
||||
long startTime = System.nanoTime();
|
||||
|
||||
Map<EnumFacing, List<BlockPos>> availableDoorMap = new HashMap<EnumFacing, List<BlockPos>>(); //Map of doors. The EnumFacing indicates what way this door faces.
|
||||
|
@ -47,27 +36,21 @@ public class Dungeon
|
|||
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))
|
||||
{
|
||||
for (EnumFacing facing : EnumFacing.VALUES) {
|
||||
if (availableDoorMap.containsKey(facing)) {
|
||||
List<BlockPos> doorList = availableDoorMap.get(facing);
|
||||
doorList.addAll(room.getDoorOffsetsForFacing(settings, facing, pos));
|
||||
} else
|
||||
{
|
||||
} 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++)
|
||||
{
|
||||
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())
|
||||
{
|
||||
for (Entry<EnumFacing, List<BlockPos>> entry : availableDoorMap.entrySet()) {
|
||||
if (entry.getValue() != null && !entry.getValue().isEmpty()) {
|
||||
facingList.add(entry.getKey());
|
||||
}
|
||||
}
|
||||
|
@ -78,8 +61,8 @@ public class Dungeon
|
|||
Pair<EnumFacing, BlockPos> removedDoor2 = null;
|
||||
BlockPos roomLocation = null;
|
||||
|
||||
roomPlacement: for (EnumFacing doorFacing : facingList)
|
||||
{
|
||||
roomPlacement:
|
||||
for (EnumFacing doorFacing : facingList) {
|
||||
EnumFacing oppositeDoorFacing = doorFacing.getOpposite();
|
||||
List<BlockPos> availableDoorList = availableDoorMap.get(doorFacing); //May need to copy here
|
||||
Collections.shuffle(availableDoorList);
|
||||
|
@ -88,23 +71,19 @@ public class Dungeon
|
|||
DungeonRoom testingRoom = getRandomRoom(rand);
|
||||
|
||||
List<BlockPos> otherDoorList = testingRoom.getDoorOffsetsForFacing(settings, oppositeDoorFacing, BlockPos.ORIGIN);
|
||||
if (otherDoorList != null && !otherDoorList.isEmpty())
|
||||
{
|
||||
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)
|
||||
{
|
||||
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))
|
||||
{
|
||||
for (AreaDescriptor testDesc : descriptors) {
|
||||
for (AreaDescriptor currentDesc : descriptorList) {
|
||||
if (testDesc.intersects(currentDesc)) {
|
||||
break testDoor;
|
||||
}
|
||||
}
|
||||
|
@ -124,33 +103,26 @@ public class Dungeon
|
|||
// Collections.shuffle(otherDoorList);
|
||||
}
|
||||
|
||||
if (removedDoor1 != null)
|
||||
{
|
||||
for (EnumFacing facing : EnumFacing.VALUES)
|
||||
{
|
||||
if (availableDoorMap.containsKey(facing))
|
||||
{
|
||||
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
|
||||
{
|
||||
} else {
|
||||
List<BlockPos> doorList = room.getDoorOffsetsForFacing(settings, facing, roomLocation);
|
||||
availableDoorMap.put(facing, doorList);
|
||||
}
|
||||
}
|
||||
|
||||
EnumFacing face = removedDoor1.getKey();
|
||||
if (availableDoorMap.containsKey(face))
|
||||
{
|
||||
if (availableDoorMap.containsKey(face)) {
|
||||
availableDoorMap.get(face).remove(removedDoor1.getRight());
|
||||
}
|
||||
}
|
||||
|
||||
if (removedDoor2 != null)
|
||||
{
|
||||
if (removedDoor2 != null) {
|
||||
EnumFacing face = removedDoor2.getKey();
|
||||
if (availableDoorMap.containsKey(face))
|
||||
{
|
||||
if (availableDoorMap.containsKey(face)) {
|
||||
availableDoorMap.get(face).remove(removedDoor2.getRight());
|
||||
}
|
||||
}
|
||||
|
@ -162,8 +134,7 @@ public class Dungeon
|
|||
System.out.println("Duration: " + duration + "(ns), " + duration / 1000000 + "(ms)");
|
||||
|
||||
//Building what I've got
|
||||
for (Entry<BlockPos, Pair<DungeonRoom, PlacementSettings>> entry : roomMap.entrySet())
|
||||
{
|
||||
for (Entry<BlockPos, Pair<DungeonRoom, PlacementSettings>> entry : roomMap.entrySet()) {
|
||||
BlockPos placementPos = entry.getKey();
|
||||
DungeonRoom placedRoom = entry.getValue().getKey();
|
||||
PlacementSettings placementSettings = entry.getValue().getValue();
|
||||
|
@ -174,8 +145,7 @@ public class Dungeon
|
|||
return false;
|
||||
}
|
||||
|
||||
public static DungeonRoom getRandomRoom(Random rand)
|
||||
{
|
||||
public static DungeonRoom getRandomRoom(Random rand) {
|
||||
return DungeonRoomRegistry.getRandomDungeonRoom(rand);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,57 +1,46 @@
|
|||
package WayofTime.bloodmagic.structures;
|
||||
|
||||
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 WayofTime.bloodmagic.api.ritual.AreaDescriptor;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
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
|
||||
{
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
public class DungeonRoom {
|
||||
public int dungeonWeight = 1;
|
||||
public Map<String, BlockPos> structureMap = new HashMap<String, BlockPos>();
|
||||
|
||||
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>();
|
||||
|
||||
public DungeonRoom(Map<String, BlockPos> structureMap, Map<EnumFacing, List<BlockPos>> doorMap, List<AreaDescriptor.Rectangle> descriptorList)
|
||||
{
|
||||
public DungeonRoom(Map<String, BlockPos> structureMap, Map<EnumFacing, List<BlockPos>> doorMap, List<AreaDescriptor.Rectangle> descriptorList) {
|
||||
this.structureMap = structureMap;
|
||||
this.doorMap = doorMap;
|
||||
this.descriptorList = descriptorList;
|
||||
}
|
||||
|
||||
public List<AreaDescriptor> getAreaDescriptors(PlacementSettings settings, BlockPos offset)
|
||||
{
|
||||
public List<AreaDescriptor> getAreaDescriptors(PlacementSettings settings, BlockPos offset) {
|
||||
List<AreaDescriptor> newList = new ArrayList<AreaDescriptor>();
|
||||
|
||||
for (AreaDescriptor desc : descriptorList)
|
||||
{
|
||||
for (AreaDescriptor desc : descriptorList) {
|
||||
newList.add(desc.rotateDescriptor(settings).offset(offset));
|
||||
}
|
||||
|
||||
return newList;
|
||||
}
|
||||
|
||||
public List<BlockPos> getDoorOffsetsForFacing(PlacementSettings settings, EnumFacing facing, BlockPos offset)
|
||||
{
|
||||
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))
|
||||
{
|
||||
if (doorMap.containsKey(originalFacing)) {
|
||||
List<BlockPos> doorList = doorMap.get(originalFacing);
|
||||
for (BlockPos doorPos : doorList)
|
||||
{
|
||||
for (BlockPos doorPos : doorList) {
|
||||
offsetList.add(Template.transformedBlockPos(settings, doorPos).add(offset));
|
||||
}
|
||||
}
|
||||
|
@ -59,10 +48,8 @@ public class DungeonRoom
|
|||
return offsetList;
|
||||
}
|
||||
|
||||
public boolean placeStructureAtPosition(Random rand, PlacementSettings settings, WorldServer world, BlockPos pos)
|
||||
{
|
||||
for (Entry<String, BlockPos> entry : structureMap.entrySet())
|
||||
{
|
||||
public boolean placeStructureAtPosition(Random rand, PlacementSettings settings, WorldServer world, BlockPos pos) {
|
||||
for (Entry<String, BlockPos> entry : structureMap.entrySet()) {
|
||||
ResourceLocation location = new ResourceLocation(entry.getKey());
|
||||
DungeonStructure structure = new DungeonStructure(location);
|
||||
BlockPos offsetPos = Template.transformedBlockPos(settings, entry.getValue());
|
||||
|
|
|
@ -1,95 +1,75 @@
|
|||
package WayofTime.bloodmagic.structures;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.Writer;
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.gson.Serializers;
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.io.Resources;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
import WayofTime.bloodmagic.gson.Serializers;
|
||||
import java.io.*;
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class DungeonRoomLoader
|
||||
{
|
||||
public static void saveDungeons()
|
||||
{
|
||||
for (DungeonRoom room : DungeonRoomRegistry.dungeonWeightMap.keySet())
|
||||
{
|
||||
public class DungeonRoomLoader {
|
||||
public static void saveDungeons() {
|
||||
for (DungeonRoom room : DungeonRoomRegistry.dungeonWeightMap.keySet()) {
|
||||
saveSingleDungeon(room);
|
||||
}
|
||||
}
|
||||
|
||||
public static void saveSingleDungeon(DungeonRoom room)
|
||||
{
|
||||
public static void saveSingleDungeon(DungeonRoom room) {
|
||||
String json = Serializers.GSON.toJson(room);
|
||||
|
||||
Writer writer;
|
||||
try
|
||||
{
|
||||
try {
|
||||
File file = new File("config/BloodMagic/schematics");
|
||||
file.mkdirs();
|
||||
|
||||
writer = new FileWriter("config/BloodMagic/schematics/" + new Random().nextInt() + ".json");
|
||||
writer.write(json);
|
||||
writer.close();
|
||||
} catch (IOException e)
|
||||
{
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void loadDungeons()
|
||||
{
|
||||
try
|
||||
{
|
||||
public static void loadDungeons() {
|
||||
try {
|
||||
URL schematicURL = DungeonRoomLoader.class.getResource(resLocToResourcePath(new ResourceLocation("bloodmagic:schematics")));
|
||||
List<String> schematics = Serializers.GSON.fromJson(Resources.toString(schematicURL, Charsets.UTF_8), new TypeToken<List<String>>(){}.getType());
|
||||
for (String schematicKey : schematics)
|
||||
{
|
||||
List<String> schematics = Serializers.GSON.fromJson(Resources.toString(schematicURL, Charsets.UTF_8), new TypeToken<List<String>>() {
|
||||
}.getType());
|
||||
for (String schematicKey : schematics) {
|
||||
ResourceLocation schematic = new ResourceLocation(schematicKey);
|
||||
URL dungeonURL = DungeonRoomLoader.class.getResource(resLocToResourcePath(schematic));
|
||||
DungeonRoom dungeonRoom = Serializers.GSON.fromJson(Resources.toString(dungeonURL, Charsets.UTF_8), DungeonRoom.class);
|
||||
DungeonRoomRegistry.registerDungeonRoom(dungeonRoom, Math.max(1, dungeonRoom.dungeonWeight));
|
||||
}
|
||||
} catch (Exception e)
|
||||
{
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void test()
|
||||
{
|
||||
public static void test() {
|
||||
ResourceLocation id = new ResourceLocation(BloodMagic.MODID, "testGson");
|
||||
String s = id.getResourceDomain();
|
||||
String s1 = id.getResourcePath();
|
||||
InputStream inputstream = null;
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
inputstream = DungeonRoomLoader.class.getResourceAsStream("/assets/" + s + "/schematics/" + s1 + ".nbt");
|
||||
// this.readTemplateFromStream(s1, inputstream);
|
||||
return;
|
||||
} catch (Throwable var10)
|
||||
{
|
||||
} catch (Throwable var10) {
|
||||
|
||||
} finally
|
||||
{
|
||||
} finally {
|
||||
IOUtils.closeQuietly(inputstream);
|
||||
}
|
||||
}
|
||||
|
||||
public static String resLocToResourcePath(ResourceLocation resourceLocation)
|
||||
{
|
||||
public static String resLocToResourcePath(ResourceLocation resourceLocation) {
|
||||
return "/assets/" + resourceLocation.getResourceDomain() + "/schematics/" + resourceLocation.getResourcePath() + ".json";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,25 +5,20 @@ import java.util.Map;
|
|||
import java.util.Map.Entry;
|
||||
import java.util.Random;
|
||||
|
||||
public class DungeonRoomRegistry
|
||||
{
|
||||
public class DungeonRoomRegistry {
|
||||
public static Map<DungeonRoom, Integer> dungeonWeightMap = new HashMap<DungeonRoom, Integer>();
|
||||
private static int totalWeight = 0;
|
||||
|
||||
public static void registerDungeonRoom(DungeonRoom room, int weight)
|
||||
{
|
||||
public static void registerDungeonRoom(DungeonRoom room, int weight) {
|
||||
dungeonWeightMap.put(room, weight);
|
||||
totalWeight += weight;
|
||||
}
|
||||
|
||||
public static DungeonRoom getRandomDungeonRoom(Random rand)
|
||||
{
|
||||
public static DungeonRoom getRandomDungeonRoom(Random rand) {
|
||||
int wantedWeight = rand.nextInt(totalWeight);
|
||||
for (Entry<DungeonRoom, Integer> entry : dungeonWeightMap.entrySet())
|
||||
{
|
||||
for (Entry<DungeonRoom, Integer> entry : dungeonWeightMap.entrySet()) {
|
||||
wantedWeight -= entry.getValue();
|
||||
if (wantedWeight < 0)
|
||||
{
|
||||
if (wantedWeight < 0) {
|
||||
return entry.getKey();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package WayofTime.bloodmagic.structures;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
@ -10,17 +8,16 @@ import net.minecraft.world.gen.structure.template.PlacementSettings;
|
|||
import net.minecraft.world.gen.structure.template.Template;
|
||||
import net.minecraft.world.gen.structure.template.TemplateManager;
|
||||
|
||||
public class DungeonStructure
|
||||
{
|
||||
import java.util.Random;
|
||||
|
||||
public class DungeonStructure {
|
||||
public ResourceLocation resource;
|
||||
|
||||
public DungeonStructure(ResourceLocation resource)
|
||||
{
|
||||
public DungeonStructure(ResourceLocation resource) {
|
||||
this.resource = resource;
|
||||
}
|
||||
|
||||
public boolean placeStructureAtPosition(Random rand, PlacementSettings settings, WorldServer world, BlockPos pos)
|
||||
{
|
||||
public boolean placeStructureAtPosition(Random rand, PlacementSettings settings, WorldServer world, BlockPos pos) {
|
||||
if (pos == null)
|
||||
return false;
|
||||
|
||||
|
@ -29,8 +26,7 @@ public class DungeonStructure
|
|||
|
||||
Template template = templatemanager.getTemplate(minecraftserver, resource);
|
||||
|
||||
if (template == null)
|
||||
{
|
||||
if (template == null) {
|
||||
System.out.println("Invalid template for location: " + resource);
|
||||
return false;
|
||||
}
|
||||
|
@ -44,8 +40,7 @@ public class DungeonStructure
|
|||
return true;
|
||||
}
|
||||
|
||||
public DungeonStructure copy()
|
||||
{
|
||||
public DungeonStructure copy() {
|
||||
return new DungeonStructure(resource);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,19 +1,16 @@
|
|||
package WayofTime.bloodmagic.structures;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.WorldServer;
|
||||
|
||||
public class DungeonTester
|
||||
{
|
||||
public static void testDungeonGeneration(WorldServer world, BlockPos pos)
|
||||
{
|
||||
import java.util.Random;
|
||||
|
||||
public class DungeonTester {
|
||||
public static void testDungeonGeneration(WorldServer world, BlockPos pos) {
|
||||
|
||||
}
|
||||
|
||||
public static void testDungeonElementWithOutput(WorldServer world, BlockPos pos)
|
||||
{
|
||||
public static void testDungeonElementWithOutput(WorldServer world, BlockPos pos) {
|
||||
Dungeon.placeStructureAtPosition(new Random(), world, pos);
|
||||
// ResourceLocation resource = new ResourceLocation(Constants.Mod.MODID, "Corridor1");
|
||||
//
|
||||
|
|
|
@ -1,52 +1,43 @@
|
|||
package WayofTime.bloodmagic.structures;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.Mirror;
|
||||
import net.minecraft.util.Rotation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.gen.structure.template.PlacementSettings;
|
||||
|
||||
public class DungeonUtil
|
||||
{
|
||||
public static EnumFacing rotate(Mirror mirror, Rotation rotation, EnumFacing original)
|
||||
{
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class DungeonUtil {
|
||||
public static EnumFacing rotate(Mirror mirror, Rotation rotation, EnumFacing original) {
|
||||
return rotation.rotate(mirror.mirror(original));
|
||||
}
|
||||
|
||||
public static EnumFacing reverseRotate(Mirror mirror, Rotation rotation, EnumFacing original)
|
||||
{
|
||||
public static EnumFacing reverseRotate(Mirror mirror, Rotation rotation, EnumFacing original) {
|
||||
return mirror.mirror(getOppositeRotation(rotation).rotate(original));
|
||||
}
|
||||
|
||||
public static EnumFacing getFacingForSettings(PlacementSettings settings, EnumFacing original)
|
||||
{
|
||||
public static EnumFacing getFacingForSettings(PlacementSettings settings, EnumFacing original) {
|
||||
return rotate(settings.getMirror(), settings.getRotation(), original);
|
||||
}
|
||||
|
||||
public static Rotation getOppositeRotation(Rotation rotation)
|
||||
{
|
||||
switch (rotation)
|
||||
{
|
||||
case CLOCKWISE_90:
|
||||
return Rotation.COUNTERCLOCKWISE_90;
|
||||
case COUNTERCLOCKWISE_90:
|
||||
return Rotation.CLOCKWISE_90;
|
||||
default:
|
||||
return rotation;
|
||||
public static Rotation getOppositeRotation(Rotation rotation) {
|
||||
switch (rotation) {
|
||||
case CLOCKWISE_90:
|
||||
return Rotation.COUNTERCLOCKWISE_90;
|
||||
case COUNTERCLOCKWISE_90:
|
||||
return Rotation.CLOCKWISE_90;
|
||||
default:
|
||||
return rotation;
|
||||
}
|
||||
}
|
||||
|
||||
public static void addRoom(Map<EnumFacing, List<BlockPos>> doorMap, EnumFacing facing, BlockPos offsetPos)
|
||||
{
|
||||
if (doorMap.containsKey(facing))
|
||||
{
|
||||
public static void addRoom(Map<EnumFacing, List<BlockPos>> doorMap, EnumFacing facing, BlockPos offsetPos) {
|
||||
if (doorMap.containsKey(facing)) {
|
||||
doorMap.get(facing).add(offsetPos);
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
List<BlockPos> doorList = new ArrayList<BlockPos>();
|
||||
doorList.add(offsetPos);
|
||||
doorMap.put(facing, doorList);
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
package WayofTime.bloodmagic.structures;
|
||||
|
||||
public class ModDungeons
|
||||
{
|
||||
public static void init()
|
||||
{
|
||||
public class ModDungeons {
|
||||
public static void init() {
|
||||
// ResourceLocation resource = new ResourceLocation(Constants.Mod.MODID, "HallChest1");
|
||||
//
|
||||
// Map<String, BlockPos> structureMap = new HashMap<String, BlockPos>();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue