55 lines
2.9 KiB
Java
55 lines
2.9 KiB
Java
/*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;
|
||
}
|
||
|
||
} */ |