|
|
@@ -195,27 +195,28 @@ public class AnvilContainerRe extends Container {
|
|
|
float[] netheriteChance = {0f, 0f, 0.0625f, 0.1f};
|
|
|
float newBreakChance = baseBreakChance * ((blockstate.get(RegMain.blockStateMaterial) == 0) ? ironChance : netheriteChance)[world.getDifficulty().getId()];
|
|
|
if (!player.abilities.isCreativeMode && blockstate.isIn(BlockTags.ANVIL) && player.getRNG().nextFloat() < newBreakChance) {
|
|
|
- BlockState blockstate1 = AnvilBlock.damage(blockstate);
|
|
|
- if (blockstate1 == null) {
|
|
|
+ BlockState newBlockState = AnvilBlock.damage(blockstate);
|
|
|
+ if (newBlockState == null) {
|
|
|
world.removeBlock(blockPos, false);
|
|
|
world.playEvent(1029, blockPos, 0);
|
|
|
} else {
|
|
|
// TODO : <验证> 铁砧损坏等级增加时的物品处理是否在多人工作正常
|
|
|
- //保存当前物品
|
|
|
+ // TODO : 解决 Mixin config mixins.blacksmithre.json does not specify "minVersion" property
|
|
|
+ // 保存当前物品并清空物品栏,避免在更改方块时爆出
|
|
|
AnvilTileEntity tileEntity = (AnvilTileEntity) world.getTileEntity(blockPos);
|
|
|
ItemStack itemStack0 = tileEntity.getItems().get(0).copy();
|
|
|
ItemStack itemStack1 = tileEntity.getItems().get(1).copy();
|
|
|
- //清空物品,避免爆出
|
|
|
tileEntity.inventory.clear();
|
|
|
-
|
|
|
- //放置损坏后的方块,放回物品
|
|
|
- world.setBlockState(blockPos, blockstate1, 2);
|
|
|
- AnvilTileEntity tileEntity1 = (AnvilTileEntity) world.getTileEntity(blockPos);
|
|
|
- tileEntity1.inventory.set(0,itemStack0);
|
|
|
- tileEntity1.inventory.set(1,itemStack1);
|
|
|
- tileEntity1.markDirty();
|
|
|
- //玩家更新GUI
|
|
|
- player.openContainer(tileEntity1.getBlockState().getContainer(world,blockPos));
|
|
|
+ // 放置损坏后的方块
|
|
|
+ world.setBlockState(blockPos, newBlockState, 2);
|
|
|
+ // 把物品放回新方块
|
|
|
+ AnvilTileEntity newTileEntity = (AnvilTileEntity) world.getTileEntity(blockPos);
|
|
|
+ newTileEntity.inventory.set(0, itemStack0);
|
|
|
+ newTileEntity.inventory.set(1, itemStack1);
|
|
|
+ newTileEntity.markDirty();
|
|
|
+ // 让玩家再次打开 GUI
|
|
|
+ // TODO : 想办法让玩家的鼠标在铁砧损坏时不会移动到中心(因为实际上 GUI 已经被关闭后重新打开了)
|
|
|
+ player.openContainer(newTileEntity.getBlockState().getContainer(world, blockPos));
|
|
|
world.playEvent(1030, blockPos, 0);
|
|
|
}
|
|
|
} else {
|