Compare commits

...

4 Commits

28 changed files with 537 additions and 66 deletions

View File

@ -2,6 +2,7 @@ package ru.dbotthepony.mc.otm.datagen
import net.minecraft.data.worldgen.BootstrapContext import net.minecraft.data.worldgen.BootstrapContext
import net.minecraft.tags.DamageTypeTags import net.minecraft.tags.DamageTypeTags
import net.minecraft.world.damagesource.DamageEffects
import net.minecraft.world.damagesource.DamageScaling import net.minecraft.world.damagesource.DamageScaling
import net.minecraft.world.damagesource.DamageType import net.minecraft.world.damagesource.DamageType
import ru.dbotthepony.mc.otm.datagen.tags.TagsProvider import ru.dbotthepony.mc.otm.datagen.tags.TagsProvider
@ -20,6 +21,7 @@ fun registerDamageTypes(context: BootstrapContext<DamageType>) {
context.register(MDamageTypes.EXPLOSIVE_HAMMER, DamageType("otm_explosive_hammer", DamageScaling.NEVER, 0.1f)) context.register(MDamageTypes.EXPLOSIVE_HAMMER, DamageType("otm_explosive_hammer", DamageScaling.NEVER, 0.1f))
context.register(MDamageTypes.HAMMER_NAIL, DamageType("otm_hammer_nail", DamageScaling.NEVER, 0.1f)) context.register(MDamageTypes.HAMMER_NAIL, DamageType("otm_hammer_nail", DamageScaling.NEVER, 0.1f))
context.register(MDamageTypes.ANDROID_DISCHARGE, DamageType("otm_android_discharge", DamageScaling.NEVER, 4.0f)) context.register(MDamageTypes.ANDROID_DISCHARGE, DamageType("otm_android_discharge", DamageScaling.NEVER, 4.0f))
context.register(MDamageTypes.NOT_NORMAL_PILL, DamageType("otm_not_normal_pill", DamageScaling.NEVER, 0f, DamageEffects.DROWNING))
} }
fun registerDamageTypeTags(provider: TagsProvider.Delegate<DamageType>) { fun registerDamageTypeTags(provider: TagsProvider.Delegate<DamageType>) {
@ -36,6 +38,7 @@ fun registerDamageTypeTags(provider: TagsProvider.Delegate<DamageType>) {
.add(MDamageTypes.SHOCKWAVE) .add(MDamageTypes.SHOCKWAVE)
.add(MDamageTypes.COSMIC_RAYS) .add(MDamageTypes.COSMIC_RAYS)
.add(MDamageTypes.ANDROID_DISCHARGE) .add(MDamageTypes.ANDROID_DISCHARGE)
.add(MDamageTypes.NOT_NORMAL_PILL)
ignoreMagic ignoreMagic
.add(MDamageTypes.EXOPACK_PROBE) .add(MDamageTypes.EXOPACK_PROBE)
@ -43,9 +46,11 @@ fun registerDamageTypeTags(provider: TagsProvider.Delegate<DamageType>) {
.add(MDamageTypes.BECOME_HUMANE) .add(MDamageTypes.BECOME_HUMANE)
.add(MDamageTypes.COSMIC_RAYS) .add(MDamageTypes.COSMIC_RAYS)
.add(MDamageTypes.ANDROID_DISCHARGE) .add(MDamageTypes.ANDROID_DISCHARGE)
.add(MDamageTypes.NOT_NORMAL_PILL)
ignoreInvl ignoreInvl
.add(MDamageTypes.BECOME_HUMANE) .add(MDamageTypes.BECOME_HUMANE)
.add(MDamageTypes.BECOME_ANDROID) .add(MDamageTypes.BECOME_ANDROID)
.add(MDamageTypes.ANDROID_DISCHARGE) .add(MDamageTypes.ANDROID_DISCHARGE)
.add(MDamageTypes.NOT_NORMAL_PILL)
} }

View File

@ -48,6 +48,7 @@ import ru.dbotthepony.mc.otm.datagen.loot.*
import ru.dbotthepony.mc.otm.datagen.loot.LootModifiers import ru.dbotthepony.mc.otm.datagen.loot.LootModifiers
import ru.dbotthepony.mc.otm.datagen.recipes.* import ru.dbotthepony.mc.otm.datagen.recipes.*
import ru.dbotthepony.mc.otm.datagen.tags.TagsProvider import ru.dbotthepony.mc.otm.datagen.tags.TagsProvider
import ru.dbotthepony.mc.otm.datagen.tags.addSuspiciousTags
import ru.dbotthepony.mc.otm.datagen.tags.addTags import ru.dbotthepony.mc.otm.datagen.tags.addTags
import ru.dbotthepony.mc.otm.datagen.textures.ColorizedSpritesProvider import ru.dbotthepony.mc.otm.datagen.textures.ColorizedSpritesProvider
import ru.dbotthepony.mc.otm.matter.MatterDataProvider import ru.dbotthepony.mc.otm.matter.MatterDataProvider
@ -515,6 +516,7 @@ object DataGen {
)) {} )) {}
addTags(tagsProvider) addTags(tagsProvider)
addSuspiciousTags(tagsProvider)
event.generator.addProvider(event.includeClient(), colorizedSpritesProvider) event.generator.addProvider(event.includeClient(), colorizedSpritesProvider)
event.generator.addProvider(event.includeClient(), blockModelProvider) event.generator.addProvider(event.includeClient(), blockModelProvider)
@ -575,6 +577,7 @@ object DataGen {
addOreSmeltingRecipes(consumer) addOreSmeltingRecipes(consumer)
addPainterRecipes(consumer) addPainterRecipes(consumer)
addMatterEntanglerRecipes(consumer) addMatterEntanglerRecipes(consumer)
addSuspiciousRecipes(consumer)
} }
addPlatePressRecipes(recipeProvider) addPlatePressRecipes(recipeProvider)

View File

@ -538,10 +538,10 @@ fun addAdvancements(serializer: Consumer<AdvancementHolder>, lang: MatteryLangua
}, },
) )
.requirements(Strategy.OR) .requirements(Strategy.OR)
.addCriterion("pill1", criterion(MItems.PILL_ANDROID)) .also {
.addCriterion("pill2", criterion(MItems.PILL_HEAL)) for ((i, item) in MItems.PILLS.withIndex())
.addCriterion("pill3", criterion(MItems.PILL_HUMANE)) it.addCriterion("pill$i", criterion(item))
.addCriterion("pill4", criterion(MItems.PILL_OBLIVION)) }
.save(serializer, modLocation("regular/pill")) .save(serializer, modLocation("regular/pill"))
AdvancementBuilder() AdvancementBuilder()
@ -559,10 +559,10 @@ fun addAdvancements(serializer: Consumer<AdvancementHolder>, lang: MatteryLangua
) )
.rewards(AdvancementRewards.Builder.experience(200)) .rewards(AdvancementRewards.Builder.experience(200))
.requirements(Strategy.AND) .requirements(Strategy.AND)
.addCriterion("pill1", criterion(MItems.PILL_ANDROID)) .also {
.addCriterion("pill2", criterion(MItems.PILL_HEAL)) for ((i, item) in MItems.PILLS.withIndex())
.addCriterion("pill3", criterion(MItems.PILL_HUMANE)) it.addCriterion("pill$i", criterion(item))
.addCriterion("pill4", criterion(MItems.PILL_OBLIVION)) }
.save(serializer, modLocation("regular/all_pills")) .save(serializer, modLocation("regular/all_pills"))
val essenceCapsule = AdvancementBuilder() val essenceCapsule = AdvancementBuilder()

View File

@ -222,4 +222,6 @@ fun addItemModels(provider: MatteryItemModelProvider) {
for ((color, item) in MItems.CARGO_CRATE_MINECARTS) { for ((color, item) in MItems.CARGO_CRATE_MINECARTS) {
provider.generated(item) provider.generated(item)
} }
MItems.SUSPICIOUS_FOODS.ITEMS.forEach { provider.inherit(it, it.mimicking()) }
} }

View File

@ -32,6 +32,10 @@ class MatteryItemModelProvider(event: GatherDataEvent) : ItemModelProvider(event
fun block(item: Item) = exec { withExistingParent(item.registryName!!.path, modLocation("block/${item.registryName!!.path}")) } fun block(item: Item) = exec { withExistingParent(item.registryName!!.path, modLocation("block/${item.registryName!!.path}")) }
fun block(item: Item, path: String) = exec { withExistingParent(item.registryName!!.path, modLocation("block/$path")) } fun block(item: Item, path: String) = exec { withExistingParent(item.registryName!!.path, modLocation("block/$path")) }
fun inherit(item: Item, parent: Item) {
exec { withExistingParent(item.registryName!!.path, parent.registryName!!) }
}
fun coloredWithBaseBlock(items: Map<DyeColor?, Item>, path: String) { fun coloredWithBaseBlock(items: Map<DyeColor?, Item>, path: String) {
for (color in DyeColor.entries) { for (color in DyeColor.entries) {
block(items[color]!!, path + "_${color.name.lowercase()}") block(items[color]!!, path + "_${color.name.lowercase()}")

View File

@ -362,6 +362,10 @@ private fun misc(provider: MatteryLanguageProvider) {
misc("pill.heal", "Instantly restores 4 hearts upon ingestion, provides 2 min Absorption V and 8 seconds Regeneration III.") misc("pill.heal", "Instantly restores 4 hearts upon ingestion, provides 2 min Absorption V and 8 seconds Regeneration III.")
misc("pill.heal_android", "Does nothing to androids.") misc("pill.heal_android", "Does nothing to androids.")
misc("pill.not_normal", "Instantly kills fleshy creatures upon ingestion")
misc("pill.suspicious_food.desc", "On closer inspection, this food doesn't seem right...")
misc("pill.suspicious_food", "Suspicious %s")
misc("pill.message", "Nothing happened, but you feel... exhausted?.. Maybe get rest.") misc("pill.message", "Nothing happened, but you feel... exhausted?.. Maybe get rest.")
misc("pill.message_finish", "§kONE OF US ONE OF US ONE OF US") misc("pill.message_finish", "§kONE OF US ONE OF US ONE OF US")
@ -451,6 +455,8 @@ private fun death(provider: MatteryLanguageProvider) {
death("otm_emp", "%1\$s electronics' fried") death("otm_emp", "%1\$s electronics' fried")
death("otm_cosmic_rays", "%1\$s electronics' got scrambled by cosmic radiation") death("otm_cosmic_rays", "%1\$s electronics' got scrambled by cosmic radiation")
death("otm_android_discharge", "%1\$s ran out of power") death("otm_android_discharge", "%1\$s ran out of power")
death("otm_not_normal_pill", "%1\$s took meds")
death("otm_not_normal_pill.item", "%1\$s took %2\$s")
death("otm_become_android.player", "%1\$s lost their humanity whilst %2\$s tried to reason with them") death("otm_become_android.player", "%1\$s lost their humanity whilst %2\$s tried to reason with them")
death("otm_become_humane.player", "%1\$s gained their humanity whilst %2\$s tried to reason with them") death("otm_become_humane.player", "%1\$s gained their humanity whilst %2\$s tried to reason with them")
@ -757,6 +763,7 @@ private fun items(provider: MatteryLanguageProvider) {
add(MItems.PILL_HUMANE, "Humane Pill") add(MItems.PILL_HUMANE, "Humane Pill")
add(MItems.PILL_OBLIVION, "Android Factory Reset Pill") add(MItems.PILL_OBLIVION, "Android Factory Reset Pill")
add(MItems.PILL_HEAL, "Medical Pill") add(MItems.PILL_HEAL, "Medical Pill")
add(MItems.PILL_NOT_NORMAL, "Not/Normal Pill")
add(MItems.MATTER_CAPACITOR_PARTS, "Matter Capacitor Parts") add(MItems.MATTER_CAPACITOR_PARTS, "Matter Capacitor Parts")
add(MItems.MATTER_CAPACITOR_BASIC, "Basic Matter Capacitor") add(MItems.MATTER_CAPACITOR_BASIC, "Basic Matter Capacitor")

View File

@ -368,6 +368,10 @@ private fun misc(provider: MatteryLanguageProvider) {
misc("pill.heal", "Мгновенно восполняет 4 сердца при употреблении, а так же даёт на 2 минуты поглощение V и на 8 секунд регенерацию III.") misc("pill.heal", "Мгновенно восполняет 4 сердца при употреблении, а так же даёт на 2 минуты поглощение V и на 8 секунд регенерацию III.")
misc("pill.heal_android", "Не действует на андроидов.") misc("pill.heal_android", "Не действует на андроидов.")
misc("pill.not_normal", "Мгновенно убивает существ из плоти")
misc("pill.suspicious_food.desc", "При более тщательном рассмотрении данная пища выглядит подозрительно...")
misc("pill.suspicious_food", "Подозрительный %s")
misc("pill.message", "Ничего не произошло, но вы чувствуете... себя уставшим?.. Возможно надо отдохнуть.") misc("pill.message", "Ничего не произошло, но вы чувствуете... себя уставшим?.. Возможно надо отдохнуть.")
misc("pill.message_finish", "§kОДИН ИЗ НАС ОДИН ИЗ НАС ОДИН ИЗ НАС ОДИН ИЗ НАС ОДИН ИЗ НАС") misc("pill.message_finish", "§kОДИН ИЗ НАС ОДИН ИЗ НАС ОДИН ИЗ НАС ОДИН ИЗ НАС ОДИН ИЗ НАС")
@ -452,6 +456,8 @@ private fun death(provider: MatteryLanguageProvider) {
death("otm_emp", "Электроника %1\$s перегорела") death("otm_emp", "Электроника %1\$s перегорела")
death("otm_cosmic_rays", "Электроника %1\$s была ошеломлена космическим излучением") death("otm_cosmic_rays", "Электроника %1\$s была ошеломлена космическим излучением")
death("otm_android_discharge", "В аккумуляторах %1\$s закончился заряд") death("otm_android_discharge", "В аккумуляторах %1\$s закончился заряд")
death("otm_not_normal_pill", "%1\$s принял таблетки")
death("otm_not_normal_pill.item", "%1\$s принял %2\$s")
death("otm_become_android.player", "%1\$s потерял свою человечность, когда %2\$s пытался образумить их") death("otm_become_android.player", "%1\$s потерял свою человечность, когда %2\$s пытался образумить их")
death("otm_become_humane.player", "%1\$s восстановил свою человечность, когда %2\$s пытался образумить их") death("otm_become_humane.player", "%1\$s восстановил свою человечность, когда %2\$s пытался образумить их")
@ -758,6 +764,7 @@ private fun items(provider: MatteryLanguageProvider) {
add(MItems.PILL_HUMANE, "Пилюля человечности") add(MItems.PILL_HUMANE, "Пилюля человечности")
add(MItems.PILL_OBLIVION, "Пилюля сброса андроида до заводских настроек") add(MItems.PILL_OBLIVION, "Пилюля сброса андроида до заводских настроек")
add(MItems.PILL_HEAL, "Медицинская пилюля") add(MItems.PILL_HEAL, "Медицинская пилюля")
add(MItems.PILL_NOT_NORMAL, "Не/Нормальная пилюля")
add(MItems.MATTER_CAPACITOR_PARTS, "Части накопителя материи") add(MItems.MATTER_CAPACITOR_PARTS, "Части накопителя материи")
add(MItems.MATTER_CAPACITOR_BASIC, "Простой накопитель материи") add(MItems.MATTER_CAPACITOR_BASIC, "Простой накопитель материи")

View File

@ -129,6 +129,7 @@ fun addLootModifiers(it: LootModifiers) {
ItemStack(MItems.PILL_ANDROID, 1) to 0.1, ItemStack(MItems.PILL_ANDROID, 1) to 0.1,
ItemStack(MItems.PILL_HEAL, 2) to 0.5, ItemStack(MItems.PILL_HEAL, 2) to 0.5,
ItemStack(MItems.PILL_HEAL, 1) to 0.75, ItemStack(MItems.PILL_HEAL, 1) to 0.75,
ItemStack(MItems.PILL_NOT_NORMAL, 3) to 0.25,
)) ))
it.add("mineshaft_pill", PlainLootAppender( it.add("mineshaft_pill", PlainLootAppender(
@ -136,6 +137,7 @@ fun addLootModifiers(it: LootModifiers) {
ItemStack(MItems.PILL_ANDROID, 1) to 0.04, ItemStack(MItems.PILL_ANDROID, 1) to 0.04,
ItemStack(MItems.PILL_HEAL, 2) to 0.1, ItemStack(MItems.PILL_HEAL, 2) to 0.1,
ItemStack(MItems.PILL_HEAL, 1) to 0.4, ItemStack(MItems.PILL_HEAL, 1) to 0.4,
ItemStack(MItems.PILL_NOT_NORMAL, 3) to 0.25,
)) ))
it.add("mineshaft_nutrient_paste", PlainLootAppender( it.add("mineshaft_nutrient_paste", PlainLootAppender(
@ -149,11 +151,13 @@ fun addLootModifiers(it: LootModifiers) {
arrayOf(LootTableIdCondition(BuiltInLootTables.DESERT_PYRAMID)), arrayOf(LootTableIdCondition(BuiltInLootTables.DESERT_PYRAMID)),
ItemStack(MItems.PILL_ANDROID, 1) to 0.15, ItemStack(MItems.PILL_ANDROID, 1) to 0.15,
ItemStack(MItems.PILL_HEAL, 1) to 0.3, ItemStack(MItems.PILL_HEAL, 1) to 0.3,
ItemStack(MItems.PILL_NOT_NORMAL, 3) to 0.25,
)) ))
it.add("jungle_temple_pill", PlainLootAppender( it.add("jungle_temple_pill", PlainLootAppender(
arrayOf(LootTableIdCondition(BuiltInLootTables.JUNGLE_TEMPLE)), arrayOf(LootTableIdCondition(BuiltInLootTables.JUNGLE_TEMPLE)),
ItemStack(MItems.PILL_ANDROID, 1) to 0.5 ItemStack(MItems.PILL_ANDROID, 1) to 0.5,
ItemStack(MItems.PILL_NOT_NORMAL, 8) to 0.2,
)) ))
it.add("end_city_modifications", PlainLootAppender( it.add("end_city_modifications", PlainLootAppender(
@ -161,7 +165,7 @@ fun addLootModifiers(it: LootModifiers) {
ItemStack(MItems.PILL_ANDROID, 1) to 0.15, ItemStack(MItems.PILL_ANDROID, 1) to 0.15,
ItemStack(MItems.PILL_HUMANE, 1) to 0.3, ItemStack(MItems.PILL_HUMANE, 1) to 0.3,
ItemStack(MItems.PILL_OBLIVION, 1) to 0.5, ItemStack(MItems.PILL_OBLIVION, 1) to 0.5,
ItemStack(MItems.ZPM_BATTERY, 1) to 0.005, ItemStack(MItems.ZPM_BATTERY, 1) to 0.01,
)) ))
it.add("shipwreck_supply_pill", PlainLootAppender( it.add("shipwreck_supply_pill", PlainLootAppender(
@ -171,6 +175,7 @@ fun addLootModifiers(it: LootModifiers) {
ItemStack(MItems.PILL_HEAL, 1) to 0.6, ItemStack(MItems.PILL_HEAL, 1) to 0.6,
ItemStack(MItems.PILL_HEAL, 1) to 0.6, ItemStack(MItems.PILL_HEAL, 1) to 0.6,
ItemStack(MItems.PILL_HEAL, 1) to 0.6, ItemStack(MItems.PILL_HEAL, 1) to 0.6,
ItemStack(MItems.PILL_NOT_NORMAL, 4) to 0.25,
)) ))
it.add("shipwreck_supply_nutrient_paste", PlainLootAppender( it.add("shipwreck_supply_nutrient_paste", PlainLootAppender(

View File

@ -0,0 +1,54 @@
package ru.dbotthepony.mc.otm.datagen.recipes
import net.minecraft.data.recipes.RecipeCategory
import net.minecraft.data.recipes.RecipeOutput
import net.minecraft.data.recipes.ShapelessRecipeBuilder
import net.minecraft.data.recipes.SimpleCookingRecipeBuilder
import net.minecraft.world.item.ItemStack
import net.minecraft.world.item.crafting.Ingredient
import net.neoforged.neoforge.common.Tags
import ru.dbotthepony.mc.otm.core.registryName
import ru.dbotthepony.mc.otm.datagen.modLocation
import ru.dbotthepony.mc.otm.registry.MItems
fun addSuspiciousRecipes(consumer: RecipeOutput) {
for (item in MItems.SUSPICIOUS_FOODS.ITEMS) {
if (item.defaultMaxStackSize == 1) {
ShapelessRecipeBuilder.shapeless(RecipeCategory.FOOD, ItemStack(item))
.requires(item.mimicking())
.unlockedBy(MItems.PILL_NOT_NORMAL)
.requires(MItems.PILL_NOT_NORMAL)
.save(consumer)
} else {
ShapelessRecipeBuilder.shapeless(RecipeCategory.FOOD, ItemStack(item, 8))
.requires(item.mimicking(), 8)
.unlockedBy(MItems.PILL_NOT_NORMAL)
.requires(MItems.PILL_NOT_NORMAL)
.save(consumer)
}
}
MatteryRecipe(MItems.SUSPICIOUS_FOODS.GOLDEN_CARROT, 8, RecipeCategory.FOOD)
.row(MItems.SUSPICIOUS_FOODS.CARROT, MItems.SUSPICIOUS_FOODS.CARROT, MItems.SUSPICIOUS_FOODS.CARROT)
.row(MItems.SUSPICIOUS_FOODS.CARROT, Tags.Items.NUGGETS_GOLD, MItems.SUSPICIOUS_FOODS.CARROT)
.row(MItems.SUSPICIOUS_FOODS.CARROT, MItems.SUSPICIOUS_FOODS.CARROT, MItems.SUSPICIOUS_FOODS.CARROT)
.unlockedBy(MItems.SUSPICIOUS_FOODS.CARROT)
.build(consumer, "upgrade")
val cooking = listOf(
MItems.SUSPICIOUS_FOODS.POTATO to MItems.SUSPICIOUS_FOODS.BAKED_POTATO,
MItems.SUSPICIOUS_FOODS.BEEF to MItems.SUSPICIOUS_FOODS.COOKED_BEEF,
MItems.SUSPICIOUS_FOODS.CHICKEN to MItems.SUSPICIOUS_FOODS.COOKED_CHICKEN,
MItems.SUSPICIOUS_FOODS.COD to MItems.SUSPICIOUS_FOODS.COOKED_COD,
MItems.SUSPICIOUS_FOODS.MUTTON to MItems.SUSPICIOUS_FOODS.COOKED_MUTTON,
MItems.SUSPICIOUS_FOODS.PORKCHOP to MItems.SUSPICIOUS_FOODS.COOKED_PORKCHOP,
MItems.SUSPICIOUS_FOODS.RABBIT to MItems.SUSPICIOUS_FOODS.COOKED_RABBIT,
MItems.SUSPICIOUS_FOODS.SALMON to MItems.SUSPICIOUS_FOODS.COOKED_SALMON,
)
for ((source, target) in cooking) {
SimpleCookingRecipeBuilder.smelting(Ingredient.of(source), RecipeCategory.FOOD, target, 0.1f, 200).unlockedBy(source).save(consumer, modLocation("cooking_${source.registryName!!.path}"))
SimpleCookingRecipeBuilder.smoking(Ingredient.of(source), RecipeCategory.FOOD, target, 0.1f, 100).unlockedBy(source).save(consumer, modLocation("smoking_${source.registryName!!.path}"))
SimpleCookingRecipeBuilder.campfireCooking(Ingredient.of(source), RecipeCategory.FOOD, target, 0.1f, 600).unlockedBy(source).save(consumer, modLocation("campfire_cooking_${source.registryName!!.path}"))
}
}

View File

@ -0,0 +1,68 @@
package ru.dbotthepony.mc.otm.datagen.tags
import net.minecraft.tags.ItemTags
import net.minecraft.world.entity.EntityType
import net.minecraft.world.item.Items
import ru.dbotthepony.mc.otm.registry.MItems
fun addSuspiciousTags(tagsProvider: TagsProvider) {
tagsProvider.entityTypes.Appender(MItems.SUSPICIOUS_FOODS.OWNED_MEAT_CONSUMERS)
.add(MItems.SUSPICIOUS_FOODS.MEAT_CONSUMERS)
tagsProvider.entityTypes.Appender(MItems.SUSPICIOUS_FOODS.OWNED_FISH_CONSUMERS)
.add(MItems.SUSPICIOUS_FOODS.FISH_CONSUMERS)
tagsProvider.entityTypes.Appender(MItems.SUSPICIOUS_FOODS.OWNED_COOKIE_CONSUMERS)
.add(MItems.SUSPICIOUS_FOODS.COOKIE_CONSUMERS)
tagsProvider.entityTypes.Appender(MItems.SUSPICIOUS_FOODS.OWNED_CARROT_CONSUMERS)
.add(MItems.SUSPICIOUS_FOODS.CARROT_CONSUMERS)
tagsProvider.entityTypes.Appender(MItems.SUSPICIOUS_FOODS.CARROT_CONSUMERS)
.add(EntityType.RABBIT)
tagsProvider.items.Appender(ItemTags.RABBIT_FOOD)
.add(MItems.SUSPICIOUS_FOODS.CARROT)
tagsProvider.items.Appender(ItemTags.WOLF_FOOD)
.add(MItems.SUSPICIOUS_FOODS.MUTTON)
.add(MItems.SUSPICIOUS_FOODS.CHICKEN)
.add(MItems.SUSPICIOUS_FOODS.BEEF)
.add(MItems.SUSPICIOUS_FOODS.RABBIT)
.add(MItems.SUSPICIOUS_FOODS.PORKCHOP)
.add(MItems.SUSPICIOUS_FOODS.COOKED_MUTTON)
.add(MItems.SUSPICIOUS_FOODS.COOKED_BEEF)
.add(MItems.SUSPICIOUS_FOODS.COOKED_CHICKEN)
.add(MItems.SUSPICIOUS_FOODS.COOKED_RABBIT)
.add(MItems.SUSPICIOUS_FOODS.COOKED_PORKCHOP)
.add(MItems.SUSPICIOUS_FOODS.ROTTEN_FLESH)
tagsProvider.entityTypes.Appender(MItems.SUSPICIOUS_FOODS.MEAT_CONSUMERS)
.add(EntityType.WOLF)
tagsProvider.entityTypes.Appender(MItems.SUSPICIOUS_FOODS.FISH_CONSUMERS)
.add(EntityType.OCELOT)
.add(EntityType.CAT)
tagsProvider.entityTypes.Appender(MItems.SUSPICIOUS_FOODS.COOKIE_CONSUMERS)
.add(EntityType.PARROT)
// Cats easily can eat cooked food and a lot of cats even PREFER to eat fish cooked,
// literally begging for fish when they smell it being cooked (and ignoring it while it lays raw)
// What mojang were thinking?
tagsProvider.items.Appender(ItemTags.OCELOT_FOOD)
.add(Items.COOKED_COD)
.add(Items.COOKED_SALMON)
.add(MItems.SUSPICIOUS_FOODS.COD)
.add(MItems.SUSPICIOUS_FOODS.COOKED_COD)
.add(MItems.SUSPICIOUS_FOODS.SALMON)
.add(MItems.SUSPICIOUS_FOODS.COOKED_SALMON)
tagsProvider.items.Appender(ItemTags.CAT_FOOD)
.add(Items.COOKED_COD)
.add(Items.COOKED_SALMON)
.add(MItems.SUSPICIOUS_FOODS.COD)
.add(MItems.SUSPICIOUS_FOODS.COOKED_COD)
.add(MItems.SUSPICIOUS_FOODS.SALMON)
.add(MItems.SUSPICIOUS_FOODS.COOKED_SALMON)
}

View File

@ -152,7 +152,7 @@ class TagsProvider(private val event: GatherDataEvent) {
val appender = tag(tag) val appender = tag(tag)
for (value in values) { for (value in values) {
appender.addTag(value) appender.addOptionalTag(value)
} }
} }
} }
@ -178,6 +178,7 @@ class TagsProvider(private val event: GatherDataEvent) {
val fluids = Delegate(BuiltInRegistries.FLUID) val fluids = Delegate(BuiltInRegistries.FLUID)
val fluidTypes = Delegate(NeoForgeRegistries.Keys.FLUID_TYPES) val fluidTypes = Delegate(NeoForgeRegistries.Keys.FLUID_TYPES)
val mobEffects = Delegate(BuiltInRegistries.MOB_EFFECT) val mobEffects = Delegate(BuiltInRegistries.MOB_EFFECT)
val entityTypes = Delegate(BuiltInRegistries.ENTITY_TYPE)
val damageTypes = Delegate(Registries.DAMAGE_TYPE) val damageTypes = Delegate(Registries.DAMAGE_TYPE)
private val coloredItems = EnumMap<DyeColor, Delegate<Item>.Appender>(DyeColor::class.java) private val coloredItems = EnumMap<DyeColor, Delegate<Item>.Appender>(DyeColor::class.java)

View File

@ -57,6 +57,7 @@ import ru.dbotthepony.mc.otm.item.tool.ExplosiveHammerItem
import ru.dbotthepony.mc.otm.item.armor.TritaniumArmorItem import ru.dbotthepony.mc.otm.item.armor.TritaniumArmorItem
import ru.dbotthepony.mc.otm.item.QuantumBatteryItem import ru.dbotthepony.mc.otm.item.QuantumBatteryItem
import ru.dbotthepony.mc.otm.item.PortableCondensationDriveItem import ru.dbotthepony.mc.otm.item.PortableCondensationDriveItem
import ru.dbotthepony.mc.otm.item.consumables.NotNormalFood
import ru.dbotthepony.mc.otm.item.tool.RedstoneInteractorItem import ru.dbotthepony.mc.otm.item.tool.RedstoneInteractorItem
import ru.dbotthepony.mc.otm.matter.AbstractRegistryAction import ru.dbotthepony.mc.otm.matter.AbstractRegistryAction
import ru.dbotthepony.mc.otm.matter.IMatterFunction import ru.dbotthepony.mc.otm.matter.IMatterFunction
@ -206,6 +207,8 @@ object OverdriveThatMatters {
FORGE_BUS.addListener(EventPriority.NORMAL, RedstoneInteractorItem::onUse) FORGE_BUS.addListener(EventPriority.NORMAL, RedstoneInteractorItem::onUse)
FORGE_BUS.addListener(EventPriority.NORMAL, NotNormalFood::onInteract)
if (isCuriosLoaded) { if (isCuriosLoaded) {
FORGE_BUS.addListener(EventPriority.NORMAL, ::onCuriosSlotModifiersUpdated) FORGE_BUS.addListener(EventPriority.NORMAL, ::onCuriosSlotModifiersUpdated)
} }

View File

@ -134,7 +134,7 @@ abstract class EnergyCableBlockEntity(type: BlockEntityType<*>, blockPos: BlockP
private var ongoingNewState: Boolean? = null private var ongoingNewState: Boolean? = null
fun updatePoweredState(newState: Boolean) { fun updatePoweredState(newState: Boolean) {
if (isRemoved) return if (isRemoved || !SERVER_IS_LIVE) return
val level = level ?: return val level = level ?: return
if (isPoweredState != newState || ongoingNewState != newState) { if (isPoweredState != newState || ongoingNewState != newState) {

View File

@ -29,7 +29,7 @@ import ru.dbotthepony.mc.otm.core.getEntitiesInEllipsoid
import ru.dbotthepony.mc.otm.core.lookupOrThrow import ru.dbotthepony.mc.otm.core.lookupOrThrow
import ru.dbotthepony.mc.otm.core.math.Vector import ru.dbotthepony.mc.otm.core.math.Vector
import ru.dbotthepony.mc.otm.core.util.countingLazy import ru.dbotthepony.mc.otm.core.util.countingLazy
import ru.dbotthepony.mc.otm.item.EssenceCapsuleItem import ru.dbotthepony.mc.otm.item.consumables.EssenceCapsuleItem
import ru.dbotthepony.mc.otm.item.EssenceServoItem import ru.dbotthepony.mc.otm.item.EssenceServoItem
import ru.dbotthepony.mc.otm.menu.tech.EssenceStorageMenu import ru.dbotthepony.mc.otm.menu.tech.EssenceStorageMenu
import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.registry.MBlockEntities

View File

@ -44,7 +44,7 @@ open class FluidGaugePanel<out S : Screen>(
protected open fun makeTooltip(): MutableList<Component> { protected open fun makeTooltip(): MutableList<Component> {
val tooltip = mutableListOf<Component>( val tooltip = mutableListOf<Component>(
if (widget.fluid.isEmpty) TranslatableComponent("otm.gui.empty") else TextComponent(String.format("%s: %.2f%%", widget.fluid.displayName.string, widget.percentage * 100.0)), if (widget.fluid.isEmpty) TranslatableComponent("otm.gui.empty") else TextComponent(String.format("%s: %.2f%%", widget.fluid.hoverName.string, widget.percentage * 100.0)),
formatFluidLevel(if (widget.fluid.isEmpty) 0 else widget.fluid.amount, widget.maxCapacity, formatAsReadable = ShiftPressedCond) formatFluidLevel(if (widget.fluid.isEmpty) 0 else widget.fluid.amount, widget.maxCapacity, formatAsReadable = ShiftPressedCond)
) )
@ -67,7 +67,7 @@ open class FluidGaugePanel<out S : Screen>(
override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
if (widget.percentage > 0.01f && widget.fluid.isNotEmpty) { if (widget.percentage > 0.01f && widget.fluid.isNotEmpty) {
val data = IClientFluidTypeExtensions.of(widget.fluid.fluid) val data = IClientFluidTypeExtensions.of(widget.fluid.fluid)
val texture = data.stillTexture!! val texture = data.stillTexture
val sprite = minecraft.getTextureAtlas(InventoryMenu.BLOCK_ATLAS).apply(texture)!! val sprite = minecraft.getTextureAtlas(InventoryMenu.BLOCK_ATLAS).apply(texture)!!
val tint = RGBAColor.argb(data.getTintColor(widget.fluid)) val tint = RGBAColor.argb(data.getTintColor(widget.fluid))
var height = (height * widget.percentage) / 16f var height = (height * widget.percentage) / 16f

View File

@ -8,6 +8,7 @@ import mezz.jei.api.gui.handlers.IGuiContainerHandler
import mezz.jei.api.helpers.IJeiHelpers import mezz.jei.api.helpers.IJeiHelpers
import mezz.jei.api.neoforge.NeoForgeTypes import mezz.jei.api.neoforge.NeoForgeTypes
import mezz.jei.api.registration.IGuiHandlerRegistration import mezz.jei.api.registration.IGuiHandlerRegistration
import mezz.jei.api.registration.IModInfoRegistration
import mezz.jei.api.registration.IRecipeCatalystRegistration import mezz.jei.api.registration.IRecipeCatalystRegistration
import mezz.jei.api.registration.IRecipeCategoryRegistration import mezz.jei.api.registration.IRecipeCategoryRegistration
import mezz.jei.api.registration.IRecipeRegistration import mezz.jei.api.registration.IRecipeRegistration
@ -64,12 +65,17 @@ class JEIPlugin : IModPlugin {
return LOCATION return LOCATION
} }
override fun registerModInfo(modAliasRegistration: IModInfoRegistration) {
modAliasRegistration.addModAliases(OverdriveThatMatters.MOD_ID, "otm", "matteroverdrive")
}
override fun registerRecipeCatalysts(registration: IRecipeCatalystRegistration) { override fun registerRecipeCatalysts(registration: IRecipeCatalystRegistration) {
registration.addRecipeCatalyst(ItemStack(MItems.CHEMICAL_GENERATOR[null]!!), RecipeTypes.FUELING) registration.addRecipeCatalyst(ItemStack(MItems.CHEMICAL_GENERATOR[null]!!), RecipeTypes.FUELING)
registration.addRecipeCatalyst(ItemStack(MItems.POWERED_FURNACE[null]!!), RecipeTypes.SMELTING) registration.addRecipeCatalyst(ItemStack(MItems.POWERED_FURNACE[null]!!), RecipeTypes.SMELTING)
registration.addRecipeCatalyst(ItemStack(MItems.ExopackUpgrades.SMELTING_UPGRADE), RecipeTypes.SMELTING) registration.addRecipeCatalyst(ItemStack(MItems.ExopackUpgrades.SMELTING_UPGRADE), RecipeTypes.SMELTING)
registration.addRecipeCatalyst(ItemStack(MItems.POWERED_BLAST_FURNACE[null]!!), RecipeTypes.BLASTING) registration.addRecipeCatalyst(ItemStack(MItems.POWERED_BLAST_FURNACE[null]!!), RecipeTypes.BLASTING)
registration.addRecipeCatalyst(ItemStack(MItems.POWERED_SMOKER[null]!!), RecipeTypes.SMOKING) registration.addRecipeCatalyst(ItemStack(MItems.POWERED_SMOKER[null]!!), RecipeTypes.SMOKING)
registration.addRecipeCatalyst(ItemStack(MItems.GRILL[null]!!), RecipeTypes.SMOKING)
MItems.POWERED_SMOKER.values.forEach { registration.addRecipeCatalyst(ItemStack(it), MicrowaveRecipeCategory.recipeType) } MItems.POWERED_SMOKER.values.forEach { registration.addRecipeCatalyst(ItemStack(it), MicrowaveRecipeCategory.recipeType) }
registration.addRecipeCatalyst(ItemStack(MItems.ExopackUpgrades.CRAFTING_UPGRADE), RecipeTypes.CRAFTING) registration.addRecipeCatalyst(ItemStack(MItems.ExopackUpgrades.CRAFTING_UPGRADE), RecipeTypes.CRAFTING)
registration.addRecipeCatalyst(ItemStack(MItems.ITEM_MONITOR[null]!!), RecipeTypes.CRAFTING) registration.addRecipeCatalyst(ItemStack(MItems.ITEM_MONITOR[null]!!), RecipeTypes.CRAFTING)

View File

@ -29,6 +29,7 @@ import ru.dbotthepony.mc.otm.core.nbt.map
import ru.dbotthepony.mc.otm.core.nbt.mapPresent import ru.dbotthepony.mc.otm.core.nbt.mapPresent
import ru.dbotthepony.mc.otm.core.util.formatMatter import ru.dbotthepony.mc.otm.core.util.formatMatter
import ru.dbotthepony.mc.otm.core.util.formatPower import ru.dbotthepony.mc.otm.core.util.formatPower
import ru.dbotthepony.mc.otm.runIfClient
class TooltipList { class TooltipList {
fun interface TooltipProvider { fun interface TooltipProvider {
@ -67,6 +68,16 @@ class TooltipList {
descriptionLines.add { _, _, result -> result.invoke(component.invoke()) } descriptionLines.add { _, _, result -> result.invoke(component.invoke()) }
} }
@JvmName("addDetailed")
fun addDetailed(component: Component) {
descriptionLines.add { _, _, result -> if (runIfClient(true) { minecraft.window.isShiftDown }) result.invoke(component.copy()) }
}
@JvmName("addDetailedFunction2Component")
fun addDetailed(component: () -> Component) {
descriptionLines.add { _, _, result -> if (runIfClient(true) { minecraft.window.isShiftDown }) result.invoke(component.invoke()) }
}
fun needsNoPower(formatting: ChatFormatting = ChatFormatting.GRAY) { fun needsNoPower(formatting: ChatFormatting = ChatFormatting.GRAY) {
add(TranslatableComponent("otm.needs_no_power").withStyle(formatting)) add(TranslatableComponent("otm.needs_no_power").withStyle(formatting))
} }

View File

@ -1,4 +1,4 @@
package ru.dbotthepony.mc.otm.item package ru.dbotthepony.mc.otm.item.consumables
import net.minecraft.ChatFormatting import net.minecraft.ChatFormatting
import net.minecraft.network.chat.Component import net.minecraft.network.chat.Component
@ -17,8 +17,8 @@ import ru.dbotthepony.mc.otm.capability.matteryPlayer
import ru.dbotthepony.mc.otm.client.isShiftDown import ru.dbotthepony.mc.otm.client.isShiftDown
import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.minecraft
import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.TranslatableComponent
import ru.dbotthepony.mc.otm.core.nbt.set
import ru.dbotthepony.mc.otm.core.util.getLevelFromXp import ru.dbotthepony.mc.otm.core.util.getLevelFromXp
import ru.dbotthepony.mc.otm.item.MatteryItem
import ru.dbotthepony.mc.otm.registry.MDataComponentTypes import ru.dbotthepony.mc.otm.registry.MDataComponentTypes
import ru.dbotthepony.mc.otm.runIfClient import ru.dbotthepony.mc.otm.runIfClient

View File

@ -0,0 +1,48 @@
package ru.dbotthepony.mc.otm.item.consumables
import net.minecraft.ChatFormatting
import net.minecraft.world.InteractionHand
import net.minecraft.world.InteractionResultHolder
import net.minecraft.world.effect.MobEffectInstance
import net.minecraft.world.effect.MobEffects
import net.minecraft.world.entity.LivingEntity
import net.minecraft.world.entity.player.Player
import net.minecraft.world.item.ItemStack
import net.minecraft.world.item.Rarity
import net.minecraft.world.item.UseAnim
import net.minecraft.world.level.Level
import ru.dbotthepony.mc.otm.capability.matteryPlayer
import ru.dbotthepony.mc.otm.core.TranslatableComponent
import ru.dbotthepony.mc.otm.item.MatteryItem
class HealPillItem : MatteryItem(Properties().stacksTo(64).rarity(Rarity.UNCOMMON)) {
override fun getUseDuration(itemStack: ItemStack, p_344979_: LivingEntity): Int {
return 24
}
init {
tooltips.add(TranslatableComponent("otm.pill.heal").withStyle(ChatFormatting.GRAY))
tooltips.add(TranslatableComponent("otm.pill.heal_android").withStyle(ChatFormatting.GRAY))
}
override fun use(level: Level, ply: Player, hand: InteractionHand): InteractionResultHolder<ItemStack> {
if (ply.matteryPlayer.isAndroid)
return super.use(level, ply, hand)
ply.startUsingItem(hand)
return InteractionResultHolder.consume(ply.getItemInHand(hand))
}
override fun finishUsingItem(stack: ItemStack, level: Level, ent: LivingEntity): ItemStack {
if (ent.matteryPlayer?.isAndroid == true)
return super.finishUsingItem(stack, level, ent)
stack.shrink(1)
ent.addEffect(MobEffectInstance(MobEffects.ABSORPTION, 20 * 60 * 2, 4))
ent.addEffect(MobEffectInstance(MobEffects.REGENERATION, 20 * 8, 2))
ent.heal(8f)
return stack
}
override fun getUseAnimation(p_41452_: ItemStack): UseAnim = UseAnim.EAT
}

View File

@ -0,0 +1,142 @@
package ru.dbotthepony.mc.otm.item.consumables
import net.minecraft.ChatFormatting
import net.minecraft.core.component.DataComponentMap
import net.minecraft.network.chat.Component
import net.minecraft.network.chat.Style
import net.minecraft.tags.TagKey
import net.minecraft.world.InteractionHand
import net.minecraft.world.InteractionResult
import net.minecraft.world.InteractionResultHolder
import net.minecraft.world.entity.EntityType
import net.minecraft.world.entity.LivingEntity
import net.minecraft.world.entity.OwnableEntity
import net.minecraft.world.entity.player.Player
import net.minecraft.world.item.Item
import net.minecraft.world.item.ItemStack
import net.minecraft.world.item.UseAnim
import net.minecraft.world.level.Level
import net.minecraft.world.level.gameevent.GameEvent
import net.neoforged.neoforge.event.entity.player.PlayerInteractEvent.EntityInteract
import ru.dbotthepony.mc.otm.capability.matteryPlayer
import ru.dbotthepony.mc.otm.client.isShiftDown
import ru.dbotthepony.mc.otm.client.minecraft
import ru.dbotthepony.mc.otm.core.TranslatableComponent
import ru.dbotthepony.mc.otm.core.damageType
import ru.dbotthepony.mc.otm.item.MatteryItem
import ru.dbotthepony.mc.otm.registry.MDamageTypes
import ru.dbotthepony.mc.otm.registry.MatteryDamageSource
import ru.dbotthepony.mc.otm.runIfClient
class NotNormalFood(
val mimicking: () -> Item,
val usableOn: TagKey<EntityType<*>>? = null,
val usableOnOwned: TagKey<EntityType<*>>? = null
) : MatteryItem(Properties()) { // properties go unused because this item use properties aka components of mimicked item
constructor(mimicking: () -> Item, tags: Pair<TagKey<EntityType<*>>, TagKey<EntityType<*>>>) : this(mimicking, tags.first, tags.second)
init {
tooltips.addDetailed(TranslatableComponent("otm.pill.suspicious_food.desc").withStyle(ChatFormatting.GRAY))
}
override fun components(): DataComponentMap {
return mimicking().components()
}
override fun getDefaultMaxStackSize(): Int {
return mimicking().defaultMaxStackSize
}
override fun getUseAnimation(stack: ItemStack): UseAnim {
return mimicking().getUseAnimation(stack)
}
override fun getUseDuration(stack: ItemStack, entity: LivingEntity): Int {
return mimicking().getUseDuration(stack, entity)
}
override fun use(level: Level, player: Player, hand: InteractionHand): InteractionResultHolder<ItemStack> {
return mimicking().use(level, player, hand)
}
override fun finishUsingItem(stack: ItemStack, level: Level, entity: LivingEntity): ItemStack {
val copy = stack.copy()
val result = mimicking().finishUsingItem(stack, level, entity)
if (entity.matteryPlayer?.isAndroid != true) {
entity.health = 1f
val source = MatteryDamageSource(level.registryAccess().damageType(MDamageTypes.NOT_NORMAL_PILL), inflictor = copy)
entity.invulnerableTime = 0
entity.hurt(source, Float.MAX_VALUE)
if (entity.isAlive)
entity.die(source)
}
return result
}
override fun getDescription(): Component {
if (runIfClient(false) { minecraft.window.isShiftDown }) {
return TranslatableComponent("otm.pill.suspicious_food", mimicking().description)
}
return mimicking().getDescription()
}
override fun getName(stack: ItemStack): Component {
if (runIfClient(false) { minecraft.window.isShiftDown }) {
return TranslatableComponent("otm.pill.suspicious_food", mimicking().getName(stack))
}
return mimicking().getName(stack)
}
override fun getDescriptionId(): String {
if (!runIfClient(false) { minecraft.window.isShiftDown })
return mimicking().getDescriptionId()
return super.getDescriptionId()
}
override fun getDescriptionId(stack: ItemStack): String {
if (!runIfClient(false) { minecraft.window.isShiftDown })
return mimicking().getDescriptionId(stack)
return super.getDescriptionId(stack)
}
companion object {
fun onInteract(event: EntityInteract) {
val item = event.itemStack.item as? NotNormalFood ?: return
val target = event.target as? LivingEntity ?: return
if (
item.usableOn != null && event.target.type.`is`(item.usableOn) ||
item.usableOnOwned != null && event.target.type.`is`(item.usableOnOwned) && event.target is OwnableEntity && (event.target as OwnableEntity).ownerUUID == event.entity.uuid
) {
event.isCanceled = true
val copy = event.itemStack.copy()
if (!event.entity.hasInfiniteMaterials()) {
event.itemStack.shrink(1)
}
event.cancellationResult = InteractionResult.sidedSuccess(target.level().isClientSide)
target.gameEvent(GameEvent.EAT)
if (!target.level().isClientSide) {
target.health = 1f
val source = MatteryDamageSource(target.level().registryAccess().damageType(MDamageTypes.NOT_NORMAL_PILL), inflictor = copy)
target.invulnerableTime = 0
target.hurt(source, Float.MAX_VALUE)
if (target.isAlive)
target.die(source)
}
}
}
}
}

View File

@ -0,0 +1,49 @@
package ru.dbotthepony.mc.otm.item.consumables
import net.minecraft.ChatFormatting
import net.minecraft.world.InteractionHand
import net.minecraft.world.InteractionResultHolder
import net.minecraft.world.entity.LivingEntity
import net.minecraft.world.entity.player.Player
import net.minecraft.world.item.*
import net.minecraft.world.level.Level
import ru.dbotthepony.mc.otm.core.TranslatableComponent
import ru.dbotthepony.mc.otm.capability.matteryPlayer
import ru.dbotthepony.mc.otm.core.damageType
import ru.dbotthepony.mc.otm.item.MatteryItem
import ru.dbotthepony.mc.otm.registry.MDamageTypes
import ru.dbotthepony.mc.otm.registry.MatteryDamageSource
class NotNormalPill : MatteryItem(Properties().stacksTo(64).rarity(Rarity.UNCOMMON)) {
override fun getUseDuration(itemStack: ItemStack, p_344979_: LivingEntity): Int {
return 24
}
init {
tooltips.addDetailed(TranslatableComponent("otm.pill.not_normal").withStyle(ChatFormatting.GRAY))
}
override fun use(level: Level, ply: Player, hand: InteractionHand): InteractionResultHolder<ItemStack> {
ply.startUsingItem(hand)
return InteractionResultHolder.consume(ply.getItemInHand(hand))
}
override fun finishUsingItem(stack: ItemStack, level: Level, ent: LivingEntity): ItemStack {
if (ent.matteryPlayer?.isAndroid == true)
return super.finishUsingItem(stack, level, ent)
val copy = stack.copy()
if (!ent.hasInfiniteMaterials())
stack.shrink(1)
if (!level.isClientSide) {
ent.health = 0f
ent.die(MatteryDamageSource(level.registryAccess().damageType(MDamageTypes.NOT_NORMAL_PILL), inflictor = copy))
}
return stack
}
override fun getUseAnimation(p_41452_: ItemStack): UseAnim = UseAnim.EAT
}

View File

@ -1,56 +1,23 @@
package ru.dbotthepony.mc.otm.item package ru.dbotthepony.mc.otm.item.consumables
import net.minecraft.ChatFormatting import net.minecraft.ChatFormatting
import net.minecraft.network.chat.Component
import net.minecraft.server.level.ServerPlayer import net.minecraft.server.level.ServerPlayer
import net.minecraft.world.InteractionHand import net.minecraft.world.InteractionHand
import net.minecraft.world.InteractionResultHolder import net.minecraft.world.InteractionResultHolder
import net.minecraft.world.effect.MobEffectInstance
import net.minecraft.world.effect.MobEffects
import net.minecraft.world.entity.LivingEntity import net.minecraft.world.entity.LivingEntity
import net.minecraft.world.entity.player.Player import net.minecraft.world.entity.player.Player
import net.minecraft.world.item.* import net.minecraft.world.item.ItemStack
import net.minecraft.world.item.Rarity
import net.minecraft.world.item.UseAnim
import net.minecraft.world.level.Level import net.minecraft.world.level.Level
import ru.dbotthepony.mc.otm.core.TranslatableComponent
import ru.dbotthepony.mc.otm.capability.MatteryCapability
import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.capability.matteryPlayer
import ru.dbotthepony.mc.otm.core.TranslatableComponent
import ru.dbotthepony.mc.otm.item.MatteryItem
enum class PillType { enum class PillType {
BECOME_ANDROID, BECOME_HUMANE, OBLIVION BECOME_ANDROID, BECOME_HUMANE, OBLIVION
} }
class HealPillItem : MatteryItem(Properties().stacksTo(64).rarity(Rarity.UNCOMMON)) {
override fun getUseDuration(itemStack: ItemStack, p_344979_: LivingEntity): Int {
return 24
}
init {
tooltips.add(TranslatableComponent("otm.pill.heal").withStyle(ChatFormatting.GRAY))
tooltips.add(TranslatableComponent("otm.pill.heal_android").withStyle(ChatFormatting.GRAY))
}
override fun use(level: Level, ply: Player, hand: InteractionHand): InteractionResultHolder<ItemStack> {
if (ply.matteryPlayer.isAndroid)
return super.use(level, ply, hand)
ply.startUsingItem(hand)
return InteractionResultHolder.consume(ply.getItemInHand(hand))
}
override fun finishUsingItem(stack: ItemStack, level: Level, ent: LivingEntity): ItemStack {
if (ent.matteryPlayer?.isAndroid == true)
return super.finishUsingItem(stack, level, ent)
stack.shrink(1)
ent.addEffect(MobEffectInstance(MobEffects.ABSORPTION, 20 * 60 * 2, 4))
ent.addEffect(MobEffectInstance(MobEffects.REGENERATION, 20 * 8, 2))
ent.heal(8f)
return stack
}
override fun getUseAnimation(p_41452_: ItemStack): UseAnim = UseAnim.EAT
}
class PillItem(val pillType: PillType) : MatteryItem(Properties().stacksTo(64).rarity(Rarity.UNCOMMON)) { class PillItem(val pillType: PillType) : MatteryItem(Properties().stacksTo(64).rarity(Rarity.UNCOMMON)) {
init { init {
when (pillType) { when (pillType) {

View File

@ -6,12 +6,11 @@ import net.minecraft.world.entity.player.Inventory
import net.minecraft.world.item.ItemStack import net.minecraft.world.item.ItemStack
import net.minecraft.world.item.enchantment.EnchantmentEffectComponents import net.minecraft.world.item.enchantment.EnchantmentEffectComponents
import net.minecraft.world.item.enchantment.EnchantmentHelper import net.minecraft.world.item.enchantment.EnchantmentHelper
import net.minecraft.world.item.enchantment.Enchantments
import ru.dbotthepony.kommons.util.getValue import ru.dbotthepony.kommons.util.getValue
import ru.dbotthepony.mc.otm.block.entity.RedstoneSetting import ru.dbotthepony.mc.otm.block.entity.RedstoneSetting
import ru.dbotthepony.mc.otm.block.entity.tech.EssenceStorageBlockEntity import ru.dbotthepony.mc.otm.block.entity.tech.EssenceStorageBlockEntity
import ru.dbotthepony.mc.otm.core.util.getTotalXpRequiredForLevel import ru.dbotthepony.mc.otm.core.util.getTotalXpRequiredForLevel
import ru.dbotthepony.mc.otm.item.EssenceCapsuleItem import ru.dbotthepony.mc.otm.item.consumables.EssenceCapsuleItem
import ru.dbotthepony.mc.otm.item.EssenceServoItem import ru.dbotthepony.mc.otm.item.EssenceServoItem
import ru.dbotthepony.mc.otm.menu.MatteryMenu import ru.dbotthepony.mc.otm.menu.MatteryMenu
import ru.dbotthepony.mc.otm.menu.MatterySlot import ru.dbotthepony.mc.otm.menu.MatterySlot

View File

@ -10,6 +10,7 @@ import ru.dbotthepony.mc.otm.core.ResourceLocation
object MDamageTypes { object MDamageTypes {
private fun register(name: String): ResourceKey<DamageType> = ResourceKey.create(Registries.DAMAGE_TYPE, ResourceLocation(OverdriveThatMatters.MOD_ID, name)) private fun register(name: String): ResourceKey<DamageType> = ResourceKey.create(Registries.DAMAGE_TYPE, ResourceLocation(OverdriveThatMatters.MOD_ID, name))
val NOT_NORMAL_PILL = register("not_normal_pill")
val BECOME_ANDROID = register("become_android") val BECOME_ANDROID = register("become_android")
val BECOME_HUMANE = register("become_humane") val BECOME_HUMANE = register("become_humane")
val EVENT_HORIZON = register("event_horizon") val EVENT_HORIZON = register("event_horizon")

View File

@ -15,6 +15,7 @@ import net.minecraft.world.item.HoeItem
import net.minecraft.world.item.Item import net.minecraft.world.item.Item
import net.minecraft.world.item.Item.Properties import net.minecraft.world.item.Item.Properties
import net.minecraft.world.item.ItemStack import net.minecraft.world.item.ItemStack
import net.minecraft.world.item.Items
import net.minecraft.world.item.PickaxeItem import net.minecraft.world.item.PickaxeItem
import net.minecraft.world.item.Rarity import net.minecraft.world.item.Rarity
import net.minecraft.world.item.ShearsItem import net.minecraft.world.item.ShearsItem
@ -39,16 +40,16 @@ import ru.dbotthepony.mc.otm.core.math.Decimal
import ru.dbotthepony.mc.otm.item.BatteryItem import ru.dbotthepony.mc.otm.item.BatteryItem
import ru.dbotthepony.mc.otm.item.ChestUpgraderItem import ru.dbotthepony.mc.otm.item.ChestUpgraderItem
import ru.dbotthepony.mc.otm.item.CrudeBatteryItem import ru.dbotthepony.mc.otm.item.CrudeBatteryItem
import ru.dbotthepony.mc.otm.item.EssenceCapsuleItem import ru.dbotthepony.mc.otm.item.consumables.EssenceCapsuleItem
import ru.dbotthepony.mc.otm.item.EssenceServoItem import ru.dbotthepony.mc.otm.item.EssenceServoItem
import ru.dbotthepony.mc.otm.item.FluidCapsuleItem import ru.dbotthepony.mc.otm.item.FluidCapsuleItem
import ru.dbotthepony.mc.otm.item.block.FluidTankItem import ru.dbotthepony.mc.otm.item.block.FluidTankItem
import ru.dbotthepony.mc.otm.item.GravitationalDisruptorItem import ru.dbotthepony.mc.otm.item.GravitationalDisruptorItem
import ru.dbotthepony.mc.otm.item.HealPillItem import ru.dbotthepony.mc.otm.item.consumables.HealPillItem
import ru.dbotthepony.mc.otm.item.MatteryItem import ru.dbotthepony.mc.otm.item.MatteryItem
import ru.dbotthepony.mc.otm.item.MinecartCargoCrateItem import ru.dbotthepony.mc.otm.item.MinecartCargoCrateItem
import ru.dbotthepony.mc.otm.item.PillItem import ru.dbotthepony.mc.otm.item.consumables.PillItem
import ru.dbotthepony.mc.otm.item.PillType import ru.dbotthepony.mc.otm.item.consumables.PillType
import ru.dbotthepony.mc.otm.item.PortableCondensationDriveItem import ru.dbotthepony.mc.otm.item.PortableCondensationDriveItem
import ru.dbotthepony.mc.otm.item.ProceduralBatteryItem import ru.dbotthepony.mc.otm.item.ProceduralBatteryItem
import ru.dbotthepony.mc.otm.item.QuantumBatteryItem import ru.dbotthepony.mc.otm.item.QuantumBatteryItem
@ -58,6 +59,8 @@ import ru.dbotthepony.mc.otm.item.addSimpleDescription
import ru.dbotthepony.mc.otm.item.armor.PortableGravitationStabilizerItem import ru.dbotthepony.mc.otm.item.armor.PortableGravitationStabilizerItem
import ru.dbotthepony.mc.otm.item.armor.TritaniumArmorItem import ru.dbotthepony.mc.otm.item.armor.TritaniumArmorItem
import ru.dbotthepony.mc.otm.item.block.EnergyCableItem import ru.dbotthepony.mc.otm.item.block.EnergyCableItem
import ru.dbotthepony.mc.otm.item.consumables.NotNormalFood
import ru.dbotthepony.mc.otm.item.consumables.NotNormalPill
import ru.dbotthepony.mc.otm.item.exopack.ExopackProbeItem import ru.dbotthepony.mc.otm.item.exopack.ExopackProbeItem
import ru.dbotthepony.mc.otm.item.exopack.ExopackSlotUpgradeItem import ru.dbotthepony.mc.otm.item.exopack.ExopackSlotUpgradeItem
import ru.dbotthepony.mc.otm.item.exopack.ExopackUpgradeItem import ru.dbotthepony.mc.otm.item.exopack.ExopackUpgradeItem
@ -424,14 +427,18 @@ object MItems {
val PILL_HUMANE: Item by registry.register(MNames.PILL_HUMANE) { PillItem(PillType.BECOME_HUMANE) } val PILL_HUMANE: Item by registry.register(MNames.PILL_HUMANE) { PillItem(PillType.BECOME_HUMANE) }
val PILL_OBLIVION: Item by registry.register(MNames.PILL_OBLIVION) { PillItem(PillType.OBLIVION) } val PILL_OBLIVION: Item by registry.register(MNames.PILL_OBLIVION) { PillItem(PillType.OBLIVION) }
val PILL_HEAL: Item by registry.register(MNames.PILL_HEAL) { HealPillItem() } val PILL_HEAL: Item by registry.register(MNames.PILL_HEAL) { HealPillItem() }
val PILL_NOT_NORMAL: Item by registry.register(MNames.PILL_NOT_NORMAL) { NotNormalPill() }
val PILLS = SupplierList( val PILLS = SupplierList(
::PILL_ANDROID, ::PILL_ANDROID,
::PILL_HUMANE, ::PILL_HUMANE,
::PILL_OBLIVION, ::PILL_OBLIVION,
::PILL_HEAL, ::PILL_HEAL,
::PILL_NOT_NORMAL,
) )
val SUSPICIOUS_FOODS = SuspiciousFoods(registry)
val BATTERY_CRUDE: Item by registry.register(MNames.BATTERY_CRUDE) { CrudeBatteryItem() } val BATTERY_CRUDE: Item by registry.register(MNames.BATTERY_CRUDE) { CrudeBatteryItem() }
val BATTERY_BASIC: Item by registry.register(MNames.BATTERY_BASIC) { BatteryItem(ItemsConfig.Batteries.BASIC) } val BATTERY_BASIC: Item by registry.register(MNames.BATTERY_BASIC) { BatteryItem(ItemsConfig.Batteries.BASIC) }
val BATTERY_NORMAL: Item by registry.register(MNames.BATTERY_NORMAL) { BatteryItem(ItemsConfig.Batteries.NORMAL) } val BATTERY_NORMAL: Item by registry.register(MNames.BATTERY_NORMAL) { BatteryItem(ItemsConfig.Batteries.NORMAL) }

View File

@ -108,6 +108,7 @@ object MNames {
const val PILL_HUMANE = "pill_humane" const val PILL_HUMANE = "pill_humane"
const val PILL_OBLIVION = "pill_oblivion" const val PILL_OBLIVION = "pill_oblivion"
const val PILL_HEAL = "pill_heal" const val PILL_HEAL = "pill_heal"
const val PILL_NOT_NORMAL = "pill_not_normal"
const val BATTERY_CRUDE = "battery_crude" const val BATTERY_CRUDE = "battery_crude"
const val BATTERY_BASIC = "battery_basic" const val BATTERY_BASIC = "battery_basic"

View File

@ -24,10 +24,12 @@ class MatteryDamageSource(
val itemStack = inflictor ?: (entity as? LivingEntity)?.mainHandItem ?: ItemStack.EMPTY val itemStack = inflictor ?: (entity as? LivingEntity)?.mainHandItem ?: ItemStack.EMPTY
if (!itemStack.isEmpty && itemStack.has(DataComponents.CUSTOM_NAME)) { if (!itemStack.isEmpty && itemStack.has(DataComponents.CUSTOM_NAME)) {
return TranslatableComponent("death.attack.$msgId.player.item", victim.displayName!!, entity!!.displayName!!, itemStack.displayName) if (entity?.displayName == null) {
} return TranslatableComponent("death.attack.$msgId.item", victim.displayName!!, itemStack.displayName)
} else {
if (entity != null) { return TranslatableComponent("death.attack.$msgId.player.item", victim.displayName!!, entity!!.displayName!!, itemStack.displayName)
}
} else if (entity != null) {
return TranslatableComponent("death.attack.$msgId.player", victim.displayName!!, entity!!.displayName!!) return TranslatableComponent("death.attack.$msgId.player", victim.displayName!!, entity!!.displayName!!)
} }

View File

@ -0,0 +1,79 @@
package ru.dbotthepony.mc.otm.registry
import net.minecraft.core.registries.Registries
import net.minecraft.tags.TagKey
import net.minecraft.world.entity.EntityType
import net.minecraft.world.item.Item
import net.minecraft.world.item.Items
import ru.dbotthepony.mc.otm.OverdriveThatMatters
import ru.dbotthepony.mc.otm.core.ResourceLocation
import ru.dbotthepony.mc.otm.core.collect.SupplierList
import ru.dbotthepony.mc.otm.item.consumables.NotNormalFood
@Suppress("PropertyName")
class SuspiciousFoods(registry: MDeferredRegister<Item>) {
val OWNED_MEAT_CONSUMERS: TagKey<EntityType<*>> = TagKey.create(Registries.ENTITY_TYPE, ResourceLocation(OverdriveThatMatters.MOD_ID, "owned_consumes_suspicious_meat"))
val OWNED_FISH_CONSUMERS: TagKey<EntityType<*>> = TagKey.create(Registries.ENTITY_TYPE, ResourceLocation(OverdriveThatMatters.MOD_ID, "owned_consumes_suspicious_fish"))
val OWNED_EXOTIC_FISH_CONSUMERS: TagKey<EntityType<*>> = TagKey.create(Registries.ENTITY_TYPE, ResourceLocation(OverdriveThatMatters.MOD_ID, "owned_consumes_suspicious_fish"))
val OWNED_COOKIE_CONSUMERS: TagKey<EntityType<*>> = TagKey.create(Registries.ENTITY_TYPE, ResourceLocation(OverdriveThatMatters.MOD_ID, "owned_consumes_suspicious_cookie"))
val OWNED_CARROT_CONSUMERS: TagKey<EntityType<*>> = TagKey.create(Registries.ENTITY_TYPE, ResourceLocation(OverdriveThatMatters.MOD_ID, "owned_consumes_suspicious_carrot"))
val MEAT_CONSUMERS: TagKey<EntityType<*>> = TagKey.create(Registries.ENTITY_TYPE, ResourceLocation(OverdriveThatMatters.MOD_ID, "consumes_suspicious_meat"))
val FISH_CONSUMERS: TagKey<EntityType<*>> = TagKey.create(Registries.ENTITY_TYPE, ResourceLocation(OverdriveThatMatters.MOD_ID, "consumes_suspicious_fish"))
val EXOTIC_FISH_CONSUMERS: TagKey<EntityType<*>> = TagKey.create(Registries.ENTITY_TYPE, ResourceLocation(OverdriveThatMatters.MOD_ID, "consumes_suspicious_fish"))
val COOKIE_CONSUMERS: TagKey<EntityType<*>> = TagKey.create(Registries.ENTITY_TYPE, ResourceLocation(OverdriveThatMatters.MOD_ID, "consumes_suspicious_cookie"))
val CARROT_CONSUMERS: TagKey<EntityType<*>> = TagKey.create(Registries.ENTITY_TYPE, ResourceLocation(OverdriveThatMatters.MOD_ID, "consumes_suspicious_carrot"))
private val meat = MEAT_CONSUMERS to OWNED_MEAT_CONSUMERS
private val fish = FISH_CONSUMERS to OWNED_FISH_CONSUMERS
private val efish = EXOTIC_FISH_CONSUMERS to OWNED_EXOTIC_FISH_CONSUMERS
val APPLE by registry.register("suspicious_apple") { NotNormalFood({ Items.APPLE }) }
val BAKED_POTATO by registry.register("suspicious_baked_potato") { NotNormalFood({ Items.BAKED_POTATO }) }
val BEEF by registry.register("suspicious_beef") { NotNormalFood({ Items.BEEF }, meat) }
val BEETROOT by registry.register("suspicious_beetroot") { NotNormalFood({ Items.BEETROOT }) }
val BEETROOT_SOUP by registry.register("suspicious_beetroot_soup") { NotNormalFood({ Items.BEETROOT_SOUP }) }
val BREAD by registry.register("suspicious_bread") { NotNormalFood({ Items.BREAD }) }
val CARROT by registry.register("suspicious_carrot") { NotNormalFood({ Items.CARROT }, CARROT_CONSUMERS, OWNED_CARROT_CONSUMERS) }
val CHICKEN by registry.register("suspicious_chicken") { NotNormalFood({ Items.CHICKEN }, meat) }
val CHORUS_FRUIT by registry.register("suspicious_chorus_fruit") { NotNormalFood({ Items.CHORUS_FRUIT }) }
val COD by registry.register("suspicious_cod") { NotNormalFood({ Items.COD }, fish) }
val COOKED_BEEF by registry.register("suspicious_cooked_beef") { NotNormalFood({ Items.COOKED_BEEF }, meat) }
val COOKED_CHICKEN by registry.register("suspicious_cooked_chicken") { NotNormalFood({ Items.COOKED_CHICKEN }, meat) }
val COOKED_COD by registry.register("suspicious_cooked_cod") { NotNormalFood({ Items.COOKED_COD }, fish) }
val COOKED_MUTTON by registry.register("suspicious_cooked_mutton") { NotNormalFood({ Items.COOKED_MUTTON }, meat) }
val COOKED_PORKCHOP by registry.register("suspicious_cooked_porkchop") { NotNormalFood({ Items.COOKED_PORKCHOP }, meat) }
val COOKED_RABBIT by registry.register("suspicious_cooked_rabbit") { NotNormalFood({ Items.COOKED_RABBIT }, meat) }
val COOKED_SALMON by registry.register("suspicious_cooked_salmon") { NotNormalFood({ Items.COOKED_SALMON }, fish) }
val COOKIE by registry.register("suspicious_cookie") { NotNormalFood({ Items.COOKIE }, COOKIE_CONSUMERS, OWNED_COOKIE_CONSUMERS) }
val ENCHANTED_GOLDEN_APPLE by registry.register("suspicious_enchanted_golden_apple") { NotNormalFood({ Items.ENCHANTED_GOLDEN_APPLE }) }
val GOLDEN_APPLE by registry.register("suspicious_golden_apple") { NotNormalFood({ Items.GOLDEN_APPLE }) }
val GOLDEN_CARROT by registry.register("suspicious_golden_carrot") { NotNormalFood({ Items.GOLDEN_CARROT }, CARROT_CONSUMERS, OWNED_CARROT_CONSUMERS) }
val MELON_SLICE by registry.register("suspicious_melon_slice") { NotNormalFood({ Items.MELON_SLICE }) }
val MUSHROOM_STEW by registry.register("suspicious_mushroom_stew") { NotNormalFood({ Items.MUSHROOM_STEW }) }
val MUTTON by registry.register("suspicious_mutton") { NotNormalFood({ Items.MUTTON }, meat) }
val POISONOUS_POTATO by registry.register("suspicious_poisonous_potato") { NotNormalFood({ Items.POISONOUS_POTATO }) }
val PORKCHOP by registry.register("suspicious_porkchop") { NotNormalFood({ Items.PORKCHOP }, meat) }
val POTATO by registry.register("suspicious_potato") { NotNormalFood({ Items.POTATO }) }
val PUFFERFISH by registry.register("suspicious_pufferfish") { NotNormalFood({ Items.PUFFERFISH }, efish) }
val PUMPKIN_PIE by registry.register("suspicious_pumpkin_pie") { NotNormalFood({ Items.PUMPKIN_PIE }) }
val RABBIT by registry.register("suspicious_rabbit") { NotNormalFood({ Items.RABBIT }, meat) }
val RABBIT_STEW by registry.register("suspicious_rabbit_stew") { NotNormalFood({ Items.RABBIT_STEW }) }
val ROTTEN_FLESH by registry.register("suspicious_rotten_flesh") { NotNormalFood({ Items.ROTTEN_FLESH }, meat) }
val SALMON by registry.register("suspicious_salmon") { NotNormalFood({ Items.SALMON }, fish) }
val SWEET_BERRIES by registry.register("suspicious_sweet_berries") { NotNormalFood({ Items.SWEET_BERRIES }) }
val GLOW_BERRIES by registry.register("suspicious_glow_berries") { NotNormalFood({ Items.GLOW_BERRIES }) }
val TROPICAL_FISH by registry.register("suspicious_tropical_fish") { NotNormalFood({ Items.TROPICAL_FISH }, efish) }
val ITEMS = SupplierList(
::APPLE, ::BAKED_POTATO, ::BEEF,
::BEETROOT, ::BEETROOT_SOUP, ::BREAD, ::CARROT, ::CHICKEN, ::CHORUS_FRUIT, ::COD,
::COOKED_BEEF, ::COOKED_CHICKEN, ::COOKED_COD, ::COOKED_MUTTON, ::COOKED_PORKCHOP, ::COOKED_RABBIT, ::COOKED_SALMON, ::COOKIE, ::ENCHANTED_GOLDEN_APPLE,
::GOLDEN_APPLE, ::GOLDEN_CARROT, ::MELON_SLICE, ::MUSHROOM_STEW, ::MUTTON, ::POISONOUS_POTATO, ::PORKCHOP, ::POTATO,
::PUFFERFISH, ::PUMPKIN_PIE, ::RABBIT, ::RABBIT_STEW, ::ROTTEN_FLESH, ::SALMON, ::SWEET_BERRIES, ::GLOW_BERRIES, ::TROPICAL_FISH,
)
// "dried_kelp" to { Items.DRIED_KELP },
// "spider_eye" to { Items.SPIDER_EYE },
// "honey_bottle" to { Items.HONEY_BOTTLE },
}