diff --git a/winterly-common/build.gradle.kts b/winterly-common/build.gradle.kts index e7d4ea2..6d476fc 100644 --- a/winterly-common/build.gradle.kts +++ b/winterly-common/build.gradle.kts @@ -12,7 +12,4 @@ dependencies { // Do NOT use other classes from fabric loader modImplementation("net.fabricmc:fabric-loader:${rootProject.property("fabric_loader_version")}") modCompileOnly("me.shedaniel.cloth:cloth-config-fabric:${rootProject.property("cloth_config")}") { exclude("net.fabricmc.fabric-api") } - - // Remove the next line if you don't want to depend on the API - //modApi("dev.architectury:architectury:${rootProject.property("architectury_version")}") } diff --git a/winterly-common/src/main/java/ru/pinkgoosik/winterly/block/GiftBoxBlock.java b/winterly-common/src/main/java/ru/pinkgoosik/winterly/block/GiftBoxBlock.java index 5b984b8..f4d1dd3 100644 --- a/winterly-common/src/main/java/ru/pinkgoosik/winterly/block/GiftBoxBlock.java +++ b/winterly-common/src/main/java/ru/pinkgoosik/winterly/block/GiftBoxBlock.java @@ -1,16 +1,27 @@ package ru.pinkgoosik.winterly.block; +import net.minecraft.ChatFormatting; import net.minecraft.core.BlockPos; +import net.minecraft.core.component.DataComponentMap; +import net.minecraft.core.component.DataComponents; +import net.minecraft.core.registries.Registries; +import net.minecraft.locale.Language; +import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.Style; import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundSource; +import net.minecraft.tags.TagKey; import net.minecraft.world.InteractionHand; import net.minecraft.world.ItemInteractionResult; +import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.TooltipFlag; +import net.minecraft.world.item.component.CustomData; +import net.minecraft.world.item.enchantment.EnchantmentHelper; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; @@ -25,6 +36,7 @@ import ru.pinkgoosik.winterly.Winterly; import ru.pinkgoosik.winterly.block.entity.GiftBoxBlockEntity; import ru.pinkgoosik.winterly.block.entity.GiftBoxBlockEntityData; +import ru.pinkgoosik.winterly.data.GiftBoxData; import java.util.List; @@ -47,43 +59,49 @@ public VoxelShape getShape(BlockState state, BlockGetter world, BlockPos pos, Co return GiftBoxBlock.SHAPE; } -// @Override -// public void setPlacedBy(Level world, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack stack) { -// super.setPlacedBy(world, pos, state, placer, stack); -// -// if(world.getBlockEntity(pos) instanceof GiftBoxBlockEntityData entity) { -// entity.load(stack.getOrCreateTag()); -// } -// } - -// @Override -// public BlockState playerWillDestroy(Level world, BlockPos pos, BlockState state, Player player) { -// super.playerWillDestroy(world, pos, state, player); -// -// if(!world.isClientSide && world.getBlockEntity(pos) instanceof GiftBoxBlockEntityData entity) { -// ItemStack stack = player.getItemInHand(InteractionHand.MAIN_HAND); -// if(!EnchantmentHelper.getEnchantments(stack).containsKey(Enchantments.SILK_TOUCH)) { -// if(entity.getStacks().isEmpty()) { -// popResource(world, pos, new ItemStack(this.asItem())); -// } -// else { -// entity.getStacks().forEach(st -> popResource(world, pos, st)); -// } -// } -// else { -// ItemStack box = new ItemStack(this); -// -// if(!entity.getStacks().isEmpty()) { -// var nbt = new CompoundTag(); -// entity.saveAdditional(nbt); -// box.setTag(nbt); -// } -// popResource(world, pos, box); -// } -// } -// return state; -// } + @Override + public void setPlacedBy(Level world, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack stack) { + super.setPlacedBy(world, pos, state, placer, stack); + + if(world.getBlockEntity(pos) instanceof GiftBoxBlockEntityData entity && placer != null) { + if(stack.getComponents().has(DataComponents.CUSTOM_DATA)) { + entity.loadAdditional(stack.getComponents().get(DataComponents.CUSTOM_DATA).copyTag(), placer.registryAccess()); + } + } + } + + @Override + public BlockState playerWillDestroy(Level world, BlockPos pos, BlockState state, Player player) { + super.playerWillDestroy(world, pos, state, player); + + if(!world.isClientSide && world.getBlockEntity(pos) instanceof GiftBoxBlockEntityData entity) { + ItemStack stack = player.getItemInHand(InteractionHand.MAIN_HAND); + + + if(!EnchantmentHelper.hasTag(stack, TagKey.create(Registries.ENCHANTMENT, Winterly.id("gift_box_pickup")))) { + if(entity.getStacks().isEmpty()) { + popResource(world, pos, new ItemStack(this.asItem())); + } + else { + entity.getStacks().forEach(st -> popResource(world, pos, st)); + } + } + else { + ItemStack box = new ItemStack(this); + + if(!entity.getStacks().isEmpty()) { + var nbt = new CompoundTag(); + entity.saveAdditional(nbt, player.registryAccess()); + box.applyComponents(DataComponentMap.builder().set(DataComponents.CUSTOM_DATA, CustomData.of(nbt)).build()); + } + popResource(world, pos, box); + } + + + } + return state; + } @Override protected ItemInteractionResult useItemOn(ItemStack stack, BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hitResult) { @@ -96,6 +114,7 @@ protected ItemInteractionResult useItemOn(ItemStack stack, BlockState state, Lev } } entity.getStacks().add(stack.copy()); + ((BlockEntity)entity).setChanged(); player.setItemInHand(hand, ItemStack.EMPTY); level.playSound(null, pos, SoundEvents.BUNDLE_INSERT, SoundSource.BLOCKS, 1, 1); return ItemInteractionResult.SUCCESS; @@ -105,29 +124,36 @@ protected ItemInteractionResult useItemOn(ItemStack stack, BlockState state, Lev } @Override - public void appendHoverText(ItemStack stack, Item.TooltipContext context, List tooltipComponents, TooltipFlag tooltipFlag) { - super.appendHoverText(stack, context, tooltipComponents, tooltipFlag); - -// if(stack.getOrCreateTag().contains("giftBoxData")) { -// var gift = GiftBoxData.fromNbt(stack.getOrCreateTag().getCompound("giftBoxData")); -// -// gift.stacks.forEach(st -> { -// String name = Language.getInstance().getOrDefault(st.getDescriptionId()); -// tooltip.add(Component.nullToEmpty("- " + name + " x" + st.getCount()).toFlatList(Style.EMPTY.withColor(ChatFormatting.GRAY)).get(0)); -// }); -// } -// else { -// Language lang = Language.getInstance(); -// String key = "description.winterly.gift_box."; -// -// for(int i = 0; i <= 32; i++) { -// if(lang.has(key + i)) { -// tooltip.add(Component.translatable(key + i).toFlatList(Style.EMPTY.withColor(ChatFormatting.GRAY)).get(0)); -// } -// if(!lang.has(key + (i + 1))) { -// break; -// } -// } -// } + public void appendHoverText(ItemStack stack, Item.TooltipContext context, List tooltip, TooltipFlag tooltipFlag) { + super.appendHoverText(stack, context, tooltip, tooltipFlag); + + + if(stack.getComponents().has(DataComponents.CUSTOM_DATA)) { + var tag = stack.getComponents().get(DataComponents.CUSTOM_DATA).copyTag(); + + if(tag.contains("giftBoxData")) { + var gift = GiftBoxData.fromNbt(tag.getCompound("giftBoxData"), context.registries()); + + gift.stacks.forEach(st -> { + String name = Language.getInstance().getOrDefault(st.getDescriptionId()); + tooltip.add(Component.nullToEmpty("- " + name + " x" + st.getCount()).toFlatList(Style.EMPTY.withColor(ChatFormatting.GRAY)).get(0)); + }); + return; + } + + } + + Language lang = Language.getInstance(); + String key = "description.winterly.gift_box."; + + for(int i = 0; i <= 32; i++) { + if(lang.has(key + i)) { + tooltip.add(Component.translatable(key + i).toFlatList(Style.EMPTY.withColor(ChatFormatting.GRAY)).get(0)); + } + if(!lang.has(key + (i + 1))) { + break; + } + } + } } diff --git a/winterly-common/src/main/java/ru/pinkgoosik/winterly/block/entity/GiftBoxBlockEntity.java b/winterly-common/src/main/java/ru/pinkgoosik/winterly/block/entity/GiftBoxBlockEntity.java index 783d13d..f8978de 100644 --- a/winterly-common/src/main/java/ru/pinkgoosik/winterly/block/entity/GiftBoxBlockEntity.java +++ b/winterly-common/src/main/java/ru/pinkgoosik/winterly/block/entity/GiftBoxBlockEntity.java @@ -27,13 +27,13 @@ public ArrayList getStacks() { @Override public void saveAdditional(CompoundTag tag, HolderLookup.Provider registries) { super.saveAdditional(tag, registries); - tag.put("giftBoxData", GiftBoxData.toNbt(this)); + tag.put("giftBoxData", GiftBoxData.toNbt(this, registries)); } @Override public void loadAdditional(CompoundTag tag, HolderLookup.Provider registries) { super.loadAdditional(tag, registries); - var data = GiftBoxData.fromNbt(tag.getCompound("giftBoxData")); + var data = GiftBoxData.fromNbt(tag.getCompound("giftBoxData"), registries); this.stacks = data.stacks; } diff --git a/winterly-common/src/main/java/ru/pinkgoosik/winterly/data/GiftBoxData.java b/winterly-common/src/main/java/ru/pinkgoosik/winterly/data/GiftBoxData.java index a03a708..21af1c2 100644 --- a/winterly-common/src/main/java/ru/pinkgoosik/winterly/data/GiftBoxData.java +++ b/winterly-common/src/main/java/ru/pinkgoosik/winterly/data/GiftBoxData.java @@ -1,55 +1,38 @@ package ru.pinkgoosik.winterly.data; -import net.minecraft.core.component.DataComponentMap; -import net.minecraft.core.component.DataComponents; -import net.minecraft.world.item.component.CustomData; +import net.minecraft.core.HolderLookup; import java.util.ArrayList; -import net.minecraft.core.registries.BuiltInRegistries; +import java.util.Optional; + import net.minecraft.nbt.CompoundTag; -import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; import ru.pinkgoosik.winterly.block.entity.GiftBoxBlockEntityData; public class GiftBoxData { public ArrayList stacks = new ArrayList<>(); - public static GiftBoxData fromNbt(CompoundTag nbt) { + public static GiftBoxData fromNbt(CompoundTag nbt, HolderLookup.Provider registries) { GiftBoxData gift = new GiftBoxData(); int size = nbt.getInt("size"); for(int i = 0; i < size; i++) { CompoundTag entryNbt = nbt.getCompound(String.valueOf(i)); - - var item = BuiltInRegistries.ITEM.getOptional(ResourceLocation.parse(entryNbt.getString("item"))); - if(item.isPresent()) { - ItemStack temp = new ItemStack(item.get(), entryNbt.getInt("count")); - - if(entryNbt.contains("nbt")) { - temp.applyComponents(DataComponentMap.builder().set(DataComponents.CUSTOM_DATA, CustomData.of((CompoundTag) entryNbt.get("nbt"))).build()); - } - - gift.stacks.add(temp); - } + Optional stack = ItemStack.parse(registries, entryNbt.getCompound("itemstack")); + stack.ifPresent(itemStack -> gift.stacks.add(itemStack)); } return gift; } - public static CompoundTag toNbt(GiftBoxBlockEntityData entity) { + public static CompoundTag toNbt(GiftBoxBlockEntityData entity, HolderLookup.Provider registries) { CompoundTag nbt = new CompoundTag(); nbt.putInt("size", entity.getStacks().size()); for(int i = 0; i < entity.getStacks().size(); i++) { ItemStack stack = entity.getStacks().get(i); CompoundTag entryNbt = new CompoundTag(); - entryNbt.putString("item", BuiltInRegistries.ITEM.getKey(stack.getItem()).toString()); - - if(stack.getComponents().has(DataComponents.CUSTOM_DATA)) { - entryNbt.put("nbt", stack.getComponents().get(DataComponents.CUSTOM_DATA).copyTag()); - } - - entryNbt.putInt("count", stack.getCount()); + entryNbt.put("itemstack", stack.save(registries)); nbt.put(Integer.toString(i), entryNbt); } diff --git a/winterly-common/src/main/java/ru/pinkgoosik/winterly/registry/CommonWinterlyBlocks.java b/winterly-common/src/main/java/ru/pinkgoosik/winterly/registry/CommonWinterlyBlocks.java index 715395e..f161f04 100644 --- a/winterly-common/src/main/java/ru/pinkgoosik/winterly/registry/CommonWinterlyBlocks.java +++ b/winterly-common/src/main/java/ru/pinkgoosik/winterly/registry/CommonWinterlyBlocks.java @@ -1,72 +1,26 @@ package ru.pinkgoosik.winterly.registry; import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.item.BlockItem; -import net.minecraft.world.item.Item; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockBehaviour; import ru.pinkgoosik.winterly.Winterly; -import net.minecraft.core.Registry; -import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.world.item.BlockItem; -import net.minecraft.world.item.Item; import net.minecraft.world.level.block.*; -import net.minecraft.world.level.block.state.BlockBehaviour; -import net.minecraft.world.level.material.MapColor; import net.minecraft.world.level.material.PushReaction; -import ru.pinkgoosik.winterly.Winterly; import ru.pinkgoosik.winterly.block.*; import ru.pinkgoosik.winterly.block.base.BasePaneBlock; import ru.pinkgoosik.winterly.block.base.BaseStairsBlock; import ru.pinkgoosik.winterly.block.base.BaseTransparentBlock; import static net.minecraft.world.level.block.Blocks.*; -import static ru.pinkgoosik.winterly.registry.CommonWinterlyBlocks.*; import java.util.LinkedHashMap; import java.util.Map; -import java.util.function.Function; -import java.util.function.Predicate; import java.util.function.Supplier; @SuppressWarnings("unused") public abstract class CommonWinterlyBlocks { -// public static final Map> ITEMS = new LinkedHashMap<>(); public static final Map> BLOCKS = new LinkedHashMap<>(); -// public static final Block RED_SOCK = add("red_sock", new SockBlock(copyOf(CANDLE).sounds(BlockSoundGroup.WOOL))); -// public static final Block GREEN_SOCK = add("green_sock", new SockBlock(copyOf(CANDLE).sounds(BlockSoundGroup.WOOL))); -// public static final Block BLUE_SOCK = add("blue_sock", new SockBlock(copyOf(CANDLE).sounds(BlockSoundGroup.WOOL))); -// -// public static Block ICICLE = add("icicle", new IcicleBlock(copyOf(ICE).pushReaction(PushReaction.DESTROY))); -// public static Block ICICLE_BLOCK = add("icicle_block", new BaseTransparentBlock(copyOf(PACKED_ICE).noOcclusion())); -// public static Block PACKED_ICICLE_BLOCK = add("packed_icicle_block", new BaseTransparentBlock(copyOf(PACKED_ICE).noOcclusion())); -// public static Block ICICLE_PANE = add("icicle_pane", new BasePaneBlock(copyOf(PACKED_ICE).noOcclusion())); -// public static Block ICICLE_BARS = add("icicle_bars", new BasePaneBlock(copyOf(ICE).noOcclusion())); -// public static Block CRYOMARBLE_BLOCK = add("cryomarble_block", new Block(copyOf(DIAMOND_BLOCK))); -// public static Block SNOWGUY = add("snowguy", new SnowguyBlock(copyOf(WHITE_WOOL).sound(SoundType.SNOW))); -// public static Block SNOWBALL_WALL = add("snowball_wall", new SnowballWallBlock(copyOf(WHITE_WOOL).sound(SoundType.SNOW).noOcclusion())); -// public static Block DENSE_SNOW = add("dense_snow", new Block(copyOf(WHITE_WOOL).sound(SoundType.SNOW))); -// public static Block DENSE_SNOW_STAIRS = add("dense_snow_stairs", new BaseStairsBlock(SNOW_BLOCK.defaultBlockState(), copyOf(WHITE_WOOL).sound(SoundType.SNOW))); -// public static Block DENSE_SNOW_SLAB = add("dense_snow_slab", new SlabBlock(copyOf(WHITE_WOOL).sound(SoundType.SNOW))); -// public static Block SNOW_BRICKS = add("snow_bricks", new Block(copyOf(WHITE_WOOL).sound(SoundType.SNOW))); -// public static Block SNOW_BRICK_STAIRS = add("snow_brick_stairs", new BaseStairsBlock(SNOW_BLOCK.defaultBlockState(), copyOf(WHITE_WOOL).sound(SoundType.SNOW))); -// public static Block SNOW_BRICK_SLAB = add("snow_brick_slab", new SlabBlock(copyOf(WHITE_WOOL).sound(SoundType.SNOW))); -// public static Block FROZEN_GRASS; -// public static Block FROZEN_FLOWER; -// public static Block RAW_CRYOMARBLE_SHARD = add("raw_cryomarble_shard", new IcicleBlock(copyOf(WHITE_WOOL).sound(SoundType.GLASS).lightLevel(state -> 12))); -// public static Block RED_GIFT_BOX = add("red_gift_box", new GiftBoxBlock(copyOf(RED_WOOL).pushReaction(PushReaction.DESTROY))); -// public static Block ORANGE_GIFT_BOX = add("orange_gift_box", new GiftBoxBlock(copyOf(RED_GIFT_BOX))); -// public static Block YELLOW_GIFT_BOX = add("yellow_gift_box", new GiftBoxBlock(copyOf(RED_GIFT_BOX))); -// public static Block GREEN_GIFT_BOX = add("green_gift_box", new GiftBoxBlock(copyOf(RED_GIFT_BOX))); -// public static Block CYAN_GIFT_BOX = add("cyan_gift_box", new GiftBoxBlock(copyOf(RED_GIFT_BOX))); -// public static Block BLUE_GIFT_BOX = add("blue_gift_box", new GiftBoxBlock(copyOf(RED_GIFT_BOX))); -// public static Block PURPLE_GIFT_BOX = add("purple_gift_box", new GiftBoxBlock(copyOf(RED_GIFT_BOX))); -// public static Block BLACK_GIFT_BOX = add("black_gift_box", new GiftBoxBlock(copyOf(RED_GIFT_BOX))); -// public static Block WHITE_GIFT_BOX = add("white_gift_box", new GiftBoxBlock(copyOf(RED_GIFT_BOX))); -// public static Block GARLAND_LIGHTS = add("garland_lights", new GarlandLightsBlock(copyOf(GREEN_WOOL).pushReaction(PushReaction.DESTROY).noCollission().sound(SoundType.CANDLE))); -// public static Block RAINY_GARLAND_LIGHTS = add("rainy_garland_lights", new GarlandLightsBlock(copyOf(WHITE_WOOL).pushReaction(PushReaction.DESTROY).noCollission().sound(SoundType.CANDLE))); - public static void init() { add("icicle", () -> new IcicleBlock(copyOf(ICE).pushReaction(PushReaction.DESTROY))); add("icicle_block", () -> new BaseTransparentBlock(copyOf(PACKED_ICE).noOcclusion())); @@ -100,20 +54,6 @@ public static void add(String name, Supplier block) { BLOCKS.put(Winterly.id(name), block); } -// public static T addBlockItem(String name, T block, BlockItem item) { -// addBlock(name, block); -// if (item != null) { -// item.registerBlocks(Item.BY_BLOCK, item); -// ITEMS.put(Winterly.id(name), item); -// } -// return block; -// } -// -// public static T addBlock(String name, T block) { -// BLOCKS.put(Winterly.id(name), block); -// return block; -// } - public static BlockBehaviour.Properties copyOf(Block block) { return BlockBehaviour.Properties.ofFullCopy(block); } diff --git a/winterly-common/src/main/java/ru/pinkgoosik/winterly/registry/CommonWinterlyItems.java b/winterly-common/src/main/java/ru/pinkgoosik/winterly/registry/CommonWinterlyItems.java index f1a0e06..6fdf0bc 100644 --- a/winterly-common/src/main/java/ru/pinkgoosik/winterly/registry/CommonWinterlyItems.java +++ b/winterly-common/src/main/java/ru/pinkgoosik/winterly/registry/CommonWinterlyItems.java @@ -2,8 +2,7 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.world.food.FoodProperties; -import net.minecraft.world.item.Item; -import net.minecraft.world.item.Tiers; +import net.minecraft.world.item.*; import ru.pinkgoosik.winterly.Winterly; import ru.pinkgoosik.winterly.item.tool.*; @@ -16,22 +15,22 @@ public class CommonWinterlyItems { public static final Map> ITEMS = new LinkedHashMap<>(); public static void init() { - add("red_candy_cane", () -> new Item(settings().food(new FoodProperties.Builder().nutrition(2).saturationModifier(0.1F).fast().build()))); - add("green_candy_cane", () -> new Item(settings().food(new FoodProperties.Builder().nutrition(2).saturationModifier(0.1F).fast().build()))); - add("blue_candy_cane", () -> new Item(settings().food(new FoodProperties.Builder().nutrition(2).saturationModifier(0.1F).fast().build()))); + add("red_candy_cane", () -> new Item(properties().food(new FoodProperties.Builder().nutrition(2).saturationModifier(0.1F).fast().build()))); + add("green_candy_cane", () -> new Item(properties().food(new FoodProperties.Builder().nutrition(2).saturationModifier(0.1F).fast().build()))); + add("blue_candy_cane", () -> new Item(properties().food(new FoodProperties.Builder().nutrition(2).saturationModifier(0.1F).fast().build()))); - add("cryomarble_shard", () -> new Item(settings())); - add("cryomarble", () -> new Item(settings())); + add("cryomarble_shard", () -> new Item(properties())); + add("cryomarble", () -> new Item(properties())); - add("cryomarble_sword", () -> new CryomarbleSwordItem(Tiers.DIAMOND, settings())); - add("cryomarble_shovel", () -> new CryomarbleShovelItem(Tiers.DIAMOND, settings())); - add("cryomarble_pickaxe", () -> new CryomarblePickaxeItem(Tiers.DIAMOND, settings())); + add("cryomarble_sword", () -> new CryomarbleSwordItem(Tiers.DIAMOND, properties().attributes(SwordItem.createAttributes(Tiers.DIAMOND, 3, -2.4F)))); + add("cryomarble_shovel", () -> new CryomarbleShovelItem(Tiers.DIAMOND, properties().attributes(ShovelItem.createAttributes(Tiers.DIAMOND, 1.5F, -3.0F)))); + add("cryomarble_pickaxe", () -> new CryomarblePickaxeItem(Tiers.DIAMOND, properties().attributes(PickaxeItem.createAttributes(Tiers.DIAMOND, 1.0F, -2.8F)))); - add("cryomarble_axe", () -> new CryomarbleAxeItem(Tiers.DIAMOND, settings())); - add("cryomarble_hoe", () -> new CryomarbleHoeItem(Tiers.DIAMOND, settings())); + add("cryomarble_axe", () -> new CryomarbleAxeItem(Tiers.DIAMOND, properties().attributes(AxeItem.createAttributes(Tiers.DIAMOND, 5.0F, -3.0F)))); + add("cryomarble_hoe", () -> new CryomarbleHoeItem(Tiers.DIAMOND, properties().attributes(HoeItem.createAttributes(Tiers.DIAMOND, -3.0F, 0.0F)))); } - public static Item.Properties settings() { + public static Item.Properties properties() { return new Item.Properties(); } diff --git a/winterly-common/src/main/resources/assets/winterly/lang/en_us.json b/winterly-common/src/main/resources/assets/winterly/lang/en_us.json index cc0312d..cec70ac 100644 --- a/winterly-common/src/main/resources/assets/winterly/lang/en_us.json +++ b/winterly-common/src/main/resources/assets/winterly/lang/en_us.json @@ -11,6 +11,11 @@ "tip.winterly.requires_curios.0": "Requires Curios API to be installed", "tip.winterly.requires_curios.1": "in order to be wearable.", + "tag.item.winterly.candy_canes": "Candy Canes", + "tag.item.winterly.scarfs": "Scarfs", + "tag.block.winterly.gift_boxes": "Gift Boxes", + "tag.enchantment.winterly.gift_box_pickup": "Gift Box Pickup", + "item.winterly.red_candy_cane": "Red Candy Cane", "item.winterly.green_candy_cane": "Green Candy Cane", "item.winterly.blue_candy_cane": "Blue Candy Cane", diff --git a/winterly-common/src/main/resources/assets/winterly/lang/ru_ru.json b/winterly-common/src/main/resources/assets/winterly/lang/ru_ru.json index 1f79440..a70c5cc 100644 --- a/winterly-common/src/main/resources/assets/winterly/lang/ru_ru.json +++ b/winterly-common/src/main/resources/assets/winterly/lang/ru_ru.json @@ -11,6 +11,11 @@ "tip.winterly.requires_curios.0": "Для ношения требуется", "tip.winterly.requires_curios.1": "установка мода Curios API.", + "tag.item.winterly.candy_canes": "Candy Canes", + "tag.item.winterly.scarfs": "Scarfs", + "tag.block.winterly.gift_boxes": "Gift Boxes", + "tag.enchantment.winterly.gift_box_pickup": "Gift Box Pickup", + "item.winterly.red_candy_cane": "Красный леденец", "item.winterly.green_candy_cane": "Зеленый леденец", "item.winterly.blue_candy_cane": "Синий леденец", diff --git a/winterly-common/src/main/resources/assets/winterly/lang/zh_cn.json b/winterly-common/src/main/resources/assets/winterly/lang/zh_cn.json index 117c243..877ea22 100644 --- a/winterly-common/src/main/resources/assets/winterly/lang/zh_cn.json +++ b/winterly-common/src/main/resources/assets/winterly/lang/zh_cn.json @@ -11,6 +11,11 @@ "tip.winterly.requires_curios.0": "Requires Curios API to be installed", "tip.winterly.requires_curios.1": "in order to be wearable.", + "tag.item.winterly.candy_canes": "Candy Canes", + "tag.item.winterly.scarfs": "Scarfs", + "tag.block.winterly.gift_boxes": "Gift Boxes", + "tag.enchantment.winterly.gift_box_pickup": "Gift Box Pickup", + "item.winterly.red_candy_cane": "红色条纹拐杖糖", "item.winterly.green_candy_cane": "绿色条纹拐杖糖", "item.winterly.blue_candy_cane": "蓝色条纹拐杖糖", diff --git a/winterly-common/src/main/resources/data/minecraft/tags/item/axes.json b/winterly-common/src/main/resources/data/minecraft/tags/item/axes.json new file mode 100644 index 0000000..c5796bc --- /dev/null +++ b/winterly-common/src/main/resources/data/minecraft/tags/item/axes.json @@ -0,0 +1,6 @@ +{ + "replace": false, + "values": [ + "winterly:cryomarble_axe" + ] +} diff --git a/winterly-common/src/main/resources/data/minecraft/tags/item/hoes.json b/winterly-common/src/main/resources/data/minecraft/tags/item/hoes.json new file mode 100644 index 0000000..b77215b --- /dev/null +++ b/winterly-common/src/main/resources/data/minecraft/tags/item/hoes.json @@ -0,0 +1,6 @@ +{ + "replace": false, + "values": [ + "winterly:cryomarble_hoe" + ] +} diff --git a/winterly-common/src/main/resources/data/minecraft/tags/item/pickaxes.json b/winterly-common/src/main/resources/data/minecraft/tags/item/pickaxes.json new file mode 100644 index 0000000..b64de37 --- /dev/null +++ b/winterly-common/src/main/resources/data/minecraft/tags/item/pickaxes.json @@ -0,0 +1,6 @@ +{ + "replace": false, + "values": [ + "winterly:cryomarble_pickaxe" + ] +} diff --git a/winterly-common/src/main/resources/data/minecraft/tags/item/shovels.json b/winterly-common/src/main/resources/data/minecraft/tags/item/shovels.json new file mode 100644 index 0000000..694aaf5 --- /dev/null +++ b/winterly-common/src/main/resources/data/minecraft/tags/item/shovels.json @@ -0,0 +1,6 @@ +{ + "replace": false, + "values": [ + "winterly:cryomarble_shovel" + ] +} diff --git a/winterly-common/src/main/resources/data/minecraft/tags/item/swords.json b/winterly-common/src/main/resources/data/minecraft/tags/item/swords.json new file mode 100644 index 0000000..47af569 --- /dev/null +++ b/winterly-common/src/main/resources/data/minecraft/tags/item/swords.json @@ -0,0 +1,6 @@ +{ + "replace": false, + "values": [ + "winterly:cryomarble_sword" + ] +} diff --git a/winterly-common/src/main/resources/data/winterly/tags/block/gift_boxes.json b/winterly-common/src/main/resources/data/winterly/tags/block/gift_boxes.json index a356179..102f16d 100644 --- a/winterly-common/src/main/resources/data/winterly/tags/block/gift_boxes.json +++ b/winterly-common/src/main/resources/data/winterly/tags/block/gift_boxes.json @@ -3,11 +3,11 @@ "winterly:blue_gift_box", "winterly:red_gift_box", "winterly:green_gift_box", - "winterly:purple_gift_box", - "winterly:yellow_gift_box", - "winterly:black_gift_box", - "winterly:white_gift_box", - "winterly:cyan_gift_box", - "winterly:orange_gift_box" + "winterly:purple_gift_box", + "winterly:yellow_gift_box", + "winterly:black_gift_box", + "winterly:white_gift_box", + "winterly:cyan_gift_box", + "winterly:orange_gift_box" ] } diff --git a/winterly-common/src/main/resources/data/winterly/tags/enchantment/gift_box_pickup.json b/winterly-common/src/main/resources/data/winterly/tags/enchantment/gift_box_pickup.json new file mode 100644 index 0000000..9114b74 --- /dev/null +++ b/winterly-common/src/main/resources/data/winterly/tags/enchantment/gift_box_pickup.json @@ -0,0 +1,5 @@ +{ + "values": [ + "minecraft:silk_touch" + ] +} diff --git a/winterly-fabric/build.gradle.kts b/winterly-fabric/build.gradle.kts index a250cb5..d5dcf53 100644 --- a/winterly-fabric/build.gradle.kts +++ b/winterly-fabric/build.gradle.kts @@ -37,9 +37,6 @@ dependencies { modImplementation("net.fabricmc:fabric-loader:${rootProject.property("fabric_loader_version")}") modApi("net.fabricmc.fabric-api:fabric-api:${rootProject.property("fabric_api_version")}") - // Remove the next line if you don't want to depend on the API - //modApi("dev.architectury:architectury-fabric:${rootProject.property("architectury_version")}") - modCompileOnly("dev.emi:trinkets:${rootProject.property("trinkets_version")}") modImplementation("dev.onyxstudios.cardinal-components-api:cardinal-components-entity:${rootProject.property("cca_version")}") @@ -48,12 +45,12 @@ dependencies { modImplementation("dev.onyxstudios.cardinal-components-api:cardinal-components-world:${rootProject.property("cca_version")}") include("dev.onyxstudios.cardinal-components-api:cardinal-components-world:${rootProject.property("cca_version")}") - modCompileOnly("io.wispforest:owo-lib:${rootProject.property("owo_lib")}") + modApi("io.wispforest:owo-lib:${rootProject.property("owo_lib")}") modApi("me.shedaniel.cloth:cloth-config-fabric:${rootProject.property("cloth_config")}") { exclude("net.fabricmc.fabric-api") } modApi("com.terraformersmc:modmenu:${rootProject.property("modmenu_version")}") //modLocalRuntime "maven.modrinth:here-be-no-dragons:1.0.0" - //modLocalRuntime "dev.emi:emi-fabric:1.0.29+1.20.4" + modLocalRuntime("dev.emi:emi-fabric:1.1.10+1.21") common(project(":winterly-common", configuration = "namedElements")) { isTransitive = false } shadowCommon(project(":winterly-common", configuration = "transformProductionFabric")) { isTransitive = false } diff --git a/winterly-fabric/src/main/java/ru/pinkgoosik/winterly/fabric/registry/WinterlyItems.java b/winterly-fabric/src/main/java/ru/pinkgoosik/winterly/fabric/registry/WinterlyItems.java index bea58db..4683b22 100644 --- a/winterly-fabric/src/main/java/ru/pinkgoosik/winterly/fabric/registry/WinterlyItems.java +++ b/winterly-fabric/src/main/java/ru/pinkgoosik/winterly/fabric/registry/WinterlyItems.java @@ -2,13 +2,8 @@ import net.minecraft.core.Registry; import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.world.food.FoodProperties; -import net.minecraft.world.item.Item; -import net.minecraft.world.item.Tiers; import ru.pinkgoosik.winterly.fabric.item.SantaHatItem; import ru.pinkgoosik.winterly.fabric.item.ScarfItem; -import ru.pinkgoosik.winterly.Winterly; -import ru.pinkgoosik.winterly.item.tool.*; import ru.pinkgoosik.winterly.registry.CommonWinterlyItems; import static ru.pinkgoosik.winterly.registry.CommonWinterlyItems.*; @@ -18,27 +13,14 @@ public class WinterlyItems { public static void init() { CommonWinterlyItems.init(); -// RED_CANDY_CANE = add("red_candy_cane", new Item(settings().food(new FoodProperties.Builder().nutrition(2).saturationModifier(0.1F).fast().build()))); -// GREEN_CANDY_CANE = add("green_candy_cane", new Item(settings().food(new FoodProperties.Builder().nutrition(2).saturationModifier(0.1F).fast().build()))); -// BLUE_CANDY_CANE = add("blue_candy_cane", new Item(settings().food(new FoodProperties.Builder().nutrition(2).saturationModifier(0.1F).fast().build()))); -// -// CRYOMARBLE_SHARD = add("cryomarble_shard", new Item(settings())); -// CRYOMARBLE = add("cryomarble", new Item(settings())); -// -// CRYOMARBLE_SWORD = add("cryomarble_sword", new CryomarbleSwordItem(Tiers.DIAMOND, settings())); -// CRYOMARBLE_SHOVEL = add("cryomarble_shovel", new CryomarbleShovelItem(Tiers.DIAMOND, settings())); -// CRYOMARBLE_PICKAXE = add("cryomarble_pickaxe", new CryomarblePickaxeItem(Tiers.DIAMOND, settings())); -// CRYOMARBLE_AXE = add("cryomarble_axe", new CryomarbleAxeItem(Tiers.DIAMOND, settings())); -// CRYOMARBLE_HOE = add("cryomarble_hoe", new CryomarbleHoeItem(Tiers.DIAMOND, settings())); -// - add("red_santa_hat", () -> new SantaHatItem(settings(), "red")); - add("blue_santa_hat", () -> new SantaHatItem(settings(), "blue")); + add("red_santa_hat", () -> new SantaHatItem(properties(), "red")); + add("blue_santa_hat", () -> new SantaHatItem(properties(), "blue")); - add("white_scarf", () -> new ScarfItem(settings(), "white")); - add("red_scarf", () -> new ScarfItem(settings(), "red")); - add("green_scarf", () -> new ScarfItem(settings(), "green")); - add("blue_scarf", () -> new ScarfItem(settings(), "blue")); - add("rainbow_scarf", () -> new ScarfItem(settings(), "rainbow")); + add("white_scarf", () -> new ScarfItem(properties(), "white")); + add("red_scarf", () -> new ScarfItem(properties(), "red")); + add("green_scarf", () -> new ScarfItem(properties(), "green")); + add("blue_scarf", () -> new ScarfItem(properties(), "blue")); + add("rainbow_scarf", () -> new ScarfItem(properties(), "rainbow")); ITEMS.forEach((id, sup) -> Registry.register(BuiltInRegistries.ITEM, id, sup.get())); } diff --git a/winterly-neoforge/build.gradle.kts b/winterly-neoforge/build.gradle.kts index 1672ef4..450d7b7 100644 --- a/winterly-neoforge/build.gradle.kts +++ b/winterly-neoforge/build.gradle.kts @@ -26,20 +26,20 @@ configurations { repositories { maven { url = uri("https://maven.theillusivec4.top/") } maven { url = uri("https://maven.shedaniel.me/") } + maven { url = uri("https://maven.terraformersmc.com") } } dependencies { neoForge("net.neoforged:neoforge:${rootProject.property("neoforge_version")}") - // Remove the next line if you don't want to depend on the API - //modApi("dev.architectury:architectury-fabric:${rootProject.property("architectury_version")}") - modCompileOnly("top.theillusivec4.curios:curios-neoforge:${rootProject.property("curios_version")}:api") // Use the full Curios API jar at runtime modCompileOnly("top.theillusivec4.curios:curios-neoforge:${rootProject.property("curios_version")}") modApi("me.shedaniel.cloth:cloth-config-neoforge:${rootProject.property("cloth_config")}") + modLocalRuntime("dev.emi:emi-neoforge:1.1.10+1.21") + common(project(":winterly-common", configuration = "namedElements")) { isTransitive = false } shadowCommon(project(":winterly-common", configuration = "transformProductionNeoForge")) { isTransitive = false } } diff --git a/winterly-neoforge/src/main/java/ru/pinkgoosik/winterly/neoforge/WinterlyNeoforge.java b/winterly-neoforge/src/main/java/ru/pinkgoosik/winterly/neoforge/WinterlyNeoforge.java index d717323..66fc7e2 100644 --- a/winterly-neoforge/src/main/java/ru/pinkgoosik/winterly/neoforge/WinterlyNeoforge.java +++ b/winterly-neoforge/src/main/java/ru/pinkgoosik/winterly/neoforge/WinterlyNeoforge.java @@ -1,19 +1,16 @@ package ru.pinkgoosik.winterly.neoforge; -import net.minecraft.core.component.DataComponents; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.Registries; import net.minecraft.network.chat.Component; import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.CreativeModeTab; import net.minecraft.world.item.Item; -import net.minecraft.world.item.Items; import net.neoforged.bus.api.IEventBus; import net.neoforged.fml.common.Mod; import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent; import net.neoforged.fml.loading.FMLEnvironment; import net.neoforged.neoforge.event.BuildCreativeModeTabContentsEvent; -import net.neoforged.neoforge.event.ModifyDefaultComponentsEvent; import net.neoforged.neoforge.registries.RegisterEvent; import ru.pinkgoosik.winterly.neoforge.client.WinterlyNeoforgeClient; import ru.pinkgoosik.winterly.neoforge.data.WinterlyDataAttachments; @@ -38,27 +35,12 @@ public WinterlyNeoforge(IEventBus bus) { bus.addListener(this::register); bus.addListener(this::buildCreativeTab); bus.addListener(this::commonSetup); - bus.addListener(this::modifyComponents); if(FMLEnvironment.dist.isClient()) { WinterlyNeoforgeClient.init(bus); } } - // Listened to on the mod event bus - public void modifyComponents(ModifyDefaultComponentsEvent event) { - // Sets the component on melon seeds -// event.modify(Items.MELON_SEEDS, builder -> -// builder.set(DataComponents.CAN_BREAK) -// ); - - // Removes the component for any items that have a crafting item - event.modifyMatching( - item -> item.hasCraftingRemainingItem(), - builder -> builder.remove(DataComponents.BUCKET_ENTITY_DATA) - ); - } - public void register(RegisterEvent event) { WinterlyItems.init(); WinterlyBlocks.init(); @@ -67,21 +49,10 @@ public void register(RegisterEvent event) { registry.register(Winterly.id("items"), CreativeModeTab.builder().icon(BuiltInRegistries.ITEM.get(Winterly.id("snowguy"))::getDefaultInstance).title(Component.translatable("itemGroup.winterly.items")).build()); }); - event.register(Registries.ITEM, registry -> { - ITEMS.forEach((id, sup) -> registry.register(id, sup.get())); - }); - - event.register(Registries.BLOCK, registry -> { - CommonWinterlyBlocks.BLOCKS.forEach((id, sup) -> registry.register(id, sup.get())); - }); - - event.register(Registries.ITEM, registry -> { - CommonWinterlyBlocks.BLOCKS.forEach((id, sup) -> registry.register(id, new BlockItem(BuiltInRegistries.BLOCK.get(id), new Item.Properties()))); - }); - - event.register(Registries.BLOCK_ENTITY_TYPE, registry -> { - WinterlyBlockEntities.init(registry); - }); + event.register(Registries.ITEM, registry -> ITEMS.forEach((id, sup) -> registry.register(id, sup.get()))); + event.register(Registries.BLOCK, registry -> CommonWinterlyBlocks.BLOCKS.forEach((id, sup) -> registry.register(id, sup.get()))); + event.register(Registries.ITEM, registry -> CommonWinterlyBlocks.BLOCKS.forEach((id, sup) -> registry.register(id, new BlockItem(BuiltInRegistries.BLOCK.get(id), new Item.Properties())))); + event.register(Registries.BLOCK_ENTITY_TYPE, WinterlyBlockEntities::init); } private void buildCreativeTab(BuildCreativeModeTabContentsEvent event) { diff --git a/winterly-neoforge/src/main/java/ru/pinkgoosik/winterly/neoforge/block/BaseTransparentBlock.java b/winterly-neoforge/src/main/java/ru/pinkgoosik/winterly/neoforge/block/BaseTransparentBlock.java deleted file mode 100644 index 64a413c..0000000 --- a/winterly-neoforge/src/main/java/ru/pinkgoosik/winterly/neoforge/block/BaseTransparentBlock.java +++ /dev/null @@ -1,10 +0,0 @@ -package ru.pinkgoosik.winterly.neoforge.block; - -import net.minecraft.world.level.block.TransparentBlock; - -public class BaseTransparentBlock extends TransparentBlock { - - public BaseTransparentBlock(Properties arg) { - super(arg); - } -} diff --git a/winterly-neoforge/src/main/java/ru/pinkgoosik/winterly/neoforge/item/SantaHatItem.java b/winterly-neoforge/src/main/java/ru/pinkgoosik/winterly/neoforge/item/SantaHatItem.java index 5ca46fb..b210672 100644 --- a/winterly-neoforge/src/main/java/ru/pinkgoosik/winterly/neoforge/item/SantaHatItem.java +++ b/winterly-neoforge/src/main/java/ru/pinkgoosik/winterly/neoforge/item/SantaHatItem.java @@ -13,6 +13,7 @@ import java.util.List; +@SuppressWarnings("NullableProblems") public class SantaHatItem extends CommonSantaHatItem { public SantaHatItem(Item.Properties settings, String color) { diff --git a/winterly-neoforge/src/main/java/ru/pinkgoosik/winterly/neoforge/registry/WinterlyItems.java b/winterly-neoforge/src/main/java/ru/pinkgoosik/winterly/neoforge/registry/WinterlyItems.java index 71e1cbe..7d0fca1 100644 --- a/winterly-neoforge/src/main/java/ru/pinkgoosik/winterly/neoforge/registry/WinterlyItems.java +++ b/winterly-neoforge/src/main/java/ru/pinkgoosik/winterly/neoforge/registry/WinterlyItems.java @@ -12,14 +12,14 @@ public class WinterlyItems { public static void init() { CommonWinterlyItems.init(); - add("red_santa_hat", () -> new SantaHatItem(settings(), "red")); - add("blue_santa_hat", () -> new SantaHatItem(settings(), "blue")); + add("red_santa_hat", () -> new SantaHatItem(properties(), "red")); + add("blue_santa_hat", () -> new SantaHatItem(properties(), "blue")); - add("white_scarf", () -> new ScarfItem(settings(), "white")); - add("red_scarf", () -> new ScarfItem(settings(), "red")); - add("green_scarf", () -> new ScarfItem(settings(), "green")); - add("blue_scarf", () -> new ScarfItem(settings(), "blue")); - add("rainbow_scarf", () -> new ScarfItem(settings(), "rainbow")); + add("white_scarf", () -> new ScarfItem(properties(), "white")); + add("red_scarf", () -> new ScarfItem(properties(), "red")); + add("green_scarf", () -> new ScarfItem(properties(), "green")); + add("blue_scarf", () -> new ScarfItem(properties(), "blue")); + add("rainbow_scarf", () -> new ScarfItem(properties(), "rainbow")); } }