mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-10-26 05:50:08 +00:00
chores: remove unrelated code reformatting
This commit is contained in:
1 parent
6badce6bc7
commit
088523222d
7 files changed
+17
-30
No files matched your search
@@ -25,6 +25,7 @@ import com.dfsek.terra.api.world.biome.PlatformBiome;
|
|||||||
* @author daoge_cmd
|
* @author daoge_cmd
|
||||||
*/
|
*/
|
||||||
public class AllayPlatform extends AbstractPlatform {
|
public class AllayPlatform extends AbstractPlatform {
|
||||||
|
|
||||||
public static final Set<AllayGeneratorWrapper> GENERATOR_WRAPPERS = new HashSet<>();
|
public static final Set<AllayGeneratorWrapper> GENERATOR_WRAPPERS = new HashSet<>();
|
||||||
|
|
||||||
protected static final AllayWorldHandle ALLAY_WORLD_HANDLE = new AllayWorldHandle();
|
protected static final AllayWorldHandle ALLAY_WORLD_HANDLE = new AllayWorldHandle();
|
||||||
@@ -81,14 +82,12 @@ public class AllayPlatform extends AbstractPlatform {
|
|||||||
@Override
|
@Override
|
||||||
public void register(TypeRegistry registry) {
|
public void register(TypeRegistry registry) {
|
||||||
super.register(registry);
|
super.register(registry);
|
||||||
registry.registerLoader(BlockState.class, ($, o, $$, $$$) -> ALLAY_WORLD_HANDLE.createBlockState((String) o))
|
registry.registerLoader(BlockState.class, (type, o, loader, depthTracker) -> ALLAY_WORLD_HANDLE.createBlockState((String) o))
|
||||||
.registerLoader(PlatformBiome.class, ($, o, $$, depthTracker) -> parseBiome((String) o, depthTracker));
|
.registerLoader(PlatformBiome.class, (type, o, loader, depthTracker) -> parseBiome((String) o, depthTracker));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected AllayBiome parseBiome(String id, DepthTracker depthTracker) throws LoadException {
|
protected AllayBiome parseBiome(String id, DepthTracker depthTracker) throws LoadException {
|
||||||
if(!id.startsWith("minecraft:")) {
|
if(!id.startsWith("minecraft:")) throw new LoadException("Invalid biome identifier " + id, depthTracker);
|
||||||
throw new LoadException("Invalid biome identifier " + id, depthTracker);
|
|
||||||
}
|
|
||||||
return new AllayBiome(BiomeId.fromId(Mapping.biomeIdJeToBe(id)));
|
return new AllayBiome(BiomeId.fromId(Mapping.biomeIdJeToBe(id)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -45,11 +45,8 @@ public class JeBlockState {
|
|||||||
if(properties.size() == defaultProperties.size()) {
|
if(properties.size() == defaultProperties.size()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
defaultProperties
|
defaultProperties.entrySet().stream().filter(entry -> !properties.containsKey(entry.getKey())).forEach(
|
||||||
.entrySet()
|
entry -> properties.put(entry.getKey(), entry.getValue()));
|
||||||
.stream()
|
|
||||||
.filter(entry -> !properties.containsKey(entry.getKey()))
|
|
||||||
.forEach(entry -> properties.put(entry.getKey(), entry.getValue()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private JeBlockState(String identifier, TreeMap<String, String> properties) {
|
private JeBlockState(String identifier, TreeMap<String, String> properties) {
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import java.util.TreeMap;
|
|||||||
* @author daoge_cmd
|
* @author daoge_cmd
|
||||||
*/
|
*/
|
||||||
public final class Mapping {
|
public final class Mapping {
|
||||||
|
|
||||||
private static final Map<String, Map<String, String>> JE_BLOCK_DEFAULT_PROPERTIES = new Object2ObjectOpenHashMap<>();
|
private static final Map<String, Map<String, String>> JE_BLOCK_DEFAULT_PROPERTIES = new Object2ObjectOpenHashMap<>();
|
||||||
private static final Map<BlockState, JeBlockState> BLOCK_STATE_BE_TO_JE = new Object2ObjectOpenHashMap<>();
|
private static final Map<BlockState, JeBlockState> BLOCK_STATE_BE_TO_JE = new Object2ObjectOpenHashMap<>();
|
||||||
private static final Map<Integer, BlockState> BLOCK_STATE_JE_HASH_TO_BE = new Int2ObjectOpenHashMap<>();
|
private static final Map<Integer, BlockState> BLOCK_STATE_JE_HASH_TO_BE = new Int2ObjectOpenHashMap<>();
|
||||||
@@ -89,10 +90,7 @@ public final class Mapping {
|
|||||||
TerraAllayPlugin.INSTANCE.getPluginLogger().error("biomes mapping not found");
|
TerraAllayPlugin.INSTANCE.getPluginLogger().error("biomes mapping not found");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Set<Entry<String, Map<String, Integer>>> mappings = JSONUtils.from(
|
Set<Entry<String, Map<String, Integer>>> mappings = JSONUtils.from(stream, new TypeToken<Map<String, Map<String, Integer>>>(){}).entrySet();
|
||||||
stream,
|
|
||||||
new TypeToken<Map<String, Map<String, Integer>>>() {}
|
|
||||||
).entrySet();
|
|
||||||
mappings.forEach(mapping -> BIOME_ID_JE_TO_BE.put(mapping.getKey(), mapping.getValue().get("bedrock_id")));
|
mappings.forEach(mapping -> BIOME_ID_JE_TO_BE.put(mapping.getKey(), mapping.getValue().get("bedrock_id")));
|
||||||
} catch(IOException e) {
|
} catch(IOException e) {
|
||||||
TerraAllayPlugin.INSTANCE.getPluginLogger().error("Failed to load biomes mapping", e);
|
TerraAllayPlugin.INSTANCE.getPluginLogger().error("Failed to load biomes mapping", e);
|
||||||
@@ -107,10 +105,7 @@ public final class Mapping {
|
|||||||
TerraAllayPlugin.INSTANCE.getPluginLogger().error("items mapping not found");
|
TerraAllayPlugin.INSTANCE.getPluginLogger().error("items mapping not found");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Set<Entry<String, Map<String, Object>>> mappings = JSONUtils.from(
|
Set<Entry<String, Map<String, Object>>> mappings = JSONUtils.from(stream, new TypeToken<Map<String, Map<String, Object>>>() {}).entrySet();
|
||||||
stream,
|
|
||||||
new TypeToken<Map<String, Map<String, Object>>>() {}
|
|
||||||
).entrySet();
|
|
||||||
mappings.forEach(mapping -> {
|
mappings.forEach(mapping -> {
|
||||||
ItemType<?> item = ItemTypeSafeGetter
|
ItemType<?> item = ItemTypeSafeGetter
|
||||||
.name((String) mapping.getValue().get("bedrock_identifier"))
|
.name((String) mapping.getValue().get("bedrock_identifier"))
|
||||||
@@ -132,10 +127,7 @@ public final class Mapping {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// noinspection unchecked
|
// noinspection unchecked
|
||||||
List<Map<String, Map<String, Object>>> mappings = (List<Map<String, Map<String, Object>>>) JSONUtils.from(
|
List<Map<String, Map<String, Object>>> mappings = (List<Map<String, Map<String, Object>>>) JSONUtils.from(stream, new TypeToken<Map<String, Object>>() {}).get("mappings");
|
||||||
stream,
|
|
||||||
new TypeToken<Map<String, Object>>() {}
|
|
||||||
).get("mappings");
|
|
||||||
mappings.forEach(mapping -> {
|
mappings.forEach(mapping -> {
|
||||||
JeBlockState jeState = createJeBlockState(mapping.get("java_state"));
|
JeBlockState jeState = createJeBlockState(mapping.get("java_state"));
|
||||||
BlockState beState = createBeBlockState(mapping.get("bedrock_state"));
|
BlockState beState = createBeBlockState(mapping.get("bedrock_state"));
|
||||||
@@ -167,7 +159,8 @@ public final class Mapping {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static BlockState createBeBlockState(Map<String, Object> data) {
|
private static BlockState createBeBlockState(Map<String, Object> data) {
|
||||||
Getter getter = BlockStateSafeGetter.name("minecraft:" + data.get("bedrock_identifier"));
|
Getter getter = BlockStateSafeGetter
|
||||||
|
.name("minecraft:" + data.get("bedrock_identifier"));
|
||||||
if(data.containsKey("state")) {
|
if(data.containsKey("state")) {
|
||||||
// noinspection unchecked
|
// noinspection unchecked
|
||||||
convertValueType((Map<String, Object>) data.get("state")).forEach(getter::property);
|
convertValueType((Map<String, Object>) data.get("state")).forEach(getter::property);
|
||||||
@@ -190,7 +183,6 @@ public final class Mapping {
|
|||||||
|
|
||||||
private static JeBlockState createJeBlockState(Map<String, Object> data) {
|
private static JeBlockState createJeBlockState(Map<String, Object> data) {
|
||||||
// noinspection unchecked
|
// noinspection unchecked
|
||||||
return JeBlockState.create((String) data.get("Name"),
|
return JeBlockState.create((String) data.get("Name"), new TreeMap<>((Map<String, String>) data.getOrDefault("Properties", Map.of())));
|
||||||
new TreeMap<>((Map<String, String>) data.getOrDefault("Properties", Map.of())));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -70,8 +70,6 @@ public class TerraAllayPlugin extends Plugin {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
private void onWorldUnload(WorldUnloadEvent event) {
|
private void onWorldUnload(WorldUnloadEvent event) {
|
||||||
AllayPlatform.GENERATOR_WRAPPERS.removeIf(
|
AllayPlatform.GENERATOR_WRAPPERS.removeIf(wrapper -> wrapper.getAllayWorldGenerator().getDimension().getWorld() == event.getWorld());
|
||||||
wrapper -> wrapper.getAllayWorldGenerator().getDimension().getWorld() == event.getWorld()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -21,8 +21,7 @@ public record AllayChunk(ServerWorld world, Chunk allayChunk) implements com.dfs
|
|||||||
public void setBlock(int x, int y, int z, BlockState data, boolean physics) {
|
public void setBlock(int x, int y, int z, BlockState data, boolean physics) {
|
||||||
AllayBlockState allayBlockState = (AllayBlockState) data;
|
AllayBlockState allayBlockState = (AllayBlockState) data;
|
||||||
allayChunk.setBlockState(x, y, z, allayBlockState.allayBlockState());
|
allayChunk.setBlockState(x, y, z, allayBlockState.allayBlockState());
|
||||||
boolean containsWater = allayBlockState.containsWater() || allayChunk.getBlockState(x, y, z).getBlockType().hasBlockTag(BlockTags.WATER);
|
if (allayBlockState.containsWater() || allayChunk.getBlockState(x, y, z).getBlockType().hasBlockTag(BlockTags.WATER)) {
|
||||||
if (containsWater) {
|
|
||||||
allayChunk.setBlockState(x, y, z, WATER, 1);
|
allayChunk.setBlockState(x, y, z, WATER, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import com.dfsek.terra.api.world.chunk.generation.ProtoChunk;
|
|||||||
* @author daoge_cmd
|
* @author daoge_cmd
|
||||||
*/
|
*/
|
||||||
public record AllayProtoChunk(UnsafeChunk allayChunk) implements ProtoChunk {
|
public record AllayProtoChunk(UnsafeChunk allayChunk) implements ProtoChunk {
|
||||||
|
|
||||||
private static final org.allaymc.api.block.type.BlockState WATER = BlockTypes.WATER.ofState(BlockPropertyTypes.LIQUID_DEPTH.createValue(0));
|
private static final org.allaymc.api.block.type.BlockState WATER = BlockTypes.WATER.ofState(BlockPropertyTypes.LIQUID_DEPTH.createValue(0));
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import com.dfsek.terra.api.world.chunk.generation.ProtoWorld;
|
|||||||
* @author daoge_cmd
|
* @author daoge_cmd
|
||||||
*/
|
*/
|
||||||
public record AllayProtoWorld(AllayServerWorld allayServerWorld, OtherChunkAccessibleContext context) implements ProtoWorld {
|
public record AllayProtoWorld(AllayServerWorld allayServerWorld, OtherChunkAccessibleContext context) implements ProtoWorld {
|
||||||
|
|
||||||
private static final org.allaymc.api.block.type.BlockState WATER = BlockTypes.WATER.ofState(BlockPropertyTypes.LIQUID_DEPTH.createValue(0));
|
private static final org.allaymc.api.block.type.BlockState WATER = BlockTypes.WATER.ofState(BlockPropertyTypes.LIQUID_DEPTH.createValue(0));
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in new issue
Block a user