-
Notifications
You must be signed in to change notification settings - Fork 95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: adapt allay update #484
base: ver/6.6.0
Are you sure you want to change the base?
Changes from 1 commit
9b6a503
4222eef
92a5134
6badce6
0885232
73a2c70
944c04b
98aadc8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ object Versions { | |
const val caffeine = "3.1.8" | ||
|
||
const val slf4j = "2.0.16" | ||
|
||
object Internal { | ||
const val shadow = "8.3.3" | ||
const val apacheText = "1.12.0" | ||
|
@@ -31,7 +31,7 @@ object Versions { | |
const val fabricAPI = "0.106.1+${Mod.minecraft}" | ||
const val cloud = "2.0.0-beta.9" | ||
} | ||
// | ||
|
||
// object Quilt { | ||
// const val quiltLoader = "0.20.2" | ||
// const val fabricApi = "7.3.1+0.89.3-1.20.1" | ||
|
@@ -46,9 +46,8 @@ object Versions { | |
|
||
const val architecuryLoom = "1.7.413" | ||
const val architecturyPlugin = "3.4.159" | ||
|
||
} | ||
// | ||
|
||
// object Forge { | ||
// const val forge = "${Mod.minecraft}-48.0.13" | ||
// const val burningwave = "12.63.0" | ||
|
@@ -65,20 +64,19 @@ object Versions { | |
const val paperWeight = "1.7.2" | ||
const val cloud = "2.0.0-beta.10" | ||
} | ||
|
||
// | ||
|
||
// object Sponge { | ||
// const val sponge = "9.0.0-SNAPSHOT" | ||
// const val mixin = "0.8.2" | ||
// const val minecraft = "1.17.1" | ||
// } | ||
// | ||
object CLI { | ||
const val logback = "1.5.8" | ||
const val picocli = "4.7.6" | ||
} | ||
|
||
object Allay { | ||
const val api = "0114e0b290" | ||
const val api = "master-SNAPSHOT" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use a specific version rather than |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,6 @@ | |
* @author daoge_cmd | ||
*/ | ||
public final class Mapping { | ||
|
||
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<Integer, BlockState> BLOCK_STATE_JE_HASH_TO_BE = new Int2ObjectOpenHashMap<>(); | ||
|
@@ -73,7 +72,7 @@ public static int biomeIdJeToBe(String jeBiomeId) { | |
|
||
public static Map<String, String> getJeBlockDefaultProperties(String jeBlockIdentifier) { | ||
Map<String, String> defaultProperties = JE_BLOCK_DEFAULT_PROPERTIES.get(jeBlockIdentifier); | ||
if( defaultProperties == null) { | ||
if(defaultProperties == null) { | ||
TerraAllayPlugin.INSTANCE.getPluginLogger().warn("Failed to find default properties for {}", jeBlockIdentifier); | ||
return Map.of(); | ||
} | ||
|
@@ -85,12 +84,15 @@ private static void error() { | |
} | ||
|
||
private static boolean initBiomeMapping() { | ||
try (InputStream stream = Mapping.class.getClassLoader().getResourceAsStream("mapping/biomes.json")) { | ||
if (stream == null) { | ||
try(InputStream stream = Mapping.class.getClassLoader().getResourceAsStream("mapping/biomes.json")) { | ||
solonovamax marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if(stream == null) { | ||
TerraAllayPlugin.INSTANCE.getPluginLogger().error("biomes mapping not found"); | ||
return false; | ||
} | ||
Set<Entry<String, Map<String, Integer>>> mappings = JSONUtils.from(stream, new TypeToken<Map<String, Map<String, Integer>>>(){}).entrySet(); | ||
Set<Entry<String, Map<String, Integer>>> mappings = JSONUtils.from( | ||
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"))); | ||
solonovamax marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} catch(IOException e) { | ||
TerraAllayPlugin.INSTANCE.getPluginLogger().error("Failed to load biomes mapping", e); | ||
|
@@ -100,12 +102,15 @@ private static boolean initBiomeMapping() { | |
} | ||
|
||
private static boolean initItemMapping() { | ||
try (InputStream stream = Mapping.class.getClassLoader().getResourceAsStream("mapping/items.json")) { | ||
if (stream == null) { | ||
try(InputStream stream = Mapping.class.getClassLoader().getResourceAsStream("mapping/items.json")) { | ||
if(stream == null) { | ||
TerraAllayPlugin.INSTANCE.getPluginLogger().error("items mapping not found"); | ||
return false; | ||
} | ||
Set<Entry<String, Map<String, Object>>> mappings = JSONUtils.from(stream, new TypeToken<Map<String, Map<String, Object>>>(){}).entrySet(); | ||
Set<Entry<String, Map<String, Object>>> mappings = JSONUtils.from( | ||
stream, | ||
new TypeToken<Map<String, Map<String, Object>>>() {} | ||
).entrySet(); | ||
mappings.forEach(mapping -> { | ||
ItemType<?> item = ItemTypeSafeGetter | ||
.name((String) mapping.getValue().get("bedrock_identifier")) | ||
solonovamax marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
@@ -121,13 +126,16 @@ private static boolean initItemMapping() { | |
} | ||
|
||
private static boolean initBlockStateMapping() { | ||
try (InputStream stream = Mapping.class.getClassLoader().getResourceAsStream("mapping/blocks.json")) { | ||
if (stream == null) { | ||
try(InputStream stream = Mapping.class.getClassLoader().getResourceAsStream("mapping/blocks.json")) { | ||
if(stream == null) { | ||
TerraAllayPlugin.INSTANCE.getPluginLogger().error("blocks mapping not found"); | ||
return false; | ||
} | ||
// noinspection unchecked | ||
List<Map<String, Map<String, Object>>> mappings = (List<Map<String, Map<String, Object>>>) JSONUtils.from(stream, new TypeToken<Map<String, Object>>(){}).get("mappings"); | ||
List<Map<String, Map<String, Object>>> mappings = (List<Map<String, Map<String, Object>>>) JSONUtils.from( | ||
stream, | ||
new TypeToken<Map<String, Object>>() {} | ||
).get("mappings"); | ||
solonovamax marked this conversation as resolved.
Show resolved
Hide resolved
|
||
mappings.forEach(mapping -> { | ||
JeBlockState jeState = createJeBlockState(mapping.get("java_state")); | ||
BlockState beState = createBeBlockState(mapping.get("bedrock_state")); | ||
|
@@ -141,12 +149,12 @@ private static boolean initBlockStateMapping() { | |
} | ||
|
||
private static boolean initJeBlockDefaultProperties() { | ||
try (InputStream stream = Mapping.class.getClassLoader().getResourceAsStream("je_block_default_states.json")) { | ||
if (stream == null) { | ||
try(InputStream stream = Mapping.class.getClassLoader().getResourceAsStream("je_block_default_states.json")) { | ||
if(stream == null) { | ||
TerraAllayPlugin.INSTANCE.getPluginLogger().error("je_block_default_states.json not found"); | ||
return false; | ||
} | ||
Map<String, Map<String, String>> states = JSONUtils.from(stream, new TypeToken<Map<String, Map<String, String>>>(){}); | ||
Map<String, Map<String, String>> states = JSONUtils.from(stream, new TypeToken<>() {}); | ||
solonovamax marked this conversation as resolved.
Show resolved
Hide resolved
|
||
for(Entry<String, Map<String, String>> entry : states.entrySet()) { | ||
String identifier = entry.getKey(); | ||
Map<String, String> properties = entry.getValue(); | ||
|
@@ -159,9 +167,8 @@ private static boolean initJeBlockDefaultProperties() { | |
} | ||
|
||
private static BlockState createBeBlockState(Map<String, Object> data) { | ||
Getter getter = BlockStateSafeGetter | ||
.name("minecraft:" + data.get("bedrock_identifier")); | ||
if (data.containsKey("state")) { | ||
Getter getter = BlockStateSafeGetter.name("minecraft:" + data.get("bedrock_identifier")); | ||
if(data.containsKey("state")) { | ||
// noinspection unchecked | ||
convertValueType((Map<String, Object>) data.get("state")).forEach(getter::property); | ||
} | ||
|
@@ -170,8 +177,8 @@ private static BlockState createBeBlockState(Map<String, Object> data) { | |
|
||
private static Map<String, Object> convertValueType(Map<String, Object> data) { | ||
TreeMap<String, Object> result = new TreeMap<>(); | ||
for (Entry<String, Object> entry : data.entrySet()) { | ||
if (entry.getValue() instanceof Number number) { | ||
for(Entry<String, Object> entry : data.entrySet()) { | ||
if(entry.getValue() instanceof Number number) { | ||
// Convert double to int because the number in json is double | ||
result.put(entry.getKey(), number.intValue()); | ||
} else { | ||
|
@@ -183,6 +190,7 @@ private static Map<String, Object> convertValueType(Map<String, Object> data) { | |
|
||
private static JeBlockState createJeBlockState(Map<String, Object> data) { | ||
// noinspection unchecked | ||
return JeBlockState.create((String) data.get("Name"), new TreeMap<>((Map<String, String>) data.getOrDefault("Properties", Map.of()))); | ||
return JeBlockState.create((String) data.get("Name"), | ||
new TreeMap<>((Map<String, String>) data.getOrDefault("Properties", Map.of()))); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why is this two lines instead of one? return JeBlockState.create(
(String) data.get("Name"),
new TreeMap<>((Map<String, String>) data.getOrDefault("Properties", Map.of()))
); (or whatever the code formatted with the editorconfig file applied is) |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
|
||
import com.dfsek.terra.api.world.biome.PlatformBiome; | ||
|
||
|
||
/** | ||
* @author daoge_cmd | ||
*/ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reformat code to remove this