mirror of
https://github.com/WiIIiam278/HuskSync.git
synced 2025-12-19 14:59:21 +00:00
feat: remove 1.20.1 support
This commit is contained in:
11
README.md
11
README.md
@@ -48,15 +48,16 @@ HuskSync supports the following [compatible versions](https://william278.net/doc
|
||||
|
||||
| Minecraft | Latest HuskSync | Java Version | Platforms | Support Status |
|
||||
|:---------------:|:---------------:|:------------:|:--------------|:------------------------------|
|
||||
| 1.21.7/8 | _latest_ | 21 | Paper | ✅ **Active Release** |
|
||||
| 1.21.10 | _latest_ | 21 | Paper | ✅ **Active Release** |
|
||||
| 1.21.7/8 | _latest_ | 21 | Paper | ✅ **August 2026** |
|
||||
| 1.21.6 | 3.8.5 | 21 | Paper | 🗃️ Archived (July 2025) |
|
||||
| 1.21.5 | _latest_ | 21 | Paper | ✅ **January 2026** (Non-LTS) |
|
||||
| 1.21.4 | _latest_ | 21 | Paper, Fabric | ✅ **November 2025** (Non-LTS) |
|
||||
| 1.21.5 | _latest_ | 21 | Paper | ✅ **February 2026** (Non-LTS) |
|
||||
| 1.21.4 | _latest_ | 21 | Paper, Fabric | ✅ **February 2026** (Non-LTS) |
|
||||
| 1.21.3 | 3.7.1 | 21 | Paper, Fabric | 🗃️ Archived (December 2024) |
|
||||
| 1.21.1 | _latest_ | 21 | Paper, Fabric | ✅ **November 2025** (LTS) |
|
||||
| 1.21.1 | _latest_ | 21 | Paper, Fabric | ✅ **May 2026** (LTS) |
|
||||
| 1.20.6 | 3.6.8 | 17 | Paper | 🗃️ Archived (October 2024) |
|
||||
| 1.20.4 | 3.6.8 | 17 | Paper | 🗃️ Archived (July 2024) |
|
||||
| 1.20.1 | _latest_ | 17 | Paper, Fabric | ✅ **November 2025** (LTS) |
|
||||
| 1.20.1 | 3.8.7 | 17 | Paper, Fabric | 🗃️ Archived (November 2024) |
|
||||
| 1.17.1 - 1.19.4 | 3.6.8 | 17 | Paper | 🗃️ Archived |
|
||||
| 1.16.5 | 3.2.1 | 16 | Paper | 🗃️ Archived |
|
||||
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
minecraft_version_range=1.20.1
|
||||
minecraft_version_numeric=12001
|
||||
minecraft_api_version=1.20
|
||||
paper_api_version=1.20.1-R0.1-SNAPSHOT
|
||||
@@ -38,11 +38,7 @@ import org.bukkit.attribute.AttributeModifier;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
//#if MC==12001
|
||||
//$$ import org.bukkit.inventory.EquipmentSlot;
|
||||
//#else
|
||||
import org.bukkit.inventory.EquipmentSlotGroup;
|
||||
//#endif
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.persistence.PersistentDataContainer;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
@@ -620,33 +616,19 @@ public abstract class BukkitData implements Data {
|
||||
instance.getBaseValue(),
|
||||
instance.getModifiers().stream()
|
||||
.filter(modifier -> !settings.isIgnoredModifier(modifier.getName()))
|
||||
//#if MC==12001
|
||||
//$$ .filter(modifier -> modifier.getSlot() == null)
|
||||
//#else
|
||||
.filter(modifier -> modifier.getSlotGroup() != EquipmentSlotGroup.ANY)
|
||||
//#endif
|
||||
.map(BukkitData.Attributes::adapt).collect(Collectors.toSet())
|
||||
);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static Modifier adapt(@NotNull AttributeModifier modifier) {
|
||||
//#if MC==12001
|
||||
//$$ return new Modifier(
|
||||
//$$ modifier.getUniqueId(),
|
||||
//$$ modifier.getName(),
|
||||
//$$ modifier.getAmount(),
|
||||
//$$ modifier.getOperation().ordinal(),
|
||||
//$$ modifier.getSlot() != null ? modifier.getSlot().ordinal() : -1
|
||||
//$$ );
|
||||
//#else
|
||||
return new Modifier(
|
||||
modifier.getKey().toString(),
|
||||
modifier.getAmount(),
|
||||
modifier.getOperation().ordinal(),
|
||||
modifier.getSlotGroup().toString()
|
||||
);
|
||||
//#endif
|
||||
}
|
||||
|
||||
private static void applyAttribute(@Nullable AttributeInstance instance, @Nullable Attribute attribute) {
|
||||
@@ -666,22 +648,12 @@ public abstract class BukkitData implements Data {
|
||||
|
||||
@NotNull
|
||||
private static AttributeModifier adapt(@NotNull Modifier modifier) {
|
||||
//#if MC==12001
|
||||
//$$ return new AttributeModifier(
|
||||
//$$ modifier.uuid(),
|
||||
//$$ modifier.name(),
|
||||
//$$ modifier.amount(),
|
||||
//$$ AttributeModifier.Operation.values()[modifier.operation()],
|
||||
//$$ modifier.equipmentSlot() != -1 ? EquipmentSlot.values()[modifier.equipmentSlot()] : null
|
||||
//$$ );
|
||||
//#else
|
||||
return new AttributeModifier(
|
||||
Objects.requireNonNull(NamespacedKey.fromString(modifier.name())),
|
||||
modifier.amount(),
|
||||
AttributeModifier.Operation.values()[modifier.operation()],
|
||||
Optional.ofNullable(EquipmentSlotGroup.getByName(modifier.slotGroup())).orElse(EquipmentSlotGroup.ANY)
|
||||
);
|
||||
//#endif
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -597,11 +597,7 @@ public interface BukkitMapHandler {
|
||||
final List<MapBanner> banners = Lists.newArrayList();
|
||||
for (int i = 0; i < getCursors().size(); i++) {
|
||||
final MapCursor cursor = getCursors().getCursor(i);
|
||||
//#if MC==12001
|
||||
//$$ final String type = cursor.getType().name().toLowerCase(Locale.ENGLISH);
|
||||
//#else
|
||||
final String type = cursor.getType().getKey().getKey();
|
||||
//#endif
|
||||
if (type.startsWith(BANNER_PREFIX)) {
|
||||
banners.add(new MapBanner(
|
||||
type.replaceAll(BANNER_PREFIX, ""),
|
||||
|
||||
@@ -51,11 +51,7 @@ public final class BukkitKeyedAdapter {
|
||||
|
||||
@Nullable
|
||||
public static PotionEffectType matchEffectType(@NotNull String key) {
|
||||
//#if MC==12001
|
||||
//$$ return PotionEffectType.getByName(key);
|
||||
//#else
|
||||
return getRegistryValue(Registry.EFFECT, key);
|
||||
//#endif
|
||||
}
|
||||
|
||||
private static <T extends Keyed> T getRegistryValue(@NotNull Registry<T> registry, @NotNull String keyString) {
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
essential.defaults.loom.mappings=net.fabricmc:yarn:1.20.1+build.10:v2
|
||||
|
||||
minecraft_version_range='1.20.1'
|
||||
|
||||
fabric_loader_version=0.15.11
|
||||
fabric_api_version=0.92.2+1.20.1
|
||||
fabric_permissions_api_version=0.2-SNAPSHOT
|
||||
fabric_adventure_platform_version=5.9.0
|
||||
fabric_sgui_version=1.2.2+1.20
|
||||
@@ -1,17 +0,0 @@
|
||||
{
|
||||
"required": true,
|
||||
"minVersion": "0.8",
|
||||
"package": "net.william278.husksync.mixins",
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"server": [
|
||||
"ItemEntityMixin",
|
||||
"PlayerEntityMixin",
|
||||
"ServerPlayerEntityMixin",
|
||||
"ServerPlayNetworkHandlerMixin",
|
||||
"ServerWorldMixin"
|
||||
],
|
||||
"client": [],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
}
|
||||
}
|
||||
@@ -7,11 +7,9 @@ preprocess {
|
||||
def fabric12105 = createNode("1.21.5", 12105, "yarn")
|
||||
def fabric12104 = createNode("1.21.4", 12104, "yarn")
|
||||
def fabric12101 = createNode("1.21.1", 12101, "yarn")
|
||||
def fabric12001 = createNode("1.20.1", 12001, "yarn")
|
||||
|
||||
strictExtraMappings.set(true)
|
||||
fabric12105.link(fabric12108, null)
|
||||
fabric12104.link(fabric12108, null)
|
||||
fabric12101.link(fabric12108, null)
|
||||
fabric12001.link(fabric12108, null)
|
||||
}
|
||||
@@ -26,12 +26,7 @@ import com.google.gson.annotations.SerializedName;
|
||||
import lombok.*;
|
||||
import net.minecraft.advancement.AdvancementProgress;
|
||||
import net.minecraft.advancement.PlayerAdvancementTracker;
|
||||
//#if MC==12001
|
||||
//$$ import net.minecraft.enchantment.EnchantmentHelper;
|
||||
//$$ import net.minecraft.nbt.NbtCompound;
|
||||
//#else
|
||||
import net.minecraft.component.DataComponentTypes;
|
||||
//#endif
|
||||
import net.minecraft.entity.attribute.EntityAttribute;
|
||||
import net.minecraft.entity.attribute.EntityAttributeInstance;
|
||||
import net.minecraft.entity.attribute.EntityAttributeModifier;
|
||||
@@ -95,16 +90,6 @@ public abstract class FabricData implements Data {
|
||||
stack.getItem().toString(),
|
||||
stack.getCount(),
|
||||
stack.getName().getString(),
|
||||
//#if MC==12001
|
||||
//$$ Optional.ofNullable(stack.getSubNbt(ItemStack.DISPLAY_KEY))
|
||||
//$$ .flatMap(display -> Optional.ofNullable(display.get(ItemStack.LORE_KEY))
|
||||
//$$ .map(lore -> ((List<String>) lore).stream().toList()))
|
||||
//$$ .orElse(null),
|
||||
//$$ stack.getEnchantments().stream()
|
||||
//$$ .map(element -> EnchantmentHelper.getIdFromNbt((NbtCompound) element))
|
||||
//$$ .filter(Objects::nonNull).map(Identifier::toString)
|
||||
//$$ .toList()
|
||||
//#else
|
||||
stack.getComponents().get(DataComponentTypes.LORE).lines().stream()
|
||||
.map(Text::getString)
|
||||
.toList(),
|
||||
@@ -112,7 +97,6 @@ public abstract class FabricData implements Data {
|
||||
.map(RegistryEntry::getIdAsString)
|
||||
.filter(Objects::nonNull)
|
||||
.toList()
|
||||
//#endif
|
||||
) : null)
|
||||
.toArray(Stack[]::new);
|
||||
}
|
||||
@@ -274,11 +258,7 @@ public abstract class FabricData implements Data {
|
||||
.map(effect -> {
|
||||
final StatusEffect type = matchEffectType(effect.type());
|
||||
return type != null ? new StatusEffectInstance(
|
||||
//#if MC==12001
|
||||
//$$ type,
|
||||
//#else
|
||||
RegistryEntry.of(type),
|
||||
//#endif
|
||||
effect.duration(),
|
||||
effect.amplifier(),
|
||||
effect.isAmbient(),
|
||||
@@ -300,16 +280,10 @@ public abstract class FabricData implements Data {
|
||||
@Override
|
||||
public void apply(@NotNull FabricUser user, @NotNull FabricHuskSync plugin) throws IllegalStateException {
|
||||
final ServerPlayerEntity player = user.getPlayer();
|
||||
//#if MC==12001
|
||||
//$$ final List<StatusEffect> effectsToRemove = player.getActiveStatusEffects().entrySet().stream()
|
||||
//$$ .filter(e -> !e.getValue().isAmbient()).map(Map.Entry::getKey).toList();
|
||||
//$$ effectsToRemove.forEach(player::removeStatusEffect);
|
||||
//#else
|
||||
//todo ambient check
|
||||
final List<StatusEffect> effectsToRemove = new ArrayList<>(player.getActiveStatusEffects().keySet().stream()
|
||||
.map(RegistryEntry::value).toList());
|
||||
effectsToRemove.forEach(effect -> player.removeStatusEffect(RegistryEntry.of(effect)));
|
||||
//#endif
|
||||
getEffects().forEach(player::addStatusEffect);
|
||||
}
|
||||
|
||||
@@ -319,11 +293,7 @@ public abstract class FabricData implements Data {
|
||||
public List<Effect> getActiveEffects() {
|
||||
return effects.stream()
|
||||
.map(potionEffect -> {
|
||||
//#if MC==12001
|
||||
//$$ final String key = getEffectId(potionEffect.getEffectType());
|
||||
//#else
|
||||
final String key = getEffectId(potionEffect.getEffectType().value());
|
||||
//#endif
|
||||
return key != null ? new Effect(
|
||||
key,
|
||||
potionEffect.getAmplifier(),
|
||||
@@ -357,21 +327,13 @@ public abstract class FabricData implements Data {
|
||||
|
||||
advancementProgress.getObtainedCriteria().forEach((criteria) -> awardedCriteria.put(
|
||||
criteria,
|
||||
//#if MC==12001
|
||||
//$$ advancementProgress.getEarliestProgressObtainDate()
|
||||
//#else
|
||||
Date.from(advancementProgress.getEarliestProgressObtainDate())
|
||||
//#endif
|
||||
));
|
||||
|
||||
// Only save the advancement if criteria has been completed
|
||||
if (!awardedCriteria.isEmpty()) {
|
||||
advancements.add(Advancement.adapt(
|
||||
//#if MC==12001
|
||||
//$$ advancementEntry.getId().toString(),
|
||||
//#else
|
||||
advancementEntry.id().asString(),
|
||||
//#endif
|
||||
awardedCriteria
|
||||
));
|
||||
}
|
||||
@@ -392,11 +354,7 @@ public abstract class FabricData implements Data {
|
||||
final AdvancementProgress progress = player.getAdvancementTracker().getProgress(advancementEntry);
|
||||
final Optional<Advancement> record = completed.stream()
|
||||
.filter(r -> r.getKey().equals(
|
||||
//#if MC==12001
|
||||
//$$ advancementEntry.getId().toString()
|
||||
//#else
|
||||
advancementEntry.id().asString()
|
||||
//#endif
|
||||
))
|
||||
.findFirst();
|
||||
if (record.isEmpty()) {
|
||||
@@ -414,11 +372,7 @@ public abstract class FabricData implements Data {
|
||||
}
|
||||
|
||||
private void setAdvancement(@NotNull FabricHuskSync plugin,
|
||||
//#if MC==12001
|
||||
//$$ @NotNull net.minecraft.advancement.Advancement advancementEntry,
|
||||
//#else
|
||||
@NotNull net.minecraft.advancement.AdvancementEntry advancementEntry,
|
||||
//#endif
|
||||
@NotNull ServerPlayerEntity player,
|
||||
@NotNull FabricUser user,
|
||||
@NotNull List<String> toAward,
|
||||
@@ -445,11 +399,7 @@ public abstract class FabricData implements Data {
|
||||
// Performs a consuming function for every advancement entry registered on the server
|
||||
private static void forEachAdvancementEntry(
|
||||
@NotNull MinecraftServer server,
|
||||
//#if MC==12001
|
||||
//$$ @NotNull ThrowingConsumer<net.minecraft.advancement.Advancement> con
|
||||
//#else
|
||||
@NotNull ThrowingConsumer<net.minecraft.advancement.AdvancementEntry> con
|
||||
//#endif
|
||||
) {
|
||||
server.getAdvancementLoader().getAdvancements().forEach(con);
|
||||
}
|
||||
@@ -482,11 +432,7 @@ public abstract class FabricData implements Data {
|
||||
|
||||
@NotNull
|
||||
public static FabricData.Location adapt(@NotNull ServerPlayerEntity player) {
|
||||
//#if MC==12001
|
||||
//$$ final String worldName = player.getWorld().getDimensionKey().getValue().toString();
|
||||
//#else
|
||||
final String worldName = player.getWorld().getDimensionEntry().getIdAsString();
|
||||
//#endif
|
||||
return from(
|
||||
player.getX(),
|
||||
player.getY(),
|
||||
@@ -659,21 +605,6 @@ public abstract class FabricData implements Data {
|
||||
final List<Attribute> attributes = Lists.newArrayList();
|
||||
final AttributeSettings settings = plugin.getSettings().getSynchronization().getAttributes();
|
||||
Registries.ATTRIBUTE.forEach(id -> {
|
||||
//#if MC==12001
|
||||
//$$ final EntityAttributeInstance instance = player.getAttributeInstance(id);
|
||||
//$$ final Identifier key = Registries.ATTRIBUTE.getId(id);
|
||||
//$$ if (instance == null || key == null || settings.isIgnoredAttribute(key.asString())) {
|
||||
//$$ return;
|
||||
//$$ }
|
||||
//$$ final Set<Modifier> modifiers = Sets.newHashSet();
|
||||
//$$ instance.getModifiers().forEach(modifier -> modifiers.add(new Modifier(
|
||||
//$$ modifier.getId(),
|
||||
//$$ modifier.getName(),
|
||||
//$$ modifier.getValue(),
|
||||
//$$ modifier.getOperation().getId(),
|
||||
//$$ -1
|
||||
//$$ )));
|
||||
//#else
|
||||
final EntityAttributeInstance instance = player.getAttributeInstance(RegistryEntry.of(id));
|
||||
final Identifier key = Registries.ATTRIBUTE.getId(id);
|
||||
if (instance == null || key == null || settings.isIgnoredAttribute(key.asString())) {
|
||||
@@ -686,7 +617,6 @@ public abstract class FabricData implements Data {
|
||||
modifier.operation().getId(),
|
||||
Modifier.ANY_EQUIPMENT_SLOT_GROUP
|
||||
)));
|
||||
//#endif
|
||||
attributes.add(new Attribute(
|
||||
key.toString(),
|
||||
instance.getBaseValue(),
|
||||
@@ -719,11 +649,7 @@ public abstract class FabricData implements Data {
|
||||
return;
|
||||
}
|
||||
applyAttribute(
|
||||
//#if MC==12001
|
||||
//$$ user.getPlayer().getAttributeInstance(id),
|
||||
//#else
|
||||
user.getPlayer().getAttributeInstance(RegistryEntry.of(id)),
|
||||
//#endif
|
||||
getAttribute(id).orElse(null)
|
||||
);
|
||||
});
|
||||
|
||||
@@ -26,9 +26,6 @@ import lombok.AccessLevel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import net.minecraft.datafixer.TypeReferences;
|
||||
import net.minecraft.item.ItemStack;
|
||||
//#if MC==12001
|
||||
//$$ import net.minecraft.nbt.NbtCompound;
|
||||
//#endif
|
||||
import net.minecraft.nbt.*;
|
||||
import net.minecraft.registry.DynamicRegistryManager;
|
||||
import net.william278.desertwell.util.Version;
|
||||
@@ -280,10 +277,6 @@ public abstract class FabricSerializer {
|
||||
//$$ return (NbtCompound) item.toNbt(reg);
|
||||
//#elseif MC==12101
|
||||
//$$ return (NbtCompound) item.encode(reg);
|
||||
//#elseif MC==12001
|
||||
//$$ final NbtCompound compound = new NbtCompound();
|
||||
//$$ item.writeNbt(compound);
|
||||
//$$ return compound;
|
||||
//#endif
|
||||
} catch (Throwable e) {
|
||||
return null;
|
||||
@@ -294,10 +287,8 @@ public abstract class FabricSerializer {
|
||||
private ItemStack decodeNbt(@NotNull NbtElement item, @NotNull DynamicRegistryManager reg) {
|
||||
//#if MC>=12108
|
||||
final @Nullable ItemStack stack = ItemStack.CODEC.decode(reg.getOps(NbtOps.INSTANCE), item).getOrThrow().getFirst();
|
||||
//#elseif MC>12001
|
||||
//#else
|
||||
//$$ final @Nullable ItemStack stack = ItemStack.fromNbt(reg, item).orElse(null);
|
||||
//#elseif MC==12001
|
||||
//$$ final @Nullable ItemStack stack = ItemStack.fromNbt((NbtCompound) item);
|
||||
//#endif
|
||||
if (stack == null) {
|
||||
throw new IllegalStateException("Failed to decode item NBT (decode got null): (%s)".formatted(item));
|
||||
|
||||
@@ -120,11 +120,7 @@ public interface FabricUserDataHolder extends UserDataHolder {
|
||||
@Override
|
||||
default Optional<Data.Items.EnderChest> getEnderChest() {
|
||||
return Optional.of(FabricData.Items.EnderChest.adapt(
|
||||
//#if MC==12001
|
||||
//$$ getPlayer().getEnderChestInventory().stacks
|
||||
//#else
|
||||
getPlayer().getEnderChestInventory().getHeldStacks()
|
||||
//#endif
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
@@ -82,13 +82,9 @@ public class PlayerEntityMixin {
|
||||
|
||||
@Unique
|
||||
private boolean hasVanishingCurse(@NotNull ItemStack stack) {
|
||||
//#if MC==12001
|
||||
//$$ return EnchantmentHelper.hasVanishingCurse(stack);
|
||||
//#else
|
||||
return EnchantmentHelper.hasAnyEnchantmentsIn(
|
||||
stack, TagKey.of(Enchantments.VANISHING_CURSE.getRegistryRef(), Enchantments.VANISHING_CURSE.getValue())
|
||||
);
|
||||
//#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -92,11 +92,7 @@ public abstract class ServerPlayNetworkHandlerMixin {
|
||||
|
||||
@Inject(method = "onCreativeInventoryAction", at = @At("HEAD"), cancellable = true)
|
||||
public void onCreativeInventoryAction(CreativeInventoryActionC2SPacket packet, CallbackInfo ci) {
|
||||
//#if MC==12001
|
||||
//$$ int slot = packet.getSlot();
|
||||
//#else
|
||||
int slot = packet.slot();
|
||||
//#endif
|
||||
if (slot < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user