Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
96079065b6 | ||
|
|
86f91ed77a |
@@ -11,9 +11,6 @@
|
||||
- Fixed honey from Saccharine Leaves being harvestable at less than the max age.
|
||||
- Items given from interacting with Saccharine Leaves are placed in the active hotbar slot if possible.
|
||||
- Fix all Pokémon being saved to chunks and never despawning.
|
||||
- Fixed PokeSnacks crashing if there was no available spawn.
|
||||
- Fixed Pokémon spawn influences not being specific to regional forms
|
||||
- Fixed crashing when viewing another player in spectator mode
|
||||
|
||||
### Developer
|
||||
|
||||
|
||||
@@ -54,8 +54,6 @@ dependencies {
|
||||
// Flywheel has no common dep so just pick one and don't use any platform specific code in common
|
||||
// modCompileOnly(libs.flywheelFabric)
|
||||
|
||||
modCompileOnly(files("temp/vivecraft-1.21.1-1.3.4.jar")) // TODO: Switch this to a proper dependency when Vivecraft gets a maven repo
|
||||
|
||||
// Showdown
|
||||
modCompileOnly(libs.graal)
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ public class AbstractClientPlayerMixin {
|
||||
cir.setReturnValue(usageContext.getFovMultiplier());
|
||||
} else {
|
||||
// Only modify fov through riding if the pokedex is not open
|
||||
AbstractClientPlayer player = (AbstractClientPlayer) (Object) this;
|
||||
LocalPlayer player = (LocalPlayer) (Object) this;
|
||||
// Only modify fov for the driver and not the passengers
|
||||
if (player != null && player.isPassenger() && player.getVehicle() instanceof PokemonEntity && player.getVehicle().getControllingPassenger() == player) {
|
||||
PokemonEntity ride = (PokemonEntity) player.getVehicle();
|
||||
|
||||
@@ -42,8 +42,8 @@ import com.cobblemon.mod.common.api.scheduling.ServerRealTimeTaskTracker
|
||||
import com.cobblemon.mod.common.api.scheduling.ServerTaskTracker
|
||||
import com.cobblemon.mod.common.api.spawning.BestSpawner
|
||||
import com.cobblemon.mod.common.api.spawning.CobblemonSpawningZoneGenerator
|
||||
import com.cobblemon.mod.common.api.spawning.SpawningZoneGenerator
|
||||
import com.cobblemon.mod.common.api.spawning.position.AreaSpawnablePositionResolver
|
||||
import com.cobblemon.mod.common.api.spawning.SpawningZoneGenerator
|
||||
import com.cobblemon.mod.common.api.starter.StarterHandler
|
||||
import com.cobblemon.mod.common.api.stats.CobblemonStats
|
||||
import com.cobblemon.mod.common.api.storage.PokemonStoreManager
|
||||
@@ -76,8 +76,12 @@ import com.cobblemon.mod.common.config.LastChangedVersion
|
||||
import com.cobblemon.mod.common.config.constraint.IntConstraint
|
||||
import com.cobblemon.mod.common.config.starter.StarterConfig
|
||||
import com.cobblemon.mod.common.data.CobblemonDataProvider
|
||||
import com.cobblemon.mod.common.events.*
|
||||
import com.cobblemon.mod.common.integration.vivecraft.CobblemonVR
|
||||
import com.cobblemon.mod.common.events.AdvancementHandler
|
||||
import com.cobblemon.mod.common.events.EntityCallbackHandler
|
||||
import com.cobblemon.mod.common.events.CallbackHandler
|
||||
import com.cobblemon.mod.common.events.PokedexHandler
|
||||
import com.cobblemon.mod.common.events.ServerTickHandler
|
||||
import com.cobblemon.mod.common.events.StatHandler
|
||||
import com.cobblemon.mod.common.net.messages.client.settings.ServerSettingsPacket
|
||||
import com.cobblemon.mod.common.permission.LaxPermissionValidator
|
||||
import com.cobblemon.mod.common.platform.events.PlatformEvents
|
||||
@@ -131,12 +135,10 @@ object Cobblemon {
|
||||
const val MODID = CobblemonBuildDetails.MOD_ID
|
||||
const val VERSION = CobblemonBuildDetails.VERSION
|
||||
const val CONFIG_PATH = "config/$MODID/main.json"
|
||||
|
||||
@JvmField
|
||||
val LOGGER: Logger = LogManager.getLogger()
|
||||
|
||||
lateinit var implementation: CobblemonImplementation
|
||||
|
||||
@Deprecated("This field is now a config value", ReplaceWith("Cobblemon.config.captureCalculator"))
|
||||
var captureCalculator: CaptureCalculator
|
||||
get() = this.config.captureCalculator
|
||||
@@ -166,49 +168,21 @@ object Cobblemon {
|
||||
val serverPlayerStructs = mutableMapOf<UUID, ObjectValue<Player>>()
|
||||
|
||||
val statistics: CobblemonStats = CobblemonStats
|
||||
var cobblemonVR: CobblemonVR? = null
|
||||
|
||||
@JvmStatic
|
||||
val builtinPacks = listOf<CobblemonPack>(
|
||||
CobblemonPack(
|
||||
id = "adorncompatibility",
|
||||
name = "Adorn Compatibility",
|
||||
packType = PackType.CLIENT_RESOURCES,
|
||||
activationBehaviour = ResourcePackActivationBehaviour.ALWAYS_ENABLED,
|
||||
neededMods = setOf("adorn")
|
||||
),
|
||||
CobblemonPack(
|
||||
id = "gyaradosjump",
|
||||
name = "Gyarados Jump Patterns",
|
||||
packType = PackType.CLIENT_RESOURCES,
|
||||
activationBehaviour = ResourcePackActivationBehaviour.DEFAULT_ENABLED
|
||||
),
|
||||
CobblemonPack(
|
||||
id = "regionbiasforms",
|
||||
name = "Region Bias Forms",
|
||||
packType = PackType.CLIENT_RESOURCES,
|
||||
activationBehaviour = ResourcePackActivationBehaviour.DEFAULT_ENABLED
|
||||
),
|
||||
CobblemonPack(
|
||||
id = "uniqueshinyforms",
|
||||
name = "Shinies for Magikarp Jump",
|
||||
packType = PackType.CLIENT_RESOURCES,
|
||||
activationBehaviour = ResourcePackActivationBehaviour.NORMAL
|
||||
),
|
||||
CobblemonPack(id = "adorncompatibility", name = "Adorn Compatibility", packType = PackType.CLIENT_RESOURCES, activationBehaviour = ResourcePackActivationBehaviour.ALWAYS_ENABLED, neededMods = setOf("adorn")),
|
||||
CobblemonPack(id = "gyaradosjump", name = "Gyarados Jump Patterns", packType = PackType.CLIENT_RESOURCES, activationBehaviour = ResourcePackActivationBehaviour.DEFAULT_ENABLED),
|
||||
CobblemonPack(id = "regionbiasforms", name = "Region Bias Forms", packType = PackType.CLIENT_RESOURCES, activationBehaviour = ResourcePackActivationBehaviour.DEFAULT_ENABLED),
|
||||
CobblemonPack(id = "uniqueshinyforms", name = "Shinies for Magikarp Jump", packType = PackType.CLIENT_RESOURCES, activationBehaviour = ResourcePackActivationBehaviour.NORMAL),
|
||||
|
||||
CobblemonPack(
|
||||
id = "repurposedstructurescobblemon",
|
||||
name = "Repurposed Structures Cobblemon",
|
||||
packType = PackType.SERVER_DATA,
|
||||
activationBehaviour = ResourcePackActivationBehaviour.DEFAULT_ENABLED,
|
||||
neededMods = setOf("repurposed_structures")
|
||||
),
|
||||
CobblemonPack(id = "repurposedstructurescobblemon", name = "Repurposed Structures Cobblemon", packType = PackType.SERVER_DATA, activationBehaviour = ResourcePackActivationBehaviour.DEFAULT_ENABLED, neededMods = setOf("repurposed_structures")),
|
||||
)
|
||||
|
||||
fun preInitialize(implementation: CobblemonImplementation) {
|
||||
this.implementation = implementation
|
||||
|
||||
this.LOGGER.info("Launching Cobblemon ${CobblemonBuildDetails.VERSION}${if (CobblemonBuildDetails.SNAPSHOT) "-SNAPSHOT" else ""} ")
|
||||
this.LOGGER.info("Launching Cobblemon ${CobblemonBuildDetails.VERSION}${if(CobblemonBuildDetails.SNAPSHOT) "-SNAPSHOT" else ""} ")
|
||||
if (CobblemonBuildDetails.SNAPSHOT) {
|
||||
this.LOGGER.info(" - Git Commit: ${smallCommitHash()} (https://gitlab.com/cable-mc/cobblemon/-/commit/${CobblemonBuildDetails.GIT_COMMIT})")
|
||||
this.LOGGER.info(" - Branch: ${CobblemonBuildDetails.BRANCH}")
|
||||
@@ -220,6 +194,7 @@ object Cobblemon {
|
||||
implementation.registerSoundEvents()
|
||||
implementation.registerDataComponents()
|
||||
implementation.registerBlocks()
|
||||
implementation.registerArmorMaterials()
|
||||
implementation.registerItems()
|
||||
implementation.registerEntityTypes()
|
||||
implementation.registerEntityAttributes()
|
||||
@@ -272,10 +247,7 @@ object Cobblemon {
|
||||
}
|
||||
|
||||
PlatformEvents.RIGHT_CLICK_ENTITY.subscribe { event ->
|
||||
if (event.player.getItemInHand(event.hand).item is NameTagItem && event.entity.type.`is`(
|
||||
CobblemonEntityTypeTags.CANNOT_HAVE_NAME_TAG
|
||||
)
|
||||
) {
|
||||
if (event.player.getItemInHand(event.hand).item is NameTagItem && event.entity.type.`is`(CobblemonEntityTypeTags.CANNOT_HAVE_NAME_TAG)) {
|
||||
event.cancel()
|
||||
}
|
||||
}
|
||||
@@ -286,10 +258,7 @@ object Cobblemon {
|
||||
pokemon.lockedEvolutions
|
||||
.filterIsInstance<BlockClickEvolution>()
|
||||
.forEach { evolution ->
|
||||
evolution.attemptEvolution(
|
||||
pokemon,
|
||||
BlockClickEvolution.BlockInteractionContext(block, player.level())
|
||||
)
|
||||
evolution.attemptEvolution(pokemon, BlockClickEvolution.BlockInteractionContext(block, player.level()))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -349,11 +318,6 @@ object Cobblemon {
|
||||
SlowpokeTailRegrowthSpeciesFeatureProvider
|
||||
)
|
||||
|
||||
if (implementation.isModInstalled("vivecraft")) { // VR integration
|
||||
cobblemonVR = CobblemonVR()
|
||||
cobblemonVR?.init()
|
||||
}
|
||||
|
||||
CustomPokemonProperty.register(UncatchableProperty)
|
||||
CustomPokemonProperty.register(BattleCloneProperty)
|
||||
CustomPokemonProperty.register(PokemonFlagProperty)
|
||||
@@ -373,7 +337,7 @@ object Cobblemon {
|
||||
}
|
||||
|
||||
PlatformEvents.SERVER_TICK_POST.subscribe {
|
||||
ServerTaskTracker.update(1 / 20F)
|
||||
ServerTaskTracker.update(1/20F)
|
||||
ServerRealTimeTaskTracker.update()
|
||||
}
|
||||
PlatformEvents.SERVER_TICK_PRE.subscribe {
|
||||
@@ -417,22 +381,10 @@ object Cobblemon {
|
||||
.applyConnectionString(ConnectionString(config.mongoDBConnectionString))
|
||||
.build()
|
||||
mongoClient = MongoClients.create(mongoClientSettings)
|
||||
val generalMongoFactory = CachedPlayerDataStoreFactory(
|
||||
PlayerDataMongoBackend(
|
||||
mongoClient,
|
||||
config.mongoDBDatabaseName,
|
||||
"PlayerDataCollection"
|
||||
)
|
||||
)
|
||||
val generalMongoFactory = CachedPlayerDataStoreFactory(PlayerDataMongoBackend(mongoClient, config.mongoDBDatabaseName, "PlayerDataCollection"))
|
||||
generalMongoFactory.setup(server)
|
||||
|
||||
val pokedexMongoFactory = CachedPlayerDataStoreFactory(
|
||||
DexDataMongoBackend(
|
||||
mongoClient,
|
||||
config.mongoDBDatabaseName,
|
||||
"PokeDexCollection"
|
||||
)
|
||||
)
|
||||
val pokedexMongoFactory = CachedPlayerDataStoreFactory(DexDataMongoBackend(mongoClient, config.mongoDBDatabaseName, "PokeDexCollection"))
|
||||
pokedexMongoFactory.setup(server)
|
||||
|
||||
playerDataManager.setFactory(generalMongoFactory, PlayerInstancedDataStoreTypes.GENERAL)
|
||||
@@ -554,7 +506,6 @@ object Cobblemon {
|
||||
field.set(config, field.get(defaultConfig))
|
||||
}
|
||||
}
|
||||
|
||||
is IntConstraint -> {
|
||||
var value = field.get(config)
|
||||
if (value is Int) {
|
||||
@@ -607,76 +558,20 @@ object Cobblemon {
|
||||
}
|
||||
|
||||
private fun registerArgumentTypes() {
|
||||
this.implementation.registerCommandArgument(
|
||||
cobblemonResource("pokemon"),
|
||||
SpeciesArgumentType::class,
|
||||
SingletonArgumentInfo.contextFree(SpeciesArgumentType::species)
|
||||
)
|
||||
this.implementation.registerCommandArgument(
|
||||
cobblemonResource("pokemon_properties"),
|
||||
PokemonPropertiesArgumentType::class,
|
||||
SingletonArgumentInfo.contextFree(PokemonPropertiesArgumentType::properties)
|
||||
)
|
||||
this.implementation.registerCommandArgument(
|
||||
cobblemonResource("spawn_bucket"),
|
||||
SpawnBucketArgumentType::class,
|
||||
SingletonArgumentInfo.contextFree(SpawnBucketArgumentType::spawnBucket)
|
||||
)
|
||||
this.implementation.registerCommandArgument(
|
||||
cobblemonResource("move"),
|
||||
MoveArgumentType::class,
|
||||
SingletonArgumentInfo.contextFree(MoveArgumentType::move)
|
||||
)
|
||||
this.implementation.registerCommandArgument(
|
||||
cobblemonResource("party_slot"),
|
||||
PartySlotArgumentType::class,
|
||||
SingletonArgumentInfo.contextFree(PartySlotArgumentType::partySlot)
|
||||
)
|
||||
this.implementation.registerCommandArgument(
|
||||
cobblemonResource("pokemon_store"),
|
||||
PokemonStoreArgumentType::class,
|
||||
SingletonArgumentInfo.contextFree(PokemonStoreArgumentType::pokemonStore)
|
||||
)
|
||||
this.implementation.registerCommandArgument(
|
||||
cobblemonResource("dialogue"),
|
||||
DialogueArgumentType::class,
|
||||
SingletonArgumentInfo.contextFree(DialogueArgumentType::dialogue)
|
||||
)
|
||||
this.implementation.registerCommandArgument(
|
||||
cobblemonResource("form"),
|
||||
FormArgumentType::class,
|
||||
SingletonArgumentInfo.contextFree(FormArgumentType::form)
|
||||
)
|
||||
this.implementation.registerCommandArgument(
|
||||
cobblemonResource("dex"),
|
||||
DexArgumentType::class,
|
||||
SingletonArgumentInfo.contextFree(DexArgumentType::dex)
|
||||
)
|
||||
this.implementation.registerCommandArgument(
|
||||
cobblemonResource("npc_class"),
|
||||
NPCClassArgumentType::class,
|
||||
SingletonArgumentInfo.contextFree(NPCClassArgumentType::npcClass)
|
||||
)
|
||||
this.implementation.registerCommandArgument(
|
||||
cobblemonResource("wallpaper"),
|
||||
UnlockablePCBoxWallpaperArgumentType::class,
|
||||
SingletonArgumentInfo.contextFree(UnlockablePCBoxWallpaperArgumentType::wallpaper)
|
||||
)
|
||||
this.implementation.registerCommandArgument(
|
||||
cobblemonResource("mark"),
|
||||
MarkArgumentType::class,
|
||||
SingletonArgumentInfo.contextFree(MarkArgumentType::mark)
|
||||
)
|
||||
this.implementation.registerCommandArgument(
|
||||
cobblemonResource("transform_type"),
|
||||
TransformTypeArgumentType::class,
|
||||
SingletonArgumentInfo.contextFree(TransformTypeArgumentType::transformType)
|
||||
)
|
||||
this.implementation.registerCommandArgument(
|
||||
cobblemonResource("model_part"),
|
||||
ModelPartArgumentType::class,
|
||||
SingletonArgumentInfo.contextFree(ModelPartArgumentType::modelPart)
|
||||
)
|
||||
this.implementation.registerCommandArgument(cobblemonResource("pokemon"), SpeciesArgumentType::class, SingletonArgumentInfo.contextFree(SpeciesArgumentType::species))
|
||||
this.implementation.registerCommandArgument(cobblemonResource("pokemon_properties"), PokemonPropertiesArgumentType::class, SingletonArgumentInfo.contextFree(PokemonPropertiesArgumentType::properties))
|
||||
this.implementation.registerCommandArgument(cobblemonResource("spawn_bucket"), SpawnBucketArgumentType::class, SingletonArgumentInfo.contextFree(SpawnBucketArgumentType::spawnBucket))
|
||||
this.implementation.registerCommandArgument(cobblemonResource("move"), MoveArgumentType::class, SingletonArgumentInfo.contextFree(MoveArgumentType::move))
|
||||
this.implementation.registerCommandArgument(cobblemonResource("party_slot"), PartySlotArgumentType::class, SingletonArgumentInfo.contextFree(PartySlotArgumentType::partySlot))
|
||||
this.implementation.registerCommandArgument(cobblemonResource("pokemon_store"), PokemonStoreArgumentType::class, SingletonArgumentInfo.contextFree(PokemonStoreArgumentType::pokemonStore))
|
||||
this.implementation.registerCommandArgument(cobblemonResource("dialogue"), DialogueArgumentType::class, SingletonArgumentInfo.contextFree(DialogueArgumentType::dialogue))
|
||||
this.implementation.registerCommandArgument(cobblemonResource("form"), FormArgumentType::class, SingletonArgumentInfo.contextFree(FormArgumentType::form))
|
||||
this.implementation.registerCommandArgument(cobblemonResource("dex"), DexArgumentType::class, SingletonArgumentInfo.contextFree (DexArgumentType::dex))
|
||||
this.implementation.registerCommandArgument(cobblemonResource("npc_class"), NPCClassArgumentType::class, SingletonArgumentInfo.contextFree(NPCClassArgumentType::npcClass))
|
||||
this.implementation.registerCommandArgument(cobblemonResource("wallpaper"), UnlockablePCBoxWallpaperArgumentType::class, SingletonArgumentInfo.contextFree(UnlockablePCBoxWallpaperArgumentType::wallpaper))
|
||||
this.implementation.registerCommandArgument(cobblemonResource("mark"), MarkArgumentType::class, SingletonArgumentInfo.contextFree(MarkArgumentType::mark))
|
||||
this.implementation.registerCommandArgument(cobblemonResource("transform_type"), TransformTypeArgumentType::class, SingletonArgumentInfo.contextFree(TransformTypeArgumentType::transformType))
|
||||
this.implementation.registerCommandArgument(cobblemonResource("model_part"), ModelPartArgumentType::class, SingletonArgumentInfo.contextFree(ModelPartArgumentType::modelPart))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.cobblemon.mod.common
|
||||
|
||||
import com.cobblemon.mod.common.platform.PlatformRegistry
|
||||
import com.cobblemon.mod.common.util.cobblemonResource
|
||||
import net.minecraft.core.Registry
|
||||
import net.minecraft.core.registries.BuiltInRegistries
|
||||
import net.minecraft.core.registries.Registries
|
||||
import net.minecraft.resources.ResourceKey
|
||||
import net.minecraft.sounds.SoundEvents
|
||||
import net.minecraft.world.item.ArmorItem
|
||||
import net.minecraft.world.item.ArmorMaterial
|
||||
import net.minecraft.world.item.Items
|
||||
import net.minecraft.world.item.crafting.Ingredient
|
||||
|
||||
@Suppress("unused")
|
||||
object CobblemonArmorMaterials :
|
||||
PlatformRegistry<Registry<ArmorMaterial>, ResourceKey<Registry<ArmorMaterial>>, ArmorMaterial>() {
|
||||
|
||||
override val registry: Registry<ArmorMaterial> = BuiltInRegistries.ARMOR_MATERIAL
|
||||
override val resourceKey: ResourceKey<Registry<ArmorMaterial>> = Registries.ARMOR_MATERIAL
|
||||
|
||||
@JvmField
|
||||
val MALICIOUS_ARMOR = cosmeticMaterial("malicious_armor")
|
||||
@JvmField
|
||||
val HEAVY_DUTY_BOOTS = cosmeticMaterial("heavy_duty_boots")
|
||||
@JvmField
|
||||
val PROTECTIVE_PADS = cosmeticMaterial("protective_pads")
|
||||
@JvmField
|
||||
val ASSAULT_VEST = cosmeticMaterial("assault_vest")
|
||||
@JvmField
|
||||
val MYSTIC_WATER = cosmeticMaterial("mystic_water")
|
||||
@JvmField
|
||||
val BLACK_BELT = cosmeticMaterial("black_belt")
|
||||
|
||||
private fun cosmeticMaterial(name: String): ArmorMaterial {
|
||||
val armorMaterial = ArmorMaterial(
|
||||
mapOf(
|
||||
ArmorItem.Type.HELMET to 0,
|
||||
ArmorItem.Type.CHESTPLATE to 0,
|
||||
ArmorItem.Type.LEGGINGS to 0,
|
||||
ArmorItem.Type.BOOTS to 0,
|
||||
),
|
||||
0,
|
||||
SoundEvents.ARMOR_EQUIP_GENERIC,
|
||||
{ Ingredient.EMPTY },
|
||||
listOf(ArmorMaterial.Layer(cobblemonResource(name), "", true)),
|
||||
0.0f,
|
||||
0.0f,
|
||||
)
|
||||
|
||||
return create(name, armorMaterial)
|
||||
}
|
||||
}
|
||||
@@ -64,6 +64,8 @@ interface CobblemonImplementation {
|
||||
|
||||
fun registerEntityDataSerializers()
|
||||
|
||||
fun registerArmorMaterials()
|
||||
|
||||
/**
|
||||
* TODO
|
||||
*
|
||||
|
||||
@@ -44,16 +44,21 @@ import com.cobblemon.mod.common.pokeball.PokeBall
|
||||
import com.cobblemon.mod.common.pokemon.IVs
|
||||
import com.cobblemon.mod.common.pokemon.helditem.CobblemonHeldItemManager
|
||||
import com.cobblemon.mod.common.util.cobblemonResource
|
||||
import net.minecraft.core.Holder
|
||||
import net.minecraft.core.Registry
|
||||
import net.minecraft.core.registries.BuiltInRegistries
|
||||
import net.minecraft.core.registries.Registries
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.resources.ResourceKey
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
import net.minecraft.sounds.SoundEvents
|
||||
import net.minecraft.world.effect.MobEffectInstance
|
||||
import net.minecraft.world.effect.MobEffects
|
||||
import net.minecraft.world.entity.EquipmentSlot
|
||||
import net.minecraft.world.entity.LivingEntity
|
||||
import net.minecraft.world.food.FoodProperties
|
||||
import net.minecraft.world.item.ArmorItem
|
||||
import net.minecraft.world.item.ArmorMaterial
|
||||
import net.minecraft.world.item.BlockItem
|
||||
import net.minecraft.world.item.HangingSignItem
|
||||
import net.minecraft.world.item.Item
|
||||
@@ -501,8 +506,6 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
|
||||
@JvmField val RAZOR_CLAW = noSettingsItem("razor_claw")
|
||||
@JvmField val RAZOR_FANG = noSettingsItem("razor_fang")
|
||||
@JvmField val AUSPICIOUS_ARMOR = heldItem("auspicious_armor")
|
||||
@JvmField val MALICIOUS_ARMOR = heldItem("malicious_armor")
|
||||
@JvmField val SHELL_HELMET = heldItem("shell_helmet")
|
||||
@JvmField val METAL_ALLOY = noSettingsItem("metal_alloy")
|
||||
@JvmField val SCROLL_OF_DARKNESS = noSettingsItem("scroll_of_darkness")
|
||||
@JvmField val SCROLL_OF_WATERS = noSettingsItem("scroll_of_waters")
|
||||
@@ -892,7 +895,8 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
|
||||
val WATER_STONE = noSettingsItem("water_stone")
|
||||
|
||||
val wearables = mutableListOf<WearableItem>()
|
||||
//Wearable items (these items should have a corresponding 3D model)
|
||||
|
||||
// Wearable items (these items should have a corresponding 3D model)
|
||||
@JvmField val BLACK_GLASSES = wearableItem("black_glasses")
|
||||
@JvmField val CHOICE_BAND = wearableItem("choice_band")
|
||||
@JvmField val CHOICE_SPECS = wearableItem("choice_specs")
|
||||
@@ -903,6 +907,20 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
|
||||
@JvmField val ROCKY_HELMET = wearableItem("rocky_helmet")
|
||||
@JvmField val SAFETY_GOGGLES = wearableItem("safety_goggles")
|
||||
@JvmField val WISE_GLASSES = wearableItem("wise_glasses")
|
||||
@JvmField val SHELL_HELMET = wearableItem("shell_helmet")
|
||||
|
||||
@JvmField
|
||||
val MALICIOUS_ARMOR = armorItem("malicious_armor", CobblemonArmorMaterials.MALICIOUS_ARMOR, ArmorItem.Type.CHESTPLATE)
|
||||
@JvmField
|
||||
val HEAVY_DUTY_BOOTS = armorItem("heavy_duty_boots", CobblemonArmorMaterials.HEAVY_DUTY_BOOTS, ArmorItem.Type.BOOTS)
|
||||
@JvmField
|
||||
val PROTECTIVE_PADS = armorItem("protective_pads", CobblemonArmorMaterials.PROTECTIVE_PADS, ArmorItem.Type.CHESTPLATE)
|
||||
@JvmField
|
||||
val ASSAULT_VEST = armorItem("assault_vest", CobblemonArmorMaterials.ASSAULT_VEST, ArmorItem.Type.CHESTPLATE)
|
||||
@JvmField
|
||||
val MYSTIC_WATER = armorItem("mystic_water", CobblemonArmorMaterials.MYSTIC_WATER, ArmorItem.Type.CHESTPLATE)
|
||||
@JvmField
|
||||
val BLACK_BELT = armorItem("black_belt", CobblemonArmorMaterials.BLACK_BELT, ArmorItem.Type.CHESTPLATE)
|
||||
|
||||
// Held Items
|
||||
@JvmField
|
||||
@@ -912,14 +930,10 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
|
||||
@JvmField
|
||||
val AIR_BALLOON = heldItem("air_balloon")
|
||||
@JvmField
|
||||
val ASSAULT_VEST = heldItem("assault_vest")
|
||||
@JvmField
|
||||
val BIG_ROOT = compostableBlockItem("big_root", CobblemonBlocks.BIG_ROOT, 0.30f)
|
||||
@JvmField
|
||||
val BINDING_BAND = heldItem("binding_band")
|
||||
@JvmField
|
||||
val BLACK_BELT = heldItem("black_belt")
|
||||
@JvmField
|
||||
val BLACK_SLUDGE = heldItem("black_sludge")
|
||||
@JvmField
|
||||
val BLUNDER_POLICY = heldItem("blunder_policy")
|
||||
@@ -966,8 +980,6 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
|
||||
@JvmField
|
||||
val HARD_STONE = heldItem("hard_stone")
|
||||
@JvmField
|
||||
val HEAVY_DUTY_BOOTS = heldItem("heavy_duty_boots")
|
||||
@JvmField
|
||||
val IRON_BALL = heldItem("iron_ball")
|
||||
@JvmField
|
||||
val LAGGING_TAIL = heldItem("lagging_tail")
|
||||
@@ -992,8 +1004,6 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
|
||||
@JvmField
|
||||
val MIRACLE_SEED = heldItem("miracle_seed")
|
||||
@JvmField
|
||||
val MYSTIC_WATER = heldItem("mystic_water")
|
||||
@JvmField
|
||||
val NEVER_MELT_ICE = heldItem("never_melt_ice")
|
||||
@JvmField
|
||||
val POISON_BARB = heldItem("poison_barb")
|
||||
@@ -1012,8 +1022,6 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
|
||||
@JvmField
|
||||
val PSYCHIC_SEED = heldItem("psychic_seed")
|
||||
@JvmField
|
||||
val PROTECTIVE_PADS = heldItem("protective_pads")
|
||||
@JvmField
|
||||
val PUNCHING_GLOVE = heldItem("punching_glove")
|
||||
@JvmField
|
||||
val QUICK_CLAW = heldItem("quick_claw")
|
||||
@@ -1491,9 +1499,13 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
|
||||
return item
|
||||
}
|
||||
|
||||
private fun wearableItem(name: String, heldItemRemappedName: String? = null): CobblemonItem = create(
|
||||
private fun wearableItem(
|
||||
name: String,
|
||||
heldItemRemappedName: String? = null,
|
||||
equipmentSlot: EquipmentSlot = EquipmentSlot.HEAD,
|
||||
): CobblemonItem = create(
|
||||
name,
|
||||
WearableItem(name).also {
|
||||
WearableItem(name, equipmentSlot).also {
|
||||
wearables.add(it)
|
||||
if (heldItemRemappedName != null) {
|
||||
CobblemonHeldItemManager.registerRemap(it, heldItemRemappedName)
|
||||
@@ -1501,6 +1513,21 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
|
||||
}
|
||||
)
|
||||
|
||||
private fun armorItem(
|
||||
name: String,
|
||||
armorMaterial: ArmorMaterial,
|
||||
armorType: ArmorItem.Type,
|
||||
durability: Int? = null,
|
||||
): ArmorItem {
|
||||
var properties = Properties()
|
||||
if (durability != null) properties = properties.durability(durability)
|
||||
val armorMaterialHolder = BuiltInRegistries.ARMOR_MATERIAL.wrapAsHolder(armorMaterial)
|
||||
|
||||
val armorItem = ArmorItem(armorMaterialHolder, armorType, properties)
|
||||
|
||||
return create(name, armorItem)
|
||||
}
|
||||
|
||||
private fun campfirePotItem(block: Block, color: CampfirePotColor): CampfirePotItem {
|
||||
val item = create("campfire_pot_${color.suffix}", CampfirePotItem(block, color))
|
||||
campfire_pots.add(item)
|
||||
|
||||
@@ -44,7 +44,11 @@ abstract class SpawnAction<R>(
|
||||
|
||||
spawnablePosition.applyInfluences { it.affectAction(this) }
|
||||
val result = run()
|
||||
future.complete(result)
|
||||
if (result != null) {
|
||||
future.complete(result)
|
||||
} else {
|
||||
future.completeExceptionally(Exception("Nothing was spawned."))
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
@@ -61,9 +61,7 @@ open class SpawnBaitInfluence(val effects: List<SpawnBait.Effect>, val onUsed: (
|
||||
val baitEVStat = effects.firstOrNull { it.type == Effects.EV }?.subcategory?.path?.let { Stats.getStat(it) }
|
||||
|
||||
if (detailSpecies != null && baitEVStat != null) {
|
||||
val detailAspects = detail.pokemon.aspects
|
||||
val formData = detailSpecies.getForm(detailAspects)
|
||||
val evYieldValue = formData.evYield[baitEVStat]?.toFloat() ?: 0f
|
||||
val evYieldValue = detailSpecies.evYield[baitEVStat]?.toFloat() ?: 0f
|
||||
return when {
|
||||
evYieldValue > 0 -> {
|
||||
markUsed()
|
||||
@@ -85,9 +83,7 @@ open class SpawnBaitInfluence(val effects: List<SpawnBait.Effect>, val onUsed: (
|
||||
val baitTypingEffect = baitEffect?.subcategory?.path?.let { ElementalTypes.get(it) }
|
||||
|
||||
if (detailSpecies != null && baitTypingEffect != null) {
|
||||
val detailAspects = detail.pokemon.aspects
|
||||
val formData = detailSpecies.getForm(detailAspects)
|
||||
val isMatchingType = formData.types.contains(baitTypingEffect)
|
||||
val isMatchingType = detailSpecies.types.contains(baitTypingEffect)
|
||||
return when {
|
||||
isMatchingType -> {
|
||||
markUsed()
|
||||
@@ -104,9 +100,6 @@ open class SpawnBaitInfluence(val effects: List<SpawnBait.Effect>, val onUsed: (
|
||||
val detailSpecies = detail.pokemon.species?.let { PokemonSpecies.getByName(it) }
|
||||
|
||||
if (detailSpecies != null) {
|
||||
val detailAspects = detail.pokemon.aspects
|
||||
val formData = detailSpecies.getForm(detailAspects)
|
||||
|
||||
// Collect all the egg group effects
|
||||
val eggGroupEffects = effects.filter { it.type == Effects.EGG_GROUP }
|
||||
|
||||
@@ -118,7 +111,7 @@ open class SpawnBaitInfluence(val effects: List<SpawnBait.Effect>, val onUsed: (
|
||||
LOGGER.warn("Unknown egg group identifier: $effectEggGroupKey")
|
||||
return@firstOrNull false
|
||||
}
|
||||
formData.eggGroups.contains(eggGroup)
|
||||
detailSpecies.eggGroups.contains(eggGroup)
|
||||
}
|
||||
|
||||
if (matchingEffect != null) {
|
||||
|
||||
@@ -8,9 +8,7 @@
|
||||
|
||||
package com.cobblemon.mod.common.client
|
||||
|
||||
import com.cobblemon.mod.common.Cobblemon
|
||||
import com.cobblemon.mod.common.Cobblemon.LOGGER
|
||||
import com.cobblemon.mod.common.Cobblemon.cobblemonVR
|
||||
import com.cobblemon.mod.common.CobblemonBlockEntities
|
||||
import com.cobblemon.mod.common.CobblemonBlocks
|
||||
import com.cobblemon.mod.common.CobblemonClientImplementation
|
||||
@@ -29,7 +27,6 @@ import com.cobblemon.mod.common.client.gui.PartyOverlayDataControl
|
||||
import com.cobblemon.mod.common.client.gui.RideControlsOverlay
|
||||
import com.cobblemon.mod.common.client.gui.battle.BattleOverlay
|
||||
import com.cobblemon.mod.common.client.gui.cookingpot.CookingPotScreen
|
||||
import com.cobblemon.mod.common.client.integration.vivecraft.CobblemonVRClient
|
||||
import com.cobblemon.mod.common.client.particle.BedrockParticleOptionsRepository
|
||||
import com.cobblemon.mod.common.client.render.ClientPlayerIcon
|
||||
import com.cobblemon.mod.common.client.render.DeferredRenderer
|
||||
@@ -75,7 +72,6 @@ import com.cobblemon.mod.common.client.tooltips.TooltipManager
|
||||
import com.cobblemon.mod.common.client.trade.ClientTrade
|
||||
import com.cobblemon.mod.common.entity.boat.CobblemonBoatType
|
||||
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity
|
||||
import com.cobblemon.mod.common.integration.vivecraft.CobblemonVR
|
||||
import com.cobblemon.mod.common.platform.events.PlatformEvents
|
||||
import com.cobblemon.mod.common.pokedex.scanner.PokedexUsageContext
|
||||
import com.cobblemon.mod.common.util.isLookingAt
|
||||
@@ -156,10 +152,6 @@ object CobblemonClient {
|
||||
this.registerTooltipManagers()
|
||||
this.registerMenuScreens()
|
||||
|
||||
if (Cobblemon.implementation.isModInstalled("vivecraft")) { // VR integration
|
||||
CobblemonVRClient.init()
|
||||
}
|
||||
|
||||
LOGGER.info("Registering custom BuiltinItemRenderers")
|
||||
CobblemonBuiltinItemRendererRegistry.register(CobblemonItems.POKEMON_MODEL, PokemonItemRenderer())
|
||||
|
||||
@@ -195,9 +187,7 @@ object CobblemonClient {
|
||||
|
||||
nearbyPokemon?.forEach { entity ->
|
||||
if (entity is PokemonEntity && !entity.isSilent && !entity.passengers.contains(player)) {
|
||||
if (player.isLookingAt(entity) && !player.isSpectator && entity.pokemon.shiny) entity.delegate.spawnShinyParticle(
|
||||
player
|
||||
)
|
||||
if (player.isLookingAt(entity) && !player.isSpectator && entity.pokemon.shiny) entity.delegate.spawnShinyParticle(player)
|
||||
entity.delegate.spawnAspectParticle()
|
||||
}
|
||||
}
|
||||
@@ -379,10 +369,7 @@ object CobblemonClient {
|
||||
this.implementation.registerBlockEntityRenderer(CobblemonBlockEntities.DISPLAY_CASE, ::DisplayCaseRenderer)
|
||||
this.implementation.registerBlockEntityRenderer(CobblemonBlockEntities.LECTERN, ::LecternBlockEntityRenderer)
|
||||
this.implementation.registerBlockEntityRenderer(CobblemonBlockEntities.CAMPFIRE, ::CampfireBlockEntityRenderer)
|
||||
this.implementation.registerBlockEntityRenderer(
|
||||
CobblemonBlockEntities.POKE_SNACK,
|
||||
::PokeSnackBlockEntityRenderer
|
||||
)
|
||||
this.implementation.registerBlockEntityRenderer(CobblemonBlockEntities.POKE_SNACK, ::PokeSnackBlockEntityRenderer)
|
||||
}
|
||||
|
||||
private fun registerEntityRenderers() {
|
||||
@@ -411,11 +398,7 @@ object CobblemonClient {
|
||||
|
||||
private fun registerItemColors() {
|
||||
implementation.registerItemColors(AprijuiceItemColorProvider, *CobblemonItems.aprijuices.toTypedArray())
|
||||
implementation.registerItemColors(
|
||||
PokeSnackItemColorProvider,
|
||||
CobblemonItems.POKE_SNACK,
|
||||
CobblemonItems.POKE_CAKE
|
||||
)
|
||||
implementation.registerItemColors(PokeSnackItemColorProvider, CobblemonItems.POKE_SNACK, CobblemonItems.POKE_CAKE)
|
||||
implementation.registerItemColors(PokeBaitItemColorProvider, CobblemonItems.POKE_BAIT)
|
||||
implementation.registerItemColors(PonigiriItemColorProvider, CobblemonItems.PONIGIRI)
|
||||
implementation.registerItemColors(SinisterTeaItemColorProvider, CobblemonItems.SINISTER_TEA)
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
package com.cobblemon.mod.common.client.integration.vivecraft
|
||||
|
||||
import com.cobblemon.mod.common.client.integration.vivecraft.party.PartyOnArm
|
||||
import com.cobblemon.mod.common.client.integration.vivecraft.proximity.ProximityManager
|
||||
import com.cobblemon.mod.common.client.integration.vivecraft.proximity.ProximityRegistration
|
||||
import com.cobblemon.mod.common.client.integration.vivecraft.listener.proximity.PokeRodBaitListener
|
||||
import org.vivecraft.api.data.VRBodyPart
|
||||
|
||||
class CobblemonVRClient {
|
||||
|
||||
companion object {
|
||||
fun init() {
|
||||
PartyOnArm.init()
|
||||
ProximityManager.init()
|
||||
ProximityManager.register(
|
||||
ProximityRegistration(
|
||||
bodyA = VRBodyPart.MAIN_HAND,
|
||||
bodyB = VRBodyPart.OFF_HAND,
|
||||
distanceThreshold = 0.25f,
|
||||
angleThreshold = 120f,
|
||||
listener = PokeRodBaitListener("Main-OffHand")
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
package com.cobblemon.mod.common.client.integration.vivecraft.listener.proximity
|
||||
|
||||
import com.cobblemon.mod.common.Cobblemon
|
||||
import com.cobblemon.mod.common.CobblemonNetwork
|
||||
import com.cobblemon.mod.common.api.tags.CobblemonItemTags
|
||||
import com.cobblemon.mod.common.client.integration.vivecraft.proximity.ProximityListener
|
||||
import com.cobblemon.mod.common.client.integration.vivecraft.proximity.ProximityRegistration
|
||||
import com.cobblemon.mod.common.net.messages.server.pokerod.ApplyBaitPacket
|
||||
import net.minecraft.client.Minecraft
|
||||
import net.minecraft.world.InteractionHand
|
||||
import net.minecraft.world.item.ItemStack
|
||||
import org.vivecraft.api.data.VRBodyPart
|
||||
import org.vivecraft.api.data.VRPose
|
||||
|
||||
class PokeRodBaitListener(private val name: String) : ProximityListener {
|
||||
//TODO: Also add that if 1 is Rod the other needs to be seasoning
|
||||
override fun isActive(registration: ProximityRegistration): Boolean {
|
||||
val player = Minecraft.getInstance().player ?: return false
|
||||
val handA: InteractionHand = VRBodyPart.toInteractionHand(registration.bodyA) ?: return false
|
||||
val itemStackA: ItemStack = player.getItemInHand(handA)
|
||||
|
||||
val handB: InteractionHand = VRBodyPart.toInteractionHand(registration.bodyB) ?: return false
|
||||
val itemStackB: ItemStack = player.getItemInHand(handB)
|
||||
|
||||
return itemStackA.`is`(CobblemonItemTags.POKE_RODS) || itemStackB.`is`(CobblemonItemTags.POKE_RODS)
|
||||
}
|
||||
|
||||
override fun onEnter(bodyA: VRBodyPart, bodyB: VRBodyPart, pose: VRPose) {
|
||||
Cobblemon.LOGGER.info("[$name] Enter: $bodyA <-> $bodyB")
|
||||
}
|
||||
|
||||
override fun onExit(bodyA: VRBodyPart, bodyB: VRBodyPart, pose: VRPose) {
|
||||
Cobblemon.LOGGER.info("[$name] Exit: $bodyA <-> $bodyB")
|
||||
}
|
||||
|
||||
override fun onTick(bodyA: VRBodyPart, bodyB: VRBodyPart, pose: VRPose) {
|
||||
Cobblemon.LOGGER.info("[$name] Proximity: $bodyA <-> $bodyB")
|
||||
CobblemonNetwork.sendToServer(ApplyBaitPacket())
|
||||
}
|
||||
}
|
||||
@@ -1,237 +0,0 @@
|
||||
package com.cobblemon.mod.common.client.integration.vivecraft.listener.swing
|
||||
|
||||
import com.cobblemon.mod.common.Cobblemon
|
||||
import net.minecraft.client.Minecraft
|
||||
import net.minecraft.world.InteractionHand
|
||||
import net.minecraft.world.entity.player.Player
|
||||
import net.minecraft.world.item.ItemStack
|
||||
import net.minecraft.world.phys.Vec3
|
||||
import org.vivecraft.api.client.VRClientAPI
|
||||
import org.vivecraft.api.client.tracker.swing.SwingContext
|
||||
import org.vivecraft.api.client.tracker.swing.SwingListener
|
||||
import org.vivecraft.api.data.VRBodyPart
|
||||
import kotlin.math.abs
|
||||
|
||||
/**
|
||||
* Listener that classifies directional swings (up, down, forward, backward, left, right)
|
||||
* using Vivecraft VR pose history and invokes handler methods for each direction.
|
||||
*
|
||||
* @param forwardDotThreshold Dot product threshold used to classify forward/back/left/right directions.
|
||||
* @param historyTicks Number of ticks used to compute velocity from historical poses.
|
||||
*/
|
||||
abstract class DirectionalSwingListener(
|
||||
private val forwardDotThreshold: Double = 0.3,
|
||||
private val historyTicks: Int = 10
|
||||
) : SwingListener {
|
||||
|
||||
protected val minecraft: Minecraft = Minecraft.getInstance()
|
||||
protected val clientData: VRClientAPI = VRClientAPI.instance()
|
||||
|
||||
/**
|
||||
* Compute the net movement vector for the specified body part over the given number of ticks.
|
||||
* Returns null if historical pose data is unavailable, insufficient, or movement is negligible.
|
||||
*
|
||||
* @param bodyPart The VR body part to compute movement for.
|
||||
* @param ticks The number of ticks of history to consider.
|
||||
* @return The movement vector or null if unavailable/insignificant.
|
||||
*/
|
||||
private fun changeForVelocity(bodyPart: VRBodyPart, ticks: Int = historyTicks): Vec3? {
|
||||
val history = clientData.historicalVRPoses ?: return null
|
||||
if (history.ticksOfHistory() < ticks) return null
|
||||
|
||||
val delta = history.netMovement(bodyPart, ticks)
|
||||
delta?.lengthSqr()?.let { if (it < 1e-6) return null }
|
||||
|
||||
return delta
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when an upward swing is detected.
|
||||
*
|
||||
* @param useHand The hand used for the swing.
|
||||
* @param handVel The velocity vector of the hand during the swing.
|
||||
* @param player The player performing the swing.
|
||||
* @return True if the upward action was handled, false otherwise.
|
||||
*/
|
||||
protected open fun onUpwardSwing(
|
||||
useHand: InteractionHand,
|
||||
player: Player
|
||||
): Boolean {
|
||||
Cobblemon.LOGGER.info(
|
||||
"Ignoring swing: upward movement. player={}, hand={}",
|
||||
player, useHand
|
||||
)
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a downward swing is detected.
|
||||
*
|
||||
* @param useHand The hand used for the swing.
|
||||
* @param handVel The velocity vector of the hand during the swing.
|
||||
* @param player The player performing the swing.
|
||||
* @return True if the downward action was handled, false otherwise.
|
||||
*/
|
||||
protected open fun onDownwardSwing(
|
||||
useHand: InteractionHand,
|
||||
handVel: Vec3,
|
||||
player: Player
|
||||
): Boolean {
|
||||
Cobblemon.LOGGER.info(
|
||||
"Ignoring swing: downward movement. handVel={}, player={}, hand={}",
|
||||
handVel, player, useHand
|
||||
)
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a forward swing is detected.
|
||||
*
|
||||
* @param useHand The hand used for the swing.
|
||||
* @param handVel The velocity vector of the hand during the swing.
|
||||
* @param player The player performing the swing.
|
||||
* @return True if the forward action was handled, false otherwise.
|
||||
*/
|
||||
protected open fun onForwardSwing(
|
||||
useHand: InteractionHand,
|
||||
handVel: Vec3,
|
||||
player: Player
|
||||
): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a backward swing is detected.
|
||||
*
|
||||
* @param useHand The hand used for the swing.
|
||||
* @param handVel The velocity vector of the hand during the swing.
|
||||
* @param player The player performing the swing.
|
||||
* @return True if the backward action was handled, false otherwise.
|
||||
*/
|
||||
protected open fun onBackwardSwing(
|
||||
useHand: InteractionHand,
|
||||
handVel: Vec3,
|
||||
player: Player
|
||||
): Boolean {
|
||||
Cobblemon.LOGGER.info(
|
||||
"Ignoring swing: backward movement. handVel={}, player={}, hand={}",
|
||||
handVel, player, useHand
|
||||
)
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a leftward swing is detected.
|
||||
*
|
||||
* @param useHand The hand used for the swing.
|
||||
* @param handVel The velocity vector of the hand during the swing.
|
||||
* @param player The player performing the swing.
|
||||
* @return True if the leftward action was handled, false otherwise.
|
||||
*/
|
||||
protected open fun onLeftSwing(
|
||||
useHand: InteractionHand,
|
||||
handVel: Vec3,
|
||||
player: Player
|
||||
): Boolean {
|
||||
Cobblemon.LOGGER.info(
|
||||
"Ignoring swing: leftward movement. handVel={}, player={}, hand={}",
|
||||
handVel, player, useHand
|
||||
)
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a rightward swing is detected.
|
||||
*
|
||||
* @param useHand The hand used for the swing.
|
||||
* @param handVel The velocity vector of the hand during the swing.
|
||||
* @param player The player performing the swing.
|
||||
* @return True if the rightward action was handled, false otherwise.
|
||||
*/
|
||||
protected open fun onRightSwing(
|
||||
useHand: InteractionHand,
|
||||
handVel: Vec3,
|
||||
player: Player
|
||||
): Boolean {
|
||||
Cobblemon.LOGGER.info(
|
||||
"Ignoring swing: rightward movement. handVel={}, player={}, hand={}",
|
||||
handVel, player, useHand
|
||||
)
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks if the given item stack is valid for processing by this swing listener.
|
||||
* Subclasses must implement this to specify which items they handle.
|
||||
* @param itemStack The item stack to validate.
|
||||
* @return True if the item stack is valid, false otherwise.
|
||||
*/
|
||||
protected abstract fun isValidItem(itemStack: ItemStack): Boolean
|
||||
|
||||
/**
|
||||
* Called when a swing ends. Validates the held item, computes hand velocity from historical poses,
|
||||
* handles vertical swings first (upward/downward) and then classifies horizontal direction:
|
||||
* forward/backward by dot with player look direction; left/right by projecting onto a right vector
|
||||
* computed from world up and forward. Ambiguous swings are ignored.
|
||||
*
|
||||
* @param context Vivecraft swing context containing body part information.
|
||||
*/
|
||||
override fun onSwingEnd(context: SwingContext?) {
|
||||
val player = minecraft.player ?: return
|
||||
val ctx = context ?: return
|
||||
val useHand: InteractionHand = VRBodyPart.toInteractionHand(ctx.bodyPart) ?: return
|
||||
val itemStack: ItemStack = player.getItemInHand(useHand)
|
||||
|
||||
if (!isValidItem(itemStack)) return
|
||||
|
||||
val handVel = changeForVelocity(ctx.bodyPart) ?: run {
|
||||
Cobblemon.LOGGER.info(
|
||||
"Ignoring swing: insufficient historical pose data for velocity. bodyPart={}, player={}",
|
||||
ctx.bodyPart, player
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
val vertical = handVel.y
|
||||
if (vertical > 0.0) {
|
||||
if (onUpwardSwing(useHand, player)) return
|
||||
} else if (vertical < 0.0) {
|
||||
if (onDownwardSwing(useHand, handVel, player)) return
|
||||
}
|
||||
|
||||
val forward = player.lookAngle.normalize()
|
||||
val handDir = handVel.normalize()
|
||||
val forwardDot = handDir.dot(forward)
|
||||
|
||||
val worldUp = Vec3(0.0, 1.0, 0.0)
|
||||
val right = forward.cross(worldUp).let {
|
||||
if (it.lengthSqr() < 1e-6) Vec3(1.0, 0.0, 0.0) else it.normalize()
|
||||
}
|
||||
val rightDot = handDir.dot(right)
|
||||
|
||||
if (forwardDot > forwardDotThreshold) {
|
||||
if (onForwardSwing(useHand, handVel, player)) return
|
||||
return
|
||||
}
|
||||
|
||||
if (forwardDot < -forwardDotThreshold) {
|
||||
if (onBackwardSwing(useHand, handVel, player)) return
|
||||
return
|
||||
}
|
||||
|
||||
if (abs(rightDot) > forwardDotThreshold) {
|
||||
if (rightDot > 0.0) {
|
||||
if (onRightSwing(useHand, handVel, player)) return
|
||||
} else {
|
||||
if (onLeftSwing(useHand, handVel, player)) return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
Cobblemon.LOGGER.info(
|
||||
"Ignoring swing: ambiguous direction. forwardDot={}, rightDot={}, handVel={}, player={}",
|
||||
forwardDot, rightDot, handVel, player
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
package com.cobblemon.mod.common.client.integration.vivecraft.listener.swing
|
||||
|
||||
import com.cobblemon.mod.common.CobblemonNetwork
|
||||
import com.cobblemon.mod.common.api.tags.CobblemonItemTags
|
||||
import com.cobblemon.mod.common.net.messages.server.pokeball.SendOutPokeBallPacket
|
||||
import net.minecraft.world.InteractionHand
|
||||
import net.minecraft.world.entity.player.Player
|
||||
import net.minecraft.world.item.ItemStack
|
||||
import net.minecraft.world.phys.Vec3
|
||||
|
||||
class PokeBallSwingListener : DirectionalSwingListener() {
|
||||
|
||||
override fun isValidItem(itemStack: ItemStack): Boolean =
|
||||
itemStack.`is`(CobblemonItemTags.POKE_BALLS)
|
||||
|
||||
override fun onForwardSwing(
|
||||
useHand: InteractionHand,
|
||||
handVel: Vec3,
|
||||
player: Player
|
||||
): Boolean {
|
||||
CobblemonNetwork.sendToServer(SendOutPokeBallPacket())
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onDownwardSwing(useHand: InteractionHand, handVel: Vec3, player: Player): Boolean {
|
||||
CobblemonNetwork.sendToServer(SendOutPokeBallPacket())
|
||||
return super.onDownwardSwing(useHand, handVel, player)
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
package com.cobblemon.mod.common.client.integration.vivecraft.listener.swing
|
||||
|
||||
import com.cobblemon.mod.common.CobblemonNetwork
|
||||
import com.cobblemon.mod.common.api.tags.CobblemonItemTags
|
||||
import com.cobblemon.mod.common.net.messages.server.pokerod.CastPokeRodPacket
|
||||
import com.cobblemon.mod.common.net.messages.server.pokerod.ReelPokeRodPacket
|
||||
import net.minecraft.world.InteractionHand
|
||||
import net.minecraft.world.entity.player.Player
|
||||
import net.minecraft.world.item.ItemStack
|
||||
import net.minecraft.world.phys.Vec3
|
||||
|
||||
class PokeRodSwingListener : DirectionalSwingListener() {
|
||||
|
||||
override fun isValidItem(itemStack: ItemStack): Boolean =
|
||||
itemStack.`is`(CobblemonItemTags.POKE_RODS)
|
||||
|
||||
override fun onUpwardSwing(useHand: InteractionHand, player: Player): Boolean {
|
||||
CobblemonNetwork.sendToServer(ReelPokeRodPacket(useHand == InteractionHand.MAIN_HAND))
|
||||
return super.onUpwardSwing(useHand, player)
|
||||
}
|
||||
|
||||
override fun onForwardSwing(useHand: InteractionHand, handVel: Vec3, player: Player): Boolean {
|
||||
CobblemonNetwork.sendToServer(CastPokeRodPacket(useHand == InteractionHand.MAIN_HAND))
|
||||
return super.onForwardSwing(useHand, handVel, player)
|
||||
}
|
||||
|
||||
override fun onDownwardSwing(useHand: InteractionHand, handVel: Vec3, player: Player): Boolean {
|
||||
CobblemonNetwork.sendToServer(CastPokeRodPacket(useHand == InteractionHand.MAIN_HAND))
|
||||
return super.onDownwardSwing(useHand, handVel, player)
|
||||
}
|
||||
}
|
||||
@@ -1,188 +0,0 @@
|
||||
package com.cobblemon.mod.common.client.integration.vivecraft.party
|
||||
|
||||
import com.cobblemon.mod.common.Cobblemon
|
||||
import com.cobblemon.mod.common.client.CobblemonClient
|
||||
import com.cobblemon.mod.common.entity.pokeball.EmptyPokeBallEntity
|
||||
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity
|
||||
import com.cobblemon.mod.common.platform.events.ClientTickEvent
|
||||
import com.cobblemon.mod.common.platform.events.PlatformEvents
|
||||
import com.cobblemon.mod.common.platform.events.RenderEvent
|
||||
import com.cobblemon.mod.common.pokemon.Pokemon
|
||||
import com.mojang.math.Axis
|
||||
import net.minecraft.client.Minecraft
|
||||
import net.minecraft.client.gui.GuiGraphics
|
||||
import net.minecraft.client.player.LocalPlayer
|
||||
import net.minecraft.client.renderer.LightTexture
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
import net.minecraft.world.InteractionHand
|
||||
import net.minecraft.world.entity.Entity
|
||||
import net.minecraft.world.phys.Vec3
|
||||
import org.joml.Vector3f
|
||||
import org.vivecraft.api.VRAPI
|
||||
import org.vivecraft.api.client.InteractModule
|
||||
import org.vivecraft.api.client.VRClientAPI
|
||||
import org.vivecraft.api.data.VRBodyPartData
|
||||
import java.util.function.Consumer
|
||||
|
||||
class PartyOnArm : InteractModule {
|
||||
|
||||
val fakePartyEntities: Array<Entity?> = arrayOfNulls(6)
|
||||
var selectedIndex = -1
|
||||
|
||||
private fun onTick(tickEvent: ClientTickEvent.Post) {
|
||||
val client = tickEvent.client
|
||||
client.player ?: return
|
||||
val playerData = VRClientAPI.instance().postTickWorldPose ?: return
|
||||
val offHandData = playerData.offHand
|
||||
|
||||
// Keep up-to-date fakePartyEntities, which is done so we always have a Pokemon or PokeBall entity available to
|
||||
// render and keep it ticking so we have proper animations.
|
||||
val party = CobblemonClient.storage.party
|
||||
|
||||
// Handle the selected index, placing either a Pokemon or null
|
||||
if (selectedIndex > -1) {
|
||||
val actual = party.get(selectedIndex)
|
||||
if (actual == null) {
|
||||
fakePartyEntities[selectedIndex] = null
|
||||
} else if (fakePartyEntities[selectedIndex] is PokemonEntity) {
|
||||
fakePartyEntities[selectedIndex]!!.tick()
|
||||
} else {
|
||||
fakePartyEntities[selectedIndex] = PokemonEntity(client.level!!, actual)
|
||||
}
|
||||
}
|
||||
// Handle the other indices, placing a pokeball or null
|
||||
for (i in 0..5) {
|
||||
if (i != selectedIndex) {
|
||||
val actual = party.get(i)
|
||||
if (actual == null) {
|
||||
fakePartyEntities[i] = null
|
||||
} else if (fakePartyEntities[i] !is EmptyPokeBallEntity) {
|
||||
val pokeBall = EmptyPokeBallEntity(actual.caughtBall, client.level!!)
|
||||
pokeBall.captureState = EmptyPokeBallEntity.CaptureState.FALL
|
||||
fakePartyEntities[i] = pokeBall
|
||||
} else {
|
||||
fakePartyEntities[i]!!.tick()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check primary hand for overlap with any of the Pokemon
|
||||
val centerPos = getCenterPos(offHandData)
|
||||
selectedIndex = -1
|
||||
for (i in 0..5) {
|
||||
if (party.get(i) != null) {
|
||||
val pokemonPos = getPokemonPos(centerPos, playerData.offHand, i)
|
||||
if (playerData.mainHand.pos.distanceToSqr(pokemonPos) < DIST_SELECT_SQR) {
|
||||
selectedIndex = i
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun onRender(renderEvent: RenderEvent) {
|
||||
if (renderEvent.stage != RenderEvent.Stage.AFTER_ENTITIES) return
|
||||
val mc = Minecraft.getInstance()
|
||||
val bufferSource = mc.renderBuffers().bufferSource()
|
||||
val guiGraphics = GuiGraphics(mc, mc.renderBuffers().bufferSource())
|
||||
val cameraPos = renderEvent.camera.getPosition()
|
||||
val poseStack = guiGraphics.pose()
|
||||
val partialTick = renderEvent.tickCounter.getGameTimeDeltaPartialTick(true)
|
||||
val offHandData = VRClientAPI.instance().getWorldRenderPose()?.offHand ?: return
|
||||
|
||||
val centerPos = getCenterPos(offHandData)
|
||||
|
||||
|
||||
for (i in 0..5) {
|
||||
val pokemon = fakePartyEntities[i]
|
||||
if (pokemon != null) {
|
||||
poseStack.pushPose()
|
||||
val pokemonPos = getPokemonPos(centerPos, offHandData, i)
|
||||
val renderPos = Vec3(
|
||||
-cameraPos.x + pokemonPos.x,
|
||||
-cameraPos.y + pokemonPos.y,
|
||||
-cameraPos.z + pokemonPos.z,
|
||||
)
|
||||
poseStack.translate(renderPos.x, renderPos.y, renderPos.z)
|
||||
poseStack.scale(0.05f, 0.05f, 0.05f)
|
||||
poseStack.mulPose(Axis.YN.rotation(offHandData.yaw.toFloat()))
|
||||
poseStack.mulPose(Axis.XN.rotation(offHandData.pitch.toFloat()))
|
||||
poseStack.mulPose(Axis.ZP.rotation(offHandData.roll.toFloat() + Math.PI.toFloat()))
|
||||
mc.entityRenderDispatcher.getRenderer(pokemon).render(pokemon, 0f, partialTick, poseStack, bufferSource,
|
||||
LightTexture.FULL_BRIGHT)
|
||||
poseStack.popPose()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun getCenterPos(pose: VRBodyPartData): Vec3 {
|
||||
return pose.pos.subtract(pose.dir.scale(0.125))
|
||||
}
|
||||
|
||||
private fun getPokemonPos(centerPos: Vec3, controllerData: VRBodyPartData, index: Int): Vec3 {
|
||||
var pos = centerPos
|
||||
// Move to bottom of hand
|
||||
var downVecF = Vector3f(0f, -0.0625f, 0f)
|
||||
downVecF.rotate(Axis.ZP.rotation(controllerData.roll.toFloat()))
|
||||
downVecF.rotate(Axis.XN.rotation(controllerData.pitch.toFloat()))
|
||||
downVecF.rotate(Axis.YN.rotation(controllerData.yaw.toFloat()))
|
||||
pos = pos.add(Vec3(downVecF.x.toDouble(), downVecF.y.toDouble(), downVecF.z.toDouble()))
|
||||
// Move right or left based on index
|
||||
val rightF = Vector3f(0f, 0f, 1f) // Default forward vector of Minecraft
|
||||
rightF.rotate(Axis.YN.rotation(Math.PI.toFloat() / 2f))
|
||||
rightF.rotate(Axis.ZP.rotation(controllerData.roll.toFloat()))
|
||||
rightF.rotate(Axis.XN.rotation(controllerData.pitch.toFloat()))
|
||||
rightF.rotate(Axis.YN.rotation(controllerData.yaw.toFloat()))
|
||||
val right = Vec3(rightF.x.toDouble(), rightF.y.toDouble(), rightF.z.toDouble())
|
||||
if (index > 2) {
|
||||
pos = pos.add(right.scale(-0.0625))
|
||||
} else {
|
||||
pos = pos.add(right.scale(0.0625))
|
||||
}
|
||||
// Offset by -hand direction if on left, 0 if center, or +hand direction if right
|
||||
return pos.add(controllerData.dir.scale(DIST_BETWEEN_HORIZONTAL * (index % 3 - 1)))
|
||||
}
|
||||
|
||||
override fun getId(): ResourceLocation {
|
||||
return INTERACT_ID
|
||||
}
|
||||
|
||||
override fun isActive(
|
||||
player: LocalPlayer,
|
||||
hand: InteractionHand,
|
||||
handPosition: Vec3
|
||||
): Boolean {
|
||||
return hand == InteractionHand.MAIN_HAND && selectedIndex > -1
|
||||
}
|
||||
|
||||
override fun onPress(
|
||||
player: LocalPlayer,
|
||||
hand: InteractionHand
|
||||
): Boolean {
|
||||
// UUID lookup is done at press time since the Pokemon may have switched since initially hovered over, such
|
||||
// as via commands.
|
||||
val uuid = CobblemonClient.storage.party.get(selectedIndex)?.uuid ?: return false
|
||||
CobblemonClient.storage.switchToPokemon(uuid)
|
||||
return true
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val DIST_BETWEEN_HORIZONTAL: Double = 0.125
|
||||
const val DIST_BETWEEN_VERTICAL: Float = 0.05f
|
||||
const val DIST_SELECT_SQR: Double = 0.1 * 0.1
|
||||
|
||||
val INTERACT_ID = ResourceLocation(Cobblemon.MODID, "party_on_arm_interact_module")
|
||||
|
||||
private val INSTANCE = PartyOnArm()
|
||||
|
||||
fun init() {
|
||||
PlatformEvents.RENDER.subscribe(Consumer { renderEvent: RenderEvent? -> INSTANCE.onRender(renderEvent!!) })
|
||||
PlatformEvents.CLIENT_TICK_POST.subscribe(Consumer { tickEvent: ClientTickEvent.Post? ->
|
||||
INSTANCE.onTick(
|
||||
tickEvent!!
|
||||
)
|
||||
})
|
||||
VRAPI.instance().register(INSTANCE)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package com.cobblemon.mod.common.client.integration.vivecraft.proximity
|
||||
|
||||
import org.vivecraft.api.data.VRBodyPart
|
||||
import org.vivecraft.api.data.VRPose
|
||||
|
||||
// TODO: Make an PR to Vivecraft that adds this feature directly to Vivecraft
|
||||
interface ProximityListener {
|
||||
fun isActive(registration: ProximityRegistration): Boolean = true
|
||||
fun onEnter(bodyA: VRBodyPart, bodyB: VRBodyPart, pose: VRPose)
|
||||
fun onExit(bodyA: VRBodyPart, bodyB: VRBodyPart, pose: VRPose)
|
||||
fun onTick(bodyA: VRBodyPart, bodyB: VRBodyPart, pose: VRPose)
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
package com.cobblemon.mod.common.client.integration.vivecraft.proximity
|
||||
|
||||
import com.cobblemon.mod.common.platform.events.ClientTickEvent
|
||||
import com.cobblemon.mod.common.platform.events.PlatformEvents
|
||||
import org.vivecraft.api.client.VRClientAPI
|
||||
import kotlin.math.acos
|
||||
|
||||
// TODO: Make an PR to Vivecraft that adds this feature directly to Vivecraft
|
||||
class ProximityManager {
|
||||
private val registrations = mutableListOf<ProximityRegistration>()
|
||||
private val previousInProximity = mutableMapOf<ProximityRegistration, Boolean>()
|
||||
private val api: VRClientAPI = VRClientAPI.instance()
|
||||
|
||||
fun register(registration: ProximityRegistration) {
|
||||
registrations += registration
|
||||
previousInProximity.putIfAbsent(registration, false)
|
||||
}
|
||||
|
||||
fun unregister(registration: ProximityRegistration) {
|
||||
registrations -= registration
|
||||
previousInProximity.remove(registration)
|
||||
}
|
||||
|
||||
fun clear() {
|
||||
registrations.clear()
|
||||
previousInProximity.clear()
|
||||
}
|
||||
|
||||
fun isActive(registration: ProximityRegistration): Boolean {
|
||||
return registration.listener.isActive(registration)
|
||||
}
|
||||
|
||||
fun onTick(tickEvent: ClientTickEvent.Post) {
|
||||
val vrPose = api.getPostTickWorldPose() ?: return
|
||||
|
||||
for (reg in registrations) {
|
||||
if (!isActive(reg)) continue
|
||||
val poseA = vrPose.getBodyPartData(reg.bodyA) ?: continue
|
||||
val poseB = vrPose.getBodyPartData(reg.bodyB) ?: continue
|
||||
|
||||
val distance = poseA.pos.distanceTo(poseB.pos)
|
||||
|
||||
val dot = poseA.dir.dot(poseB.dir).coerceIn(-1.0, 1.0)
|
||||
val angleDeg = Math.toDegrees(acos(dot)).toFloat()
|
||||
val angleOk = angleDeg <= reg.angleThreshold
|
||||
|
||||
val nowInProximity = distance <= reg.distanceThreshold && angleOk
|
||||
val wasInProximity = previousInProximity[reg] ?: false
|
||||
|
||||
if (!wasInProximity && nowInProximity) {
|
||||
reg.listener.onEnter(reg.bodyA, reg.bodyB, vrPose)
|
||||
} else if (wasInProximity && !nowInProximity) {
|
||||
reg.listener.onExit(reg.bodyA, reg.bodyB, vrPose)
|
||||
}
|
||||
|
||||
if (nowInProximity) {
|
||||
reg.listener.onTick(reg.bodyA, reg.bodyB, vrPose)
|
||||
}
|
||||
|
||||
previousInProximity[reg] = nowInProximity
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val INSTANCE = ProximityManager()
|
||||
|
||||
fun init() {
|
||||
PlatformEvents.CLIENT_TICK_POST.subscribe { tickEvent: ClientTickEvent.Post? ->
|
||||
INSTANCE.onTick(
|
||||
tickEvent!!
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun register(registration: ProximityRegistration) = INSTANCE.register(registration)
|
||||
fun unregister(registration: ProximityRegistration) = INSTANCE.unregister(registration)
|
||||
fun clearAll() = INSTANCE.clear()
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package com.cobblemon.mod.common.client.integration.vivecraft.proximity
|
||||
|
||||
import org.vivecraft.api.data.VRBodyPart
|
||||
|
||||
// TODO: Make an PR to Vivecraft that adds this feature directly to Vivecraft
|
||||
data class ProximityRegistration(
|
||||
val bodyA: VRBodyPart,
|
||||
val bodyB: VRBodyPart,
|
||||
val distanceThreshold: Float,
|
||||
val angleThreshold: Float = 180f,
|
||||
val listener: ProximityListener
|
||||
)
|
||||
@@ -802,14 +802,13 @@ class PokeRodFishingBobberEntity(type: EntityType<out PokeRodFishingBobberEntity
|
||||
|
||||
spawnAction.complete()
|
||||
val result = spawnAction.future
|
||||
val resultingSpawn = result.get()
|
||||
|
||||
if (resultingSpawn == null) {
|
||||
if (result.isCompletedExceptionally) {
|
||||
noBite(player)
|
||||
return false
|
||||
}
|
||||
|
||||
var spawnedPokemon: PokemonEntity? = null
|
||||
val resultingSpawn = result.get()
|
||||
|
||||
if (resultingSpawn is EntitySpawnResult) {
|
||||
for (entity in resultingSpawn.entities) {
|
||||
|
||||
@@ -1282,7 +1282,7 @@ open class PokemonEntity(
|
||||
}
|
||||
|
||||
override fun shouldBeSaved(): Boolean {
|
||||
if (ownerUUID == null && !pokemon.isNPCOwned() && (Cobblemon.config.savePokemonToWorld || isPersistenceRequired)) {
|
||||
if (ownerUUID == null && !pokemon.isNPCOwned() && (Cobblemon.config.savePokemonToWorld || isPersistenceRequired || this.pokemon.canDropHeldItem)) {
|
||||
CobblemonEvents.POKEMON_ENTITY_SAVE_TO_WORLD.postThen(PokemonEntitySaveToWorldEvent(this)) {
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.cobblemon.mod.common.integration.vivecraft
|
||||
|
||||
import com.cobblemon.mod.common.client.integration.vivecraft.listener.swing.PokeBallSwingListener
|
||||
import com.cobblemon.mod.common.client.integration.vivecraft.listener.swing.PokeRodSwingListener
|
||||
import org.vivecraft.api.VRAPI
|
||||
|
||||
class CobblemonVR {
|
||||
|
||||
fun init() {
|
||||
VRAPI.instance()
|
||||
.register(PokeBallSwingListener())
|
||||
|
||||
VRAPI.instance()
|
||||
.register(PokeRodSwingListener())
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,7 @@ import net.minecraft.world.level.Level
|
||||
import kotlin.math.cos
|
||||
|
||||
class PokeBallItem(
|
||||
val pokeBall: PokeBall
|
||||
val pokeBall: PokeBall
|
||||
) : CobblemonItem(Properties().apply {
|
||||
when (pokeBall.name) {
|
||||
// Master balls are a netherite product and should be fire immune
|
||||
@@ -43,7 +43,7 @@ class PokeBallItem(
|
||||
return InteractionResultHolder.sidedSuccess(itemStack, world.isClientSide)
|
||||
}
|
||||
|
||||
fun throwPokeBall(world: Level, player: ServerPlayer) {
|
||||
private fun throwPokeBall(world: Level, player: ServerPlayer) {
|
||||
val pokeBallEntity = EmptyPokeBallEntity(pokeBall, player.level(), player).apply {
|
||||
val overhandFactor: Float = if (player.xRot < 0) {
|
||||
5f * cos(player.xRot.toRadians())
|
||||
@@ -57,5 +57,4 @@ class PokeBallItem(
|
||||
}
|
||||
world.addFreshEntity(pokeBallEntity)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -13,7 +13,10 @@ import net.minecraft.resources.ResourceLocation
|
||||
import net.minecraft.world.entity.EquipmentSlot
|
||||
import net.minecraft.world.item.Equipable
|
||||
|
||||
class WearableItem(val name: String): CobblemonItem(Properties()), Equipable {
|
||||
class WearableItem(
|
||||
val name: String,
|
||||
val armorEquipmentSlot: EquipmentSlot = EquipmentSlot.HEAD,
|
||||
): CobblemonItem(Properties()), Equipable {
|
||||
companion object {
|
||||
const val MODEL_PATH = "item/wearable"
|
||||
}
|
||||
@@ -21,5 +24,7 @@ class WearableItem(val name: String): CobblemonItem(Properties()), Equipable {
|
||||
fun getModel3d(): ResourceLocation = cobblemonResource("${MODEL_PATH}/${this.name}")
|
||||
fun getModel2d(): ResourceLocation = cobblemonResource(this.name)
|
||||
|
||||
override fun getEquipmentSlot(): EquipmentSlot { return EquipmentSlot.HEAD }
|
||||
override fun getEquipmentSlot(): EquipmentSlot {
|
||||
return armorEquipmentSlot
|
||||
}
|
||||
}
|
||||
@@ -75,8 +75,7 @@ class PokerodItem(val pokeRodId: ResourceLocation, settings: Properties) : Fishi
|
||||
|
||||
if (baitCount > 1) {
|
||||
baitStack.count = baitCount - 1
|
||||
stack.set(
|
||||
CobblemonItemComponents.BAIT, RodBaitComponent(baitStack)
|
||||
stack.set(CobblemonItemComponents.BAIT, RodBaitComponent(baitStack)
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -150,163 +149,90 @@ class PokerodItem(val pokeRodId: ResourceLocation, settings: Properties) : Fishi
|
||||
}
|
||||
|
||||
override fun use(world: Level, user: Player, hand: InteractionHand): InteractionResultHolder<ItemStack> {
|
||||
|
||||
val itemStack = user.getItemInHand(hand)
|
||||
val offHandItem = user.getItemInHand(InteractionHand.OFF_HAND)
|
||||
|
||||
attemptApplyOffhandBait(world, user, itemStack, offHandItem)?.let { return it }
|
||||
// Check if offhand item is valid bait and the rod is not in use, if so then apply bait from offhand
|
||||
if (!world.isClientSide && user.fishing == null && SpawnBaitEffects.isFishingBait(offHandItem)) {
|
||||
CobblemonEvents.BAIT_SET_PRE.postThen(BaitSetEvent(itemStack, offHandItem), { event ->
|
||||
return InteractionResultHolder.fail(itemStack)
|
||||
}, {
|
||||
playAttachSound(user)
|
||||
|
||||
if (user.fishing != null) {
|
||||
attemptReel(world, user, hand, itemStack)?.let { return it }
|
||||
} else {
|
||||
attemptCast(world, user, hand, itemStack)?.let { return it }
|
||||
// if there is bait on the rod already then drop it on the ground before applying offhand bait
|
||||
val baitStack = getBaitStackOnRod(itemStack)
|
||||
|
||||
if (baitStack != ItemStack.EMPTY && offHandItem.item != baitStack.item) {
|
||||
user.drop(baitStack, true) // Drop the full stack
|
||||
|
||||
// apply single bait item from offhand
|
||||
val singleBait = offHandItem.copy()
|
||||
singleBait.count = 1
|
||||
setBait(itemStack, singleBait)
|
||||
offHandItem.shrink(1)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
return InteractionResultHolder.sidedSuccess(itemStack, world.isClientSide)
|
||||
}
|
||||
|
||||
fun applyBait(
|
||||
rodStack: ItemStack,
|
||||
baitSource: ItemStack,
|
||||
player: Player?
|
||||
): Boolean {
|
||||
if (baitSource.isEmpty || !SpawnBaitEffects.isFishingBait(baitSource)) return false
|
||||
|
||||
val existingBait = getBaitStackOnRod(rodStack)
|
||||
if (!existingBait.isEmpty && existingBait.item == baitSource.item) return false
|
||||
|
||||
var applied = false
|
||||
|
||||
CobblemonEvents.BAIT_SET_PRE.postThen(
|
||||
BaitSetEvent(rodStack, baitSource),
|
||||
{ return false },
|
||||
{
|
||||
if (!existingBait.isEmpty && player != null) {
|
||||
player.drop(existingBait, true)
|
||||
}
|
||||
|
||||
val singleBait = baitSource.copy()
|
||||
singleBait.count = 1
|
||||
setBait(rodStack, singleBait)
|
||||
|
||||
baitSource.shrink(1)
|
||||
applied = true
|
||||
var i: Int
|
||||
if (user.fishing != null) { // if the bobber is out yet
|
||||
if (!world.isClientSide) {
|
||||
CobblemonEvents.POKEROD_REEL.postThen(
|
||||
PokerodReelEvent(user, itemStack),
|
||||
{ event -> return InteractionResultHolder.fail(itemStack) },
|
||||
{ event ->
|
||||
i = user.fishing!!.retrieve(itemStack)
|
||||
itemStack.hurtAndBreak(i, user, hand.toEquipmentSlot())
|
||||
world.playSoundServer(
|
||||
Vec3(user.x,
|
||||
user.y,
|
||||
user.z),
|
||||
CobblemonSounds.FISHING_ROD_REEL_IN,
|
||||
SoundSource.PLAYERS,
|
||||
1.0f,
|
||||
1.0f / (world.getRandom().nextFloat() * 0.4f + 0.8f)
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
return applied
|
||||
}
|
||||
|
||||
fun attemptApplyOffhandBait(
|
||||
world: Level,
|
||||
user: Player,
|
||||
rodStack: ItemStack,
|
||||
offHandItem: ItemStack
|
||||
): InteractionResultHolder<ItemStack>? {
|
||||
if (world.isClientSide) return null
|
||||
if (user.fishing != null) return null
|
||||
world.playSound(null as Player?, user.x, user.y, user.z, CobblemonSounds.FISHING_ROD_REEL_IN, SoundSource.PLAYERS, 1.0f, 1.0f)
|
||||
user.gameEvent(GameEvent.ITEM_INTERACT_FINISH)
|
||||
} else { // if the bobber is not out yet
|
||||
|
||||
val applied = applyBait(
|
||||
rodStack = rodStack,
|
||||
baitSource = offHandItem,
|
||||
player = user
|
||||
)
|
||||
if (!world.isClientSide) {
|
||||
val lureLevel = world.enchantmentRegistry.getHolder(Enchantments.LURE).map { EnchantmentHelper.getItemEnchantmentLevel(it, itemStack) }.orElse(0)
|
||||
val luckLevel = world.enchantmentRegistry.getHolder(Enchantments.LUCK_OF_THE_SEA).map { EnchantmentHelper.getItemEnchantmentLevel(it, itemStack) }.orElse(0)
|
||||
|
||||
if (applied) {
|
||||
playAttachSound(user)
|
||||
return InteractionResultHolder.sidedSuccess(rodStack, false)
|
||||
val bobberEntity = PokeRodFishingBobberEntity(
|
||||
user,
|
||||
pokeRodId,
|
||||
getBaitStackOnRod(itemStack),
|
||||
world,
|
||||
luckLevel,
|
||||
lureLevel,
|
||||
itemStack
|
||||
)
|
||||
CobblemonEvents.POKEROD_CAST_PRE.postThen(
|
||||
PokerodCastEvent.Pre(itemStack, bobberEntity, getBaitStackOnRod(itemStack)),
|
||||
{ event -> return InteractionResultHolder.fail(itemStack) },
|
||||
{ event ->
|
||||
world.addFreshEntity(bobberEntity)
|
||||
var baitId = getBaitStackOnRod(itemStack).takeUnless { it.isEmpty }?.itemHolder?.unwrapKey()?.orElse(null)?.location() ?: cobblemonResource("empty_bait")
|
||||
CobblemonCriteria.CAST_POKE_ROD.trigger(user as ServerPlayer, CastPokeRodContext(baitId))
|
||||
|
||||
CobblemonEvents.POKEROD_CAST_POST.post(
|
||||
PokerodCastEvent.Post(itemStack, bobberEntity, getBaitStackOnRod(itemStack))
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
user.awardStat(Stats.ITEM_USED.get(this))
|
||||
user.gameEvent(GameEvent.ITEM_INTERACT_START)
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
|
||||
fun attemptReel(
|
||||
world: Level,
|
||||
user: Player,
|
||||
hand: InteractionHand,
|
||||
itemStack: ItemStack
|
||||
): InteractionResultHolder<ItemStack>? {
|
||||
if (user.fishing == null) return null
|
||||
|
||||
if (!world.isClientSide) {
|
||||
CobblemonEvents.POKEROD_REEL.postThen(
|
||||
PokerodReelEvent(user, itemStack),
|
||||
{ event -> return InteractionResultHolder.fail(itemStack) },
|
||||
{ event ->
|
||||
val i = user.fishing!!.retrieve(itemStack)
|
||||
itemStack.hurtAndBreak(i, user, hand.toEquipmentSlot())
|
||||
world.playSoundServer(
|
||||
Vec3(user.x, user.y, user.z),
|
||||
CobblemonSounds.FISHING_ROD_REEL_IN,
|
||||
SoundSource.PLAYERS,
|
||||
1.0f,
|
||||
1.0f / (world.getRandom().nextFloat() * 0.4f + 0.8f)
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
world.playSound(
|
||||
null as Player?,
|
||||
user.x,
|
||||
user.y,
|
||||
user.z,
|
||||
CobblemonSounds.FISHING_ROD_REEL_IN,
|
||||
SoundSource.PLAYERS,
|
||||
1.0f,
|
||||
1.0f
|
||||
)
|
||||
user.gameEvent(GameEvent.ITEM_INTERACT_FINISH)
|
||||
|
||||
return InteractionResultHolder.sidedSuccess(itemStack, world.isClientSide)
|
||||
}
|
||||
|
||||
fun attemptCast(
|
||||
world: Level,
|
||||
user: Player,
|
||||
hand: InteractionHand,
|
||||
itemStack: ItemStack
|
||||
): InteractionResultHolder<ItemStack>? {
|
||||
if (user.fishing != null) return null
|
||||
|
||||
if (!world.isClientSide) {
|
||||
val lureLevel = world.enchantmentRegistry.getHolder(Enchantments.LURE)
|
||||
.map { EnchantmentHelper.getItemEnchantmentLevel(it, itemStack) }
|
||||
.orElse(0)
|
||||
val luckLevel = world.enchantmentRegistry.getHolder(Enchantments.LUCK_OF_THE_SEA)
|
||||
.map { EnchantmentHelper.getItemEnchantmentLevel(it, itemStack) }
|
||||
.orElse(0)
|
||||
|
||||
val bobberEntity = PokeRodFishingBobberEntity(
|
||||
user,
|
||||
pokeRodId,
|
||||
getBaitStackOnRod(itemStack),
|
||||
world,
|
||||
luckLevel,
|
||||
lureLevel,
|
||||
itemStack
|
||||
)
|
||||
|
||||
CobblemonEvents.POKEROD_CAST_PRE.postThen(
|
||||
PokerodCastEvent.Pre(itemStack, bobberEntity, getBaitStackOnRod(itemStack)),
|
||||
{ event -> return InteractionResultHolder.fail(itemStack) },
|
||||
{ event ->
|
||||
world.addFreshEntity(bobberEntity)
|
||||
val baitId = getBaitStackOnRod(itemStack).takeUnless { it.isEmpty }
|
||||
?.itemHolder?.unwrapKey()?.orElse(null)?.location()
|
||||
?: cobblemonResource("empty_bait")
|
||||
CobblemonCriteria.CAST_POKE_ROD.trigger(user as ServerPlayer, CastPokeRodContext(baitId))
|
||||
|
||||
CobblemonEvents.POKEROD_CAST_POST.post(
|
||||
PokerodCastEvent.Post(itemStack, bobberEntity, getBaitStackOnRod(itemStack))
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
user.awardStat(Stats.ITEM_USED.get(this))
|
||||
user.gameEvent(GameEvent.ITEM_INTERACT_START)
|
||||
|
||||
return InteractionResultHolder.sidedSuccess(itemStack, world.isClientSide)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.cobblemon.mod.common.net.messages.server.pokeball
|
||||
|
||||
import com.cobblemon.mod.common.api.net.NetworkPacket
|
||||
import com.cobblemon.mod.common.util.cobblemonResource
|
||||
import net.minecraft.network.RegistryFriendlyByteBuf
|
||||
|
||||
class SendOutPokeBallPacket() : NetworkPacket<SendOutPokeBallPacket> {
|
||||
override val id = ID
|
||||
override fun encode(buffer: RegistryFriendlyByteBuf) {
|
||||
}
|
||||
|
||||
companion object {
|
||||
val ID = cobblemonResource("send_out_pokeball")
|
||||
fun decode(buffer: RegistryFriendlyByteBuf) = SendOutPokeBallPacket()
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.cobblemon.mod.common.net.messages.server.pokerod
|
||||
|
||||
import com.cobblemon.mod.common.api.net.NetworkPacket
|
||||
import com.cobblemon.mod.common.util.cobblemonResource
|
||||
import net.minecraft.network.RegistryFriendlyByteBuf
|
||||
|
||||
class ApplyBaitPacket() : NetworkPacket<ApplyBaitPacket> {
|
||||
override val id = ID
|
||||
override fun encode(buffer: RegistryFriendlyByteBuf) {
|
||||
}
|
||||
|
||||
companion object {
|
||||
val ID = cobblemonResource("apply_bait")
|
||||
fun decode(buffer: RegistryFriendlyByteBuf) = ApplyBaitPacket()
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package com.cobblemon.mod.common.net.messages.server.pokerod
|
||||
|
||||
import com.cobblemon.mod.common.api.net.NetworkPacket
|
||||
import com.cobblemon.mod.common.util.cobblemonResource
|
||||
import net.minecraft.network.RegistryFriendlyByteBuf
|
||||
|
||||
class CastPokeRodPacket(val mainHand: Boolean) : NetworkPacket<CastPokeRodPacket> {
|
||||
override val id = ID
|
||||
override fun encode(buffer: RegistryFriendlyByteBuf) {
|
||||
buffer.writeBoolean(mainHand)
|
||||
}
|
||||
|
||||
companion object {
|
||||
val ID = cobblemonResource("cast_pokerod")
|
||||
fun decode(buffer: RegistryFriendlyByteBuf) = CastPokeRodPacket(buffer.readBoolean())
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package com.cobblemon.mod.common.net.messages.server.pokerod
|
||||
|
||||
import com.cobblemon.mod.common.api.net.NetworkPacket
|
||||
import com.cobblemon.mod.common.util.cobblemonResource
|
||||
import net.minecraft.network.RegistryFriendlyByteBuf
|
||||
|
||||
class ReelPokeRodPacket(val mainHand: Boolean) : NetworkPacket<ReelPokeRodPacket> {
|
||||
override val id = ID
|
||||
override fun encode(buffer: RegistryFriendlyByteBuf) {
|
||||
buffer.writeBoolean(mainHand)
|
||||
}
|
||||
|
||||
companion object {
|
||||
val ID = cobblemonResource("reel_pokerod")
|
||||
fun decode(buffer: RegistryFriendlyByteBuf) = ReelPokeRodPacket(buffer.readBoolean())
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Cobblemon Contributors
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package com.cobblemon.mod.common.net.serverhandling.pokeball
|
||||
|
||||
import com.cobblemon.mod.common.api.net.ServerNetworkPacketHandler
|
||||
import com.cobblemon.mod.common.item.PokeBallItem
|
||||
import com.cobblemon.mod.common.net.messages.server.pokeball.SendOutPokeBallPacket
|
||||
import com.cobblemon.mod.common.util.isServerSide
|
||||
import net.minecraft.server.MinecraftServer
|
||||
import net.minecraft.server.level.ServerPlayer
|
||||
|
||||
object SendOutPokeBallHandler : ServerNetworkPacketHandler<SendOutPokeBallPacket> {
|
||||
|
||||
override fun handle(packet: SendOutPokeBallPacket, server: MinecraftServer, player: ServerPlayer) {
|
||||
(player.mainHandItem.item as? PokeBallItem)?.let { pokeball ->
|
||||
if (player.level().isServerSide()) {
|
||||
pokeball.throwPokeBall(player.level(), player)
|
||||
}
|
||||
// TODO: player.mainHandItem.consume(1, player)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
package com.cobblemon.mod.common.net.serverhandling.pokerod
|
||||
|
||||
import com.cobblemon.mod.common.api.net.ServerNetworkPacketHandler
|
||||
import com.cobblemon.mod.common.item.interactive.PokerodItem
|
||||
import com.cobblemon.mod.common.net.messages.server.pokerod.ApplyBaitPacket
|
||||
import com.cobblemon.mod.common.util.isServerSide
|
||||
import net.minecraft.server.MinecraftServer
|
||||
import net.minecraft.server.level.ServerPlayer
|
||||
import net.minecraft.world.InteractionHand
|
||||
|
||||
object ApplyBaitHandler : ServerNetworkPacketHandler<ApplyBaitPacket> {
|
||||
|
||||
override fun handle(packet: ApplyBaitPacket, server: MinecraftServer, player: ServerPlayer) {
|
||||
|
||||
val mainHandItem = player.getItemInHand(InteractionHand.MAIN_HAND)
|
||||
val offHandItem = player.getItemInHand(InteractionHand.OFF_HAND)
|
||||
|
||||
println("[ApplyBaitHandler] Main hand: ${mainHandItem.item}")
|
||||
println("[ApplyBaitHandler] Off hand: ${offHandItem.item}")
|
||||
|
||||
(mainHandItem.item as? PokerodItem)?.let { pokerod ->
|
||||
if (player.level().isServerSide()) {
|
||||
pokerod.applyBait(
|
||||
mainHandItem,
|
||||
offHandItem,
|
||||
player
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
(offHandItem.item as? PokerodItem)?.let { pokerod ->
|
||||
if (player.level().isServerSide()) {
|
||||
pokerod.applyBait(
|
||||
offHandItem,
|
||||
mainHandItem,
|
||||
player
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Cobblemon Contributors
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package com.cobblemon.mod.common.net.serverhandling.pokerod
|
||||
|
||||
import com.cobblemon.mod.common.api.net.ServerNetworkPacketHandler
|
||||
import com.cobblemon.mod.common.item.PokeBallItem
|
||||
import com.cobblemon.mod.common.item.interactive.PokerodItem
|
||||
import com.cobblemon.mod.common.net.messages.server.pokeball.SendOutPokeBallPacket
|
||||
import com.cobblemon.mod.common.net.messages.server.pokerod.CastPokeRodPacket
|
||||
import com.cobblemon.mod.common.util.isServerSide
|
||||
import net.minecraft.server.MinecraftServer
|
||||
import net.minecraft.server.level.ServerPlayer
|
||||
import net.minecraft.world.InteractionHand
|
||||
|
||||
object CastPokeRodHandler : ServerNetworkPacketHandler<CastPokeRodPacket> {
|
||||
|
||||
override fun handle(packet: CastPokeRodPacket, server: MinecraftServer, player: ServerPlayer) {
|
||||
val hand = if (packet.mainHand) InteractionHand.MAIN_HAND else InteractionHand.OFF_HAND
|
||||
(player.getItemInHand(hand).item as? PokerodItem)?.let { pokerod ->
|
||||
if (player.level().isServerSide()) pokerod.attemptCast(
|
||||
player.level(),
|
||||
player,
|
||||
hand,
|
||||
player.getItemInHand(hand)
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Cobblemon Contributors
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package com.cobblemon.mod.common.net.serverhandling.pokerod
|
||||
|
||||
import com.cobblemon.mod.common.api.net.ServerNetworkPacketHandler
|
||||
import com.cobblemon.mod.common.item.PokeBallItem
|
||||
import com.cobblemon.mod.common.item.interactive.PokerodItem
|
||||
import com.cobblemon.mod.common.net.messages.server.pokeball.SendOutPokeBallPacket
|
||||
import com.cobblemon.mod.common.net.messages.server.pokerod.CastPokeRodPacket
|
||||
import com.cobblemon.mod.common.net.messages.server.pokerod.ReelPokeRodPacket
|
||||
import com.cobblemon.mod.common.util.isServerSide
|
||||
import net.minecraft.server.MinecraftServer
|
||||
import net.minecraft.server.level.ServerPlayer
|
||||
import net.minecraft.world.InteractionHand
|
||||
|
||||
object ReelPokeRodHandler : ServerNetworkPacketHandler<ReelPokeRodPacket> {
|
||||
|
||||
override fun handle(packet: ReelPokeRodPacket, server: MinecraftServer, player: ServerPlayer) {
|
||||
val hand = if (packet.mainHand) InteractionHand.MAIN_HAND else InteractionHand.OFF_HAND
|
||||
(player.getItemInHand(hand).item as? PokerodItem)?.let { pokerod ->
|
||||
if (player.level().isServerSide()) pokerod.attemptReel(
|
||||
player.level(),
|
||||
player,
|
||||
hand,
|
||||
player.getItemInHand(hand)
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -32,7 +32,6 @@ data class RenderEvent(
|
||||
|
||||
/** Represents when a layer is rendered by [LevelRenderer.renderLevel]. Ordinal corresponds with its render order. */
|
||||
enum class Stage {
|
||||
AFTER_ENTITIES,
|
||||
TRANSLUCENT
|
||||
}
|
||||
}
|
||||
@@ -673,7 +673,7 @@ open class Pokemon : ShowdownIdentifiable {
|
||||
* Whether this Pokémon's held item can be dropped by its AI.
|
||||
*/
|
||||
internal var canDropHeldItem: Boolean = false
|
||||
get() = field || heldItem.isEmpty
|
||||
get() = field && !heldItem.isEmpty
|
||||
|
||||
val riding: RidingProperties
|
||||
get() = this.form.riding
|
||||
|
||||
@@ -11,7 +11,6 @@ package com.cobblemon.mod.common.util
|
||||
import net.minecraft.core.BlockPos
|
||||
import net.minecraft.world.phys.Vec3
|
||||
import org.joml.Vector3f
|
||||
import kotlin.math.sqrt
|
||||
|
||||
/**
|
||||
* For conversion from Vec3dto BlockPos, loses accuracy
|
||||
@@ -23,17 +22,9 @@ fun Vec3.toBlockPos(): BlockPos {
|
||||
fun Vec3.toVec3f(): Vector3f = Vector3f(x.toFloat(), y.toFloat(), z.toFloat())
|
||||
fun Vector3f.toVec3d(): Vec3 =
|
||||
Vec3(x.toDouble(), y.toDouble(), z.toDouble())
|
||||
|
||||
fun Vector3f.set(vec3d: Vec3): Vector3f {
|
||||
x = vec3d.x.toFloat()
|
||||
y = vec3d.y.toFloat()
|
||||
z = vec3d.z.toFloat()
|
||||
return this
|
||||
}
|
||||
|
||||
fun Vector3f.distance(other: Vector3f): Float {
|
||||
val dx = other.x - x
|
||||
val dy = other.y - y
|
||||
val dz = other.z - z
|
||||
return sqrt(dx * dx + dy * dy + dz * dz)
|
||||
}
|
||||
@@ -0,0 +1,235 @@
|
||||
{
|
||||
"format_version": "1.21.6",
|
||||
"credit": "Made with Blockbench",
|
||||
"texture_size": [64, 24],
|
||||
"textures": {
|
||||
"0": "cobblemon:item/wearable/shell_helmet",
|
||||
"particle": "cobblemon:item/wearable/shell_helmet"
|
||||
},
|
||||
"elements": [
|
||||
{
|
||||
"from": [4, 1, 7],
|
||||
"to": [12, 4, 10],
|
||||
"rotation": {"angle": 0, "axis": "y", "origin": [7, 2, 12]},
|
||||
"faces": {
|
||||
"north": {"uv": [4, 0, 6, 2], "texture": "#0"},
|
||||
"east": {"uv": [4, 2, 4.75, 4], "texture": "#0"},
|
||||
"south": {"uv": [1.75, 12.66667, 3.75, 14.66667], "texture": "#0"},
|
||||
"west": {"uv": [4.75, 2, 5.5, 4], "texture": "#0"},
|
||||
"up": {"uv": [4, 2, 2, 0], "texture": "#0"},
|
||||
"down": {"uv": [4, 2, 2, 4.66667], "texture": "#0"}
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [11, 0, 7],
|
||||
"to": [12, 1, 7],
|
||||
"rotation": {"angle": 0, "axis": "y", "origin": [7, -3, 9]},
|
||||
"faces": {
|
||||
"north": {"uv": [5.5, 3.33333, 5.75, 4], "texture": "#0"},
|
||||
"east": {"uv": [0, 0, 0, 0.66667], "texture": "#0"},
|
||||
"south": {"uv": [5.75, 3.33333, 6, 4], "texture": "#0"},
|
||||
"west": {"uv": [0, 0, 0, 0.66667], "texture": "#0"},
|
||||
"up": {"uv": [0.25, 0, 0, 0], "texture": "#0"},
|
||||
"down": {"uv": [0.25, 0, 0, 0], "texture": "#0"}
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [4, 0, 7],
|
||||
"to": [5, 1, 7],
|
||||
"rotation": {"angle": 0, "axis": "y", "origin": [0, -3, 9]},
|
||||
"faces": {
|
||||
"north": {"uv": [4, 4, 4.25, 4.66667], "texture": "#0"},
|
||||
"east": {"uv": [0, 0, 0, 0.66667], "texture": "#0"},
|
||||
"south": {"uv": [3.75, 12.66667, 4, 13.33333], "texture": "#0"},
|
||||
"west": {"uv": [0, 0, 0, 0.66667], "texture": "#0"},
|
||||
"up": {"uv": [0.25, 0, 0, 0], "texture": "#0"},
|
||||
"down": {"uv": [0.25, 0, 0, 0], "texture": "#0"}
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [12, -1, 7],
|
||||
"to": [12, 1, 9],
|
||||
"rotation": {"angle": 0, "axis": "y", "origin": [7, 2, 11]},
|
||||
"faces": {
|
||||
"north": {"uv": [0, 0, 0, 1.33333], "texture": "#0"},
|
||||
"east": {"uv": [4.25, 6.66667, 4.75, 8], "texture": "#0"},
|
||||
"south": {"uv": [0, 0, 0, 1.33333], "texture": "#0"},
|
||||
"west": {"uv": [5.5, 2, 6, 3.33333], "texture": "#0"},
|
||||
"up": {"uv": [0, 3.33333, 0, 0], "texture": "#0"},
|
||||
"down": {"uv": [0, 0, 0, 3.33333], "texture": "#0"}
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [4, -1, 7],
|
||||
"to": [4, 1, 9],
|
||||
"rotation": {"angle": 0, "axis": "y", "origin": [7, 2, 11]},
|
||||
"faces": {
|
||||
"north": {"uv": [0, 0, 0, 1.33333], "texture": "#0"},
|
||||
"east": {"uv": [4, 10, 4.5, 11.33333], "texture": "#0"},
|
||||
"south": {"uv": [0, 0, 0, 1.33333], "texture": "#0"},
|
||||
"west": {"uv": [4.75, 6.66667, 5.25, 8], "texture": "#0"},
|
||||
"up": {"uv": [0, 3.33333, 0, 0], "texture": "#0"},
|
||||
"down": {"uv": [0, 0, 0, 3.33333], "texture": "#0"}
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [5, 2, 4],
|
||||
"to": [11, 4, 7],
|
||||
"rotation": {"angle": 0, "axis": "y", "origin": [7, 2, 12]},
|
||||
"faces": {
|
||||
"north": {"uv": [4.25, 4, 5.75, 5.33333], "texture": "#0"},
|
||||
"east": {"uv": [6, 2.66667, 6.75, 4], "texture": "#0"},
|
||||
"south": {"uv": [4.25, 5.33333, 5.75, 6.66667], "texture": "#0"},
|
||||
"west": {"uv": [5.75, 4, 6.5, 5.33333], "texture": "#0"},
|
||||
"up": {"uv": [5.5, 13.33333, 4, 11.33333], "texture": "#0"},
|
||||
"down": {"uv": [5.25, 13.33333, 3.75, 15.33333], "texture": "#0"}
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [5, 2, 7],
|
||||
"to": [11, 2, 10],
|
||||
"rotation": {"angle": 0, "axis": "y", "origin": [7, 2, 12]},
|
||||
"faces": {
|
||||
"north": {"uv": [4.25, 4, 5.75, 5.33333], "texture": "#0"},
|
||||
"east": {"uv": [6, 2.66667, 6.75, 4], "texture": "#0"},
|
||||
"south": {"uv": [4.25, 5.33333, 5.75, 6.66667], "texture": "#0"},
|
||||
"west": {"uv": [5.75, 4, 6.5, 5.33333], "texture": "#0"},
|
||||
"up": {"uv": [5.5, 13.33333, 4, 11.33333], "texture": "#0"},
|
||||
"down": {"uv": [3.75, 15.33333, 5.25, 13.33333], "texture": "#0"}
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [11, 0, 4],
|
||||
"to": [11, 2, 7],
|
||||
"rotation": {"angle": 0, "axis": "y", "origin": [7, 2, 12]},
|
||||
"faces": {
|
||||
"north": {"uv": [0, 0, 0, 1.33333], "texture": "#0"},
|
||||
"east": {"uv": [5.75, 5.33333, 6.5, 6.66667], "texture": "#0"},
|
||||
"south": {"uv": [0, 0, 0, 1.33333], "texture": "#0"},
|
||||
"west": {"uv": [6, 1.33333, 6.75, 2.66667], "texture": "#0"},
|
||||
"up": {"uv": [0, 2, 0, 0], "texture": "#0"},
|
||||
"down": {"uv": [0, 0, 0, 2], "texture": "#0"}
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [5, 0, 4],
|
||||
"to": [5, 2, 7],
|
||||
"rotation": {"angle": 0, "axis": "y", "origin": [7, 2, 12]},
|
||||
"faces": {
|
||||
"north": {"uv": [0, 0, 0, 1.33333], "texture": "#0"},
|
||||
"east": {"uv": [6, 0, 6.75, 1.33333], "texture": "#0"},
|
||||
"south": {"uv": [0, 0, 0, 1.33333], "texture": "#0"},
|
||||
"west": {"uv": [5.25, 6.66667, 6, 8], "texture": "#0"},
|
||||
"up": {"uv": [0, 2, 0, 0], "texture": "#0"},
|
||||
"down": {"uv": [0, 0, 0, 2], "texture": "#0"}
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [4, 1, 10],
|
||||
"to": [12, 4, 15],
|
||||
"rotation": {"angle": 0, "axis": "y", "origin": [7, 0, 12]},
|
||||
"faces": {
|
||||
"north": {"uv": [0, 10.66667, 1.75, 14], "texture": "#0"},
|
||||
"east": {"uv": [3.25, 8, 4.5, 10], "texture": "#0"},
|
||||
"south": {"uv": [1.75, 10.66667, 4, 12.66667], "texture": "#0"},
|
||||
"west": {"uv": [2, 8, 3.25, 10], "texture": "#0"},
|
||||
"up": {"uv": [6.5, 11.33333, 4.5, 8], "texture": "#0"},
|
||||
"down": {"uv": [4.25, 4.66667, 2, 8], "texture": "#0"}
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [4, -4, 9],
|
||||
"to": [12, 1, 15],
|
||||
"rotation": {"angle": 0, "axis": "y", "origin": [4, -3, 13]},
|
||||
"faces": {
|
||||
"north": {"uv": [10.75, 3.33333, 12.75, 6.66667], "texture": "#0"},
|
||||
"east": {"uv": [12.75, 0, 14.25, 3.33333], "texture": "#0"},
|
||||
"south": {"uv": [10.75, 0, 12.75, 3.33333], "texture": "#0"},
|
||||
"west": {"uv": [14.25, 0, 15.75, 3.33333], "texture": "#0"},
|
||||
"up": {"uv": [8.75, 4, 10.75, 8], "texture": "#0"},
|
||||
"down": {"uv": [8.75, 0, 10.75, 4], "texture": "#0"}
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [6, -1.3, 10.5],
|
||||
"to": [10, 6.7, 18.5],
|
||||
"rotation": {"angle": 45, "axis": "x", "origin": [7.5, 1.65, 13.5]},
|
||||
"faces": {
|
||||
"north": {"uv": [12.75, 3.33333, 13.75, 8.66667], "texture": "#0"},
|
||||
"east": {"uv": [2, 0, 0, 5.33333], "texture": "#0"},
|
||||
"south": {"uv": [13.75, 3.33333, 14.75, 8.66667], "texture": "#0"},
|
||||
"west": {"uv": [0, 0, 2, 5.33333], "texture": "#0"},
|
||||
"up": {"uv": [12.75, 8.66667, 13.75, 14], "texture": "#0"},
|
||||
"down": {"uv": [13.75, 8.66667, 14.75, 14], "texture": "#0"}
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [4, -1.4, 7.4],
|
||||
"to": [12, -1.4, 18.4],
|
||||
"rotation": {"angle": 45, "axis": "x", "origin": [7.5, 1.65, 13.5]},
|
||||
"faces": {
|
||||
"north": {"uv": [12.75, 3.33333, 13.75, 8.66667], "texture": "#0"},
|
||||
"east": {"uv": [0, 5.33333, 2, 10.66667], "texture": "#0"},
|
||||
"south": {"uv": [13.75, 3.33333, 14.75, 8.66667], "texture": "#0"},
|
||||
"west": {"uv": [0, 0, 2, 5.33333], "texture": "#0"},
|
||||
"up": {"uv": [12.75, 8.66667, 13.75, 14], "texture": "#0"},
|
||||
"down": {"uv": [6.75, 0, 8.75, 6.66667], "texture": "#0"}
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [4.01, -4, 7],
|
||||
"to": [4.01, 4, 15],
|
||||
"faces": {
|
||||
"north": {"uv": [0, 0, 0, 5.33333], "texture": "#0"},
|
||||
"east": {"uv": [8.75, 8, 10.75, 13.33333], "texture": "#0"},
|
||||
"south": {"uv": [0, 0, 0, 5.33333], "texture": "#0"},
|
||||
"west": {"uv": [6.5, 6.66667, 8.5, 12], "texture": "#0"},
|
||||
"up": {"uv": [0, 0, 0, 5.33333], "texture": "#0"},
|
||||
"down": {"uv": [0, 0, 0, 5.33333], "texture": "#0"}
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [11.99, -4, 7],
|
||||
"to": [11.99, 4, 15],
|
||||
"faces": {
|
||||
"north": {"uv": [0, 0, 0, 5.33333], "texture": "#0"},
|
||||
"east": {"uv": [6.5, 6.66667, 8.5, 12], "texture": "#0"},
|
||||
"south": {"uv": [0, 0, 0, 5.33333], "texture": "#0"},
|
||||
"west": {"uv": [10.75, 9.33333, 12.75, 14.66667], "texture": "#0"},
|
||||
"up": {"uv": [0, 0, 0, 5.33333], "texture": "#0"},
|
||||
"down": {"uv": [0, 0, 0, 5.33333], "texture": "#0"}
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [4, 0, 7.01],
|
||||
"to": [12, 4, 7.01],
|
||||
"rotation": {"angle": 0, "axis": "y", "origin": [7, -3, 9]},
|
||||
"faces": {
|
||||
"north": {"uv": [10.75, 3.33333, 12.75, 6.66667], "texture": "#0"},
|
||||
"east": {"uv": [0, 0, 0, 0.66667], "texture": "#0"},
|
||||
"south": {"uv": [10.75, 6.66667, 12.75, 9.33333], "texture": "#0"},
|
||||
"west": {"uv": [0, 0, 0, 0.66667], "texture": "#0"},
|
||||
"up": {"uv": [0.25, 0, 0, 0], "texture": "#0"},
|
||||
"down": {"uv": [0.25, 0, 0, 0], "texture": "#0"}
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [4, -3.99, 12],
|
||||
"to": [12, -3.99, 15],
|
||||
"faces": {
|
||||
"north": {"uv": [0, 0, 2, 0], "texture": "#0"},
|
||||
"east": {"uv": [0, 0, 0.75, 0], "texture": "#0"},
|
||||
"south": {"uv": [0, 0, 2, 0], "texture": "#0"},
|
||||
"west": {"uv": [0, 0, 0.75, 0], "texture": "#0"},
|
||||
"up": {"uv": [10.75, 8.66667, 12.75, 6.66667], "texture": "#0"},
|
||||
"down": {"uv": [10.75, 4.66667, 12.75, 6.66667], "texture": "#0"}
|
||||
}
|
||||
}
|
||||
],
|
||||
"display": {
|
||||
"head": {
|
||||
"translation": [0, 15.25, -6],
|
||||
"scale": [1.9, 1.9, 1.9]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 863 B |
|
After Width: | Height: | Size: 582 B |
|
After Width: | Height: | Size: 245 B |
|
After Width: | Height: | Size: 415 B |
|
After Width: | Height: | Size: 847 B |
|
After Width: | Height: | Size: 268 B |
|
After Width: | Height: | Size: 308 B |
@@ -51,16 +51,6 @@ dependencies {
|
||||
modImplementation(libs.fabric.loader)
|
||||
modApi(libs.fabric.api)
|
||||
modApi(libs.bundles.fabric)
|
||||
|
||||
// VR Support
|
||||
modRuntimeOnly(files("temp/vivecraft-1.21.1-1.3.4-fabric.jar"))
|
||||
runtimeOnly("com.illposed.osc:javaosc-core:0.9")
|
||||
runtimeOnly("com.electronwill.night-config:toml:3.6.6")
|
||||
runtimeOnly("com.electronwill.night-config:core:3.6.6")
|
||||
runtimeOnly("org.lwjgl:lwjgl-openvr:3.3.3")
|
||||
runtimeOnly("org.lwjgl:lwjgl-openvr:3.3.3:natives-linux")
|
||||
runtimeOnly("org.lwjgl:lwjgl-openvr:3.3.3:natives-macos")
|
||||
runtimeOnly("org.lwjgl:lwjgl-openvr:3.3.3:natives-windows")
|
||||
|
||||
modCompileOnly(libs.bundles.common.integrations.compileOnly) {
|
||||
isTransitive = false
|
||||
|
||||
@@ -250,6 +250,10 @@ object CobblemonFabric : CobblemonImplementation {
|
||||
EntityDataSerializers.registerSerializer(RideBoostsDataSerializer)
|
||||
}
|
||||
|
||||
override fun registerArmorMaterials() {
|
||||
CobblemonArmorMaterials.register { identifier, armorMaterial -> Registry.register(CobblemonArmorMaterials.registry, identifier, armorMaterial) }
|
||||
}
|
||||
|
||||
override fun registerItems() {
|
||||
CobblemonItems.register { identifier, item -> Registry.register(CobblemonItems.registry, identifier, item) }
|
||||
CobblemonItemGroups.register { provider ->
|
||||
|
||||
@@ -170,18 +170,6 @@ class CobblemonFabricClient: ClientModInitializer, CobblemonClientImplementation
|
||||
)
|
||||
)
|
||||
}
|
||||
WorldRenderEvents.AFTER_ENTITIES.register { context -> PlatformEvents.RENDER.post(
|
||||
RenderEvent(
|
||||
stage = RenderEvent.Stage.AFTER_ENTITIES,
|
||||
levelRenderer = context.worldRenderer(),
|
||||
poseStack = context.matrixStack() ?: PoseStack(),
|
||||
modelViewMatrix = context.positionMatrix(),
|
||||
projectionMatrix = context.projectionMatrix(),
|
||||
tickCounter = context.tickCounter(),
|
||||
camera = context.camera()
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
CobblemonModelPredicateRegistry.registerPredicates()
|
||||
}
|
||||
|
||||
@@ -39,14 +39,6 @@ dependencies {
|
||||
//include(libs.flywheelForge)
|
||||
modLocalRuntime(libs.neoforge.debugutils)
|
||||
modRuntimeOnly(libs.bundles.neoforge.integrations.runtimeOnly)
|
||||
|
||||
// VR Support
|
||||
modRuntimeOnly(files("temp/vivecraft-1.21.1-1.3.4-neoforge.jar"))
|
||||
runtimeOnly("com.illposed.osc:javaosc-core:0.9")
|
||||
runtimeOnly("org.lwjgl:lwjgl-openvr:3.3.3")
|
||||
runtimeOnly("org.lwjgl:lwjgl-openvr:3.3.3:natives-linux")
|
||||
runtimeOnly("org.lwjgl:lwjgl-openvr:3.3.3:natives-macos")
|
||||
runtimeOnly("org.lwjgl:lwjgl-openvr:3.3.3:natives-windows")
|
||||
|
||||
implementation(libs.neo.kotlin.forge)
|
||||
|
||||
|
||||
@@ -9,21 +9,10 @@
|
||||
package com.cobblemon.mod.neoforge
|
||||
|
||||
import com.cobblemon.mod.common.*
|
||||
import com.cobblemon.mod.common.CobblemonRecipeCategories.COOKING_POT_COMPLEX_DISHES
|
||||
import com.cobblemon.mod.common.CobblemonRecipeCategories.COOKING_POT_FOODS
|
||||
import com.cobblemon.mod.common.CobblemonRecipeCategories.COOKING_POT_MEDICINES
|
||||
import com.cobblemon.mod.common.CobblemonRecipeCategories.COOKING_POT_MISC
|
||||
import com.cobblemon.mod.common.CobblemonRecipeCategories.COOKING_POT_SEARCH
|
||||
import com.cobblemon.mod.common.CobblemonRecipeCategories.*
|
||||
import com.cobblemon.mod.common.advancement.CobblemonCriteria
|
||||
import com.cobblemon.mod.common.advancement.predicate.CobblemonEntitySubPredicates
|
||||
import com.cobblemon.mod.common.api.net.serializers.IdentifierDataSerializer
|
||||
import com.cobblemon.mod.common.api.net.serializers.NPCPlayerTextureSerializer
|
||||
import com.cobblemon.mod.common.api.net.serializers.PlatformTypeDataSerializer
|
||||
import com.cobblemon.mod.common.api.net.serializers.PoseTypeDataSerializer
|
||||
import com.cobblemon.mod.common.api.net.serializers.RideBoostsDataSerializer
|
||||
import com.cobblemon.mod.common.api.net.serializers.StringSetDataSerializer
|
||||
import com.cobblemon.mod.common.api.net.serializers.UUIDSetDataSerializer
|
||||
import com.cobblemon.mod.common.api.net.serializers.Vec3DataSerializer
|
||||
import com.cobblemon.mod.common.api.net.serializers.*
|
||||
import com.cobblemon.mod.common.item.group.CobblemonItemGroups
|
||||
import com.cobblemon.mod.common.loot.LootInjector
|
||||
import com.cobblemon.mod.common.particle.CobblemonParticles
|
||||
@@ -42,13 +31,9 @@ import com.cobblemon.mod.neoforge.net.CobblemonNeoForgeNetworkManager
|
||||
import com.cobblemon.mod.neoforge.permission.ForgePermissionValidator
|
||||
import com.cobblemon.mod.neoforge.worldgen.CobblemonBiomeModifiers
|
||||
import com.mojang.brigadier.arguments.ArgumentType
|
||||
import java.util.Optional
|
||||
import java.util.UUID
|
||||
import net.minecraft.commands.synchronization.ArgumentTypeInfo
|
||||
import net.minecraft.commands.synchronization.ArgumentTypeInfos
|
||||
import net.minecraft.core.registries.BuiltInRegistries
|
||||
import net.minecraft.core.registries.Registries
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.resources.ResourceKey
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
import net.minecraft.server.MinecraftServer
|
||||
@@ -83,12 +68,7 @@ import net.neoforged.neoforge.client.event.RegisterRecipeBookCategoriesEvent
|
||||
import net.neoforged.neoforge.common.ItemAbilities
|
||||
import net.neoforged.neoforge.common.NeoForge
|
||||
import net.neoforged.neoforge.common.NeoForgeMod
|
||||
import net.neoforged.neoforge.event.AddPackFindersEvent
|
||||
import net.neoforged.neoforge.event.AddReloadListenerEvent
|
||||
import net.neoforged.neoforge.event.BuildCreativeModeTabContentsEvent
|
||||
import net.neoforged.neoforge.event.LootTableLoadEvent
|
||||
import net.neoforged.neoforge.event.OnDatapackSyncEvent
|
||||
import net.neoforged.neoforge.event.RegisterCommandsEvent
|
||||
import net.neoforged.neoforge.event.*
|
||||
import net.neoforged.neoforge.event.entity.EntityAttributeCreationEvent
|
||||
import net.neoforged.neoforge.event.entity.player.PlayerEvent
|
||||
import net.neoforged.neoforge.event.entity.player.PlayerWakeUpEvent
|
||||
@@ -101,6 +81,7 @@ import net.neoforged.neoforge.registries.NeoForgeRegistries
|
||||
import net.neoforged.neoforge.registries.RegisterEvent
|
||||
import net.neoforged.neoforge.server.ServerLifecycleHooks
|
||||
import thedarkcolour.kotlinforforge.neoforge.forge.MOD_BUS
|
||||
import java.util.*
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
@Mod(Cobblemon.MODID)
|
||||
@@ -331,6 +312,16 @@ class CobblemonNeoForge : CobblemonImplementation {
|
||||
}
|
||||
}
|
||||
|
||||
override fun registerArmorMaterials() {
|
||||
with(MOD_BUS) {
|
||||
addListener<RegisterEvent> { event ->
|
||||
event.register(CobblemonArmorMaterials.resourceKey) { helper ->
|
||||
CobblemonArmorMaterials.register { identifier, armorMaterial -> helper.register(identifier, armorMaterial) }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun registerItems() {
|
||||
with(MOD_BUS) {
|
||||
addListener<RegisterEvent> { event ->
|
||||
|
||||
@@ -74,7 +74,6 @@ object NeoForgeClientPlatformEventHandler {
|
||||
fun onRenderLevelStageEvent(event: RenderLevelStageEvent) {
|
||||
val stage = when (event.stage) {
|
||||
RenderLevelStageEvent.Stage.AFTER_PARTICLES -> RenderEvent.Stage.TRANSLUCENT
|
||||
RenderLevelStageEvent.Stage.AFTER_ENTITIES -> RenderEvent.Stage.AFTER_ENTITIES
|
||||
else -> return
|
||||
}
|
||||
|
||||
|
||||