Skip to content

Commit

Permalink
can right click card deck to remove a card now
Browse files Browse the repository at this point in the history
(debug feature ong)
yeah
hawk tuah
  • Loading branch information
awakaxis committed Nov 19, 2024
1 parent ffe6e8e commit 21e9107
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/main/java/net/awakaxis/uno/block/CardDeckBlock.java
Original file line number Diff line number Diff line change
@@ -1,30 +1,48 @@
package net.awakaxis.uno.block;

import net.awakaxis.uno.UNOBlockEntities;
import net.awakaxis.uno.client.renderer.blockentity.CardDeckRenderer;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
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.BaseEntityBlock;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.RenderShape;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityTicker;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public class CardDeckBlock extends BaseEntityBlock {

private static final VoxelShape DEFAULT_COLLISION = box(6, 0, 5, 10, 3, 11);
private static final VoxelShape DEFAULT_COLLISION = box(6, 0, 5, 10, 2, 11);

public CardDeckBlock(BlockBehaviour.Properties properties) {
super(properties);
}

@Override
public @NotNull InteractionResult use(BlockState blockState, Level level, BlockPos blockPos, Player player, InteractionHand interactionHand, BlockHitResult blockHitResult) {
if (level.isClientSide) {
CardDeckRenderer.CARD_COUNT -= 1;
return InteractionResult.SUCCESS;
} else {
return InteractionResult.PASS;
}
}

@Override
public @NotNull VoxelShape getShape(BlockState blockState, BlockGetter blockGetter, BlockPos blockPos, CollisionContext collisionContext) {
return DEFAULT_COLLISION;
Expand Down

0 comments on commit 21e9107

Please sign in to comment.