Compare commits
148 Commits
Author | SHA1 | Date | |
---|---|---|---|
ecb8a8ecd0 | |||
c83476225d | |||
f0846a7b3a | |||
f8277e55c3 | |||
e9f4b22cb8 | |||
49dd781a82 | |||
baeef3816f | |||
9264e24c42 | |||
65dbeeeb4f | |||
f6138671d2 | |||
34b60be434 | |||
6153c2e972 | |||
b6ef6c5e8e | |||
376e548cec | |||
5829dc8e5a | |||
653ecedafb | |||
5f6fb9c731 | |||
87e64a102a | |||
0b7e54b4ef | |||
f0dba4ccc3 | |||
5eb78b6e9c | |||
b35dfaeacd | |||
6e143e072d | |||
6a2eb3dec2 | |||
410ba675ea | |||
ce94d22212 | |||
fccf97c4c8 | |||
21b84651a8 | |||
55c975f1e8 | |||
80917f7d12 | |||
07bc48887e | |||
12b10ee6fe | |||
9e72d73bfd | |||
a88549f17f | |||
5552be70d5 | |||
d29f68fc4e | |||
cb386d39f5 | |||
6bbe2f2750 | |||
22c3c22081 | |||
562e6c509f | |||
0da77bc453 | |||
4a606b8d36 | |||
f2aade3a8e | |||
46820a311f | |||
19b4942c90 | |||
3743a3402d | |||
d88801d8bf | |||
055b9cc489 | |||
f1df27d5d7 | |||
640f62d63b | |||
c88023470f | |||
d3423a6160 | |||
55c0be74d3 | |||
a59fe8c256 | |||
9d9b19da9d | |||
6dce3a37e6 | |||
652acf3ce1 | |||
6eb3700f88 | |||
101e57756a | |||
0695f613d3 | |||
67dbcde6dc | |||
04ce837b02 | |||
b4c994f02f | |||
ef997ca1fe | |||
8007c1757e | |||
7e6a150ab7 | |||
8aafa38c27 | |||
cc164f669d | |||
e51ba7015a | |||
ee624f1b3f | |||
1d0e24095a | |||
2b884739f4 | |||
a7d405b5ea | |||
74183f0982 | |||
8ee5e94a78 | |||
76c4c3e6a2 | |||
a68c08ecf8 | |||
f9dcf43cc4 | |||
42fe77e6b4 | |||
bc59853f4e | |||
9b80162a03 | |||
b28e180704 | |||
2deaef94aa | |||
cac468685e | |||
78ac178526 | |||
c98562f2cb | |||
92f2680feb | |||
b8f98f0e9e | |||
077e82064b | |||
62cc823e29 | |||
c821fa76a6 | |||
1d68f32b19 | |||
6e4bf4e7ec | |||
ae544e8844 | |||
d96a0e1a63 | |||
5b45cf7d0a | |||
37e7f42587 | |||
7f15ae6a3a | |||
edea36a8a6 | |||
ad76b4cabc | |||
7258e1e4d3 | |||
34ef50f6ee | |||
4c5c2362ce | |||
5ad9d49537 | |||
54fa8a252e | |||
4e3ca82fc7 | |||
d84af00876 | |||
a9cb2db3b4 | |||
454e4f6a63 | |||
6dbd942626 | |||
748a232569 | |||
da4c1108c2 | |||
c4bcab44e4 | |||
8e469c309d | |||
f3bf84a7a2 | |||
b6643a6dd3 | |||
31268e33ef | |||
86c426a504 | |||
afe7d698c8 | |||
0bcc078fe9 | |||
e3e02dbad2 | |||
e563b85946 | |||
cc82146f0a | |||
f4ec4c9066 | |||
108b49bedb | |||
1a5a9a6303 | |||
bf46ac0647 | |||
71850b38e5 | |||
796f29127f | |||
8c43a3ec6d | |||
477e782c7c | |||
65cf8bf9df | |||
e5a982ae13 | |||
f942093e4f | |||
5d15611f84 | |||
1803d687ab | |||
347be35184 | |||
aa0a283e06 | |||
98fcacc9a8 | |||
422ae92303 | |||
7683cacc29 | |||
520112df77 | |||
5453c8c793 | |||
3c5ea937a5 | |||
f16483d7c0 | |||
8072a7b135 | |||
44c6d0c0cf | |||
27dce0bd31 |
@ -150,14 +150,13 @@ dependencies {
|
||||
val configured_id: String by project
|
||||
val curios_version: String by project
|
||||
val jei_mc_version: String by project
|
||||
val curios_mc_version: String by project
|
||||
val resourceful_lib_id: String by project
|
||||
val resourceful_config_id: String by project
|
||||
val botarium_id: String by project
|
||||
val ad_astra_id: String by project
|
||||
val worldedit_id: String by project
|
||||
|
||||
compileOnly(fg.deobf("top.theillusivec4.curios:curios-forge:${curios_version}+${curios_mc_version}"))
|
||||
compileOnly(fg.deobf("curse.maven:curios-309927:${curios_version}"))
|
||||
compileOnly(fg.deobf("curse.maven:cosmetic-armor-reworked-237307:$cosmetic_armor_reworked_id"))
|
||||
|
||||
compileOnly(fg.deobf("mezz.jei:jei-${jei_mc_version}-common-api:${jei_version}"))
|
||||
|
@ -10,28 +10,28 @@ mod_version=1.4
|
||||
|
||||
use_commit_hash_in_version=true
|
||||
|
||||
mc_version=1.20.2
|
||||
jei_mc_version=1.20.2
|
||||
curios_mc_version=1.20.2
|
||||
mc_version=1.19.4
|
||||
jei_mc_version=1.19.4
|
||||
curios_mc_version=1.19.4
|
||||
|
||||
forge_gradle_version=[6.0.14,6.2)
|
||||
forge_version=48.1.0
|
||||
forge_version=45.2.8
|
||||
mixingradle_version=0.7.33
|
||||
mixin_version=0.8.5
|
||||
|
||||
kommons_version=3.0.2
|
||||
|
||||
jei_version=16.0.0.28
|
||||
jei_version=13.1.0.16
|
||||
jupiter_version=5.9.2
|
||||
curios_version=6.0.2
|
||||
cosmetic_armor_reworked_id=4764779
|
||||
curios_version=4834414
|
||||
cosmetic_armor_reworked_id=4439659
|
||||
ad_astra_id=4594155
|
||||
botarium_id=4594094
|
||||
resourceful_lib_id=4598948
|
||||
resourceful_config_id=4576455
|
||||
jade_id=4818518
|
||||
jade_id=4573063
|
||||
configured_id=4462894
|
||||
worldedit_id=4807512
|
||||
worldedit_id=4445118
|
||||
|
||||
kotlin_for_forge_version=4.7.0
|
||||
kotlin_version=1.9.0
|
||||
|
@ -1,9 +1,8 @@
|
||||
package ru.dbotthepony.mc.otm.datagen.advancements
|
||||
|
||||
import net.minecraft.advancements.AdvancementHolder
|
||||
import net.minecraft.advancements.AdvancementRewards
|
||||
import net.minecraft.advancements.FrameType
|
||||
import net.minecraft.advancements.AdvancementRequirements.Strategy
|
||||
import net.minecraft.advancements.RequirementsStrategy
|
||||
import net.minecraft.advancements.critereon.InventoryChangeTrigger
|
||||
import net.minecraft.world.item.DyeColor
|
||||
import net.minecraft.world.item.ItemStack
|
||||
@ -17,6 +16,8 @@ import ru.dbotthepony.mc.otm.triggers.BlackHoleTrigger
|
||||
import ru.dbotthepony.mc.otm.triggers.NailedEntityTrigger
|
||||
import java.util.function.Consumer
|
||||
|
||||
typealias Strategy = RequirementsStrategy
|
||||
|
||||
fun addAdvancements(serializer: Consumer<AdvancementHolder>, lang: MatteryLanguageProvider) {
|
||||
val translation = lang.MultiBuilder("otm.advancements.regular")
|
||||
|
||||
|
@ -1,7 +1,5 @@
|
||||
package ru.dbotthepony.mc.otm.datagen.advancements
|
||||
|
||||
import net.minecraft.advancements.AdvancementHolder
|
||||
import net.minecraft.advancements.AdvancementRequirements.Strategy
|
||||
import net.minecraft.advancements.AdvancementRewards
|
||||
import net.minecraft.advancements.FrameType
|
||||
import net.minecraft.advancements.critereon.EntityPredicate
|
||||
|
@ -1,12 +1,9 @@
|
||||
package ru.dbotthepony.mc.otm.datagen.advancements
|
||||
|
||||
import net.minecraft.advancements.Advancement
|
||||
import net.minecraft.advancements.AdvancementHolder
|
||||
import net.minecraft.advancements.FrameType
|
||||
import net.minecraft.advancements.critereon.ItemPredicate
|
||||
import net.minecraft.world.item.ItemStack
|
||||
import net.minecraft.world.item.Items
|
||||
import net.minecraftforge.common.data.ExistingFileHelper
|
||||
import ru.dbotthepony.mc.otm.datagen.lang.MatteryLanguageProvider
|
||||
import ru.dbotthepony.mc.otm.datagen.modLocation
|
||||
import ru.dbotthepony.mc.otm.registry.MItems
|
||||
|
@ -1,11 +1,9 @@
|
||||
package ru.dbotthepony.mc.otm.datagen.advancements
|
||||
|
||||
import net.minecraft.advancements.Advancement
|
||||
import net.minecraft.advancements.Criterion
|
||||
import net.minecraft.advancements.CriterionTriggerInstance
|
||||
import net.minecraft.advancements.DisplayInfo
|
||||
import net.minecraft.advancements.FrameType
|
||||
import net.minecraft.advancements.critereon.ContextAwarePredicate
|
||||
import net.minecraft.advancements.critereon.EntityPredicate
|
||||
import net.minecraft.advancements.critereon.InventoryChangeTrigger
|
||||
import net.minecraft.advancements.critereon.ItemPredicate
|
||||
@ -16,6 +14,7 @@ import net.minecraft.world.item.Item
|
||||
import net.minecraft.world.item.ItemStack
|
||||
import net.minecraft.world.level.ItemLike
|
||||
import ru.dbotthepony.mc.otm.core.TextComponent
|
||||
import java.util.function.Consumer
|
||||
|
||||
fun AdvancementBuilder(): Advancement.Builder = Advancement.Builder.advancement()
|
||||
|
||||
@ -58,7 +57,7 @@ fun predicate(tag: TagKey<Item>): ItemPredicate {
|
||||
return ItemPredicate.Builder.item().of(tag).build()
|
||||
}
|
||||
|
||||
fun criterion(tag: TagKey<Item>): Criterion<*> {
|
||||
fun criterion(tag: TagKey<Item>): CriterionTriggerInstance {
|
||||
return InventoryChangeTrigger.TriggerInstance.hasItems(predicate(tag))
|
||||
}
|
||||
|
||||
@ -66,8 +65,10 @@ fun predicate(item: ItemLike): ItemPredicate {
|
||||
return ItemPredicate.Builder.item().of(item).build()
|
||||
}
|
||||
|
||||
fun criterion(item: ItemLike): Criterion<*> {
|
||||
fun criterion(item: ItemLike): CriterionTriggerInstance {
|
||||
return InventoryChangeTrigger.TriggerInstance.hasItems(predicate(item))
|
||||
}
|
||||
|
||||
fun EntityPredicate.wrap(): ContextAwarePredicate = EntityPredicate.wrap(this)
|
||||
fun EntityPredicate.wrap(): EntityPredicate.Composite = EntityPredicate.Composite.wrap(this)
|
||||
|
||||
fun Advancement.Builder.save(advancement: Consumer<Advancement>, name: ResourceLocation) = save(advancement, name.toString())
|
||||
|
@ -1,8 +1,8 @@
|
||||
package ru.dbotthepony.mc.otm.datagen.advancements
|
||||
|
||||
import net.minecraft.advancements.AdvancementHolder
|
||||
import net.minecraft.advancements.AdvancementRequirements
|
||||
import net.minecraft.advancements.Advancement
|
||||
import net.minecraft.advancements.FrameType
|
||||
import net.minecraft.advancements.RequirementsStrategy
|
||||
import net.minecraft.advancements.critereon.ItemPredicate
|
||||
import net.minecraft.world.item.Item
|
||||
import net.minecraft.world.item.ItemStack
|
||||
@ -16,6 +16,8 @@ import ru.dbotthepony.mc.otm.registry.MItems
|
||||
import ru.dbotthepony.mc.otm.triggers.TakeItemOutOfReplicatorTrigger
|
||||
import java.util.function.Consumer
|
||||
|
||||
typealias AdvancementHolder = Advancement
|
||||
|
||||
data class CraftEntry(
|
||||
val item: Collection<Item>,
|
||||
val englishName: String,
|
||||
@ -59,7 +61,7 @@ data class CraftEntry(
|
||||
it.addCriterion(i.toString(), criterion(item))
|
||||
}
|
||||
}
|
||||
.requirements(AdvancementRequirements.Strategy.OR)
|
||||
.requirements(RequirementsStrategy.OR)
|
||||
.save(serializer, modLocation("machines/$path"))
|
||||
}
|
||||
}
|
||||
@ -82,7 +84,7 @@ fun addMachineAdvancements(serializer: Consumer<AdvancementHolder>, lang: Matter
|
||||
for ((i, v) in MItems.CHEMICAL_GENERATOR.values.withIndex())
|
||||
it.addCriterion("has_machine_$i", criterion(v))
|
||||
}
|
||||
.requirements(AdvancementRequirements.Strategy.OR)
|
||||
.requirements(RequirementsStrategy.OR)
|
||||
.save(serializer, modLocation("machines/chemical_generator"))
|
||||
|
||||
val press = AdvancementBuilder()
|
||||
@ -100,7 +102,7 @@ fun addMachineAdvancements(serializer: Consumer<AdvancementHolder>, lang: Matter
|
||||
for ((i, m) in MItems.TWIN_PLATE_PRESS.values.withIndex())
|
||||
it.addCriterion(i.toString(), criterion(m))
|
||||
}
|
||||
.requirements(AdvancementRequirements.Strategy.OR)
|
||||
.requirements(RequirementsStrategy.OR)
|
||||
.save(serializer, modLocation("machines/plate_press"))
|
||||
|
||||
CraftEntry(MItems.ENERGY_SERVO.values, "Power Goes In, Powered Things Go Out",
|
||||
|
@ -1,7 +1,6 @@
|
||||
package ru.dbotthepony.mc.otm.datagen.recipes
|
||||
|
||||
import net.minecraft.data.recipes.RecipeCategory
|
||||
import net.minecraft.data.recipes.RecipeOutput
|
||||
import net.minecraft.tags.ItemTags
|
||||
import net.minecraftforge.common.Tags
|
||||
import ru.dbotthepony.mc.otm.registry.MItemTags
|
||||
|
@ -1,14 +1,12 @@
|
||||
package ru.dbotthepony.mc.otm.datagen.recipes
|
||||
|
||||
import net.minecraft.data.recipes.RecipeCategory
|
||||
import net.minecraft.data.recipes.RecipeOutput
|
||||
import net.minecraft.data.recipes.SimpleCookingRecipeBuilder
|
||||
import net.minecraft.util.valueproviders.ConstantFloat
|
||||
import net.minecraft.world.item.Item
|
||||
import net.minecraft.world.item.ItemStack
|
||||
import net.minecraft.world.item.crafting.Ingredient
|
||||
import net.minecraft.world.level.ItemLike
|
||||
import ru.dbotthepony.mc.otm.core.registryName
|
||||
import ru.dbotthepony.mc.otm.datagen.modLocation
|
||||
import ru.dbotthepony.mc.otm.registry.MItemTags
|
||||
import ru.dbotthepony.mc.otm.registry.MItems
|
||||
|
@ -1,8 +1,6 @@
|
||||
package ru.dbotthepony.mc.otm.datagen.recipes
|
||||
|
||||
import net.minecraft.data.recipes.FinishedRecipe
|
||||
import net.minecraft.data.recipes.RecipeCategory
|
||||
import net.minecraft.data.recipes.RecipeOutput
|
||||
import net.minecraft.data.recipes.ShapelessRecipeBuilder
|
||||
import net.minecraft.tags.ItemTags
|
||||
import net.minecraft.world.item.ItemStack
|
||||
@ -17,7 +15,6 @@ import ru.dbotthepony.mc.otm.registry.MRegistry
|
||||
import ru.dbotthepony.mc.otm.core.registryName
|
||||
import ru.dbotthepony.mc.otm.datagen.modLocation
|
||||
import ru.dbotthepony.mc.otm.recipe.UpgradeRecipe
|
||||
import java.util.function.Consumer
|
||||
|
||||
fun addCraftingTableRecipes(consumer: RecipeOutput) {
|
||||
val machinesCategory = RecipeCategory.DECORATIONS
|
||||
|
@ -1,6 +1,5 @@
|
||||
package ru.dbotthepony.mc.otm.datagen.recipes
|
||||
|
||||
import net.minecraft.data.recipes.RecipeOutput
|
||||
import net.minecraft.world.item.Items
|
||||
import net.minecraftforge.common.Tags
|
||||
import ru.dbotthepony.mc.otm.registry.MItemTags
|
||||
|
@ -1,6 +1,5 @@
|
||||
package ru.dbotthepony.mc.otm.datagen.recipes
|
||||
|
||||
import net.minecraft.data.recipes.RecipeOutput
|
||||
import net.minecraft.world.item.ItemStack
|
||||
import net.minecraft.world.item.crafting.Ingredient
|
||||
import net.minecraftforge.common.Tags
|
||||
@ -14,6 +13,7 @@ import ru.dbotthepony.mc.otm.registry.MItems
|
||||
fun addMatterEntanglerRecipes(consumer: RecipeOutput) {
|
||||
consumer.accept(
|
||||
MatterEntanglerRecipe(
|
||||
modLocation("quantum_capacitor"),
|
||||
IngredientMatrix.of(
|
||||
listOf(Ingredient.of(MItems.ELECTRIC_PARTS), Ingredient.of(MItemTags.GOLD_WIRES), Ingredient.of(MItems.ELECTRIC_PARTS)),
|
||||
listOf(Ingredient.of(MItems.BATTERY_CAPACITOR), Ingredient.of(MItems.QUANTUM_TRANSCEIVER), Ingredient.of(MItems.BATTERY_CAPACITOR)),
|
||||
@ -23,11 +23,12 @@ fun addMatterEntanglerRecipes(consumer: RecipeOutput) {
|
||||
400.0,
|
||||
ItemStack(MItems.QUANTUM_CAPACITOR, 2),
|
||||
experience = 15f
|
||||
).energetic().toFinished(modLocation("quantum_capacitor"))
|
||||
).energetic().toFinished()
|
||||
)
|
||||
|
||||
consumer.accept(
|
||||
MatterEntanglerRecipe(
|
||||
modLocation("quantum_battery"),
|
||||
IngredientMatrix.of(
|
||||
listOf(Ingredient.of(Tags.Items.STORAGE_BLOCKS_REDSTONE), Ingredient.of(MItemTags.GOLD_WIRES), Ingredient.of(Tags.Items.STORAGE_BLOCKS_REDSTONE)),
|
||||
listOf(Ingredient.of(MItems.BATTERY_DENSE), Ingredient.of(MItems.QUANTUM_TRANSCEIVER), Ingredient.of(MItems.BATTERY_DENSE)),
|
||||
@ -37,6 +38,6 @@ fun addMatterEntanglerRecipes(consumer: RecipeOutput) {
|
||||
600.0,
|
||||
ItemStack(MItems.QUANTUM_BATTERY, 2),
|
||||
experience = 20f
|
||||
).energetic().toFinished(modLocation("quantum_battery"))
|
||||
).energetic().toFinished()
|
||||
)
|
||||
}
|
||||
|
@ -7,7 +7,6 @@ import net.minecraft.advancements.Criterion
|
||||
import net.minecraft.advancements.CriterionTriggerInstance
|
||||
import net.minecraft.data.recipes.FinishedRecipe
|
||||
import net.minecraft.data.recipes.RecipeCategory
|
||||
import net.minecraft.data.recipes.RecipeOutput
|
||||
import net.minecraft.data.recipes.ShapedRecipeBuilder
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
import net.minecraft.tags.TagKey
|
||||
@ -62,10 +61,6 @@ private fun RecipeOutput.map(mapper: (FinishedRecipe) -> FinishedRecipe): Recipe
|
||||
override fun accept(recipe: FinishedRecipe) {
|
||||
this@map.accept(mapper(recipe))
|
||||
}
|
||||
|
||||
override fun advancement(): Advancement.Builder {
|
||||
return this@map.advancement()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -77,11 +72,11 @@ class MatteryRecipe(val result: ItemLike, val count: Int = 1, val category: Reci
|
||||
private val rows = arrayOfNulls<RecipeRow>(3)
|
||||
private var index = 0
|
||||
|
||||
private val unlockedBy = ArrayList<Pair<String, Criterion<*>>>().also {
|
||||
private val unlockedBy = ArrayList<Pair<String, CriterionTriggerInstance>>().also {
|
||||
it.add("has_result" to has(result))
|
||||
}
|
||||
|
||||
fun unlockedBy(name: String, trigger: Criterion<*>): MatteryRecipe {
|
||||
fun unlockedBy(name: String, trigger: CriterionTriggerInstance): MatteryRecipe {
|
||||
unlockedBy.add(name to trigger)
|
||||
return this
|
||||
}
|
||||
@ -195,7 +190,7 @@ class MatteryRecipe(val result: ItemLike, val count: Int = 1, val category: Reci
|
||||
pJson["source"] = upgradeSource!!.toString()
|
||||
}
|
||||
|
||||
override fun type(): RecipeSerializer<*> {
|
||||
override fun getType(): RecipeSerializer<*> {
|
||||
return UpgradeRecipe.CODEC
|
||||
}
|
||||
}
|
||||
@ -227,7 +222,7 @@ class MatteryRecipe(val result: ItemLike, val count: Int = 1, val category: Reci
|
||||
fun buildEnergetic(consumer: RecipeOutput, name: String? = null) {
|
||||
build(consumer.map {
|
||||
object : FinishedRecipe by it {
|
||||
override fun type(): RecipeSerializer<*> {
|
||||
override fun getType(): RecipeSerializer<*> {
|
||||
return EnergyContainerRecipe.Companion
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +1,12 @@
|
||||
package ru.dbotthepony.mc.otm.datagen.recipes
|
||||
|
||||
import com.google.common.collect.ImmutableList
|
||||
import net.minecraft.advancements.CriteriaTriggers
|
||||
import net.minecraft.advancements.Criterion
|
||||
import net.minecraft.advancements.critereon.ContextAwarePredicate
|
||||
import net.minecraft.advancements.CriterionTriggerInstance
|
||||
import net.minecraft.advancements.critereon.EntityPredicate
|
||||
import net.minecraft.advancements.critereon.InventoryChangeTrigger
|
||||
import net.minecraft.advancements.critereon.ItemPredicate
|
||||
import net.minecraft.advancements.critereon.MinMaxBounds
|
||||
import net.minecraft.data.DataGenerator
|
||||
import net.minecraft.data.recipes.FinishedRecipe
|
||||
import net.minecraft.data.recipes.RecipeBuilder
|
||||
import net.minecraft.data.recipes.RecipeOutput
|
||||
import net.minecraft.data.recipes.RecipeProvider
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
import net.minecraft.tags.ItemTags
|
||||
@ -27,31 +22,30 @@ import ru.dbotthepony.mc.otm.datagen.modLocation
|
||||
import ru.dbotthepony.mc.otm.recipe.MicrowaveRecipe
|
||||
import ru.dbotthepony.mc.otm.recipe.PlatePressRecipe
|
||||
import java.util.*
|
||||
import java.util.function.Consumer
|
||||
import java.util.stream.Stream
|
||||
|
||||
private typealias RecipeBuilderCallback = (MatteryRecipeProvider, consumer: RecipeOutput) -> Unit
|
||||
|
||||
fun has(p_176521_: MinMaxBounds.Ints, p_176522_: ItemLike): Criterion<InventoryChangeTrigger.TriggerInstance> {
|
||||
fun has(p_176521_: MinMaxBounds.Ints, p_176522_: ItemLike): CriterionTriggerInstance {
|
||||
return inventoryTrigger(ItemPredicate.Builder.item().of(p_176522_).withCount(p_176521_).build())
|
||||
}
|
||||
|
||||
fun has(p_125978_: ItemLike): Criterion<InventoryChangeTrigger.TriggerInstance> {
|
||||
fun has(p_125978_: ItemLike): CriterionTriggerInstance {
|
||||
return inventoryTrigger(ItemPredicate.Builder.item().of(p_125978_).build())
|
||||
}
|
||||
|
||||
fun has(p_125976_: TagKey<Item>): Criterion<InventoryChangeTrigger.TriggerInstance> {
|
||||
fun has(p_125976_: TagKey<Item>): CriterionTriggerInstance {
|
||||
return inventoryTrigger(ItemPredicate.Builder.item().of(p_125976_).build())
|
||||
}
|
||||
|
||||
fun inventoryTrigger(vararg p_126012_: ItemPredicate): Criterion<InventoryChangeTrigger.TriggerInstance> {
|
||||
return CriteriaTriggers.INVENTORY_CHANGED.createCriterion(InventoryChangeTrigger.TriggerInstance(
|
||||
Optional.empty(),
|
||||
fun inventoryTrigger(vararg p_126012_: ItemPredicate): CriterionTriggerInstance {
|
||||
return InventoryChangeTrigger.TriggerInstance(
|
||||
EntityPredicate.Composite.ANY,
|
||||
MinMaxBounds.Ints.ANY,
|
||||
MinMaxBounds.Ints.ANY,
|
||||
MinMaxBounds.Ints.ANY,
|
||||
ImmutableList.copyOf(p_126012_)
|
||||
))
|
||||
p_126012_
|
||||
)
|
||||
}
|
||||
|
||||
fun multiIngredient(vararg items: Any) : Ingredient {
|
||||
@ -104,24 +98,25 @@ class MatteryRecipeProvider(generatorIn: DataGenerator) : RecipeProvider(generat
|
||||
fun plate(id: String, count: Int = 1, workTicks: Int = 200, experience: FloatProvider = ConstantFloat.ZERO) {
|
||||
exec { _, consumer ->
|
||||
consumer.accept(PlatePressRecipe(
|
||||
modLocation("plates/$id"),
|
||||
Ingredient.of(ItemTags.create(ResourceLocation("forge", "ingots/$id"))),
|
||||
Ingredient.of(ItemTags.create(ResourceLocation("forge", "plates/$id"))),
|
||||
count,
|
||||
workTicks,
|
||||
experience = experience
|
||||
).toFinished(modLocation("plates/$id")))
|
||||
).toFinished())
|
||||
}
|
||||
}
|
||||
|
||||
fun plate(id: String, ingredient: Ingredient, result: Ingredient, count: Int = 1, workTicks: Int = 200, experience: FloatProvider = ConstantFloat.ZERO) {
|
||||
exec { it, callback ->
|
||||
callback.accept(PlatePressRecipe(ingredient, result, count, workTicks, experience = experience).toFinished(modLocation("plate_$id")))
|
||||
callback.accept(PlatePressRecipe(modLocation("plates/$id"), ingredient, result, count, workTicks, experience = experience).toFinished())
|
||||
}
|
||||
}
|
||||
|
||||
fun microwave(id: String, ingredient: Ingredient, result: Ingredient, count: Int = 1, workTicks: Int = 200, experience: FloatProvider = ConstantFloat.ZERO) {
|
||||
exec { it, callback ->
|
||||
callback.accept(MicrowaveRecipe(ingredient, result, count, workTicks, experience = experience).toFinished(modLocation("microwave/$id")))
|
||||
callback.accept(MicrowaveRecipe(modLocation("microwave/$id"), ingredient, result, count, workTicks, experience = experience).toFinished())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,20 +1,16 @@
|
||||
package ru.dbotthepony.mc.otm.datagen.recipes
|
||||
|
||||
import net.minecraft.data.recipes.FinishedRecipe
|
||||
import net.minecraft.data.recipes.RecipeOutput
|
||||
import net.minecraft.world.item.DyeColor
|
||||
import net.minecraft.world.item.Item
|
||||
import net.minecraft.world.item.ItemStack
|
||||
import net.minecraft.world.item.Items
|
||||
import net.minecraft.world.item.crafting.Ingredient
|
||||
import ru.dbotthepony.mc.otm.core.registryName
|
||||
import ru.dbotthepony.mc.otm.core.stream
|
||||
import ru.dbotthepony.mc.otm.datagen.modLocation
|
||||
import ru.dbotthepony.mc.otm.recipe.PainterArmorDyeRecipe
|
||||
import ru.dbotthepony.mc.otm.recipe.PainterRecipe
|
||||
import ru.dbotthepony.mc.otm.registry.MItems
|
||||
import ru.dbotthepony.mc.otm.registry.MRegistry
|
||||
import java.util.function.Consumer
|
||||
|
||||
private val Item.recipeName get() = registryName!!.namespace + "/" + registryName!!.path
|
||||
|
||||
@ -23,10 +19,11 @@ private fun generate(consumer: RecipeOutput, items: Map<out DyeColor?, Item>, am
|
||||
if (targetColor == null) continue
|
||||
|
||||
consumer.accept(PainterRecipe(
|
||||
modLocation("painter/" + targetItem.recipeName),
|
||||
Ingredient.of(items.entries.stream().filter { it.key != null && it.key != targetColor }.map { ItemStack(it.value) }),
|
||||
ItemStack(targetItem),
|
||||
mapOf(targetColor to amount)
|
||||
).toFinished(modLocation("painter/" + targetItem.recipeName)))
|
||||
).toFinished())
|
||||
}
|
||||
}
|
||||
|
||||
@ -40,19 +37,21 @@ private fun generate(consumer: RecipeOutput, default: Item, items: Map<out DyeCo
|
||||
if (k1 == null) continue
|
||||
|
||||
consumer.accept(PainterRecipe(
|
||||
modLocation("painter/" + default.recipeName + "/" + v1.recipeName),
|
||||
Ingredient.of(default),
|
||||
ItemStack(v1),
|
||||
mapOf(k1 to amount)
|
||||
).toFinished(modLocation("painter/" + default.recipeName + "/" + v1.recipeName)))
|
||||
).toFinished())
|
||||
}
|
||||
}
|
||||
|
||||
private fun cleaning(consumer: RecipeOutput, to: Item, from: Map<out DyeColor?, Item>) {
|
||||
consumer.accept(PainterRecipe(
|
||||
modLocation("painter/cleaning/" + to.recipeName),
|
||||
Ingredient.of(from.entries.stream().filter { it.key != null }.map { ItemStack(it.value) }),
|
||||
ItemStack(to),
|
||||
mapOf(null to 15)
|
||||
).toFinished(modLocation("painter/cleaning/" + to.recipeName)))
|
||||
).toFinished())
|
||||
}
|
||||
|
||||
private fun striped(consumer: RecipeOutput, name: String, items: List<Pair<Item, Pair<DyeColor, DyeColor>>>, base: Map<DyeColor, Item>) {
|
||||
@ -60,10 +59,11 @@ private fun striped(consumer: RecipeOutput, name: String, items: List<Pair<Item,
|
||||
val (baseColor, stripe) = colors
|
||||
|
||||
consumer.accept(PainterRecipe(
|
||||
modLocation("painter/stripes_$name/${baseColor.getName()}/${stripe.getName()}"),
|
||||
Ingredient.of(base[baseColor]),
|
||||
ItemStack(stripeItem),
|
||||
setOf(stripe)
|
||||
).toFinished(modLocation("painter/stripes_$name/${baseColor.getName()}/${stripe.getName()}")))
|
||||
).toFinished())
|
||||
}
|
||||
}
|
||||
|
||||
@ -318,32 +318,36 @@ fun addPainterRecipes(consumer: RecipeOutput) {
|
||||
striped(consumer, "slabs", MRegistry.TRITANIUM_STRIPED_SLAB.itemsWithColor, MRegistry.TRITANIUM_SLAB.items)
|
||||
|
||||
for (color in DyeColor.entries) {
|
||||
consumer.accept(PainterArmorDyeRecipe(mapOf(color to 1)).toFinished(modLocation("painter/armor_dye_" + color.getName().lowercase())))
|
||||
consumer.accept(PainterArmorDyeRecipe(modLocation("painter/armor_dye_" + color.getName().lowercase()), mapOf(color to 1)).toFinished())
|
||||
}
|
||||
|
||||
consumer.accept(PainterArmorDyeRecipe(mapOf(null to 15)).toFinished(modLocation("painter/armor_clear_dye")))
|
||||
consumer.accept(PainterArmorDyeRecipe(modLocation("painter/armor_clear_dye"), mapOf(null to 15)).toFinished())
|
||||
|
||||
consumer.accept(PainterRecipe(
|
||||
modLocation("painter/tritanium_yellow_stripe"),
|
||||
Ingredient.of(MRegistry.TRITANIUM_BLOCK.item),
|
||||
ItemStack(MItems.TRITANIUM_STRIPED_BLOCK),
|
||||
mapOf(DyeColor.YELLOW to 1)
|
||||
).toFinished(modLocation("painter/tritanium_yellow_stripe")))
|
||||
).toFinished())
|
||||
|
||||
consumer.accept(PainterRecipe(
|
||||
modLocation("painter/tritanium_yellow_stripe_stairs"),
|
||||
Ingredient.of(MRegistry.TRITANIUM_STAIRS.item),
|
||||
ItemStack(MItems.TRITANIUM_STRIPED_STAIRS),
|
||||
mapOf(DyeColor.YELLOW to 1)
|
||||
).toFinished(modLocation("painter/tritanium_yellow_stripe_stairs")))
|
||||
).toFinished())
|
||||
|
||||
consumer.accept(PainterRecipe(
|
||||
modLocation("painter/tritanium_yellow_stripe_slab"),
|
||||
Ingredient.of(MRegistry.TRITANIUM_SLAB.item),
|
||||
ItemStack(MItems.TRITANIUM_STRIPED_SLAB),
|
||||
mapOf(DyeColor.YELLOW to 1)
|
||||
).toFinished(modLocation("painter/tritanium_yellow_stripe_slab")))
|
||||
).toFinished())
|
||||
|
||||
consumer.accept(PainterRecipe(
|
||||
modLocation("painter/tritanium_yellow_stripe_wall"),
|
||||
Ingredient.of(MRegistry.TRITANIUM_WALL.item),
|
||||
ItemStack(MItems.TRITANIUM_STRIPED_WALL),
|
||||
mapOf(DyeColor.YELLOW to 1)
|
||||
).toFinished(modLocation("painter/tritanium_yellow_stripe_wall")))
|
||||
).toFinished())
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package ru.dbotthepony.mc.otm.datagen.recipes
|
||||
|
||||
import net.minecraft.data.recipes.FinishedRecipe
|
||||
import net.minecraft.data.recipes.RecipeCategory
|
||||
import net.minecraft.data.recipes.RecipeOutput
|
||||
import net.minecraft.data.recipes.ShapelessRecipeBuilder
|
||||
import net.minecraft.tags.TagKey
|
||||
import net.minecraft.world.item.DyeColor
|
||||
@ -16,6 +16,9 @@ import ru.dbotthepony.mc.otm.datagen.modLocation
|
||||
import ru.dbotthepony.mc.otm.registry.MItemTags
|
||||
import ru.dbotthepony.mc.otm.registry.MItems
|
||||
import ru.dbotthepony.mc.otm.registry.MRegistry
|
||||
import java.util.function.Consumer
|
||||
|
||||
typealias RecipeOutput = Consumer<FinishedRecipe>
|
||||
|
||||
fun hammerRecipe(output: ItemLike, input: ItemLike, consumer: RecipeOutput) {
|
||||
ShapelessRecipeBuilder(RecipeCategory.MISC, output, 1)
|
||||
|
@ -1,7 +1,6 @@
|
||||
package ru.dbotthepony.mc.otm.datagen.recipes
|
||||
|
||||
import net.minecraft.data.recipes.RecipeCategory
|
||||
import net.minecraft.data.recipes.RecipeOutput
|
||||
import net.minecraftforge.common.Tags
|
||||
import ru.dbotthepony.mc.otm.recipe.UpgradeRecipe
|
||||
import ru.dbotthepony.mc.otm.registry.MItemTags
|
||||
|
@ -1,7 +1,6 @@
|
||||
package ru.dbotthepony.mc.otm.datagen.recipes
|
||||
|
||||
import net.minecraft.data.recipes.RecipeCategory
|
||||
import net.minecraft.data.recipes.RecipeOutput
|
||||
import net.minecraftforge.common.Tags
|
||||
import ru.dbotthepony.mc.otm.registry.MItemTags
|
||||
import ru.dbotthepony.mc.otm.registry.MItems
|
||||
|
@ -30,8 +30,8 @@ fun addTags(tagsProvider: TagsProvider) {
|
||||
tagsProvider.plates.add("gold", MItems.GOLD_PLATE)
|
||||
tagsProvider.plates.add("carbon", MItems.CARBON_MESH)
|
||||
|
||||
tagsProvider.fluids.forge("experience").add(MFluids.LIQUID_XP).add(MFluids.LIQUID_XP_FLOWING)
|
||||
tagsProvider.fluidTypes.forge("experience").add(MFluids.LIQUID_XP_TYPE)
|
||||
// tagsProvider.fluids.forge("experience").add(MFluids.LIQUID_XP).add(MFluids.LIQUID_XP_FLOWING)
|
||||
// tagsProvider.fluidTypes.forge("experience").add(MFluids.LIQUID_XP_TYPE)
|
||||
|
||||
tagsProvider.items.forge("reinforced_tritanium").add(MItems.REINFORCED_TRITANIUM_PLATE)
|
||||
|
||||
|
@ -167,8 +167,9 @@ class TagsProvider(private val event: GatherDataEvent) {
|
||||
|
||||
val blocks = Delegate(ForgeRegistries.BLOCKS)
|
||||
val items = Delegate(ForgeRegistries.ITEMS)
|
||||
val fluids = Delegate(ForgeRegistries.FLUIDS)
|
||||
val fluidTypes = Delegate(ForgeRegistries.Keys.FLUID_TYPES)
|
||||
// not supported on 1.19.4 and earlier
|
||||
// val fluids = Delegate(ForgeRegistries.FLUIDS)
|
||||
// val fluidTypes = Delegate(ForgeRegistries.Keys.FLUID_TYPES)
|
||||
val mobEffects = Delegate(ForgeRegistries.MOB_EFFECTS)
|
||||
val damageTypes = Delegate(Registries.DAMAGE_TYPE)
|
||||
|
||||
|
@ -34,7 +34,7 @@ public class FoodDataMixin {
|
||||
// полностью подменяем логику если андроид
|
||||
lastFoodLevel = foodLevel;
|
||||
|
||||
if (player.level().getDifficulty() == Difficulty.PEACEFUL) {
|
||||
if (player.level.getDifficulty() == Difficulty.PEACEFUL) {
|
||||
exhaustionLevel = 0f;
|
||||
} else {
|
||||
tickTimer = 0;
|
||||
|
@ -1,25 +0,0 @@
|
||||
package ru.dbotthepony.mc.otm.mixin;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
|
||||
import static ru.dbotthepony.mc.otm.client.render.RenderHelperKt.popScissorRect;
|
||||
import static ru.dbotthepony.mc.otm.client.render.RenderHelperKt.pushScissorRect;
|
||||
|
||||
// because scissor stack fucking sucks.
|
||||
// mostly because it is not a stack at all.
|
||||
@Mixin(GuiGraphics.class)
|
||||
public abstract class GuiGraphicsMixin {
|
||||
@Overwrite
|
||||
public void enableScissor(int x0, int y0, int x1, int y1) {
|
||||
double scale = Minecraft.getInstance().getWindow().getGuiScale();
|
||||
pushScissorRect((int) (scale * x0), (int) (scale * y0), (int) (scale * (x1 - x0)), (int) (scale * (y1 - y0)));
|
||||
}
|
||||
|
||||
@Overwrite
|
||||
public void disableScissor() {
|
||||
popScissorRect();
|
||||
}
|
||||
}
|
@ -29,7 +29,7 @@ public class MixinAbstractHurtingProjectile {
|
||||
AbstractHurtingProjectile proj = (AbstractHurtingProjectile)(Object)this;
|
||||
|
||||
if (cap.isAndroid() && proj.getOwner() != entity) {
|
||||
entity.level().playSound(entity, proj.blockPosition(), MSoundEvents.INSTANCE.getANDROID_PROJ_PARRY(), SoundSource.PLAYERS, 1.0f, 0.95f + entity.level().random.nextFloat() * 0.1f);
|
||||
entity.level.playSound(entity, proj.blockPosition(), MSoundEvents.INSTANCE.getANDROID_PROJ_PARRY(), SoundSource.PLAYERS, 1.0f, 0.95f + entity.level.random.nextFloat() * 0.1f);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ import ru.dbotthepony.mc.otm.core.collect.ListSet
|
||||
import ru.dbotthepony.mc.otm.core.TranslatableComponent
|
||||
import ru.dbotthepony.mc.otm.core.isActuallyEmpty
|
||||
import ru.dbotthepony.mc.otm.data.ComponentCodec
|
||||
import ru.dbotthepony.mc.otm.data.IngredientCodec
|
||||
import ru.dbotthepony.mc.otm.data.JsonElementCodec
|
||||
import ru.dbotthepony.mc.otm.isClient
|
||||
import java.util.Optional
|
||||
@ -392,7 +393,7 @@ class AndroidResearchType(
|
||||
ListCodec(
|
||||
RecordCodecBuilder.create<Pair<Ingredient, Int>> {
|
||||
it.group(
|
||||
Ingredient.CODEC.fieldOf("item").forGetter { it.first },
|
||||
IngredientCodec.fieldOf("item").forGetter { it.first },
|
||||
Codec.intRange(1, Int.MAX_VALUE).optionalFieldOf("count", 1).forGetter { it.second }
|
||||
).apply(it, ::Pair)
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ abstract class AndroidSwitchableFeature(type: AndroidFeatureType<*>, android: Ma
|
||||
val cooldownPercent: Float get() {
|
||||
if (maxCooldown <= 0) return 0.0f
|
||||
|
||||
if (ply.level() is ClientLevel) {
|
||||
if (ply.level is ClientLevel) {
|
||||
return ((cooldown.toFloat() - minecraft.partialTick) / maxCooldown.toFloat()).coerceIn(0.0f, 1.0f)
|
||||
}
|
||||
|
||||
|
@ -71,29 +71,29 @@ class EnderTeleporterFeature(capability: MatteryPlayerCapability) : AndroidActiv
|
||||
}
|
||||
|
||||
private fun canSupportPlayer(blockPos: BlockPos): Boolean {
|
||||
val state = ply.level().getBlockState(blockPos)
|
||||
val state = ply.level.getBlockState(blockPos)
|
||||
|
||||
if (state.`is`(BlockTags.CLIMBABLE)) {
|
||||
return true // ladders can always support player
|
||||
}
|
||||
|
||||
val shape = state.getCollisionShape(ply.level(), blockPos, CollisionContext.of(ply))
|
||||
val shape = state.getCollisionShape(ply.level, blockPos, CollisionContext.of(ply))
|
||||
return Shapes.joinIsNotEmpty(shape, SHAPE_CHECK_SUPPORT_PLAYER, BooleanOp.AND)
|
||||
}
|
||||
|
||||
private fun isWall(blockPos: BlockPos): Boolean {
|
||||
val shape = ply.level().getBlockState(blockPos).getCollisionShape(ply.level(), blockPos, CollisionContext.of(ply))
|
||||
val shape = ply.level.getBlockState(blockPos).getCollisionShape(ply.level, blockPos, CollisionContext.of(ply))
|
||||
return Shapes.joinIsNotEmpty(shape, SHAPE_CHECK_NOT_FENCE, BooleanOp.AND)
|
||||
}
|
||||
|
||||
private fun isAirGap(blockPos: BlockPos): Boolean {
|
||||
val state = ply.level().getBlockState(blockPos)
|
||||
val state = ply.level.getBlockState(blockPos)
|
||||
|
||||
if (state.isAir) {
|
||||
return true
|
||||
}
|
||||
|
||||
val shape = state.getCollisionShape(ply.level(), blockPos, CollisionContext.of(ply))
|
||||
val shape = state.getCollisionShape(ply.level, blockPos, CollisionContext.of(ply))
|
||||
return shape.isEmpty || !Shapes.joinIsNotEmpty(shape, SHAPE_CHECK_SUPPORT_PLAYER, BooleanOp.AND)
|
||||
}
|
||||
|
||||
@ -140,7 +140,7 @@ class EnderTeleporterFeature(capability: MatteryPlayerCapability) : AndroidActiv
|
||||
val headPosition = ply.eyePosition
|
||||
val aimVector = ply.getViewVector(1f)
|
||||
|
||||
val result = ply.level().clip(ClipContext(
|
||||
val result = ply.level.clip(ClipContext(
|
||||
headPosition,
|
||||
headPosition + aimVector * (AndroidConfig.EnderTeleporter.MAX_DISTANCE * 2.0),
|
||||
ClipContext.Block.COLLIDER,
|
||||
@ -199,14 +199,14 @@ class EnderTeleporterFeature(capability: MatteryPlayerCapability) : AndroidActiv
|
||||
val searchDirection: IntProgression
|
||||
|
||||
if (ply.isShiftKeyDown) {
|
||||
searchDirection = -1 downTo ply.level().minBuildHeight - ply.level().maxBuildHeight
|
||||
searchDirection = -1 downTo ply.level.minBuildHeight - ply.level.maxBuildHeight
|
||||
} else {
|
||||
searchDirection = (if (ply.level().getBlockState(result.blockPos).`is`(BlockTags.CLIMBABLE)) -1 else 0) .. ply.level().maxBuildHeight - ply.level().minBuildHeight
|
||||
searchDirection = (if (ply.level.getBlockState(result.blockPos).`is`(BlockTags.CLIMBABLE)) -1 else 0) .. ply.level.maxBuildHeight - ply.level.minBuildHeight
|
||||
}
|
||||
|
||||
for (y in searchDirection) {
|
||||
val pos = BlockPos(result.blockPos.x, result.blockPos.y + y + 1, result.blockPos.z)
|
||||
val state = ply.level().getBlockState(pos)
|
||||
val state = ply.level.getBlockState(pos)
|
||||
|
||||
if (state.`is`(Blocks.BEDROCK)) {
|
||||
// Can't phase through bedrock
|
||||
@ -258,9 +258,9 @@ class EnderTeleporterFeature(capability: MatteryPlayerCapability) : AndroidActiv
|
||||
phasedBlocks = 0
|
||||
phasedBlocksList.clear()
|
||||
|
||||
for (y in 0 downTo ply.level().maxBuildHeight - ply.level().minBuildHeight) {
|
||||
for (y in 0 downTo ply.level.maxBuildHeight - ply.level.minBuildHeight) {
|
||||
val pos = BlockPos(result.blockPos.x, result.blockPos.y + y, result.blockPos.z)
|
||||
val state = ply.level().getBlockState(pos)
|
||||
val state = ply.level.getBlockState(pos)
|
||||
|
||||
if (state.`is`(Blocks.BEDROCK)) {
|
||||
// Can't phase through bedrock
|
||||
@ -302,7 +302,7 @@ class EnderTeleporterFeature(capability: MatteryPlayerCapability) : AndroidActiv
|
||||
val event = ForgeEventFactory.onEnderTeleport(ply, blockPos.x + 0.5, blockPos.y.toDouble(), blockPos.z + 0.5)
|
||||
|
||||
if (event.isCanceled) {
|
||||
(ply as ServerPlayer).connection.send(ClientboundSoundEntityPacket(SoundEvents.ITEM_BREAK.holder, SoundSource.PLAYERS, ply, 0.3f, 0.5f, ply.level().random.nextLong()))
|
||||
(ply as ServerPlayer).connection.send(ClientboundSoundEntityPacket(SoundEvents.ITEM_BREAK.holder, SoundSource.PLAYERS, ply, 0.3f, 0.5f, ply.level.random.nextLong()))
|
||||
return false
|
||||
}
|
||||
|
||||
@ -310,9 +310,9 @@ class EnderTeleporterFeature(capability: MatteryPlayerCapability) : AndroidActiv
|
||||
lastTeleport = ply.server!!.tickCount
|
||||
android.androidEnergy.extractEnergy(AndroidConfig.EnderTeleporter.ENERGY_COST, false)
|
||||
|
||||
ply.level().playSound(null, ply, SoundEvents.ENDERMAN_TELEPORT, SoundSource.PLAYERS, 0.3f, 0.8f + ply.level().random.nextFloat() * 0.4f)
|
||||
ply.level.playSound(null, ply, SoundEvents.ENDERMAN_TELEPORT, SoundSource.PLAYERS, 0.3f, 0.8f + ply.level.random.nextFloat() * 0.4f)
|
||||
ply.teleportTo(event.targetX, event.targetY, event.targetZ)
|
||||
ply.level().playSound(null, ply, SoundEvents.ENDERMAN_TELEPORT, SoundSource.PLAYERS, 1f, 0.8f + ply.level().random.nextFloat() * 0.4f)
|
||||
ply.level.playSound(null, ply, SoundEvents.ENDERMAN_TELEPORT, SoundSource.PLAYERS, 1f, 0.8f + ply.level.random.nextFloat() * 0.4f)
|
||||
|
||||
ply.deltaMovement = Vector(0.0, 0.0, 0.0)
|
||||
ply.resetFallDistance()
|
||||
@ -352,8 +352,8 @@ class EnderTeleporterFeature(capability: MatteryPlayerCapability) : AndroidActiv
|
||||
val builder = source.getBuffer(linesIgnoreZRenderType)
|
||||
|
||||
for (blockPos in phasedBlocks) {
|
||||
val blockState = ply.level().getBlockState(blockPos)
|
||||
val shape = blockState.getShape(ply.level(), blockPos, collisionContext)
|
||||
val blockState = ply.level.getBlockState(blockPos)
|
||||
val shape = blockState.getShape(ply.level, blockPos, collisionContext)
|
||||
|
||||
LevelRenderer.renderShape(
|
||||
poseStack,
|
||||
|
@ -45,7 +45,7 @@ class ItemEntityDataPacket(val itemUUID: Int, val owner: UUID? = null, val age:
|
||||
}
|
||||
|
||||
override fun play(context: MNetworkContext) {
|
||||
val level = minecraft.player?.level() as ClientLevel? ?: return
|
||||
val level = minecraft.player?.level as ClientLevel? ?: return
|
||||
val entity = level.getEntity(itemUUID) as ItemEntity? ?: return
|
||||
datatable[entity] = SharedItemEntityData(owner, age, lifespan, hasPickupDelay)
|
||||
}
|
||||
@ -69,7 +69,7 @@ class ItemMagnetFeature(capability: MatteryPlayerCapability) : AndroidSwitchable
|
||||
return
|
||||
}
|
||||
|
||||
val entities = ply.level().getEntitiesInEllipsoid(
|
||||
val entities = ply.level.getEntitiesInEllipsoid(
|
||||
ply.position,
|
||||
Vector(AndroidConfig.Magnet.RADIUS_HORIZONTAL, AndroidConfig.Magnet.RADIUS_VERTICAL, AndroidConfig.Magnet.RADIUS_HORIZONTAL),
|
||||
if (server) Predicate<Entity> { it is ItemEntity } else clientPredicate
|
||||
|
@ -40,7 +40,7 @@ object TriggerJumpBoostPacket : MatteryPacket {
|
||||
if (feature.isActive && feature.cooldown <= 4 && mattery.androidEnergy.extractEnergyExact(AndroidConfig.JumpBoost.ENERGY_COST, false)) {
|
||||
feature.putOnCooldown()
|
||||
|
||||
context.sender.level().playSound(
|
||||
context.sender.level.playSound(
|
||||
context.sender, context.sender,
|
||||
MSoundEvents.ANDROID_JUMP_BOOST, SoundSource.PLAYERS,
|
||||
1f, 1f
|
||||
@ -75,20 +75,20 @@ class JumpBoostFeature(capability: MatteryPlayerCapability) : AndroidSwitchableF
|
||||
}
|
||||
|
||||
val old = lastGround
|
||||
lastGround = ply.onGround()
|
||||
lastGround = ply.isOnGround
|
||||
|
||||
if (isActive && cooldown <= 0 && old != lastGround && !lastGround && isJumping && isShifting && ply.xRot <= ClientConfig.JUMP_BOOST_LOOK_ANGLE && android.androidEnergy.extractEnergyExact(AndroidConfig.JumpBoost.ENERGY_COST, true)) {
|
||||
ply.deltaMovement += Vector(0.0, AndroidConfig.JumpBoost.POWER * (level + 1) / 20.0, 0.0)
|
||||
putOnCooldown()
|
||||
MatteryPlayerNetworkChannel.sendToServer(TriggerJumpBoostPacket)
|
||||
|
||||
ply.level().playSound(
|
||||
ply.level.playSound(
|
||||
ply, ply,
|
||||
MSoundEvents.ANDROID_JUMP_BOOST, SoundSource.PLAYERS,
|
||||
1f, 1f
|
||||
)
|
||||
|
||||
SmokeParticlesPacket.makeSmoke(ply.x, ply.y, ply.z, ply.random, ply.level())
|
||||
SmokeParticlesPacket.makeSmoke(ply.x, ply.y, ply.z, ply.random, ply.level)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ class NanobotsRegenerationFeature(android: MatteryPlayerCapability) : AndroidFea
|
||||
private var healTicks = 0
|
||||
|
||||
override fun tickServer() {
|
||||
if (ply.isHurt && ply.level().gameRules.getBoolean(GameRules.RULE_NATURAL_REGENERATION)) {
|
||||
if (ply.isHurt && ply.level.gameRules.getBoolean(GameRules.RULE_NATURAL_REGENERATION)) {
|
||||
ticksPassed++
|
||||
|
||||
val waitTime = AndroidConfig.NanobotsRegeneration.COOLDOWN.getOrElse(healTicks) { AndroidConfig.NanobotsRegeneration.COOLDOWN.last() }
|
||||
|
@ -93,7 +93,7 @@ class ShockwaveFeature(capability: MatteryPlayerCapability) : AndroidSwitchableF
|
||||
ShockwaveTrigger.trigger(ply as ServerPlayer)
|
||||
MatteryPlayerNetworkChannel.sendTrackingAndSelf(ply, ShockwaveEffectPacket(ply.position))
|
||||
|
||||
ply.level().playSound(
|
||||
ply.level.playSound(
|
||||
null,
|
||||
ply,
|
||||
MSoundEvents.ANDROID_SHOCKWAVE,
|
||||
@ -104,13 +104,13 @@ class ShockwaveFeature(capability: MatteryPlayerCapability) : AndroidSwitchableF
|
||||
}
|
||||
|
||||
// TODO: raycasting
|
||||
val entities = ply.level().getEntitiesInEllipsoid(
|
||||
val entities = ply.level.getEntitiesInEllipsoid(
|
||||
ply.position,
|
||||
Vector(AndroidConfig.Shockwave.RADIUS_HORIZONTAL, AndroidConfig.Shockwave.RADIUS_VERTICAL, AndroidConfig.Shockwave.RADIUS_HORIZONTAL),
|
||||
except = ply,
|
||||
) { (it !is LivingEntity || !it.isSpectator && it.isAlive) }
|
||||
|
||||
val wardens = ply.level().getEntitiesInEllipsoid(
|
||||
val wardens = ply.level.getEntitiesInEllipsoid(
|
||||
Warden::class.java,
|
||||
ply.position,
|
||||
Vector(AndroidConfig.Shockwave.RADIUS_HORIZONTAL_WARDEN, AndroidConfig.Shockwave.RADIUS_VERTICAL_WARDEN, AndroidConfig.Shockwave.RADIUS_HORIZONTAL_WARDEN),
|
||||
@ -122,7 +122,7 @@ class ShockwaveFeature(capability: MatteryPlayerCapability) : AndroidSwitchableF
|
||||
seen.add(entity)
|
||||
val multiplier = (1.0 - distanceMultiplier).pow(0.5)
|
||||
|
||||
val source = MatteryDamageSource(ply.level().registryAccess().damageType(MDamageTypes.SHOCKWAVE), ply)
|
||||
val source = MatteryDamageSource(ply.level.registryAccess().damageType(MDamageTypes.SHOCKWAVE), ply)
|
||||
val damage = multiplier.toFloat() * AndroidConfig.Shockwave.DAMAGE.toFloat() * AndroidConfig.Shockwave.WARDEN_DAMAGE_MULT.toFloat()
|
||||
entity.hurt(source, damage)
|
||||
entity.deltaMovement += (entity.position - ply.position).normalize() * (multiplier * 3.0)
|
||||
@ -138,7 +138,7 @@ class ShockwaveFeature(capability: MatteryPlayerCapability) : AndroidSwitchableF
|
||||
|
||||
// don't hurt items, arrows, etc etc
|
||||
if (entity is LivingEntity) {
|
||||
val source = MatteryDamageSource(ply.level().registryAccess().damageType(MDamageTypes.SHOCKWAVE), ply)
|
||||
val source = MatteryDamageSource(ply.level.registryAccess().damageType(MDamageTypes.SHOCKWAVE), ply)
|
||||
val damage = multiplier.toFloat() * AndroidConfig.Shockwave.DAMAGE.toFloat()
|
||||
entity.hurt(source, damage)
|
||||
entity.deltaMovement += (entity.position - ply.position).normalize() * (multiplier * 3.0)
|
||||
@ -158,21 +158,21 @@ class ShockwaveFeature(capability: MatteryPlayerCapability) : AndroidSwitchableF
|
||||
for (blockPos in getEllipsoidBlockPositions(AndroidConfig.Shockwave.RADIUS_HORIZONTAL.roundToInt(), AndroidConfig.Shockwave.RADIUS_VERTICAL.roundToInt(), AndroidConfig.Shockwave.RADIUS_HORIZONTAL.roundToInt())) {
|
||||
val newBlockPos = blockPos + rounded
|
||||
|
||||
val blockState = ply.level().getBlockState(newBlockPos)
|
||||
val blockState = ply.level.getBlockState(newBlockPos)
|
||||
|
||||
if (!blockState.isAir && blockState.getExplosionResistance(ply.level(), newBlockPos) <= 0f && ply.level().getBlockEntity(newBlockPos) == null && blockState.block.defaultDestroyTime() >= 0f) {
|
||||
// Block.dropResources(blockState, ply.level(), newBlockPos)
|
||||
// blockState.block.destroy(ply.level(), newBlockPos, blockState)
|
||||
// ply.level().setBlock(newBlockPos, blockState.fluidState.createLegacyBlock(), Block.UPDATE_ALL)
|
||||
if (!blockState.isAir && blockState.getExplosionResistance(ply.level, newBlockPos) <= 0f && ply.level.getBlockEntity(newBlockPos) == null && blockState.block.defaultDestroyTime() >= 0f) {
|
||||
// Block.dropResources(blockState, ply.level, newBlockPos)
|
||||
// blockState.block.destroy(ply.level, newBlockPos, blockState)
|
||||
// ply.level.setBlock(newBlockPos, blockState.fluidState.createLegacyBlock(), Block.UPDATE_ALL)
|
||||
|
||||
ply.level().destroyBlock(newBlockPos, true)
|
||||
ply.level.destroyBlock(newBlockPos, true)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun ticker(isClient: Boolean) {
|
||||
if (!ply.onGround() || ply.isSpectator) {
|
||||
if (!ply.isOnGround || ply.isSpectator) {
|
||||
airTicks = (airTicks + 1).coerceAtMost(3)
|
||||
} else {
|
||||
airTicks = (airTicks - 1).coerceAtLeast(0)
|
||||
@ -192,7 +192,7 @@ class ShockwaveFeature(capability: MatteryPlayerCapability) : AndroidSwitchableF
|
||||
creativeFlightTicks == 0
|
||||
) {
|
||||
val old = wasMidair
|
||||
wasMidair = !ply.onGround()
|
||||
wasMidair = !ply.isOnGround
|
||||
|
||||
if (wasMidair) {
|
||||
highestSpeed = (-ply.deltaMovement.y).coerceAtLeast(highestSpeed)
|
||||
|
@ -1,6 +1,7 @@
|
||||
package ru.dbotthepony.mc.otm.block
|
||||
|
||||
import net.minecraft.core.BlockPos
|
||||
import net.minecraft.world.item.DyeColor
|
||||
import net.minecraft.world.level.BlockGetter
|
||||
import net.minecraft.world.level.Level
|
||||
import net.minecraft.world.level.block.Block
|
||||
@ -10,7 +11,7 @@ import net.minecraft.world.level.block.entity.BlockEntity
|
||||
import net.minecraft.world.level.block.entity.BlockEntityTicker
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType
|
||||
import net.minecraft.world.level.block.state.BlockState
|
||||
import net.minecraft.world.level.material.MapColor
|
||||
import net.minecraft.world.level.material.Material
|
||||
import net.minecraft.world.level.material.PushReaction
|
||||
import net.minecraft.world.phys.shapes.CollisionContext
|
||||
import net.minecraft.world.phys.shapes.VoxelShape
|
||||
@ -19,7 +20,7 @@ import ru.dbotthepony.mc.otm.registry.MBlockEntities
|
||||
import ru.dbotthepony.mc.otm.shapes.BlockShapes
|
||||
|
||||
class BlackHoleBlock :
|
||||
Block(Properties.of().mapColor(MapColor.COLOR_BLACK).noCollission().pushReaction(PushReaction.BLOCK).sound(SoundType.STONE).strength(-1f, 7200000.0f)), EntityBlock {
|
||||
Block(Properties.of(Material.AIR, DyeColor.BLACK).noCollission().sound(SoundType.STONE).strength(-1f, 7200000.0f)), EntityBlock {
|
||||
override fun getShape(
|
||||
p_60555_: BlockState,
|
||||
p_60556_: BlockGetter,
|
||||
@ -29,6 +30,10 @@ class BlackHoleBlock :
|
||||
return SHAPE
|
||||
}
|
||||
|
||||
override fun getPistonPushReaction(p_60584_: BlockState): PushReaction {
|
||||
return PushReaction.BLOCK
|
||||
}
|
||||
|
||||
override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity {
|
||||
return BlackHoleBlockEntity(blockPos, blockState)
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ import net.minecraft.world.level.block.entity.BlockEntity
|
||||
import net.minecraft.world.level.block.state.BlockState
|
||||
import net.minecraft.world.level.block.state.StateDefinition
|
||||
import net.minecraft.world.level.block.state.properties.BooleanProperty
|
||||
import net.minecraft.world.level.material.MapColor
|
||||
import net.minecraft.world.level.material.Material
|
||||
import net.minecraft.world.level.material.PushReaction
|
||||
import net.minecraft.world.phys.BlockHitResult
|
||||
import net.minecraft.world.phys.shapes.BooleanOp
|
||||
@ -27,7 +27,6 @@ import net.minecraft.world.phys.shapes.Shapes
|
||||
import net.minecraft.world.phys.shapes.VoxelShape
|
||||
import ru.dbotthepony.mc.otm.block.entity.MatterCableBlockEntity
|
||||
import ru.dbotthepony.mc.otm.block.entity.StorageCableBlockEntity
|
||||
import ru.dbotthepony.mc.otm.block.entity.cable.EnergyCableBlockEntity
|
||||
import java.util.Collections
|
||||
import java.util.EnumMap
|
||||
|
||||
@ -44,6 +43,10 @@ abstract class CableBlock(properties: Properties) : MatteryBlock(properties) {
|
||||
|
||||
override fun hasDynamicShape() = true
|
||||
|
||||
override fun getPistonPushReaction(p_60584_: BlockState): PushReaction {
|
||||
return PushReaction.DESTROY
|
||||
}
|
||||
|
||||
override fun createBlockStateDefinition(builder: StateDefinition.Builder<Block, BlockState>) {
|
||||
builder.add(
|
||||
CONNECTION_SOUTH,
|
||||
@ -114,7 +117,7 @@ abstract class CableBlock(properties: Properties) : MatteryBlock(properties) {
|
||||
}
|
||||
}
|
||||
|
||||
class MatterCableBlock : CableBlock(Properties.of().mapColor(MapColor.METAL).requiresCorrectToolForDrops().pushReaction(PushReaction.DESTROY).sound(SoundType.METAL).strength(1.0f, 6.0f)), EntityBlock {
|
||||
class MatterCableBlock : CableBlock(Properties.of(Material.METAL).requiresCorrectToolForDrops().sound(SoundType.METAL).strength(1.0f, 6.0f)), EntityBlock {
|
||||
private val shapes = generateShapes(0.15)
|
||||
|
||||
@Suppress("OVERRIDE_DEPRECATION")
|
||||
@ -127,7 +130,7 @@ class MatterCableBlock : CableBlock(Properties.of().mapColor(MapColor.METAL).req
|
||||
}
|
||||
}
|
||||
|
||||
class StorageCableBlock : CableBlock(Properties.of().mapColor(MapColor.METAL).requiresCorrectToolForDrops().pushReaction(PushReaction.DESTROY).sound(SoundType.METAL).strength(1.0f, 6.0f)), EntityBlock {
|
||||
class StorageCableBlock : CableBlock(Properties.of(Material.METAL).requiresCorrectToolForDrops().sound(SoundType.METAL).strength(1.0f, 6.0f)), EntityBlock {
|
||||
private val shapes = generateShapes(0.185)
|
||||
|
||||
@Suppress("OVERRIDE_DEPRECATION")
|
||||
@ -140,7 +143,7 @@ class StorageCableBlock : CableBlock(Properties.of().mapColor(MapColor.METAL).re
|
||||
}
|
||||
}
|
||||
|
||||
class EnergyCableBlock(val factory: (blockPos: BlockPos, blockState: BlockState) -> BlockEntity) : CableBlock(Properties.of().mapColor(MapColor.METAL).pushReaction(PushReaction.DESTROY).requiresCorrectToolForDrops().sound(SoundType.METAL).strength(1.0f, 6.0f)), EntityBlock {
|
||||
class EnergyCableBlock(val factory: (blockPos: BlockPos, blockState: BlockState) -> BlockEntity) : CableBlock(Properties.of(Material.METAL).requiresCorrectToolForDrops().sound(SoundType.METAL).strength(1.0f, 6.0f)), EntityBlock {
|
||||
private val shapes = generateShapes(0.185)
|
||||
|
||||
@Suppress("OVERRIDE_DEPRECATION")
|
||||
|
@ -9,16 +9,21 @@ import net.minecraft.world.level.block.entity.BlockEntity
|
||||
import net.minecraft.world.level.block.entity.BlockEntityTicker
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType
|
||||
import net.minecraft.world.level.block.state.BlockState
|
||||
import net.minecraft.world.level.material.Material
|
||||
import net.minecraft.world.level.material.PushReaction
|
||||
import ru.dbotthepony.mc.otm.block.entity.blackhole.BlockEntityExplosionDebugger
|
||||
import ru.dbotthepony.mc.otm.block.entity.blackhole.BlockEntitySphereDebugger
|
||||
import ru.dbotthepony.mc.otm.registry.MBlockEntities
|
||||
|
||||
class BlockExplosionDebugger : Block(Properties.of().sound(SoundType.STONE).pushReaction(PushReaction.BLOCK)), EntityBlock {
|
||||
class BlockExplosionDebugger : Block(Properties.of(Material.METAL).sound(SoundType.STONE)), EntityBlock {
|
||||
override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity {
|
||||
return BlockEntityExplosionDebugger(p_153215_, p_153216_)
|
||||
}
|
||||
|
||||
override fun getPistonPushReaction(p_60584_: BlockState): PushReaction {
|
||||
return PushReaction.BLOCK
|
||||
}
|
||||
|
||||
override fun <T : BlockEntity?> getTicker(
|
||||
p_153212_: Level,
|
||||
p_153213_: BlockState,
|
||||
@ -32,7 +37,7 @@ class BlockExplosionDebugger : Block(Properties.of().sound(SoundType.STONE).push
|
||||
}
|
||||
}
|
||||
|
||||
class BlockSphereDebugger : Block(Properties.of()), EntityBlock {
|
||||
class BlockSphereDebugger : Block(Properties.of(Material.STONE)), EntityBlock {
|
||||
override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity {
|
||||
return BlockEntitySphereDebugger(p_153215_, p_153216_)
|
||||
}
|
||||
|
@ -25,8 +25,7 @@ import net.minecraft.world.level.block.Block
|
||||
import net.minecraft.world.level.block.EntityBlock
|
||||
import net.minecraft.world.level.block.state.BlockState
|
||||
import net.minecraft.world.level.block.state.properties.Property
|
||||
import net.minecraft.world.level.material.MapColor
|
||||
import net.minecraft.world.level.material.PushReaction
|
||||
import net.minecraft.world.level.material.Material
|
||||
import net.minecraft.world.phys.BlockHitResult
|
||||
import net.minecraft.world.phys.shapes.VoxelShape
|
||||
import ru.dbotthepony.mc.otm.block.entity.IRedstoneControlled
|
||||
@ -267,8 +266,8 @@ open class MatteryBlock(properties: Properties = DEFAULT_PROPERTIES) : Block(pro
|
||||
}
|
||||
|
||||
companion object {
|
||||
val DEFAULT_PROPERTIES: Properties = Properties.of().mapColor(MapColor.METAL).requiresCorrectToolForDrops().destroyTime(1.5f).explosionResistance(25.0f)
|
||||
val DEFAULT_MACHINE_PROPERTIES: Properties = Properties.of().mapColor(MapColor.METAL).pushReaction(PushReaction.BLOCK).requiresCorrectToolForDrops().destroyTime(1.5f).explosionResistance(25.0f)
|
||||
val DEFAULT_PROPERTIES: Properties = Properties.of(Material.METAL).requiresCorrectToolForDrops().destroyTime(1.5f).explosionResistance(25.0f)
|
||||
val DEFAULT_MACHINE_PROPERTIES: Properties = Properties.of(Material.HEAVY_METAL).requiresCorrectToolForDrops().destroyTime(1.5f).explosionResistance(25.0f)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,8 @@ import net.minecraft.world.level.block.entity.BlockEntity
|
||||
import net.minecraft.world.level.block.state.BlockState
|
||||
import net.minecraft.world.level.block.state.StateDefinition
|
||||
import net.minecraft.world.level.block.state.properties.BooleanProperty
|
||||
import net.minecraft.world.level.material.MapColor
|
||||
import net.minecraft.world.level.material.Material
|
||||
import net.minecraft.world.level.material.PushReaction
|
||||
import net.minecraft.world.phys.shapes.CollisionContext
|
||||
import net.minecraft.world.phys.shapes.Shapes
|
||||
import net.minecraft.world.phys.shapes.VoxelShape
|
||||
@ -23,7 +24,7 @@ import ru.dbotthepony.mc.otm.core.get
|
||||
import ru.dbotthepony.mc.otm.shapes.BlockShapes
|
||||
|
||||
class CargoCrateBlock(val color: DyeColor?) : RotatableMatteryBlock(
|
||||
Properties.of().mapColor(color?.mapColor ?: MapColor.COLOR_BLUE).requiresCorrectToolForDrops().sound(SoundType.METAL).strength(1.5f, 30.0f)
|
||||
Properties.of(Material.METAL, color ?: DyeColor.BLUE).requiresCorrectToolForDrops().sound(SoundType.METAL).strength(1.5f, 30.0f)
|
||||
), EntityBlock {
|
||||
override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity {
|
||||
return CargoCrateBlockEntity(blockPos, blockState)
|
||||
@ -34,6 +35,10 @@ class CargoCrateBlock(val color: DyeColor?) : RotatableMatteryBlock(
|
||||
builder.add(IS_OPEN)
|
||||
}
|
||||
|
||||
override fun getPistonPushReaction(p_60584_: BlockState): PushReaction {
|
||||
return PushReaction.BLOCK
|
||||
}
|
||||
|
||||
override fun getStateForPlacement(context: BlockPlaceContext): BlockState? {
|
||||
return super.getStateForPlacement(context)?.setValue(IS_OPEN, false)
|
||||
}
|
||||
|
@ -4,12 +4,13 @@ import net.minecraft.core.BlockPos
|
||||
import net.minecraft.world.level.block.EntityBlock
|
||||
import net.minecraft.world.level.block.entity.BlockEntity
|
||||
import net.minecraft.world.level.block.state.BlockState
|
||||
import net.minecraft.world.level.material.Material
|
||||
import net.minecraft.world.level.material.PushReaction
|
||||
import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock
|
||||
import ru.dbotthepony.mc.otm.block.addSimpleDescription
|
||||
import ru.dbotthepony.mc.otm.block.entity.decorative.DevChestBlockEntity
|
||||
|
||||
class DevChestBlock : RotatableMatteryBlock(Properties.of().destroyTime(-1f).explosionResistance(360000f).pushReaction(PushReaction.BLOCK)), EntityBlock {
|
||||
class DevChestBlock : RotatableMatteryBlock(Properties.of(Material.METAL).destroyTime(-1f).explosionResistance(360000f)), EntityBlock {
|
||||
override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity {
|
||||
return DevChestBlockEntity(p_153215_, p_153216_)
|
||||
}
|
||||
@ -17,4 +18,8 @@ class DevChestBlock : RotatableMatteryBlock(Properties.of().destroyTime(-1f).exp
|
||||
init {
|
||||
addSimpleDescription()
|
||||
}
|
||||
|
||||
override fun getPistonPushReaction(p_60584_: BlockState): PushReaction {
|
||||
return PushReaction.NORMAL
|
||||
}
|
||||
}
|
||||
|
@ -3,12 +3,13 @@ package ru.dbotthepony.mc.otm.block.decorative
|
||||
import net.minecraft.ChatFormatting
|
||||
import net.minecraft.core.BlockPos
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.world.item.DyeColor
|
||||
import net.minecraft.world.item.ItemStack
|
||||
import net.minecraft.world.item.TooltipFlag
|
||||
import net.minecraft.world.level.BlockGetter
|
||||
import net.minecraft.world.level.block.SoundType
|
||||
import net.minecraft.world.level.block.state.BlockState
|
||||
import net.minecraft.world.level.material.MapColor
|
||||
import net.minecraft.world.level.material.Material
|
||||
import net.minecraft.world.level.material.PushReaction
|
||||
import net.minecraft.world.phys.shapes.CollisionContext
|
||||
import net.minecraft.world.phys.shapes.VoxelShape
|
||||
@ -18,7 +19,7 @@ import ru.dbotthepony.mc.otm.core.get
|
||||
import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom
|
||||
import ru.dbotthepony.mc.otm.shapes.BlockShapes
|
||||
|
||||
class EngineBlock : RotatableMatteryBlock(Properties.of().mapColor(MapColor.COLOR_ORANGE).sound(SoundType.METAL).explosionResistance(14f).destroyTime(2.5f).requiresCorrectToolForDrops().pushReaction(PushReaction.NORMAL)) {
|
||||
class EngineBlock : RotatableMatteryBlock(Properties.of(Material.METAL, DyeColor.ORANGE).sound(SoundType.METAL).explosionResistance(14f).destroyTime(2.5f).requiresCorrectToolForDrops()) {
|
||||
override fun appendHoverText(
|
||||
itemStack: ItemStack,
|
||||
blockAccessor: BlockGetter?,
|
||||
@ -29,6 +30,10 @@ class EngineBlock : RotatableMatteryBlock(Properties.of().mapColor(MapColor.COLO
|
||||
components.add(TranslatableComponent("$descriptionId.desc").withStyle(ChatFormatting.DARK_GRAY))
|
||||
}
|
||||
|
||||
override fun getPistonPushReaction(p_60584_: BlockState): PushReaction {
|
||||
return PushReaction.NORMAL
|
||||
}
|
||||
|
||||
override fun rotationFreedom(): BlockRotationFreedom {
|
||||
return BlockRotationFreedom.DIRECTIONAL
|
||||
}
|
||||
|
@ -10,14 +10,15 @@ import net.minecraft.world.level.block.entity.BlockEntity
|
||||
import net.minecraft.world.level.block.entity.BlockEntityTicker
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType
|
||||
import net.minecraft.world.level.block.state.BlockState
|
||||
import net.minecraft.world.level.material.MapColor
|
||||
import net.minecraft.world.level.material.Material
|
||||
import net.minecraft.world.level.material.MaterialColor
|
||||
import net.minecraft.world.level.material.PushReaction
|
||||
import net.minecraft.world.phys.BlockHitResult
|
||||
import net.minecraftforge.fluids.FluidUtil
|
||||
import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock
|
||||
import ru.dbotthepony.mc.otm.block.entity.decorative.InfiniteWaterSourceBlockEntity
|
||||
|
||||
class InfiniteWaterSourceBlock : RotatableMatteryBlock(Properties.of().destroyTime(1.5f).explosionResistance(10f).pushReaction(PushReaction.NORMAL).requiresCorrectToolForDrops().mapColor(MapColor.WATER)), EntityBlock {
|
||||
class InfiniteWaterSourceBlock : RotatableMatteryBlock(Properties.of(Material.METAL, MaterialColor.WATER).destroyTime(1.5f).explosionResistance(10f).requiresCorrectToolForDrops()), EntityBlock {
|
||||
override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity {
|
||||
return InfiniteWaterSourceBlockEntity(p_153215_, p_153216_)
|
||||
}
|
||||
@ -31,6 +32,10 @@ class InfiniteWaterSourceBlock : RotatableMatteryBlock(Properties.of().destroyTi
|
||||
return super.use(blockState, level, blockPos, ply, hand, blockHitResult)
|
||||
}
|
||||
|
||||
override fun getPistonPushReaction(p_60584_: BlockState): PushReaction {
|
||||
return PushReaction.NORMAL
|
||||
}
|
||||
|
||||
override fun <T : BlockEntity> getTicker(p_153212_: Level, p_153213_: BlockState, p_153214_: BlockEntityType<T>): BlockEntityTicker<T>? {
|
||||
if (p_153212_.isClientSide)
|
||||
return null
|
||||
|
@ -3,6 +3,7 @@ package ru.dbotthepony.mc.otm.block.decorative
|
||||
import net.minecraft.ChatFormatting
|
||||
import net.minecraft.core.BlockPos
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.world.item.DyeColor
|
||||
import net.minecraft.world.item.ItemStack
|
||||
import net.minecraft.world.item.Items
|
||||
import net.minecraft.world.item.TooltipFlag
|
||||
@ -13,7 +14,7 @@ import net.minecraft.world.level.block.*
|
||||
import net.minecraft.world.level.block.state.BlockState
|
||||
import net.minecraft.world.level.block.state.StateDefinition
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties
|
||||
import net.minecraft.world.level.material.MapColor
|
||||
import net.minecraft.world.level.material.Material
|
||||
import net.minecraft.world.level.material.PushReaction
|
||||
import net.minecraft.world.phys.shapes.CollisionContext
|
||||
import net.minecraft.world.phys.shapes.Shapes
|
||||
@ -29,12 +30,16 @@ import ru.dbotthepony.mc.otm.registry.MBlocks
|
||||
|
||||
private val FACING_FULL = BlockRotationFreedom.DIRECTIONAL.property
|
||||
|
||||
class LaboratoryLampLight : Block(Properties.of().strength(-1.0F, 3600000.8F).noCollission().noLootTable().replaceable().pushReaction(PushReaction.DESTROY).lightLevel { 15 }) {
|
||||
class LaboratoryLampLight : Block(Properties.of(Material.AIR).strength(-1.0F, 3600000.8F).noCollission().noLootTable().lightLevel { 15 }) {
|
||||
override fun createBlockStateDefinition(builder: StateDefinition.Builder<Block, BlockState>) {
|
||||
super.createBlockStateDefinition(builder)
|
||||
builder.add(FACING_FULL)
|
||||
}
|
||||
|
||||
override fun getPistonPushReaction(p_60584_: BlockState): PushReaction {
|
||||
return PushReaction.DESTROY
|
||||
}
|
||||
|
||||
override fun hasDynamicShape(): Boolean {
|
||||
return true
|
||||
}
|
||||
@ -103,11 +108,15 @@ class LaboratoryLampLight : Block(Properties.of().strength(-1.0F, 3600000.8F).no
|
||||
}
|
||||
}
|
||||
|
||||
class LaboratoryLamp(val invertRedstone: Boolean) : Block(Properties.of().mapColor(MapColor.METAL).sound(SoundType.METAL).explosionResistance(12f).destroyTime(2f).requiresCorrectToolForDrops().pushReaction(PushReaction.BLOCK)) {
|
||||
class LaboratoryLamp(val invertRedstone: Boolean) : Block(Properties.of(Material.METAL, DyeColor.WHITE).sound(SoundType.METAL).explosionResistance(12f).destroyTime(2f).requiresCorrectToolForDrops()) {
|
||||
init {
|
||||
registerDefaultState(stateDefinition.any().setValue(BlockStateProperties.LIT, !invertRedstone))
|
||||
}
|
||||
|
||||
override fun getPistonPushReaction(p_60584_: BlockState): PushReaction {
|
||||
return PushReaction.NORMAL
|
||||
}
|
||||
|
||||
override fun createBlockStateDefinition(builder: StateDefinition.Builder<Block, BlockState>) {
|
||||
super.createBlockStateDefinition(builder)
|
||||
builder.add(FACING_FULL)
|
||||
|
@ -12,18 +12,17 @@ import net.minecraft.world.level.BlockGetter
|
||||
import net.minecraft.world.level.block.DoorBlock
|
||||
import net.minecraft.world.level.block.state.BlockState
|
||||
import net.minecraft.world.level.block.state.properties.BlockSetType
|
||||
import net.minecraft.world.level.material.Material
|
||||
import net.minecraft.world.level.material.PushReaction
|
||||
import ru.dbotthepony.mc.otm.core.TooltipList
|
||||
import ru.dbotthepony.mc.otm.core.TranslatableComponent
|
||||
import ru.dbotthepony.mc.otm.core.collect.iteratorOf
|
||||
|
||||
class TritaniumDoorBlock(val color: DyeColor?) : DoorBlock(
|
||||
Properties.of()
|
||||
.mapColor(color ?: DyeColor.LIGHT_BLUE)
|
||||
Properties.of(Material.METAL, color ?: DyeColor.LIGHT_BLUE)
|
||||
.explosionResistance(80f)
|
||||
.noOcclusion()
|
||||
.destroyTime(3f)
|
||||
.pushReaction(PushReaction.DESTROY)
|
||||
.requiresCorrectToolForDrops(),
|
||||
BlockSetType.IRON
|
||||
) {
|
||||
@ -45,6 +44,10 @@ class TritaniumDoorBlock(val color: DyeColor?) : DoorBlock(
|
||||
tooltips.assemble(p_49816_, p_49818_)
|
||||
}
|
||||
|
||||
override fun getPistonPushReaction(p_52814_: BlockState): PushReaction {
|
||||
return PushReaction.DESTROY
|
||||
}
|
||||
|
||||
override fun canEntityDestroy(
|
||||
state: BlockState,
|
||||
level: BlockGetter,
|
||||
|
@ -16,12 +16,14 @@ import net.minecraft.world.level.block.state.BlockState
|
||||
import net.minecraft.world.level.block.state.StateDefinition
|
||||
import net.minecraft.world.level.block.state.properties.BlockSetType
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties
|
||||
import net.minecraft.world.level.material.Material
|
||||
import net.minecraft.world.level.material.PushReaction
|
||||
import ru.dbotthepony.mc.otm.core.TooltipList
|
||||
import ru.dbotthepony.mc.otm.core.TranslatableComponent
|
||||
import ru.dbotthepony.mc.otm.core.collect.iteratorOf
|
||||
import ru.dbotthepony.mc.otm.core.get
|
||||
|
||||
class TritaniumPressurePlate(color: DyeColor?) : BasePressurePlateBlock(Properties.of().mapColor(color ?: DyeColor.LIGHT_BLUE).sound(SoundType.METAL).explosionResistance(80f).noOcclusion().destroyTime(3f).requiresCorrectToolForDrops().forceSolidOn().noCollission(), BlockSetType.IRON) {
|
||||
class TritaniumPressurePlate(color: DyeColor?) : BasePressurePlateBlock(Properties.of(Material.METAL, color ?: DyeColor.LIGHT_BLUE).sound(SoundType.METAL).explosionResistance(80f).noOcclusion().destroyTime(3f).requiresCorrectToolForDrops().noCollission(), BlockSetType.IRON) {
|
||||
val tooltips = TooltipList()
|
||||
|
||||
override fun appendHoverText(
|
||||
|
@ -14,12 +14,12 @@ import net.minecraft.world.level.block.TrapDoorBlock
|
||||
import net.minecraft.world.level.block.state.BlockState
|
||||
import net.minecraft.world.level.block.state.properties.BlockSetType
|
||||
import ru.dbotthepony.mc.otm.core.TooltipList
|
||||
import net.minecraft.world.level.material.Material
|
||||
import ru.dbotthepony.mc.otm.core.TranslatableComponent
|
||||
import ru.dbotthepony.mc.otm.core.collect.iteratorOf
|
||||
|
||||
class TritaniumTrapdoorBlock(val color: DyeColor?) : TrapDoorBlock(
|
||||
Properties.of()
|
||||
.mapColor(color ?: DyeColor.LIGHT_BLUE)
|
||||
Properties.of(Material.METAL, color ?: DyeColor.LIGHT_BLUE)
|
||||
.explosionResistance(80f)
|
||||
.noOcclusion().destroyTime(3f)
|
||||
.requiresCorrectToolForDrops()
|
||||
|
@ -33,7 +33,7 @@ class ExperienceStorage(val maxExperience: DoubleSupplier = DoubleSupplier { Dou
|
||||
|
||||
if (whole > 0) {
|
||||
experience -= whole
|
||||
ExperienceOrb.award(player.level() as ServerLevel, player.position(), whole)
|
||||
ExperienceOrb.award(player.level as ServerLevel, player.position(), whole)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -594,14 +594,11 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc
|
||||
private fun recheckPlayer(player: ServerPlayer) {
|
||||
sometimeServer {
|
||||
if (player in players && !player.hasDisconnected()) {
|
||||
if (player.connection.chunkSender.isPending(chunkPos)) {
|
||||
recheckPlayer(player)
|
||||
} else {
|
||||
veto.remove(player)
|
||||
veto.remove(player)
|
||||
|
||||
blockEntities.forEach {
|
||||
it.synchers[player] = it.syncher.Remote()
|
||||
}
|
||||
blockEntities.forEach {
|
||||
it.synchers[player] =
|
||||
it.syncher.Remote()
|
||||
}
|
||||
} else if (player in players && player.hasDisconnected()) {
|
||||
unsubscribe(player)
|
||||
|
@ -668,11 +668,11 @@ class ExplosionQueue(private val level: ServerLevel) : SavedData() {
|
||||
@JvmStatic
|
||||
fun queueForLevel(level: ServerLevel): ExplosionQueue {
|
||||
return level.dataStorage.computeIfAbsent(
|
||||
Factory({ ExplosionQueue(level) }, {
|
||||
{
|
||||
val factory = ExplosionQueue(level)
|
||||
factory.load(it)
|
||||
factory
|
||||
}, DataFixTypes.LEVEL),
|
||||
}, { ExplosionQueue(level) },
|
||||
"otm_blackhole_explosion_queue"
|
||||
)
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ import net.minecraft.world.level.Level
|
||||
import net.minecraft.world.level.block.Block
|
||||
import net.minecraft.world.level.block.state.BlockState
|
||||
import net.minecraft.world.level.gameevent.GameEvent
|
||||
import net.minecraft.world.level.storage.loot.LootParams
|
||||
import net.minecraft.world.level.storage.loot.LootContext
|
||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets
|
||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParams
|
||||
import net.minecraft.world.phys.Vec3
|
||||
@ -105,7 +105,7 @@ class CargoCrateBlockEntity(
|
||||
val lootTableSeed = lootTableSeed ?: 0L
|
||||
val server = level?.server ?: return
|
||||
|
||||
val loot = server.lootData.getLootTable(lootTable)
|
||||
val loot = server.lootTables.get(lootTable)
|
||||
|
||||
if (ply is ServerPlayer) {
|
||||
CriteriaTriggers.GENERATE_LOOT.trigger(ply, lootTable)
|
||||
@ -114,15 +114,16 @@ class CargoCrateBlockEntity(
|
||||
this.lootTable = null
|
||||
this.lootTableSeed = null
|
||||
|
||||
val params = LootParams.Builder(level as ServerLevel)
|
||||
val params = LootContext.Builder(level as ServerLevel)
|
||||
.withParameter(LootContextParams.ORIGIN, Vec3.atCenterOf(this.worldPosition))
|
||||
|
||||
if (ply != null) {
|
||||
params.withLuck(ply.luck).withParameter(LootContextParams.THIS_ENTITY, ply)
|
||||
}
|
||||
|
||||
params.withOptionalRandomSeed(lootTableSeed)
|
||||
Containers.dropContents(level as ServerLevel, blockPos, container)
|
||||
loot.fill(container, params.create(LootContextParamSets.CHEST), lootTableSeed)
|
||||
loot.fill(container, params.create(LootContextParamSets.CHEST))
|
||||
}
|
||||
|
||||
override val defaultDisplayName: Component
|
||||
|
@ -29,6 +29,7 @@ import ru.dbotthepony.mc.otm.container.MatteryContainer
|
||||
import ru.dbotthepony.mc.otm.container.ShadowCraftingContainer
|
||||
import ru.dbotthepony.mc.otm.container.UpgradeContainer
|
||||
import ru.dbotthepony.mc.otm.core.math.Decimal
|
||||
import ru.dbotthepony.mc.otm.core.value
|
||||
import ru.dbotthepony.mc.otm.data.DecimalCodec
|
||||
import ru.dbotthepony.mc.otm.data.minRange
|
||||
import ru.dbotthepony.mc.otm.graph.matter.MatterNode
|
||||
|
@ -11,7 +11,6 @@ import net.minecraft.world.Container
|
||||
import net.minecraft.world.entity.player.Inventory
|
||||
import net.minecraft.world.entity.player.Player
|
||||
import net.minecraft.world.inventory.AbstractContainerMenu
|
||||
import net.minecraft.world.inventory.TransientCraftingContainer
|
||||
import net.minecraft.world.item.ItemStack
|
||||
import net.minecraft.world.item.crafting.CraftingRecipe
|
||||
import net.minecraft.world.item.crafting.RecipeType
|
||||
@ -28,11 +27,9 @@ import ru.dbotthepony.mc.otm.capability.matteryPlayer
|
||||
import ru.dbotthepony.mc.otm.client.render.IGUIRenderable
|
||||
import ru.dbotthepony.mc.otm.client.render.UVWindingOrder
|
||||
import ru.dbotthepony.mc.otm.config.MachinesConfig
|
||||
import ru.dbotthepony.mc.otm.container.MatteryContainer
|
||||
import ru.dbotthepony.mc.otm.graph.storage.StorageNode
|
||||
import ru.dbotthepony.mc.otm.graph.storage.StorageGraph
|
||||
import ru.dbotthepony.mc.otm.registry.MBlockEntities
|
||||
import ru.dbotthepony.mc.otm.container.set
|
||||
import ru.dbotthepony.mc.otm.core.nbt.mapString
|
||||
import ru.dbotthepony.mc.otm.core.nbt.set
|
||||
import ru.dbotthepony.mc.otm.menu.storage.ItemMonitorMenu
|
||||
@ -44,11 +41,14 @@ import kotlin.collections.HashMap
|
||||
import ru.dbotthepony.mc.otm.client.render.Widgets8
|
||||
import ru.dbotthepony.mc.otm.container.CombinedContainer
|
||||
import ru.dbotthepony.mc.otm.container.MatteryCraftingContainer
|
||||
import ru.dbotthepony.mc.otm.container.get
|
||||
import ru.dbotthepony.mc.otm.container.set
|
||||
import ru.dbotthepony.mc.otm.container.util.slotIterator
|
||||
import ru.dbotthepony.mc.otm.core.collect.map
|
||||
import ru.dbotthepony.mc.otm.core.collect.toList
|
||||
import ru.dbotthepony.mc.otm.core.isNotEmpty
|
||||
import ru.dbotthepony.mc.otm.core.util.ItemStorageStackSorter
|
||||
import ru.dbotthepony.mc.otm.core.value
|
||||
|
||||
interface IItemMonitorPlayerSettings {
|
||||
var ingredientPriority: ItemMonitorPlayerSettings.IngredientPriority
|
||||
@ -430,7 +430,7 @@ class ItemMonitorBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matte
|
||||
check(this.settings.put(UUID.fromString(key), ItemMonitorPlayerSettings().also { it.deserializeNBT(settings.getCompound(key)) }) == null)
|
||||
}
|
||||
|
||||
craftingGrid.deserializeNBT(nbt["crafting_grid"])
|
||||
craftingGrid.deserializeNBT(nbt["crafting_grid"] as? CompoundTag)
|
||||
}
|
||||
|
||||
fun getSettings(ply: ServerPlayer): ItemMonitorPlayerSettings {
|
||||
|
@ -36,6 +36,7 @@ import ru.dbotthepony.mc.otm.core.collect.filter
|
||||
import ru.dbotthepony.mc.otm.core.collect.maybe
|
||||
import ru.dbotthepony.mc.otm.core.getValue
|
||||
import ru.dbotthepony.mc.otm.core.immutableList
|
||||
import ru.dbotthepony.mc.otm.core.value
|
||||
import ru.dbotthepony.mc.otm.core.util.item
|
||||
import ru.dbotthepony.mc.otm.menu.tech.PoweredFurnaceMenu
|
||||
import ru.dbotthepony.mc.otm.recipe.MatteryCookingRecipe
|
||||
|
@ -22,6 +22,7 @@ import ru.dbotthepony.mc.otm.container.UpgradeContainer
|
||||
import ru.dbotthepony.mc.otm.container.balance
|
||||
import ru.dbotthepony.mc.otm.core.collect.filter
|
||||
import ru.dbotthepony.mc.otm.core.collect.maybe
|
||||
import ru.dbotthepony.mc.otm.core.value
|
||||
import ru.dbotthepony.mc.otm.menu.tech.PlatePressMenu
|
||||
import ru.dbotthepony.mc.otm.registry.MBlockEntities
|
||||
import ru.dbotthepony.mc.otm.registry.MRecipes
|
||||
|
@ -19,6 +19,7 @@ import net.minecraft.world.level.block.entity.BlockEntityType
|
||||
import net.minecraft.world.level.block.state.BlockState
|
||||
import net.minecraft.world.level.block.state.StateDefinition
|
||||
import net.minecraft.world.level.block.state.properties.EnumProperty
|
||||
import net.minecraft.world.level.material.Material
|
||||
import net.minecraft.world.level.material.PushReaction
|
||||
import net.minecraft.world.phys.shapes.CollisionContext
|
||||
import net.minecraft.world.phys.shapes.VoxelShape
|
||||
@ -35,13 +36,12 @@ import ru.dbotthepony.mc.otm.core.math.plus
|
||||
import ru.dbotthepony.mc.otm.oncePre
|
||||
import ru.dbotthepony.mc.otm.shapes.BlockShapes
|
||||
|
||||
class AndroidChargerBlock(val color: DyeColor?) : RotatableMatteryBlock(Properties.of().destroyTime(2.5f).explosionResistance(40f).pushReaction(PushReaction.BLOCK).requiresCorrectToolForDrops()), EntityBlock {
|
||||
class AndroidChargerBlock(val color: DyeColor?) : RotatableMatteryBlock(Properties.of(Material.METAL).destroyTime(2.5f).explosionResistance(40f).requiresCorrectToolForDrops()), EntityBlock {
|
||||
init {
|
||||
tooltips.painted(color)
|
||||
addSimpleDescription()
|
||||
tooltips.blockEntityEnergy()
|
||||
}
|
||||
|
||||
enum class Type : StringRepresentable {
|
||||
BASE,
|
||||
MIDDLE,
|
||||
@ -52,6 +52,10 @@ class AndroidChargerBlock(val color: DyeColor?) : RotatableMatteryBlock(Properti
|
||||
}
|
||||
}
|
||||
|
||||
override fun getPistonPushReaction(p_60584_: BlockState): PushReaction {
|
||||
return PushReaction.BLOCK
|
||||
}
|
||||
|
||||
override fun createBlockStateDefinition(builder: StateDefinition.Builder<Block, BlockState>) {
|
||||
super.createBlockStateDefinition(builder)
|
||||
builder.add(PART)
|
||||
|
@ -9,7 +9,7 @@ import net.minecraft.world.level.block.entity.BlockEntity
|
||||
import net.minecraft.world.level.block.entity.BlockEntityTicker
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType
|
||||
import net.minecraft.world.level.block.state.BlockState
|
||||
import net.minecraft.world.level.material.MapColor
|
||||
import net.minecraft.world.level.material.Material
|
||||
import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock
|
||||
import ru.dbotthepony.mc.otm.block.entity.blackhole.BlackHoleBlockEntity
|
||||
import ru.dbotthepony.mc.otm.block.entity.tech.BlackHoleGeneratorBlockEntity
|
||||
@ -17,7 +17,7 @@ import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom
|
||||
import ru.dbotthepony.mc.otm.core.math.plus
|
||||
import ru.dbotthepony.mc.otm.core.math.times
|
||||
|
||||
class BlackHoleGeneratorBlock : RotatableMatteryBlock(Properties.of().mapColor(MapColor.METAL).requiresCorrectToolForDrops().destroyTime(2.5f).explosionResistance(160.0f)), EntityBlock {
|
||||
class BlackHoleGeneratorBlock : RotatableMatteryBlock(Properties.of(Material.METAL).requiresCorrectToolForDrops().destroyTime(2.5f).explosionResistance(160.0f)), EntityBlock {
|
||||
override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity {
|
||||
return BlackHoleGeneratorBlockEntity(blockPos, blockState)
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ import net.minecraft.world.level.block.entity.BlockEntity
|
||||
import net.minecraft.world.level.block.entity.BlockEntityTicker
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType
|
||||
import net.minecraft.world.level.block.state.BlockState
|
||||
import net.minecraft.world.level.material.MapColor
|
||||
import net.minecraft.world.level.material.Material
|
||||
import net.minecraft.world.level.material.PushReaction
|
||||
import net.minecraft.world.phys.shapes.CollisionContext
|
||||
import net.minecraft.world.phys.shapes.VoxelShape
|
||||
@ -19,7 +19,7 @@ import ru.dbotthepony.mc.otm.block.entity.tech.CobblerBlockEntity
|
||||
import ru.dbotthepony.mc.otm.core.get
|
||||
import ru.dbotthepony.mc.otm.shapes.BlockShapes
|
||||
|
||||
class CobblerBlock(val color: DyeColor?) : RotatableMatteryBlock(Properties.of().mapColor(color?.mapColor ?: MapColor.METAL).pushReaction(PushReaction.BLOCK).requiresCorrectToolForDrops().destroyTime(1.5f).explosionResistance(25.0f)), EntityBlock {
|
||||
class CobblerBlock(val color: DyeColor?) : RotatableMatteryBlock(Properties.of(Material.METAL, color ?: DyeColor.LIGHT_BLUE).requiresCorrectToolForDrops().destroyTime(1.5f).explosionResistance(25.0f)), EntityBlock {
|
||||
override fun newBlockEntity(pPos: BlockPos, pState: BlockState): BlockEntity {
|
||||
return CobblerBlockEntity(pPos, pState)
|
||||
}
|
||||
@ -41,6 +41,10 @@ class CobblerBlock(val color: DyeColor?) : RotatableMatteryBlock(Properties.of()
|
||||
tooltips.painted(color)
|
||||
}
|
||||
|
||||
override fun getPistonPushReaction(p_60584_: BlockState): PushReaction {
|
||||
return PushReaction.BLOCK
|
||||
}
|
||||
|
||||
private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.COBBLESTONE_GENERATOR.rotateFromNorth(it[rotationProperty]).computeShape() }
|
||||
|
||||
@Suppress("override_deprecation")
|
||||
|
@ -10,7 +10,8 @@ import net.minecraft.world.level.block.entity.BlockEntity
|
||||
import net.minecraft.world.level.block.entity.BlockEntityTicker
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType
|
||||
import net.minecraft.world.level.block.state.BlockState
|
||||
import net.minecraft.world.level.material.MapColor
|
||||
import net.minecraft.world.level.material.Material
|
||||
import net.minecraft.world.level.material.PushReaction
|
||||
import net.minecraft.world.phys.shapes.CollisionContext
|
||||
import net.minecraft.world.phys.shapes.VoxelShape
|
||||
import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock
|
||||
@ -21,16 +22,19 @@ import ru.dbotthepony.mc.otm.core.get
|
||||
import ru.dbotthepony.mc.otm.registry.MBlockEntities
|
||||
import ru.dbotthepony.mc.otm.shapes.BlockShapes
|
||||
|
||||
class EnergyServoBlock(val color: DyeColor?) : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock {
|
||||
class EnergyServoBlock(val color: DyeColor?) : RotatableMatteryBlock(Properties.of(Material.METAL, DyeColor.BLUE).sound(SoundType.METAL).explosionResistance(12f).destroyTime(2f).requiresCorrectToolForDrops()), EntityBlock {
|
||||
init {
|
||||
tooltips.painted(color)
|
||||
addSimpleDescription()
|
||||
}
|
||||
|
||||
override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity {
|
||||
return EnergyServoBlockEntity(p_153215_, p_153216_)
|
||||
}
|
||||
|
||||
override fun getPistonPushReaction(p_60584_: BlockState): PushReaction {
|
||||
return PushReaction.BLOCK
|
||||
}
|
||||
|
||||
override fun <T : BlockEntity?> getTicker(
|
||||
p_153212_: Level,
|
||||
p_153213_: BlockState,
|
||||
|
@ -17,7 +17,7 @@ import net.minecraft.world.level.block.entity.BlockEntityType
|
||||
import net.minecraft.world.level.block.state.BlockState
|
||||
import net.minecraft.world.level.block.state.StateDefinition
|
||||
import net.minecraft.world.level.block.state.properties.BooleanProperty
|
||||
import net.minecraft.world.level.material.MapColor
|
||||
import net.minecraft.world.level.material.Material
|
||||
import net.minecraft.world.level.material.PushReaction
|
||||
import net.minecraft.world.phys.BlockHitResult
|
||||
import net.minecraft.world.phys.shapes.CollisionContext
|
||||
@ -34,7 +34,7 @@ import ru.dbotthepony.mc.otm.core.util.getLevelFromXp
|
||||
import ru.dbotthepony.mc.otm.registry.MItems
|
||||
import ru.dbotthepony.mc.otm.shapes.BlockShapes
|
||||
|
||||
class EssenceStorageBlock(val color: DyeColor?) : RotatableMatteryBlock(Properties.of().mapColor(color?.mapColor ?: MapColor.METAL).pushReaction(PushReaction.BLOCK).requiresCorrectToolForDrops().destroyTime(1.5f).explosionResistance(60.0f)), EntityBlock {
|
||||
class EssenceStorageBlock(val color: DyeColor?) : RotatableMatteryBlock(Properties.of(Material.METAL, color ?: DyeColor.LIGHT_BLUE).requiresCorrectToolForDrops().destroyTime(1.5f).explosionResistance(60.0f)), EntityBlock {
|
||||
init {
|
||||
tooltips.painted(color)
|
||||
|
||||
@ -50,7 +50,6 @@ class EssenceStorageBlock(val color: DyeColor?) : RotatableMatteryBlock(Properti
|
||||
|
||||
registerDefaultState(getStateDefinition().any().setValue(FILLED, false))
|
||||
}
|
||||
|
||||
override fun newBlockEntity(pPos: BlockPos, pState: BlockState): BlockEntity {
|
||||
return EssenceStorageBlockEntity(pPos, pState)
|
||||
}
|
||||
@ -72,6 +71,10 @@ class EssenceStorageBlock(val color: DyeColor?) : RotatableMatteryBlock(Properti
|
||||
return super.use(blockState, level, blockPos, ply, hand, blockHitResult)
|
||||
}
|
||||
|
||||
override fun getPistonPushReaction(p_60584_: BlockState): PushReaction {
|
||||
return PushReaction.BLOCK
|
||||
}
|
||||
|
||||
override fun createBlockStateDefinition(builder: StateDefinition.Builder<Block, BlockState>) {
|
||||
super.createBlockStateDefinition(builder)
|
||||
builder.add(FILLED)
|
||||
|
@ -5,6 +5,7 @@ import net.minecraft.core.BlockPos
|
||||
import net.minecraft.core.Direction
|
||||
import net.minecraft.core.SectionPos
|
||||
import net.minecraft.world.entity.LivingEntity
|
||||
import net.minecraft.world.item.DyeColor
|
||||
import net.minecraft.world.item.ItemStack
|
||||
import net.minecraft.world.item.context.BlockPlaceContext
|
||||
import net.minecraft.world.level.BlockGetter
|
||||
@ -19,7 +20,7 @@ import net.minecraft.world.level.block.entity.BlockEntityType
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour
|
||||
import net.minecraft.world.level.block.state.BlockState
|
||||
import net.minecraft.world.level.block.state.StateDefinition
|
||||
import net.minecraft.world.level.material.MapColor
|
||||
import net.minecraft.world.level.material.Material
|
||||
import net.minecraft.world.level.material.PushReaction
|
||||
import net.minecraft.world.phys.shapes.CollisionContext
|
||||
import net.minecraft.world.phys.shapes.VoxelShape
|
||||
@ -40,7 +41,7 @@ import ru.dbotthepony.mc.otm.registry.MBlocks
|
||||
import ru.dbotthepony.mc.otm.shapes.BlockShapes
|
||||
import kotlin.math.PI
|
||||
|
||||
private val props = BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_BLUE).sound(SoundType.METAL).pushReaction(PushReaction.BLOCK).requiresCorrectToolForDrops().strength(3f, 600.0f)
|
||||
private val props = BlockBehaviour.Properties.of(Material.METAL, DyeColor.BLUE).sound(SoundType.METAL).requiresCorrectToolForDrops().strength(3f, 600.0f)
|
||||
|
||||
class BlockGravitationStabilizer : RotatableMatteryBlock(props), EntityBlock {
|
||||
init {
|
||||
@ -54,6 +55,10 @@ class BlockGravitationStabilizer : RotatableMatteryBlock(props), EntityBlock {
|
||||
return GravitationStabilizerBlockEntity(p_153215_, p_153216_)
|
||||
}
|
||||
|
||||
override fun getPistonPushReaction(p_60584_: BlockState): PushReaction {
|
||||
return PushReaction.BLOCK
|
||||
}
|
||||
|
||||
override fun <T : BlockEntity?> getTicker(
|
||||
p_153212_: Level,
|
||||
p_153213_: BlockState,
|
||||
|
@ -9,12 +9,12 @@ import net.minecraft.world.level.block.entity.BlockEntity
|
||||
import net.minecraft.world.level.block.entity.BlockEntityTicker
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType
|
||||
import net.minecraft.world.level.block.state.BlockState
|
||||
import net.minecraft.world.level.material.MapColor
|
||||
import net.minecraft.world.level.material.Material
|
||||
import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock
|
||||
import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity
|
||||
import ru.dbotthepony.mc.otm.core.TranslatableComponent
|
||||
|
||||
class HatchBlock(val factory: BlockEntityType.BlockEntitySupplier<out MatteryBlockEntity>, val needsTicking: Boolean = false) : RotatableMatteryBlock(Properties.of().mapColor(MapColor.METAL).requiresCorrectToolForDrops().destroyTime(2.5f).explosionResistance(80.0f)), EntityBlock {
|
||||
class HatchBlock(val factory: BlockEntityType.BlockEntitySupplier<out MatteryBlockEntity>, val needsTicking: Boolean = false) : RotatableMatteryBlock(Properties.of(Material.METAL).requiresCorrectToolForDrops().destroyTime(2.5f).explosionResistance(80.0f)), EntityBlock {
|
||||
override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity {
|
||||
return factory.create(blockPos, blockState)
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import net.minecraft.world.entity.LivingEntity
|
||||
import net.minecraft.world.entity.MobSpawnType
|
||||
import net.minecraft.world.entity.SpawnGroupData
|
||||
import net.minecraft.world.entity.monster.Phantom
|
||||
import net.minecraft.world.item.DyeColor
|
||||
import net.minecraft.world.item.ItemStack
|
||||
import net.minecraft.world.item.context.BlockPlaceContext
|
||||
import net.minecraft.world.level.BlockGetter
|
||||
@ -20,7 +21,7 @@ import net.minecraft.world.level.block.state.BlockState
|
||||
import net.minecraft.world.level.block.state.StateDefinition
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties
|
||||
import net.minecraft.world.level.block.state.properties.DoubleBlockHalf
|
||||
import net.minecraft.world.level.material.MapColor
|
||||
import net.minecraft.world.level.material.Material
|
||||
import net.minecraft.world.level.material.PushReaction
|
||||
import net.minecraft.world.phys.AABB
|
||||
import net.minecraft.world.phys.shapes.CollisionContext
|
||||
@ -36,12 +37,11 @@ import ru.dbotthepony.mc.otm.once
|
||||
import ru.dbotthepony.mc.otm.registry.MBlocks
|
||||
import ru.dbotthepony.mc.otm.shapes.BlockShapes
|
||||
|
||||
class PhantomAttractorBlock : RotatableMatteryBlock(Properties.of().mapColor(MapColor.COLOR_BLUE).sound(SoundType.METAL).pushReaction(PushReaction.BLOCK).destroyTime(3f).explosionResistance(12f).randomTicks()) {
|
||||
class PhantomAttractorBlock : RotatableMatteryBlock(Properties.of(Material.METAL, DyeColor.BLUE).sound(SoundType.METAL).destroyTime(3f).explosionResistance(12f).randomTicks()) {
|
||||
init {
|
||||
addSimpleDescription()
|
||||
tooltips.needsNoPower()
|
||||
}
|
||||
|
||||
@Suppress("OVERRIDE_DEPRECATION")
|
||||
override fun randomTick(
|
||||
blockState: BlockState,
|
||||
@ -75,6 +75,10 @@ class PhantomAttractorBlock : RotatableMatteryBlock(Properties.of().mapColor(Map
|
||||
}
|
||||
}
|
||||
|
||||
override fun getPistonPushReaction(p_60584_: BlockState): PushReaction {
|
||||
return PushReaction.BLOCK
|
||||
}
|
||||
|
||||
override fun createBlockStateDefinition(builder: StateDefinition.Builder<Block, BlockState>) {
|
||||
super.createBlockStateDefinition(builder)
|
||||
builder.add(BlockStateProperties.DOUBLE_BLOCK_HALF)
|
||||
|
@ -11,7 +11,7 @@ import net.minecraft.world.level.block.entity.BlockEntityTicker
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType
|
||||
import net.minecraft.world.level.block.state.BlockState
|
||||
import net.minecraft.world.level.block.state.StateDefinition
|
||||
import net.minecraft.world.level.material.MapColor
|
||||
import net.minecraft.world.level.material.Material
|
||||
import net.minecraft.world.level.material.PushReaction
|
||||
import net.minecraft.world.phys.shapes.CollisionContext
|
||||
import net.minecraft.world.phys.shapes.VoxelShape
|
||||
@ -22,7 +22,7 @@ import ru.dbotthepony.mc.otm.block.getShapeForEachState
|
||||
import ru.dbotthepony.mc.otm.core.get
|
||||
import ru.dbotthepony.mc.otm.shapes.BlockShapes
|
||||
|
||||
class PlatePressBlock(val color: DyeColor?, val isTwin: Boolean = false) : RotatableMatteryBlock(Properties.of().mapColor(color?.mapColor ?: MapColor.METAL).pushReaction(PushReaction.BLOCK).requiresCorrectToolForDrops().destroyTime(1.5f).explosionResistance(25.0f)), EntityBlock {
|
||||
class PlatePressBlock(val color: DyeColor?, val isTwin: Boolean = false) : RotatableMatteryBlock(Properties.of(Material.METAL, color ?: DyeColor.LIGHT_BLUE).requiresCorrectToolForDrops().destroyTime(1.5f).explosionResistance(25.0f)), EntityBlock {
|
||||
init {
|
||||
tooltips.colored(color)
|
||||
if (isTwin) tooltips.doubleProcessing()
|
||||
@ -49,6 +49,10 @@ class PlatePressBlock(val color: DyeColor?, val isTwin: Boolean = false) : Rotat
|
||||
builder.add(WorkerState.WORKER_STATE)
|
||||
}
|
||||
|
||||
override fun getPistonPushReaction(p_60584_: BlockState): PushReaction {
|
||||
return PushReaction.BLOCK
|
||||
}
|
||||
|
||||
private val shapes = getShapeForEachState(rotationProperty) { (if (isTwin) BlockShapes.TWIN_PLATE_PRESS_IDLE else BlockShapes.PLATE_PRESS_IDLE).rotateFromNorth(it[rotationProperty]).computeShape() }
|
||||
|
||||
@Suppress("override_deprecation")
|
||||
|
@ -156,7 +156,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial
|
||||
@Cancelable
|
||||
data class PreTick(val capability: MatteryPlayerCapability) : Event() {
|
||||
val player get() = capability.ply
|
||||
val level: Level get() = capability.ply.level()
|
||||
val level: Level get() = capability.ply.level
|
||||
|
||||
override fun isCancelable(): Boolean {
|
||||
return true
|
||||
@ -168,7 +168,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial
|
||||
*/
|
||||
data class PostTick(val capability: MatteryPlayerCapability) : Event() {
|
||||
val player get() = capability.ply
|
||||
val level: Level get() = capability.ply.level()
|
||||
val level: Level get() = capability.ply.level
|
||||
|
||||
override fun isCancelable(): Boolean {
|
||||
return false
|
||||
@ -181,7 +181,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial
|
||||
*/
|
||||
data class ItemStackLeftoverEvent(val stack: ItemStack, val capability: MatteryPlayerCapability) : Event() {
|
||||
val player get() = capability.ply
|
||||
val level: Level get() = capability.ply.level()
|
||||
val level: Level get() = capability.ply.level
|
||||
|
||||
override fun isCancelable(): Boolean {
|
||||
return false
|
||||
@ -538,7 +538,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial
|
||||
|
||||
override fun computeNextJob(): JobContainer<ItemJob> {
|
||||
if (!exopackEnergy.batteryLevel.isPositive) return JobContainer.noEnergy()
|
||||
val level = ply.level() as? ServerLevel ?: return JobContainer.failure()
|
||||
val level = ply.level as? ServerLevel ?: return JobContainer.failure()
|
||||
val recipe = cache.getRecipeFor(input, level)
|
||||
|
||||
if (recipe.isEmpty) {
|
||||
@ -555,8 +555,8 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial
|
||||
override fun onJobTick(status: JobStatus<ItemJob>) {
|
||||
super.onJobTick(status)
|
||||
|
||||
if (isExopackVisible && ply.level().random.nextFloat() <= 0.05f) {
|
||||
MatteryPlayerNetworkChannel.send(PacketDistributor.TRACKING_ENTITY_AND_SELF.with(ply as ServerPlayer), ExopackSmokePacket(ply.uuid))
|
||||
if (isExopackVisible && ply.level.random.nextFloat() <= 0.05f) {
|
||||
MatteryPlayerNetworkChannel.send(PacketDistributor.TRACKING_ENTITY_AND_SELF.with { ply as ServerPlayer }, ExopackSmokePacket(ply.uuid))
|
||||
}
|
||||
}
|
||||
|
||||
@ -699,7 +699,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial
|
||||
becomeAndroid()
|
||||
|
||||
if (!ply.abilities.invulnerable)
|
||||
ply.hurt(MatteryDamageSource(ply.level().registryAccess().damageType(MDamageTypes.BECOME_ANDROID)), ply.maxHealth * 2)
|
||||
ply.hurt(MatteryDamageSource(ply.level.registryAccess().damageType(MDamageTypes.BECOME_ANDROID)), ply.maxHealth * 2)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -761,7 +761,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial
|
||||
becomeHumane()
|
||||
|
||||
if (!ply.abilities.invulnerable)
|
||||
ply.hurt(MatteryDamageSource(ply.level().registryAccess().damageType(MDamageTypes.BECOME_HUMANE)), ply.maxHealth * 2)
|
||||
ply.hurt(MatteryDamageSource(ply.level.registryAccess().damageType(MDamageTypes.BECOME_HUMANE)), ply.maxHealth * 2)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -822,7 +822,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial
|
||||
if (featureMap.containsKey(feature.type)) return false
|
||||
featureMap[feature.type] = feature
|
||||
|
||||
if (!ply.level().isClientSide) {
|
||||
if (!ply.level.isClientSide) {
|
||||
queuedTicks.add(feature::applyModifiers)
|
||||
}
|
||||
|
||||
@ -850,7 +850,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial
|
||||
|
||||
featureMap[feature] = factory
|
||||
|
||||
if (!ply.level().isClientSide && isAndroid) {
|
||||
if (!ply.level.isClientSide && isAndroid) {
|
||||
queuedTicks.add(factory::applyModifiers)
|
||||
}
|
||||
|
||||
@ -875,7 +875,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial
|
||||
val removed = featureMap.remove(feature)
|
||||
|
||||
if (removed != null) {
|
||||
if (!ply.level().isClientSide && isAndroid) {
|
||||
if (!ply.level.isClientSide && isAndroid) {
|
||||
queuedTicks.add(removed::removeModifiers)
|
||||
}
|
||||
|
||||
@ -1048,7 +1048,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial
|
||||
instance.deserializeNBT(featureTag)
|
||||
addFeature(instance)
|
||||
|
||||
if (!ply.level().isClientSide) {
|
||||
if (!ply.level.isClientSide) {
|
||||
queuedTicks.add(instance::applyModifiers)
|
||||
}
|
||||
}
|
||||
@ -1102,7 +1102,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial
|
||||
if (hasExopack) {
|
||||
for ((i, stack) in exopackContainer.withIndex()) {
|
||||
if (!stack.isEmpty) {
|
||||
stack.inventoryTick(ply.level(), ply, i + 41, false)
|
||||
stack.inventoryTick(ply.level, ply, i + 41, false)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1211,8 +1211,8 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial
|
||||
ply.isSwimming = false
|
||||
|
||||
if (ply is ServerPlayer) {
|
||||
if (ply.level().dimension().location() != lastDimension) {
|
||||
lastDimension = ply.level().dimension().location()
|
||||
if (ply.level.dimension().location() != lastDimension) {
|
||||
lastDimension = ply.level.dimension().location()
|
||||
wasInLiquid = false
|
||||
lastLiquidPosition = ply.position
|
||||
liquidDistanceTravelled = 0.0
|
||||
@ -1264,7 +1264,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial
|
||||
while (stats.foodLevel > 18 && androidEnergy.receiveEnergyExact(AndroidConfig.ANDROID_ENERGY_PER_HUNGER_POINT / 2, false)) {
|
||||
stats.foodLevel--
|
||||
}
|
||||
} else if (ply.level().difficulty != Difficulty.PEACEFUL) {
|
||||
} else if (ply.level.difficulty != Difficulty.PEACEFUL) {
|
||||
stats.foodLevel = stats.foodLevel.coerceAtMost(18)
|
||||
}
|
||||
|
||||
@ -1276,7 +1276,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial
|
||||
stats.setSaturation(stats.saturationLevel + (extracted / AndroidConfig.ANDROID_ENERGY_PER_HUNGER_POINT).toFloat())
|
||||
}
|
||||
|
||||
if (androidEnergy.batteryLevel <= Decimal.TEN && !ply.isCreative && ply.level().difficulty != Difficulty.PEACEFUL) {
|
||||
if (androidEnergy.batteryLevel <= Decimal.TEN && !ply.isCreative && ply.level.difficulty != Difficulty.PEACEFUL) {
|
||||
if (stats.saturationLevel > 1f) {
|
||||
if (androidEnergy.receiveEnergyExact(AndroidConfig.ANDROID_ENERGY_PER_HUNGER_POINT, false)) {
|
||||
stats.setSaturation(stats.saturationLevel - 1f)
|
||||
@ -1293,7 +1293,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial
|
||||
}
|
||||
|
||||
if (androidEnergy.batteryLevel <= Decimal.TEN) {
|
||||
if (--nextDischargeHurt <= 0 && ply.hurt(DamageSource(ply.level().registryAccess().damageType(MDamageTypes.ANDROID_DISCHARGE)), 1f)) {
|
||||
if (--nextDischargeHurt <= 0 && ply.hurt(DamageSource(ply.level.registryAccess().damageType(MDamageTypes.ANDROID_DISCHARGE)), 1f)) {
|
||||
nextDischargeHurt = 20
|
||||
}
|
||||
|
||||
@ -1306,13 +1306,13 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial
|
||||
} else {
|
||||
nextDischargeHurt = 20
|
||||
|
||||
if (ply.isHurt && ply.level().gameRules.getBoolean(GameRules.RULE_NATURAL_REGENERATION)) {
|
||||
if (ply.isHurt && ply.level.gameRules.getBoolean(GameRules.RULE_NATURAL_REGENERATION)) {
|
||||
if (--nextHealTick <= 0) {
|
||||
nextHealTick = if (ply.level().difficulty == Difficulty.PEACEFUL) 10 else AndroidConfig.TIME_BETWEEN_NATURAL_REGENERATION
|
||||
nextHealTick = if (ply.level.difficulty == Difficulty.PEACEFUL) 10 else AndroidConfig.TIME_BETWEEN_NATURAL_REGENERATION
|
||||
ply.heal(1f)
|
||||
}
|
||||
} else {
|
||||
nextHealTick = if (ply.level().difficulty == Difficulty.PEACEFUL) 10 else AndroidConfig.TIME_BETWEEN_NATURAL_REGENERATION
|
||||
nextHealTick = if (ply.level.difficulty == Difficulty.PEACEFUL) 10 else AndroidConfig.TIME_BETWEEN_NATURAL_REGENERATION
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1441,7 +1441,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial
|
||||
|
||||
pos.mul(RenderSystem.getProjectionMatrix())
|
||||
pos.mul(poseStack.last().pose())
|
||||
makeSmoke(cam.x + pos.x, cam.y + pos.y, cam.z + pos.z, ply.level().random, ply.level())
|
||||
makeSmoke(cam.x + pos.x, cam.y + pos.y, cam.z + pos.z, ply.level.random, ply.level)
|
||||
}
|
||||
}
|
||||
|
||||
@ -1536,13 +1536,13 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial
|
||||
val ent = event.player
|
||||
|
||||
if (event.phase == TickEvent.Phase.START) {
|
||||
if (!ent.level().isClientSide) {
|
||||
if (!ent.level.isClientSide) {
|
||||
ent.getCapability(MatteryCapability.MATTERY_PLAYER).ifPresentK {
|
||||
it.preTick()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (ent.level().isClientSide) {
|
||||
if (ent.level.isClientSide) {
|
||||
ent.getCapability(MatteryCapability.MATTERY_PLAYER).ifPresentK {
|
||||
it.tickClient()
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ object AndroidAbilityKeyMapping : KeyMapping("key.otm.android_ability", KeyConfl
|
||||
|
||||
val x = minecraft.window.guiScaledWidth.toFloat() * .5f + iconSize / 2f
|
||||
val y = minecraft.window.guiScaledHeight.toFloat() * .5f - iconSize / 2f
|
||||
val wrap = MGUIGraphics(event.guiGraphics)
|
||||
val wrap = MGUIGraphics(event.poseStack)
|
||||
|
||||
feature.renderIcon(wrap, x, y, iconSize, iconSize)
|
||||
|
||||
|
@ -155,7 +155,7 @@ object AndroidMenuKeyMapping : KeyMapping("key.otm.android_menu", KeyConflictCon
|
||||
RenderSystem.setShaderColor(0f, 0f, 0f, 0.6f)
|
||||
|
||||
val size = minecraft.window.guiScaledHeight.coerceAtMost(minecraft.window.guiScaledWidth).toFloat() * 0.35f
|
||||
val wrap = MGUIGraphics(event.guiGraphics)
|
||||
val wrap = MGUIGraphics(event.poseStack)
|
||||
|
||||
wrap.drawArc(
|
||||
minecraft.window.guiScaledWidth / 2f,
|
||||
@ -241,7 +241,7 @@ object AndroidMenuKeyMapping : KeyMapping("key.otm.android_menu", KeyConflictCon
|
||||
|
||||
val iconSize = size * 0.25f
|
||||
|
||||
val poseStack = event.guiGraphics.pose()
|
||||
val poseStack = event.poseStack
|
||||
poseStack.pushPose()
|
||||
poseStack.translate(minecraft.window.guiScaledWidth.toDouble() / 2f, minecraft.window.guiScaledHeight.toDouble() / 2f, 0.0)
|
||||
|
||||
@ -294,7 +294,7 @@ object AndroidMenuKeyMapping : KeyMapping("key.otm.android_menu", KeyConflictCon
|
||||
|
||||
val y = minecraft.window.guiScaledHeight * 0.2f
|
||||
var x = minecraft.window.guiScaledWidth * 0.5f - (features.size.toFloat() * COOLDOWN_ICON_SIZE / 2f + (features.size - 1).toFloat() * (COOLDOWN_ICON_MARGIN / 2f))
|
||||
val wrap = MGUIGraphics(event.guiGraphics)
|
||||
val wrap = MGUIGraphics(event.poseStack)
|
||||
|
||||
for (feature in features) {
|
||||
feature.renderIcon(wrap, x, y, COOLDOWN_ICON_SIZE, COOLDOWN_ICON_SIZE)
|
||||
|
@ -60,7 +60,7 @@ fun onMovementInputUpdate(event: MovementInputUpdateEvent) {
|
||||
cap.lastJumpTicks = 14
|
||||
} else {
|
||||
if (ply.isInWater) {
|
||||
if (ply.onGround()) {
|
||||
if (ply.isOnGround) {
|
||||
cap.lastJumpTicks = 14
|
||||
}
|
||||
|
||||
@ -224,7 +224,7 @@ fun onMouseScrolled(event: MouseScrolled.Pre) {
|
||||
|
||||
for (widget in screen.renderables) {
|
||||
if (widget is Panel2Widget<*, *>) {
|
||||
if (widget.panel.mouseScrolledChecked(event.mouseX, event.mouseY, event.deltaX)) {
|
||||
if (widget.panel.mouseScrolledChecked(event.mouseX, event.mouseY, event.scrollDelta)) {
|
||||
event.isCanceled = true
|
||||
return
|
||||
}
|
||||
@ -233,7 +233,7 @@ fun onMouseScrolled(event: MouseScrolled.Pre) {
|
||||
val slot = screen.slotUnderMouse
|
||||
|
||||
if (slot != null && (slot.container == minecraft.player?.inventory && slot.containerSlot in 9 .. 35 || slot.container == minecraft.player?.matteryPlayer?.exopackContainer)) {
|
||||
widget.panel.mouseScrolledInner(event.mouseX, event.mouseY, event.deltaX)
|
||||
widget.panel.mouseScrolledInner(event.mouseX, event.mouseY, event.scrollDelta)
|
||||
event.isCanceled = true
|
||||
return
|
||||
}
|
||||
|
@ -1,8 +1,9 @@
|
||||
package ru.dbotthepony.mc.otm.client
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem
|
||||
import com.mojang.blaze3d.vertex.PoseStack
|
||||
import net.minecraft.client.gui.Font
|
||||
import net.minecraft.client.gui.GuiGraphics
|
||||
|
||||
import net.minecraft.client.gui.components.Button
|
||||
import net.minecraft.client.gui.screens.DeathScreen
|
||||
import net.minecraft.client.gui.screens.InBedChatScreen
|
||||
@ -141,7 +142,7 @@ object MatteryGUI {
|
||||
return
|
||||
}
|
||||
|
||||
val guiGraphics = MGUIGraphics(event.guiGraphics)
|
||||
val guiGraphics = MGUIGraphics(event.poseStack)
|
||||
val stack = guiGraphics.pose
|
||||
val window = event.window
|
||||
|
||||
@ -253,7 +254,7 @@ object MatteryGUI {
|
||||
|
||||
val leftPadding = ceil(level * 80f - 0.5f)
|
||||
|
||||
val guiGraphics = MGUIGraphics(event.guiGraphics)
|
||||
val guiGraphics = MGUIGraphics(event.poseStack)
|
||||
|
||||
if (ply.hasEffect(MobEffects.HUNGER)) {
|
||||
CHARGE_HUNGER_BG.render(guiGraphics, left.toFloat(), top.toFloat())
|
||||
@ -323,7 +324,7 @@ object MatteryGUI {
|
||||
val top: Int = height - gui.leftHeight
|
||||
gui.leftHeight += 10
|
||||
|
||||
val guiGraphics = MGUIGraphics(event.guiGraphics)
|
||||
val guiGraphics = MGUIGraphics(event.poseStack)
|
||||
|
||||
HEALTH_BG.render(guiGraphics, left.toFloat(), top.toFloat())
|
||||
|
||||
@ -360,7 +361,7 @@ object MatteryGUI {
|
||||
}
|
||||
}
|
||||
|
||||
fun renderShieldCooldownOverlay(graphics: GuiGraphics, font: Font, stack: ItemStack, x: Int, y: Int): Boolean {
|
||||
fun renderShieldCooldownOverlay(pose: PoseStack, font: Font, stack: ItemStack, x: Int, y: Int): Boolean {
|
||||
if (!stack.isEmpty && stack.item is ShieldItem) {
|
||||
if (!stack.canPerformAction(ToolActions.SHIELD_BLOCK)) return false
|
||||
|
||||
@ -369,7 +370,7 @@ object MatteryGUI {
|
||||
|
||||
val percent = ((stack.item.getUseDuration(stack) - ply.useItemRemainingTicks + minecraft.partialTick) / 5f).coerceIn(0f, 1f)
|
||||
RenderSystem.setShaderColor(1f, 1f, 1f, 0.5f)
|
||||
drawArc(graphics.pose(), x + 8f, y + 8f, 8f, 0f, PI / 2.0, PI / 2.0 + PI * 2.0 * percent, alignAtCenter = true)
|
||||
drawArc(pose, x + 8f, y + 8f, 8f, 0f, PI / 2.0, PI / 2.0 + PI * 2.0 * percent, alignAtCenter = true)
|
||||
RenderSystem.setShaderColor(1f, 1f, 1f, 1f)
|
||||
|
||||
return true
|
||||
|
@ -3,12 +3,13 @@ package ru.dbotthepony.mc.otm.client.render
|
||||
import com.google.common.collect.ImmutableList
|
||||
import com.mojang.blaze3d.vertex.BufferBuilder
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer
|
||||
import com.mojang.blaze3d.vertex.VertexSorting
|
||||
import it.unimi.dsi.fastutil.ints.IntArrays
|
||||
import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap
|
||||
import it.unimi.dsi.fastutil.objects.ReferenceArraySet
|
||||
import net.minecraft.client.renderer.MultiBufferSource
|
||||
import net.minecraft.client.renderer.RenderType
|
||||
import net.minecraft.client.renderer.Sheets
|
||||
import org.joml.Vector3f
|
||||
|
||||
private fun equals(existing: ImmutableList<RenderType>?, types: Array<out RenderType>): Boolean {
|
||||
if (types.isEmpty()) {
|
||||
@ -63,7 +64,8 @@ private fun equals(existing: ImmutableList<RenderType>?, types: ImmutableList<Re
|
||||
*
|
||||
* Allows to batch OTM's geometry
|
||||
*/
|
||||
class DynamicBufferSource(val minimalInitialBufferSize: Int = 0, val maximalInitialBufferSize: Int = Int.MAX_VALUE, val vertexSorting: VertexSorting = VertexSorting.DISTANCE_TO_ORIGIN) : MultiBufferSource {
|
||||
// 1.19.4 and earlier: there is no actual quad sorting
|
||||
class DynamicBufferSource(val minimalInitialBufferSize: Int = 0, val maximalInitialBufferSize: Int = Int.MAX_VALUE, val sortX: Int = 0, val sortY: Int = 0, val sortZ: Int = 0) : MultiBufferSource {
|
||||
init {
|
||||
require(minimalInitialBufferSize >= 0) { "Invalid minimal buffer size $minimalInitialBufferSize" }
|
||||
require(maximalInitialBufferSize >= minimalInitialBufferSize) { "Maximal buffer size $maximalInitialBufferSize must be greater or equal to minimal buffer size $minimalInitialBufferSize" }
|
||||
@ -350,7 +352,7 @@ class DynamicBufferSource(val minimalInitialBufferSize: Int = 0, val maximalInit
|
||||
for (state in bufferList) {
|
||||
if (state.dirty) {
|
||||
state.dirty = false
|
||||
state.type.end(state.builder, vertexSorting)
|
||||
state.type.end(state.builder, sortX, sortY, sortZ)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -360,7 +362,7 @@ class DynamicBufferSource(val minimalInitialBufferSize: Int = 0, val maximalInit
|
||||
|
||||
if (state.dirty) {
|
||||
state.dirty = false
|
||||
type.end(state.builder, vertexSorting)
|
||||
type.end(state.builder, sortX, sortY, sortZ)
|
||||
}
|
||||
}
|
||||
|
||||
@ -369,7 +371,7 @@ class DynamicBufferSource(val minimalInitialBufferSize: Int = 0, val maximalInit
|
||||
|
||||
if (state.dirty) {
|
||||
state.dirty = false
|
||||
type.end(state.builder, vertexSorting)
|
||||
type.end(state.builder, sortX, sortY, sortZ)
|
||||
}
|
||||
|
||||
for (ustate in state.dependants) {
|
||||
@ -380,7 +382,7 @@ class DynamicBufferSource(val minimalInitialBufferSize: Int = 0, val maximalInit
|
||||
private fun endBatchChain(state: State) {
|
||||
if (state.dirty) {
|
||||
state.dirty = false
|
||||
state.type.end(state.builder, vertexSorting)
|
||||
state.type.end(state.builder, sortX, sortY, sortZ)
|
||||
}
|
||||
|
||||
for (ustate in state.dependants) {
|
||||
@ -390,7 +392,7 @@ class DynamicBufferSource(val minimalInitialBufferSize: Int = 0, val maximalInit
|
||||
|
||||
companion object {
|
||||
@JvmField
|
||||
val GUI = DynamicBufferSource(maximalInitialBufferSize = 2 shl 8, vertexSorting = VertexSorting.ORTHOGRAPHIC_Z)
|
||||
val GUI = DynamicBufferSource(maximalInitialBufferSize = 2 shl 8)
|
||||
@JvmField
|
||||
val WORLD = DynamicBufferSource(minimalInitialBufferSize = 2 shl 12)
|
||||
|
||||
|
@ -1,9 +1,7 @@
|
||||
package ru.dbotthepony.mc.otm.client.render
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack
|
||||
import com.mojang.blaze3d.vertex.VertexSorting
|
||||
import net.minecraft.client.gui.Font
|
||||
import net.minecraft.client.gui.GuiGraphics
|
||||
import net.minecraft.client.renderer.MultiBufferSource
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.util.FormattedCharSequence
|
||||
@ -14,7 +12,7 @@ import ru.dbotthepony.mc.otm.core.math.component1
|
||||
import ru.dbotthepony.mc.otm.core.math.component2
|
||||
import ru.dbotthepony.mc.otm.core.math.component3
|
||||
|
||||
private val buffer = DynamicBufferSource(vertexSorting = VertexSorting.ORTHOGRAPHIC_Z)
|
||||
private val buffer = DynamicBufferSource()
|
||||
private fun buffer() = buffer
|
||||
|
||||
private fun Font.drawInBatch(
|
||||
|
@ -148,7 +148,7 @@ object GlitchRenderer {
|
||||
|
||||
val glitchBuffer = glitchBuffer
|
||||
val projection = RenderSystem.getProjectionMatrix()
|
||||
RenderSystem.setProjectionMatrix(Matrix4f(), VertexSorting.ORTHOGRAPHIC_Z)
|
||||
RenderSystem.setProjectionMatrix(Matrix4f())
|
||||
|
||||
RenderSystem.getModelViewStack().also {
|
||||
it.pushPose()
|
||||
@ -244,7 +244,7 @@ object GlitchRenderer {
|
||||
RenderSystem.setShaderTexture(0, glitchBuffer.colorTextureId)
|
||||
draw(0.0, 0.0)
|
||||
|
||||
RenderSystem.setProjectionMatrix(projection, VertexSorting.DISTANCE_TO_ORIGIN)
|
||||
RenderSystem.setProjectionMatrix(projection)
|
||||
RenderSystem.getModelViewStack().popPose()
|
||||
RenderSystem.applyModelViewMatrix()
|
||||
}
|
||||
|
@ -1,33 +1,41 @@
|
||||
package ru.dbotthepony.mc.otm.client.render
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem
|
||||
import com.mojang.blaze3d.vertex.BufferUploader
|
||||
import com.mojang.blaze3d.vertex.DefaultVertexFormat
|
||||
import com.mojang.blaze3d.vertex.PoseStack
|
||||
import com.mojang.blaze3d.vertex.Tesselator
|
||||
import com.mojang.blaze3d.vertex.VertexFormat
|
||||
import net.minecraft.client.gui.Font
|
||||
import net.minecraft.client.gui.GuiGraphics
|
||||
import net.minecraft.client.gui.GuiComponent
|
||||
import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent
|
||||
import net.minecraft.client.gui.screens.inventory.tooltip.TooltipRenderUtil
|
||||
import net.minecraft.client.renderer.GameRenderer
|
||||
import net.minecraft.client.renderer.MultiBufferSource
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
import net.minecraft.util.FormattedCharSequence
|
||||
import net.minecraft.world.item.ItemStack
|
||||
import net.minecraftforge.client.ForgeHooksClient
|
||||
import ru.dbotthepony.mc.otm.client.minecraft
|
||||
import ru.dbotthepony.kommons.math.RGBAColor
|
||||
import kotlin.math.PI
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
// polyfill class for 1.19.4 and older
|
||||
class MGUIGraphics(val parent: GuiGraphics) {
|
||||
val pose: PoseStack get() = parent.pose()
|
||||
val bufferSource: MultiBufferSource.BufferSource get() = parent.bufferSource()
|
||||
val width get() = parent.guiWidth()
|
||||
val height get() = parent.guiHeight()
|
||||
class MGUIGraphics(val pose: PoseStack) {
|
||||
val bufferSource: MultiBufferSource.BufferSource get() = minecraft.renderBuffers().crumblingBufferSource()
|
||||
val width get() = minecraft.window.guiScaledWidth
|
||||
val height get() = minecraft.window.guiScaledHeight
|
||||
val font: Font get() = minecraft.font
|
||||
|
||||
fun setColor(red: Float, green: Float, blue: Float, alpha: Float) {
|
||||
parent.setColor(red, green, blue, alpha)
|
||||
RenderSystem.setShaderColor(red, green, blue, alpha)
|
||||
}
|
||||
|
||||
fun renderFakeItem(itemStack: ItemStack, x: Int, y: Int) {
|
||||
parent.renderFakeItem(itemStack, x, y)
|
||||
minecraft.itemRenderer.renderGuiItem(pose, itemStack, x, y)
|
||||
}
|
||||
|
||||
fun drawLine(
|
||||
@ -79,11 +87,70 @@ class MGUIGraphics(val parent: GuiGraphics) {
|
||||
}
|
||||
|
||||
fun renderComponentTooltip(font: Font, lines: MutableList<Component>, x: Int, y: Int, itemStack: ItemStack = ItemStack.EMPTY) {
|
||||
parent.renderComponentTooltip(font, lines, x, y, itemStack)
|
||||
if (lines.isNotEmpty()) {
|
||||
val mapped = lines.map { ClientTooltipComponent.create(it.visualOrderText) }
|
||||
val preEvent = ForgeHooksClient.onRenderTooltipPre(itemStack, pose, x, y, width, height, mapped, font, font)
|
||||
|
||||
if (preEvent.isCanceled) return
|
||||
var totalWidth = 0
|
||||
var totalHeight = if (lines.size == 1) -2 else 0
|
||||
|
||||
for (line in mapped) {
|
||||
val k = line.getWidth(preEvent.font)
|
||||
if (k > totalWidth) totalWidth = k
|
||||
totalHeight += line.height
|
||||
}
|
||||
|
||||
@Suppress("NAME_SHADOWING")
|
||||
var x = x + 12
|
||||
@Suppress("NAME_SHADOWING")
|
||||
var y = y - 12
|
||||
|
||||
if (x + totalWidth >= minecraft.window.guiScaledWidth)
|
||||
x = (x - 24 - totalWidth).coerceAtLeast(4)
|
||||
|
||||
if (y + totalHeight + 3 >= minecraft.window.guiScaledHeight)
|
||||
y = minecraft.window.guiScaledHeight - totalHeight - 3
|
||||
|
||||
pose.pushPose()
|
||||
val tesselator = Tesselator.getInstance()
|
||||
val bufferbuilder = tesselator.builder
|
||||
RenderSystem.setShader { GameRenderer.getPositionColorShader() }
|
||||
bufferbuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR)
|
||||
val matrix4f = pose.last().pose()
|
||||
val colorEvent = ForgeHooksClient.onRenderTooltipColor(itemStack, pose, x, y, preEvent.font, mapped)
|
||||
|
||||
TooltipRenderUtil.renderTooltipBackground(GuiComponent::fillGradient, matrix4f, bufferbuilder, x, y, totalWidth, totalHeight, 400, colorEvent.backgroundStart, colorEvent.backgroundEnd, colorEvent.borderStart, colorEvent.borderEnd)
|
||||
RenderSystem.enableDepthTest()
|
||||
RenderSystem.enableBlend()
|
||||
RenderSystem.defaultBlendFunc()
|
||||
BufferUploader.drawWithShader(bufferbuilder.end())
|
||||
|
||||
pose.translate(0.0f, 0.0f, 400.0f)
|
||||
var yCurrent = y
|
||||
|
||||
for (i in mapped.indices) {
|
||||
val line = mapped[i]
|
||||
line.renderText(preEvent.font, x, yCurrent, matrix4f, bufferSource)
|
||||
yCurrent += line.height + if (i == 0) 2 else 0
|
||||
}
|
||||
|
||||
bufferSource.endBatch()
|
||||
|
||||
yCurrent = y
|
||||
|
||||
for (i in mapped.indices) {
|
||||
val line = mapped[i]
|
||||
line.renderImage(preEvent.font, x, yCurrent, pose, minecraft.itemRenderer)
|
||||
yCurrent += line.height + if (i == 0) 2 else 0
|
||||
}
|
||||
|
||||
pose.popPose()
|
||||
}
|
||||
}
|
||||
|
||||
fun flush() {
|
||||
parent.flush()
|
||||
bufferSource.endBatch()
|
||||
}
|
||||
|
||||
fun draw(
|
||||
|
@ -1,16 +1,18 @@
|
||||
package ru.dbotthepony.mc.otm.client.screen
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem
|
||||
import com.mojang.blaze3d.vertex.PoseStack
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectFunction
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap
|
||||
import net.minecraft.ChatFormatting
|
||||
import net.minecraft.client.gui.Font
|
||||
import net.minecraft.client.gui.GuiGraphics
|
||||
|
||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.world.entity.player.Inventory
|
||||
import net.minecraft.world.inventory.Slot
|
||||
import net.minecraft.world.item.Item
|
||||
import net.minecraft.world.item.ItemDisplayContext
|
||||
import net.minecraft.world.item.ItemStack
|
||||
import net.minecraftforge.client.event.ContainerScreenEvent.Render.Background
|
||||
import net.minecraftforge.client.event.ContainerScreenEvent.Render.Foreground
|
||||
@ -92,19 +94,11 @@ abstract class MatteryScreen<T : MatteryMenu>(menu: T, inventory: Inventory, tit
|
||||
fun renderItemStack(graphics: MGUIGraphics, itemstack: ItemStack, countOverride: String? = null) {
|
||||
if (!itemstack.isEmpty) {
|
||||
RenderSystem.enableDepthTest()
|
||||
|
||||
val (x, y) = graphics.pose.translation()
|
||||
|
||||
graphics.parent.renderItem(
|
||||
requireNotNull(ru.dbotthepony.mc.otm.client.minecraft.player) { "yo, dude, what the fuck" },
|
||||
itemstack,
|
||||
1,
|
||||
1,
|
||||
(x + y * ru.dbotthepony.mc.otm.client.minecraft.window.guiScaledWidth).toInt()
|
||||
)
|
||||
|
||||
itemRenderer.renderGuiItem(graphics.pose, itemstack, 1, 1)
|
||||
RenderSystem.depthFunc(GL11.GL_ALWAYS)
|
||||
graphics.parent.renderItemDecorations(
|
||||
|
||||
itemRenderer.renderGuiItemDecorations(
|
||||
graphics.pose,
|
||||
super.font,
|
||||
itemstack,
|
||||
1,
|
||||
@ -569,7 +563,7 @@ abstract class MatteryScreen<T : MatteryMenu>(menu: T, inventory: Inventory, tit
|
||||
return super.mouseReleased(p_97812_, p_97813_, p_97814_)
|
||||
}
|
||||
|
||||
override fun mouseScrolled(mouseX: Double, mouseY: Double, scrollX: Double, scrollY: Double): Boolean {
|
||||
override fun mouseScrolled(mouseX: Double, mouseY: Double, scrollY: Double): Boolean {
|
||||
for (panel in panels) {
|
||||
if (panel.mouseScrolledChecked(mouseX, mouseY, scrollY)) {
|
||||
return true
|
||||
@ -614,7 +608,7 @@ abstract class MatteryScreen<T : MatteryMenu>(menu: T, inventory: Inventory, tit
|
||||
return super.keyPressed(key, scancode, mods)
|
||||
}
|
||||
|
||||
override fun renderBg(p_283065_: GuiGraphics, p_97788_: Float, p_97789_: Int, p_97790_: Int) {}
|
||||
override fun renderBg(p_283065_: PoseStack, p_97788_: Float, p_97789_: Int, p_97790_: Int) {}
|
||||
|
||||
var returnSlot: Slot? = null
|
||||
|
||||
@ -647,13 +641,13 @@ abstract class MatteryScreen<T : MatteryMenu>(menu: T, inventory: Inventory, tit
|
||||
return false
|
||||
}
|
||||
|
||||
override fun render(graphics: GuiGraphics, mouseX: Int, mouseY: Int, partialTick: Float) {
|
||||
val wrap = MGUIGraphics(graphics)
|
||||
override fun render(poseStack: PoseStack, mouseX: Int, mouseY: Int, partialTick: Float) {
|
||||
val wrap = MGUIGraphics(poseStack)
|
||||
val mouseXf = mouseX.toFloat()
|
||||
val mouseYf = mouseY.toFloat()
|
||||
|
||||
// dark background
|
||||
this.renderBackground(graphics, mouseX, mouseY, partialTick)
|
||||
this.renderBackground(poseStack)
|
||||
|
||||
super.hoveredSlot = null
|
||||
var hovered = false
|
||||
@ -680,17 +674,17 @@ abstract class MatteryScreen<T : MatteryMenu>(menu: T, inventory: Inventory, tit
|
||||
panels.asReversed().any { it.updateCursor1() }
|
||||
|
||||
RenderSystem.depthFunc(GL11.GL_LESS)
|
||||
MinecraftForge.EVENT_BUS.post(Background(this, graphics, mouseX, mouseY))
|
||||
MinecraftForge.EVENT_BUS.post(Background(this, poseStack, mouseX, mouseY))
|
||||
RenderSystem.disableDepthTest()
|
||||
|
||||
// Screen.super.render
|
||||
for (widget in renderables) {
|
||||
widget.render(graphics, mouseX, mouseY, partialTick)
|
||||
widget.render(poseStack, mouseX, mouseY, partialTick)
|
||||
}
|
||||
// /Screen.super.render
|
||||
|
||||
RenderSystem.disableDepthTest()
|
||||
MinecraftForge.EVENT_BUS.post(Foreground(this, graphics, mouseX, mouseY))
|
||||
MinecraftForge.EVENT_BUS.post(Foreground(this, poseStack, mouseX, mouseY))
|
||||
|
||||
var itemstack = if (draggingItem.isEmpty) menu.carried else draggingItem
|
||||
|
||||
@ -708,14 +702,14 @@ abstract class MatteryScreen<T : MatteryMenu>(menu: T, inventory: Inventory, tit
|
||||
}
|
||||
|
||||
@Suppress("NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS")
|
||||
renderFloatingItem(graphics, itemstack, mouseX - 8, mouseY - i2, overrideCount)
|
||||
renderFloatingItem(poseStack, itemstack, mouseX - 8, mouseY - i2, overrideCount)
|
||||
}
|
||||
|
||||
if (menu.carried.isEmpty) {
|
||||
val hoveredSlot = super.hoveredSlot
|
||||
|
||||
if (hoveredSlot != null && hoveredSlot.hasItem()) {
|
||||
this.renderTooltip(graphics, mouseX, mouseY)
|
||||
this.renderTooltip(poseStack, mouseX, mouseY)
|
||||
} else {
|
||||
for (panel in panels) {
|
||||
RenderSystem.disableDepthTest()
|
||||
|
@ -30,6 +30,7 @@ import ru.dbotthepony.mc.otm.core.TranslatableComponent
|
||||
import ru.dbotthepony.mc.otm.core.map
|
||||
import ru.dbotthepony.kommons.math.RGBAColor
|
||||
import ru.dbotthepony.mc.otm.core.util.CreativeMenuItemComparator
|
||||
import ru.dbotthepony.mc.otm.core.value
|
||||
import ru.dbotthepony.mc.otm.menu.decorative.PainterMenu
|
||||
|
||||
class PainterScreen(menu: PainterMenu, inventory: Inventory, title: Component) : MatteryScreen<PainterMenu>(menu, inventory, title) {
|
||||
@ -155,7 +156,7 @@ class PainterScreen(menu: PainterMenu, inventory: Inventory, title: Component) :
|
||||
set(value) {}
|
||||
|
||||
override fun innerRenderTooltips(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean {
|
||||
val list = getTooltipFromItem(minecraft!!, recipeOutput)
|
||||
val list = getTooltipFromItem(recipeOutput)
|
||||
|
||||
recipe.value.dyes.forEach {
|
||||
val (dye, amount) = it
|
||||
|
@ -100,7 +100,7 @@ open class EditablePanel<out S : Screen>(
|
||||
return this@EditablePanel.mouseDragged(p_94740_, p_94741_, p_94742_, p_94743_, p_94744_)
|
||||
}
|
||||
|
||||
override fun mouseScrolled(mouseX: Double, mouseY: Double, scrollX: Double, scrollY: Double): Boolean {
|
||||
override fun mouseScrolled(mouseX: Double, mouseY: Double, scrollY: Double): Boolean {
|
||||
return this@EditablePanel.mouseScrolled(mouseX, mouseY, scrollY)
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@ import com.mojang.blaze3d.systems.RenderSystem
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectFunction
|
||||
import net.minecraft.client.gui.screens.Screen
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen
|
||||
import net.minecraft.world.effect.MobEffect
|
||||
import net.minecraft.world.effect.MobEffectInstance
|
||||
import net.minecraft.world.entity.LivingEntity
|
||||
@ -264,7 +264,7 @@ open class EffectListPanel<out S : Screen> @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
companion object {
|
||||
val BAR = ResourceLocation("textures/gui/sprites/container/inventory/effect_background_large.png").sprite(0f, 0f, 120f, 32f, 120f, 32f)
|
||||
val SQUARE_THIN = ResourceLocation("textures/gui/sprites/hud/effect_background.png").sprite(0f, 0f, 24f, 24f, 24f, 24f)
|
||||
val BAR = AbstractContainerScreen.INVENTORY_LOCATION.sprite(0f, 166f, 120f, 32f)
|
||||
val SQUARE_THIN = AbstractContainerScreen.INVENTORY_LOCATION.sprite(141f, 166f, 24f, 24f)
|
||||
}
|
||||
}
|
||||
|
@ -170,14 +170,16 @@ class EntityRendererPanel<out S : Screen> @JvmOverloads constructor(
|
||||
return
|
||||
}
|
||||
|
||||
val renderX = width.toInt() / 2
|
||||
val renderY = (height * 0.9f).toInt()
|
||||
|
||||
InventoryScreen.renderEntityInInventoryFollowsMouse(
|
||||
graphics.parent,
|
||||
0, 0,
|
||||
this.width.toInt(), this.height.toInt(),
|
||||
graphics.pose,
|
||||
renderX,
|
||||
renderY,
|
||||
renderScale,
|
||||
0f,
|
||||
mouseX - absoluteX.toInt(),
|
||||
mouseY - absoluteY + height * 0.15f,
|
||||
absoluteX.toInt() + renderX - mouseX,
|
||||
absoluteY + height * 0.15f - mouseY,
|
||||
entity
|
||||
)
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package ru.dbotthepony.mc.otm.client.screen.panels
|
||||
|
||||
import net.minecraft.client.gui.GuiGraphics
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack
|
||||
import net.minecraft.client.gui.components.Renderable
|
||||
import net.minecraft.client.gui.components.events.GuiEventListener
|
||||
import net.minecraft.client.gui.screens.Screen
|
||||
@ -14,13 +15,13 @@ class Panel2Widget<out S: Screen, out P : EditablePanel<S>>(
|
||||
require(panel.parent == null) { "Widget wrapped panels can't have a parent ($panel has parent ${panel.parent})" }
|
||||
}
|
||||
|
||||
override fun render(graphics: GuiGraphics, mouseX: Int, mouseY: Int, partialTick: Float) {
|
||||
override fun render(stack: PoseStack, mouseX: Int, mouseY: Int, partialTick: Float) {
|
||||
panel.tick()
|
||||
|
||||
val xFloat = mouseX.toFloat()
|
||||
val yFloat = mouseY.toFloat()
|
||||
|
||||
val wrap = MGUIGraphics(graphics)
|
||||
val wrap = MGUIGraphics(stack)
|
||||
|
||||
panel.tickHover(xFloat, yFloat)
|
||||
panel.render(wrap, xFloat, yFloat, partialTick)
|
||||
@ -49,7 +50,7 @@ class Panel2Widget<out S: Screen, out P : EditablePanel<S>>(
|
||||
return panel.mouseDraggedChecked(p_94740_, p_94741_, p_94742_, p_94743_, p_94744_)
|
||||
}
|
||||
|
||||
override fun mouseScrolled(mouseX: Double, mouseY: Double, scrollX: Double, scrollY: Double): Boolean {
|
||||
override fun mouseScrolled(mouseX: Double, mouseY: Double, scrollY: Double): Boolean {
|
||||
return panel.mouseScrolledChecked(mouseX, mouseY, scrollY)
|
||||
}
|
||||
|
||||
|
@ -91,7 +91,7 @@ abstract class Widget2Panel<out S : Screen, T : AbstractWidget>(
|
||||
|
||||
override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
|
||||
RenderSystem.depthFunc(GL11.GL_ALWAYS)
|
||||
getOrCreateWidget().render(graphics.parent, mouseX.toInt(), mouseY.toInt(), partialTick)
|
||||
getOrCreateWidget().render(graphics.pose, mouseX.toInt(), mouseY.toInt(), partialTick)
|
||||
RenderSystem.depthFunc(GL11.GL_ALWAYS)
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
package ru.dbotthepony.mc.otm.client.screen.panels.slot
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem
|
||||
import net.minecraft.client.gui.screens.Screen.getTooltipFromItem
|
||||
import net.minecraft.client.renderer.GameRenderer
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.world.item.ItemStack
|
||||
@ -45,7 +44,7 @@ abstract class AbstractSlotPanel<out S : MatteryScreen<*>>(
|
||||
}
|
||||
|
||||
protected open fun getItemStackTooltip(stack: ItemStack): MutableList<Component> {
|
||||
return getTooltipFromItem(ru.dbotthepony.mc.otm.client.minecraft, stack)
|
||||
return screen.getTooltipFromItem(stack)
|
||||
}
|
||||
|
||||
override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
|
||||
|
@ -69,11 +69,14 @@ open class SlotPanel<out S : MatteryScreen<*>, out T : Slot>(
|
||||
itemstack = carried.copy()
|
||||
dragHit = true
|
||||
|
||||
val k = Math.min(AbstractContainerMenu.getQuickCraftPlaceCount(
|
||||
AbstractContainerMenu.getQuickCraftSlotCount(
|
||||
screen.quickCraftSlots,
|
||||
screen.quickCraftingType,
|
||||
itemstack
|
||||
) + slot.item.count, slot.getMaxStackSize(itemstack))
|
||||
itemstack,
|
||||
if (slot.item.isEmpty) 0 else slot.item.count
|
||||
)
|
||||
|
||||
val k = itemstack.maxStackSize.coerceAtMost(slot.getMaxStackSize(itemstack))
|
||||
|
||||
if (itemstack.count > k) {
|
||||
countOverride = ChatFormatting.YELLOW.toString() + k
|
||||
|
@ -35,7 +35,7 @@ fun onCuriosSlotModifiersUpdated(event: SlotModifiersUpdatedEvent) {
|
||||
}
|
||||
|
||||
fun openCuriosScreen(carriedStack: ItemStack = ItemStack.EMPTY) {
|
||||
if (FMLEnvironment.dist.isClient) NetworkHandler.INSTANCE.send(CPacketOpenCurios(carriedStack), PacketDistributor.SERVER.noArg())
|
||||
if (FMLEnvironment.dist.isClient) NetworkHandler.INSTANCE.send(PacketDistributor.SERVER.noArg(), CPacketOpenCurios(carriedStack))
|
||||
}
|
||||
|
||||
private fun Player.getCuriosSlotsImpl(): List<PlayerSlot<Slot, Slot>> {
|
||||
@ -57,7 +57,7 @@ private fun Player.getCuriosSlotsImpl(): List<PlayerSlot<Slot, Slot>> {
|
||||
val stacks = curio.stacks
|
||||
|
||||
for (slot in 0 until stacks.slots) {
|
||||
val regular = CurioSlot(this, stacks, slot, identifier, 0, 0, curio.renders, curio.canToggleRendering())
|
||||
val regular = CurioSlot(this, stacks, slot, identifier, 0, 0, curio.renders)
|
||||
|
||||
if (curio.hasCosmetic()) {
|
||||
val cosmetic = CosmeticCurioSlot(this, curio.cosmeticStacks, slot, identifier, 0, 0)
|
||||
|
@ -2,6 +2,9 @@ package ru.dbotthepony.mc.otm.compat.jade.providers
|
||||
|
||||
import net.minecraft.nbt.CompoundTag
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
import net.minecraft.server.level.ServerPlayer
|
||||
import net.minecraft.world.level.Level
|
||||
import net.minecraft.world.level.block.entity.BlockEntity
|
||||
import ru.dbotthepony.mc.otm.block.entity.WorkerState
|
||||
import ru.dbotthepony.mc.otm.block.entity.matter.MatterBottlerBlockEntity
|
||||
import ru.dbotthepony.mc.otm.compat.jade.JadeTagKeys
|
||||
@ -16,16 +19,14 @@ import snownee.jade.api.config.IPluginConfig
|
||||
import snownee.jade.api.ui.BoxStyle
|
||||
import snownee.jade.api.ui.IElementHelper
|
||||
|
||||
object MatterBottlerProvider : IBlockComponentProvider, IServerDataProvider<BlockAccessor> {
|
||||
object MatterBottlerProvider : IBlockComponentProvider, IServerDataProvider<BlockEntity> {
|
||||
override fun getUid(): ResourceLocation = JadeUids.MATTER_BOTTLER
|
||||
|
||||
override fun appendServerData(data: CompoundTag, accessor: BlockAccessor) {
|
||||
if (accessor.blockEntity is MatterBottlerBlockEntity) {
|
||||
val bottler = accessor.blockEntity as MatterBottlerBlockEntity
|
||||
|
||||
override fun appendServerData(data: CompoundTag, player: ServerPlayer, level: Level, bottler: BlockEntity?, state: Boolean) {
|
||||
if (bottler is MatterBottlerBlockEntity) {
|
||||
val bottlerData = CompoundTag()
|
||||
bottlerData.putBoolean("isBottling", bottler.isBottling)
|
||||
bottlerData.putBoolean("isIdling", accessor.blockState.getValue(WorkerState.SEMI_WORKER_STATE) !== WorkerState.WORKING)
|
||||
bottlerData.putBoolean("isIdling", bottler.blockState.getValue(WorkerState.SEMI_WORKER_STATE) !== WorkerState.WORKING)
|
||||
bottlerData.putFloat("workProgress", bottler.workProgress)
|
||||
data.put(JadeTagKeys.MATTER_BOTTLER_DATA, bottlerData)
|
||||
}
|
||||
@ -56,7 +57,7 @@ object MatterBottlerProvider : IBlockComponentProvider, IServerDataProvider<Bloc
|
||||
data.getFloat("workProgress"),
|
||||
null,
|
||||
elementHelper.progressStyle().color(RGBAColor.WHITE.toBGRA()),
|
||||
BoxStyle.getNestedBox(),
|
||||
BoxStyle.DEFAULT,
|
||||
true
|
||||
)
|
||||
)
|
||||
|
@ -2,6 +2,9 @@ package ru.dbotthepony.mc.otm.compat.jade.providers
|
||||
|
||||
import net.minecraft.nbt.CompoundTag
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
import net.minecraft.server.level.ServerPlayer
|
||||
import net.minecraft.world.level.Level
|
||||
import net.minecraft.world.level.block.entity.BlockEntity
|
||||
import ru.dbotthepony.mc.otm.block.entity.matter.MatterReconstructorBlockEntity
|
||||
import ru.dbotthepony.mc.otm.compat.jade.JadeTagKeys
|
||||
import ru.dbotthepony.mc.otm.compat.jade.JadeUids
|
||||
@ -15,13 +18,11 @@ import snownee.jade.api.config.IPluginConfig
|
||||
import snownee.jade.api.ui.BoxStyle
|
||||
import snownee.jade.api.ui.IElementHelper
|
||||
|
||||
object MatterReconstructorProvider : IBlockComponentProvider, IServerDataProvider<BlockAccessor> {
|
||||
object MatterReconstructorProvider : IBlockComponentProvider, IServerDataProvider<BlockEntity> {
|
||||
override fun getUid(): ResourceLocation = JadeUids.MATTER_RECONSTRUCTOR
|
||||
|
||||
override fun appendServerData(data: CompoundTag, accessor: BlockAccessor) {
|
||||
if (accessor.blockEntity is MatterReconstructorBlockEntity) {
|
||||
val reconstructor = accessor.blockEntity as MatterReconstructorBlockEntity
|
||||
|
||||
override fun appendServerData(data: CompoundTag, player: ServerPlayer, level: Level, reconstructor: BlockEntity?, state: Boolean) {
|
||||
if (reconstructor is MatterReconstructorBlockEntity) {
|
||||
val item = reconstructor.repairContainer.get(0)
|
||||
|
||||
if (!item.isEmpty && item.isDamageableItem && item.maxDamage != 0) {
|
||||
@ -57,7 +58,7 @@ object MatterReconstructorProvider : IBlockComponentProvider, IServerDataProvide
|
||||
maxDamage
|
||||
),
|
||||
elementHelper.progressStyle().color(RGBAColor.DARK_GREEN.toBGRA()).textColor(RGBAColor.WHITE.toBGRA()),
|
||||
BoxStyle.getNestedBox(),
|
||||
BoxStyle.DEFAULT,
|
||||
true
|
||||
)
|
||||
)
|
||||
|
@ -4,6 +4,9 @@ import net.minecraft.ChatFormatting
|
||||
import net.minecraft.nbt.CompoundTag
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
import net.minecraft.server.level.ServerPlayer
|
||||
import net.minecraft.world.level.Level
|
||||
import net.minecraft.world.level.block.entity.BlockEntity
|
||||
import ru.dbotthepony.mc.otm.capability.AbstractProfiledStorage
|
||||
import ru.dbotthepony.mc.otm.capability.MatteryCapability
|
||||
import ru.dbotthepony.mc.otm.compat.jade.JadeColors
|
||||
@ -24,11 +27,11 @@ import snownee.jade.api.config.IPluginConfig
|
||||
import snownee.jade.api.ui.BoxStyle
|
||||
import snownee.jade.api.ui.IElementHelper
|
||||
|
||||
object MatterStorageProvider : IBlockComponentProvider, IServerDataProvider<BlockAccessor> {
|
||||
object MatterStorageProvider : IBlockComponentProvider, IServerDataProvider<BlockEntity> {
|
||||
override fun getUid(): ResourceLocation = JadeUids.MATTER_STORAGE
|
||||
|
||||
override fun appendServerData(data: CompoundTag, accessor: BlockAccessor) {
|
||||
accessor.blockEntity?.getCapability(MatteryCapability.MATTER)?.ifPresentK {
|
||||
override fun appendServerData(data: CompoundTag, player: ServerPlayer, level: Level, blockEntity: BlockEntity?, state: Boolean) {
|
||||
blockEntity?.getCapability(MatteryCapability.MATTER)?.ifPresentK {
|
||||
val matterData = CompoundTag()
|
||||
|
||||
matterData.putDecimal("storedMatter", it.storedMatter)
|
||||
@ -69,7 +72,7 @@ object MatterStorageProvider : IBlockComponentProvider, IServerDataProvider<Bloc
|
||||
maxStoredMatter.formatMatter()
|
||||
),
|
||||
elementHelper.progressStyle().color(JadeColors.MATTER_COLOR.toBGRA()).textColor(RGBAColor.WHITE.toBGRA()),
|
||||
BoxStyle.getNestedBox(),
|
||||
BoxStyle.DEFAULT,
|
||||
true
|
||||
)
|
||||
)
|
||||
|
@ -4,6 +4,9 @@ import net.minecraft.ChatFormatting
|
||||
import net.minecraft.nbt.CompoundTag
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
import net.minecraft.server.level.ServerPlayer
|
||||
import net.minecraft.world.level.Level
|
||||
import net.minecraft.world.level.block.entity.BlockEntity
|
||||
import ru.dbotthepony.mc.otm.capability.AbstractProfiledStorage
|
||||
import ru.dbotthepony.mc.otm.capability.MatteryCapability
|
||||
import ru.dbotthepony.mc.otm.compat.jade.JadeColors
|
||||
@ -21,11 +24,11 @@ import snownee.jade.api.config.IPluginConfig
|
||||
import snownee.jade.api.ui.BoxStyle
|
||||
import snownee.jade.api.ui.IElementHelper
|
||||
|
||||
object MatteryEnergyProvider : IBlockComponentProvider, IServerDataProvider<BlockAccessor> {
|
||||
object MatteryEnergyProvider : IBlockComponentProvider, IServerDataProvider<BlockEntity> {
|
||||
override fun getUid(): ResourceLocation = JadeUids.MATTERY_ENERGY
|
||||
|
||||
override fun appendServerData(data: CompoundTag, accessor: BlockAccessor) {
|
||||
accessor.blockEntity?.getCapability(MatteryCapability.ENERGY)?.ifPresentK {
|
||||
override fun appendServerData(data: CompoundTag, player: ServerPlayer, level: Level, blockEntity: BlockEntity?, state: Boolean) {
|
||||
blockEntity?.getCapability(MatteryCapability.ENERGY)?.ifPresentK {
|
||||
val energyData = CompoundTag()
|
||||
|
||||
energyData.putDecimal("batteryLevel", it.batteryLevel)
|
||||
@ -67,7 +70,7 @@ object MatteryEnergyProvider : IBlockComponentProvider, IServerDataProvider<Bloc
|
||||
maxBatteryLevel.formatPower()
|
||||
),
|
||||
elementHelper.progressStyle().color(JadeColors.ENERGY_COLOR.toBGRA(), JadeColors.ENERGY_COLOR2.toBGRA()).textColor(RGBAColor.WHITE.toBGRA()),
|
||||
BoxStyle.getNestedBox(),
|
||||
BoxStyle.DEFAULT,
|
||||
true
|
||||
)
|
||||
)
|
||||
|
@ -3,6 +3,9 @@ package ru.dbotthepony.mc.otm.compat.jade.providers
|
||||
import net.minecraft.nbt.CompoundTag
|
||||
import net.minecraft.nbt.ListTag
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
import net.minecraft.server.level.ServerPlayer
|
||||
import net.minecraft.world.level.Level
|
||||
import net.minecraft.world.level.block.entity.BlockEntity
|
||||
import ru.dbotthepony.mc.otm.block.entity.ItemJob
|
||||
import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity
|
||||
import ru.dbotthepony.mc.otm.compat.jade.JadeTagKeys
|
||||
@ -19,13 +22,11 @@ import snownee.jade.api.config.IPluginConfig
|
||||
import snownee.jade.api.ui.BoxStyle
|
||||
import snownee.jade.api.ui.IElementHelper
|
||||
|
||||
object MatteryWorkerProvider : IBlockComponentProvider, IServerDataProvider<BlockAccessor> {
|
||||
object MatteryWorkerProvider : IBlockComponentProvider, IServerDataProvider<BlockEntity> {
|
||||
override fun getUid(): ResourceLocation = JadeUids.MATTERY_WORKER
|
||||
|
||||
override fun appendServerData(data: CompoundTag, accessor: BlockAccessor) {
|
||||
if (accessor.blockEntity is MatteryWorkerBlockEntity<*>) {
|
||||
val worker = accessor.blockEntity as MatteryWorkerBlockEntity<*>
|
||||
|
||||
override fun appendServerData(data: CompoundTag, player: ServerPlayer, level: Level, worker: BlockEntity?, state: Boolean) {
|
||||
if (worker is MatteryWorkerBlockEntity<*>) {
|
||||
val workerData = CompoundTag()
|
||||
|
||||
workerData["jobs"] = ListTag().also {
|
||||
@ -75,7 +76,7 @@ object MatteryWorkerProvider : IBlockComponentProvider, IServerDataProvider<Bloc
|
||||
progress,
|
||||
null,
|
||||
if (isUnableToProcess) styleError else style,
|
||||
BoxStyle.getNestedBox(),
|
||||
BoxStyle.DEFAULT,
|
||||
true
|
||||
)
|
||||
)
|
||||
|
@ -14,15 +14,14 @@ import net.minecraft.world.entity.player.Player
|
||||
import net.minecraft.world.inventory.MenuType
|
||||
import net.minecraft.world.inventory.Slot
|
||||
import net.minecraft.world.item.crafting.CraftingRecipe
|
||||
import net.minecraft.world.item.crafting.RecipeHolder
|
||||
import ru.dbotthepony.mc.otm.core.TranslatableComponent
|
||||
import ru.dbotthepony.mc.otm.core.toImmutableList
|
||||
import ru.dbotthepony.mc.otm.menu.ExopackInventoryMenu
|
||||
import java.util.*
|
||||
import kotlin.collections.ArrayList
|
||||
|
||||
class ExopackInventoryTransferHandler(private val helper: IRecipeTransferHandlerHelper) : IRecipeTransferHandler<ExopackInventoryMenu, RecipeHolder<CraftingRecipe>> {
|
||||
private val transfer = helper.createUnregisteredRecipeTransferHandler(object : IRecipeTransferInfo<ExopackInventoryMenu, RecipeHolder<CraftingRecipe>> {
|
||||
class ExopackInventoryTransferHandler(private val helper: IRecipeTransferHandlerHelper) : IRecipeTransferHandler<ExopackInventoryMenu, CraftingRecipe> {
|
||||
private val transfer = helper.createUnregisteredRecipeTransferHandler(object : IRecipeTransferInfo<ExopackInventoryMenu, CraftingRecipe> {
|
||||
override fun getContainerClass(): Class<out ExopackInventoryMenu> {
|
||||
return ExopackInventoryMenu::class.java
|
||||
}
|
||||
@ -31,24 +30,24 @@ class ExopackInventoryTransferHandler(private val helper: IRecipeTransferHandler
|
||||
return Optional.empty()
|
||||
}
|
||||
|
||||
override fun getRecipeType(): mezz.jei.api.recipe.RecipeType<RecipeHolder<CraftingRecipe>> {
|
||||
override fun getRecipeType(): mezz.jei.api.recipe.RecipeType<CraftingRecipe> {
|
||||
return RecipeTypes.CRAFTING
|
||||
}
|
||||
|
||||
override fun canHandle(container: ExopackInventoryMenu, recipe: RecipeHolder<CraftingRecipe>): Boolean {
|
||||
override fun canHandle(container: ExopackInventoryMenu, recipe: CraftingRecipe): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun getRecipeSlots(
|
||||
container: ExopackInventoryMenu,
|
||||
recipe: RecipeHolder<CraftingRecipe>
|
||||
recipe: CraftingRecipe
|
||||
): List<Slot> {
|
||||
return container.craftingSlots
|
||||
}
|
||||
|
||||
override fun getInventorySlots(
|
||||
container: ExopackInventoryMenu,
|
||||
recipe: RecipeHolder<CraftingRecipe>
|
||||
recipe: CraftingRecipe
|
||||
): List<Slot> {
|
||||
return container.playerInventorySlots
|
||||
}
|
||||
@ -62,7 +61,7 @@ class ExopackInventoryTransferHandler(private val helper: IRecipeTransferHandler
|
||||
return Optional.empty()
|
||||
}
|
||||
|
||||
override fun getRecipeType(): mezz.jei.api.recipe.RecipeType<RecipeHolder<CraftingRecipe>> {
|
||||
override fun getRecipeType(): mezz.jei.api.recipe.RecipeType<CraftingRecipe> {
|
||||
return RecipeTypes.CRAFTING
|
||||
}
|
||||
|
||||
@ -89,7 +88,7 @@ class ExopackInventoryTransferHandler(private val helper: IRecipeTransferHandler
|
||||
|
||||
override fun transferRecipe(
|
||||
container: ExopackInventoryMenu,
|
||||
recipe: RecipeHolder<CraftingRecipe>,
|
||||
recipe: CraftingRecipe,
|
||||
recipeSlots: IRecipeSlotsView,
|
||||
player: Player,
|
||||
maxTransfer: Boolean,
|
||||
|
@ -1,7 +1,8 @@
|
||||
package ru.dbotthepony.mc.otm.compat.jei
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack
|
||||
import mezz.jei.api.gui.drawable.IDrawable
|
||||
import net.minecraft.client.gui.GuiGraphics
|
||||
|
||||
import ru.dbotthepony.mc.otm.client.render.MGUIGraphics
|
||||
import ru.dbotthepony.mc.otm.client.render.IGUIRenderable
|
||||
|
||||
@ -14,7 +15,7 @@ class IGUIRenderable2IDrawable(val parent: IGUIRenderable) : IDrawable {
|
||||
return parent.height.toInt()
|
||||
}
|
||||
|
||||
override fun draw(guiGraphics: GuiGraphics, xOffset: Int, yOffset: Int) {
|
||||
parent.render(MGUIGraphics(guiGraphics), xOffset.toFloat(), yOffset.toFloat())
|
||||
override fun draw(stack: PoseStack, xOffset: Int, yOffset: Int) {
|
||||
parent.render(MGUIGraphics(stack), xOffset.toFloat(), yOffset.toFloat())
|
||||
}
|
||||
}
|
||||
|
@ -26,6 +26,8 @@ import ru.dbotthepony.mc.otm.core.collect.filter
|
||||
import ru.dbotthepony.mc.otm.core.collect.filterIsInstance
|
||||
import ru.dbotthepony.mc.otm.core.collect.map
|
||||
import ru.dbotthepony.mc.otm.core.collect.toList
|
||||
import ru.dbotthepony.mc.otm.core.filterNotNull
|
||||
import ru.dbotthepony.mc.otm.core.value
|
||||
import ru.dbotthepony.mc.otm.menu.decorative.PainterMenu
|
||||
import ru.dbotthepony.mc.otm.menu.matter.MatterEntanglerMenu
|
||||
import ru.dbotthepony.mc.otm.menu.tech.PlatePressMenu
|
||||
|
@ -1,5 +1,6 @@
|
||||
package ru.dbotthepony.mc.otm.compat.jei
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack
|
||||
import mezz.jei.api.gui.builder.IRecipeLayoutBuilder
|
||||
import mezz.jei.api.gui.drawable.IDrawable
|
||||
import mezz.jei.api.gui.ingredient.IRecipeSlotsView
|
||||
@ -7,7 +8,7 @@ import mezz.jei.api.recipe.IFocusGroup
|
||||
import mezz.jei.api.recipe.RecipeIngredientRole
|
||||
import mezz.jei.api.recipe.RecipeType
|
||||
import mezz.jei.api.recipe.category.IRecipeCategory
|
||||
import net.minecraft.client.gui.GuiGraphics
|
||||
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.world.item.ItemStack
|
||||
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
||||
@ -61,8 +62,8 @@ object MatterEntanglerRecipeCategory : IRecipeCategory<IMatterEntanglerRecipe>,
|
||||
builder.addSlot(RecipeIngredientRole.OUTPUT, 116, 18 + 4).addItemStack(recipe.result)
|
||||
}
|
||||
|
||||
override fun draw(guiGraphics: GuiGraphics, xOffset: Int, yOffset: Int) {
|
||||
val wrap = MGUIGraphics(guiGraphics)
|
||||
override fun draw(stack: PoseStack, xOffset: Int, yOffset: Int) {
|
||||
val wrap = MGUIGraphics(stack)
|
||||
|
||||
for (x in 0 until 3) {
|
||||
for (y in 0 until 3) {
|
||||
@ -74,8 +75,8 @@ object MatterEntanglerRecipeCategory : IRecipeCategory<IMatterEntanglerRecipe>,
|
||||
ProgressGaugePanel.GAUGE_BACKGROUND.render(wrap, xOffset + 89f, yOffset + 18f + 4f)
|
||||
}
|
||||
|
||||
override fun draw(recipe: IMatterEntanglerRecipe, recipeSlotsView: IRecipeSlotsView, guiGraphics: GuiGraphics, mouseX: Double, mouseY: Double) {
|
||||
val wrap = MGUIGraphics(guiGraphics)
|
||||
override fun draw(recipe: IMatterEntanglerRecipe, recipeSlotsView: IRecipeSlotsView, poseStack: PoseStack, mouseX: Double, mouseY: Double) {
|
||||
val wrap = MGUIGraphics(poseStack)
|
||||
|
||||
renderMatterGauge(wrap, 13f, 6f, drainSpeed = (recipe.matter / Decimal(300)).toFloat())
|
||||
renderEnergyGauge(wrap, 4f, 6f, drainSpeed = (recipe.ticks / 2000.0).toFloat())
|
||||
|
@ -1,5 +1,6 @@
|
||||
package ru.dbotthepony.mc.otm.compat.jei
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack
|
||||
import mezz.jei.api.gui.builder.IRecipeLayoutBuilder
|
||||
import mezz.jei.api.gui.drawable.IDrawable
|
||||
import mezz.jei.api.gui.ingredient.IRecipeSlotsView
|
||||
@ -7,14 +8,13 @@ import mezz.jei.api.recipe.IFocusGroup
|
||||
import mezz.jei.api.recipe.RecipeIngredientRole
|
||||
import mezz.jei.api.recipe.RecipeType
|
||||
import mezz.jei.api.recipe.category.IRecipeCategory
|
||||
import net.minecraft.client.gui.GuiGraphics
|
||||
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
import net.minecraft.world.item.ItemStack
|
||||
import net.minecraft.world.item.crafting.Ingredient
|
||||
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
||||
import ru.dbotthepony.mc.otm.client.render.MGUIGraphics
|
||||
import ru.dbotthepony.mc.otm.client.minecraft
|
||||
import ru.dbotthepony.mc.otm.client.render.RenderGravity
|
||||
import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel
|
||||
import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel
|
||||
@ -45,14 +45,14 @@ object MicrowaveRecipeCategory : IRecipeCategory<MicrowaveRecipe>, IDrawable {
|
||||
return MItems.POWERED_SMOKER[null]!!.description
|
||||
}
|
||||
|
||||
override fun draw(graphics: GuiGraphics, xOffset: Int, yOffset: Int) {
|
||||
override fun draw(stack: PoseStack, xOffset: Int, yOffset: Int) {
|
||||
@Suppress("name_shadowing")
|
||||
val xOffset = xOffset.toFloat()
|
||||
|
||||
@Suppress("name_shadowing")
|
||||
val yOffset = yOffset.toFloat()
|
||||
|
||||
val wrap = MGUIGraphics(graphics)
|
||||
val wrap = MGUIGraphics(stack)
|
||||
|
||||
AbstractSlotPanel.SLOT_BACKGROUND.render(wrap, X_INPUT + xOffset, Y_INPUT + yOffset)
|
||||
AbstractSlotPanel.SLOT_BACKGROUND.render(wrap, X_OUTPUT + xOffset, Y_OUTPUT + yOffset)
|
||||
@ -68,11 +68,11 @@ object MicrowaveRecipeCategory : IRecipeCategory<MicrowaveRecipe>, IDrawable {
|
||||
override fun draw(
|
||||
recipe: MicrowaveRecipe,
|
||||
recipeSlotsView: IRecipeSlotsView,
|
||||
graphics: GuiGraphics,
|
||||
poseStack: PoseStack,
|
||||
mouseX: Double,
|
||||
mouseY: Double
|
||||
) {
|
||||
val wrap = MGUIGraphics(graphics)
|
||||
val wrap = MGUIGraphics(poseStack)
|
||||
wrap.draw(TranslatableComponent("otm.gui.recipe.ticks", recipe.workTime), 40f, 30f, gravity = RenderGravity.TOP_CENTER, color = RGBAColor.BLACK)
|
||||
|
||||
val average = recipe.experience.toString()
|
||||
|
@ -1,5 +1,6 @@
|
||||
package ru.dbotthepony.mc.otm.compat.jei
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack
|
||||
import mezz.jei.api.constants.VanillaTypes
|
||||
import mezz.jei.api.gui.builder.IRecipeLayoutBuilder
|
||||
import mezz.jei.api.gui.drawable.IDrawable
|
||||
@ -7,7 +8,7 @@ import mezz.jei.api.recipe.IFocusGroup
|
||||
import mezz.jei.api.recipe.RecipeIngredientRole
|
||||
import mezz.jei.api.recipe.RecipeType
|
||||
import mezz.jei.api.recipe.category.IRecipeCategory
|
||||
import net.minecraft.client.gui.GuiGraphics
|
||||
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
import net.minecraft.world.item.ItemStack
|
||||
@ -71,8 +72,8 @@ object PainterRecipeCategory : IRecipeCategory<PainterRecipe>, IDrawable {
|
||||
builder.addSlot(RecipeIngredientRole.OUTPUT, 100, 22).addIngredients(VanillaTypes.ITEM_STACK, listOf(recipe.output))
|
||||
}
|
||||
|
||||
override fun draw(guiGraphics: GuiGraphics, xOffset: Int, yOffset: Int) {
|
||||
val wrap = MGUIGraphics(guiGraphics)
|
||||
override fun draw(stack: PoseStack, xOffset: Int, yOffset: Int) {
|
||||
val wrap = MGUIGraphics(stack)
|
||||
|
||||
for (x in 0 .. 1) {
|
||||
for (y in 0 .. 2) {
|
||||
|
@ -1,5 +1,6 @@
|
||||
package ru.dbotthepony.mc.otm.compat.jei
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack
|
||||
import mezz.jei.api.gui.builder.IRecipeLayoutBuilder
|
||||
import mezz.jei.api.gui.drawable.IDrawable
|
||||
import mezz.jei.api.gui.ingredient.IRecipeSlotsView
|
||||
@ -7,14 +8,13 @@ import mezz.jei.api.recipe.IFocusGroup
|
||||
import mezz.jei.api.recipe.RecipeIngredientRole
|
||||
import mezz.jei.api.recipe.RecipeType
|
||||
import mezz.jei.api.recipe.category.IRecipeCategory
|
||||
import net.minecraft.client.gui.GuiGraphics
|
||||
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
import net.minecraft.world.item.ItemStack
|
||||
import net.minecraft.world.item.crafting.Ingredient
|
||||
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
||||
import ru.dbotthepony.mc.otm.client.render.MGUIGraphics
|
||||
import ru.dbotthepony.mc.otm.client.minecraft
|
||||
import ru.dbotthepony.mc.otm.client.render.RenderGravity
|
||||
import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel
|
||||
import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel
|
||||
@ -45,14 +45,14 @@ object PlatePressRecipeCategory : IRecipeCategory<PlatePressRecipe>, IDrawable {
|
||||
return MItems.TWIN_PLATE_PRESS[null]!!.description
|
||||
}
|
||||
|
||||
override fun draw(graphics: GuiGraphics, xOffset: Int, yOffset: Int) {
|
||||
override fun draw(stack: PoseStack, xOffset: Int, yOffset: Int) {
|
||||
@Suppress("name_shadowing")
|
||||
val xOffset = xOffset.toFloat()
|
||||
|
||||
@Suppress("name_shadowing")
|
||||
val yOffset = yOffset.toFloat()
|
||||
|
||||
val wrap = MGUIGraphics(graphics)
|
||||
val wrap = MGUIGraphics(stack)
|
||||
|
||||
AbstractSlotPanel.SLOT_BACKGROUND.render(wrap, X_INPUT + xOffset, Y_INPUT + yOffset)
|
||||
AbstractSlotPanel.SLOT_BACKGROUND.render(wrap, X_OUTPUT + xOffset, Y_OUTPUT + yOffset)
|
||||
@ -68,11 +68,11 @@ object PlatePressRecipeCategory : IRecipeCategory<PlatePressRecipe>, IDrawable {
|
||||
override fun draw(
|
||||
recipe: PlatePressRecipe,
|
||||
recipeSlotsView: IRecipeSlotsView,
|
||||
graphics: GuiGraphics,
|
||||
stack: PoseStack,
|
||||
mouseX: Double,
|
||||
mouseY: Double
|
||||
) {
|
||||
val wrap = MGUIGraphics(graphics)
|
||||
val wrap = MGUIGraphics(stack)
|
||||
|
||||
wrap.draw(TranslatableComponent("otm.gui.recipe.ticks", recipe.workTime), 40f, 30f, gravity = RenderGravity.TOP_CENTER, color = RGBAColor.BLACK)
|
||||
|
||||
|
@ -1,24 +1,118 @@
|
||||
package ru.dbotthepony.mc.otm.container
|
||||
|
||||
import net.minecraft.nbt.CompoundTag
|
||||
import net.minecraft.nbt.Tag
|
||||
import net.minecraft.world.Container
|
||||
import net.minecraft.world.entity.player.Player
|
||||
import net.minecraft.world.entity.player.StackedContents
|
||||
import net.minecraft.world.inventory.AbstractContainerMenu
|
||||
import net.minecraft.world.inventory.CraftingContainer
|
||||
import net.minecraft.world.item.Item
|
||||
import net.minecraft.world.item.ItemStack
|
||||
import net.minecraftforge.common.util.INBTSerializable
|
||||
import java.util.function.Predicate
|
||||
|
||||
open class MatteryCraftingContainer(listener: ContainerListener, private val width: Int, private val height: Int) : MatteryContainer(listener, width * height), CraftingContainer {
|
||||
constructor(listener: () -> Unit, width: Int, height: Int) : this({ _, _, _ -> listener.invoke() }, width, height)
|
||||
constructor(width: Int, height: Int) : this(EmptyListener, width, height)
|
||||
|
||||
final override fun getWidth(): Int {
|
||||
return width
|
||||
object DummyMenu : AbstractContainerMenu(null, 0) {
|
||||
override fun quickMoveStack(pPlayer: Player, pIndex: Int): ItemStack {
|
||||
return ItemStack.EMPTY
|
||||
}
|
||||
|
||||
final override fun getHeight(): Int {
|
||||
return height
|
||||
}
|
||||
|
||||
final override fun getItems(): MutableList<ItemStack> {
|
||||
val i = spliterator()
|
||||
val result = ArrayList<ItemStack>(i.estimateSize().toInt())
|
||||
i.forEachRemaining { result.add(it) }
|
||||
return result
|
||||
override fun stillValid(pPlayer: Player): Boolean {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// урод
|
||||
open class MatteryCraftingContainer private constructor(private val listener: MatteryContainer.ContainerListener, width: Int, height: Int, private val parent: MatteryContainer) : CraftingContainer(DummyMenu, width, height), IMatteryContainer by parent, INBTSerializable<CompoundTag?> {
|
||||
constructor(width: Int, height: Int) : this(MatteryContainer.EmptyListener, width, height)
|
||||
constructor(listener: () -> Unit, width: Int, height: Int) : this({ _, _, _ -> listener.invoke() }, width, height, MatteryContainer(width * height))
|
||||
constructor(listener: MatteryContainer.ContainerListener, width: Int, height: Int) : this(listener, width, height, MatteryContainer(width * height))
|
||||
|
||||
init {
|
||||
parent.listener = MatteryContainer.ContainerListener { slot, new, old -> this@MatteryCraftingContainer.setChanged(slot, new, old) }
|
||||
}
|
||||
|
||||
protected open fun setChanged(slot: Int, new: ItemStack, old: ItemStack) {
|
||||
listener.setChanged(slot, new, old)
|
||||
}
|
||||
|
||||
override fun serializeNBT(): CompoundTag {
|
||||
return parent.serializeNBT()
|
||||
}
|
||||
|
||||
override fun deserializeNBT(nbt: CompoundTag?) {
|
||||
parent.deserializeNBT(nbt)
|
||||
}
|
||||
|
||||
override fun clearContent() {
|
||||
parent.clearContent()
|
||||
}
|
||||
|
||||
override fun getContainerSize(): Int {
|
||||
return parent.getContainerSize()
|
||||
}
|
||||
|
||||
override fun isEmpty(): Boolean {
|
||||
return parent.isEmpty()
|
||||
}
|
||||
|
||||
override fun getItem(p_39332_: Int): ItemStack {
|
||||
return parent.getItem(p_39332_)
|
||||
}
|
||||
|
||||
override fun removeItem(p_39334_: Int, p_39335_: Int): ItemStack {
|
||||
return parent.removeItem(p_39334_, p_39335_)
|
||||
}
|
||||
|
||||
override fun removeItemNoUpdate(p_39344_: Int): ItemStack {
|
||||
return parent.removeItemNoUpdate(p_39344_)
|
||||
}
|
||||
|
||||
override fun setItem(p_39337_: Int, p_39338_: ItemStack) {
|
||||
parent.setItem(p_39337_, p_39338_)
|
||||
}
|
||||
|
||||
override fun setChanged() {
|
||||
parent.setChanged()
|
||||
}
|
||||
|
||||
override fun stillValid(p_39340_: Player): Boolean {
|
||||
return parent.stillValid(p_39340_)
|
||||
}
|
||||
|
||||
override fun fillStackedContents(p_39342_: StackedContents) {
|
||||
parent.fillStackedContents(p_39342_)
|
||||
}
|
||||
|
||||
override fun getMaxStackSize(): Int {
|
||||
return parent.getMaxStackSize()
|
||||
}
|
||||
|
||||
override fun startOpen(p_18955_: Player) {
|
||||
parent.startOpen(p_18955_)
|
||||
}
|
||||
|
||||
override fun stopOpen(p_18954_: Player) {
|
||||
parent.stopOpen(p_18954_)
|
||||
}
|
||||
|
||||
override fun canPlaceItem(p_18952_: Int, p_18953_: ItemStack): Boolean {
|
||||
return parent.canPlaceItem(p_18952_, p_18953_)
|
||||
}
|
||||
|
||||
override fun canTakeItem(p_273520_: Container, p_272681_: Int, p_273702_: ItemStack): Boolean {
|
||||
return parent.canTakeItem(p_273520_, p_272681_, p_273702_)
|
||||
}
|
||||
|
||||
override fun countItem(p_18948_: Item): Int {
|
||||
return parent.countItem(p_18948_)
|
||||
}
|
||||
|
||||
override fun hasAnyOf(p_18950_: Set<Item>): Boolean {
|
||||
return parent.hasAnyOf(p_18950_)
|
||||
}
|
||||
|
||||
override fun hasAnyMatching(p_216875_: Predicate<ItemStack>): Boolean {
|
||||
return parent.hasAnyMatching(p_216875_)
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,15 @@
|
||||
package ru.dbotthepony.mc.otm.container
|
||||
|
||||
import net.minecraft.world.entity.player.Player
|
||||
import net.minecraft.world.entity.player.StackedContents
|
||||
import net.minecraft.world.inventory.CraftingContainer
|
||||
import net.minecraft.world.item.ItemStack
|
||||
import ru.dbotthepony.mc.otm.container.util.iterator
|
||||
import ru.dbotthepony.mc.otm.core.collect.toList
|
||||
|
||||
class ShadowCraftingContainer(private val parent: CraftingContainer) : IContainer by ShadowContainer(parent), CraftingContainer {
|
||||
class ShadowCraftingContainer private constructor(private val parent: CraftingContainer, private val shadow: ShadowContainer) : CraftingContainer(DummyMenu, parent.width, parent.height), IContainer by shadow {
|
||||
constructor(parent: CraftingContainer) : this(parent, ShadowContainer(parent))
|
||||
|
||||
override fun fillStackedContents(contents: StackedContents) {
|
||||
for (item in iterator()) {
|
||||
contents.accountStack(item)
|
||||
@ -21,8 +24,40 @@ class ShadowCraftingContainer(private val parent: CraftingContainer) : IContaine
|
||||
return parent.height
|
||||
}
|
||||
|
||||
override fun getItems(): MutableList<ItemStack> {
|
||||
return iterator().toList()
|
||||
override fun clearContent() {
|
||||
shadow.clearContent()
|
||||
}
|
||||
|
||||
override fun getContainerSize(): Int {
|
||||
return shadow.getContainerSize()
|
||||
}
|
||||
|
||||
override fun isEmpty(): Boolean {
|
||||
return shadow.isEmpty()
|
||||
}
|
||||
|
||||
override fun getItem(p_39332_: Int): ItemStack {
|
||||
return shadow.getItem(p_39332_)
|
||||
}
|
||||
|
||||
override fun removeItem(p_39334_: Int, p_39335_: Int): ItemStack {
|
||||
return shadow.removeItem(p_39334_, p_39335_)
|
||||
}
|
||||
|
||||
override fun removeItemNoUpdate(p_39344_: Int): ItemStack {
|
||||
return shadow.removeItemNoUpdate(p_39344_)
|
||||
}
|
||||
|
||||
override fun setItem(p_39337_: Int, p_39338_: ItemStack) {
|
||||
shadow.setItem(p_39337_, p_39338_)
|
||||
}
|
||||
|
||||
override fun setChanged() {
|
||||
shadow.setChanged()
|
||||
}
|
||||
|
||||
override fun stillValid(p_39340_: Player): Boolean {
|
||||
return shadow.stillValid(p_39340_)
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
@ -20,11 +20,13 @@ import net.minecraft.network.FriendlyByteBuf
|
||||
import net.minecraft.network.chat.ComponentContents
|
||||
import net.minecraft.network.chat.contents.TranslatableContents
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
import net.minecraft.world.Container
|
||||
import net.minecraft.world.entity.Entity
|
||||
import net.minecraft.world.item.Item
|
||||
import net.minecraft.world.item.ItemStack
|
||||
import net.minecraft.world.item.Items
|
||||
import net.minecraft.world.item.crafting.Ingredient
|
||||
import net.minecraft.world.item.crafting.Recipe
|
||||
import net.minecraft.world.level.BlockGetter
|
||||
import net.minecraft.world.level.Level
|
||||
import net.minecraft.world.level.LevelAccessor
|
||||
@ -33,6 +35,8 @@ import net.minecraft.world.level.block.Blocks
|
||||
import net.minecraft.world.level.block.state.BlockState
|
||||
import net.minecraft.world.level.block.state.StateHolder
|
||||
import net.minecraft.world.level.block.state.properties.Property
|
||||
import net.minecraft.world.level.saveddata.SavedData
|
||||
import net.minecraft.world.level.storage.DimensionDataStorage
|
||||
import net.minecraft.world.phys.Vec3
|
||||
import net.minecraftforge.common.ForgeHooks
|
||||
import net.minecraftforge.common.util.LazyOptional
|
||||
@ -67,6 +71,7 @@ import java.util.UUID
|
||||
import java.util.concurrent.Callable
|
||||
import java.util.concurrent.Future
|
||||
import java.util.function.Consumer
|
||||
import java.util.function.Function
|
||||
import java.util.function.Supplier
|
||||
import java.util.stream.Stream
|
||||
import java.util.stream.StreamSupport
|
||||
@ -516,3 +521,4 @@ fun <A, B> lazy2(a: () -> A, b: A.() -> B): Supplier<B> {
|
||||
return Supplier { b.invoke(first.value) }
|
||||
}
|
||||
|
||||
inline val <R : Recipe<T>, T : Container> R.value get() = this
|
||||
|
@ -117,7 +117,7 @@ fun CompoundTag.putJson(key: String, json: JsonElement) {
|
||||
putByteArray(key, bytes.array.copyOfRange(0, bytes.length))
|
||||
}
|
||||
|
||||
fun CompoundTag.getJson(key: String, sizeLimit: NbtAccounter = NbtAccounter(1 shl 18, 512)): JsonElement? {
|
||||
fun CompoundTag.getJson(key: String, sizeLimit: NbtAccounter = NbtAccounter(1 shl 18)): JsonElement? {
|
||||
val bytes = getByteArray(key)
|
||||
|
||||
if (bytes.isEmpty())
|
||||
|
@ -56,7 +56,7 @@ object CreativeMenuItemComparator : Comparator<Item> {
|
||||
if (item2index.isEmpty()) {
|
||||
val player = minecraft.player ?: return
|
||||
// creative tabs were not populated yet
|
||||
CreativeModeTabs.tryRebuildTabContents(player.connection.enabledFeatures(), false /* operator tabs */, player.level().registryAccess())
|
||||
CreativeModeTabs.tryRebuildTabContents(player.connection.enabledFeatures(), false /* operator tabs */, player.level.registryAccess())
|
||||
|
||||
doRebuild()
|
||||
}
|
||||
|
@ -8,9 +8,7 @@ import com.mojang.serialization.Codec
|
||||
import com.mojang.serialization.DataResult
|
||||
import com.mojang.serialization.DynamicOps
|
||||
import com.mojang.serialization.JsonOps
|
||||
import io.netty.buffer.ByteBuf
|
||||
import io.netty.buffer.Unpooled
|
||||
import net.minecraft.advancements.AdvancementHolder
|
||||
import net.minecraft.data.recipes.FinishedRecipe
|
||||
import net.minecraft.network.FriendlyByteBuf
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
@ -24,15 +22,7 @@ import ru.dbotthepony.mc.otm.core.util.readBinaryJsonWithCodecIndirect
|
||||
import ru.dbotthepony.mc.otm.core.util.writeBinaryJsonWithCodec
|
||||
import kotlin.collections.ArrayDeque
|
||||
import kotlin.concurrent.getOrSet
|
||||
import kotlin.reflect.KProperty
|
||||
|
||||
/**
|
||||
* 1.20.2: Mojang FINALLY moved json IO of recipes to codecs
|
||||
*
|
||||
* ...but they forgot to do the same for Networking them, Ingredient does not have codec for network.
|
||||
*
|
||||
* Mojang.... Mojang never changes.
|
||||
*/
|
||||
class Codec2RecipeSerializer<S : Recipe<*>>(
|
||||
val empty: S?,
|
||||
codec: (Codec2RecipeSerializer<S>.Context) -> Codec<S>,
|
||||
@ -40,45 +30,18 @@ class Codec2RecipeSerializer<S : Recipe<*>>(
|
||||
constructor(supplier: (Codec2RecipeSerializer<S>.Context) -> Codec<S>) : this(null, supplier)
|
||||
|
||||
private class CurrentContext {
|
||||
val idStack = ArrayDeque<ResourceLocation>()
|
||||
var isNetwork = 0
|
||||
}
|
||||
|
||||
inner class Context {
|
||||
val id: ResourceLocation
|
||||
get() = checkNotNull(context.idStack.lastOrNull()) { "Not currently deserializing recipe" }
|
||||
|
||||
val ingredients: Codec<Ingredient> get() = ActualIngredientCodec
|
||||
|
||||
fun <P : Recipe<*>> wrap(serializer: RecipeSerializer<P>): Codec<P> {
|
||||
return object : Codec<P> {
|
||||
override fun <T : Any?> encode(input: P, ops: DynamicOps<T>, prefix: T): DataResult<T> {
|
||||
if (context.isNetwork > 0) {
|
||||
val parent = Unpooled.buffer()
|
||||
val buff = FriendlyByteBuf(parent)
|
||||
serializer.toNetwork(buff, input)
|
||||
return DataResult.success(ops.createByteList(parent.nioBuffer()))
|
||||
} else {
|
||||
return serializer.codec().encode(input, ops, prefix)
|
||||
}
|
||||
}
|
||||
|
||||
override fun <T : Any?> decode(ops: DynamicOps<T>, input: T): DataResult<Pair<P, T>> {
|
||||
if (context.isNetwork > 0) {
|
||||
return ops.getByteBuffer(input).flatMap {
|
||||
val parent = Unpooled.buffer()
|
||||
val buff = FriendlyByteBuf(parent)
|
||||
parent.writeBytes(it)
|
||||
parent.setIndex(0, 0)
|
||||
val read = serializer.fromNetwork(buff)
|
||||
|
||||
if (read == null)
|
||||
DataResult.error { "Unable to read parent recipe from network" }
|
||||
else
|
||||
DataResult.success(Pair(read, ops.empty()))
|
||||
}
|
||||
} else {
|
||||
return serializer.codec().decode(ops, input)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
val isNetwork: Boolean
|
||||
get() = context.isNetwork > 0
|
||||
}
|
||||
|
||||
private val codec = codec.invoke(Context())
|
||||
@ -97,30 +60,45 @@ class Codec2RecipeSerializer<S : Recipe<*>>(
|
||||
}
|
||||
}
|
||||
|
||||
override fun codec(): Codec<S> {
|
||||
return this
|
||||
override fun fromJson(id: ResourceLocation, data: JsonObject): S {
|
||||
try {
|
||||
context.idStack.addLast(id)
|
||||
|
||||
return decode(JsonOps.INSTANCE, data).get().map(
|
||||
{ it.first },
|
||||
{ empty ?: throw JsonSyntaxException("Failed to deserialize recipe from JSON: ${it.message()}") }
|
||||
)
|
||||
} finally {
|
||||
context.idStack.removeLast()
|
||||
}
|
||||
}
|
||||
|
||||
override fun fromNetwork(data: FriendlyByteBuf): S? {
|
||||
override fun fromNetwork(id: ResourceLocation, data: FriendlyByteBuf): S? {
|
||||
try {
|
||||
context.idStack.addLast(id)
|
||||
context.isNetwork++
|
||||
|
||||
return data.readBinaryJsonWithCodecIndirect(this)
|
||||
.resultOrPartial { LOGGER.error("Failed to read recipe from network: $it") }.orElse(null)
|
||||
.resultOrPartial { LOGGER.error("Failed to read recipe $id from network: $it") }.orElse(null)
|
||||
} finally {
|
||||
context.isNetwork--
|
||||
context.idStack.removeLast()
|
||||
}
|
||||
}
|
||||
|
||||
override fun toNetwork(data: FriendlyByteBuf, recipe: S) {
|
||||
try {
|
||||
context.idStack.addLast(recipe.id)
|
||||
context.isNetwork++
|
||||
|
||||
data.writeBinaryJsonWithCodec(this, recipe)
|
||||
} finally {
|
||||
context.isNetwork--
|
||||
context.idStack.removeLast()
|
||||
}
|
||||
}
|
||||
|
||||
fun toFinished(recipe: S, id: ResourceLocation): FinishedRecipe {
|
||||
fun toFinished(recipe: S): FinishedRecipe {
|
||||
return object : FinishedRecipe {
|
||||
override fun serializeRecipeData(p_125967_: JsonObject) {
|
||||
encode(recipe, JsonOps.INSTANCE, p_125967_).get().map(
|
||||
@ -137,15 +115,19 @@ class Codec2RecipeSerializer<S : Recipe<*>>(
|
||||
)
|
||||
}
|
||||
|
||||
override fun id(): ResourceLocation {
|
||||
return id
|
||||
override fun getId(): ResourceLocation {
|
||||
return recipe.id
|
||||
}
|
||||
|
||||
override fun type(): RecipeSerializer<*> {
|
||||
override fun getType(): RecipeSerializer<*> {
|
||||
return this@Codec2RecipeSerializer
|
||||
}
|
||||
|
||||
override fun advancement(): AdvancementHolder? {
|
||||
override fun serializeAdvancement(): JsonObject? {
|
||||
return null
|
||||
}
|
||||
|
||||
override fun getAdvancementId(): ResourceLocation? {
|
||||
return null
|
||||
}
|
||||
}
|
||||
@ -156,7 +138,7 @@ class Codec2RecipeSerializer<S : Recipe<*>>(
|
||||
return if (context.isNetwork > 0) {
|
||||
networkIngredientCodec.encode(input, ops, prefix)
|
||||
} else {
|
||||
Ingredient.CODEC.encode(input, ops, prefix)
|
||||
IngredientCodec.encode(input, ops, prefix)
|
||||
}
|
||||
}
|
||||
|
||||
@ -164,7 +146,7 @@ class Codec2RecipeSerializer<S : Recipe<*>>(
|
||||
return if (context.isNetwork > 0) {
|
||||
networkIngredientCodec.decode(ops, input)
|
||||
} else {
|
||||
Ingredient.CODEC.decode(ops, input)
|
||||
IngredientCodec.decode(ops, input)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -178,14 +160,8 @@ class Codec2RecipeSerializer<S : Recipe<*>>(
|
||||
* since RecipeSerializers are expected to be stateless. [Codec2RecipeSerializer], however, is stateful (threading PoV).
|
||||
* To make it stateless, [ThreadLocal] is used.
|
||||
*/
|
||||
private val context by object : ThreadLocal<CurrentContext>() {
|
||||
override fun initialValue(): CurrentContext {
|
||||
return CurrentContext()
|
||||
}
|
||||
}
|
||||
private val contextHolder = ThreadLocal<CurrentContext>()
|
||||
private val context: CurrentContext
|
||||
get() = contextHolder.getOrSet { CurrentContext() }
|
||||
}
|
||||
}
|
||||
|
||||
private operator fun <T> ThreadLocal<T>.getValue(companion: Codec2RecipeSerializer.Companion, property: KProperty<*>): T {
|
||||
return get()
|
||||
}
|
||||
|
@ -0,0 +1,38 @@
|
||||
package ru.dbotthepony.mc.otm.data
|
||||
|
||||
import com.google.gson.JsonDeserializationContext
|
||||
import com.google.gson.JsonNull
|
||||
import com.google.gson.JsonObject
|
||||
import com.google.gson.JsonSerializationContext
|
||||
import com.google.gson.JsonSyntaxException
|
||||
import com.mojang.serialization.Codec
|
||||
import net.minecraft.world.level.storage.loot.Serializer
|
||||
import ru.dbotthepony.mc.otm.core.fromJsonStrict
|
||||
import ru.dbotthepony.mc.otm.core.set
|
||||
import ru.dbotthepony.mc.otm.core.toJsonStrict
|
||||
|
||||
class Codec2Serializer<T : Any>(val codec: Codec<T>, val embed: Boolean = false) : Serializer<T> {
|
||||
override fun serialize(data: JsonObject, value: T, context: JsonSerializationContext) {
|
||||
if (embed) {
|
||||
val result = codec.toJsonStrict(value, data)
|
||||
|
||||
if (result !is JsonObject) {
|
||||
throw RuntimeException("Expected JsonObject from codec, got ${result::class.qualifiedName}")
|
||||
}
|
||||
|
||||
val keys = ArrayList(data.keySet())
|
||||
for (k in keys) data.remove(k)
|
||||
for ((k, v) in result.entrySet()) data[k] = v
|
||||
} else {
|
||||
data["value"] = codec.toJsonStrict(value)
|
||||
}
|
||||
}
|
||||
|
||||
override fun deserialize(data: JsonObject, context: JsonDeserializationContext): T {
|
||||
if (embed) {
|
||||
return codec.fromJsonStrict(data)
|
||||
} else {
|
||||
return codec.fromJsonStrict(data["value"] ?: JsonNull.INSTANCE)
|
||||
}
|
||||
}
|
||||
}
|
@ -1,29 +1,48 @@
|
||||
package ru.dbotthepony.mc.otm.data
|
||||
|
||||
import com.mojang.serialization.Codec
|
||||
import com.mojang.serialization.DataResult
|
||||
import com.mojang.serialization.Dynamic
|
||||
import com.mojang.serialization.DynamicOps
|
||||
import com.mojang.serialization.JsonOps
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder
|
||||
import net.minecraft.advancements.critereon.DamagePredicate
|
||||
import net.minecraft.advancements.critereon.DamageSourcePredicate
|
||||
import net.minecraft.advancements.critereon.EntityPredicate
|
||||
import net.minecraft.advancements.critereon.MinMaxBounds
|
||||
import java.util.Optional
|
||||
import kotlin.reflect.KProperty1
|
||||
|
||||
val DoublesCodec: Codec<MinMaxBounds.Doubles> = RecordCodecBuilder.create {
|
||||
it.group(
|
||||
Codec.DOUBLE.optionalFieldOf("min").forGetter { Optional.ofNullable(it.min) },
|
||||
Codec.DOUBLE.optionalFieldOf("max").forGetter { Optional.ofNullable(it.max) },
|
||||
).apply(it) { min, max ->
|
||||
if (min.isEmpty && max.isEmpty)
|
||||
MinMaxBounds.Doubles.ANY
|
||||
else if (min.isEmpty)
|
||||
MinMaxBounds.Doubles.atMost(max.get())
|
||||
else if (max.isEmpty)
|
||||
MinMaxBounds.Doubles.atLeast(min.get())
|
||||
else
|
||||
MinMaxBounds.Doubles.between(min.get(), max.get())
|
||||
}
|
||||
}
|
||||
|
||||
private val dealtReceived: Codec<Pair<MinMaxBounds.Doubles, MinMaxBounds.Doubles>> = RecordCodecBuilder.create {
|
||||
it.group(
|
||||
MinMaxBounds.Doubles.CODEC.fieldOf("dealt").forGetter { it.first },
|
||||
MinMaxBounds.Doubles.CODEC.fieldOf("taken").forGetter { it.second },
|
||||
DoublesCodec.fieldOf("dealt").forGetter { it.first },
|
||||
DoublesCodec.fieldOf("taken").forGetter { it.second },
|
||||
).apply(it, ::Pair)
|
||||
}
|
||||
|
||||
val DamagePredicateCodec: Codec<DamagePredicate> = RecordCodecBuilder.create {
|
||||
it.group(
|
||||
dealtReceived.fieldOf("damage").forGetter { it.dealtDamage to it.takenDamage },
|
||||
Codec.BOOL.optionalFieldOf("blocked").forGetter { it.blocked },
|
||||
EntityPredicate.CODEC.optionalFieldOf("source_entity").forGetter { it.sourceEntity },
|
||||
DamageSourcePredicate.CODEC.optionalFieldOf("type").forGetter { it.type },
|
||||
).apply(it) { damage, blocked, source, type -> DamagePredicate(damage.first, damage.second, source, blocked, type) }
|
||||
Codec.BOOL.optionalFieldOf("blocked").forGetter { Optional.ofNullable(it.blocked) },
|
||||
Codec.PASSTHROUGH.xmap({ EntityPredicate.fromJson(it.cast(JsonOps.INSTANCE)) }, { Dynamic(JsonOps.INSTANCE, it.serializeToJson()) }).fieldOf("source_entity").forGetter { it.sourceEntity },
|
||||
Codec.PASSTHROUGH.xmap({ DamageSourcePredicate.fromJson(it.cast(JsonOps.INSTANCE)) }, { Dynamic(JsonOps.INSTANCE, it.serializeToJson()) }).fieldOf("type").forGetter { it.type },
|
||||
).apply(it) { damage, blocked, source, type -> DamagePredicate(damage.first, damage.second, source, blocked.orElse(null), type) }
|
||||
}
|
||||
|
||||
fun <V, T1> simpleCodec(factory: (T1) -> V, field1: KProperty1<V, T1>, codec1: Codec<T1>): Codec<V> {
|
||||
|
@ -0,0 +1,23 @@
|
||||
package ru.dbotthepony.mc.otm.data
|
||||
|
||||
import com.google.gson.JsonSyntaxException
|
||||
import com.mojang.datafixers.util.Pair
|
||||
import com.mojang.serialization.Codec
|
||||
import com.mojang.serialization.DataResult
|
||||
import com.mojang.serialization.DynamicOps
|
||||
import com.mojang.serialization.JsonOps
|
||||
import net.minecraft.world.item.crafting.Ingredient
|
||||
|
||||
object IngredientCodec : Codec<Ingredient> {
|
||||
override fun <T : Any> encode(input: Ingredient, ops: DynamicOps<T>, prefix: T): DataResult<T> {
|
||||
return DataResult.success(JsonOps.INSTANCE.convertTo(ops, input.toJson()))
|
||||
}
|
||||
|
||||
override fun <T : Any> decode(ops: DynamicOps<T>, input: T): DataResult<Pair<Ingredient, T>> {
|
||||
try {
|
||||
return DataResult.success(Pair(Ingredient.fromJson(ops.convertTo(JsonOps.INSTANCE, input)), ops.empty()))
|
||||
} catch (err: JsonSyntaxException) {
|
||||
return DataResult.error { "Error decoding Ingredient: ${err.message}" }
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package ru.dbotthepony.mc.otm.data
|
||||
|
||||
import com.google.gson.JsonObject
|
||||
import com.google.gson.JsonParseException
|
||||
import com.google.gson.JsonSyntaxException
|
||||
import com.mojang.datafixers.util.Pair
|
||||
import com.mojang.serialization.Codec
|
||||
import com.mojang.serialization.DataResult
|
||||
import com.mojang.serialization.DynamicOps
|
||||
import com.mojang.serialization.JsonOps
|
||||
import net.minecraft.advancements.critereon.ItemPredicate
|
||||
|
||||
object ItemPredicateCodec : Codec<ItemPredicate> {
|
||||
override fun <T : Any> encode(input: ItemPredicate, ops: DynamicOps<T>, prefix: T): DataResult<T> {
|
||||
return DataResult.success(JsonOps.INSTANCE.convertTo(ops, input.serializeToJson().let { if (it is JsonObject) it.getRidOfNulls() else it }))
|
||||
}
|
||||
|
||||
override fun <T : Any> decode(ops: DynamicOps<T>, input: T): DataResult<Pair<ItemPredicate, T>> {
|
||||
return try {
|
||||
DataResult.success(Pair(ItemPredicate.fromJson(ops.convertTo(JsonOps.INSTANCE, input)), ops.empty()))
|
||||
} catch (err: JsonSyntaxException) {
|
||||
DataResult.error { "Failed to deserialize ItemPredicate: ${err.message}" }
|
||||
} catch (err: JsonParseException) {
|
||||
DataResult.error { "Failed to deserialize ItemPredicate: ${err.message}" }
|
||||
}
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user