unimplement Keyed in Structure

This commit is contained in:
dfsek
2021-12-26 19:26:02 -07:00
parent 1ac3964589
commit 9c5b789aa2
6 changed files with 16 additions and 25 deletions
@@ -74,11 +74,6 @@ public class TerraFlora implements Structure {
return faces; return faces;
} }
@Override
public String getID() {
return id;
}
@Override @Override
public boolean generate(Vector3Int location, WritableWorld world, Random random, Rotation rotation) { public boolean generate(Vector3Int location, WritableWorld world, Random random, Rotation rotation) {
boolean doRotation = testRotation.size() > 0; boolean doRotation = testRotation.size() > 0;
@@ -95,11 +95,6 @@ public class VanillaOre implements Structure {
return true; return true;
} }
@Override
public String getID() {
return null;
}
public BlockState getMaterial(BlockType replace) { public BlockState getMaterial(BlockType replace) {
return materials.getOrDefault(replace, material); return materials.getOrDefault(replace, material);
} }
@@ -1,6 +1,7 @@
package com.dfsek.terra.addons.palette.shortcut.block; package com.dfsek.terra.addons.palette.shortcut.block;
import com.dfsek.terra.api.block.state.BlockState; import com.dfsek.terra.api.block.state.BlockState;
import com.dfsek.terra.api.registry.key.RegistryKey;
import com.dfsek.terra.api.structure.Structure; import com.dfsek.terra.api.structure.Structure;
import com.dfsek.terra.api.util.Rotation; import com.dfsek.terra.api.util.Rotation;
import com.dfsek.terra.api.util.vector.Vector3Int; import com.dfsek.terra.api.util.vector.Vector3Int;
@@ -21,9 +22,4 @@ public class SingletonStructure implements Structure {
world.setBlockState(location, blockState); world.setBlockState(location, blockState);
return true; return true;
} }
@Override
public String getID() {
return blockState.getAsString();
}
} }
@@ -10,6 +10,8 @@ package com.dfsek.terra.addons.sponge;
import java.util.Random; import java.util.Random;
import com.dfsek.terra.api.block.state.BlockState; import com.dfsek.terra.api.block.state.BlockState;
import com.dfsek.terra.api.registry.key.Keyed;
import com.dfsek.terra.api.registry.key.RegistryKey;
import com.dfsek.terra.api.structure.Structure; import com.dfsek.terra.api.structure.Structure;
import com.dfsek.terra.api.util.Rotation; import com.dfsek.terra.api.util.Rotation;
import com.dfsek.terra.api.util.vector.Vector2Int; import com.dfsek.terra.api.util.vector.Vector2Int;
@@ -17,13 +19,13 @@ import com.dfsek.terra.api.util.vector.Vector3Int;
import com.dfsek.terra.api.world.WritableWorld; import com.dfsek.terra.api.world.WritableWorld;
public class SpongeStructure implements Structure { public class SpongeStructure implements Structure, Keyed<SpongeStructure> {
private final BlockState[][][] blocks; private final BlockState[][][] blocks;
private final String id; private final RegistryKey id;
public SpongeStructure(BlockState[][][] blocks, String id) { public SpongeStructure(BlockState[][][] blocks, RegistryKey id) {
this.blocks = blocks; this.blocks = blocks;
this.id = id; this.id = id;
} }
@@ -49,7 +51,7 @@ public class SpongeStructure implements Structure {
} }
@Override @Override
public String getID() { public RegistryKey getRegistryKey() {
return id; return id;
} }
} }
@@ -7,6 +7,8 @@
package com.dfsek.terra.addons.terrascript.script; package com.dfsek.terra.addons.terrascript.script;
import com.dfsek.terra.api.registry.key.Keyed;
import com.dfsek.terra.api.registry.key.RegistryKey;
import com.dfsek.terra.api.util.vector.Vector3Int; import com.dfsek.terra.api.util.vector.Vector3Int;
import net.jafama.FastMath; import net.jafama.FastMath;
@@ -49,14 +51,14 @@ import com.dfsek.terra.api.util.Rotation;
import com.dfsek.terra.api.world.WritableWorld; import com.dfsek.terra.api.world.WritableWorld;
public class StructureScript implements Structure { public class StructureScript implements Structure, Keyed<StructureScript> {
private static final Logger LOGGER = LoggerFactory.getLogger(StructureScript.class); private static final Logger LOGGER = LoggerFactory.getLogger(StructureScript.class);
private final Block block; private final Block block;
private final String id; private final RegistryKey id;
private final Platform platform; private final Platform platform;
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
public StructureScript(InputStream inputStream, String id, Platform platform, Registry<Structure> registry, public StructureScript(InputStream inputStream, RegistryKey id, Platform platform, Registry<Structure> registry,
Registry<LootTable> lootRegistry, Registry<LootTable> lootRegistry,
Registry<FunctionBuilder> functionRegistry) { Registry<FunctionBuilder> functionRegistry) {
Parser parser; Parser parser;
@@ -148,7 +150,7 @@ public class StructureScript implements Structure {
} }
@Override @Override
public String getID() { public RegistryKey getRegistryKey() {
return id; return null;
} }
} }
@@ -9,12 +9,13 @@ package com.dfsek.terra.api.structure;
import java.util.Random; import java.util.Random;
import com.dfsek.terra.api.registry.key.Keyed;
import com.dfsek.terra.api.util.Rotation; import com.dfsek.terra.api.util.Rotation;
import com.dfsek.terra.api.registry.key.StringIdentifiable; import com.dfsek.terra.api.registry.key.StringIdentifiable;
import com.dfsek.terra.api.util.vector.Vector3Int; import com.dfsek.terra.api.util.vector.Vector3Int;
import com.dfsek.terra.api.world.WritableWorld; import com.dfsek.terra.api.world.WritableWorld;
public interface Structure extends StringIdentifiable { public interface Structure {
boolean generate(Vector3Int location, WritableWorld world, Random random, Rotation rotation); boolean generate(Vector3Int location, WritableWorld world, Random random, Rotation rotation);
} }