Fixed fancy beds deleting their sheets when broken

This commit is contained in:
Sollace 2024-03-22 19:09:50 +00:00
parent 7c48486956
commit 01b9e11e2d
No known key found for this signature in database
GPG key ID: E52FACE7B5C773DB
2 changed files with 14 additions and 1 deletions

View file

@ -57,6 +57,20 @@ public class FancyBedBlock extends BedBlock {
return SHAPES.get(state.get(PART).ordinal()).apply(BedBlock.getOppositePartDirection(state));
}
@Deprecated
@Override
public void onStateReplaced(BlockState state, World world, BlockPos pos, BlockState newState, boolean moved) {
if (state.hasBlockEntity() && !state.isOf(newState.getBlock()) && state.get(PART) == BedPart.HEAD) {
world.getBlockEntity(pos, UBlockEntities.FANCY_BED).ifPresent(tile -> {
SheetPattern pattern = tile.getPattern();
if (pattern != SheetPattern.NONE) {
dropStack(world, pos, BedsheetsItem.forPattern(pattern).getDefaultStack());
}
});
}
super.onStateReplaced(state, world, pos, newState, moved);
}
@Override
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
return new Tile(pos, state);

View file

@ -6,7 +6,6 @@ import org.jetbrains.annotations.Nullable;
import com.google.common.base.Suppliers;
import com.minelittlepony.unicopia.block.FancyBedBlock;
import net.minecraft.block.Block;
import net.minecraft.block.BlockEntityProvider;
import net.minecraft.block.entity.BlockEntity;