diff --git a/gradle.properties b/gradle.properties index f252f6f6..4eed241d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -29,7 +29,7 @@ player_anim_version=1.0.2-rc1+1.20 bend geckolib_version=4.2.1 curios_version=5.5.0+1.20.1 -lib39_version=0.0.8 +lib39_version=0.0.14 ## Mod Properties # The unique mod identifier for the mod. Must be lowercase in English locale. Must fit the regex [a-z][a-z0-9_]{1,63} # Must match the String constant located in the main mod class annotated with @Mod. diff --git a/libs/lib39-1.20.1-0.0.8.jar b/libs/lib39-1.20.1-0.0.14.jar similarity index 95% rename from libs/lib39-1.20.1-0.0.8.jar rename to libs/lib39-1.20.1-0.0.14.jar index 6c3b0f30..1a0566cc 100644 Binary files a/libs/lib39-1.20.1-0.0.8.jar and b/libs/lib39-1.20.1-0.0.14.jar differ diff --git a/libs/lib39-1.20.1-0.0.7.jar b/libs/lib39-1.20.1-0.0.7.jar deleted file mode 100644 index a74f7633..00000000 Binary files a/libs/lib39-1.20.1-0.0.7.jar and /dev/null differ diff --git a/src/main/java/top/r3944realms/eroticdungeongame/ClientHandler.java b/src/main/java/top/r3944realms/eroticdungeongame/ClientHandler.java index 7c185451..8fa57d67 100644 --- a/src/main/java/top/r3944realms/eroticdungeongame/ClientHandler.java +++ b/src/main/java/top/r3944realms/eroticdungeongame/ClientHandler.java @@ -1,3 +1,15 @@ +/* + * * + * * Copyright (c) 2025 R3944Realms. All rights reserved. + * * + * * This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. + * * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/4.0/ + * * or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA. + * * + * * 本作品采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可。 + * + */ + package top.r3944realms.eroticdungeongame; import net.minecraftforge.api.distmarker.Dist; diff --git a/src/main/java/top/r3944realms/eroticdungeongame/CommonHandler.java b/src/main/java/top/r3944realms/eroticdungeongame/CommonHandler.java index e8a55147..542430e7 100644 --- a/src/main/java/top/r3944realms/eroticdungeongame/CommonHandler.java +++ b/src/main/java/top/r3944realms/eroticdungeongame/CommonHandler.java @@ -1,6 +1,19 @@ +/* + * * + * * Copyright (c) 2025 R3944Realms. All rights reserved. + * * + * * This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. + * * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/4.0/ + * * or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA. + * * + * * 本作品采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可。 + * + */ + package top.r3944realms.eroticdungeongame; import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.entity.Entity; import net.minecraftforge.common.capabilities.RegisterCapabilitiesEvent; import net.minecraftforge.event.AttachCapabilitiesEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; @@ -8,9 +21,13 @@ import top.r3944realms.eroticdungeongame.content.capability.DungeonDataSyncManag import top.r3944realms.eroticdungeongame.content.register.EDGCapabilities; import top.r3944realms.lib39.api.event.SyncManagerRegisterEvent; +import java.util.UUID; +import java.util.function.Function; + public class CommonHandler { @net.minecraftforge.fml.common.Mod.EventBusSubscriber(modid = EroticDungeon.MOD_ID, bus = net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus.FORGE) public static class Game extends CommonHandler { + private static Function entityProvider; public static DungeonDataSyncManager dungeonDataSyncManager; public static ResourceLocation DUNGEON_SYNC = EroticDungeon.rl("dungeon_sync"); @SubscribeEvent @@ -23,6 +40,9 @@ public class CommonHandler { dungeonDataSyncManager = new DungeonDataSyncManager(); event.registerSyncManager(DUNGEON_SYNC, dungeonDataSyncManager, EDGCapabilities.PLAYER_DUNGEON_DATA_CAP); } + public static Function getEntityProvider() { + return entityProvider; + } } @net.minecraftforge.fml.common.Mod.EventBusSubscriber(modid = EroticDungeon.MOD_ID, bus = net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus.MOD) diff --git a/src/main/java/top/r3944realms/eroticdungeongame/EroticDungeon.java b/src/main/java/top/r3944realms/eroticdungeongame/EroticDungeon.java index 8a5a3eb0..3b998a18 100644 --- a/src/main/java/top/r3944realms/eroticdungeongame/EroticDungeon.java +++ b/src/main/java/top/r3944realms/eroticdungeongame/EroticDungeon.java @@ -1,3 +1,15 @@ +/* + * * + * * Copyright (c) 2025 R3944Realms. All rights reserved. + * * + * * This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. + * * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/4.0/ + * * or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA. + * * + * * 本作品采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可。 + * + */ + package top.r3944realms.eroticdungeongame; import net.minecraft.resources.ResourceLocation; diff --git a/src/main/java/top/r3944realms/eroticdungeongame/content/animation/AnimationHandler.java b/src/main/java/top/r3944realms/eroticdungeongame/content/animation/AnimationHandler.java index 5180f489..5a5d98e5 100644 --- a/src/main/java/top/r3944realms/eroticdungeongame/content/animation/AnimationHandler.java +++ b/src/main/java/top/r3944realms/eroticdungeongame/content/animation/AnimationHandler.java @@ -1,3 +1,15 @@ +/* + * * + * * Copyright (c) 2025 R3944Realms. All rights reserved. + * * + * * This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. + * * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/4.0/ + * * or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA. + * * + * * 本作品采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可。 + * + */ + package top.r3944realms.eroticdungeongame.content.animation; import net.minecraft.world.entity.player.Player; diff --git a/src/main/java/top/r3944realms/eroticdungeongame/content/animation/AnimationLayers.java b/src/main/java/top/r3944realms/eroticdungeongame/content/animation/AnimationLayers.java index 033171c8..d7ec9632 100644 --- a/src/main/java/top/r3944realms/eroticdungeongame/content/animation/AnimationLayers.java +++ b/src/main/java/top/r3944realms/eroticdungeongame/content/animation/AnimationLayers.java @@ -1,3 +1,15 @@ +/* + * * + * * Copyright (c) 2025 R3944Realms. All rights reserved. + * * + * * This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. + * * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/4.0/ + * * or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA. + * * + * * 本作品采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可。 + * + */ + package top.r3944realms.eroticdungeongame.content.animation; import dev.kosmx.playerAnim.api.layered.IAnimation; diff --git a/src/main/java/top/r3944realms/eroticdungeongame/content/animation/AnimationProperties.java b/src/main/java/top/r3944realms/eroticdungeongame/content/animation/AnimationProperties.java index bf308311..a81ec5a5 100644 --- a/src/main/java/top/r3944realms/eroticdungeongame/content/animation/AnimationProperties.java +++ b/src/main/java/top/r3944realms/eroticdungeongame/content/animation/AnimationProperties.java @@ -1,3 +1,15 @@ +/* + * * + * * Copyright (c) 2025 R3944Realms. All rights reserved. + * * + * * This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. + * * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/4.0/ + * * or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA. + * * + * * 本作品采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可。 + * + */ + package top.r3944realms.eroticdungeongame.content.animation; import dev.kosmx.playerAnim.core.data.KeyframeAnimation; diff --git a/src/main/java/top/r3944realms/eroticdungeongame/content/animation/ClientAnimationHandler.java b/src/main/java/top/r3944realms/eroticdungeongame/content/animation/ClientAnimationHandler.java index 880fdafb..11be4317 100644 --- a/src/main/java/top/r3944realms/eroticdungeongame/content/animation/ClientAnimationHandler.java +++ b/src/main/java/top/r3944realms/eroticdungeongame/content/animation/ClientAnimationHandler.java @@ -1,5 +1,18 @@ +/* + * * + * * Copyright (c) 2025 R3944Realms. All rights reserved. + * * + * * This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. + * * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/4.0/ + * * or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA. + * * + * * 本作品采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可。 + * + */ + package top.r3944realms.eroticdungeongame.content.animation; +import net.minecraft.world.entity.player.Player; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import org.slf4j.Logger; @@ -19,6 +32,16 @@ public enum ClientAnimationHandler implements IAnimationHandler { loadSeatAnimations(); } + @Override + public void playerSeatAnimation(Player player, Integer animationId) { + + } + + @Override + public void removeSeatAnimation(Player player) { + + } + private void loadSeatAnimations() { } diff --git a/src/main/java/top/r3944realms/eroticdungeongame/content/animation/IAnimationHandler.java b/src/main/java/top/r3944realms/eroticdungeongame/content/animation/IAnimationHandler.java index 7fb3ffa0..13b8d9e2 100644 --- a/src/main/java/top/r3944realms/eroticdungeongame/content/animation/IAnimationHandler.java +++ b/src/main/java/top/r3944realms/eroticdungeongame/content/animation/IAnimationHandler.java @@ -1,3 +1,15 @@ +/* + * * + * * Copyright (c) 2025 R3944Realms. All rights reserved. + * * + * * This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. + * * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/4.0/ + * * or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA. + * * + * * 本作品采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可。 + * + */ + package top.r3944realms.eroticdungeongame.content.animation; import net.minecraft.world.entity.player.Player; diff --git a/src/main/java/top/r3944realms/eroticdungeongame/content/animation/type/IAnimationType.java b/src/main/java/top/r3944realms/eroticdungeongame/content/animation/type/IAnimationType.java index ba3da8a0..33a52072 100644 --- a/src/main/java/top/r3944realms/eroticdungeongame/content/animation/type/IAnimationType.java +++ b/src/main/java/top/r3944realms/eroticdungeongame/content/animation/type/IAnimationType.java @@ -1,3 +1,15 @@ +/* + * * + * * Copyright (c) 2025 R3944Realms. All rights reserved. + * * + * * This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. + * * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/4.0/ + * * or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA. + * * + * * 本作品采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可。 + * + */ + package top.r3944realms.eroticdungeongame.content.animation.type; public interface IAnimationType { diff --git a/src/main/java/top/r3944realms/eroticdungeongame/content/animation/type/SeatAnimationType.java b/src/main/java/top/r3944realms/eroticdungeongame/content/animation/type/SeatAnimationType.java index f6082d18..4e8ec919 100644 --- a/src/main/java/top/r3944realms/eroticdungeongame/content/animation/type/SeatAnimationType.java +++ b/src/main/java/top/r3944realms/eroticdungeongame/content/animation/type/SeatAnimationType.java @@ -1,3 +1,15 @@ +/* + * * + * * Copyright (c) 2025 R3944Realms. All rights reserved. + * * + * * This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. + * * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/4.0/ + * * or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA. + * * + * * 本作品采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可。 + * + */ + package top.r3944realms.eroticdungeongame.content.animation.type; import org.jetbrains.annotations.Contract; diff --git a/src/main/java/top/r3944realms/eroticdungeongame/content/block/AbstractSeatBlock.java b/src/main/java/top/r3944realms/eroticdungeongame/content/block/AbstractSeatBlock.java index a9712196..d7c8ea05 100644 --- a/src/main/java/top/r3944realms/eroticdungeongame/content/block/AbstractSeatBlock.java +++ b/src/main/java/top/r3944realms/eroticdungeongame/content/block/AbstractSeatBlock.java @@ -1,3 +1,15 @@ +/* + * * + * * Copyright (c) 2025 R3944Realms. All rights reserved. + * * + * * This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. + * * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/4.0/ + * * or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA. + * * + * * 本作品采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可。 + * + */ + package top.r3944realms.eroticdungeongame.content.block; import net.minecraft.core.BlockPos; diff --git a/src/main/java/top/r3944realms/eroticdungeongame/content/block/AbstractTwoPartSeatBlock.java b/src/main/java/top/r3944realms/eroticdungeongame/content/block/AbstractTwoPartSeatBlock.java index 742406c1..dfdacc27 100644 --- a/src/main/java/top/r3944realms/eroticdungeongame/content/block/AbstractTwoPartSeatBlock.java +++ b/src/main/java/top/r3944realms/eroticdungeongame/content/block/AbstractTwoPartSeatBlock.java @@ -1,3 +1,15 @@ +/* + * * + * * Copyright (c) 2025 R3944Realms. All rights reserved. + * * + * * This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. + * * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/4.0/ + * * or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA. + * * + * * 本作品采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可。 + * + */ + package top.r3944realms.eroticdungeongame.content.block; import net.minecraft.core.BlockPos; diff --git a/src/main/java/top/r3944realms/eroticdungeongame/content/block/FurnitureType.java b/src/main/java/top/r3944realms/eroticdungeongame/content/block/FurnitureType.java index fe1df2a7..d6a721dd 100644 --- a/src/main/java/top/r3944realms/eroticdungeongame/content/block/FurnitureType.java +++ b/src/main/java/top/r3944realms/eroticdungeongame/content/block/FurnitureType.java @@ -1,3 +1,15 @@ +/* + * * + * * Copyright (c) 2025 R3944Realms. All rights reserved. + * * + * * This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. + * * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/4.0/ + * * or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA. + * * + * * 本作品采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可。 + * + */ + package top.r3944realms.eroticdungeongame.content.block; public enum FurnitureType { diff --git a/src/main/java/top/r3944realms/eroticdungeongame/content/block/HorizontalDoubleSeatBlock.java b/src/main/java/top/r3944realms/eroticdungeongame/content/block/HorizontalDoubleSeatBlock.java index 3c8aa8b6..beccf952 100644 --- a/src/main/java/top/r3944realms/eroticdungeongame/content/block/HorizontalDoubleSeatBlock.java +++ b/src/main/java/top/r3944realms/eroticdungeongame/content/block/HorizontalDoubleSeatBlock.java @@ -1,3 +1,15 @@ +/* + * * + * * Copyright (c) 2025 R3944Realms. All rights reserved. + * * + * * This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. + * * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/4.0/ + * * or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA. + * * + * * 本作品采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可。 + * + */ + package top.r3944realms.eroticdungeongame.content.block; import net.minecraft.core.Direction; diff --git a/src/main/java/top/r3944realms/eroticdungeongame/content/block/blockentity/SeatBlockEntity.java b/src/main/java/top/r3944realms/eroticdungeongame/content/block/blockentity/SeatBlockEntity.java index 3b82c36d..a9262f68 100644 --- a/src/main/java/top/r3944realms/eroticdungeongame/content/block/blockentity/SeatBlockEntity.java +++ b/src/main/java/top/r3944realms/eroticdungeongame/content/block/blockentity/SeatBlockEntity.java @@ -1,3 +1,15 @@ +/* + * * + * * Copyright (c) 2025 R3944Realms. All rights reserved. + * * + * * This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. + * * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/4.0/ + * * or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA. + * * + * * 本作品采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可。 + * + */ + package top.r3944realms.eroticdungeongame.content.block.blockentity; import net.minecraft.core.BlockPos; @@ -23,7 +35,6 @@ import java.util.UUID; */ @SuppressWarnings("unused") public class SeatBlockEntity extends BlockEntity { - private int seatEntityId; private UUID boundPlayerUUID; diff --git a/src/main/java/top/r3944realms/eroticdungeongame/content/block/part/SeatPart.java b/src/main/java/top/r3944realms/eroticdungeongame/content/block/part/SeatPart.java index c68b10c8..33d315f2 100644 --- a/src/main/java/top/r3944realms/eroticdungeongame/content/block/part/SeatPart.java +++ b/src/main/java/top/r3944realms/eroticdungeongame/content/block/part/SeatPart.java @@ -1,3 +1,15 @@ +/* + * * + * * Copyright (c) 2025 R3944Realms. All rights reserved. + * * + * * This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. + * * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/4.0/ + * * or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA. + * * + * * 本作品采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可。 + * + */ + package top.r3944realms.eroticdungeongame.content.block.part; import net.minecraft.util.StringRepresentable; diff --git a/src/main/java/top/r3944realms/eroticdungeongame/content/capability/AbstractPlayerDungeonData.java b/src/main/java/top/r3944realms/eroticdungeongame/content/capability/AbstractPlayerDungeonData.java index e5e8c88e..75fac714 100644 --- a/src/main/java/top/r3944realms/eroticdungeongame/content/capability/AbstractPlayerDungeonData.java +++ b/src/main/java/top/r3944realms/eroticdungeongame/content/capability/AbstractPlayerDungeonData.java @@ -1,17 +1,35 @@ +/* + * * + * * Copyright (c) 2025 R3944Realms. All rights reserved. + * * + * * This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. + * * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/4.0/ + * * or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA. + * * + * * 本作品采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可。 + * + */ + package top.r3944realms.eroticdungeongame.content.capability; -import net.minecraft.core.BlockPos; import net.minecraft.resources.ResourceLocation; import top.r3944realms.lib39.core.sync.NBTSyncData; -public abstract class AbstractPlayerDungeonData extends NBTSyncData { +import java.util.UUID; + +public sealed abstract class AbstractPlayerDungeonData extends NBTSyncData permits PlayerDungeonData { protected AbstractPlayerDungeonData(ResourceLocation id) { super(id); } - - abstract Integer getSeatAnimId(); - abstract void setSeatAnimId(Integer seatAnimId); - - abstract BlockPos getSeatPosition(); - abstract void setSeatPosition(BlockPos seatPosition); + abstract public UUID getPlayerUUID(); + abstract public Integer getSeatAnimId(); + abstract public void setSeatAnimId(Integer seatAnimId); + abstract public Integer getSeatEntityId(); + abstract public void setSeatEntityId(Integer seatEntityId); + public void removeSeatAnimId() { + setSeatAnimId(null); + } + public void removeSeatEntityId() { + setSeatEntityId(null); + } } diff --git a/src/main/java/top/r3944realms/eroticdungeongame/content/capability/DungeonDataSyncManager.java b/src/main/java/top/r3944realms/eroticdungeongame/content/capability/DungeonDataSyncManager.java index 9760702e..0a3dc778 100644 --- a/src/main/java/top/r3944realms/eroticdungeongame/content/capability/DungeonDataSyncManager.java +++ b/src/main/java/top/r3944realms/eroticdungeongame/content/capability/DungeonDataSyncManager.java @@ -1,14 +1,47 @@ +/* + * * + * * Copyright (c) 2025 R3944Realms. All rights reserved. + * * + * * This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. + * * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/4.0/ + * * or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA. + * * + * * 本作品采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可。 + * + */ + package top.r3944realms.eroticdungeongame.content.capability; -import top.r3944realms.lib39.core.sync.ISyncManager; +import net.minecraftforge.common.util.LazyOptional; +import org.jetbrains.annotations.Nullable; +import top.r3944realms.eroticdungeongame.content.register.EDGCapabilities; +import top.r3944realms.lib39.core.event.CommonHandler; +import top.r3944realms.lib39.core.sync.CachedSyncManager; -import java.util.HashSet; -import java.util.Set; +import java.util.*; -public class DungeonDataSyncManager implements ISyncManager { - public static Set playerDungeons = new HashSet<>(); +public class DungeonDataSyncManager extends CachedSyncManager { + public static Map playerDungeonData = new HashMap<>(); @Override - public Set getSyncSet() { - return playerDungeons; + public Map getSyncMap() { + return playerDungeonData; + } + + @Nullable + public AbstractPlayerDungeonData getPlayerDungeonData(UUID uuid) { + return playerDungeonData.get(uuid); + } + public void removePlayerSeatEntity(UUID uuid) { + try { + Optional abstractPlayerDungeonData = Optional.ofNullable(CommonHandler.Game.getServerLevel()) + .map(i -> i.getEntity(uuid)) + .map(i -> i.getCapability(EDGCapabilities.PLAYER_DUNGEON_DATA_CAP)) + .map(LazyOptional::resolve) + .map(Optional::orElseThrow); + abstractPlayerDungeonData + .ifPresent(AbstractPlayerDungeonData::removeSeatEntityId); + abstractPlayerDungeonData + .ifPresent(AbstractPlayerDungeonData::removeSeatAnimId); + } catch (NoSuchElementException ignored) {} } } diff --git a/src/main/java/top/r3944realms/eroticdungeongame/content/capability/PlayerDungeonData.java b/src/main/java/top/r3944realms/eroticdungeongame/content/capability/PlayerDungeonData.java index facb4b06..a48180b1 100644 --- a/src/main/java/top/r3944realms/eroticdungeongame/content/capability/PlayerDungeonData.java +++ b/src/main/java/top/r3944realms/eroticdungeongame/content/capability/PlayerDungeonData.java @@ -1,59 +1,88 @@ +/* + * * + * * Copyright (c) 2025 R3944Realms. All rights reserved. + * * + * * This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. + * * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/4.0/ + * * or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA. + * * + * * 本作品采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可。 + * + */ + package top.r3944realms.eroticdungeongame.content.capability; -import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.player.Player; +import org.jetbrains.annotations.NotNull; import top.r3944realms.eroticdungeongame.EroticDungeon; import top.r3944realms.eroticdungeongame.content.register.EDGCapabilities; import top.r3944realms.lib39.core.network.NetworkHandler; import top.r3944realms.lib39.core.network.toClient.SyncNBTDataS2CPack; +import top.r3944realms.lib39.util.nbt.NBTReader; +import top.r3944realms.lib39.util.nbt.NBTWriter; + +import java.util.UUID; public final class PlayerDungeonData extends AbstractPlayerDungeonData { + public final String SEAT_ANIMATION_ID = "seat_animation_id"; + public final String SEAT_ENTITY_ID = "seat_entity_id"; public final Player player; - - PlayerDungeonData(Player player) { + public Integer seatAnimationId; + public Integer seatEntityId; + public PlayerDungeonData(Player player) { super(EroticDungeon.rl(EDGCapabilities.DUNGEON_DATA)); this.player = player; } @Override public CompoundTag serializeNBT() { - return null; + return NBTWriter.builder() + .intValue(SEAT_ANIMATION_ID, seatAnimationId) + .intValue(SEAT_ENTITY_ID, seatEntityId) + .build(); } @Override public void deserializeNBT(CompoundTag compoundTag) { - + NBTReader.of(compoundTag) + .intValue(SEAT_ANIMATION_ID, i -> seatAnimationId = i) + .intValue(SEAT_ENTITY_ID, i -> seatEntityId = i); } @Override public void checkIfDirtyThenUpdate() { - if (isDirty()) { - NetworkHandler.sendToPlayer(new SyncNBTDataS2CPack(player.getId(), id(), this), (ServerPlayer)player); + if (isDirty() && player instanceof ServerPlayer serverPlayer) { + NetworkHandler.sendToPlayer(new SyncNBTDataS2CPack(player.getId(), id(), this), serverPlayer); } } + @Override + public @NotNull UUID getPlayerUUID() { + return player.getUUID(); + } + @Override public Integer getSeatAnimId() { - return 0; + return seatAnimationId; } @Override public void setSeatAnimId(Integer seatAnimId) { - + this.setSeatEntityId(seatAnimId); + makeDirty(); } @Override - public BlockPos getSeatPosition() { - return null; + public Integer getSeatEntityId() { + return seatEntityId; } @Override - public void setSeatPosition(BlockPos seatPosition) { - + public void setSeatEntityId(Integer seatEntityId) { + seatAnimationId = seatEntityId; + makeDirty(); } - - } diff --git a/src/main/java/top/r3944realms/eroticdungeongame/content/capability/PlayerDungeonDataProvider.java b/src/main/java/top/r3944realms/eroticdungeongame/content/capability/PlayerDungeonDataProvider.java index a54210c4..71fbaa44 100644 --- a/src/main/java/top/r3944realms/eroticdungeongame/content/capability/PlayerDungeonDataProvider.java +++ b/src/main/java/top/r3944realms/eroticdungeongame/content/capability/PlayerDungeonDataProvider.java @@ -1,3 +1,15 @@ +/* + * * + * * Copyright (c) 2025 R3944Realms. All rights reserved. + * * + * * This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. + * * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/4.0/ + * * or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA. + * * + * * 本作品采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可。 + * + */ + package top.r3944realms.eroticdungeongame.content.capability; import net.minecraft.core.Direction; diff --git a/src/main/java/top/r3944realms/eroticdungeongame/content/device/SeatType.java b/src/main/java/top/r3944realms/eroticdungeongame/content/device/SeatType.java index 01e9cdcb..9ed33471 100644 --- a/src/main/java/top/r3944realms/eroticdungeongame/content/device/SeatType.java +++ b/src/main/java/top/r3944realms/eroticdungeongame/content/device/SeatType.java @@ -1,3 +1,15 @@ +/* + * * + * * Copyright (c) 2025 R3944Realms. All rights reserved. + * * + * * This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. + * * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/4.0/ + * * or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA. + * * + * * 本作品采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可。 + * + */ + package top.r3944realms.eroticdungeongame.content.device; import net.minecraft.world.entity.EntityType; diff --git a/src/main/java/top/r3944realms/eroticdungeongame/content/device/SeatTypeRegistry.java b/src/main/java/top/r3944realms/eroticdungeongame/content/device/SeatTypeRegistry.java index f3ea7859..d6dffdb7 100644 --- a/src/main/java/top/r3944realms/eroticdungeongame/content/device/SeatTypeRegistry.java +++ b/src/main/java/top/r3944realms/eroticdungeongame/content/device/SeatTypeRegistry.java @@ -1,3 +1,15 @@ +/* + * * + * * Copyright (c) 2025 R3944Realms. All rights reserved. + * * + * * This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. + * * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/4.0/ + * * or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA. + * * + * * 本作品采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可。 + * + */ + package top.r3944realms.eroticdungeongame.content.device; import net.minecraft.world.entity.EntityType; diff --git a/src/main/java/top/r3944realms/eroticdungeongame/content/entity/SeatEntity.java b/src/main/java/top/r3944realms/eroticdungeongame/content/entity/SeatEntity.java index 10f67496..5e03eb0f 100644 --- a/src/main/java/top/r3944realms/eroticdungeongame/content/entity/SeatEntity.java +++ b/src/main/java/top/r3944realms/eroticdungeongame/content/entity/SeatEntity.java @@ -1,3 +1,15 @@ +/* + * * + * * Copyright (c) 2025 R3944Realms. All rights reserved. + * * + * * This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. + * * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/4.0/ + * * or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA. + * * + * * 本作品采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可。 + * + */ + package top.r3944realms.eroticdungeongame.content.entity; diff --git a/src/main/java/top/r3944realms/eroticdungeongame/content/register/EDGBlockEntities.java b/src/main/java/top/r3944realms/eroticdungeongame/content/register/EDGBlockEntities.java index 3f7958de..260d74a9 100644 --- a/src/main/java/top/r3944realms/eroticdungeongame/content/register/EDGBlockEntities.java +++ b/src/main/java/top/r3944realms/eroticdungeongame/content/register/EDGBlockEntities.java @@ -1,3 +1,15 @@ +/* + * * + * * Copyright (c) 2025 R3944Realms. All rights reserved. + * * + * * This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. + * * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/4.0/ + * * or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA. + * * + * * 本作品采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可。 + * + */ + package top.r3944realms.eroticdungeongame.content.register; import net.minecraft.world.level.block.entity.BlockEntityType; diff --git a/src/main/java/top/r3944realms/eroticdungeongame/content/register/EDGBlocks.java b/src/main/java/top/r3944realms/eroticdungeongame/content/register/EDGBlocks.java index fc82002a..027260ff 100644 --- a/src/main/java/top/r3944realms/eroticdungeongame/content/register/EDGBlocks.java +++ b/src/main/java/top/r3944realms/eroticdungeongame/content/register/EDGBlocks.java @@ -1,3 +1,15 @@ +/* + * * + * * Copyright (c) 2025 R3944Realms. All rights reserved. + * * + * * This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. + * * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/4.0/ + * * or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA. + * * + * * 本作品采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可。 + * + */ + package top.r3944realms.eroticdungeongame.content.register; import net.minecraft.world.level.block.Block; diff --git a/src/main/java/top/r3944realms/eroticdungeongame/content/register/EDGCapabilities.java b/src/main/java/top/r3944realms/eroticdungeongame/content/register/EDGCapabilities.java index 29b30fa9..8b0a7a56 100644 --- a/src/main/java/top/r3944realms/eroticdungeongame/content/register/EDGCapabilities.java +++ b/src/main/java/top/r3944realms/eroticdungeongame/content/register/EDGCapabilities.java @@ -1,3 +1,15 @@ +/* + * * + * * Copyright (c) 2025 R3944Realms. All rights reserved. + * * + * * This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. + * * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/4.0/ + * * or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA. + * * + * * 本作品采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可。 + * + */ + package top.r3944realms.eroticdungeongame.content.register; import net.minecraft.world.entity.player.Player; diff --git a/src/main/java/top/r3944realms/eroticdungeongame/content/register/EDGCreativeTabs.java b/src/main/java/top/r3944realms/eroticdungeongame/content/register/EDGCreativeTabs.java index 7e73d621..df1fc3a9 100644 --- a/src/main/java/top/r3944realms/eroticdungeongame/content/register/EDGCreativeTabs.java +++ b/src/main/java/top/r3944realms/eroticdungeongame/content/register/EDGCreativeTabs.java @@ -1,3 +1,15 @@ +/* + * * + * * Copyright (c) 2025 R3944Realms. All rights reserved. + * * + * * This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. + * * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/4.0/ + * * or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA. + * * + * * 本作品采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可。 + * + */ + package top.r3944realms.eroticdungeongame.content.register; import net.minecraft.core.registries.Registries; diff --git a/src/main/java/top/r3944realms/eroticdungeongame/content/register/EDGEntities.java b/src/main/java/top/r3944realms/eroticdungeongame/content/register/EDGEntities.java index 57b34a19..40ad23f8 100644 --- a/src/main/java/top/r3944realms/eroticdungeongame/content/register/EDGEntities.java +++ b/src/main/java/top/r3944realms/eroticdungeongame/content/register/EDGEntities.java @@ -1,3 +1,15 @@ +/* + * * + * * Copyright (c) 2025 R3944Realms. All rights reserved. + * * + * * This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. + * * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/4.0/ + * * or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA. + * * + * * 本作品采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可。 + * + */ + package top.r3944realms.eroticdungeongame.content.register; import net.minecraft.world.entity.Entity; diff --git a/src/main/java/top/r3944realms/eroticdungeongame/content/register/EDGItems.java b/src/main/java/top/r3944realms/eroticdungeongame/content/register/EDGItems.java index a04c1d68..86529ebd 100644 --- a/src/main/java/top/r3944realms/eroticdungeongame/content/register/EDGItems.java +++ b/src/main/java/top/r3944realms/eroticdungeongame/content/register/EDGItems.java @@ -1,3 +1,15 @@ +/* + * * + * * Copyright (c) 2025 R3944Realms. All rights reserved. + * * + * * This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. + * * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/4.0/ + * * or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA. + * * + * * 本作品采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可。 + * + */ + package top.r3944realms.eroticdungeongame.content.register; import net.minecraft.world.item.Item; diff --git a/src/main/java/top/r3944realms/eroticdungeongame/content/util/FurnitureHelper.java b/src/main/java/top/r3944realms/eroticdungeongame/content/util/FurnitureHelper.java index 66cd0e08..7c29b00d 100644 --- a/src/main/java/top/r3944realms/eroticdungeongame/content/util/FurnitureHelper.java +++ b/src/main/java/top/r3944realms/eroticdungeongame/content/util/FurnitureHelper.java @@ -1,3 +1,15 @@ +/* + * * + * * Copyright (c) 2025 R3944Realms. All rights reserved. + * * + * * This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. + * * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/4.0/ + * * or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA. + * * + * * 本作品采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可。 + * + */ + package top.r3944realms.eroticdungeongame.content.util; import net.minecraft.core.BlockPos; @@ -10,8 +22,10 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.properties.BooleanProperty; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import top.r3944realms.eroticdungeongame.CommonHandler; import top.r3944realms.eroticdungeongame.EroticDungeon; import top.r3944realms.eroticdungeongame.content.block.blockentity.SeatBlockEntity; +import top.r3944realms.eroticdungeongame.content.capability.DungeonDataSyncManager; import top.r3944realms.eroticdungeongame.content.device.SeatType; import top.r3944realms.eroticdungeongame.content.entity.SeatEntity; @@ -22,6 +36,7 @@ public class FurnitureHelper { } public static List RESTRAINT_FURNACES = new ArrayList<>(); + public static @Nullable String getEntityDeviceId(@NotNull Entity entity) { // "entity.eroticdungeongame.wall_cuff -> 8 + modid -> wall_cuff" return entity.getEncodeId() == null ? null : entity.getEncodeId().substring(8 + EroticDungeon.MOD_ID.length()); @@ -60,11 +75,12 @@ public class FurnitureHelper { .orElse(null); } - public static boolean isPlayerBound(UUID playerUUID) { - return DeviceManager.getInstance().entrySet().stream() - .anyMatch(entry -> entry.getValue().getBoundPlayerUuid().equals(playerUUID)); + public static boolean isPlayerBound(@NotNull UUID player) { + DungeonDataSyncManager dungeonDataSyncManager = Objects.requireNonNull(CommonHandler.Game.dungeonDataSyncManager, "DungeonDataSyncManager is not initialized"); + return Optional.ofNullable(dungeonDataSyncManager.getPlayerDungeonData(player)).map(i->i.getSeatEntityId() != null).orElse(false); } - public static void releasePlayerFromDevice(Player player) { + + public static void releasePlayerFromDevice(@NotNull Player player) { SeatBlockEntity deviceBlockEntity; // 检查玩家是否骑乘在实体上 @@ -92,15 +108,7 @@ public class FurnitureHelper { deviceBlockEntity.releasePlayer(player.level(), deviceBlockEntity.getBlockPos()); // 从设备管理器中移除会话 - DeviceManager.getSeatSessions().remove(deviceBlockEntity.getBoundPlayerUUID()); - - // 检查玩家是否仍被其他设备绑定 - if (isPlayerBound(player.getUUID())) { - return; - } - - // 重置玩家的姿势状态 - DeviceManager.resetSeatSession(player); + CommonHandler.Game.dungeonDataSyncManager.removePlayerSeatEntity(deviceBlockEntity.getBoundPlayerUUID()); } } }