Inital
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
/*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;
|
||||
}
|
||||
|
||||
} */
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.ismailkaygisiz.gamblingplus.block;
|
||||
|
||||
import com.ismailkaygisiz.gamblingplus.GamblingPlusMod;
|
||||
import com.ismailkaygisiz.gamblingplus.item.ModItems;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.CreativeModeTabs;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.SoundType;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import net.minecraft.world.level.material.MapColor;
|
||||
import net.minecraftforge.eventbus.api.bus.BusGroup;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class ModBlocks {
|
||||
public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, GamblingPlusMod.MOD_ID);
|
||||
|
||||
public static final RegistryObject<Block> RUBY_BLOCK = registerBlock("ruby_block", ()-> new Block(BlockBehaviour.Properties.of()
|
||||
.setId((ResourceKey.create(Registries.BLOCK, ResourceLocation.parse(String.format("%s:%s", GamblingPlusMod.MOD_ID, "ruby_block")))))
|
||||
.strength(.1f).requiresCorrectToolForDrops().sound(SoundType.IRON)));
|
||||
|
||||
public static final RegistryObject<Block> RAW_RUBY_BLOCK = registerBlock("raw_ruby_block", ()-> new Block(BlockBehaviour.Properties.of()
|
||||
.setId((ResourceKey.create(Registries.BLOCK, ResourceLocation.parse(String.format("%s:%s", GamblingPlusMod.MOD_ID, "raw_ruby_block")))))
|
||||
.strength(.1f).requiresCorrectToolForDrops()));
|
||||
|
||||
public static <T extends Block> void registerBlockItem(String name, RegistryObject<T> block){
|
||||
ModItems.ITEMS.register(name,()-> new BlockItem(block.get(), new Item.Properties()
|
||||
.setId(ResourceKey.create(Registries.ITEM, ResourceLocation.parse(String.format("%s:%s", GamblingPlusMod.MOD_ID, name))))
|
||||
.useItemDescriptionPrefix()));
|
||||
}
|
||||
|
||||
public static <T extends Block> RegistryObject<T> registerBlock(String name, Supplier<T> block){
|
||||
RegistryObject<T> toReturn = BLOCKS.register(name,block);
|
||||
registerBlockItem(name, toReturn);
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static void register(BusGroup eventBus) { BLOCKS.register(eventBus); }
|
||||
}
|
||||
Reference in New Issue
Block a user