mirror of
https://github.com/Ellpeck/PrettyPipes.git
synced 2024-12-22 15:39:22 +01:00
fixed the pipe not dropping its cover on break
This commit is contained in:
parent
27b3ddd869
commit
c1100b02fe
3 changed files with 26 additions and 11 deletions
|
@ -52,11 +52,7 @@ public class WrenchItem extends Item {
|
|||
if (!world.isRemote) {
|
||||
if (tile.cover != null) {
|
||||
// remove the cover
|
||||
List<ItemStack> drops = Block.getDrops(tile.cover, (ServerWorld) world, pos, null, player, player.getHeldItem(context.getHand()));
|
||||
for (ItemStack drop : drops)
|
||||
Block.spawnAsEntity(world, pos, drop);
|
||||
|
||||
tile.cover = null;
|
||||
tile.removeCover(player, context.getHand());
|
||||
Utility.sendTileEntityToClients(tile);
|
||||
} else {
|
||||
// remove the pipe
|
||||
|
|
|
@ -258,12 +258,6 @@ public class PipeBlock extends ContainerBlock {
|
|||
@Override
|
||||
public void onReplaced(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving) {
|
||||
if (state.getBlock() != newState.getBlock()) {
|
||||
PipeTileEntity tile = Utility.getTileEntity(PipeTileEntity.class, worldIn, pos);
|
||||
if (tile != null) {
|
||||
Utility.dropInventory(tile, tile.modules);
|
||||
for (IPipeItem item : tile.getItems())
|
||||
item.drop(worldIn, item.getContent());
|
||||
}
|
||||
PipeNetwork network = PipeNetwork.get(worldIn);
|
||||
network.removeNode(pos);
|
||||
network.onPipeChanged(pos, state);
|
||||
|
@ -271,6 +265,19 @@ public class PipeBlock extends ContainerBlock {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockHarvested(World worldIn, BlockPos pos, BlockState state, PlayerEntity player) {
|
||||
PipeTileEntity tile = Utility.getTileEntity(PipeTileEntity.class, worldIn, pos);
|
||||
if (tile != null) {
|
||||
Utility.dropInventory(tile, tile.modules);
|
||||
for (IPipeItem item : tile.getItems())
|
||||
item.drop(worldIn, item.getContent());
|
||||
if (tile.cover != null)
|
||||
tile.removeCover(player, Hand.MAIN_HAND);
|
||||
}
|
||||
super.onBlockHarvested(worldIn, pos, state, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasComparatorInputOverride(BlockState state) {
|
||||
return true;
|
||||
|
|
|
@ -9,6 +9,7 @@ import de.ellpeck.prettypipes.network.PipeItem;
|
|||
import de.ellpeck.prettypipes.network.PipeNetwork;
|
||||
import de.ellpeck.prettypipes.pipe.containers.MainPipeContainer;
|
||||
import de.ellpeck.prettypipes.pressurizer.PressurizerTileEntity;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
|
@ -26,10 +27,12 @@ import net.minecraft.tileentity.ITickableTileEntity;
|
|||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
|
@ -351,6 +354,15 @@ public class PipeTileEntity extends TileEntity implements INamedContainerProvide
|
|||
return builder.build();
|
||||
}
|
||||
|
||||
public void removeCover(PlayerEntity player, Hand hand) {
|
||||
if (this.world.isRemote)
|
||||
return;
|
||||
List<ItemStack> drops = Block.getDrops(this.cover, (ServerWorld) this.world, this.pos, null, player, player.getHeldItem(hand));
|
||||
for (ItemStack drop : drops)
|
||||
Block.spawnAsEntity(this.world, this.pos, drop);
|
||||
this.cover = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
super.remove();
|
||||
|
|
Loading…
Reference in a new issue