Advertisement
SforzandoCF

fires and forges 1.21.1

Oct 2nd, 2024 (edited)
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.98 KB | None | 0 0
  1. package com.sforzando.firesandforges;
  2.  
  3. public class FiresAndForgesItems {
  4.     public static final Item SOUL_FORGE = register(Identifier.of("fires_and_forges", "soul_forge"), new BlockItem(FiresAndForgesBlocks.SOUL_FORGE, new Item.Settings().rarity(Rarity.UNCOMMON)));
  5.     public static final Item CURSED_FORGE = register(Identifier.of("fires_and_forges", "cursed_forge"), new BlockItem(FiresAndForgesBlocks.CURSED_FORGE, new Item.Settings().rarity(Rarity.RARE)));
  6.     public static final Item STAR_FORGE = register(Identifier.of("fires_and_forges", "star_forge"), new BlockItem(FiresAndForgesBlocks.STAR_FORGE, new Item.Settings().rarity(Rarity.EPIC)));
  7. }
  8.  
  9. public class FiresAndForgesBlocks {
  10.     public static final Block SOUL_FORGE = register(Identifier.of("fires_and_forges", "soul_forge"), new SoulForgeBlock(AbstractBlock.Settings.of().sounds(BlockSoundGroup.STONE).strength(10.0F, 20.0F).dynamicShape()));
  11.     public static final Block CURSED_FORGE = register(Identifier.of("fires_and_forges", "cursed_forge"), new CursedForgeBlock(AbstractBlock.Settings.of().sounds(BlockSoundGroup.METAL).strength(17.5F, 35.0F).dynamicShape()));
  12.     public static final Block STAR_FORGE = register(Identifier.of("fires_and_forges", "star_forge"), new StarForgeBlock(AbstractBlock.Settings.of().sounds(BlockSoundGroup.NETHERITE).strength(25.0F, 50.0F).dynamicShape()));
  13. }
  14.  
  15. public class SoulForgeBlock extends BlockWithEntity implements LandingBlock {
  16.     public SoulForgeBlock (AbstractBlock.Settings settings) {
  17.         super (settings);
  18.     }
  19.    
  20.     public MapCodec<SoulForgeBlock> getCodec () {
  21.         return AbstractBlock.simpleCodec(SoulForgeBlock::new);
  22.     }
  23.    
  24.     public NamedScreenHandlerFactory createScreenHandlerFactory (BlockState state, World world, BlockPos pos) {
  25.         return this.getOrCreateBlockEntity(world, pos);
  26.     }
  27.    
  28.     public ActionResult onUse (BlockState state, World world, BlockPos pos, PlayerEntity player, BlockHitResult hit) {
  29.         if (world.isClientSide())
  30.             MinecraftClient.getInstance().setScreen(new GenericContainerScreen(this.createScreenHandlerFactory(state, world, pos).createMenu(0, player.getInventory(), player), player.getInventory(), Component.translatable("fires_and_forges:menu.soul_forge.name")));
  31.     }
  32.    
  33.     public SoulForgeBlockEntity newBlockEntity (BlockState state, BlockPos pos) {
  34.         return new SoulForgeBlockEntity (state, pos);
  35.     }
  36.    
  37.     public SoulForgeBlockEntity getOrCreateBlockEntity (World world, BlockPos pos) {
  38.         if (world.getBlockEntity(pos) instanceof SoulForgeBlockEntity e) {
  39.             return e;
  40.         } else {
  41.             SoulForgeBlockEntity e = this.newBlockEntity(world.getBlockState(pos), pos);
  42.             e.setWorld(world);
  43.             return e;
  44.         }
  45.     }
  46. }
  47.  
  48. public class SoulForgeBlockEntity extends BlockEntity implements NamedScreenHandlerFactory {
  49.     public SoulForgeBlockEntity (BlockState state, BlockPos pos) {
  50.         super(FiresAndForgesBlockEntities.SOUL_FORGE, state, pos);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement