mirror of
https://github.com/WiIIiam278/HuskSync.git
synced 2025-12-19 14:59:21 +00:00
feat: start 1.21.3
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
plugins {
|
||||
id 'fabric-loom' version '1.7-SNAPSHOT'
|
||||
id 'fabric-loom' version "$fabric_loom_version"
|
||||
}
|
||||
|
||||
apply plugin: 'fabric-loom'
|
||||
@@ -18,7 +18,7 @@ dependencies {
|
||||
modImplementation include("net.kyori:adventure-platform-fabric:${fabric_adventure_platform_version}")
|
||||
modImplementation include("me.lucko:fabric-permissions-api:${fabric_permissions_api_version}")
|
||||
modImplementation include("eu.pb4:sgui:${fabric_sgui_version}")
|
||||
modImplementation include('net.william278.uniform:uniform-fabric:1.2.1+1.20.1')
|
||||
modImplementation include('net.william278.uniform:uniform-fabric:1.2.2+1.21.3')
|
||||
modCompileOnly "net.fabricmc.fabric-api:fabric-api:${fabric_api_version}"
|
||||
|
||||
implementation include('org.apache.commons:commons-pool2:2.12.0')
|
||||
|
||||
@@ -32,7 +32,7 @@ import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.fabricmc.loader.api.ModContainer;
|
||||
import net.kyori.adventure.platform.AudienceProvider;
|
||||
import net.kyori.adventure.platform.fabric.FabricServerAudiences;
|
||||
import net.kyori.adventure.platform.modcommon.MinecraftServerAudiences;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.william278.desertwell.util.Version;
|
||||
import net.william278.husksync.adapter.DataAdapter;
|
||||
@@ -142,7 +142,7 @@ public class FabricHuskSync implements DedicatedServerModInitializer, HuskSync,
|
||||
|
||||
private void onEnable() {
|
||||
// Initial plugin setup
|
||||
this.audiences = FabricServerAudiences.of(minecraftServer);
|
||||
this.audiences = MinecraftServerAudiences.of(minecraftServer);
|
||||
|
||||
// Check compatibility
|
||||
checkCompatibility();
|
||||
|
||||
@@ -157,7 +157,7 @@ public abstract class FabricData implements Data {
|
||||
@Override
|
||||
public void apply(@NotNull FabricUser user, @NotNull FabricHuskSync plugin) throws IllegalStateException {
|
||||
final ServerPlayerEntity player = user.getPlayer();
|
||||
player.playerScreenHandler.clearCraftingSlots();
|
||||
player.playerScreenHandler.getCraftingInput().clear();
|
||||
player.currentScreenHandler.setCursorStack(ItemStack.EMPTY);
|
||||
final ItemStack[] items = getContents();
|
||||
for (int slot = 0; slot < player.getInventory().size(); slot++) {
|
||||
@@ -693,6 +693,7 @@ public abstract class FabricData implements Data {
|
||||
@NotNull
|
||||
public static FabricData.Hunger adapt(@NotNull ServerPlayerEntity player) {
|
||||
final HungerManager hunger = player.getHungerManager();
|
||||
// todo mixin for hunger
|
||||
return from(hunger.getFoodLevel(), hunger.getSaturationLevel(), hunger.getExhaustion());
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,6 @@ import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.TypedActionResult;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.hit.EntityHitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@@ -124,9 +123,9 @@ public class FabricEventListener extends EventListener implements LockedHandler
|
||||
return (cancelPlayerEvent(player.getUuid())) ? ActionResult.FAIL : ActionResult.PASS;
|
||||
}
|
||||
|
||||
private TypedActionResult<ItemStack> handleItemInteract(PlayerEntity player, World world, Hand hand) {
|
||||
private ActionResult handleItemInteract(PlayerEntity player, World world, Hand hand) {
|
||||
ItemStack stackInHand = player.getStackInHand(hand);
|
||||
return (cancelPlayerEvent(player.getUuid())) ? TypedActionResult.fail(stackInHand) : TypedActionResult.pass(stackInHand);
|
||||
return (cancelPlayerEvent(player.getUuid())) ? ActionResult.FAIL : ActionResult.PASS;
|
||||
}
|
||||
|
||||
private boolean handleBlockBreak(World world, PlayerEntity player, BlockPos blockPos, BlockState blockState, BlockEntity blockEntity) {
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package net.william278.husksync.mixins;
|
||||
|
||||
import net.minecraft.entity.player.HungerManager;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
@Mixin(HungerManager.class)
|
||||
public class HungerManagerMixin {
|
||||
|
||||
@Shadow
|
||||
private float exhaustion;
|
||||
|
||||
@Accessor("exhaustion")
|
||||
public void setExhaustion(float exhaustion) {
|
||||
this.exhaustion = exhaustion;
|
||||
}
|
||||
|
||||
@Accessor("exhaustion")
|
||||
public float getExhaustion() {
|
||||
return exhaustion;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -36,7 +36,7 @@ public class ServerWorldMixin {
|
||||
@Shadow
|
||||
private MinecraftServer server;
|
||||
|
||||
@Inject(method = "saveLevel", at = @At("HEAD"))
|
||||
@Inject(method = "savePersistentState", at = @At("HEAD"))
|
||||
public void saveLevel(CallbackInfo ci) {
|
||||
if (server.isStopping() || server.isStopped()) {
|
||||
return;
|
||||
|
||||
@@ -25,7 +25,7 @@ import eu.pb4.sgui.api.elements.GuiElementInterface;
|
||||
import eu.pb4.sgui.api.gui.SimpleGui;
|
||||
import me.lucko.fabric.api.permissions.v0.Permissions;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.platform.fabric.FabricServerAudiences;
|
||||
import net.kyori.adventure.platform.modcommon.MinecraftServerAudiences;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.screen.GenericContainerScreenHandler;
|
||||
import net.minecraft.screen.ScreenHandlerType;
|
||||
@@ -102,7 +102,7 @@ public class FabricUser extends OnlineUser implements FabricUserDataHolder {
|
||||
this.editable = editable;
|
||||
|
||||
// Set title, items
|
||||
this.setTitle(((FabricServerAudiences) plugin.getAudiences()).toNative(title.toComponent()));
|
||||
this.setTitle(((MinecraftServerAudiences) plugin.getAudiences()).asNative(title.toComponent()));
|
||||
this.setLockPlayerInventory(!editable);
|
||||
for (int i = 0; i < size; i++) {
|
||||
final ItemStack item = items.getContents()[i];
|
||||
|
||||
@@ -8,7 +8,8 @@
|
||||
"PlayerEntityMixin",
|
||||
"ServerPlayerEntityMixin",
|
||||
"ServerPlayNetworkHandlerMixin",
|
||||
"ServerWorldMixin"
|
||||
"ServerWorldMixin",
|
||||
"HungerManagerMixin"
|
||||
],
|
||||
"client": [],
|
||||
"injectors": {
|
||||
|
||||
Reference in New Issue
Block a user