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:
@@ -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