Giter Club home page Giter Club logo

Comments (2)

i493052739 avatar i493052739 commented on July 17, 2024 1

image

不只是树场
用原版箱子作为机械动力机械结构实体(Contraption/多方块结构)的储存位,被强力胶选定的多方块区域在实体化成Contraption时,物品还不会丢失;但一旦在去实体化后(变回方块后)都会导致内部储存的所有物品丢失。

目前测试,原版箱子、双箱子、陷阱箱、Quark (asm的原版箱子)会丢失;
但原版木桶、原版熔炉、Iron Chest模组箱子、CookingForBlockHeads模组冰箱、MyCrayfishFurniture模组抽屉等,不会存在该问题。

猜测是 CatCustomInventory 相关的箱子,及 BarrelBlock 正常
原版箱子 ChestBlock 及其子类如 TrappedChestBlock,可能有地方需要修复

是否有后台报错:

简化的复现步骤:

  • 放铁轨
  • 放装配站在铁轨上
  • 放矿车在装配站中
  • 放拉杆在装配站上
  • 放箱子在装配站上
  • 用强力胶黏住多个并排的箱子
  • 拉动拉杆、开关控制 contraption 和 block 之间的转换

猜测的问题触发位置:
com.simibubi.create.content.contraptions.AbstractContraptionEntitydisassemble 方法
https://github.com/Creators-of-Create/Create/blob/2201d87da7744cf9ee3f83e1e4c21643244f342b/src/main/java/com/simibubi/create/content/contraptions/Contraption.java#L1076-L1098
其中的 blockEntity.load(tag);
storage.addStorageToWorld(block, blockEntity);

继续追进去能够发现:addStorageToWorld 对 ChestBlockEntity 有独立的处理逻辑:
https://github.com/Creators-of-Create/Create/blob/2201d87da7744cf9ee3f83e1e4c21643244f342b/src/main/java/com/simibubi/create/content/contraptions/MountedStorage.java#L143-L152
其调用 saveWithFullMetadatasaveWithoutMetadata,对应 cat 存入 PublicBukkitValuesthis.persistentDataContainer.toTagCompound()
对应 cat craftbukkit 部分:

public CompoundTag toTagCompound() {
CompoundTag tag = new CompoundTag();
for (Map.Entry<String, Tag> entry : this.customDataTags.entrySet()) {
tag.put(entry.getKey(), entry.getValue());
}
return tag;
}

this.customDataTags 可能需要进一步 debug 查看这里实际的内容变动


也可能是我排查的方向错了,可能只是 craftBukkit 没存进 forge 的箱子内容导致原版箱子变空(比如假设所有craftBukkit的原版箱子 CraftInventory 在放下时默认为空箱子?或者没有 loadForgeContainer)而 CatCustomInventory 相关的容器能够正常 loadForgeContainer
顺着这个思路去看的话:

public CatCustomInventory(ItemStackHandler handler) {
this.container = new CraftInventoryCustom(this, handler.stacks);
this.inventory = this.container.getInventory();
}

其中的
public CraftInventoryCustom(InventoryHolder owner, NonNullList<ItemStack> items) {
super(new MinecraftInventory(owner, items));
}

能拿到 forge 的 MinecraftInventory

目前还不太会用 gradle 去 debug cat... 不过至于为什么猜是通过 ItemStackHandler 构造的 CatCustomInventory
是因为机械动力的 MountedStorage 的 handler 和 dummyHandler 成员均是 ItemStackHandler

from catserver.

LRW-Calen avatar LRW-Calen commented on July 17, 2024 1

image

不只是树场 用原版箱子作为机械动力机械结构实体(Contraption/多方块结构)的储存位,被强力胶选定的多方块区域在实体化成Contraption时,物品还不会丢失;但一旦在去实体化后(变回方块后)都会导致内部储存的所有物品丢失。

目前测试,原版箱子、双箱子、陷阱箱、Quark (asm的原版箱子)会丢失; 但原版木桶、原版熔炉、Iron Chest模组箱子、CookingForBlockHeads模组冰箱、MyCrayfishFurniture模组抽屉等,不会存在该问题。

猜测是 CatCustomInventory 相关的箱子,及 BarrelBlock 正常 原版箱子 ChestBlock 及其子类如 TrappedChestBlock,可能有地方需要修复

是否有后台报错:

简化的复现步骤:

  • 放铁轨
  • 放装配站在铁轨上
  • 放矿车在装配站中
  • 放拉杆在装配站上
  • 放箱子在装配站上
  • 用强力胶黏住多个并排的箱子
  • 拉动拉杆、开关控制 contraption 和 block 之间的转换

猜测的问题触发位置: com.simibubi.create.content.contraptions.AbstractContraptionEntitydisassemble 方法 https://github.com/Creators-of-Create/Create/blob/2201d87da7744cf9ee3f83e1e4c21643244f342b/src/main/java/com/simibubi/create/content/contraptions/Contraption.java#L1076-L1098 其中的 blockEntity.load(tag);storage.addStorageToWorld(block, blockEntity);

继续追进去能够发现:addStorageToWorld 对 ChestBlockEntity 有独立的处理逻辑: https://github.com/Creators-of-Create/Create/blob/2201d87da7744cf9ee3f83e1e4c21643244f342b/src/main/java/com/simibubi/create/content/contraptions/MountedStorage.java#L143-L152 其调用 saveWithFullMetadatasaveWithoutMetadata,对应 cat 存入 PublicBukkitValuesthis.persistentDataContainer.toTagCompound() 对应 cat craftbukkit 部分:

public CompoundTag toTagCompound() {
CompoundTag tag = new CompoundTag();
for (Map.Entry<String, Tag> entry : this.customDataTags.entrySet()) {
tag.put(entry.getKey(), entry.getValue());
}
return tag;
}

this.customDataTags 可能需要进一步 debug 查看这里实际的内容变动
也可能是我排查的方向错了,可能只是 craftBukkit 没存进 forge 的箱子内容导致原版箱子变空(比如假设所有craftBukkit的原版箱子 CraftInventory 在放下时默认为空箱子?或者没有 loadForgeContainer)而 CatCustomInventory 相关的容器能够正常 loadForgeContainer 顺着这个思路去看的话:

public CatCustomInventory(ItemStackHandler handler) {
this.container = new CraftInventoryCustom(this, handler.stacks);
this.inventory = this.container.getInventory();
}

其中的

public CraftInventoryCustom(InventoryHolder owner, NonNullList<ItemStack> items) {
super(new MinecraftInventory(owner, items));
}

能拿到 forge 的 MinecraftInventory
目前还不太会用 gradle 去 debug cat... 不过至于为什么猜是通过 ItemStackHandler 构造的 CatCustomInventory 是因为机械动力的 MountedStorage 的 handler 和 dummyHandler 成员均是 ItemStackHandler

说起来调试 我也没弄明白怎么让clone下来的catserver跑起来 甚至mc本体这个依赖都下不动() 不过调试的话 可以把整个服务器目录放到一个maven项目里 用maven启动catserver那个jar文件
如果要看jar里面代码的话 把forge那几个jar添加成maven依赖 然后刷新maven 就可以看里面代码了
比如这样w

        <dependency>
            <groupId>net.minecraftforge</groupId>
            <artifactId>Forge-universal</artifactId>
            <version>1.18.2</version>
            <scope>system</scope>
            <systemPath>${project.basedir}/run/libraries/net/minecraftforge/forge/1.18.2-40.2.14/forge-1.18.2-40.2.14-universal.jar</systemPath>
        </dependency>

这个run目录里面就是服务器
(其实那次修拔刀剑capability丢失那个bug的时候 我一直靠写mod然后mixin进去打日志 内心是崩溃的QwQ)
祝你好运w

from catserver.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.