Skip to content

Commit

Permalink
Setup Warnings for when MinecraftDataVersion is > 100 SchemaID's abov…
Browse files Browse the repository at this point in the history
…e current Game Version
  • Loading branch information
sakura-ryoko committed Jan 16, 2025
1 parent dada014 commit b0f0dd4
Show file tree
Hide file tree
Showing 16 changed files with 67 additions and 47 deletions.
27 changes: 3 additions & 24 deletions src/main/java/fi/dy/masa/litematica/data/EntitiesDataStorage.java
Original file line number Diff line number Diff line change
Expand Up @@ -973,14 +973,7 @@ public BlockEntity handleBlockEntityData(BlockPos pos, NbtCompound nbt, @Nullabl

synchronized (this.blockEntityCache)
{
if (this.blockEntityCache.containsKey(pos))
{
this.blockEntityCache.replace(pos, Pair.of(System.currentTimeMillis(), Pair.of(blockEntity, nbt)));
}
else
{
this.blockEntityCache.put(pos, Pair.of(System.currentTimeMillis(), Pair.of(blockEntity, nbt)));
}
this.blockEntityCache.put(pos, Pair.of(System.currentTimeMillis(), Pair.of(blockEntity, nbt)));
}

blockEntity.read(nbt, this.getClientWorld().getRegistryManager());
Expand Down Expand Up @@ -1017,14 +1010,7 @@ public BlockEntity handleBlockEntityData(BlockPos pos, NbtCompound nbt, @Nullabl
}
synchronized (this.blockEntityCache)
{
if (this.blockEntityCache.containsKey(pos))
{
this.blockEntityCache.replace(pos, Pair.of(System.currentTimeMillis(), Pair.of(blockEntity2, nbt)));
}
else
{
this.blockEntityCache.put(pos, Pair.of(System.currentTimeMillis(), Pair.of(blockEntity2, nbt)));
}
this.blockEntityCache.put(pos, Pair.of(System.currentTimeMillis(), Pair.of(blockEntity2, nbt)));
}

if (Configs.Generic.ENTITY_DATA_LOAD_NBT.getBooleanValue())
Expand Down Expand Up @@ -1069,14 +1055,7 @@ public Entity handleEntityData(int entityId, NbtCompound nbt)
}
synchronized (this.entityCache)
{
if (this.entityCache.containsKey(entityId))
{
this.entityCache.replace(entityId, Pair.of(System.currentTimeMillis(), Pair.of(entity, nbt)));
}
else
{
this.entityCache.put(entityId, Pair.of(System.currentTimeMillis(), Pair.of(entity, nbt)));
}
this.entityCache.put(entityId, Pair.of(System.currentTimeMillis(), Pair.of(entity, nbt)));
}

if (Configs.Generic.ENTITY_DATA_LOAD_NBT.getBooleanValue())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,14 @@ protected void drawSelectedSchematicInfo(@Nullable DirectoryEntry entry, DrawCon

if (schema != null)
{
str = StringUtils.translate("litematica.gui.label.schematic_info.schema", schema.getString(), version.minecraftDataVersion());
if (version.minecraftDataVersion() - LitematicaSchematic.MINECRAFT_DATA_VERSION > 100)
{
str = StringUtils.translate("litematica.gui.label.schematic_info.schema.newer", schema.getString(), version.minecraftDataVersion());
}
else
{
str = StringUtils.translate("litematica.gui.label.schematic_info.schema", schema.getString(), version.minecraftDataVersion());
}
this.drawString(drawContext, str, x, y, textColor);
y += 12;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1251,7 +1251,7 @@ private boolean readFromNBT(NbtCompound nbt)

if (version >= 1 && version <= SCHEMATIC_VERSION)
{
if (minecraftDataVersion > this.MINECRAFT_DATA_VERSION)
if (minecraftDataVersion - this.MINECRAFT_DATA_VERSION > 100)
{
InfoUtils.showGuiOrInGameMessage(MessageType.WARNING, "litematica.error.schematic_load.newer_minecraft_version", minecraftDataVersion, this.MINECRAFT_DATA_VERSION);
}
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/fi/dy/masa/litematica/util/DataFixerMode.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
public enum DataFixerMode implements IConfigOptionListEntry
{
ALWAYS ("always", "litematica.gui.label.data_fixer_mode.always"),
//BELOW_1215 ("below_1215", "litematica.gui.label.data_fixer_mode.below_1215"),
BELOW_1205 ("below_1205", "litematica.gui.label.data_fixer_mode.below_1205"),
BELOW_120X ("below_120X", "litematica.gui.label.data_fixer_mode.below_120X"),
BELOW_119X ("below_119X", "litematica.gui.label.data_fixer_mode.below_119X"),
Expand Down Expand Up @@ -93,6 +94,18 @@ public static Schema getEffectiveSchema(int dataVersion)
switch (config)
{
case ALWAYS -> { return schema; }
// FIXME 1.21.5+
/*
case BELOW_1215 ->
{
if (dataVersion < Schema.SCHEMA_1_21_05.getDataVersion())
{
return schema;
}
return null;
}
*/
case BELOW_1205 ->
{
if (dataVersion < Schema.SCHEMA_1_20_05.getDataVersion())
Expand Down
1 change: 1 addition & 0 deletions src/main/java/fi/dy/masa/litematica/util/EntityUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ public static void loadNbtIntoEntity(Entity entity, NbtCompound nbt)
}
}

@Deprecated
private static void readLeashableEntityCustomData(Entity entity, NbtCompound nbt)
{
MinecraftClient mc = MinecraftClient.getInstance();
Expand Down
24 changes: 13 additions & 11 deletions src/main/java/fi/dy/masa/litematica/util/InventoryUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
import fi.dy.masa.litematica.data.EntitiesDataStorage;
import fi.dy.masa.litematica.world.WorldSchematic;

import org.jetbrains.annotations.ApiStatus;

public class InventoryUtils
{
private static final List<Integer> PICK_BLOCKABLE_SLOTS = new ArrayList<>();
Expand Down Expand Up @@ -507,23 +509,23 @@ public static String convertItemNbtToString(NbtCompound nbt)
* @param threshold the number of items at or below which the re-stocking will happen
* @param allowHotbar whether to allow taking items from other hotbar slots
*/
@Experimental
public static void PRW_preRestockHand(PlayerEntity player,
Hand hand,
int threshold,
boolean allowHotbar)
@ApiStatus.Experimental
public static void preRestockHand(PlayerEntity player,
Hand hand,
int threshold,
boolean allowHotbar)
{
PlayerInventory container = player.getInventory();
final ItemStack handStack = player.getStackInHand(hand);
final int count = handStack.getCount();
final int max = handStack.getMaxCount();

if (handStack.isEmpty() == false &&
PRW_getCursorStack().isEmpty() &&
getCursorStack().isEmpty() &&
(count <= threshold && count < max))
{
int endSlot = allowHotbar ? 44 : 35;
int currentMainHandSlot = PRW_getSelectedHotbarSlot() + 36;
int currentMainHandSlot = getSelectedHotbarSlot() + 36;
int currentSlot = hand == Hand.MAIN_HAND ? currentMainHandSlot : 45;

for (int slotNum = 9; slotNum <= endSlot; ++slotNum)
Expand Down Expand Up @@ -557,8 +559,8 @@ public static void PRW_preRestockHand(PlayerEntity player,
}
}

@Experimental
public static ItemStack PRW_getCursorStack()
@ApiStatus.Experimental
public static ItemStack getCursorStack()
{
PlayerEntity player = MinecraftClient.getInstance().player;
if (player == null)
Expand All @@ -569,8 +571,8 @@ public static ItemStack PRW_getCursorStack()
return inv != null ? inv.getMainHandStack() : ItemStack.EMPTY;
}

@Experimental
public static int PRW_getSelectedHotbarSlot()
@ApiStatus.Experimental
public static int getSelectedHotbarSlot()
{
PlayerEntity player = MinecraftClient.getInstance().player;
if (player == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public static Hand doPickBlockForStack(ItemStack stack)

if (hand != null)
{
InventoryUtils.PRW_preRestockHand(player, hand, 6, true);
InventoryUtils.preRestockHand(player, hand, 6, true);
}

return hand;
Expand Down
4 changes: 3 additions & 1 deletion src/main/resources/assets/litematica/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@
"litematica.error.schematic.create.no_selections": "No valid selection regions!",

"litematica.error.schematic_load.cant_read_file": "Can't read the schematic file '%s' (doesn't exist or permission issue)",
"litematica.error.schematic_load.newer_minecraft_version": "WARNING! Schematic is from a future version of Minecraft: '%d' > '%d'\nAny NBT data may be at risk of corruption.",
"litematica.error.schematic_load.newer_minecraft_version": "Schematic is from a future version of Minecraft: '%d' > '%d'\nSome NBT data may be at risk of corruption.",
"litematica.error.schematic_load.no_schematic_selected": "No Schematic file selected!",
"litematica.error.schematic_load.no_schematic_version_information": "The schematic doesn't have version information, and can't be safely loaded!",
"litematica.error.schematic_load.unsupported_schematic_version": "Unsupported or future schematic version '%d'",
Expand Down Expand Up @@ -712,6 +712,7 @@
"litematica.gui.label.easy_place_protocol.v3": "Version 3",

"litematica.gui.label.data_fixer_mode.always": "Always",
"litematica.gui.label.data_fixer_mode.below_1215": "Below 1.21.5 Only",
"litematica.gui.label.data_fixer_mode.below_1205": "Below 1.20.5 Only",
"litematica.gui.label.data_fixer_mode.below_120X": "Below 1.20.x Only",
"litematica.gui.label.data_fixer_mode.below_119X": "Below 1.19.x Only",
Expand Down Expand Up @@ -778,6 +779,7 @@
"litematica.gui.label.schematic_info.sponge_version": "Sponge Version: §f%d§r",
"litematica.gui.label.schematic_info.vanilla_version": "Vanilla Structure",
"litematica.gui.label.schematic_info.schema": "Minecraft: §f%s§r [Schema §f%d§r]",
"litematica.gui.label.schematic_info.schema.newer": "Minecraft: §c%s§r [Schema §c%d§r]",

"litematica.gui.label.schematic_load.checkbox.create_placement": "Create a placement",
"litematica.gui.label.schematic_load.hoverinfo.create_placement": "Immediately create a new placement\nand select that placement",
Expand Down
4 changes: 3 additions & 1 deletion src/main/resources/assets/litematica/lang/es_es.json
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@
"litematica.error.schematic_conversion.structure_to_litematica_failed": "Error al convertir la Estructura a un Esquema de Litematica",
"litematica.error.schematic.create.no_selections": "¡No hay regiones de selección válidas!",
"litematica.error.schematic_load.cant_read_file": "No se puede leer el archivo de esquema '%s' (no existe o problema de permisos)",
"litematica.error.schematic_load.newer_minecraft_version": "WARNING! Schematic is from a future version of Minecraft: '%d' > '%d'\nAny NBT data may be at risk of corruption.",
"litematica.error.schematic_load.newer_minecraft_version": "Schematic is from a future version of Minecraft: '%d' > '%d'\nSome NBT data may be at risk of corruption.",
"litematica.error.schematic_load.no_schematic_selected": "¡No se seleccionó ningún archivo de esquema!",
"litematica.error.schematic_load.no_schematic_version_information": "El esquema no tiene información de versión, ¡y no se puede cargar de forma segura!",
"litematica.error.schematic_load.unsupported_schematic_version": "Versión de esquema no compatible o futura '%d'",
Expand Down Expand Up @@ -663,6 +663,7 @@
"litematica.gui.label.easy_place_protocol.v2": "Versión 2",
"litematica.gui.label.easy_place_protocol.v3": "Versión 3",
"litematica.gui.label.data_fixer_mode.always": "Siempre",
"litematica.gui.label.data_fixer_mode.below_1215": "Below 1.21.5 Only",
"litematica.gui.label.data_fixer_mode.below_1205": "Solo por debajo de 1.20.5",
"litematica.gui.label.data_fixer_mode.below_120X": "Solo por debajo de 1.20.x",
"litematica.gui.label.data_fixer_mode.below_119X": "Solo por debajo de 1.19.x",
Expand Down Expand Up @@ -718,6 +719,7 @@
"litematica.gui.label.schematic_info.sponge_version": "Sponge Version: §f%d§r",
"litematica.gui.label.schematic_info.vanilla_version": "Vanilla Structure",
"litematica.gui.label.schematic_info.schema": "Minecraft: §f%s§r [Schema §f%d§r]",
"litematica.gui.label.schematic_info.schema.newer": "Minecraft: §c%s§r [Schema §c%d§r]",
"litematica.gui.label.schematic_load.checkbox.create_placement": "Crear una colocación",
"litematica.gui.label.schematic_load.hoverinfo.create_placement": "Crear inmediatamente una nueva colocación\ny seleccionar esa colocación",
"litematica.gui.label.schematic_placement.enclosing_size": "Tamaño de Encierro: %s",
Expand Down
4 changes: 3 additions & 1 deletion src/main/resources/assets/litematica/lang/it_it.json
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@
"litematica.error.schematic_conversion.structure_to_litematica_failed": "Impossibile convertire la Struttura in uno Schema Litematica",
"litematica.error.schematic.create.no_selections": "Nessuna regione di selezione valida!",
"litematica.error.schematic_load.cant_read_file": "Impossibile leggere il file dello schema '%s' (non esiste o problema di permessi)",
"litematica.error.schematic_load.newer_minecraft_version": "WARNING! Schematic is from a future version of Minecraft: '%d' > '%d'\nAny NBT data may be at risk of corruption.",
"litematica.error.schematic_load.newer_minecraft_version": "Schematic is from a future version of Minecraft: '%d' > '%d'\nSome NBT data may be at risk of corruption.",
"litematica.error.schematic_load.no_schematic_selected": "Nessun file schema selezionato!",
"litematica.error.schematic_load.no_schematic_version_information": "Lo schema non ha informazioni sulla versione e non può essere caricata in modo sicuro!",
"litematica.error.schematic_load.unsupported_schematic_version": "Versione dello schema non supportata o futura '%d'",
Expand Down Expand Up @@ -663,6 +663,7 @@
"litematica.gui.label.easy_place_protocol.v2": "Versione 2",
"litematica.gui.label.easy_place_protocol.v3": "Versione 3",
"litematica.gui.label.data_fixer_mode.always": "Sempre",
"litematica.gui.label.data_fixer_mode.below_1215": "Below 1.21.5 Only",
"litematica.gui.label.data_fixer_mode.below_1205": "Solo sotto la 1.20.5",
"litematica.gui.label.data_fixer_mode.below_120X": "Solo sotto la 1.20.x",
"litematica.gui.label.data_fixer_mode.below_119X": "Solo sotto la 1.19.x",
Expand Down Expand Up @@ -718,6 +719,7 @@
"litematica.gui.label.schematic_info.sponge_version": "Sponge Version: §f%d§r",
"litematica.gui.label.schematic_info.vanilla_version": "Vanilla Structure",
"litematica.gui.label.schematic_info.schema": "Minecraft: §f%s§r [Schema §f%d§r]",
"litematica.gui.label.schematic_info.schema.newer": "Minecraft: §c%s§r [Schema §c%d§r]",
"litematica.gui.label.schematic_load.checkbox.create_placement": "Crea una posizione",
"litematica.gui.label.schematic_load.hoverinfo.create_placement": "Crea immediatamente una nuova posizione\ned è selezionata quella posizione",
"litematica.gui.label.schematic_placement.enclosing_size": "Dimensioni complessive: %s",
Expand Down
4 changes: 3 additions & 1 deletion src/main/resources/assets/litematica/lang/ja_jp.json
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@
"litematica.error.schematic_conversion.structure_to_litematica_failed": "構造を Litematica スキーマティックに変換できませんでした",
"litematica.error.schematic.create.no_selections": "有効な選択範囲がありません!",
"litematica.error.schematic_load.cant_read_file": "スキーマティックファイル '%s' を読み取れません(存在しないか、アクセス権の問題)",
"litematica.error.schematic_load.newer_minecraft_version": "WARNING! Schematic is from a future version of Minecraft: '%d' > '%d'\nAny NBT data may be at risk of corruption.",
"litematica.error.schematic_load.newer_minecraft_version": "Schematic is from a future version of Minecraft: '%d' > '%d'\nSome NBT data may be at risk of corruption.",
"litematica.error.schematic_load.no_schematic_selected": "スキーマティックファイルが選択されていません!",
"litematica.error.schematic_load.no_schematic_version_information": "スキーマティックにはバージョン情報がなく、安全に読み込むことができません!",
"litematica.error.schematic_load.unsupported_schematic_version": "サポートされていない、または将来のスキーマティックバージョン '%d'",
Expand Down Expand Up @@ -663,6 +663,7 @@
"litematica.gui.label.easy_place_protocol.v2": "Version 2",
"litematica.gui.label.easy_place_protocol.v3": "Version 3",
"litematica.gui.label.data_fixer_mode.always": "Always",
"litematica.gui.label.data_fixer_mode.below_1215": "Below 1.21.5 Only",
"litematica.gui.label.data_fixer_mode.below_1205": "Below 1.20.5 Only",
"litematica.gui.label.data_fixer_mode.below_120X": "Below 1.20.x Only",
"litematica.gui.label.data_fixer_mode.below_119X": "Below 1.19.x Only",
Expand Down Expand Up @@ -718,6 +719,7 @@
"litematica.gui.label.schematic_info.sponge_version": "Sponge Version: §f%d§r",
"litematica.gui.label.schematic_info.vanilla_version": "Vanilla Structure",
"litematica.gui.label.schematic_info.schema": "Minecraft: §f%s§r [Schema §f%d§r]",
"litematica.gui.label.schematic_info.schema.newer": "Minecraft: §c%s§r [Schema §c%d§r]",
"litematica.gui.label.schematic_load.checkbox.create_placement": "配置を作成",
"litematica.gui.label.schematic_load.hoverinfo.create_placement": "新しい配置をすぐに作成し、その配置を選択します",
"litematica.gui.label.schematic_placement.enclosing_size": "囲むサイズ: %s",
Expand Down
4 changes: 3 additions & 1 deletion src/main/resources/assets/litematica/lang/ko_kr.json
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@
"litematica.error.schematic_conversion.structure_to_litematica_failed": "구조물을 라이트메티카 스키메틱으로 변환하는 데에 실패했습니다.",
"litematica.error.schematic.create.no_selections": "유효한 선택 지역이 없습니다!",
"litematica.error.schematic_load.cant_read_file": "스키메틱 파일을 읽을 수 없습니다. '%s' (존재하지 않거나 권한이 없습니다.)",
"litematica.error.schematic_load.newer_minecraft_version": "WARNING! Schematic is from a future version of Minecraft: '%d' > '%d'\nAny NBT data may be at risk of corruption.",
"litematica.error.schematic_load.newer_minecraft_version": "Schematic is from a future version of Minecraft: '%d' > '%d'\nSome NBT data may be at risk of corruption.",
"litematica.error.schematic_load.no_schematic_selected": "선택된 스키메틱 파일이 없습니다!",
"litematica.error.schematic_load.no_schematic_version_information": "스키메틱에 버전 정보가 없으므로, 안전하게 불러올 수 없습니다!",
"litematica.error.schematic_load.unsupported_schematic_version": "미지원 또는 추후 스키메틱 버전입니다. '%d'",
Expand Down Expand Up @@ -663,6 +663,7 @@
"litematica.gui.label.easy_place_protocol.v2": "버전 2",
"litematica.gui.label.easy_place_protocol.v3": "버전 3",
"litematica.gui.label.data_fixer_mode.always": "언제나",
"litematica.gui.label.data_fixer_mode.below_1215": "Below 1.21.5 Only",
"litematica.gui.label.data_fixer_mode.below_1205": "1.20.5 이하 전용",
"litematica.gui.label.data_fixer_mode.below_120X": "1.20.x 이하 전용",
"litematica.gui.label.data_fixer_mode.below_119X": "1.19.x 이하 전용",
Expand Down Expand Up @@ -718,6 +719,7 @@
"litematica.gui.label.schematic_info.sponge_version": "Sponge 버전: §f%d§r",
"litematica.gui.label.schematic_info.vanilla_version": "바닐라 구조물",
"litematica.gui.label.schematic_info.schema": "마인크래프트: §f%s§r [스키마 §f%d§r]",
"litematica.gui.label.schematic_info.schema.newer": "Minecraft: §c%s§r [Schema §c%d§r]",
"litematica.gui.label.schematic_load.checkbox.create_placement": "배치 생성",
"litematica.gui.label.schematic_load.hoverinfo.create_placement": "즉시 새 배치를 생성하고\n해당 배치를 선택합니다.",
"litematica.gui.label.schematic_placement.enclosing_size": "인클로징 크기: %s",
Expand Down
Loading

0 comments on commit b0f0dd4

Please sign in to comment.