diff --git a/TEMPLATE_LICENSE.txt b/TEMPLATE_LICENSE.txt deleted file mode 100644 index b64bc64..0000000 --- a/TEMPLATE_LICENSE.txt +++ /dev/null @@ -1,24 +0,0 @@ -MIT License - -Copyright (c) 2023 NeoForged project - -This license applies to the template files as supplied by github.com/NeoForged/MDK - - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/src/main/java/indi/fcwyzzr/minecraft/food_talks/common/mixin/tweaks/mechanic/ItemMixin.java b/src/main/java/indi/fcwyzzr/minecraft/food_talks/common/mixin/tweaks/mechanic/ItemMixin.java index 3a02131..673d5ad 100644 --- a/src/main/java/indi/fcwyzzr/minecraft/food_talks/common/mixin/tweaks/mechanic/ItemMixin.java +++ b/src/main/java/indi/fcwyzzr/minecraft/food_talks/common/mixin/tweaks/mechanic/ItemMixin.java @@ -21,7 +21,7 @@ private void use_mixin(Level level, Player player, InteractionHand usedHand, Cal if (!cir.getReturnValue().getResult().equals(InteractionResult.CONSUME)) return; final var item = player.getItemInHand(usedHand); - if (! CompoundFood.Companion.isFood(item)) + if (! CompoundFood.Companion.isFood(item, false)) return; if (!Anorexia.INSTANCE.canEat(item, player)) diff --git a/src/main/kotlin/indi/fcwyzzr/minecraft/food_talks/api/common/item/CompoundFood.kt b/src/main/kotlin/indi/fcwyzzr/minecraft/food_talks/api/common/item/CompoundFood.kt index 2ff0294..666a7c3 100644 --- a/src/main/kotlin/indi/fcwyzzr/minecraft/food_talks/api/common/item/CompoundFood.kt +++ b/src/main/kotlin/indi/fcwyzzr/minecraft/food_talks/api/common/item/CompoundFood.kt @@ -33,8 +33,6 @@ abstract class CompoundFood( fun chewTick(stack: ItemStack) = (stack.components[FoodItemProperties.type]!!.chewSeconds * FoodTalks.TPS).toInt() fun bites(stack: ItemStack) = stack.maxDamage override fun getUseAnimation(stack: ItemStack) = UseAnim.EAT -// override fun getUseDuration(stack: ItemStack, entity: LivingEntity) = -// (stack.components[FoodItemProperties.type]!!.chewSeconds * FoodTalks.TPS).toInt() override fun getUseDuration(stack: ItemStack, entity: LivingEntity) = 5 + chewTick(stack) override fun use(level: Level, player: Player, usedHand: InteractionHand): InteractionResultHolder { @@ -65,8 +63,15 @@ abstract class CompoundFood( } companion object{ - fun isFood(itemStack: ItemStack): Boolean{ - return itemStack.components.has(DataComponents.FOOD) || itemStack.item is CompoundFood + fun isFood(itemStack: ItemStack, notCompound: Boolean = false): Boolean{ + return if (notCompound) + isVanillaFood(itemStack) && itemStack.item !is CompoundFood + else + isVanillaFood(itemStack) || itemStack.item is CompoundFood + } + + private fun isVanillaFood(itemStack: ItemStack): Boolean{ + return itemStack.components.has(DataComponents.FOOD) } fun containerOrNull(itemStack: ItemStack): ItemStack? { @@ -82,8 +87,8 @@ abstract class CompoundFood( }?.getOrNull() } - fun isHandHoldFood(itemStack: ItemStack): Boolean{ - return isFood(itemStack) && containerOrNull(itemStack) == null + fun isHandHoldFood(itemStack: ItemStack, notCompound: Boolean = false): Boolean{ + return isFood(itemStack, notCompound) && containerOrNull(itemStack) == null } } } \ No newline at end of file diff --git a/src/main/kotlin/indi/fcwyzzr/minecraft/food_talks/client/renderer/block/PlateRenderer.kt b/src/main/kotlin/indi/fcwyzzr/minecraft/food_talks/client/renderer/block/PlateRenderer.kt index 810d4ef..8048ffc 100644 --- a/src/main/kotlin/indi/fcwyzzr/minecraft/food_talks/client/renderer/block/PlateRenderer.kt +++ b/src/main/kotlin/indi/fcwyzzr/minecraft/food_talks/client/renderer/block/PlateRenderer.kt @@ -44,7 +44,7 @@ object PlateRenderer: BlockEntityRenderer { ) else{ poseStack.pushPose() - poseStack.translate(0.5, 2.5 / 16, 0.5) + poseStack.translate(0.5, 2.0 / 16, 0.5) poseStack.mulPose(Axis.XP.rotationDegrees(90F)) poseStack.scale(1F, 1F, 3F) Minecraft.getInstance().itemRenderer.renderStatic( diff --git a/src/main/kotlin/indi/fcwyzzr/minecraft/food_talks/client/renderer/item/SandwichRenderer.kt b/src/main/kotlin/indi/fcwyzzr/minecraft/food_talks/client/renderer/item/SandwichRenderer.kt index 9bb4aa3..d42cd73 100644 --- a/src/main/kotlin/indi/fcwyzzr/minecraft/food_talks/client/renderer/item/SandwichRenderer.kt +++ b/src/main/kotlin/indi/fcwyzzr/minecraft/food_talks/client/renderer/item/SandwichRenderer.kt @@ -53,6 +53,9 @@ object SandwichRenderer { light: Int, overlay: Int ){ + if (layer.isEmpty()) + return + val itemRenderer = Minecraft .getInstance() .itemRenderer diff --git a/src/main/kotlin/indi/fcwyzzr/minecraft/food_talks/common/block/BottleBlock.kt b/src/main/kotlin/indi/fcwyzzr/minecraft/food_talks/common/block/BottleBlock.kt index a477d3a..e1884e2 100644 --- a/src/main/kotlin/indi/fcwyzzr/minecraft/food_talks/common/block/BottleBlock.kt +++ b/src/main/kotlin/indi/fcwyzzr/minecraft/food_talks/common/block/BottleBlock.kt @@ -12,6 +12,7 @@ import net.minecraft.core.Registry import net.minecraft.core.component.DataComponents import net.minecraft.core.registries.BuiltInRegistries import net.minecraft.resources.ResourceKey +import net.minecraft.server.level.ServerLevel import net.minecraft.world.InteractionHand import net.minecraft.world.InteractionResult import net.minecraft.world.ItemInteractionResult @@ -20,7 +21,10 @@ import net.minecraft.world.item.ItemStack import net.minecraft.world.item.ItemUtils import net.minecraft.world.item.Items import net.minecraft.world.item.alchemy.PotionContents -import net.minecraft.world.level.* +import net.minecraft.world.level.BlockGetter +import net.minecraft.world.level.Level +import net.minecraft.world.level.LevelAccessor +import net.minecraft.world.level.LevelReader import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.Blocks import net.minecraft.world.level.block.EntityBlock @@ -28,8 +32,9 @@ import net.minecraft.world.level.block.SoundType import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.block.state.StateDefinition import net.minecraft.world.level.block.state.properties.IntegerProperty -import net.minecraft.world.level.material.FluidState import net.minecraft.world.level.material.PushReaction +import net.minecraft.world.level.storage.loot.LootParams +import net.minecraft.world.level.storage.loot.parameters.LootContextParams import net.minecraft.world.phys.BlockHitResult import net.minecraft.world.phys.HitResult import net.minecraft.world.phys.shapes.CollisionContext @@ -81,23 +86,6 @@ class BottleBlock private constructor(): Block(Properties.of().apply { return canSupportCenter(pLevel, pPos.below(), Direction.UP) } - override fun onDestroyedByPlayer( - state: BlockState, - level: Level, - pos: BlockPos, - player: Player, - willHarvest: Boolean, - fluid: FluidState - ): Boolean { - val entity = level.getBlockEntity(pos) as BottleBlockEntity - - if (level.gameRules.getBoolean(GameRules.RULE_DOBLOCKDROPS) && ! player.hasInfiniteMaterials()) - doDestroyDrop(level, entity, state.getValue(PROPERTY_FILL_LEVEL)) - super.onDestroyedByPlayer(state, level, pos, player, willHarvest, fluid) - - return true - } - override fun updateShape( state: BlockState, direction: Direction, @@ -111,7 +99,8 @@ class BottleBlock private constructor(): Block(Properties.of().apply { level, pos ) - ) Blocks.AIR.defaultBlockState() else + ) Blocks.AIR.defaultBlockState() + else super.updateShape( state, direction, @@ -122,9 +111,10 @@ class BottleBlock private constructor(): Block(Properties.of().apply { ) } - private fun doDestroyDrop(level: Level, entity: BottleBlockEntity, fillLevel: Int){ - val itemStack = Cocktail.buildFromBottle(entity, fillLevel) - popResource(level, entity.blockPos, itemStack) + override fun getDrops(state: BlockState, params: LootParams.Builder): MutableList { + val entity = params.getParameter(LootContextParams.BLOCK_ENTITY) as BottleBlockEntity + val fillLevel = state.getValue(PROPERTY_FILL_LEVEL) + return mutableListOf(Cocktail.buildFromBottle(entity, fillLevel)) } /** @@ -140,14 +130,13 @@ class BottleBlock private constructor(): Block(Properties.of().apply { if (! player.isShiftKeyDown) return InteractionResult.PASS - doDestroyDrop( - level, - level.getBlockEntity(pos) as BottleBlockEntity, - state.getValue(PROPERTY_FILL_LEVEL) - ) - if (!player.hasInfiniteMaterials()) - level.setBlockAndUpdate(pos, Blocks.AIR.defaultBlockState()) + if (player.hasInfiniteMaterials() && level is ServerLevel) + getDrops(state, level, pos, level.getBlockEntity(pos)).forEach { + popResource(level, pos, it) + } + else if (level is ServerLevel) + level.destroyBlock(pos, true) return InteractionResult.SUCCESS } diff --git a/src/main/kotlin/indi/fcwyzzr/minecraft/food_talks/common/block/PlateBlock.kt b/src/main/kotlin/indi/fcwyzzr/minecraft/food_talks/common/block/PlateBlock.kt index 7b2cbcc..b51dfc8 100644 --- a/src/main/kotlin/indi/fcwyzzr/minecraft/food_talks/common/block/PlateBlock.kt +++ b/src/main/kotlin/indi/fcwyzzr/minecraft/food_talks/common/block/PlateBlock.kt @@ -2,6 +2,7 @@ package indi.fcwyzzr.minecraft.food_talks.common.block import indi.fcwyzzr.minecraft.f_lib.registry.FRegistry import indi.fcwyzzr.minecraft.food_talks.common.block.entity.PlateBlockEntity +import indi.fcwyzzr.minecraft.food_talks.common.item.Plate import indi.fcwyzzr.minecraft.food_talks.common.item.Sandwich import indi.fcwyzzr.minecraft.food_talks.toRegistryName import indi.fcwyzzr.minecraft.food_talks.toResourceLocation @@ -9,9 +10,9 @@ import net.minecraft.core.BlockPos import net.minecraft.core.Direction import net.minecraft.core.Holder import net.minecraft.core.Registry -import net.minecraft.core.component.DataComponentMap import net.minecraft.core.registries.BuiltInRegistries import net.minecraft.resources.ResourceKey +import net.minecraft.server.level.ServerLevel import net.minecraft.sounds.SoundEvents import net.minecraft.sounds.SoundSource import net.minecraft.world.InteractionHand @@ -20,17 +21,20 @@ import net.minecraft.world.ItemInteractionResult import net.minecraft.world.entity.Entity import net.minecraft.world.entity.item.ItemEntity import net.minecraft.world.entity.player.Player -import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack -import net.minecraft.world.level.* +import net.minecraft.world.level.BlockGetter +import net.minecraft.world.level.Level +import net.minecraft.world.level.LevelAccessor +import net.minecraft.world.level.LevelReader import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.Blocks import net.minecraft.world.level.block.EntityBlock import net.minecraft.world.level.block.SoundType import net.minecraft.world.level.block.entity.BlockEntity import net.minecraft.world.level.block.state.BlockState -import net.minecraft.world.level.material.FluidState import net.minecraft.world.level.material.PushReaction +import net.minecraft.world.level.storage.loot.LootParams +import net.minecraft.world.level.storage.loot.parameters.LootContextParams import net.minecraft.world.phys.BlockHitResult import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.VoxelShape @@ -93,11 +97,11 @@ class PlateBlock private constructor(): Block(Properties.of().apply { ): InteractionResult { val entity = level.getBlockEntity(pos) as PlateBlockEntity if (player.isShiftKeyDown){ - if (!player.hasInfiniteMaterials() && level.gameRules.getBoolean(GameRules.RULE_DOBLOCKDROPS)) - doIngredientsDrop(level, pos, false) - else - entity.clear() + if (!player.hasInfiniteMaterials() + && level is ServerLevel) + entity.forEachFoldedContent { popResource(level, pos, this) } + entity.clear() return InteractionResult.SUCCESS } @@ -152,82 +156,15 @@ class PlateBlock private constructor(): Block(Properties.of().apply { } } - override fun onDestroyedByPlayer( - state: BlockState, - level: Level, - pos: BlockPos, - player: Player, - willHarvest: Boolean, - fluid: FluidState - ): Boolean { - if (level.gameRules.getBoolean(GameRules.RULE_DOBLOCKDROPS)) - doIngredientsDrop( - level, - pos, - !player.hasInfiniteMaterials() - ) - return super.onDestroyedByPlayer(state, level, pos, player, willHarvest, fluid) - } + override fun getDrops(state: BlockState, params: LootParams.Builder) = buildList { + val breaker: Entity? = params.getOptionalParameter(LootContextParams.THIS_ENTITY) + if (breaker !is Player || !breaker.hasInfiniteMaterials()) + add(Plate.defaultInstance) - override fun onDestroyedByPushReaction( - state: BlockState, - level: Level, - pos: BlockPos, - pushDirection: Direction, - fluid: FluidState - ) { - if (level.gameRules.getBoolean(GameRules.RULE_DOBLOCKDROPS)) - doIngredientsDrop( - level, - pos, - true - ) - super.onDestroyedByPushReaction(state, level, pos, pushDirection, fluid) + val entity = params.getParameter(LootContextParams.BLOCK_ENTITY) as PlateBlockEntity + entity.forEachFoldedContent(::add) } - private fun doIngredientsDrop( - level: Level, - pos: BlockPos, - dropSelf: Boolean - ){ - val entity = level.getBlockEntity(pos) as PlateBlockEntity - - if (dropSelf) - popResource(level, pos, ItemStack(instance)) - - - entity - .popDisplay() - ?.apply{ - popResource(level, pos, this) - } - ?: run { - entity - .readOnlyIngredient - .fold(mutableMapOf>()) { map, itemStack -> - if (itemStack.item !in map) { - map[itemStack.item] = mutableMapOf(itemStack.components to itemStack) - return@fold map - } - - val itemSet = map[itemStack.item]!! - if (itemStack.components !in itemSet) { - itemSet[itemStack.components] = itemStack - return@fold map - } - - itemSet[itemStack.components]!!.grow(itemStack.count) - - map - } - .flatMap { it.value.values } - .forEach{ - popResource(level, pos, it) - } - - entity.clear() - } - } companion object: FRegistry { diff --git a/src/main/kotlin/indi/fcwyzzr/minecraft/food_talks/common/block/entity/PlateBlockEntity.kt b/src/main/kotlin/indi/fcwyzzr/minecraft/food_talks/common/block/entity/PlateBlockEntity.kt index a6b34f3..750bc32 100644 --- a/src/main/kotlin/indi/fcwyzzr/minecraft/food_talks/common/block/entity/PlateBlockEntity.kt +++ b/src/main/kotlin/indi/fcwyzzr/minecraft/food_talks/common/block/entity/PlateBlockEntity.kt @@ -11,7 +11,7 @@ import net.minecraft.core.BlockPos import net.minecraft.core.Holder import net.minecraft.core.HolderLookup import net.minecraft.core.Registry -import net.minecraft.core.component.DataComponents +import net.minecraft.core.component.DataComponentMap import net.minecraft.core.registries.BuiltInRegistries import net.minecraft.nbt.CompoundTag import net.minecraft.nbt.ListTag @@ -20,6 +20,7 @@ import net.minecraft.network.protocol.Packet import net.minecraft.network.protocol.game.ClientGamePacketListener import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket import net.minecraft.resources.ResourceKey +import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack import net.minecraft.world.level.block.entity.BlockEntity import net.minecraft.world.level.block.entity.BlockEntityType @@ -50,6 +51,32 @@ class PlateBlockEntity( setChanged() } + fun forEachFoldedContent(action: ItemStack.() -> Unit){ + displayItem + ?.apply(action) + ?: run { + readOnlyIngredient + .fold(mutableMapOf>()) { map, itemStack -> + if (itemStack.item !in map) { + map[itemStack.item] = mutableMapOf(itemStack.components to itemStack) + return@fold map + } + + val itemSet = map[itemStack.item]!! + if (itemStack.components !in itemSet) { + itemSet[itemStack.components] = itemStack + return@fold map + } + + itemSet[itemStack.components]!!.grow(itemStack.count) + + map + } + .flatMap { it.value.values } + .forEach(action) + } + } + private fun addCover(itemStack: ItemStack): Boolean{ if (!itemStack.`is`(sandwichCover)) return false @@ -65,7 +92,8 @@ class PlateBlockEntity( if (size == MAX_LAYER) return false - if (!CompoundFood.isHandHoldFood(itemStack)) + // only allow non-compound food as ingredient + if (!CompoundFood.isHandHoldFood(itemStack, true)) return false // 1. last cover @@ -95,13 +123,6 @@ class PlateBlockEntity( return true } - fun popDisplay(): ItemStack? { - val pop = display - display = null - setChanged() - return pop - } - override fun loadAdditional(tag: CompoundTag, registries: HolderLookup.Provider) { super.loadAdditional(tag, registries) diff --git a/src/main/kotlin/indi/fcwyzzr/minecraft/food_talks/common/event/gameplay/EffectHandler.kt b/src/main/kotlin/indi/fcwyzzr/minecraft/food_talks/common/event/gameplay/EffectHandler.kt index c1e9d13..9dcecf8 100644 --- a/src/main/kotlin/indi/fcwyzzr/minecraft/food_talks/common/event/gameplay/EffectHandler.kt +++ b/src/main/kotlin/indi/fcwyzzr/minecraft/food_talks/common/event/gameplay/EffectHandler.kt @@ -4,13 +4,16 @@ import com.google.common.math.IntMath.pow import indi.fcwyzzr.minecraft.food_talks.FoodTalks import indi.fcwyzzr.minecraft.food_talks.api.common.item.CompoundFood import indi.fcwyzzr.minecraft.food_talks.common.mob_effect.beneficial.* -import indi.fcwyzzr.minecraft.food_talks.common.mob_effect.harmful.* +import indi.fcwyzzr.minecraft.food_talks.common.mob_effect.harmful.Anorexia +import indi.fcwyzzr.minecraft.food_talks.common.mob_effect.harmful.Toothache +import indi.fcwyzzr.minecraft.food_talks.common.mob_effect.harmful.Vomit import indi.fcwyzzr.minecraft.food_talks.common.registries.ToothacheDamage import indi.fcwyzzr.minecraft.food_talks.common.registries.from import indi.fcwyzzr.minecraft.food_talks.common.registries.milkIrremovable import net.minecraft.server.level.ServerLevel import net.minecraft.server.level.ServerPlayer import net.minecraft.util.Mth +import net.minecraft.world.effect.MobEffectInstance import net.minecraft.world.effect.MobEffects import net.minecraft.world.entity.EntityType import net.minecraft.world.entity.LivingEntity @@ -65,12 +68,10 @@ object EffectHandler { @SubscribeEvent fun entityEatingWhenToothache(event: Tick){ - if (event.duration < 20) + if (!event.entity.hasEffect(Toothache.holder)) return if (event.duration % 10 != 0) return - if (!event.entity.hasEffect(Toothache.holder)) - return if (!CompoundFood.isFood(event.item)) return @@ -252,6 +253,7 @@ object EffectHandler { event.isCanceled = true event.entity.health = event.entity.maxHealth event.entity.removeEffect(JackHead.holder) + event.entity.addEffect(MobEffectInstance(MobEffects.DARKNESS, 20)) if (event.entity.level().isClientSide) return val serverLevel = event.entity.level() as ServerLevel diff --git a/src/main/kotlin/indi/fcwyzzr/minecraft/food_talks/common/item/Cocktail.kt b/src/main/kotlin/indi/fcwyzzr/minecraft/food_talks/common/item/Cocktail.kt index e156f82..29d2e5f 100644 --- a/src/main/kotlin/indi/fcwyzzr/minecraft/food_talks/common/item/Cocktail.kt +++ b/src/main/kotlin/indi/fcwyzzr/minecraft/food_talks/common/item/Cocktail.kt @@ -129,10 +129,10 @@ object Cocktail: CompoundFood( } } - private fun mergeCollapsedMobEffectInstance(self: MobEffectInstance): MobEffectInstance{ + private fun mergeFoldedMobEffectInstance(self: MobEffectInstance): MobEffectInstance{ val hidden = (self as MobEffectInstanceAccessor).hiddenEffect ?: return self - val mergedHidden = mergeCollapsedMobEffectInstance(MobEffectInstance(hidden)) + val mergedHidden = mergeFoldedMobEffectInstance(MobEffectInstance(hidden)) return mergeMobEffectInstance(mergedHidden, self) } @@ -151,7 +151,7 @@ object Cocktail: CompoundFood( val changesKey = removalWhenMergeMobEffectMap(addonMap, baseMap) val hiddenMergedRemoval = changesKey .mapNotNull(baseMap::get) - .map(::mergeCollapsedMobEffectInstance) + .map(::mergeFoldedMobEffectInstance) .associateBy { it.effect } changesKey diff --git a/src/main/kotlin/indi/fcwyzzr/minecraft/food_talks/common/item/Sandwich.kt b/src/main/kotlin/indi/fcwyzzr/minecraft/food_talks/common/item/Sandwich.kt index 6920a48..a6a8ec3 100644 --- a/src/main/kotlin/indi/fcwyzzr/minecraft/food_talks/common/item/Sandwich.kt +++ b/src/main/kotlin/indi/fcwyzzr/minecraft/food_talks/common/item/Sandwich.kt @@ -13,6 +13,7 @@ import indi.fcwyzzr.minecraft.food_talks.toResourceLocation import net.minecraft.core.Holder import net.minecraft.core.component.DataComponents import net.minecraft.core.registries.BuiltInRegistries +import net.minecraft.network.chat.Component import net.minecraft.tags.TagKey import net.minecraft.util.Mth import net.minecraft.world.effect.MobEffect @@ -24,6 +25,7 @@ import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack import net.minecraft.world.item.Items import net.minecraft.world.item.alchemy.PotionContents +import net.minecraft.world.item.component.ItemLore import net.neoforged.neoforge.client.extensions.common.IClientItemExtensions import org.spongepowered.include.com.google.common.collect.Iterables import java.util.* @@ -41,7 +43,7 @@ object Sandwich: CompoundFood( fun layers(itemStack: ItemStack): List>{ if (!itemStack.`is`(this)) throw IllegalArgumentException("itemStack other than sandwich should not use this method") - return itemStack.components[SimpleDataComponents.SandwichLayer]!! + return itemStack.components[SimpleDataComponents.SandwichLayer] ?: listOf() } override fun uponBite(itemStack: ItemStack, entity: LivingEntity): Boolean { diff --git a/src/main/kotlin/indi/fcwyzzr/minecraft/food_talks/common/registries/Tags.kt b/src/main/kotlin/indi/fcwyzzr/minecraft/food_talks/common/registries/Tags.kt index 1f05644..5f35839 100644 --- a/src/main/kotlin/indi/fcwyzzr/minecraft/food_talks/common/registries/Tags.kt +++ b/src/main/kotlin/indi/fcwyzzr/minecraft/food_talks/common/registries/Tags.kt @@ -1,7 +1,7 @@ package indi.fcwyzzr.minecraft.food_talks.common.registries import indi.fcwyzzr.minecraft.food_talks.toResourceLocation -import net.minecraft.core.registries.BuiltInRegistries +import net.minecraft.core.registries.Registries import net.minecraft.resources.ResourceLocation import net.minecraft.tags.ItemTags import net.minecraft.tags.TagKey @@ -11,13 +11,13 @@ import net.minecraft.world.item.Item fun ResourceLocation.toItemTag(): TagKey = ItemTags.create(this) fun ResourceLocation.toMobEffectTag(): TagKey = TagKey.create( - BuiltInRegistries.MOB_EFFECT.key(), this + Registries.MOB_EFFECT, this ) val sandwichCover = "ingredient/sandwich_cover" .toResourceLocation() .toItemTag() -val milkIrremovable = "milk_irremovable.json" +val milkIrremovable = "milk_irremovable" .toResourceLocation() .toMobEffectTag() \ No newline at end of file diff --git a/src/main/resources/assets/food_talks/lang/en_us.json b/src/main/resources/assets/food_talks/lang/en_us.json index 10d2486..a36458b 100644 --- a/src/main/resources/assets/food_talks/lang/en_us.json +++ b/src/main/resources/assets/food_talks/lang/en_us.json @@ -19,6 +19,8 @@ "effect.food_talks.gout": "Gout", "effect.food_talks.vomit": "Vomit", "effect.food_talks.toothache": "Toothache", - "effect.food_talks.overweight": "Overweight" + "effect.food_talks.overweight": "Overweight", + "death.attack.toothache": "%1$s 's teeth was shattered into pieces.", + "death.attack.gout": "%1$s 's joint exploded." } \ No newline at end of file diff --git a/src/main/resources/assets/food_talks/lang/zh_cn.json b/src/main/resources/assets/food_talks/lang/zh_cn.json index 3afb472..ef0e1b2 100644 --- a/src/main/resources/assets/food_talks/lang/zh_cn.json +++ b/src/main/resources/assets/food_talks/lang/zh_cn.json @@ -18,5 +18,8 @@ "effect.food_talks.gout": "痛风", "effect.food_talks.vomit": "呕吐", "effect.food_talks.toothache": "牙痛", - "effect.food_talks.overweight": "肥胖" + "effect.food_talks.overweight": "肥胖", + + "death.attack.tooth_ache": "%1$s可能需要一副假牙。", + "death.attack.gout": "%1$s的关节爆炸了。" } \ No newline at end of file