mirror of
https://github.com/Ellpeck/PrettyPipes.git
synced 2024-12-04 08:18:35 +01:00
parent
4a0cde4435
commit
04f2bf3ea4
3 changed files with 8 additions and 21 deletions
|
@ -45,11 +45,10 @@ public class WrenchItem extends Item {
|
|||
if (!world.isClientSide) {
|
||||
if (tile.cover != null) {
|
||||
// remove the cover
|
||||
tile.removeCover(player, context.getHand());
|
||||
tile.removeCover();
|
||||
Utility.sendBlockEntityToClients(tile);
|
||||
} else {
|
||||
// remove the pipe
|
||||
PipeBlock.dropItems(world, pos, player);
|
||||
Block.dropResources(state, world, pos, tile, null, ItemStack.EMPTY);
|
||||
world.removeBlock(pos, false);
|
||||
}
|
||||
|
|
|
@ -263,7 +263,12 @@ public class PipeBlock extends BaseEntityBlock implements SimpleWaterloggedBlock
|
|||
network.removeNode(pos);
|
||||
network.onPipeChanged(pos, state);
|
||||
if (worldIn.getBlockEntity(pos) instanceof PipeBlockEntity pipe) {
|
||||
Utility.dropInventory(pipe, pipe.modules);
|
||||
for (var item : pipe.getItems())
|
||||
item.drop(worldIn, item.getContent());
|
||||
pipe.getItems().clear();
|
||||
if (pipe.cover != null)
|
||||
pipe.removeCover();
|
||||
for (var craft : pipe.getActiveCrafts()) {
|
||||
for (var lock : craft.ingredientsToRequest)
|
||||
network.resolveNetworkLock(lock);
|
||||
|
@ -273,12 +278,6 @@ public class PipeBlock extends BaseEntityBlock implements SimpleWaterloggedBlock
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState playerWillDestroy(Level worldIn, BlockPos pos, BlockState state, Player player) {
|
||||
PipeBlock.dropItems(worldIn, pos, player);
|
||||
return super.playerWillDestroy(worldIn, pos, state, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAnalogOutputSignal(BlockState state) {
|
||||
return true;
|
||||
|
@ -320,15 +319,4 @@ public class PipeBlock extends BaseEntityBlock implements SimpleWaterloggedBlock
|
|||
return BaseEntityBlock.createTickerHelper(type, Registry.pipeBlockEntity, PipeBlockEntity::tick);
|
||||
}
|
||||
|
||||
public static void dropItems(Level worldIn, BlockPos pos, Player player) {
|
||||
var tile = Utility.getBlockEntity(PipeBlockEntity.class, worldIn, pos);
|
||||
if (tile != null) {
|
||||
Utility.dropInventory(tile, tile.modules);
|
||||
for (var item : tile.getItems())
|
||||
item.drop(worldIn, item.getContent());
|
||||
if (tile.cover != null)
|
||||
tile.removeCover(player, InteractionHand.MAIN_HAND);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -353,10 +353,10 @@ public class PipeBlockEntity extends BlockEntity implements MenuProvider, IPipeC
|
|||
return -1;
|
||||
}
|
||||
|
||||
public void removeCover(Player player, InteractionHand hand) {
|
||||
public void removeCover() {
|
||||
if (this.level.isClientSide)
|
||||
return;
|
||||
var drops = Block.getDrops(this.cover, (ServerLevel) this.level, this.worldPosition, null, player, player.getItemInHand(hand));
|
||||
var drops = Block.getDrops(this.cover, (ServerLevel) this.level, this.worldPosition, null);
|
||||
for (var drop : drops)
|
||||
Containers.dropItemStack(this.level, this.worldPosition.getX(), this.worldPosition.getY(), this.worldPosition.getZ(), drop);
|
||||
this.cover = null;
|
||||
|
|
Loading…
Reference in a new issue