Skip to content

Commit

Permalink
Update to 1.21
Browse files Browse the repository at this point in the history
(cherry picked from commit 34582ce)
  • Loading branch information
Spottedleaf authored and mworzala committed Jun 15, 2024
1 parent 79f85fe commit 4a6df4b
Show file tree
Hide file tree
Showing 10 changed files with 359 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,11 @@ public final class MCVersionRegistry {
3820,
3825,
3828,
3833
// All up to 1.20.6
3833,
3939,
3943,
3945
// All up to 1.21
};
List<Integer> converterVersions = new ArrayList<>(mcConverterVersions.length);
for (final int version : mcConverterVersions) {
Expand Down Expand Up @@ -292,6 +295,9 @@ public final class MCVersionRegistry {
// Too much changed in this version.
registerBreakpoint(MCVersions.V24W07A + 1, 5);
registerBreakpointAfter(MCVersions.V24W07A + 1, Integer.MAX_VALUE);

// final release of major version
registerBreakpointAfter(MCVersions.V1_20_6, Integer.MAX_VALUE);
}

static {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,18 @@ public final class MCVersions {
public static final int V1_20_5 = 3837;
public static final int V1_20_6_RC1 = 3838;
public static final int V1_20_6 = 3839;
public static final int V2418WA = 3940;
public static final int V2419WA = 3941;
public static final int V2419WB = 3942;
public static final int V2420WA = 3944;
public static final int V2421WA = 3946;
public static final int V2421WB = 3947;
public static final int V_1_21_PRE1 = 3948;
public static final int V_1_21_PRE2 = 3949;
public static final int V_1_21_PRE3 = 3950;
public static final int V_1_21_PRE4 = 3951;
public static final int V_1_21_RC1 = 3952;
public static final int V_1_21 = 3953;

private MCVersions() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import ca.spottedleaf.dataconverter.converters.DataConverter;
import ca.spottedleaf.dataconverter.minecraft.converters.helpers.RenameHelper;
import ca.spottedleaf.dataconverter.types.MapType;
import ca.spottedleaf.dataconverter.util.NamespaceUtil;
import java.util.function.Function;

public final class ConverterEnchantmentsRename extends DataConverter<MapType<String>, MapType<String>> {
Expand All @@ -16,7 +17,9 @@ public ConverterEnchantmentsRename(final int toVersion, final Function<String, S
public ConverterEnchantmentsRename(final int toVersion, final int versionStep, final Function<String, String> renamer) {
super(toVersion, versionStep);

this.renamer = renamer;
this.renamer = (final String input) -> {
return renamer.apply(NamespaceUtil.correctNamespace(input));
};
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -527,12 +527,13 @@ private static void convertAttributes(final TransientItemStack item, final TypeU
}
}

final boolean hideModifiers = (flags & TOOLTIP_FLAG_HIDE_MODIFIERS) != 0;
if (newAttributes.size() > 0 || hideModifiers) {
if (newAttributes.size() > 0) {
final MapType<String> newModifiers = type.createEmptyMap();
item.componentSetMap("minecraft:attribute_modifiers", newModifiers);

newModifiers.setList("modifiers", newAttributes);

final boolean hideModifiers = (flags & TOOLTIP_FLAG_HIDE_MODIFIERS) != 0;
if (hideModifiers) {
newModifiers.setBoolean("show_in_tooltip", false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,11 @@ private static void registerAll() {
V3825.register();
V3828.register();
V3833.register();
// V1.21
V3938.register();
V3939.register();
V3943.register();
V3945.register();
}

private MCTypeRegistry() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ public MapType<String> walk(final MapType<String> root, final long fromVersion,
WalkerUtils.convertListPath(MCTypeRegistry.ITEM_STACK, root, "minecraft:container", "item", fromVersion, toVersion);
WalkerUtils.convert(MCTypeRegistry.ENTITY, root, "minecraft:entity_data", fromVersion, toVersion);
WalkerUtils.convertList(MCTypeRegistry.ITEM_NAME, root, "minecraft:pot_decorations", fromVersion, toVersion);
WalkerUtils.convert(MCTypeRegistry.ITEM_STACK, root.getMap("minecraft:food"), "using_converts_to", fromVersion, toVersion);

return null;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package ca.spottedleaf.dataconverter.minecraft.versions;

import ca.spottedleaf.dataconverter.minecraft.MCVersions;
import ca.spottedleaf.dataconverter.minecraft.datatypes.MCTypeRegistry;
import ca.spottedleaf.dataconverter.minecraft.walkers.generic.DataWalkerTypePaths;
import ca.spottedleaf.dataconverter.minecraft.walkers.itemstack.DataWalkerItems;

public final class V3938 {

private static final int VERSION = MCVersions.V1_20_6 + 99;

private static void registerArrow(final String id) {
MCTypeRegistry.ENTITY.addWalker(VERSION, id, new DataWalkerTypePaths<>(MCTypeRegistry.BLOCK_STATE, "inBlockState"));
// new: weapon
MCTypeRegistry.ENTITY.addWalker(VERSION, id, new DataWalkerItems("item", "weapon"));
}

public static void register() {
registerArrow("minecraft:spectral_arrow");
registerArrow("minecraft:arrow");
}

private V3938() {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package ca.spottedleaf.dataconverter.minecraft.versions;

import ca.spottedleaf.dataconverter.minecraft.MCVersions;
import ca.spottedleaf.dataconverter.minecraft.converters.leveldat.ConverterRemoveFeatureFlag;
import ca.spottedleaf.dataconverter.minecraft.datatypes.MCTypeRegistry;
import java.util.Arrays;
import java.util.HashSet;

public final class V3939 {

private static final int VERSION = MCVersions.V1_20_6 + 100;

public static void register() {
MCTypeRegistry.LEVEL.addStructureConverter(new ConverterRemoveFeatureFlag(VERSION, new HashSet<>(
Arrays.asList(
"minecraft:update_1_21"
)
)));
}

private V3939() {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package ca.spottedleaf.dataconverter.minecraft.versions;

import ca.spottedleaf.dataconverter.converters.DataConverter;
import ca.spottedleaf.dataconverter.minecraft.MCVersions;
import ca.spottedleaf.dataconverter.minecraft.datatypes.MCTypeRegistry;
import ca.spottedleaf.dataconverter.types.MapType;

public final class V3943 {

private static final int VERSION = MCVersions.V2419WB + 1;

public static void register() {
MCTypeRegistry.OPTIONS.addStructureConverter(new DataConverter<>(VERSION) {
@Override
public MapType<String> convert(final MapType<String> data, final long sourceVersion, final long toVersion) {
final String oldRange = data.getString("menuBackgroundBlurriness", "0.5");

int newRange;
try {
newRange = (int)Math.round(Double.parseDouble(oldRange) * 10.0);
} catch (final NumberFormatException ex) {
newRange = 5;
}

// note: options are always string, so DFU is wrong to use int
data.setString("menuBackgroundBlurriness", Integer.toString(newRange));

return null;
}
});
}

private V3943() {}
}
Loading

0 comments on commit 4a6df4b

Please sign in to comment.