修复集装箱部署已有实体时丢失数据的问题
This commit is contained in:
parent
87ca42f096
commit
4ccb3112ed
1 changed files with 8 additions and 13 deletions
|
@ -56,22 +56,17 @@ public class ContainerBlockEntity extends BlockEntity implements GeoBlockEntity
|
|||
} else {
|
||||
var direction = pState.getValue(ContainerBlock.FACING);
|
||||
|
||||
var entity = blockEntity.entityType.create(pLevel);
|
||||
if (entity == null) return;
|
||||
|
||||
if (blockEntity.entityTag != null) {
|
||||
var entity = blockEntity.entityType.create(pLevel);
|
||||
if (entity != null) {
|
||||
entity.setPos(pPos.getX() + 0.5 + (2 * Math.random() - 1) * 0.1f, pPos.getY() + 0.5 + (2 * Math.random() - 1) * 0.1f, pPos.getZ() + 0.5 + (2 * Math.random() - 1) * 0.1f);
|
||||
entity.setYRot(direction.toYRot());
|
||||
pLevel.addFreshEntity(entity);
|
||||
}
|
||||
} else if (blockEntity.entityType != null) {
|
||||
var entity = blockEntity.entityType.create(pLevel);
|
||||
if (entity != null) {
|
||||
entity.setPos(pPos.getX() + 0.5 + (2 * Math.random() - 1) * 0.1f, pPos.getY() + 0.5 + (2 * Math.random() - 1) * 0.1f, pPos.getZ() + 0.5 + (2 * Math.random() - 1) * 0.1f);
|
||||
entity.setYRot(direction.toYRot());
|
||||
pLevel.addFreshEntity(entity);
|
||||
}
|
||||
entity.load(blockEntity.entityTag);
|
||||
}
|
||||
|
||||
entity.setPos(pPos.getX() + 0.5 + (2 * Math.random() - 1) * 0.1f, pPos.getY() + 0.5 + (2 * Math.random() - 1) * 0.1f, pPos.getZ() + 0.5 + (2 * Math.random() - 1) * 0.1f);
|
||||
entity.setYRot(direction.toYRot());
|
||||
pLevel.addFreshEntity(entity);
|
||||
|
||||
pLevel.setBlockAndUpdate(pPos, Blocks.AIR.defaultBlockState());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue