나는 그 블록과 상호 작용하기 위해 다른 블록의 위치를 저장해야하는 블록을 가지고있다. 세계에서 로그 아웃하지 않는 한 모든 것이 잘 작동합니다. 타일 엔티티 nbt 데이터에 다른 블록의 좌표를 저장하고 싶습니다. 데이터 저장은 잘 작동하지만 세계에 다시 로그인하여 nbt 데이터를로드 할 때 문제가 발생합니다. 나는 이제 문제가 클라이언트 측에만 존재한다는 것을 알아 냈습니다. 세계를로드 할 때 서버에 의해 nbt에서 올바른 좌표가로드되지만 클라이언트는 각 좌표에 대해 0 만로드하며 이러한 좌표에서 블록과 상호 작용할 때 문제가 발생합니다. 이 문제를 해결하는 방법을 모릅니다. 데이터가 서버에 올바르게로드되었지만 클라이언트 측에서 올바르게로드되지 않는 이유에 대해 혼란 스럽습니다. 여기 클라이언트 측과 서버 측에서 NBT로드
작성하고 TileEntity에 NBT를 읽기위한 방법은 다음과 같습니다@Override
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
int[] cont = {0, 0, 0};
if(this.controller != null) {
LogHelper.info("Writing " + this.controller);
cont[0] = this.controller.getX();
cont[1] = this.controller.getY();
cont[2] = this.controller.getZ();
}
compound.setInteger("controllerX", cont[0]);
compound.setInteger("controllerY", cont[1]);
compound.setInteger("controllerZ", cont[2]);
super.writeToNBT(compound);
return compound;
}
@Override
public void readFromNBT(NBTTagCompound compound){
super.readFromNBT(compound);
int[] coords = {0, 0, 0};
coords[0] = compound.getInteger("controllerX");
coords[1] = compound.getInteger("controllerY");
coords[2] = compound.getInteger("controllerZ");
LogHelper.info("Loading " + Arrays.toString(coords));
this.controller = new BlockPos(coords[0], coords[1], coords[2]);
LogHelper.info("Loading " + this.controller);
}
나는 또한 NBT에 대한 int 배열을 시도했다, 그러나 그것은 전혀 작동하지 않습니다. nbt 태그에 올바른 데이터가 저장된 경우에도 빈 배열을 반환합니다. 나를 도울 수 있기를 바랍니다. :-)
로 TileEntity를 등록 할 필요도있다'공공 NBTTagCompound getUpdateTag()'getUpdatePacket'과는 다른 시간()'에서 호출된다. – Draco18s
대단히 감사합니다! 이게 내 문제를 해결했지만 getUpdatePacket() 대신 getUpdateTag()를 사용해야했습니다! – XPModder