mirror of
https://github.com/WiIIiam278/HuskSync.git
synced 2025-12-19 14:59:21 +00:00
build: target Minecraft 1.21.3
This commit is contained in:
@@ -49,6 +49,7 @@ import net.william278.husksync.FabricHuskSync;
|
||||
import net.william278.husksync.HuskSync;
|
||||
import net.william278.husksync.adapter.Adaptable;
|
||||
import net.william278.husksync.config.Settings.SynchronizationSettings.AttributeSettings;
|
||||
import net.william278.husksync.mixins.HungerManagerMixin;
|
||||
import net.william278.husksync.user.FabricUser;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -693,8 +694,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());
|
||||
return from(hunger.getFoodLevel(), hunger.getSaturationLevel(), ((HungerManagerMixin) hunger).getExhaustion());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -708,7 +708,7 @@ public abstract class FabricData implements Data {
|
||||
final HungerManager hunger = player.getHungerManager();
|
||||
hunger.setFoodLevel(foodLevel);
|
||||
hunger.setSaturationLevel(saturation);
|
||||
hunger.setExhaustion(exhaustion);
|
||||
((HungerManagerMixin) hunger).setExhaustion(exhaustion);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -148,10 +148,11 @@ public abstract class FabricSerializer {
|
||||
int VERSION1_19_2 = 3120;
|
||||
int VERSION1_19_4 = 3337;
|
||||
int VERSION1_20_1 = 3465;
|
||||
int VERSION1_20_2 = 3578; // Future
|
||||
int VERSION1_20_4 = 3700; // Future
|
||||
int VERSION1_20_5 = 3837; // Future
|
||||
int VERSION1_21 = 3953; // Future
|
||||
int VERSION1_20_2 = 3578;
|
||||
int VERSION1_20_4 = 3700;
|
||||
int VERSION1_20_5 = 3837;
|
||||
int VERSION1_21_1 = 3955;
|
||||
int VERSION1_21_3 = 4082; // Current
|
||||
|
||||
@NotNull
|
||||
default ItemStack[] getItems(@NotNull NbtCompound tag, @NotNull Version mcVersion, @NotNull FabricHuskSync plugin) {
|
||||
@@ -186,7 +187,7 @@ public abstract class FabricSerializer {
|
||||
if (item == null || item.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
NbtCompound entry = (NbtCompound) item.encode(registryManager);
|
||||
NbtCompound entry = (NbtCompound) item.toNbt(registryManager);
|
||||
entry.putInt("Slot", i);
|
||||
itemList.add(entry);
|
||||
}
|
||||
@@ -213,7 +214,6 @@ public abstract class FabricSerializer {
|
||||
return itemStacks;
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
@SuppressWarnings({"rawtypes", "unchecked"}) // For NBTOps lookup
|
||||
private NbtCompound upgradeItemData(@NotNull NbtCompound tag, @NotNull Version mcVersion,
|
||||
@@ -232,11 +232,12 @@ public abstract class FabricSerializer {
|
||||
case "1.19", "1.19.1", "1.19.2" -> VERSION1_19_2;
|
||||
case "1.19.4" -> VERSION1_19_4;
|
||||
case "1.20", "1.20.1" -> VERSION1_20_1;
|
||||
case "1.20.2" -> VERSION1_20_2; // Future
|
||||
case "1.20.4" -> VERSION1_20_4; // Future
|
||||
case "1.20.5", "1.20.6" -> VERSION1_20_5; // Future
|
||||
case "1.21" -> VERSION1_21; // Future
|
||||
default -> VERSION1_20_1; // Current supported ver
|
||||
case "1.20.2" -> VERSION1_20_2;
|
||||
case "1.20.4" -> VERSION1_20_4;
|
||||
case "1.20.5", "1.20.6" -> VERSION1_20_5;
|
||||
case "1.21", "1.21.1" -> VERSION1_21_1;
|
||||
case "1.21.2", "1.21.3" -> VERSION1_21_3;
|
||||
default -> VERSION1_21_3; // Current supported ver
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -124,7 +124,6 @@ public class FabricEventListener extends EventListener implements LockedHandler
|
||||
}
|
||||
|
||||
private ActionResult handleItemInteract(PlayerEntity player, World world, Hand hand) {
|
||||
ItemStack stackInHand = player.getStackInHand(hand);
|
||||
return (cancelPlayerEvent(player.getUuid())) ? ActionResult.FAIL : ActionResult.PASS;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,24 +1,35 @@
|
||||
/*
|
||||
* This file is part of HuskSync, licensed under the Apache License 2.0.
|
||||
*
|
||||
* Copyright (c) William278 <will27528@gmail.com>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
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 {
|
||||
public interface HungerManagerMixin {
|
||||
|
||||
@Shadow
|
||||
private float exhaustion;
|
||||
@Accessor
|
||||
float getExhaustion();
|
||||
|
||||
@Accessor("exhaustion")
|
||||
public void setExhaustion(float exhaustion) {
|
||||
this.exhaustion = exhaustion;
|
||||
}
|
||||
|
||||
@Accessor("exhaustion")
|
||||
public float getExhaustion() {
|
||||
return exhaustion;
|
||||
}
|
||||
void setExhaustion(float exhaustion);
|
||||
|
||||
}
|
||||
|
||||
@@ -4,12 +4,12 @@
|
||||
"package": "net.william278.husksync.mixins",
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"server": [
|
||||
"HungerManagerMixin",
|
||||
"ItemEntityMixin",
|
||||
"PlayerEntityMixin",
|
||||
"ServerPlayerEntityMixin",
|
||||
"ServerPlayNetworkHandlerMixin",
|
||||
"ServerWorldMixin",
|
||||
"HungerManagerMixin"
|
||||
"ServerWorldMixin"
|
||||
],
|
||||
"client": [],
|
||||
"injectors": {
|
||||
|
||||
Reference in New Issue
Block a user