Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.sforzando.worldsteel.common.init;
- public class WorldsteelItems {
- public static final Item GLOWING_BOTTLE = register("glowing_bottle", new Item(new Item.Settings().maxCount(1).food(new FoodComponent.Builder().nutrition(2).saturationModifier(0F).statusEffect(new StatusEffectInstance(StatusEffects.GLOWING), 0.7F).alwaysEdible().snack().build())));
- public static final Item DISTILLED_SOULS = register("distilled_souls", new Item(new Item.Settings().maxCount(1).food(new FoodComponent.Builder().nutrition(2).saturationModifier(0F).statusEffect(new StatusEffectInstance(StatusEffects.WITHER), 0.7F).alwaysEdible().snack().build())));
- public static final Item SOUL_STEEL_SCRAPS = register("soul_steel_scraps", new Item(new Item.Settings().maxCount(16)));
- public static final Item SOUL_STEEL_INGOT = register("soul_steel_ingot", new Item(new Item.Settings().rarity(Rarity.UNCOMMON)));
- public static final Item SOUL_STEEL_SWORD = register("soul_steel_sword", new SwordItem(WorldsteelToolTiers.SOUL_STEEL, new Item.Settings().rarity(Rarity.UNCOMMON)));
- public static final Item SOUL_STEEL_SHOVEL = register("soul_steel_shovel", new ShovelItem(WorldsteelToolTiers.SOUL_STEEL, new Item.Settings().rarity(Rarity.UNCOMMON)));
- public static final Item SOUL_STEEL_PICKAXE = register("soul_steel_pickaxe", new PickaxeItem(WorldsteelToolTiers.SOUL_STEEL, new Item.Settings().rarity(Rarity.UNCOMMON)));
- public static final Item SOUL_STEEL_AXE = register("soul_steel_axe", new AxeItem(WorldsteelToolTiers.SOUL_STEEL, new Item.Settings().rarity(Rarity.UNCOMMON)));
- public static final Item SOUL_STEEL_HOE = register("soul_steel_hoe", new HoeItem(WorldsteelToolTiers.SOUL_STEEL, new Item.Settings().rarity(Rarity.UNCOMMON)));
- public static final Item SOUL_STEEL_HELMET = register("soul_steel_helmet", new ArmorItem(RegistryEntry.<ArmorMaterial>of(WorldsteelArmorMaterials.SOUL_STEEL), ArmorItem.Type.HELMET, new Item.Settings().rarity(Rarity.UNCOMMON)));
- public static final Item SOUL_STEEL_CHESTPLATE = register("soul_steel_chestplate", new ArmorItem(RegistryEntry.<ArmorMaterial>of(WorldsteelArmorMaterials.SOUL_STEEL), ArmorItem.Type.CHESTPLATE, new Item.Settings().rarity(Rarity.UNCOMMON)));
- public static final Item SOUL_STEEL_LEGGINGS = register("soul_steel_leggings", new ArmorItem(RegistryEntry.<ArmorMaterial>of(WorldsteelArmorMaterials.SOUL_STEEL), ArmorItem.Type.LEGGINGS, new Item.Settings().rarity(Rarity.UNCOMMON)));
- public static final Item SOUL_STEEL_BOOTS = register("soul_steel_boots", new ArmorItem(RegistryEntry.<ArmorMaterial>of(WorldsteelArmorMaterials.SOUL_STEEL), ArmorItem.Type.BOOTS, new Item.Settings().rarity(Rarity.UNCOMMON)));
- public static final Item SOUL_STEEL_BLOCK = register("soul_steel_block", new BlockItem(WorldsteelBlocks.SOUL_STEEL_BLOCK, new Item.Settings().rarity(Rarity.UNCOMMON)));
- public static final Item SOUL_STEEL_GRATE = register("soul_steel_grate", new BlockItem(WorldsteelBlocks.SOUL_STEEL_GRATE, new Item.Settings().rarity(Rarity.UNCOMMON)));
- public static final Item SOUL_TRAP = register("soul_trap", new BlockItem(WorldsteelBlocks.SOUL_TRAP, new Item.Settings().rarity(Rarity.UNCOMMON)));
- public static final Item PEARL_CRYSTAL = register("pearl_crystal", new Item(new Item.Settings()));
- public static final Item PEARL_CRYSTAL_ORE = register("pearl_crystal_ore", new BlockItem(WorldsteelBlocks.PEARL_CRYSTAL_ORE, new Item.Settings()));
- public static final Item PEARL_CRYSTAL_BLOCK = register("pearl_crystal_block", new BlockItem(WorldsteelBlocks.PEARL_CRYSTAL_BLOCK, new Item.Settings()));
- public static final Item GROUND_AMETHYST = register("ground_amethyst", new Item(new Item.Settings()));
- public static final Item WORLDSTEEL_CORE = register("worldsteel_core", new Item(new Item.Settings()));
- public static final Item WORLDSTEEL_SCRAPS = register("worldsteel_scraps", new Item(new Item.Settings().maxCount(16)));
- public static final Item WORLDSTEEL_INGOT = register("worldsteel_ingot", new Item(new Item.Settings().rarity(Rarity.RARE)));
- public static final Item WORLDSTEEL_SWORD = register("worldsteel_sword", new SwordItem(WorldsteelToolTiers.WORLDSTEEL, new Item.Settings().rarity(Rarity.RARE)));
- public static final Item WORLDSTEEL_SHOVEL = register("worldsteel_shovel", new ShovelItem(WorldsteelToolTiers.WORLDSTEEL, new Item.Settings().rarity(Rarity.RARE)));
- public static final Item WORLDSTEEL_PICKAXE = register("worldsteel_pickaxe", new PickaxeItem(WorldsteelToolTiers.WORLDSTEEL, new Item.Settings().rarity(Rarity.RARE)));
- public static final Item WORLDSTEEL_AXE = register("worldsteel_axe", new AxeItem(WorldsteelToolTiers.WORLDSTEEL, new Item.Settings().rarity(Rarity.RARE)));
- public static final Item WORLDSTEEL_HOE = register("worldsteel_hoe", new HoeItem(WorldsteelToolTiers.WORLDSTEEL, new Item.Settings().rarity(Rarity.RARE)));
- public static final Item WORLDSTEEL_HELMET = register("worldsteel_helmet", new ArmorItem(RegistryEntry.<ArmorMaterial>of(WorldsteelArmorMaterials.WORLDSTEEL), ArmorItem.Type.HELMET, new Item.Settings().rarity(Rarity.RARE)));
- public static final Item WORLDSTEEL_CHESTPLATE = register("worldsteel_chestplate", new ArmorItem(RegistryEntry.<ArmorMaterial>of(WorldsteelArmorMaterials.WORLDSTEEL), ArmorItem.Type.CHESTPLATE, new Item.Settings().rarity(Rarity.RARE)));
- public static final Item WORLDSTEEL_LEGGINGS = register("worldsteel_leggings", new ArmorItem(RegistryEntry.<ArmorMaterial>of(WorldsteelArmorMaterials.WORLDSTEEL), ArmorItem.Type.LEGGINGS, new Item.Settings().rarity(Rarity.RARE)));
- public static final Item WORLDSTEEL_BOOTS = register("worldsteel_boots", new ArmorItem(RegistryEntry.<ArmorMaterial>of(WorldsteelArmorMaterials.WORLDSTEEL), ArmorItem.Type.BOOTS, new Item.Settings().rarity(Rarity.RARE)));
- public static final Item WORLDSTEEL_BLOCK = register("worldsteel_block", new BlockItem(WorldsteelBlocks.WORLDSTEEL_BLOCK, new Item.Settings().rarity(Rarity.RARE)));
- public static final Item WORLDSTEEL_RIFT = register("worldsteel_rift", new WorldsteelRiftItem(new Item.Settings().maxCount(1).rarity(Rarity.EPIC)));
- public static final Item SWEET_STARDUST = register("sweet_stardust", new Item(new Item.Settings().food(new FoodComponent.Builder().nutrition(3).saturationModifier(0.5F).snack().build())));
- public static final Item SWEET_STARDUST_PIE = register("sweet_stardust_pie", new Item(new Item.Settings().food(new FoodComponent.Builder().nutrition(9).saturationModifier(0.8F).build())));
- public static final Item SWEET_STARDUST_CAKE = register("sweet_stardust_cake", new BlockItem(WorldsteelBlocks.SWEET_STARDUST_CAKE, new Item.Settings()));
- public static final Item SWEET_STARFIRE = register("sweet_starfire", new Item(new Item.Settings().food(new FoodComponent.Builder().nutrition(3).saturationModifier(0.5F).snack().build())));
- public static final Item SWEET_STARFIRE_PIE = register("sweet_starfire_pie", new Item(new Item.Settings().food(new FoodComponent.Builder().nutrition(9).saturationModifier(0.8F).build())));
- public static final Item SWEET_STARFIRE_CAKE = register("sweet_starfire_cake", new BlockItem(WorldsteelBlocks.SWEET_STARDUST_CAKE, new Item.Settings()));
- private static Item register (String path, Item i) {
- Registry.register(Registries.ITEM, i, Identifier.of("worldsteel", path));
- }
- }
- package com.sforzando.worldsteel.common.item;
- public class WorldsteelRiftItem extends Item {
- public WorldsteelRiftItem (Item.Settings settings) {
- super (settings);
- }
- public void onItemEntityDestroyed (ItemEntity item) {
- item.getWorld().playSound(item, item.getBlockPos(), SoundEvents.ITEM_TOTEM_USE, SoundCategory.BLOCKS, 1F, 1F);
- item.getWorld().playSound(item, item.getBlockPos(), SoundEvents.ENTITY_WITHER_SPAWN, SoundCategory.BLOCKS, 1F, 1F);
- for (Entity e : item.getWorld().getEntities(item.getOwner(), new Box(item.getBlockPos()).expand(25, 25, 25), (te) -> {
- return te instanceof MobEntity && ((MobEntity)te).getTarget() == item.getOwner();
- }))
- e.kill();
- }
- public TypedActionResult<ItemStack> use (World world, PlayerEntity player, Hand hand) {
- if (world.isClientSide()) MinecraftClient.getInstance().gameRenderer.showFloatingItem(player.getStackInHand(hand));
- world.playSound(player, player.getBlockPos(), SoundEvents.ITEM_TOTEM_USE, SoundCategory.PLAYERS, 1F, 1F);
- world.playSound(player, player.getBlockPos(), SoundEvents.ENTITY_WITHER_SPAWN, SoundCategory.PLAYERS, 1F, 1F);
- for (Entity e : world.getEntities(player, new Box(player.getBlockPos()).expand(25, 25, 25), (te) -> {
- return te instanceof MobEntity && ((MobEntity)te).getTarget() == player;
- }))
- e.kill();
- player.setStackInHand(player.getStackInHand(hand).shrink(1), hand);
- return new TypedActionResult(InteractionResult.sidedSuccess(true), player.getStackInHand(hand));
- }
- public boolean hasGlint (ItemStack s) {
- return true;
- }
- }
- package com.sforzando.worldsteel.common.init;
- public class WorldsteelBlocks {
- public static final Block SOUL_STEEL_BLOCK = register("soul_steel_block", new Block(AbstractBlock.Settings.of().mapColor(DyeColor.GRAY).sound(SoundType.METAL).strength(6F, 40F).requiresTool()));
- public static final Block SOUL_STEEL_GRATE = register("soul_steel_grate", new PaneBlock(AbstractBlock.Settings.of().mapColor(MapColor.CLEAR).sound(BlockSoundGroup.METAL).strength(4F, 10F).dynamicBounds().requiresTool()));
- public static final Block SOUL_TRAP = register("soul_trap", new SoulTrapBlock(AbstractBlock.Settings.of().mapColor(MapColor.GRAY).sound(BlockSoundGroup.METAL).strength(4F, 10F).dynamicBounds().requiresTool().luminance((getOrFalse(s, FILLED) && getOrFalse(s, ACTIVE)) ? 4 : 0)));
- public static final Block PEARL_CRYSTAL_ORE = register("pearl_crystal_ore", new Block(AbstractBlock.Settings.of().mapColor(MapColor.PALE_YELLOW).sound(BlockSoundGroup.STONE).strength(4.5F, 9F).dynamicBounds().requiresTool()));
- public static final Block PEARL_CRYSTAL_BLOCK = register("pearl_crystal_block", new PearlCrystalBlock(AbstractBlock.Settings.of().mapColor(MapColor.DARK_AQUA).sound(BlockSoundGroup.AMETHYST).strength(4.5F, 9F).dynamicBounds().requiresTool()));
- public static final Block WORLDSTEEL_BLOCK = register("worldsteel_block", new Block(AbstractBlock.Settings.of().mapColor(DyeColor.DARK_AQUA).sound(SoundType.NETHERITE).strength(14F, 1300F).requiresTool()));
- public static final Block SWEET_STARDUST_CAKE = register("sweet_stardust_cake", new CandlelessCakeBlock(AbstractBlock.copy(Blocks.CAKE)));
- public static final Block SWEET_STARFIRE_CAKE = register("sweet_starfire_cake", new CandlelessCakeBlock(AbstractBlock.copy(Blocks.CAKE)));
- private static Block register (String path, Item i) {
- Registry.register(Registries.BLOCK, i, Identifier.of("worldsteel", path));
- }
- }
- package com.sforzando.worldsteel.common.block;
- public class SoulTrapBlock extends BlockWithEntity {
- public static final BooleanProperty FILLED = Properties.OCCUPIED;
- public static final BooleanProperty ACTIVE = Properties.ENABLED;
- public SoulTrapBlock (AbstractBlock.Settings settings) {
- super(settings);
- this.appendProperties(new StateManager.Builder<Block, BlockState>(this).add(FILLED, ACTIVE));
- }
- protected MapCodec<SoulTrapBlock> getCodec () {
- return simpleCodec(SoulTrapBlock:new);
- }
- public BlockEntity newBlockEntity (BlockPos pos, BlockState state) {
- return new SoulTrapBlockEntity(pos, state);
- }
- public <T extends SoulTrapBlock> BlockEntityTicker<T> getTicker (World world, BlockState state, BlockEntityType<T> type) {
- return (w, p, s, e) -> { entity.tick(); };
- }
- public boolean canPlaceAt (BlockState state, WorldView view, BlockPos pos) {
- return super.canPlaceAt(state, view, pos) && survives(view, pos);
- }
- public void randomTick (BlockState state, ServerWorld world, BlockPos pos, Random random) {
- super.randomTick(state, world, pos, random);
- if (!survives(state, world, pos))
- world.breakBlock(pos, false);
- }
- protected void neighborUpdate (BlockState state, World world, BlockPos pos, Block sourceBlock, BlockPos sourcePos, boolean notify)
- {
- super.neighborUpdate(state, world, pos, sourceBlock, sourcePos, notify);
- if (!survives(world, pos)) world.breakBlock(pos, false);
- protected InteractionResult onUse (BlockState state, World world, BlockPos pos, PlayerEntity player, BlockHitResult hit) {
- if (!getOrFalse(state, FILLED)) return InteractionResult.PASS;
- player.giveItemStack(new ItemStack(getOrFalse(state, COMPLETE) ? WorldsteelItems.DISTILLED_SOULS : WorldsteelItems.GLOWING_BOTTLE));
- world.setBlockState(pos, state.with(SoulTrapBlock.FILLED, Boolean.valueOf(false)));
- if (world.getBlockEntity(pos) instanceof SoulTrapBlockEntity stbe && world.isClientSide())
- stbe.clientStop();
- }
- protected ItemInteractionResult onUseWithItem (ItemStack stack, BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
- if (stack.isEmpty() || stack.getItem() != WorldsteelItems.GLOWING_BOTTLE || !getOrFalse(state, FILLED)) return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION;
- player.setItemInHand(stack.shrink(1), hand);
- world.setBlockState(pos, state.with(SoulTrapBlock.FILLED, Boolean.valueOf(true)));
- if (world.getBlockEntity(pos) instanceof SoulTrapBlockEntity stbe && world.isClientSide())
- stbe.clientStart();
- }
- public void survives (WorldView world, BlockPos pos) {
- return world.getBlockState(pos.down()).isIn(BlockTags.SOUL_SPEED_BLOCKS);
- }
- }
- public class SoulTrapBlockEntity {
- private SoulTrapClientData client;
- private int progress;
- public SoulTrapBlockEntity (BlockPos pos, BlockState state) {
- super (WorldsteelBlockEntities.SOUL_TRAP, pos, state);
- this.client = new SoulTrapClientData(SoulTrapBlock.getOrFalse(state, SoulTrapBlock.FILLED), SoulTrapBlock.getOrFalse(SoulTrapBlock.ACTIVE) ? WorldsteelItems.GLOWING_BOTTLE : WorldsteelItems.DISTILLED_SOULS);
- }
- public void tick () {
- if (!this.hasLevel()) return;
- if (this.getLevel().isClientSide()) this.client.tick();
- if (SoulTrapBlock.getOrFalse(this.getBlockState(), SoulTrapBlock.ACTIVE))
- this.progress++;
- if (this.progress >= 24000) {
- this.getLevel().setBlockState(SoulTrapBlock.trySet(this.getBlockState(), SoulTrapBlock.ACTIVE, false));
- if (this.getLevel().isClientSide()) this.client.setItem(WorldsteelItems.GLOWING_BOTTLE);
- }
- }
- public void clientStart () {
- if (this.hasLevel() && this.getLevel().isClientSide()) this.client.setRenderable(true);
- }
- public void clientStop () {
- if (this.hasLevel() && this.getLevel().isClientSide()) this.client.setRenderable(false);
- }
- }
- package com.sforzando.worldsteel.client;
- public class SoulTrapClientData {
- private Item item;
- private boolean renderable;
- private int rotation = 0;
- private int oRotation = 0;
- public SoulTrapClientData (Item i, boolean b) {
- this.item = i;
- this.renderable = b;
- }
- public void tick () {
- this.oRotation = rotation;
- this.rotation += 10;
- }
- public void setRenderable (boolean b) {
- this.renderable = b;
- }
- public boolean isRenderable () {
- return this.renderable;
- }
- public void setItem (Item i) {
- this.item = i;
- }
- public Item getItem () {
- return this.item;
- }
- public int getRotation () {
- return this.rotation;
- }
- public int getORotation () {
- return this.oRotation;
- }
- }
- public class SoulTrapRenderer implements BlockEntityRenderer<SoulTrapBlockEntity> {
- private BlockEntityRendererFactory.Context context;
- public SoulTrapRenderer (BlockEntityRendererFactory.Context ctx) {
- this.context = ctx;
- }
- public void render (SoulTrapBlockEntity entity, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay) {
- if (!entity.getClientData().isRenderable()) return;
- matrices.push();
- matrices.translate(0.5F, 0.4F, 0.5F);
- matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(MathHelper.lerpAngleDegrees(tickDelta, context.getRotation(), context.getORotation())));
- this.context.getItemRenderer().renderItem(new ItemStack(entity.getClientData().getItem()), ModelTransformationMode.GROUND, light, overlay, matrices, vertexConsumers, entity.getWorld(), 0);
- matrices.pop();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement