Compare commits
213 Commits
Author | SHA1 | Date | |
---|---|---|---|
29daea9bce | |||
ecb8a8ecd0 | |||
c83476225d | |||
69172b58e6 | |||
f0846a7b3a | |||
f8277e55c3 | |||
57c1644ccc | |||
e9f4b22cb8 | |||
49dd781a82 | |||
eeb5d3ba73 | |||
0f355150a2 | |||
baeef3816f | |||
9264e24c42 | |||
65dbeeeb4f | |||
f6138671d2 | |||
34b60be434 | |||
6153c2e972 | |||
0b91f54863 | |||
5fde1376b9 | |||
b6ef6c5e8e | |||
376e548cec | |||
2e427f05b1 | |||
5829dc8e5a | |||
653ecedafb | |||
53b9a7ec02 | |||
5f6fb9c731 | |||
87e64a102a | |||
0b7e54b4ef | |||
f0dba4ccc3 | |||
b4c4410432 | |||
5eb78b6e9c | |||
b35dfaeacd | |||
b4ae0bb6ae | |||
6e143e072d | |||
6a2eb3dec2 | |||
4d26cffbc8 | |||
410ba675ea | |||
ce94d22212 | |||
d9b18ddaa6 | |||
fccf97c4c8 | |||
21b84651a8 | |||
c3373bca30 | |||
55c975f1e8 | |||
80917f7d12 | |||
c652f8d6d4 | |||
07bc48887e | |||
12b10ee6fe | |||
46bc642385 | |||
9e72d73bfd | |||
a88549f17f | |||
5552be70d5 | |||
c210e9f842 | |||
d29f68fc4e | |||
cb386d39f5 | |||
55e6a4cb19 | |||
6bbe2f2750 | |||
22c3c22081 | |||
d38df3d927 | |||
562e6c509f | |||
0da77bc453 | |||
5645d5f56f | |||
4a606b8d36 | |||
f2aade3a8e | |||
46820a311f | |||
abd6a93fd4 | |||
19b4942c90 | |||
3743a3402d | |||
c17e0aac04 | |||
d88801d8bf | |||
055b9cc489 | |||
241f13914d | |||
f1df27d5d7 | |||
640f62d63b | |||
44183a45a8 | |||
c88023470f | |||
d3423a6160 | |||
55c0be74d3 | |||
667dcf6b58 | |||
a59fe8c256 | |||
9d9b19da9d | |||
eb460d04ec | |||
6dce3a37e6 | |||
652acf3ce1 | |||
9dbf40f170 | |||
6eb3700f88 | |||
101e57756a | |||
f165c0fbdc | |||
0695f613d3 | |||
67dbcde6dc | |||
1967373a9d | |||
04ce837b02 | |||
b4c994f02f | |||
a1f29021c6 | |||
ef997ca1fe | |||
8007c1757e | |||
f3f8155027 | |||
7e6a150ab7 | |||
8aafa38c27 | |||
8097551fd3 | |||
cc164f669d | |||
e51ba7015a | |||
9fe99e92f7 | |||
ee624f1b3f | |||
1d0e24095a | |||
8f8fd8c8de | |||
2b884739f4 | |||
a7d405b5ea | |||
dd331e0881 | |||
a4b3d2ba8a | |||
74183f0982 | |||
8ee5e94a78 | |||
d10ce72a0e | |||
cae867cb4d | |||
76c4c3e6a2 | |||
a68c08ecf8 | |||
f9dcf43cc4 | |||
42fe77e6b4 | |||
0f14c3eaa0 | |||
9e9c4168d6 | |||
bc59853f4e | |||
9b80162a03 | |||
b28e180704 | |||
2deaef94aa | |||
2ae5166a01 | |||
cac468685e | |||
78ac178526 | |||
37ce7343d4 | |||
0944e55141 | |||
c98562f2cb | |||
92f2680feb | |||
783c2bde34 | |||
b8f98f0e9e | |||
077e82064b | |||
cae417b3b4 | |||
8d42686cc5 | |||
62cc823e29 | |||
c821fa76a6 | |||
57cc9730f8 | |||
1d68f32b19 | |||
6b6f9f8062 | |||
6e4bf4e7ec | |||
ae544e8844 | |||
3819e5c49b | |||
d96a0e1a63 | |||
5b45cf7d0a | |||
ea448788c5 | |||
37e7f42587 | |||
34a9bfd48a | |||
7f15ae6a3a | |||
edea36a8a6 | |||
20469a14dd | |||
8a891e6ffb | |||
ad76b4cabc | |||
9cf66e443e | |||
2506f0fe0e | |||
2aa084290b | |||
b9f6b65900 | |||
41ce2841b1 | |||
a5ba27cf63 | |||
7b415fbce3 | |||
2a117a540e | |||
df15bd2f69 | |||
3dab053420 | |||
7258e1e4d3 | |||
34ef50f6ee | |||
4c5c2362ce | |||
0a5ae54614 | |||
45dd3e5c4b | |||
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,19 +150,18 @@ 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}"))
|
||||
compileOnly(fg.deobf("mezz.jei:jei-${jei_mc_version}-forge-api:${jei_version}"))
|
||||
runtimeOnly(fg.deobf("mezz.jei:jei-${jei_mc_version}-forge:${jei_version}"))
|
||||
// runtimeOnly(fg.deobf("mezz.jei:jei-${jei_mc_version}-forge:${jei_version}"))
|
||||
|
||||
// runtimeOnly(fg.deobf("ru.dbotthepony:particle-collider:0.4.5"))
|
||||
|
||||
@ -173,7 +172,7 @@ dependencies {
|
||||
compileOnly(fg.deobf("curse.maven:resourceful-config-714059:${resourceful_config_id}"))
|
||||
compileOnly(fg.deobf("curse.maven:botarium-704113:${botarium_id}"))
|
||||
compileOnly(fg.deobf("curse.maven:ad-astra-635042:${ad_astra_id}"))
|
||||
runtimeOnly(fg.deobf("curse.maven:worldedit-225608:${worldedit_id}"))
|
||||
// runtimeOnly(fg.deobf("curse.maven:worldedit-225608:${worldedit_id}"))
|
||||
|
||||
// runtimeOnly(fg.deobf("curse.maven:worldedit-225608:${worldedit_fileid}"))
|
||||
// runtimeOnly(fg.deobf("at.ridgo8.moreoverlays:MoreOverlays-updated:${more_overlays_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.3
|
||||
jei_mc_version=1.19.3
|
||||
curios_mc_version=1.19.3
|
||||
|
||||
forge_gradle_version=[6.0.14,6.2)
|
||||
forge_version=48.1.0
|
||||
forge_version=44.1.23
|
||||
mixingradle_version=0.7.33
|
||||
mixin_version=0.8.5
|
||||
|
||||
kommons_version=3.0.2
|
||||
|
||||
jei_version=16.0.0.28
|
||||
jei_version=12.4.0.22
|
||||
jupiter_version=5.9.2
|
||||
curios_version=6.0.2
|
||||
cosmetic_armor_reworked_id=4764779
|
||||
ad_astra_id=4594155
|
||||
botarium_id=4594094
|
||||
resourceful_lib_id=4598948
|
||||
resourceful_config_id=4576455
|
||||
jade_id=4818518
|
||||
curios_version=4440173
|
||||
cosmetic_armor_reworked_id=4439659
|
||||
ad_astra_id=4452072
|
||||
botarium_id=4416456
|
||||
resourceful_lib_id=4378849
|
||||
resourceful_config_id=4441381
|
||||
jade_id=4434045
|
||||
configured_id=4462894
|
||||
worldedit_id=4807512
|
||||
worldedit_id=4162208
|
||||
|
||||
kotlin_for_forge_version=4.7.0
|
||||
kotlin_version=1.9.0
|
||||
|
@ -1,55 +0,0 @@
|
||||
package ru.dbotthepony.mc.otm.datagen
|
||||
|
||||
import net.minecraft.core.RegistrySetBuilder
|
||||
import net.minecraft.core.registries.Registries
|
||||
import net.minecraft.data.worldgen.BootstapContext
|
||||
import net.minecraft.tags.DamageTypeTags
|
||||
import net.minecraft.world.damagesource.DamageScaling
|
||||
import net.minecraft.world.damagesource.DamageType
|
||||
import net.minecraftforge.common.data.DatapackBuiltinEntriesProvider
|
||||
import net.minecraftforge.data.event.GatherDataEvent
|
||||
import ru.dbotthepony.mc.otm.datagen.tags.TagsProvider
|
||||
import ru.dbotthepony.mc.otm.registry.MDamageTypes
|
||||
|
||||
fun registerDamageTypes(context: BootstapContext<DamageType>) {
|
||||
context.register(MDamageTypes.EXOPACK_PROBE, DamageType("otm_exopack_probe", DamageScaling.NEVER, 4.0f))
|
||||
context.register(MDamageTypes.BECOME_ANDROID, DamageType("otm_become_android", DamageScaling.NEVER, 0f))
|
||||
context.register(MDamageTypes.BECOME_HUMANE, DamageType("otm_become_humane", DamageScaling.NEVER, 0f))
|
||||
context.register(MDamageTypes.EVENT_HORIZON, DamageType("otm_event_horizon", DamageScaling.NEVER, 0f))
|
||||
context.register(MDamageTypes.HAWKING_RADIATION, DamageType("otm_hawking_radiation", DamageScaling.NEVER, 0f))
|
||||
context.register(MDamageTypes.EMP, DamageType("otm_emp", DamageScaling.NEVER, 0f))
|
||||
context.register(MDamageTypes.SHOCKWAVE, DamageType("otm_shockwave", DamageScaling.NEVER, 0f))
|
||||
context.register(MDamageTypes.PLASMA, DamageType("otm_plasma", DamageScaling.NEVER, 0f))
|
||||
context.register(MDamageTypes.COSMIC_RAYS, DamageType("otm_cosmic_rays", DamageScaling.NEVER, 0f))
|
||||
context.register(MDamageTypes.EXPLOSIVE_HAMMER, DamageType("otm_explosive_hammer", DamageScaling.NEVER, 0.1f))
|
||||
context.register(MDamageTypes.HAMMER_NAIL, DamageType("otm_hammer_nail", DamageScaling.NEVER, 0.1f))
|
||||
context.register(MDamageTypes.ANDROID_DISCHARGE, DamageType("otm_android_discharge", DamageScaling.NEVER, 4.0f))
|
||||
}
|
||||
|
||||
fun registerDamageTypeTags(provider: TagsProvider.Delegate<DamageType>) {
|
||||
val ignoreArmor = provider.Appender(DamageTypeTags.BYPASSES_ARMOR)
|
||||
val ignoreMagic = provider.Appender(DamageTypeTags.BYPASSES_ENCHANTMENTS)
|
||||
val ignoreInvl = provider.Appender(DamageTypeTags.BYPASSES_INVULNERABILITY)
|
||||
|
||||
ignoreArmor
|
||||
.add(MDamageTypes.EXOPACK_PROBE)
|
||||
.add(MDamageTypes.BECOME_ANDROID)
|
||||
.add(MDamageTypes.BECOME_HUMANE)
|
||||
.add(MDamageTypes.EVENT_HORIZON)
|
||||
.add(MDamageTypes.EMP)
|
||||
.add(MDamageTypes.SHOCKWAVE)
|
||||
.add(MDamageTypes.COSMIC_RAYS)
|
||||
.add(MDamageTypes.ANDROID_DISCHARGE)
|
||||
|
||||
ignoreMagic
|
||||
.add(MDamageTypes.EXOPACK_PROBE)
|
||||
.add(MDamageTypes.BECOME_ANDROID)
|
||||
.add(MDamageTypes.BECOME_HUMANE)
|
||||
.add(MDamageTypes.COSMIC_RAYS)
|
||||
.add(MDamageTypes.ANDROID_DISCHARGE)
|
||||
|
||||
ignoreInvl
|
||||
.add(MDamageTypes.BECOME_HUMANE)
|
||||
.add(MDamageTypes.BECOME_ANDROID)
|
||||
.add(MDamageTypes.ANDROID_DISCHARGE)
|
||||
}
|
@ -529,15 +529,12 @@ object DataGen {
|
||||
event.generator.addProvider(event.includeServer(), matterData)
|
||||
|
||||
val registrySetBuilder = RegistrySetBuilder()
|
||||
.add(Registries.DAMAGE_TYPE, ::registerDamageTypes)
|
||||
.add(Registries.CONFIGURED_FEATURE, ::registerConfiguredFeatures)
|
||||
.add(Registries.PLACED_FEATURE, ::registerPlacedFeatures)
|
||||
.add(ForgeRegistries.Keys.BIOME_MODIFIERS, ::registerBiomeModifiers)
|
||||
|
||||
event.generator.addProvider(event.includeServer(), DatapackBuiltinEntriesProvider(event.generator.packOutput, event.lookupProvider, registrySetBuilder, setOf(MOD_ID)))
|
||||
|
||||
registerDamageTypeTags(tagsProvider.damageTypes)
|
||||
|
||||
AddEnglishLanguage(languageProvider)
|
||||
AddRussianLanguage(languageProvider)
|
||||
|
||||
|
@ -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",
|
||||
|
@ -88,7 +88,7 @@ fun addItemModels(provider: MatteryItemModelProvider) {
|
||||
|
||||
provider.handheld(MItems.TRITANIUM_TOOLS)
|
||||
provider.armorColored(MItems.TRITANIUM_ARMOR)
|
||||
provider.armorWithTrims(MItems.SIMPLE_TRITANIUM_ARMOR)
|
||||
provider.generated(MItems.SIMPLE_TRITANIUM_ARMOR)
|
||||
|
||||
provider.handheld(MItems.CHEST_UPGRADER)
|
||||
|
||||
|
@ -99,29 +99,6 @@ class MatteryItemModelProvider(event: GatherDataEvent) : ItemModelProvider(event
|
||||
}
|
||||
}
|
||||
|
||||
fun armorWithTrims(item: Item, texture: ResourceLocation) = exec {
|
||||
val mainModel = withExistingParent(item.registryName!!.path, GENERATED).texture("layer0", texture)
|
||||
|
||||
if (item is ArmorItem) {
|
||||
for ((i, material) in ARMOR_TRIM_MATERIALS.withIndex()) {
|
||||
val trimLocation = ResourceLocation("trims/items/${item.type.getName()}_trim_${material}")
|
||||
existingFileHelper.trackGenerated(trimLocation, PackType.CLIENT_RESOURCES, ".png", "textures")
|
||||
|
||||
val overrideModel = withExistingParent("${item.registryName!!.path}_${material}_trim", GENERATED)
|
||||
.texture("layer0", texture)
|
||||
.texture("layer1", trimLocation)
|
||||
|
||||
mainModel.override()
|
||||
.predicate(ItemModelGenerators.TRIM_TYPE_PREDICATE_ID, (i + 1).toFloat() / ARMOR_TRIM_MATERIALS.size.toFloat())
|
||||
.model(overrideModel)
|
||||
.end()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun armorWithTrims(vararg items: Item) = items.forEach { armorWithTrims(it, modLocation("item/${it.registryName!!.path}")) }
|
||||
fun armorWithTrims(items: Collection<Item>) = items.forEach { armorWithTrims(it, modLocation("item/${it.registryName!!.path}")) }
|
||||
|
||||
fun armorColored(item: Item) = exec {
|
||||
withExistingParent(item.registryName!!.path, GENERATED)
|
||||
.texture("layer0", modLocation("item/${item.registryName!!.path}_base"))
|
||||
|
@ -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
|
||||
@ -432,7 +429,7 @@ fun addCraftingTableRecipes(consumer: RecipeOutput) {
|
||||
.build(consumer)
|
||||
|
||||
MatteryRecipe(MItems.PAINTER, category = machinesCategory)
|
||||
.row(Items.BRUSH, Items.BUCKET, Items.BUCKET)
|
||||
.row(Tags.Items.RODS_WOODEN, Items.BUCKET, Items.BUCKET)
|
||||
.row(MItemTags.IRON_PLATES, Items.BUCKET, MItemTags.IRON_PLATES)
|
||||
.row(MItemTags.IRON_PLATES, MItemTags.CRAFTING_TABLES, MItemTags.IRON_PLATES)
|
||||
.unlockedBy(Tags.Items.DYES)
|
||||
|
@ -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)
|
||||
|
||||
@ -125,14 +125,8 @@ fun addTags(tagsProvider: TagsProvider) {
|
||||
tagsProvider.items.Appender(Tags.Items.ARMORS_BOOTS)
|
||||
.add(MItems.TRITANIUM_BOOTS, MItems.SIMPLE_TRITANIUM_BOOTS)
|
||||
|
||||
tagsProvider.items.Appender(ItemTags.TRIMMABLE_ARMOR).add(MItems.SIMPLE_TRITANIUM_ARMOR)
|
||||
tagsProvider.items.Appender(ItemTags.FREEZE_IMMUNE_WEARABLES).add(MItems.TRITANIUM_ARMOR)
|
||||
|
||||
tagsProvider.items.Appender(ItemTags.SWORDS).add(MItems.TRITANIUM_SWORD).add(MItems.ENERGY_SWORD)
|
||||
tagsProvider.items.Appender(ItemTags.AXES).add(MItems.TRITANIUM_AXE)
|
||||
tagsProvider.items.Appender(ItemTags.PICKAXES).add(MItems.TRITANIUM_PICKAXE)
|
||||
tagsProvider.items.Appender(ItemTags.SHOVELS).add(MItems.TRITANIUM_SHOVEL)
|
||||
tagsProvider.items.Appender(ItemTags.SHOVELS).add(MItems.TRITANIUM_HOE)
|
||||
tagsProvider.items.Appender(Tags.Items.SHEARS).add(MItems.TRITANIUM_SHEARS)
|
||||
tagsProvider.items.Appender(Tags.Items.TOOLS_SHIELDS).add(MItems.TRITANIUM_SHIELD)
|
||||
|
||||
|
@ -167,10 +167,10 @@ 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)
|
||||
|
||||
val androidImmuneEffects = mobEffects.Appender(MatteryPlayerCapability.ANDROID_IMMUNE_EFFECTS)
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ open class AndroidFeatureType<T : AndroidFeature> {
|
||||
}
|
||||
|
||||
open val displayContents: ComponentContents by lazy {
|
||||
TranslatableContents(displayId, null, arrayOf())
|
||||
TranslatableContents(displayId)
|
||||
}
|
||||
|
||||
open val displayName: Component by lazy {
|
||||
|
@ -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
|
||||
@ -370,7 +371,7 @@ class AndroidResearchType(
|
||||
}
|
||||
|
||||
val displayContents: ComponentContents by lazy {
|
||||
TranslatableContents(displayId, null, arrayOf())
|
||||
TranslatableContents(displayId)
|
||||
}
|
||||
|
||||
val displayName: Component get() {
|
||||
@ -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)
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,6 @@ import ru.dbotthepony.mc.otm.client.render.sprites.sprite
|
||||
import ru.dbotthepony.mc.otm.config.AndroidConfig
|
||||
import ru.dbotthepony.mc.otm.core.genericPositions
|
||||
import ru.dbotthepony.mc.otm.core.holder
|
||||
import ru.dbotthepony.mc.otm.core.isFall
|
||||
import ru.dbotthepony.mc.otm.core.math.Vector
|
||||
import ru.dbotthepony.mc.otm.core.math.asVector
|
||||
import ru.dbotthepony.mc.otm.core.math.component1
|
||||
@ -71,29 +70,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 +139,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 +198,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 +257,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 +301,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 +309,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 +351,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,
|
||||
|
@ -9,20 +9,20 @@ import java.util.*
|
||||
|
||||
class ExtendedReachFeature(android: MatteryPlayerCapability) : AndroidFeature(AndroidFeatures.EXTENDED_REACH, android) {
|
||||
override fun applyModifiers() {
|
||||
if (!ForgeMod.BLOCK_REACH.isPresent)
|
||||
if (!ForgeMod.REACH_DISTANCE.isPresent)
|
||||
return
|
||||
|
||||
val reach = ply.getAttribute(ForgeMod.BLOCK_REACH.get()) ?: return
|
||||
val reach = ply.getAttribute(ForgeMod.REACH_DISTANCE.get()) ?: return
|
||||
|
||||
reach.removePermanentModifier(MODIFIER_ID)
|
||||
reach.addPermanentModifier(AttributeModifier(MODIFIER_ID, type.displayName.toString(), level + 1.0, AttributeModifier.Operation.ADDITION))
|
||||
}
|
||||
|
||||
override fun removeModifiers() {
|
||||
if (!ForgeMod.BLOCK_REACH.isPresent)
|
||||
if (!ForgeMod.REACH_DISTANCE.isPresent)
|
||||
return
|
||||
|
||||
ply.getAttribute(ForgeMod.BLOCK_REACH.get())?.removePermanentModifier(MODIFIER_ID)
|
||||
ply.getAttribute(ForgeMod.REACH_DISTANCE.get())?.removePermanentModifier(MODIFIER_ID)
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
@ -1,20 +1,12 @@
|
||||
package ru.dbotthepony.mc.otm.android.feature
|
||||
|
||||
import net.minecraft.ChatFormatting
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
import net.minecraft.server.level.ServerPlayer
|
||||
import net.minecraftforge.event.entity.living.LivingAttackEvent
|
||||
import net.minecraftforge.event.entity.living.LivingHurtEvent
|
||||
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
||||
import ru.dbotthepony.mc.otm.android.AndroidFeature
|
||||
import ru.dbotthepony.mc.otm.android.AndroidResearchManager
|
||||
import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability
|
||||
import ru.dbotthepony.mc.otm.config.AndroidConfig
|
||||
import ru.dbotthepony.mc.otm.core.TextComponent
|
||||
import ru.dbotthepony.mc.otm.core.TranslatableComponent
|
||||
import ru.dbotthepony.mc.otm.core.isFall
|
||||
import ru.dbotthepony.mc.otm.registry.AndroidFeatures
|
||||
import ru.dbotthepony.mc.otm.registry.MNames
|
||||
import ru.dbotthepony.mc.otm.triggers.FallDampenersSaveTrigger
|
||||
|
||||
class FallDampenersFeature(capability: MatteryPlayerCapability) : AndroidFeature(AndroidFeatures.FALL_DAMPENERS, capability) {
|
||||
|
@ -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)
|
||||
}
|
||||
@ -61,7 +61,7 @@ class ItemMagnetFeature(capability: MatteryPlayerCapability) : AndroidSwitchable
|
||||
private data class ItemPos(var position: Vector, var ticksSinceActivity: Int)
|
||||
private val rememberPositions = WeakHashMap<ItemEntity, ItemPos>()
|
||||
|
||||
private val serverPredicate = Predicate<Entity> { it is ItemEntity && !it.hasPickUpDelay() && (it.owner == null || it.owner != ply || it.lifespan - it.age <= 200) }
|
||||
private val serverPredicate = Predicate<Entity> { it is ItemEntity && !it.hasPickUpDelay() && (it.owner == null || it.owner != ply.uuid || it.lifespan - it.age <= 200) }
|
||||
private val clientPredicate = Predicate<Entity> { it is ItemEntity && (datatable[it] ?: SharedItemEntityData.EMPTY).let { !it.hasPickupDelay && (it.owner == null || it.owner != ply.uuid || it.lifespan - it.age <= 200) } }
|
||||
|
||||
private fun doTick(server: Boolean) {
|
||||
@ -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
|
||||
@ -79,7 +79,7 @@ class ItemMagnetFeature(capability: MatteryPlayerCapability) : AndroidSwitchable
|
||||
ent as ItemEntity
|
||||
|
||||
if (server) {
|
||||
GenericNetworkChannel.send(ply, ItemEntityDataPacket(ent.id, ent.owner?.uuid, ent.age, ent.lifespan, ent.hasPickUpDelay()))
|
||||
GenericNetworkChannel.send(ply, ItemEntityDataPacket(ent.id, ent.owner, ent.age, ent.lifespan, ent.hasPickUpDelay()))
|
||||
|
||||
if (!serverPredicate.test(ent)) {
|
||||
continue
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,6 @@ import ru.dbotthepony.kommons.util.setValue
|
||||
import ru.dbotthepony.mc.otm.android.AndroidFeature
|
||||
import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability
|
||||
import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact
|
||||
import ru.dbotthepony.mc.otm.core.isBypassArmor
|
||||
import ru.dbotthepony.mc.otm.core.math.Decimal
|
||||
import ru.dbotthepony.mc.otm.registry.AndroidFeatures
|
||||
import ru.dbotthepony.mc.otm.registry.StatNames
|
||||
|
@ -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() }
|
||||
|
@ -14,7 +14,6 @@ import ru.dbotthepony.mc.otm.capability.matteryPlayer
|
||||
import ru.dbotthepony.mc.otm.client.render.MGUIGraphics
|
||||
import ru.dbotthepony.mc.otm.client.render.ResearchIcons
|
||||
import ru.dbotthepony.mc.otm.config.AndroidConfig
|
||||
import ru.dbotthepony.mc.otm.core.damageType
|
||||
import ru.dbotthepony.mc.otm.core.getEntitiesInEllipsoid
|
||||
import ru.dbotthepony.mc.otm.core.getExplosionResistance
|
||||
import ru.dbotthepony.kommons.math.RGBAColor
|
||||
@ -33,7 +32,7 @@ import ru.dbotthepony.mc.otm.onceServer
|
||||
import ru.dbotthepony.mc.otm.registry.AndroidFeatures
|
||||
import ru.dbotthepony.mc.otm.registry.MDamageTypes
|
||||
import ru.dbotthepony.mc.otm.registry.MSoundEvents
|
||||
import ru.dbotthepony.mc.otm.registry.MatteryDamageSource
|
||||
import ru.dbotthepony.mc.otm.registry.ShockwaveDamageSource
|
||||
import ru.dbotthepony.mc.otm.triggers.ShockwaveDamageMobTrigger
|
||||
import ru.dbotthepony.mc.otm.triggers.ShockwaveTrigger
|
||||
import kotlin.math.pow
|
||||
@ -93,7 +92,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 +103,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 +121,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 = ShockwaveDamageSource(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 +137,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 = ShockwaveDamageSource(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 +157,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 +191,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)
|
||||
|
@ -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.sounds.SoundEvents
|
||||
import net.minecraft.world.entity.Entity
|
||||
import net.minecraft.world.entity.monster.Zombie
|
||||
import net.minecraft.world.item.DyeColor
|
||||
@ -11,21 +12,19 @@ import net.minecraft.world.item.TooltipFlag
|
||||
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
|
||||
SoundEvents.IRON_DOOR_CLOSE, SoundEvents.IRON_DOOR_OPEN
|
||||
) {
|
||||
val tooltips = TooltipList()
|
||||
|
||||
@ -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,
|
||||
|
@ -4,26 +4,29 @@ import net.minecraft.ChatFormatting
|
||||
import net.minecraft.core.BlockPos
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.server.level.ServerPlayer
|
||||
import net.minecraft.sounds.SoundEvents
|
||||
import net.minecraft.sounds.SoundSource
|
||||
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.Level
|
||||
import net.minecraft.world.level.LevelAccessor
|
||||
import net.minecraft.world.level.block.BasePressurePlateBlock
|
||||
import net.minecraft.world.level.block.Block
|
||||
import net.minecraft.world.level.block.SoundType
|
||||
import net.minecraft.world.level.block.state.BlockState
|
||||
import net.minecraft.world.level.block.state.StateDefinition
|
||||
import net.minecraft.world.level.block.state.properties.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()) {
|
||||
val tooltips = TooltipList()
|
||||
|
||||
override fun appendHoverText(
|
||||
itemStack: ItemStack,
|
||||
level: BlockGetter?,
|
||||
@ -46,6 +49,14 @@ class TritaniumPressurePlate(color: DyeColor?) : BasePressurePlateBlock(Properti
|
||||
p_49915_.add(BlockStateProperties.POWERED)
|
||||
}
|
||||
|
||||
override fun playOnSound(level: LevelAccessor, pos: BlockPos) {
|
||||
level.playSound(null, pos, SoundEvents.METAL_PRESSURE_PLATE_CLICK_ON, SoundSource.BLOCKS, 0.3f, 0.9f)
|
||||
}
|
||||
|
||||
override fun playOffSound(level: LevelAccessor, pos: BlockPos) {
|
||||
level.playSound(null, pos, SoundEvents.METAL_PRESSURE_PLATE_CLICK_OFF, SoundSource.BLOCKS, 0.3f, 0.9f)
|
||||
}
|
||||
|
||||
override fun getSignalStrength(level: Level, pos: BlockPos): Int {
|
||||
if (level.getEntitiesOfClass(ServerPlayer::class.java, TOUCH_AABB.move(pos)).isNotEmpty()) {
|
||||
return 15
|
||||
|
@ -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.sounds.SoundEvents
|
||||
import net.minecraft.world.entity.Entity
|
||||
import net.minecraft.world.entity.EntityType
|
||||
import net.minecraft.world.entity.monster.Zombie
|
||||
@ -12,19 +13,18 @@ import net.minecraft.world.item.TooltipFlag
|
||||
import net.minecraft.world.level.BlockGetter
|
||||
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()
|
||||
.isValidSpawn { _: BlockState, _: BlockGetter, _: BlockPos, _: EntityType<*>? -> false },
|
||||
BlockSetType.IRON
|
||||
SoundEvents.IRON_DOOR_CLOSE, SoundEvents.IRON_DOOR_OPEN
|
||||
) {
|
||||
val tooltips = TooltipList()
|
||||
|
||||
|
@ -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)
|
||||
|
@ -26,7 +26,6 @@ import ru.dbotthepony.mc.otm.block.entity.tech.GravitationStabilizerBlockEntity
|
||||
import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity
|
||||
import ru.dbotthepony.mc.otm.block.entity.blackhole.ExplosionQueue.Companion.queueForLevel
|
||||
import ru.dbotthepony.mc.otm.config.ServerConfig
|
||||
import ru.dbotthepony.mc.otm.core.damageType
|
||||
import ru.dbotthepony.mc.otm.core.getExplosionResistance
|
||||
import ru.dbotthepony.mc.otm.core.gracefulBlockBreak
|
||||
import ru.dbotthepony.mc.otm.core.math.Decimal
|
||||
@ -40,7 +39,6 @@ import ru.dbotthepony.mc.otm.core.nbt.set
|
||||
import ru.dbotthepony.mc.otm.core.util.decimal
|
||||
import ru.dbotthepony.mc.otm.matter.MatterManager
|
||||
import ru.dbotthepony.mc.otm.registry.MDamageTypes
|
||||
import ru.dbotthepony.mc.otm.registry.MatteryDamageSource
|
||||
import ru.dbotthepony.mc.otm.triggers.BlackHoleTrigger
|
||||
import kotlin.math.pow
|
||||
import kotlin.math.roundToInt
|
||||
@ -122,7 +120,7 @@ class BlackHoleBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mattery
|
||||
} else {
|
||||
level.explode(
|
||||
null,
|
||||
MatteryDamageSource(level.registryAccess().damageType(MDamageTypes.HAWKING_RADIATION)),
|
||||
MDamageTypes.HAWKING_RADIATION,
|
||||
null,
|
||||
blockPos.x + 0.5,
|
||||
blockPos.y + 0.5,
|
||||
@ -241,7 +239,7 @@ class BlackHoleBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mattery
|
||||
}
|
||||
|
||||
if (distance < gravitationStrength + 1.0) {
|
||||
val source = MatteryDamageSource(level.registryAccess().damageType(MDamageTypes.EVENT_HORIZON))
|
||||
val source = MDamageTypes.EVENT_HORIZON
|
||||
val damage = (gravitationStrength / distance).toFloat()
|
||||
|
||||
if (living is Player) {
|
||||
@ -259,7 +257,7 @@ class BlackHoleBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mattery
|
||||
setDeltaMovement(item, center, distance)
|
||||
|
||||
if (distance < gravitationStrength + 1) {
|
||||
if (item.hurt(MatteryDamageSource(level.registryAccess().damageType(MDamageTypes.EVENT_HORIZON)), (gravitationStrength / distance).toFloat()) && item.isRemoved) {
|
||||
if (item.hurt(MDamageTypes.EVENT_HORIZON, (gravitationStrength / distance).toFloat()) && item.isRemoved) {
|
||||
if (item.item.item === MItems.GRAVITATIONAL_DISRUPTOR) {
|
||||
collapse()
|
||||
} else {
|
||||
|
@ -6,7 +6,6 @@ import net.minecraft.nbt.DoubleTag
|
||||
import net.minecraft.nbt.ListTag
|
||||
import net.minecraft.nbt.Tag
|
||||
import net.minecraft.server.level.ServerLevel
|
||||
import net.minecraft.util.datafix.DataFixTypes
|
||||
import net.minecraft.world.level.BlockGetter
|
||||
import net.minecraft.world.level.Explosion
|
||||
import net.minecraft.world.level.ExplosionDamageCalculator
|
||||
@ -32,8 +31,6 @@ import ru.dbotthepony.mc.otm.core.math.rotateAroundAxis
|
||||
import ru.dbotthepony.mc.otm.core.math.up
|
||||
import ru.dbotthepony.mc.otm.core.nbt.set
|
||||
import ru.dbotthepony.mc.otm.registry.MDamageTypes
|
||||
import ru.dbotthepony.mc.otm.registry.MRegistry
|
||||
import ru.dbotthepony.mc.otm.registry.MatteryDamageSource
|
||||
import java.util.*
|
||||
import kotlin.collections.ArrayList
|
||||
import kotlin.collections.HashMap
|
||||
@ -539,7 +536,7 @@ private data class QueuedExplosion(val x: Double, val y: Double, val z: Double,
|
||||
fun explode(level: Level) {
|
||||
level.explode(
|
||||
null,
|
||||
MatteryDamageSource(level.registryAccess().damageType(MDamageTypes.HAWKING_RADIATION)),
|
||||
MDamageTypes.HAWKING_RADIATION,
|
||||
BlackHoleExplosionDamageCalculator,
|
||||
x,
|
||||
y,
|
||||
@ -668,11 +665,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
|
||||
@ -150,7 +151,7 @@ class MatterEntanglerBlockEntity(blockPos: BlockPos, blockState: BlockState) : M
|
||||
.values
|
||||
.firstOrNull { it.value.matches(inputs, level!!) } ?: return JobContainer.noItem()
|
||||
|
||||
val result = recipe.value.assemble(inputs, level!!.registryAccess())
|
||||
val result = recipe.value.assemble(inputs)
|
||||
|
||||
inputs.forEach { it.shrink(1) }
|
||||
inputs.setChanged()
|
||||
|
@ -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
|
||||
@ -292,7 +292,7 @@ class ItemMonitorBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matte
|
||||
|
||||
override fun getItem(slot: Int): ItemStack {
|
||||
require(slot == 0) { "Invalid slot: $slot" }
|
||||
return craftingRecipe?.getResultItem(level?.registryAccess() ?: return ItemStack.EMPTY)?.copy() ?: ItemStack.EMPTY
|
||||
return craftingRecipe?.resultItem?.copy() ?: ItemStack.EMPTY
|
||||
}
|
||||
|
||||
override fun removeItem(index: Int, amount: Int): ItemStack {
|
||||
@ -305,7 +305,7 @@ class ItemMonitorBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matte
|
||||
try {
|
||||
ForgeHooks.setCraftingPlayer(craftingPlayer)
|
||||
|
||||
if (craftingRecipe.getResultItem(level.registryAccess()).count != amount) {
|
||||
if (craftingRecipe.resultItem.count != amount) {
|
||||
return ItemStack.EMPTY
|
||||
}
|
||||
} finally {
|
||||
@ -331,7 +331,7 @@ class ItemMonitorBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matte
|
||||
|
||||
try {
|
||||
residue = craftingRecipe.getRemainingItems(craftingGrid)
|
||||
result = craftingRecipe.getResultItem(level.registryAccess())
|
||||
result = craftingRecipe.resultItem
|
||||
} finally {
|
||||
ForgeHooks.setCraftingPlayer(null)
|
||||
}
|
||||
@ -398,7 +398,7 @@ class ItemMonitorBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matte
|
||||
}
|
||||
|
||||
override fun setItem(p_18944_: Int, p_18945_: ItemStack) {
|
||||
if ((craftingRecipe != null && !craftingRecipe!!.let { it.getResultItem(level?.registryAccess() ?: return@let ItemStack.EMPTY) }.isEmpty) || !p_18945_.isEmpty) {
|
||||
if ((craftingRecipe != null && !craftingRecipe!!.resultItem.isEmpty) || !p_18945_.isEmpty) {
|
||||
throw RuntimeException("BUG-DETECT: Tried to set crafting result slot item to something, and either we have crafting recipe which have valid result, or we are trying to set slot to non empty item: $p_18945_")
|
||||
}
|
||||
}
|
||||
@ -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
|
||||
@ -145,7 +146,7 @@ sealed class AbstractPoweredFurnaceBlockEntity<P : AbstractCookingRecipe, S : Ma
|
||||
|
||||
return JobContainer.success(
|
||||
ItemJob(
|
||||
recipe.getResultItem(level.registryAccess()).copyWithCount(toProcess),
|
||||
recipe.getResultItem().copyWithCount(toProcess),
|
||||
recipe.workTime * config.workTimeMultiplier,
|
||||
config.energyConsumption * toProcess,
|
||||
experience = recipe.experience.sample(level.random) * toProcess))
|
||||
@ -153,7 +154,7 @@ sealed class AbstractPoweredFurnaceBlockEntity<P : AbstractCookingRecipe, S : Ma
|
||||
}
|
||||
|
||||
return level.recipeManager.getRecipeFor(recipeType, inputs[id], level).map {
|
||||
val output = it.value.assemble(inputs[id], level.registryAccess())
|
||||
val output = it.value.assemble(inputs[id])
|
||||
val inputItem = inputs[id][0].copyWithCount(1)
|
||||
val toProcess = inputs[id][0].count.coerceAtMost(upgrades.processingItems + 1)
|
||||
inputs[id][0].shrink(toProcess)
|
||||
|
@ -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
|
||||
@ -88,7 +89,7 @@ class PlatePressBlockEntity(
|
||||
|
||||
return JobContainer.success(
|
||||
ItemJob(
|
||||
recipe.getResultItem(level.registryAccess()).copyWithCount(toProcess),
|
||||
recipe.getResultItem().copyWithCount(toProcess),
|
||||
recipe.workTime * MachinesConfig.PLATE_PRESS.workTimeMultiplier,
|
||||
MachinesConfig.PLATE_PRESS.energyConsumption * toProcess,
|
||||
experience = recipe.experience.sample(level.random) * toProcess))
|
||||
|
@ -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,11 +21,12 @@ 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
|
||||
import net.minecraft.world.phys.shapes.VoxelShape
|
||||
import net.minecraftforge.common.ForgeHooks
|
||||
import net.minecraftforge.event.ForgeEventFactory
|
||||
import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock
|
||||
import ru.dbotthepony.mc.otm.block.addSimpleDescription
|
||||
@ -36,12 +38,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,
|
||||
@ -68,13 +69,22 @@ class PhantomAttractorBlock : RotatableMatteryBlock(Properties.of().mapColor(Map
|
||||
) {
|
||||
val phantom = EntityType.PHANTOM.create(level) ?: continue
|
||||
phantom.moveTo(spawnPos, 0.0f, 0.0f)
|
||||
groupData = ForgeEventFactory.onFinalizeSpawn(phantom, level, level.getCurrentDifficultyAt(spawnPos), MobSpawnType.SPAWNER, groupData, null)
|
||||
|
||||
if (ForgeHooks.canEntitySpawn(phantom, level, spawnPos.x.toDouble(), spawnPos.y.toDouble(), spawnPos.z.toDouble(), null, MobSpawnType.SPAWNER) == -1) {
|
||||
continue
|
||||
}
|
||||
|
||||
groupData = phantom.finalizeSpawn(level, level.getCurrentDifficultyAt(spawnPos), MobSpawnType.SPAWNER, groupData, null)
|
||||
level.addFreshEntityWithPassengers(phantom)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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")
|
||||
|
@ -121,7 +121,6 @@ import ru.dbotthepony.mc.otm.registry.AndroidFeatures
|
||||
import ru.dbotthepony.mc.otm.registry.MDamageTypes
|
||||
import ru.dbotthepony.mc.otm.registry.MItems
|
||||
import ru.dbotthepony.mc.otm.registry.MRegistry
|
||||
import ru.dbotthepony.mc.otm.registry.MatteryDamageSource
|
||||
import ru.dbotthepony.mc.otm.triggers.AndroidResearchTrigger
|
||||
import ru.dbotthepony.mc.otm.triggers.AndroidTravelUnderwater
|
||||
import ru.dbotthepony.mc.otm.triggers.BecomeAndroidDeathTrigger
|
||||
@ -156,7 +155,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 +167,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 +180,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,14 +537,14 @@ 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) {
|
||||
return JobContainer.noItem()
|
||||
} else {
|
||||
val actual = recipe.get()
|
||||
val item = actual.value.assemble(input, level.registryAccess())
|
||||
val item = actual.value.assemble(input)
|
||||
input[0].shrink(1)
|
||||
input.setChanged(0)
|
||||
return JobContainer.success(ItemJob(item, actual.value.cookingTime.toDouble(), ExopackConfig.FURNACE_POWER_CONSUMPTION, actual.value.experience))
|
||||
@ -555,8 +554,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 +698,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(MDamageTypes.BECOME_ANDROID, ply.maxHealth * 2)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -761,7 +760,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(MDamageTypes.BECOME_HUMANE, ply.maxHealth * 2)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -822,7 +821,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 +849,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 +874,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 +1047,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 +1101,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 +1210,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 +1263,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 +1275,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 +1292,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(MDamageTypes.ANDROID_DISCHARGE, 1f)) {
|
||||
nextDischargeHurt = 20
|
||||
}
|
||||
|
||||
@ -1306,13 +1305,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 +1440,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 +1535,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()
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ import net.minecraft.nbt.CompoundTag
|
||||
import net.minecraft.server.level.ServerPlayer
|
||||
import net.minecraft.world.entity.player.Player
|
||||
import net.minecraft.world.item.ItemStack
|
||||
import net.minecraft.world.ticks.ContainerSingleItem
|
||||
import net.minecraftforge.common.capabilities.ForgeCapabilities
|
||||
import net.minecraftforge.common.util.INBTSerializable
|
||||
import ru.dbotthepony.kommons.io.DelegateSyncher
|
||||
@ -13,6 +12,7 @@ import ru.dbotthepony.kommons.util.setValue
|
||||
import ru.dbotthepony.mc.otm.capability.FlowDirection
|
||||
import ru.dbotthepony.mc.otm.capability.extractEnergy
|
||||
import ru.dbotthepony.mc.otm.capability.receiveEnergy
|
||||
import ru.dbotthepony.mc.otm.container.IContainer
|
||||
import ru.dbotthepony.mc.otm.core.math.Decimal
|
||||
import ru.dbotthepony.mc.otm.core.math.getDecimal
|
||||
import ru.dbotthepony.mc.otm.core.nbt.getItemStack
|
||||
@ -31,7 +31,7 @@ class BatteryBackedEnergyStorage(
|
||||
maxCharge: Decimal,
|
||||
val isAndroid: Boolean,
|
||||
val onChange: Runnable? = null
|
||||
) : IMatteryEnergyStorage, INBTSerializable<CompoundTag?>, ContainerSingleItem {
|
||||
) : IMatteryEnergyStorage, INBTSerializable<CompoundTag?>, IContainer {
|
||||
override val energyFlow: FlowDirection
|
||||
get() = FlowDirection.INPUT
|
||||
|
||||
@ -65,6 +65,22 @@ class BatteryBackedEnergyStorage(
|
||||
item = stack
|
||||
}
|
||||
|
||||
override fun clearContent() {
|
||||
item = ItemStack.EMPTY
|
||||
}
|
||||
|
||||
override fun getContainerSize(): Int {
|
||||
return 1
|
||||
}
|
||||
|
||||
override fun isEmpty(): Boolean {
|
||||
return item.isEmpty
|
||||
}
|
||||
|
||||
override fun removeItemNoUpdate(slot: Int): ItemStack {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
override fun setChanged() {
|
||||
|
||||
}
|
||||
|
@ -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,12 +12,12 @@ 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(
|
||||
text: Any, x: Float, y: Float, color: Int, drawShadow: Boolean,
|
||||
matrix4f: Matrix4f, buffer: MultiBufferSource, displayMode: Font.DisplayMode,
|
||||
matrix4f: Matrix4f, buffer: MultiBufferSource, displayMode: Boolean,
|
||||
effectColor: Int, packedLightCoords: Int, gravity: RenderGravity,
|
||||
rounding: GravityRounding, width: FloatSupplier
|
||||
): Int {
|
||||
@ -122,7 +120,7 @@ private fun Font.drawInternal(
|
||||
scale: Float,
|
||||
color: RGBAColor,
|
||||
drawShadow: Boolean,
|
||||
displayMode: Font.DisplayMode,
|
||||
displayMode: Boolean,
|
||||
packedLightCoords: Int,
|
||||
effectColor: Int,
|
||||
shadowColor: RGBAColor,
|
||||
@ -241,7 +239,7 @@ fun Font.draw(
|
||||
scale: Float = 1f,
|
||||
color: RGBAColor = RGBAColor.WHITE,
|
||||
drawShadow: Boolean = false,
|
||||
displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL,
|
||||
displayMode: Boolean = false,
|
||||
packedLightCoords: Int = 15728880,
|
||||
effectColor: Int = 0,
|
||||
shadowColor: RGBAColor = RGBAColor.BLACK,
|
||||
@ -289,7 +287,7 @@ fun Font.draw(
|
||||
scale: Float = 1f,
|
||||
color: RGBAColor = RGBAColor.WHITE,
|
||||
drawShadow: Boolean = false,
|
||||
displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL,
|
||||
displayMode: Boolean = false,
|
||||
packedLightCoords: Int = 15728880,
|
||||
effectColor: Int = 0,
|
||||
shadowColor: RGBAColor = RGBAColor.BLACK,
|
||||
@ -337,7 +335,7 @@ fun Font.draw(
|
||||
scale: Float = 1f,
|
||||
color: RGBAColor = RGBAColor.WHITE,
|
||||
drawShadow: Boolean = false,
|
||||
displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL,
|
||||
displayMode: Boolean = false,
|
||||
packedLightCoords: Int = 15728880,
|
||||
effectColor: Int = 0,
|
||||
shadowColor: RGBAColor = RGBAColor.BLACK,
|
||||
|
@ -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()
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ data class ItemStackIcon(private val itemStack: ItemStack, override val width: F
|
||||
pose.scale(width / 16f, height / 16f, 1f)
|
||||
|
||||
guiGraphics.setColor(color.red, color.green, color.blue, color.alpha)
|
||||
guiGraphics.renderFakeItem(itemStack, 0, 0)
|
||||
guiGraphics.renderFakeItem(pose, itemStack, 0, 0)
|
||||
pose.popPose()
|
||||
|
||||
clearDepth(pose, x, y, width, height)
|
||||
|
@ -1,33 +1,48 @@
|
||||
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)
|
||||
fun renderFakeItem(poseStack: PoseStack, itemStack: ItemStack, x: Int, y: Int) {
|
||||
val global = RenderSystem.getModelViewStack()
|
||||
global.pushPose()
|
||||
global.last().pose().mul(poseStack.last().pose())
|
||||
global.last().normal().mul(poseStack.last().normal())
|
||||
RenderSystem.applyModelViewMatrix()
|
||||
minecraft.itemRenderer.renderGuiItem(itemStack, x, y)
|
||||
global.popPose()
|
||||
RenderSystem.applyModelViewMatrix()
|
||||
}
|
||||
|
||||
fun drawLine(
|
||||
@ -79,11 +94,73 @@ 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()
|
||||
TooltipRenderUtil.renderTooltipBackground(GuiComponent::fillGradient, matrix4f, bufferbuilder, x, y, totalWidth, totalHeight, 400)
|
||||
RenderSystem.enableDepthTest()
|
||||
RenderSystem.disableTexture()
|
||||
RenderSystem.enableBlend()
|
||||
RenderSystem.defaultBlendFunc()
|
||||
BufferUploader.drawWithShader(bufferbuilder.end())
|
||||
RenderSystem.disableBlend()
|
||||
RenderSystem.enableTexture()
|
||||
|
||||
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, 0 /* blit offset, i love you, go commit self-murder */)
|
||||
/* because your existence servers ZERO FUCKING PURPOSE */
|
||||
/* Z-BUFFER IN MY GUI PIECE OF SHIT */
|
||||
yCurrent += line.height + if (i == 0) 2 else 0
|
||||
}
|
||||
|
||||
pose.popPose()
|
||||
}
|
||||
}
|
||||
|
||||
fun flush() {
|
||||
parent.flush()
|
||||
bufferSource.endBatch()
|
||||
}
|
||||
|
||||
fun draw(
|
||||
@ -94,7 +171,7 @@ class MGUIGraphics(val parent: GuiGraphics) {
|
||||
scale: Float = 1f,
|
||||
color: RGBAColor = RGBAColor.WHITE,
|
||||
drawShadow: Boolean = false,
|
||||
displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL,
|
||||
displayMode: Boolean = false,
|
||||
packedLightCoords: Int = 15728880,
|
||||
effectColor: Int = 0,
|
||||
shadowColor: RGBAColor = RGBAColor.BLACK,
|
||||
@ -144,7 +221,7 @@ class MGUIGraphics(val parent: GuiGraphics) {
|
||||
scale: Float = 1f,
|
||||
color: RGBAColor = RGBAColor.WHITE,
|
||||
drawShadow: Boolean = false,
|
||||
displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL,
|
||||
displayMode: Boolean = false,
|
||||
packedLightCoords: Int = 15728880,
|
||||
effectColor: Int = 0,
|
||||
shadowColor: RGBAColor = RGBAColor.BLACK,
|
||||
@ -194,7 +271,7 @@ class MGUIGraphics(val parent: GuiGraphics) {
|
||||
scale: Float = 1f,
|
||||
color: RGBAColor = RGBAColor.WHITE,
|
||||
drawShadow: Boolean = false,
|
||||
displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL,
|
||||
displayMode: Boolean = false,
|
||||
packedLightCoords: Int = 15728880,
|
||||
effectColor: Int = 0,
|
||||
shadowColor: RGBAColor = RGBAColor.BLACK,
|
||||
|
@ -5,6 +5,7 @@ import com.mojang.blaze3d.vertex.Tesselator
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer
|
||||
import net.minecraft.core.Vec3i
|
||||
import org.joml.Matrix4f
|
||||
import org.joml.Quaternionf
|
||||
import org.joml.Vector3f
|
||||
import ru.dbotthepony.kommons.math.RGBAColor
|
||||
import ru.dbotthepony.mc.otm.core.math.IAngle
|
||||
@ -52,6 +53,12 @@ fun PoseStack.rotateAroundPoint(point: Vector3f, rotation: IAngle) {
|
||||
// last.normal().mul(rotation.forward().rotateAroundThis(rotation))
|
||||
}
|
||||
|
||||
fun PoseStack.rotateAround(rotationMatrix: Quaternionf, x: Float, y: Float, z: Float) {
|
||||
val pose = last
|
||||
pose.pose.rotateAround(rotationMatrix, x, y, z)
|
||||
pose.normal().rotate(rotationMatrix)
|
||||
}
|
||||
|
||||
fun PoseStack.translation(): Vector3f {
|
||||
return last().pose().translation
|
||||
}
|
||||
|
@ -3,12 +3,12 @@ package ru.dbotthepony.mc.otm.client.render.blockentity
|
||||
import com.mojang.blaze3d.vertex.*
|
||||
import com.mojang.math.Axis
|
||||
import net.minecraft.client.renderer.*
|
||||
import net.minecraft.client.renderer.block.model.ItemTransforms
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider
|
||||
import net.minecraft.client.renderer.entity.ItemRenderer
|
||||
import net.minecraft.world.inventory.InventoryMenu
|
||||
import net.minecraft.world.item.BlockItem
|
||||
import net.minecraft.world.item.ItemDisplayContext
|
||||
import net.minecraft.world.item.ItemStack
|
||||
import net.minecraft.world.level.block.HalfTransparentBlock
|
||||
import net.minecraft.world.level.block.StainedGlassPaneBlock
|
||||
@ -18,6 +18,7 @@ import net.minecraftforge.fluids.FluidStack
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler
|
||||
import ru.dbotthepony.mc.otm.block.entity.decorative.FluidTankBlockEntity
|
||||
import ru.dbotthepony.mc.otm.client.minecraft
|
||||
import ru.dbotthepony.mc.otm.client.render.rotateAround
|
||||
import ru.dbotthepony.mc.otm.core.ifPresentK
|
||||
import ru.dbotthepony.kommons.math.RGBAColor
|
||||
import ru.dbotthepony.mc.otm.core.math.linearInterpolation
|
||||
@ -38,7 +39,7 @@ class FluidTankRenderer(private val context: BlockEntityRendererProvider.Context
|
||||
object FluidTankItemRenderer : BlockEntityWithoutLevelRenderer(minecraft.blockEntityRenderDispatcher, minecraft.entityModels) {
|
||||
override fun renderByItem(
|
||||
stack: ItemStack,
|
||||
displayContext: ItemDisplayContext,
|
||||
displayContext: ItemTransforms.TransformType,
|
||||
poseStack: PoseStack,
|
||||
bufferSource: MultiBufferSource,
|
||||
packedLight: Int,
|
||||
@ -51,7 +52,7 @@ class FluidTankRenderer(private val context: BlockEntityRendererProvider.Context
|
||||
}
|
||||
|
||||
val hasFoil = stack.hasFoil()
|
||||
val fabulous = displayContext == ItemDisplayContext.GUI
|
||||
val fabulous = displayContext == ItemTransforms.TransformType.GUI
|
||||
|| displayContext.firstPerson()
|
||||
|| (stack.item is BlockItem && ((stack.item as BlockItem).block is HalfTransparentBlock || (stack.item as BlockItem).block is StainedGlassPaneBlock))
|
||||
|
||||
|
@ -3,9 +3,9 @@ package ru.dbotthepony.mc.otm.client.render.blockentity
|
||||
import com.mojang.blaze3d.vertex.PoseStack
|
||||
import com.mojang.math.Axis
|
||||
import net.minecraft.client.renderer.MultiBufferSource
|
||||
import net.minecraft.client.renderer.block.model.ItemTransforms
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider
|
||||
import net.minecraft.world.item.ItemDisplayContext
|
||||
import ru.dbotthepony.mc.otm.block.entity.matter.MatterReconstructorBlockEntity
|
||||
import ru.dbotthepony.mc.otm.client.render.DynamicBufferSource
|
||||
|
||||
@ -32,7 +32,7 @@ class MatterReconstructorRenderer(private val context: BlockEntityRendererProvid
|
||||
pose.mulPose(Axis.XP.rotationDegrees(90f))
|
||||
pose.mulPose(Axis.ZP.rotationDegrees(tile.blockRotation.back.toYRot()))
|
||||
|
||||
context.itemRenderer.renderStatic(item, ItemDisplayContext.FIXED, packedLight, packedOverlay, pose, DynamicBufferSource.WORLD, tile.level, tile.blockPos.asLong().toInt())
|
||||
context.itemRenderer.renderStatic(item, ItemTransforms.TransformType.FIXED, packedLight, packedOverlay, pose, DynamicBufferSource.WORLD, tile.blockPos.asLong().toInt())
|
||||
|
||||
pose.popPose()
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ import net.minecraft.client.renderer.block.model.ItemTransforms
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider
|
||||
import net.minecraft.core.particles.DustParticleOptions
|
||||
import net.minecraft.world.item.ItemDisplayContext
|
||||
import net.minecraft.world.level.levelgen.XoroshiroRandomSource
|
||||
import org.joml.Vector3f
|
||||
import org.lwjgl.opengl.GL14.glBlendColor
|
||||
@ -80,7 +79,7 @@ class MatterReplicatorRenderer(private val context: BlockEntityRendererProvider.
|
||||
|
||||
context.itemRenderer.render(
|
||||
item,
|
||||
ItemDisplayContext.NONE,
|
||||
ItemTransforms.TransformType.NONE,
|
||||
false,
|
||||
pose,
|
||||
source,
|
||||
|
@ -5,9 +5,9 @@ import com.mojang.blaze3d.systems.RenderSystem
|
||||
import com.mojang.blaze3d.vertex.PoseStack
|
||||
import com.mojang.math.Axis
|
||||
import net.minecraft.client.renderer.MultiBufferSource
|
||||
import net.minecraft.client.renderer.block.model.ItemTransforms
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider
|
||||
import net.minecraft.world.item.ItemDisplayContext
|
||||
import ru.dbotthepony.mc.otm.block.entity.matter.MatterScannerBlockEntity
|
||||
import ru.dbotthepony.mc.otm.client.render.DynamicBufferSource
|
||||
import ru.dbotthepony.mc.otm.client.render.lockBlendFunc
|
||||
@ -41,12 +41,11 @@ class MatterScannerRenderer(private val context: BlockEntityRendererProvider.Con
|
||||
|
||||
context.itemRenderer.renderStatic(
|
||||
item,
|
||||
ItemDisplayContext.FIXED,
|
||||
ItemTransforms.TransformType.FIXED,
|
||||
packedLight,
|
||||
packedOverlay,
|
||||
pose,
|
||||
source,
|
||||
tile.level,
|
||||
tile.blockPos.asLong().toInt()
|
||||
)
|
||||
|
||||
|
@ -2,9 +2,9 @@ package ru.dbotthepony.mc.otm.client.render.blockentity
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack
|
||||
import net.minecraft.client.renderer.MultiBufferSource
|
||||
import net.minecraft.client.renderer.block.model.ItemTransforms
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider
|
||||
import net.minecraft.world.item.ItemDisplayContext
|
||||
import ru.dbotthepony.mc.otm.block.entity.tech.AbstractPoweredFurnaceBlockEntity
|
||||
import ru.dbotthepony.mc.otm.core.math.normalizeAngle
|
||||
import ru.dbotthepony.mc.otm.core.math.rotateY
|
||||
@ -39,7 +39,7 @@ class PoweredSmokerRenderer(private val context: BlockEntityRendererProvider.Con
|
||||
|
||||
context.itemRenderer.render(
|
||||
slot.inputItem,
|
||||
ItemDisplayContext.NONE,
|
||||
ItemTransforms.TransformType.NONE,
|
||||
false,
|
||||
pose,
|
||||
buffers,
|
||||
@ -57,7 +57,7 @@ class PoweredSmokerRenderer(private val context: BlockEntityRendererProvider.Con
|
||||
|
||||
context.itemRenderer.render(
|
||||
slot.outputItem,
|
||||
ItemDisplayContext.NONE,
|
||||
ItemTransforms.TransformType.NONE,
|
||||
false,
|
||||
pose,
|
||||
buffers,
|
||||
|
@ -1,11 +1,12 @@
|
||||
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
|
||||
@ -23,7 +24,6 @@ import ru.dbotthepony.mc.otm.client.render.MGUIGraphics
|
||||
import ru.dbotthepony.mc.otm.client.moveMousePosScaled
|
||||
import ru.dbotthepony.mc.otm.client.render.WidgetLocation
|
||||
import ru.dbotthepony.mc.otm.client.render.Widgets18
|
||||
import ru.dbotthepony.mc.otm.client.render.translation
|
||||
import ru.dbotthepony.mc.otm.client.screen.panels.*
|
||||
import ru.dbotthepony.mc.otm.client.screen.panels.button.DeviceControls
|
||||
import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel
|
||||
@ -46,8 +46,6 @@ import ru.dbotthepony.mc.otm.client.screen.widget.WidePowerGaugePanel
|
||||
import ru.dbotthepony.mc.otm.client.screen.widget.WideProfiledPowerGaugePanel
|
||||
import ru.dbotthepony.mc.otm.config.ClientConfig
|
||||
import ru.dbotthepony.mc.otm.core.TranslatableComponent
|
||||
import ru.dbotthepony.mc.otm.core.math.component1
|
||||
import ru.dbotthepony.mc.otm.core.math.component2
|
||||
import ru.dbotthepony.mc.otm.core.math.integerDivisionDown
|
||||
import ru.dbotthepony.mc.otm.menu.MatteryMenu
|
||||
import ru.dbotthepony.mc.otm.menu.MatterySlot
|
||||
@ -89,28 +87,37 @@ abstract class MatteryScreen<T : MatteryMenu>(menu: T, inventory: Inventory, tit
|
||||
val quickCraftingType: Int get() = super.quickCraftingType
|
||||
val isQuickCrafting: Boolean get() = super.isQuickCrafting
|
||||
|
||||
fun renderItemStack(graphics: MGUIGraphics, itemstack: ItemStack, countOverride: String? = null) {
|
||||
fun renderItemStack(absoluteX: Float, absoluteY: Float, itemstack: ItemStack, countOverride: String? = null) {
|
||||
if (!itemstack.isEmpty) {
|
||||
RenderSystem.enableDepthTest()
|
||||
|
||||
val (x, y) = graphics.pose.translation()
|
||||
val systemPoseStack = RenderSystem.getModelViewStack()
|
||||
|
||||
graphics.parent.renderItem(
|
||||
systemPoseStack.pushPose()
|
||||
systemPoseStack.translate(absoluteX + 1f, absoluteY + 1f, 0f)
|
||||
RenderSystem.applyModelViewMatrix()
|
||||
RenderSystem.depthFunc(GL11.GL_LESS)
|
||||
|
||||
// Thanks Mojang
|
||||
// Very cool
|
||||
// (for int x, int y, which are then cast into doubles anyway)
|
||||
itemRenderer.blitOffset = 1f // Z pos
|
||||
|
||||
itemRenderer.renderAndDecorateItem(
|
||||
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()
|
||||
0,
|
||||
0,
|
||||
(absoluteX + absoluteY * 1000f).toInt()
|
||||
)
|
||||
|
||||
RenderSystem.depthFunc(GL11.GL_ALWAYS)
|
||||
graphics.parent.renderItemDecorations(
|
||||
super.font,
|
||||
itemstack,
|
||||
1,
|
||||
1,
|
||||
countOverride
|
||||
)
|
||||
itemRenderer.renderGuiItemDecorations(super.font, itemstack, 0, 0, countOverride)
|
||||
itemRenderer.blitOffset = 0f
|
||||
|
||||
// too big accumulations can lead to Z near clipping issues
|
||||
systemPoseStack.popPose()
|
||||
RenderSystem.applyModelViewMatrix()
|
||||
}
|
||||
}
|
||||
|
||||
@ -569,7 +576,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 +621,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 +654,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 +687,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 +715,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(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
|
||||
|
@ -5,11 +5,8 @@ import com.mojang.blaze3d.platform.InputConstants
|
||||
import com.mojang.blaze3d.systems.RenderSystem
|
||||
import it.unimi.dsi.fastutil.ints.IntAVLTreeSet
|
||||
import it.unimi.dsi.fastutil.objects.ReferenceArraySet
|
||||
import net.minecraft.client.gui.ComponentPath
|
||||
import net.minecraft.client.gui.Font
|
||||
import net.minecraft.client.gui.components.events.GuiEventListener
|
||||
import net.minecraft.client.gui.navigation.FocusNavigationEvent
|
||||
import net.minecraft.client.gui.navigation.ScreenRectangle
|
||||
import net.minecraft.client.gui.screens.Screen
|
||||
import net.minecraft.client.renderer.Rect2i
|
||||
import net.minecraft.network.chat.Component
|
||||
@ -71,17 +68,15 @@ open class EditablePanel<out S : Screen>(
|
||||
) : Comparable<EditablePanel<*>> {
|
||||
// layout engine does not support navigation using keyboard
|
||||
val listener: GuiEventListener = object : GuiEventListener {
|
||||
override fun setFocused(p_265728_: Boolean) {
|
||||
override fun changeFocus(p_265728_: Boolean): Boolean {
|
||||
if (p_265728_) {
|
||||
if (isVisible())
|
||||
requestFocus()
|
||||
} else {
|
||||
killFocus()
|
||||
}
|
||||
}
|
||||
|
||||
override fun isFocused(): Boolean {
|
||||
return isEverFocused()
|
||||
return true
|
||||
}
|
||||
|
||||
override fun mouseMoved(p_94758_: Double, p_94759_: Double) {
|
||||
@ -100,7 +95,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)
|
||||
}
|
||||
|
||||
@ -116,22 +111,9 @@ open class EditablePanel<out S : Screen>(
|
||||
return this@EditablePanel.charTyped(p_94732_, p_94733_)
|
||||
}
|
||||
|
||||
override fun nextFocusPath(p_265234_: FocusNavigationEvent): ComponentPath? {
|
||||
return null
|
||||
}
|
||||
|
||||
override fun isMouseOver(p_94748_: Double, p_94749_: Double): Boolean {
|
||||
return this@EditablePanel.isMouseOver(p_94748_, p_94749_)
|
||||
}
|
||||
|
||||
override fun getCurrentFocusPath(): ComponentPath? {
|
||||
return null
|
||||
}
|
||||
|
||||
override fun getRectangle(): ScreenRectangle {
|
||||
val rect = calculateAbsoluteRectangle()
|
||||
return ScreenRectangle(rect.x.toInt(), rect.y.toInt(), rect.width.toInt(), rect.height.toInt())
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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,15 @@ class EntityRendererPanel<out S : Screen> @JvmOverloads constructor(
|
||||
return
|
||||
}
|
||||
|
||||
InventoryScreen.renderEntityInInventoryFollowsMouse(
|
||||
graphics.parent,
|
||||
0, 0,
|
||||
this.width.toInt(), this.height.toInt(),
|
||||
val renderX = absoluteX.toInt() + width.toInt() / 2
|
||||
val renderY = absoluteY.toInt() + (height * 0.9f).toInt()
|
||||
|
||||
InventoryScreen.renderEntityInInventory(
|
||||
renderX,
|
||||
renderY,
|
||||
renderScale,
|
||||
0f,
|
||||
mouseX - absoluteX.toInt(),
|
||||
mouseY - absoluteY + height * 0.15f,
|
||||
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)
|
||||
}
|
||||
|
||||
@ -69,12 +70,8 @@ class Panel2Widget<out S: Screen, out P : EditablePanel<S>>(
|
||||
return panel.isMouseOver(p_94748_, p_94749_)
|
||||
}
|
||||
|
||||
override fun setFocused(p_265728_: Boolean) {
|
||||
override fun changeFocus(p_265728_: Boolean): Boolean {
|
||||
// no op
|
||||
}
|
||||
|
||||
override fun isFocused(): Boolean {
|
||||
// ага, щас
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
@ -34,11 +34,11 @@ open class EditBoxPanel<out S : Screen>(
|
||||
}
|
||||
|
||||
override fun configureNew(widget: EditBox, recreation: Boolean) {
|
||||
widget.isFocused = isFocusedThis
|
||||
widget.changeFocus(isFocusedThis)
|
||||
}
|
||||
|
||||
override fun onFocusChanged() {
|
||||
widget?.isFocused = isFocusedThis
|
||||
widget?.changeFocus(isFocusedThis)
|
||||
}
|
||||
|
||||
override fun mouseClickedInner(x: Double, y: Double, button: Int): Boolean {
|
||||
@ -49,7 +49,7 @@ open class EditBoxPanel<out S : Screen>(
|
||||
|
||||
override fun keyPressedInternal(key: Int, scancode: Int, mods: Int): Boolean {
|
||||
if (key == InputConstants.KEY_ESCAPE && widget?.isActive == true) {
|
||||
widget?.isFocused = false
|
||||
widget?.changeFocus(false)
|
||||
return true
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
@ -35,7 +34,7 @@ abstract class AbstractSlotPanel<out S : MatteryScreen<*>>(
|
||||
RenderSystem.setShader(GameRenderer::getPositionTexShader)
|
||||
|
||||
if (!itemstack.isEmpty) {
|
||||
screen.renderItemStack(graphics, itemstack, countOverride)
|
||||
screen.renderItemStack(absoluteX, absoluteY, itemstack, countOverride)
|
||||
clearDepth(graphics)
|
||||
}
|
||||
|
||||
@ -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
|
||||
|
@ -44,7 +44,7 @@ abstract class UserFilteredSlotPanel<out S : MatteryScreen<*>, out T : Slot>(
|
||||
if (slotFilter !== Items.AIR) {
|
||||
val itemStack = ItemStack(slotFilter!!, 1)
|
||||
|
||||
screen.renderItemStack(graphics, itemStack, null)
|
||||
screen.renderItemStack(absoluteX, absoluteY, itemStack, null)
|
||||
clearDepth(graphics)
|
||||
|
||||
graphics.renderRect(0f, 0f, width, height, color = SLOT_FILTER_COLOR)
|
||||
|
@ -318,7 +318,7 @@ private class AndroidResearchButton(
|
||||
val stack = graphics.pose
|
||||
stack.pushPose()
|
||||
stack.translate(1f, 1f, 0f)
|
||||
screen.renderItemStack(graphics, itemstack)
|
||||
screen.renderItemStack(absoluteX, absoluteY, itemstack)
|
||||
stack.popPose()
|
||||
|
||||
clearDepth(graphics)
|
||||
|
@ -4,17 +4,15 @@ import earth.terrarium.ad_astra.AdAstra
|
||||
import earth.terrarium.ad_astra.common.data.Planet
|
||||
import earth.terrarium.ad_astra.common.data.PlanetData
|
||||
import earth.terrarium.ad_astra.common.item.armor.SpaceSuit
|
||||
import earth.terrarium.ad_astra.common.registry.ModDamageSources
|
||||
import earth.terrarium.ad_astra.common.registry.ModDamageSource
|
||||
import net.minecraft.world.entity.player.Player
|
||||
import net.minecraftforge.event.entity.living.LivingHurtEvent
|
||||
import net.minecraftforge.fml.ModList
|
||||
import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability
|
||||
import ru.dbotthepony.mc.otm.capability.matteryPlayer
|
||||
import ru.dbotthepony.mc.otm.config.ServerCompatConfig
|
||||
import ru.dbotthepony.mc.otm.core.damageType
|
||||
import ru.dbotthepony.mc.otm.registry.MDamageTypes
|
||||
import ru.dbotthepony.mc.otm.registry.CosmicRaysDamageSource
|
||||
import ru.dbotthepony.mc.otm.registry.MItems
|
||||
import ru.dbotthepony.mc.otm.registry.MatteryDamageSource
|
||||
|
||||
val isAdAstraLoaded by lazy {
|
||||
ModList.get().isLoaded(AdAstra.MOD_ID)
|
||||
@ -28,7 +26,7 @@ fun onDamageEvent(event: LivingHurtEvent) {
|
||||
if (ServerCompatConfig.AdAstra.ANDROIDS_DO_NOT_NEED_OXYGEN) {
|
||||
if (ply.matteryPlayer?.isAndroid != true) return
|
||||
|
||||
if (event.source.`is`(ModDamageSources.OXYGEN)) {
|
||||
if (event.source == ModDamageSource.OXYGEN) {
|
||||
event.amount = 0f
|
||||
event.isCanceled = true
|
||||
}
|
||||
@ -52,7 +50,7 @@ fun onMatteryTick(event: MatteryPlayerCapability.PostTick) {
|
||||
val yesTritanium = yesTritanium0 + yesTritanium1
|
||||
|
||||
if (rand.nextDouble() <= (noSpacesuits - yesTritanium) * ServerCompatConfig.AdAstra.ANDROID_COSMIC_RAYS_CHANCE) {
|
||||
event.player.hurt(MatteryDamageSource(event.level.registryAccess().damageType(MDamageTypes.COSMIC_RAYS)), 1f)
|
||||
event.player.hurt(CosmicRaysDamageSource(), 1f)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
)
|
||||
)
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user