Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/main/java/growthcraft/cellar/block/CorkCoasterBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
Expand Down Expand Up @@ -95,6 +96,14 @@ public boolean canSurvive(BlockState state, LevelReader level, BlockPos pos) {
&& top.max(Direction.Axis.Z) >= 12.0D / 16.0D;
}

@Override
protected BlockState updateShape(BlockState state, Direction direction, BlockState neighborState, LevelAccessor level,
BlockPos pos, BlockPos neighborPos) {
return !state.canSurvive(level, pos)
? Blocks.AIR.defaultBlockState()
: super.updateShape(state, direction, neighborState, level, pos, neighborPos);
}

@Override
public VoxelShape getShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) {
return state.getValue(ITEM) ? SHAPE_WITH_BOTTLE : SHAPE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.Vec3;
Expand Down Expand Up @@ -94,9 +95,9 @@ public void setChangedAndUpdate() {
BlockState updatedState = state.setValue(CorkCoasterBlock.ITEM, !isEmpty());
if (state != updatedState) {
level.setBlock(worldPosition, updatedState, 3);
} else {
level.sendBlockUpdated(worldPosition, state, state, 3);
}
BlockState currentState = getBlockState();
level.sendBlockUpdated(worldPosition, currentState, currentState, Block.UPDATE_CLIENTS);
}
}

Expand All @@ -111,6 +112,7 @@ protected void saveAdditional(CompoundTag tag, HolderLookup.Provider provider) {
@Override
public void loadAdditional(CompoundTag tag, HolderLookup.Provider provider) {
super.loadAdditional(tag, provider);
items.clear();
ContainerHelper.loadAllItems(tag.getCompound(ITEMS_TAG), this.items, provider);
}

Expand Down
Loading