Revert to 1.6.4 schematics and other fixes
- Revert to 1.6.4 schematics - Fix iron doors being treated as wood doors - Fix crash when available link door has no LinkProperties
This commit is contained in:
parent
c8c706bac4
commit
931b804b10
117 changed files with 61 additions and 79 deletions
|
@ -68,13 +68,13 @@ public class PocketTemplate {
|
|||
if (tile instanceof TileEntityRift) {
|
||||
DimDoors.log.info("Rift found in schematic at " + pos);
|
||||
pocket.riftLocations.add(new Location(world, pos));
|
||||
} else if (tile instanceof TileEntityChest){
|
||||
} else if (tile instanceof TileEntityChest) {
|
||||
DimDoors.log.info("Now populating chest.");
|
||||
TileEntityChest chest = (TileEntityChest) tile;
|
||||
LootTable table = world.getLootTableManager().getLootTableFromLocation(new ResourceLocation(DimDoors.MODID+":dungeon_chest"));
|
||||
LootTable table = world.getLootTableManager().getLootTableFromLocation(new ResourceLocation(DimDoors.MODID + ":dungeon_chest"));
|
||||
LootContext ctx = new LootContext.Builder(world).build();
|
||||
table.fillInventory(chest, world.rand, ctx);
|
||||
DimDoors.log.info("Chest should be populated now. Chest is: " + (chest.isEmpty()? "emtpy.":"filled."));
|
||||
DimDoors.log.info("Chest should be populated now. Chest is: " + (chest.isEmpty() ? "emtpy." : "filled."));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -131,7 +131,7 @@ public class SchematicHandler {
|
|||
try {
|
||||
schematicNBT = CompressedStreamTools.readCompressed(schematicDataStream);
|
||||
if (!schematicNBT.hasKey("Version")) {
|
||||
schematic = SchematicConverter.convertSchematic(schematicNBT, template.getName(), template.getAuthor());
|
||||
schematic = SchematicConverter.convertSchematic(schematicNBT, template.getId(), template.getName(), template.getAuthor());
|
||||
} else {
|
||||
schematic = Schematic.loadFromNBT(schematicNBT);
|
||||
}
|
||||
|
|
|
@ -152,7 +152,7 @@ import java.util.Set;
|
|||
// Link the pocket back
|
||||
TileEntityRift thisRift = (TileEntityRift) location.getLocation().getTileEntity();
|
||||
TileEntityRift riftEntity = (TileEntityRift) pocket.getEntrance().getTileEntity();
|
||||
LinkProperties newLink = thisRift.getProperties().toBuilder().linksRemaining(0).build();
|
||||
LinkProperties newLink = thisRift.getProperties() != null ? thisRift.getProperties().toBuilder().linksRemaining(0).build() : null;
|
||||
pocket.linkPocketTo(new GlobalDestination(!noLinkBack && !riftEntity.getProperties().oneWay ? location.getLocation() : null), newLink); // TODO: linkId
|
||||
|
||||
// Link the rift if necessary and teleport the entity
|
||||
|
|
|
@ -13,7 +13,6 @@ import net.minecraft.util.ResourceLocation;
|
|||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
||||
import org.dimdev.ddutils.schem.Schematic;
|
||||
import org.dimdev.dimdoors.DimDoors;
|
||||
import org.dimdev.dimdoors.shared.blocks.BlockFabric;
|
||||
|
@ -32,19 +31,7 @@ import java.util.*;
|
|||
*/
|
||||
public final class SchematicConverter {
|
||||
|
||||
private static final Map<String, IBlockState> stateMap = new HashMap<>();
|
||||
|
||||
static {
|
||||
stateMap.put("dimdoors:Dimensional Door", ModBlocks.DIMENSIONAL_DOOR.getDefaultState());
|
||||
stateMap.put("dimdoors:Fabric of Reality", ModBlocks.FABRIC.getDefaultState().withProperty(BlockFabric.TYPE, BlockFabric.EnumType.REALITY));
|
||||
stateMap.put("dimdoors:Fabric of RealityPerm", ModBlocks.FABRIC.getDefaultState().withProperty(BlockFabric.TYPE, BlockFabric.EnumType.ANCIENT));
|
||||
stateMap.put("dimdoors:transientDoor", ModBlocks.TRANSIENT_DIMENSIONAL_DOOR.getDefaultState());
|
||||
stateMap.put("dimdoors:Warp Door", ModBlocks.WARP_DIMENSIONAL_DOOR.getDefaultState());
|
||||
stateMap.put("minecraft:iron_door", ModBlocks.DIMENSIONAL_DOOR.getDefaultState());
|
||||
stateMap.put("minecraft:wooden_door", ModBlocks.WARP_DIMENSIONAL_DOOR.getDefaultState());
|
||||
}
|
||||
|
||||
public static Schematic convertSchematic(NBTTagCompound nbt, String name, String author) {
|
||||
public static Schematic convertSchematic(NBTTagCompound nbt, String schematicId, String name, String author) {
|
||||
Schematic schematic = new Schematic();
|
||||
|
||||
schematic.version = 1; //already the default value
|
||||
|
@ -65,58 +52,53 @@ public final class SchematicConverter {
|
|||
int monoliths = 0;
|
||||
int chests = 0;
|
||||
|
||||
byte[] blockIntArray = nbt.getByteArray("Blocks");
|
||||
if (nbt.hasKey("Palette")) {
|
||||
NBTTagList paletteNBT = (NBTTagList) nbt.getTag("Palette");
|
||||
for (int i = 0; i < paletteNBT.tagCount(); i++) {
|
||||
String blockString = paletteNBT.getStringTagAt(i);
|
||||
IBlockState blockstate;
|
||||
|
||||
// Get the correct block state
|
||||
if (blockString.startsWith("dimdoors") || blockString.equals("minecraft:iron_door") || blockString.equals("minecraft:wooden_door")) {
|
||||
blockstate = stateMap.get(blockString);
|
||||
} else {
|
||||
blockstate = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(blockString)).getDefaultState();
|
||||
}
|
||||
|
||||
schematic.pallette.add(blockstate);
|
||||
byte[] blockIdArray = nbt.getByteArray("Blocks");
|
||||
byte[] addId = nbt.getByteArray("AddBlocks");
|
||||
Map<Integer, Byte> palletteMap = new HashMap<>(); // block ID -> pallette index
|
||||
byte currentPalletteIndex = 0;
|
||||
for (int i = 0; i < blockIdArray.length; i++) {
|
||||
int id;
|
||||
if (i >> 1 >= addId.length) {
|
||||
id = (short) (blockIdArray[i] & 0xFF);
|
||||
} else if ((i & 1) == 0) {
|
||||
id = (short) (((addId[i >> 1] & 0x0F) << 8) + (blockIdArray[i] & 0xFF));
|
||||
} else {
|
||||
id = (short) (((addId[i >> 1] & 0xF0) << 4) + (blockIdArray[i] & 0xFF));
|
||||
}
|
||||
} else {
|
||||
byte[] addId = nbt.getByteArray("AddBlocks");
|
||||
Map<Integer, Byte> palletteMap = new HashMap<>(); // block ID -> pallette index
|
||||
byte currentPalletteIndex = 0;
|
||||
for (int i = 0; i < blockIntArray.length; i++) {
|
||||
int id;
|
||||
if (i >> 1 >= addId.length) {
|
||||
id = (short) (blockIntArray[i] & 0xFF);
|
||||
} else if ((i & 1) == 0) {
|
||||
id = (short) (((addId[i >> 1] & 0x0F) << 8) + (blockIntArray[i] & 0xFF));
|
||||
} else {
|
||||
id = (short) (((addId[i >> 1] & 0xF0) << 4) + (blockIntArray[i] & 0xFF));
|
||||
if (palletteMap.containsKey(id)) {
|
||||
blockIdArray[i] = palletteMap.get(id);
|
||||
} else {
|
||||
IBlockState block = id <= 159 ? Block.getBlockById(id).getDefaultState() : Blocks.AIR.getDefaultState();
|
||||
switch (id) {
|
||||
case 1973:
|
||||
block = ModBlocks.FABRIC.getDefaultState();
|
||||
break;
|
||||
case 1975:
|
||||
block = ModBlocks.WARP_DIMENSIONAL_DOOR.getDefaultState();
|
||||
break;
|
||||
case 1970:
|
||||
block = ModBlocks.DIMENSIONAL_DOOR.getDefaultState();
|
||||
break;
|
||||
case 1979:
|
||||
block = ModBlocks.TRANSIENT_DIMENSIONAL_DOOR.getDefaultState();
|
||||
break;
|
||||
case 220:
|
||||
block = ModBlocks.FABRIC.getDefaultState().withProperty(BlockFabric.TYPE, BlockFabric.EnumType.REALITY);
|
||||
break;
|
||||
case 95: // Locked chest's ID was replaced with stained glass in 1.7.2
|
||||
DimDoors.log.error("Schematic contained a locked chest, which was removed in 1.7.2.");
|
||||
block = Blocks.AIR.getDefaultState();
|
||||
break;
|
||||
}
|
||||
if (palletteMap.containsKey(id)) {
|
||||
blockIntArray[i] = palletteMap.get(id);
|
||||
} else {
|
||||
Block block = Block.getBlockById(id);
|
||||
switch (id) {
|
||||
case 1975:
|
||||
block = ModBlocks.WARP_DIMENSIONAL_DOOR;
|
||||
break;
|
||||
case 1970:
|
||||
block = ModBlocks.DIMENSIONAL_DOOR;
|
||||
break;
|
||||
case 1979:
|
||||
block = ModBlocks.TRANSIENT_DIMENSIONAL_DOOR;
|
||||
break;
|
||||
}
|
||||
if (id != 0 && block.getRegistryName().toString().equals("minecraft:air")) {
|
||||
throw new RuntimeException("Change conversion code!");
|
||||
}
|
||||
schematic.pallette.add(block.getDefaultState());
|
||||
palletteMap.put(id, currentPalletteIndex);
|
||||
blockIntArray[i] = currentPalletteIndex;
|
||||
currentPalletteIndex++;
|
||||
if (id != 0 && block.getBlock().getRegistryName().toString().equals("minecraft:air")) {
|
||||
throw new RuntimeException("Unknown ID " + id + " in schematic " + schematicId);
|
||||
}
|
||||
if (block.equals(Blocks.IRON_DOOR)) block = ModBlocks.DIMENSIONAL_DOOR.getDefaultState();
|
||||
if (block.equals(Blocks.OAK_DOOR)) block = ModBlocks.WARP_DIMENSIONAL_DOOR.getDefaultState();
|
||||
schematic.pallette.add(block);
|
||||
palletteMap.put(id, currentPalletteIndex);
|
||||
blockIdArray[i] = currentPalletteIndex;
|
||||
currentPalletteIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -145,7 +127,7 @@ public final class SchematicConverter {
|
|||
for (int x = 0; x < schematic.width; x++) {
|
||||
for (int y = 0; y < schematic.height; y++) {
|
||||
for (int z = 0; z < schematic.length; z++) {
|
||||
int blockInt = blockIntArray[x + z * schematic.width + y * schematic.width * schematic.length]; //according to the documentation on https://github.com/SpongePowered/Schematic-Specification/blob/master/versions/schematic-1.md
|
||||
int blockInt = blockIdArray[x + z * schematic.width + y * schematic.width * schematic.length]; //according to the documentation on https://github.com/SpongePowered/Schematic-Specification/blob/master/versions/schematic-1.md
|
||||
int metadata = dataIntArray[x + z * schematic.width + y * schematic.width * schematic.length]; //according to the documentation on https://github.com/SpongePowered/Schematic-Specification/blob/master/versions/schematic-1.md
|
||||
|
||||
IBlockState baseState = schematic.pallette.get(blockInt); //this is the default blockstate except for ancient fabric
|
||||
|
@ -171,7 +153,7 @@ public final class SchematicConverter {
|
|||
.groups(new HashSet<>(Arrays.asList(0, 1)))
|
||||
.linksRemaining(1).build());
|
||||
|
||||
if (baseState.equals(ModBlocks.DIMENSIONAL_DOOR)) {
|
||||
if (baseState.getBlock().equals(ModBlocks.DIMENSIONAL_DOOR)) {
|
||||
ironDoors++;
|
||||
rift.setDestination(AvailableLinkDestination.builder()
|
||||
.acceptedGroups(Collections.singleton(0))
|
||||
|
@ -198,7 +180,7 @@ public final class SchematicConverter {
|
|||
if (y >= 2) {
|
||||
schematic.blockData[x][y - 1][z] = schematic.blockData[x][y - 2][z];
|
||||
} else {
|
||||
DimDoors.log.error("Someone placed a door on a sandstone block at the bottom of a schematic. This causes problems and should be remedied. Schematic name: " + schematic.name);
|
||||
DimDoors.log.error("Someone placed a door on a sandstone block at the bottom of a schematic. This causes problems and should be remedied. Schematic name: " + schematicId);
|
||||
}
|
||||
} else {
|
||||
woodDoors++;
|
||||
|
@ -217,7 +199,6 @@ public final class SchematicConverter {
|
|||
|
||||
schematic.tileEntities.add(rift.serializeNBT());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (blockState.getBlock().equals(Blocks.END_PORTAL_FRAME)) {
|
||||
|
@ -237,10 +218,11 @@ public final class SchematicConverter {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (!nbt.getTag("Entities").hasNoTags()) throw new RuntimeException("Schematic contains entities, but those aren't implemented in the conversion code");
|
||||
if (!nbt.getTag("Entities").hasNoTags())
|
||||
throw new RuntimeException("Schematic contains entities, but those aren't implemented in the conversion code");
|
||||
schematic.paletteMax = schematic.pallette.size() - 1;
|
||||
|
||||
DimDoors.log.info(schematic.name + "," + ironDoors + "," + woodDoors + "," + sandstoneDoors + "," + monoliths + "," + chests);
|
||||
DimDoors.log.info(schematicId + "," + schematic.name + "," + ironDoors + "," + woodDoors + "," + sandstoneDoors + "," + monoliths + "," + chests);
|
||||
|
||||
return schematic;
|
||||
}
|
||||
|
|
|
@ -14,11 +14,11 @@ import java.io.InputStream;
|
|||
public abstract class BaseSchematicGateway extends BaseGateway {
|
||||
private Schematic schematic;
|
||||
|
||||
public BaseSchematicGateway(String name) {
|
||||
public BaseSchematicGateway(String id) {
|
||||
String schematicJarDirectory = "/assets/dimdoors/gateways/";
|
||||
|
||||
//Initialising the possible locations/formats for the schematic file
|
||||
InputStream oldVersionSchematicStream = DimDoors.class.getResourceAsStream(schematicJarDirectory + name + ".schematic"); //@todo also check for other schematics
|
||||
InputStream oldVersionSchematicStream = DimDoors.class.getResourceAsStream(schematicJarDirectory + id + ".schematic"); //@todo also check for other schematics
|
||||
|
||||
//determine which location to load the schematic file from (and what format)
|
||||
DataInputStream schematicDataStream = null;
|
||||
|
@ -27,7 +27,7 @@ public abstract class BaseSchematicGateway extends BaseGateway {
|
|||
schematicDataStream = new DataInputStream(oldVersionSchematicStream);
|
||||
streamOpened = true;
|
||||
} else {
|
||||
DimDoors.log.warn("Schematic '" + name + "' was not found in the jar or config directory, neither with the .schem extension, nor with the .schematic extension.");
|
||||
DimDoors.log.warn("Schematic '" + id + "' was not found in the jar or config directory, neither with the .schem extension, nor with the .schematic extension.");
|
||||
}
|
||||
|
||||
NBTTagCompound schematicNBT;
|
||||
|
@ -35,10 +35,10 @@ public abstract class BaseSchematicGateway extends BaseGateway {
|
|||
if (streamOpened) {
|
||||
try {
|
||||
schematicNBT = CompressedStreamTools.readCompressed(schematicDataStream);
|
||||
schematic = SchematicConverter.convertSchematic(schematicNBT, name, null);
|
||||
schematic = SchematicConverter.convertSchematic(schematicNBT, id, null, null);
|
||||
schematicDataStream.close();
|
||||
} catch (IOException ex) {
|
||||
DimDoors.log.error("Schematic file for " + name + " could not be read as a valid schematic NBT file.", ex);
|
||||
DimDoors.log.error("Schematic file for " + id + " could not be read as a valid schematic NBT file.", ex);
|
||||
} finally {
|
||||
try {
|
||||
schematicDataStream.close();
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue