Files
gambling-plus/src/main/java/com/ismailkaygisiz/gamblingplus/block/GamblingTableBlock.java
2025-07-19 16:58:07 +03:00

55 lines
2.9 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/*package com.ismailkaygisiz.gamblingplus.block;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.BlockHitResult;
import java.util.Random;
public class GamblingTableBlock extends Block {
public GamblingTableBlock(Properties properties) { super(properties); }
@Override
protected InteractionResult useItemOn(ItemStack pStack, BlockState pState, Level pLevel, BlockPos pPos, Player pPlayer, InteractionHand pHand, BlockHitResult pHitResult) {
if (!pLevel.isClientSide && pHand == InteractionHand.MAIN_HAND) {
ItemStack held = pPlayer.getItemInHand(pHand);
int bet = 0;
if (held.getItem() == Items.EMERALD && held.getCount() >= 10) bet = 10;
else if (held.getItem() == Items.EMERALD && held.getCount() >= 5) bet = 5;
else if (held.getItem() == Items.EMERALD && held.getCount() >= 1) bet = 1;
if (bet > 0) {
held.shrink(bet);
int roll = new Random().nextInt(100);
if (roll < 40) {
pPlayer.displayClientMessage(net.minecraft.network.chat.Component.literal("Kaybettin!"),true);
} else if (roll < 70) {
pPlayer.giveExperiencePoints(bet * 5);
pPlayer.displayClientMessage(net.minecraft.network.chat.Component.literal("Kazandın! " + (bet * 5) + " XP kazandın."),true);
} else if (roll < 85) {
pPlayer.getInventory().add(new ItemStack(Items.GOLD_INGOT, bet));
pPlayer.displayClientMessage(Component.literal("Kazandın! " + bet + " altın kazandın."),true);
} else if (roll < 95) {
pPlayer.getInventory().add(new ItemStack(Items.DIAMOND, 1));
pPlayer.displayClientMessage(net.minecraft.network.chat.Component.literal("Büyük ödül! 1 elmas kazandın."),true);
} else {
pPlayer.getInventory().add(new ItemStack(Items.EMERALD, bet * 2));
pPlayer.displayClientMessage(net.minecraft.network.chat.Component.literal("Bahsin iki katı kadar zümrüt kazandın!"),true);
}
return InteractionResult.SUCCESS;
} else {
pPlayer.displayClientMessage(net.minecraft.network.chat.Component.literal("Bahis için en az 1 zümrüt olmalı!"),true);
return InteractionResult.FAIL;
}
}
return InteractionResult.SUCCESS;
}
} */