Found piece with FoamFix

- Removed soft FoamFix dependency
 - Sorted a switch case tree by key
 - Added conversion for that 1 World Thread in 1 dungeon
 - Made translateId method more sturdy by hardcoding some fall-back values, so FoamFix doesn't crash it anymore.
 - Changed Schematic author SK to full name: SenseiKiwi
This commit is contained in:
Robijnvogel 2018-01-21 08:53:23 +01:00
parent 6a2cb241ee
commit 6aa2ab8d55
4 changed files with 114 additions and 82 deletions

View file

@ -30,9 +30,8 @@ public class DimDoors {
public static final String MCVERSIONS = "[1.12,1.13)";
public static final String VERSION = "${version}";
// TODO: make the forge version here change depending on a field in build.gradle
public static final String DEPENDENCIES = "required-after:forge@[14.21.0.2320,);after:csb_ench_table;after:foamfix@[0.8.4-1.12.2,)";
public static final String DEPENDENCIES = "required-after:forge@[14.21.0.2320,);after:csb_ench_table";
// after:csb_ench_table as a workaround for https://github.com/crazysnailboy/EnchantingTable/issues/7
// before:foamfix@[0.0.0-1.12.2,) as a placeholder until https://github.com/asiekierka/FoamFix/issues/105 gets fixed at that time, the workaround in @code{SchematicConverter#convertSchematic} should also be removed.
@Mod.Instance(DimDoors.MODID)
public static DimDoors instance;

View file

@ -1,6 +1,7 @@
package org.dimdev.dimdoors.shared.tools;
import java.util.*;
import javax.annotation.Nonnull;
import net.minecraft.block.Block;
import net.minecraft.block.BlockDoor;
import net.minecraft.block.BlockEndPortalFrame;
@ -136,6 +137,8 @@ public final class SchematicConverter {
int x = tileEntityNBT.getInteger("x");
int y = tileEntityNBT.getInteger("y");
int z = tileEntityNBT.getInteger("z");
tileEntityPositions.add(new Vec3i(x, y, z));
switch (tileEntityNBT.getString("id")) {
case "TileEntityDimDoor":
case "TileEntityRift":
@ -160,6 +163,13 @@ public final class SchematicConverter {
item = Item.getItemById(oldID);
} else {
switch (oldID) {
case 220:
item = ModItems.ANCIENT_FABRIC;
newMeta = (oldMeta == 0) ? 15 : 0;
break;
case 1970:
item = ModItems.DIMENSIONAL_DOOR;
break;
case 1973:
item = ModItems.FABRIC;
newMeta = (oldMeta == 0) ? 15 : 0;
@ -167,14 +177,10 @@ public final class SchematicConverter {
case 1975:
item = ModItems.WARP_DIMENSIONAL_DOOR;
break;
case 1970:
item = ModItems.DIMENSIONAL_DOOR;
break;
case 1979: //Transient Portal
break;
case 220:
item = ModItems.ANCIENT_FABRIC;
newMeta = (oldMeta == 0) ? 15 : 0;
case 5936:
item = ModItems.WORLD_THREAD;
break;
case WRITTEN_BOOK_ID:
item = Item.getItemById(oldID);
@ -223,19 +229,8 @@ public final class SchematicConverter {
break;
}
String oldID = tileEntityNBT.getString("id");
ResourceLocation resLoc = translateId(oldID);
if (resLoc == null) {
DimDoors.log.error("Resourcelocation of TileEntity with old ID: " + oldID + " was null. If you want to complain about log spam; " + (oldID.equals("Hopper") ? "it is very likely that it's FoamFix causing this." : "we have no idea what causes this, so please report it."));
if (oldID.equals("Hopper")) {
resLoc = new ResourceLocation("minecraft:hopper");
}
}
if (resLoc != null) {
String newID = resLoc.toString();
//DimDoors.log.info("Resourcelocation succesfully translated from old ID: " + oldID + " into: " + newID + ".");
String newID = translateId(oldID);
tileEntityNBT.setString("id", newID);
}
tileEntityPositions.add(new Vec3i(x, y, z));
schematic.tileEntities.add(tileEntityNBT);
}
}
@ -391,25 +386,63 @@ public final class SchematicConverter {
return schematic;
}
private static ResourceLocation translateId(String id) { // TODO
@Nonnull
private static String translateId(String id) { // TODO
ResourceLocation location;
switch (id) {
case "Sign":
return TileEntity.getKey(TileEntitySign.class);
location = TileEntity.getKey(TileEntitySign.class);
break;
case "Music":
return TileEntity.getKey(TileEntityNote.class);
location = TileEntity.getKey(TileEntityNote.class);
break;
case "Trap":
return TileEntity.getKey(TileEntityDispenser.class);
location = TileEntity.getKey(TileEntityDispenser.class);
break;
case "Comparator":
return TileEntity.getKey(TileEntityComparator.class);
location = TileEntity.getKey(TileEntityComparator.class);
break;
case "Hopper":
return TileEntity.getKey(TileEntityHopper.class);
location = TileEntity.getKey(TileEntityHopper.class);
break;
case "Furnace":
return TileEntity.getKey(TileEntityFurnace.class);
location = TileEntity.getKey(TileEntityFurnace.class);
break;
case "Chest":
return TileEntity.getKey(TileEntityChest.class);
location = TileEntity.getKey(TileEntityChest.class);
break;
default:
throw new RuntimeException("Tile entity ID " + id + " not supported by conversion code");
}
if (location == null) {
DimDoors.log.error("Resourcelocation of TileEntity with old ID: " + id + " was null. If you want to complain about log spam; " + (id.equals("Hopper") ? "it is very likely that it's FoamFix causing this." : "we have no idea what causes this, so please report it."));
location = translateIdCrude(id);
} else {
//DimDoors.log.info("Resourcelocation succesfully translated from old ID: " + oldID + " into: " + newID + ".");
}
return location.toString();
}
@Nonnull
private static ResourceLocation translateIdCrude(String id) { // TODO
ResourceLocation location;
switch (id) {
case "Sign":
return new ResourceLocation("minecraft:sign");
case "Music":
return new ResourceLocation("minecraft:noteblock");
case "Trap":
return new ResourceLocation("minecraft:dispenser");
case "Comparator":
return new ResourceLocation("minecraft:comparator");
case "Hopper":
return new ResourceLocation("minecraft:hopper");
case "Furnace":
return new ResourceLocation("minecraft:furnace");
case "Chest":
default:
return new ResourceLocation("minecraft:chest");
}
}
private static boolean isValidItemIDForSimpleConversion(int id) {

View file

@ -5,7 +5,7 @@
"id": "courtyard_ambush",
"type": "complex_hall",
"name": "Courtyard Ambush",
"author": "SK",
"author": "SenseiKiwi",
"open": true,
"size": 4,
"baseWeight": 100
@ -14,7 +14,7 @@
"id": "intersection",
"type": "complex_hall",
"name": "Intersection",
"author": "SK",
"author": "SenseiKiwi",
"open": true,
"size": 2,
"baseWeight": 100
@ -23,7 +23,7 @@
"id": "soul_wastes",
"type": "complex_hall",
"name": "Soul Wastes",
"author": "SK",
"author": "SenseiKiwi",
"open": true,
"size": 5,
"baseWeight": 100
@ -32,7 +32,7 @@
"id": "starfall",
"type": "complex_hall",
"name": "Starfall",
"author": "SK",
"author": "SenseiKiwi",
"open": true,
"size": 3,
"baseWeight": 100
@ -41,7 +41,7 @@
"id": "the_cauldron",
"type": "complex_hall",
"name": "The Cauldron",
"author": "SK",
"author": "SenseiKiwi",
"open": true,
"size": 4,
"baseWeight": 100
@ -50,7 +50,7 @@
"id": "brimstone_mines",
"type": "maze",
"name": "Brimstone Mines",
"author": "SK",
"author": "SenseiKiwi",
"open": true,
"size": 6,
"baseWeight": 80
@ -59,7 +59,7 @@
"id": "quartzfold_cave",
"type": "maze",
"name": "Quartzfold Cave",
"author": "SK",
"author": "SenseiKiwi",
"open": true,
"size": 5,
"baseWeight": 40
@ -68,7 +68,7 @@
"id": "swirls_upon_swirls",
"type": "maze",
"name": "Swirls Upon Swirls",
"author": "SK",
"author": "SenseiKiwi",
"open": true,
"size": 5,
"baseWeight": 40
@ -77,7 +77,7 @@
"id": "tangle",
"type": "maze",
"name": "Tangle",
"author": "SK",
"author": "SenseiKiwi",
"open": true,
"size": 3,
"baseWeight": 80
@ -86,7 +86,7 @@
"id": "anvil_valley",
"type": "simple_hall",
"name": "Anvil Valley",
"author": "SK",
"author": "SenseiKiwi",
"open": true,
"size": 5,
"baseWeight": 100
@ -95,7 +95,7 @@
"id": "arena",
"type": "simple_hall",
"name": "Arena",
"author": "SK",
"author": "SenseiKiwi",
"open": true,
"size": 3,
"baseWeight": 100
@ -103,7 +103,7 @@
{
"id": "dark_path_left",
"type": "simple_hall",
"author": "SK",
"author": "SenseiKiwi",
"open": true,
"size": 1,
"baseWeight": 50
@ -111,7 +111,7 @@
{
"id": "dark_path_right",
"type": "simple_hall",
"author": "SK",
"author": "SenseiKiwi",
"open": true,
"size": 1,
"baseWeight": 50
@ -119,7 +119,7 @@
{
"id": "diamond_room",
"type": "simple_hall",
"author": "SK",
"author": "SenseiKiwi",
"open": true,
"size": 1,
"baseWeight": 100
@ -127,7 +127,7 @@
{
"id": "long_bridge",
"type": "simple_hall",
"author": "SK",
"author": "SenseiKiwi",
"open": true,
"size": 4,
"baseWeight": 100
@ -135,7 +135,7 @@
{
"id": "spiral_stairs_down",
"type": "simple_hall",
"author": "SK",
"author": "SenseiKiwi",
"open": true,
"size": 0,
"baseWeight": 100
@ -143,7 +143,7 @@
{
"id": "the_furnace",
"type": "simple_hall",
"author": "SK",
"author": "SenseiKiwi",
"open": true,
"size": 3,
"baseWeight": 100

View file

@ -89,7 +89,7 @@
{
"id": "anchored_descent",
"type": "complex_hall",
"author": "SK",
"author": "SenseiKiwi",
"open": true,
"size": 1,
"baseWeight": 50
@ -97,7 +97,7 @@
{
"id": "hallway_hidden_treasure_b",
"type": "complex_hall",
"author": "SK",
"author": "SenseiKiwi",
"open": false,
"size": 2,
"baseWeight": 50
@ -105,7 +105,7 @@
{
"id": "hidden_stairs",
"type": "complex_hall",
"author": "SK",
"author": "SenseiKiwi",
"open": true,
"size": 2,
"baseWeight": 100
@ -113,7 +113,7 @@
{
"id": "lost_garden",
"type": "complex_hall",
"author": "SK",
"author": "SenseiKiwi",
"open": true,
"size": 2,
"baseWeight": 40
@ -121,7 +121,7 @@
{
"id": "ruins_oh_no",
"type": "complex_hall",
"author": "SK",
"author": "SenseiKiwi",
"open": true,
"size": 2,
"baseWeight": 50
@ -129,7 +129,7 @@
{
"id": "small_branch_with_exit",
"type": "complex_hall",
"author": "SK",
"author": "SenseiKiwi",
"open": false,
"size": 2,
"baseWeight": 100
@ -144,7 +144,7 @@
{
"id": "tnt_puzzle_trap",
"type": "complex_hall",
"author": "SK",
"author": "SenseiKiwi",
"open": false,
"size": 2,
"baseWeight": 50
@ -217,7 +217,7 @@
{
"id": "eyes_of_tricksters",
"type": "dead_end",
"author": "SK",
"author": "SenseiKiwi",
"open": true,
"size": 2,
"baseWeight": 50
@ -225,7 +225,7 @@
{
"id": "far_away_in_the_dark",
"type": "dead_end",
"author": "SK",
"author": "SenseiKiwi",
"open": true,
"size": 2,
"baseWeight": 100
@ -233,7 +233,7 @@
{
"id": "unstable_desert",
"type": "dead_end",
"author": "SK",
"author": "SenseiKiwi",
"open": true,
"size": 2,
"baseWeight": 50
@ -290,7 +290,7 @@
{
"id": "hot_suspense",
"type": "exit",
"author": "SK",
"author": "SenseiKiwi",
"open": true,
"size": 2,
"baseWeight": 75
@ -298,7 +298,7 @@
{
"id": "locking_exit_trap",
"type": "exit",
"author": "SK",
"author": "SenseiKiwi",
"open": false,
"size": 2,
"baseWeight": 50
@ -379,7 +379,7 @@
{
"id": "claustrophobia",
"type": "hub",
"author": "SK",
"author": "SenseiKiwi",
"open": true,
"size": 4,
"baseWeight": 40
@ -387,7 +387,7 @@
{
"id": "fractal_cage",
"type": "hub",
"author": "SK",
"author": "SenseiKiwi",
"open": true,
"size": 3,
"baseWeight": 40
@ -395,7 +395,7 @@
{
"id": "heart_of_disorder",
"type": "hub",
"author": "SK",
"author": "SenseiKiwi",
"open": true,
"size": 4,
"baseWeight": 50
@ -403,7 +403,7 @@
{
"id": "random_snow",
"type": "hub",
"author": "SK",
"author": "SenseiKiwi",
"open": true,
"size": 2,
"baseWeight": 75
@ -411,7 +411,7 @@
{
"id": "random_swamp",
"type": "hub",
"author": "SK",
"author": "SenseiKiwi",
"open": true,
"size": 2,
"baseWeight": 75
@ -419,7 +419,7 @@
{
"id": "the_nexus",
"type": "hub",
"author": "SK",
"author": "SenseiKiwi",
"open": true,
"size": 3,
"baseWeight": 40
@ -483,7 +483,7 @@
{
"id": "left_down_stairs",
"type": "simple_hall",
"author": "SK",
"author": "SenseiKiwi",
"open": true,
"size": 1,
"baseWeight": 50
@ -491,7 +491,7 @@
{
"id": "left_up_path",
"type": "simple_hall",
"author": "SK",
"author": "SenseiKiwi",
"open": true,
"size": 1,
"baseWeight": 50
@ -499,7 +499,7 @@
{
"id": "right_down_stairs",
"type": "simple_hall",
"author": "SK",
"author": "SenseiKiwi",
"open": true,
"size": 1,
"baseWeight": 50
@ -507,7 +507,7 @@
{
"id": "right_up_path",
"type": "simple_hall",
"author": "SK",
"author": "SenseiKiwi",
"open": true,
"size": 1,
"baseWeight": 50
@ -515,7 +515,7 @@
{
"id": "spiral_hallway",
"type": "simple_hall",
"author": "SK",
"author": "SenseiKiwi",
"open": true,
"size": 2,
"baseWeight": 100
@ -523,7 +523,7 @@
{
"id": "u_turn_left",
"type": "simple_hall",
"author": "SK",
"author": "SenseiKiwi",
"open": true,
"size": 2,
"baseWeight": 50
@ -531,7 +531,7 @@
{
"id": "u_turn_right",
"type": "simple_hall",
"author": "SK",
"author": "SenseiKiwi",
"open": true,
"size": 2,
"baseWeight": 50
@ -539,7 +539,7 @@
{
"id": "watched_fork_left",
"type": "simple_hall",
"author": "SK",
"author": "SenseiKiwi",
"open": false,
"size": 2,
"baseWeight": 80
@ -547,7 +547,7 @@
{
"id": "watched_fork_right",
"type": "simple_hall",
"author": "SK",
"author": "SenseiKiwi",
"open": false,
"size": 2,
"baseWeight": 80
@ -639,7 +639,7 @@
{
"id": "fake_tnt_trap_b",
"type": "trap",
"author": "SK",
"author": "SenseiKiwi",
"open": false,
"size": 2,
"baseWeight": 50
@ -647,7 +647,7 @@
{
"id": "nicoles_tower",
"type": "trap",
"author": "SK",
"author": "SenseiKiwi",
"open": true,
"size": 0,
"baseWeight": 50
@ -655,7 +655,7 @@
{
"id": "race_the_light",
"type": "trap",
"author": "SK",
"author": "SenseiKiwi",
"open": false,
"size": 1,
"baseWeight": 50
@ -663,7 +663,7 @@
{
"id": "restless_corridor",
"type": "trap",
"author": "SK",
"author": "SenseiKiwi",
"open": true,
"size": 4,
"baseWeight": 40
@ -671,7 +671,7 @@
{
"id": "simple_left_trap",
"type": "trap",
"author": "SK",
"author": "SenseiKiwi",
"open": false,
"size": 2,
"baseWeight": 50
@ -679,7 +679,7 @@
{
"id": "simple_right_trap",
"type": "trap",
"author": "SK",
"author": "SenseiKiwi",
"open": false,
"size": 2,
"baseWeight": 50
@ -687,7 +687,7 @@
{
"id": "trapped_stairs_down",
"type": "trap",
"author": "SK",
"author": "SenseiKiwi",
"open": false,
"size": 2,
"baseWeight": 50
@ -695,7 +695,7 @@
{
"id": "trapped_stairs_up",
"type": "trap",
"author": "SK",
"author": "SenseiKiwi",
"open": false,
"size": 2,
"baseWeight": 50
@ -703,7 +703,7 @@
{
"id": "u_trap_right",
"type": "trap",
"author": "SK",
"author": "SenseiKiwi",
"open": true,
"size": 2,
"baseWeight": 50