mirror of
https://gitlab.com/cable-mc/cobblemon.git
synced 2026-10-21 06:36:25 -04:00
Compare commits
53
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ba3207d176 | ||
|
|
762f9ce5f1 | ||
|
|
6c12198344 | ||
|
|
06ebf51078 | ||
|
|
39c5bcd73c | ||
|
|
8f5f158b60 | ||
|
|
3bc1e35125 | ||
|
|
460bedddae | ||
|
|
8b64c315f3 | ||
|
|
7c824a2b72 | ||
|
|
f197ac5077 | ||
|
|
e0be669482 | ||
|
|
08ea21fff4 | ||
|
|
99a0ec7f0d | ||
|
|
aacebc9726 | ||
|
|
378c85b7dd | ||
|
|
c4614ff418 | ||
|
|
8cbbd2de27 | ||
|
|
067c59a636 | ||
|
|
98a02438da | ||
|
|
28c0f8ab7d | ||
|
|
fcbe0db568 | ||
|
|
83cefe476e | ||
|
|
690ccbd260 | ||
|
|
63846d53fb | ||
|
|
86cb865742 | ||
|
|
1a0c9b6a82 | ||
|
|
985eb103fe | ||
|
|
aec76a78da | ||
|
|
17f3edf2be | ||
|
|
9c5bfda20f | ||
|
|
26b25c8c39 | ||
|
|
6d545fc1ca | ||
|
|
bfd78c1a85 | ||
|
|
239485ccb5 | ||
|
|
ff959daaef | ||
|
|
32bb340260 | ||
|
|
7e6ca7be5e | ||
|
|
b7bfc6d0a1 | ||
|
|
a575c6bc3d | ||
|
|
9c102a7850 | ||
|
|
22a1eaab19 | ||
|
|
0118ace5fc | ||
|
|
d4a93abbf7 | ||
|
|
d0ee3f3e9d | ||
|
|
46ae53f565 | ||
|
|
4d123b6e4b | ||
|
|
d86879095f | ||
|
|
29b560d244 | ||
|
|
7cedfb9047 | ||
|
|
a7ab2e37c2 | ||
|
|
4723f91500 | ||
|
|
e23aa6b066 |
@@ -2,22 +2,48 @@
|
||||
## [1.7.2 (MONTH Xth, YEAR)](#1-7-2)
|
||||
|
||||
### Additions
|
||||
- Added riding statistics: `Distance by Pokémon on Land`, `Distance by Pokémon in Air` and `Distance by Pokémon in Liquid`.
|
||||
- Added the Partner Mark, which party Pokémon have a very small chance to earn as the player walks, provided they have enough friendship.
|
||||
- Added trades for Saccharine Saplings, Hearty Grains, Chipped Pot, and Masterpiece Teacup to the Wandering Trader.
|
||||
- Added brewing recipe for Throat Spray.
|
||||
- Added official Controlify Support
|
||||
- Added new effects
|
||||
- Mental Restoration: Reduces "Time Since Last Rest" statistic, which controls Insomnia, by half a minute per second per effect level
|
||||
- Negative Effect Cleanse: Removes all negative effects
|
||||
- Effect Cleanse: Removes all effects
|
||||
- Added more seasonings for sinister tea
|
||||
- Mental Herb - Mental Restoration I for 10 seconds
|
||||
- White Herb - Negative Effect Cleanse
|
||||
- Milk - Effect Cleanse
|
||||
- Moomoo Milk - Effect Cleanse
|
||||
|
||||
### Changes
|
||||
- Ride sounds have been separated into stereo for passengers and mono for other players. Riding will now sound more spacious.
|
||||
|
||||
### Fixes
|
||||
- Fixed orientation not getting reset after crashing while flying and getting back on the Pokémon.
|
||||
- Fixed Furfrou not being trimmable on NeoForge.
|
||||
- Fixed shiny Pokémon not respecting the silent flag on spawn.
|
||||
- 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
|
||||
- Fixed missing apricorn textures for Adorn blocks
|
||||
- Fixed crashing when riding due to malformed json file, instead resetting it
|
||||
- Fixed mochi items consuming two items at a time
|
||||
- Fix item interaction sometimes not working properly when playing on servers.
|
||||
- Fixed Soothe Bell not being properly tagged as a held item.
|
||||
- Fixed Mint Leaves not being usable for filling the Resurrection Machine.
|
||||
- Added Saccharine Boats and Saccharine Boat with Chests to relevant boat tags.
|
||||
|
||||
### Developer
|
||||
- Changed the `owner` parameter in the `OwnerQueryRequirement` interface from `ServerPlayer` to `Player`. This method is now also called on the client to verify whether a Pokémon interaction succeeded, so make sure to update your implementations to handle both server and client contexts.
|
||||
|
||||
### Molang & Datapacks
|
||||
- Ride sounds can now be set as exclusive to passengers
|
||||
- Ride sounds no longer play when submerged unless specified with a new setting
|
||||
|
||||
### Particles
|
||||
|
||||
|
||||
@@ -32,6 +32,10 @@ repositories {
|
||||
maven(url = "https://api.modrinth.com/maven")
|
||||
maven(url = "https://maven.neoforged.net/releases")
|
||||
maven(url = "https://maven.gegy.dev")
|
||||
exclusiveContent {
|
||||
forRepository { maven(url = "https://maven.isxander.dev/releases") }
|
||||
filter { includeGroup("dev.isxander") }
|
||||
}
|
||||
mavenLocal()
|
||||
}
|
||||
|
||||
@@ -62,6 +66,11 @@ dependencies {
|
||||
|
||||
// Unit Testing
|
||||
testImplementation(libs.bundles.unitTesting)
|
||||
|
||||
// Controlify Compat, same as flywheel so we pick one and only use the api
|
||||
modCompileOnlyApi("dev.isxander:controlify:2.4.3+1.21.1-fabric") {
|
||||
isTransitive = false
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType<Test> {
|
||||
|
||||
@@ -11,11 +11,15 @@ package com.cobblemon.mod.common.mixin;
|
||||
import com.cobblemon.mod.common.Cobblemon;
|
||||
import com.cobblemon.mod.common.OrientationControllable;
|
||||
import com.cobblemon.mod.common.PlayerSpawnerAccessor;
|
||||
import com.cobblemon.mod.common.api.riding.RidingStyle;
|
||||
import com.cobblemon.mod.common.api.spawning.spawner.PlayerSpawner;
|
||||
import com.cobblemon.mod.common.api.spawning.spawner.PlayerSpawnerFactory;
|
||||
import com.cobblemon.mod.common.api.stats.CobblemonStats;
|
||||
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity;
|
||||
import com.cobblemon.mod.common.world.gamerules.CobblemonGameRules;
|
||||
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
@@ -89,4 +93,32 @@ public abstract class ServerPlayerMixin implements PlayerSpawnerAccessor {
|
||||
private boolean cobblemon$cancelSavingPokemonMounts(boolean original, @Local(ordinal=0) Entity entity) {
|
||||
return original && !(entity instanceof PokemonEntity);
|
||||
}
|
||||
|
||||
@WrapOperation(method = "checkRidingStatistics", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ServerPlayer;getVehicle()Lnet/minecraft/world/entity/Entity;"))
|
||||
public Entity cobblemon$checkRidingStatistics(ServerPlayer player, Operation<Entity> original, @Local int distance) {
|
||||
var entity = original.call(player);
|
||||
if (!(entity instanceof PokemonEntity pokemonEntity)) {
|
||||
return entity;
|
||||
}
|
||||
|
||||
var ridingController = pokemonEntity.getRidingController();
|
||||
if (ridingController == null) return entity;
|
||||
|
||||
var activeContext = ridingController.getContext();
|
||||
if (activeContext == null) return entity;
|
||||
|
||||
var ridingStyle = activeContext.getStyle();
|
||||
CobblemonStats.CobblemonStat stat = switch (ridingStyle) {
|
||||
case RidingStyle.LAND -> CobblemonStats.RIDING_LAND;
|
||||
case RidingStyle.AIR -> CobblemonStats.RIDING_AIR;
|
||||
case RidingStyle.LIQUID -> CobblemonStats.RIDING_LIQUID;
|
||||
default -> null;
|
||||
};
|
||||
|
||||
if (stat != null) {
|
||||
player.awardStat(CobblemonStats.getStat(stat), distance);
|
||||
}
|
||||
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,12 +21,14 @@ import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import com.mojang.blaze3d.Blaze3D;
|
||||
import kotlin.Pair;
|
||||
import kotlin.jvm.functions.Function4;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.MouseHandler;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.util.SmoothDouble;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.joml.Vector2d;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@@ -146,6 +148,12 @@ public abstract class MouseHandlerMixin {
|
||||
pokeVehicle.clampPassengerRotation(player);
|
||||
}
|
||||
|
||||
for(Function4<LocalPlayer, Double, Double, Double, Vector2d> rideFun : CobblemonClient.INSTANCE.getRidingTurnInputHandler().values()) {
|
||||
Vector2d vec = rideFun.invoke(player, cursorDeltaX, cursorDeltaY, d);
|
||||
cursorDeltaX = vec.x;
|
||||
cursorDeltaY = vec.y;
|
||||
}
|
||||
|
||||
// If the ride is not orientation controllable then return and perform the normal turnPlayer logic
|
||||
if (!(vehicle instanceof OrientationControllable controllableVehicle) || !controllableVehicle.getOrientationController().isActive()) {
|
||||
xMouseSmoother.reset();
|
||||
|
||||
@@ -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.position.AreaSpawnablePositionResolver
|
||||
import com.cobblemon.mod.common.api.spawning.SpawningZoneGenerator
|
||||
import com.cobblemon.mod.common.api.spawning.position.AreaSpawnablePositionResolver
|
||||
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,12 +76,7 @@ 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.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.events.*
|
||||
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
|
||||
@@ -206,6 +201,7 @@ object Cobblemon {
|
||||
implementation.registerEntityDataSerializers()
|
||||
implementation.registerCriteria()
|
||||
implementation.registerEntitySubPredicates()
|
||||
implementation.registerMobEffects()
|
||||
DispenserBehaviorRegistry.registerDispenserBehaviors()
|
||||
|
||||
DropEntry.register("command", CommandDropEntry::class.java)
|
||||
|
||||
@@ -117,6 +117,11 @@ interface CobblemonImplementation {
|
||||
|
||||
fun registerEntitySubPredicates()
|
||||
|
||||
/**
|
||||
* TODO
|
||||
*/
|
||||
fun registerMobEffects()
|
||||
|
||||
|
||||
/**
|
||||
* Add a feature to the current platform implementation.
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* 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
|
||||
|
||||
import com.cobblemon.mod.common.api.cooking.effects.CleanseAllEffect
|
||||
import com.cobblemon.mod.common.api.cooking.effects.CleanseNegativeEffect
|
||||
import com.cobblemon.mod.common.api.cooking.effects.MentalRestorationEffect
|
||||
import com.cobblemon.mod.common.platform.PlatformRegistry
|
||||
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.world.effect.MobEffect
|
||||
|
||||
object CobblemonMobEffects : PlatformRegistry<Registry<MobEffect>, ResourceKey<Registry<MobEffect>>, MobEffect>() {
|
||||
override val registry: Registry<MobEffect> = BuiltInRegistries.MOB_EFFECT
|
||||
override val resourceKey: ResourceKey<Registry<MobEffect>> = Registries.MOB_EFFECT
|
||||
|
||||
@JvmField
|
||||
val CLEANSE_NEGATIVE = create("cleanse_negative", CleanseNegativeEffect())
|
||||
|
||||
@JvmField
|
||||
val MENTAL_RESTORATION = create("mental_restoration", MentalRestorationEffect())
|
||||
|
||||
@JvmField
|
||||
val CLEANSE_ALL = create("cleanse_all", CleanseAllEffect())
|
||||
}
|
||||
@@ -21,15 +21,12 @@ import com.cobblemon.mod.common.client.net.callback.partymove.OpenPartyMoveCallb
|
||||
import com.cobblemon.mod.common.client.net.cooking.ToggleCookingPotLidHandler
|
||||
import com.cobblemon.mod.common.client.net.data.CobblemonMechanicsSyncHandler
|
||||
import com.cobblemon.mod.common.client.net.data.DataRegistrySyncPacketHandler
|
||||
import com.cobblemon.mod.common.client.net.data.PokemonInteractionsSyncHandler
|
||||
import com.cobblemon.mod.common.client.net.data.RideSettingsSyncHandler
|
||||
import com.cobblemon.mod.common.client.net.debug.OpenRidingStatsDebugGUIHandler
|
||||
import com.cobblemon.mod.common.client.net.dialogue.DialogueClosedHandler
|
||||
import com.cobblemon.mod.common.client.net.dialogue.DialogueOpenedHandler
|
||||
import com.cobblemon.mod.common.client.net.effect.PokeSnackBlockParticlesHandler
|
||||
import com.cobblemon.mod.common.client.net.effect.RunPosableMoLangHandler
|
||||
import com.cobblemon.mod.common.client.net.effect.SaccharineLogBlockParticlesHandler
|
||||
import com.cobblemon.mod.common.client.net.effect.SpawnSnowstormEntityParticleHandler
|
||||
import com.cobblemon.mod.common.client.net.effect.SpawnSnowstormParticleHandler
|
||||
import com.cobblemon.mod.common.client.net.effect.*
|
||||
import com.cobblemon.mod.common.client.net.gui.ExpGainedDataPacketHandler
|
||||
import com.cobblemon.mod.common.client.net.gui.InteractPokemonUIPacketHandler
|
||||
import com.cobblemon.mod.common.client.net.gui.PokedexUIPacketHandler
|
||||
@@ -37,11 +34,7 @@ import com.cobblemon.mod.common.client.net.gui.SummaryUIPacketHandler
|
||||
import com.cobblemon.mod.common.client.net.npc.CloseNPCEditorHandler
|
||||
import com.cobblemon.mod.common.client.net.npc.OpenNPCEditorHandler
|
||||
import com.cobblemon.mod.common.client.net.orientation.ClientboundUpdateOrientationHandler
|
||||
import com.cobblemon.mod.common.client.net.pasture.ClosePastureHandler
|
||||
import com.cobblemon.mod.common.client.net.pasture.OpenPastureHandler
|
||||
import com.cobblemon.mod.common.client.net.pasture.PokemonPasturedHandler
|
||||
import com.cobblemon.mod.common.client.net.pasture.PokemonUnpasturedHandler
|
||||
import com.cobblemon.mod.common.client.net.pasture.UpdatePastureConflictFlagHandler
|
||||
import com.cobblemon.mod.common.client.net.pasture.*
|
||||
import com.cobblemon.mod.common.client.net.pokedex.ServerConfirmedRegisterHandler
|
||||
import com.cobblemon.mod.common.client.net.pokemon.update.ClientboundUpdateRidingStateHandler
|
||||
import com.cobblemon.mod.common.client.net.pokemon.update.PokemonUpdatePacketHandler
|
||||
@@ -59,14 +52,7 @@ import com.cobblemon.mod.common.client.net.storage.party.SetPartyPokemonHandler
|
||||
import com.cobblemon.mod.common.client.net.storage.party.SetPartyReferenceHandler
|
||||
import com.cobblemon.mod.common.client.net.storage.pc.*
|
||||
import com.cobblemon.mod.common.client.net.toast.ToastPacketHandler
|
||||
import com.cobblemon.mod.common.client.net.trade.TradeAcceptanceChangedHandler
|
||||
import com.cobblemon.mod.common.client.net.trade.TradeCancelledHandler
|
||||
import com.cobblemon.mod.common.client.net.trade.TradeCompletedHandler
|
||||
import com.cobblemon.mod.common.client.net.trade.TradeOfferExpiredHandler
|
||||
import com.cobblemon.mod.common.client.net.trade.TradeOfferNotificationHandler
|
||||
import com.cobblemon.mod.common.client.net.trade.TradeProcessStartedHandler
|
||||
import com.cobblemon.mod.common.client.net.trade.TradeStartedHandler
|
||||
import com.cobblemon.mod.common.client.net.trade.TradeUpdatedHandler
|
||||
import com.cobblemon.mod.common.client.net.trade.*
|
||||
import com.cobblemon.mod.common.net.PacketRegisterInfo
|
||||
import com.cobblemon.mod.common.net.messages.client.CalculateSeatPositionsPacket
|
||||
import com.cobblemon.mod.common.net.messages.client.OpenBehaviourEditorPacket
|
||||
@@ -83,20 +69,12 @@ import com.cobblemon.mod.common.net.messages.client.data.*
|
||||
import com.cobblemon.mod.common.net.messages.client.debug.RequestOpenRidingStatsDebugGUIPacket
|
||||
import com.cobblemon.mod.common.net.messages.client.dialogue.DialogueClosedPacket
|
||||
import com.cobblemon.mod.common.net.messages.client.dialogue.DialogueOpenedPacket
|
||||
import com.cobblemon.mod.common.net.messages.client.effect.PokeSnackBlockParticlesPacket
|
||||
import com.cobblemon.mod.common.net.messages.client.effect.RunPosableMoLangPacket
|
||||
import com.cobblemon.mod.common.net.messages.client.effect.SaccharineLogBlockParticlesPacket
|
||||
import com.cobblemon.mod.common.net.messages.client.effect.SpawnSnowstormEntityParticlePacket
|
||||
import com.cobblemon.mod.common.net.messages.client.effect.SpawnSnowstormParticlePacket
|
||||
import com.cobblemon.mod.common.net.messages.client.effect.*
|
||||
import com.cobblemon.mod.common.net.messages.client.npc.CloseNPCEditorPacket
|
||||
import com.cobblemon.mod.common.net.messages.client.npc.OpenNPCEditorPacket
|
||||
import com.cobblemon.mod.common.net.messages.client.orientation.ClientboundUpdateDriverInputPacket
|
||||
import com.cobblemon.mod.common.net.messages.client.orientation.ClientboundUpdateOrientationPacket
|
||||
import com.cobblemon.mod.common.net.messages.client.pasture.ClosePasturePacket
|
||||
import com.cobblemon.mod.common.net.messages.client.pasture.OpenPasturePacket
|
||||
import com.cobblemon.mod.common.net.messages.client.pasture.PokemonPasturedPacket
|
||||
import com.cobblemon.mod.common.net.messages.client.pasture.PokemonUnpasturedPacket
|
||||
import com.cobblemon.mod.common.net.messages.client.pasture.UpdatePastureConflictFlagPacket
|
||||
import com.cobblemon.mod.common.net.messages.client.pasture.*
|
||||
import com.cobblemon.mod.common.net.messages.client.pokedex.ServerConfirmedRegisterPacket
|
||||
import com.cobblemon.mod.common.net.messages.client.pokemon.update.*
|
||||
import com.cobblemon.mod.common.net.messages.client.pokemon.update.evolution.AddEvolutionPacket
|
||||
@@ -116,43 +94,19 @@ import com.cobblemon.mod.common.net.messages.client.storage.party.InitializePart
|
||||
import com.cobblemon.mod.common.net.messages.client.storage.party.MoveClientPartyPokemonPacket
|
||||
import com.cobblemon.mod.common.net.messages.client.storage.party.SetPartyPokemonPacket
|
||||
import com.cobblemon.mod.common.net.messages.client.storage.party.SetPartyReferencePacket
|
||||
import com.cobblemon.mod.common.net.messages.client.storage.pc.ClosePCPacket
|
||||
import com.cobblemon.mod.common.net.messages.client.storage.pc.InitializePCPacket
|
||||
import com.cobblemon.mod.common.net.messages.client.storage.pc.MoveClientPCPokemonPacket
|
||||
import com.cobblemon.mod.common.net.messages.client.storage.pc.OpenPCPacket
|
||||
import com.cobblemon.mod.common.net.messages.client.storage.pc.RenamePCBoxPacket
|
||||
import com.cobblemon.mod.common.net.messages.client.storage.pc.SetPCBoxPacket
|
||||
import com.cobblemon.mod.common.net.messages.client.storage.pc.SetPCPokemonPacket
|
||||
import com.cobblemon.mod.common.net.messages.client.storage.pc.*
|
||||
import com.cobblemon.mod.common.net.messages.client.storage.pc.wallpaper.ChangePCBoxWallpaperPacket
|
||||
import com.cobblemon.mod.common.net.messages.client.storage.pc.wallpaper.RequestPCBoxWallpapersPacket
|
||||
import com.cobblemon.mod.common.net.messages.client.storage.pc.wallpaper.SetPCBoxWallpapersPacket
|
||||
import com.cobblemon.mod.common.net.messages.client.storage.pc.wallpaper.UnlockPCBoxWallpaperPacket
|
||||
import com.cobblemon.mod.common.net.messages.client.toast.ToastPacket
|
||||
import com.cobblemon.mod.common.net.messages.client.trade.TradeAcceptanceChangedPacket
|
||||
import com.cobblemon.mod.common.net.messages.client.trade.TradeCancelledPacket
|
||||
import com.cobblemon.mod.common.net.messages.client.trade.TradeCompletedPacket
|
||||
import com.cobblemon.mod.common.net.messages.client.trade.TradeOfferExpiredPacket
|
||||
import com.cobblemon.mod.common.net.messages.client.trade.TradeOfferNotificationPacket
|
||||
import com.cobblemon.mod.common.net.messages.client.trade.TradeProcessStartedPacket
|
||||
import com.cobblemon.mod.common.net.messages.client.trade.TradeStartedPacket
|
||||
import com.cobblemon.mod.common.net.messages.client.trade.TradeUpdatedPacket
|
||||
import com.cobblemon.mod.common.net.messages.client.trade.*
|
||||
import com.cobblemon.mod.common.net.messages.client.ui.ExpGainedDataPacket
|
||||
import com.cobblemon.mod.common.net.messages.client.ui.InteractPokemonUIPacket
|
||||
import com.cobblemon.mod.common.net.messages.client.ui.PokedexUIPacket
|
||||
import com.cobblemon.mod.common.net.messages.client.ui.SummaryUIPacket
|
||||
import com.cobblemon.mod.common.net.messages.server.BattleChallengePacket
|
||||
import com.cobblemon.mod.common.net.messages.server.BattleChallengeResponsePacket
|
||||
import com.cobblemon.mod.common.net.messages.server.BenchMovePacket
|
||||
import com.cobblemon.mod.common.net.messages.server.RequestMoveSwapPacket
|
||||
import com.cobblemon.mod.common.net.messages.server.RequestPlayerInteractionsPacket
|
||||
import com.cobblemon.mod.common.net.messages.server.SelectStarterPacket
|
||||
import com.cobblemon.mod.common.net.messages.server.SendOutPokemonPacket
|
||||
import com.cobblemon.mod.common.net.messages.server.battle.BattleSelectActionsPacket
|
||||
import com.cobblemon.mod.common.net.messages.server.battle.BattleTeamLeavePacket
|
||||
import com.cobblemon.mod.common.net.messages.server.battle.BattleTeamRequestPacket
|
||||
import com.cobblemon.mod.common.net.messages.server.battle.BattleTeamResponsePacket
|
||||
import com.cobblemon.mod.common.net.messages.server.battle.RemoveSpectatorPacket
|
||||
import com.cobblemon.mod.common.net.messages.server.battle.SpectateBattlePacket
|
||||
import com.cobblemon.mod.common.net.messages.server.*
|
||||
import com.cobblemon.mod.common.net.messages.server.battle.*
|
||||
import com.cobblemon.mod.common.net.messages.server.behaviour.DamageOnCollisionPacket
|
||||
import com.cobblemon.mod.common.net.messages.server.behaviour.SetEntityBehaviourPacket
|
||||
import com.cobblemon.mod.common.net.messages.server.block.AdjustBlockEntityViewerCountPacket
|
||||
@@ -177,11 +131,7 @@ import com.cobblemon.mod.common.net.messages.server.pasture.UnpasturePokemonPack
|
||||
import com.cobblemon.mod.common.net.messages.server.pokedex.scanner.FinishScanningPacket
|
||||
import com.cobblemon.mod.common.net.messages.server.pokedex.scanner.StartScanningPacket
|
||||
import com.cobblemon.mod.common.net.messages.server.pokemon.interact.InteractPokemonPacket
|
||||
import com.cobblemon.mod.common.net.messages.server.pokemon.update.ServerboundUpdateRidingStatePacket
|
||||
import com.cobblemon.mod.common.net.messages.server.pokemon.update.SetActiveMarkPacket
|
||||
import com.cobblemon.mod.common.net.messages.server.pokemon.update.SetItemHiddenPacket
|
||||
import com.cobblemon.mod.common.net.messages.server.pokemon.update.SetMarkingsPacket
|
||||
import com.cobblemon.mod.common.net.messages.server.pokemon.update.SetNicknamePacket
|
||||
import com.cobblemon.mod.common.net.messages.server.pokemon.update.*
|
||||
import com.cobblemon.mod.common.net.messages.server.pokemon.update.evolution.AcceptEvolutionPacket
|
||||
import com.cobblemon.mod.common.net.messages.server.riding.DismountPokemonPacket
|
||||
import com.cobblemon.mod.common.net.messages.server.riding.ServerboundUpdateDriverInputPacket
|
||||
@@ -192,21 +142,11 @@ import com.cobblemon.mod.common.net.messages.server.storage.party.MovePartyPokem
|
||||
import com.cobblemon.mod.common.net.messages.server.storage.party.ReleasePartyPokemonPacket
|
||||
import com.cobblemon.mod.common.net.messages.server.storage.party.SwapPartyPokemonPacket
|
||||
import com.cobblemon.mod.common.net.messages.server.storage.pc.*
|
||||
import com.cobblemon.mod.common.net.messages.server.trade.AcceptTradeRequestPacket
|
||||
import com.cobblemon.mod.common.net.messages.server.trade.CancelTradePacket
|
||||
import com.cobblemon.mod.common.net.messages.server.trade.ChangeTradeAcceptancePacket
|
||||
import com.cobblemon.mod.common.net.messages.server.trade.OfferTradePacket
|
||||
import com.cobblemon.mod.common.net.messages.server.trade.PerformTradePacket
|
||||
import com.cobblemon.mod.common.net.messages.server.trade.UpdateTradeOfferPacket
|
||||
import com.cobblemon.mod.common.net.messages.server.trade.*
|
||||
import com.cobblemon.mod.common.net.serverhandling.ChallengeHandler
|
||||
import com.cobblemon.mod.common.net.serverhandling.ChallengeResponseHandler
|
||||
import com.cobblemon.mod.common.net.serverhandling.RequestInteractionsHandler
|
||||
import com.cobblemon.mod.common.net.serverhandling.battle.BattleSelectActionsHandler
|
||||
import com.cobblemon.mod.common.net.serverhandling.battle.RemoveSpectatorHandler
|
||||
import com.cobblemon.mod.common.net.serverhandling.battle.SpectateBattleHandler
|
||||
import com.cobblemon.mod.common.net.serverhandling.battle.TeamLeaveHandler
|
||||
import com.cobblemon.mod.common.net.serverhandling.battle.TeamRequestHandler
|
||||
import com.cobblemon.mod.common.net.serverhandling.battle.TeamRequestResponseHandler
|
||||
import com.cobblemon.mod.common.net.serverhandling.battle.*
|
||||
import com.cobblemon.mod.common.net.serverhandling.behaviour.DamageOnCollisionPacketHandler
|
||||
import com.cobblemon.mod.common.net.serverhandling.behaviour.SetEntityBehaviourHandler
|
||||
import com.cobblemon.mod.common.net.serverhandling.block.AdjustBlockEntityViewerCountHandler
|
||||
@@ -232,11 +172,7 @@ import com.cobblemon.mod.common.net.serverhandling.pasture.UnpasturePokemonHandl
|
||||
import com.cobblemon.mod.common.net.serverhandling.pokedex.scanner.FinishScanningHandler
|
||||
import com.cobblemon.mod.common.net.serverhandling.pokedex.scanner.StartScanningHandler
|
||||
import com.cobblemon.mod.common.net.serverhandling.pokemon.interact.InteractPokemonHandler
|
||||
import com.cobblemon.mod.common.net.serverhandling.pokemon.update.ServerboundUpdateRidingStateHandler
|
||||
import com.cobblemon.mod.common.net.serverhandling.pokemon.update.SetActiveMarkHandler
|
||||
import com.cobblemon.mod.common.net.serverhandling.pokemon.update.SetItemHiddenHandler
|
||||
import com.cobblemon.mod.common.net.serverhandling.pokemon.update.SetMarkingsHandler
|
||||
import com.cobblemon.mod.common.net.serverhandling.pokemon.update.SetNicknameHandler
|
||||
import com.cobblemon.mod.common.net.serverhandling.pokemon.update.*
|
||||
import com.cobblemon.mod.common.net.serverhandling.riding.DismountPokemonPacketHandler
|
||||
import com.cobblemon.mod.common.net.serverhandling.riding.DriverInputPacketHandler
|
||||
import com.cobblemon.mod.common.net.serverhandling.riding.ServerboundUpdateRiderRotationHandler
|
||||
@@ -250,12 +186,7 @@ import com.cobblemon.mod.common.net.serverhandling.storage.party.MovePartyPokemo
|
||||
import com.cobblemon.mod.common.net.serverhandling.storage.party.ReleasePCPokemonHandler
|
||||
import com.cobblemon.mod.common.net.serverhandling.storage.party.SwapPartyPokemonHandler
|
||||
import com.cobblemon.mod.common.net.serverhandling.storage.pc.*
|
||||
import com.cobblemon.mod.common.net.serverhandling.trade.AcceptTradeRequestHandler
|
||||
import com.cobblemon.mod.common.net.serverhandling.trade.CancelTradeHandler
|
||||
import com.cobblemon.mod.common.net.serverhandling.trade.ChangeTradeAcceptanceHandler
|
||||
import com.cobblemon.mod.common.net.serverhandling.trade.OfferTradeHandler
|
||||
import com.cobblemon.mod.common.net.serverhandling.trade.PerformTradeHandler
|
||||
import com.cobblemon.mod.common.net.serverhandling.trade.UpdateTradeOfferHandler
|
||||
import com.cobblemon.mod.common.net.serverhandling.trade.*
|
||||
import com.cobblemon.mod.common.util.server
|
||||
import net.minecraft.server.level.ServerPlayer
|
||||
|
||||
@@ -401,6 +332,7 @@ object CobblemonNetwork {
|
||||
// Data registries
|
||||
list.add(PacketRegisterInfo(AbilityRegistrySyncPacket.ID, AbilityRegistrySyncPacket::decode, DataRegistrySyncPacketHandler()))
|
||||
list.add(PacketRegisterInfo(CobblemonMechanicsSyncPacket.ID, CobblemonMechanicsSyncPacket::decode, CobblemonMechanicsSyncHandler))
|
||||
list.add(PacketRegisterInfo(PokemonInteractionsSyncPacket.ID, PokemonInteractionsSyncPacket::decode, PokemonInteractionsSyncHandler))
|
||||
list.add(PacketRegisterInfo(MovesRegistrySyncPacket.ID, MovesRegistrySyncPacket::decode, DataRegistrySyncPacketHandler()))
|
||||
list.add(PacketRegisterInfo(BerryRegistrySyncPacket.ID, BerryRegistrySyncPacket::decode, DataRegistrySyncPacketHandler()))
|
||||
list.add(PacketRegisterInfo(SpeciesRegistrySyncPacket.ID, SpeciesRegistrySyncPacket::decode, DataRegistrySyncPacketHandler()))
|
||||
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* 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.api.cooking.effects
|
||||
|
||||
import net.minecraft.world.effect.MobEffect
|
||||
import net.minecraft.world.effect.MobEffectCategory
|
||||
import net.minecraft.world.entity.Entity
|
||||
import net.minecraft.world.entity.LivingEntity
|
||||
|
||||
class CleanseAllEffect : MobEffect(MobEffectCategory.BENEFICIAL, 0xFFFFFF) {
|
||||
override fun isInstantenous() = true
|
||||
override fun applyInstantenousEffect(source: Entity?, indirect: Entity?, target: LivingEntity, amplifier: Int, proximity: Double) {
|
||||
target.removeAllEffects()
|
||||
}
|
||||
override fun shouldApplyEffectTickThisTick(duration: Int, amplifier: Int) = false
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* 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.api.cooking.effects
|
||||
|
||||
import net.minecraft.world.effect.MobEffect
|
||||
import net.minecraft.world.effect.MobEffectCategory
|
||||
import net.minecraft.world.entity.Entity
|
||||
import net.minecraft.world.entity.LivingEntity
|
||||
|
||||
class CleanseNegativeEffect : MobEffect(MobEffectCategory.BENEFICIAL, 0xFFFFFF) {
|
||||
override fun isInstantenous() = true
|
||||
override fun applyInstantenousEffect(source: Entity?, indirect: Entity?, target: LivingEntity, amplifier: Int, proximity: Double) {
|
||||
val snapshot = target.activeEffects.toList()
|
||||
for (ei in snapshot) {
|
||||
if (ei.effect.value().category == MobEffectCategory.HARMFUL) {
|
||||
target.removeEffect(ei.effect)
|
||||
}
|
||||
}
|
||||
}
|
||||
override fun shouldApplyEffectTickThisTick(duration: Int, amplifier: Int) = false
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* 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.api.cooking.effects
|
||||
|
||||
import net.minecraft.server.level.ServerPlayer
|
||||
import net.minecraft.stats.Stats
|
||||
import net.minecraft.world.effect.MobEffect
|
||||
import net.minecraft.world.effect.MobEffectCategory
|
||||
import net.minecraft.world.entity.LivingEntity
|
||||
|
||||
class MentalRestorationEffect : MobEffect(MobEffectCategory.BENEFICIAL, 0xAA66FF) {
|
||||
override fun applyEffectTick(entity: LivingEntity, amplifier: Int): Boolean {
|
||||
if (entity is ServerPlayer) {
|
||||
val stats = entity.stats
|
||||
val statType = Stats.CUSTOM.get(Stats.TIME_SINCE_REST)
|
||||
val current = stats.getValue(statType)
|
||||
val reduction = 31 * (amplifier + 1)// reduce by half a minute every second per level (30 ticks removed per tick + 1 to account for the tick passing)
|
||||
val newValue = Math.max(current - reduction, 0)
|
||||
stats.setValue(entity, statType, newValue)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
override fun shouldApplyEffectTickThisTick(duration: Int, amplifier: Int): Boolean {
|
||||
return true
|
||||
}
|
||||
}
|
||||
+7
-2
@@ -12,10 +12,10 @@ import com.cobblemon.mod.common.Cobblemon
|
||||
import com.cobblemon.mod.common.api.data.JsonDataRegistry
|
||||
import com.cobblemon.mod.common.api.molang.ExpressionLike
|
||||
import com.cobblemon.mod.common.api.pokemon.PokemonProperties
|
||||
import com.cobblemon.mod.common.api.pokemon.requirement.OwnerQueryRequirement
|
||||
import com.cobblemon.mod.common.api.pokemon.requirement.Requirement
|
||||
import com.cobblemon.mod.common.api.reactive.SimpleObservable
|
||||
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity
|
||||
import com.cobblemon.mod.common.net.messages.client.data.PokemonInteractionsSyncPacket
|
||||
import com.cobblemon.mod.common.pokemon.adapters.CobblemonRequirementAdapter
|
||||
import com.cobblemon.mod.common.pokemon.evolution.adapters.LegacyItemConditionWrapperAdapter
|
||||
import com.cobblemon.mod.common.pokemon.requirements.PokemonPropertiesRequirement
|
||||
@@ -51,7 +51,12 @@ object PokemonInteractions : JsonDataRegistry<PokemonInteractionSet> {
|
||||
val speciesInteractions = mutableListOf<PokemonInteractionSet>()
|
||||
val generalInteractions = mutableListOf<PokemonInteractionSet>()
|
||||
|
||||
override fun sync(player: ServerPlayer) {}
|
||||
override fun sync(player: ServerPlayer) {
|
||||
PokemonInteractionsSyncPacket(
|
||||
speciesInteractions,
|
||||
generalInteractions,
|
||||
).sendToPlayer(player)
|
||||
}
|
||||
|
||||
override fun reload(data: Map<ResourceLocation, PokemonInteractionSet>) {
|
||||
speciesInteractions.clear()
|
||||
|
||||
+88
-19
@@ -15,11 +15,10 @@ import com.cobblemon.mod.common.api.molang.MoLangFunctions.setup
|
||||
import com.cobblemon.mod.common.api.pokemon.requirement.Requirement
|
||||
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity
|
||||
import com.cobblemon.mod.common.net.messages.client.sound.UnvalidatedPlaySoundS2CPacket
|
||||
import com.cobblemon.mod.common.util.asExpressionLike
|
||||
import com.cobblemon.mod.common.util.giveOrDropItemStack
|
||||
import com.cobblemon.mod.common.util.withPlayerValue
|
||||
import com.cobblemon.mod.common.util.withQueryValue
|
||||
import com.cobblemon.mod.common.pokemon.adapters.CobblemonRequirementAdapter
|
||||
import com.cobblemon.mod.common.util.*
|
||||
import net.minecraft.core.registries.Registries
|
||||
import net.minecraft.network.FriendlyByteBuf
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
import net.minecraft.server.level.ServerPlayer
|
||||
import net.minecraft.sounds.SoundSource
|
||||
@@ -28,30 +27,83 @@ import net.minecraft.world.entity.EquipmentSlot
|
||||
import net.minecraft.world.entity.item.ItemEntity
|
||||
import net.minecraft.world.item.ItemStack
|
||||
|
||||
/**
|
||||
* A
|
||||
*/
|
||||
data class PokemonInteractionSet(
|
||||
val requirements: List<Requirement> = listOf(),
|
||||
val interactions: List<PokemonInteraction> = listOf()
|
||||
)
|
||||
val interactions: List<PokemonInteraction> = listOf(),
|
||||
) {
|
||||
fun encode(buffer: FriendlyByteBuf) {
|
||||
buffer.writeCollection(requirements) { it, requirement ->
|
||||
CobblemonRequirementAdapter.encode(requirement, it)
|
||||
}
|
||||
buffer.writeCollection(interactions) { it, interaction ->
|
||||
interaction.encode(it)
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun decode(buffer: FriendlyByteBuf): PokemonInteractionSet {
|
||||
val requirements = buffer.readList { it ->
|
||||
CobblemonRequirementAdapter.decode(it)
|
||||
}
|
||||
val interactions = buffer.readList { it ->
|
||||
PokemonInteraction.decode(it)
|
||||
}
|
||||
|
||||
return PokemonInteractionSet(
|
||||
requirements,
|
||||
interactions,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
data class PokemonInteraction(
|
||||
val grouping: ResourceLocation,
|
||||
val requirements: List<Requirement> = listOf(),
|
||||
val effects: List<InteractionEffect> = listOf(),
|
||||
val cooldown: ExpressionLike = "0".asExpressionLike()
|
||||
)
|
||||
) {
|
||||
fun encode(buffer: FriendlyByteBuf) {
|
||||
buffer.writeResourceLocation(grouping)
|
||||
buffer.writeCollection(requirements) { it, requirement ->
|
||||
CobblemonRequirementAdapter.encode(requirement, it)
|
||||
}
|
||||
buffer.writeExpressionLike(cooldown)
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun decode(buffer: FriendlyByteBuf): PokemonInteraction {
|
||||
val grouping = buffer.readResourceLocation()
|
||||
val requirements = buffer.readList { it ->
|
||||
CobblemonRequirementAdapter.decode(it)
|
||||
}
|
||||
|
||||
// No need to sync these for now
|
||||
val effects = emptyList<InteractionEffect>()
|
||||
val cooldown = buffer.readExpressionLike()
|
||||
|
||||
return PokemonInteraction(
|
||||
grouping,
|
||||
requirements,
|
||||
effects,
|
||||
cooldown,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
interface InteractionEffect {
|
||||
fun applyEffect(pokemon: PokemonEntity, player: ServerPlayer)
|
||||
}
|
||||
|
||||
class DropItemEffect(val item: ResourceLocation, val amount: IntRange?): InteractionEffect {
|
||||
class DropItemEffect(val item: ResourceLocation, val amount: IntRange?) : InteractionEffect {
|
||||
override fun applyEffect(
|
||||
pokemon: PokemonEntity,
|
||||
player: ServerPlayer
|
||||
) {
|
||||
val item = player.registryAccess().registryOrThrow(Registries.ITEM).get(item) ?: throw IllegalArgumentException("Cannot load item with id: $item")
|
||||
val item = player.registryAccess().registryOrThrow(Registries.ITEM).get(item) ?: throw IllegalArgumentException(
|
||||
"Cannot load item with id: $item"
|
||||
)
|
||||
val stack = ItemStack(item)
|
||||
stack.count = amount?.randomOrNull() ?: 1
|
||||
if (stack.isEmpty)
|
||||
@@ -68,12 +120,14 @@ class DropItemEffect(val item: ResourceLocation, val amount: IntRange?): Interac
|
||||
}
|
||||
}
|
||||
|
||||
class GiveItemEffect(val item: ResourceLocation, val amount: IntRange?): InteractionEffect {
|
||||
class GiveItemEffect(val item: ResourceLocation, val amount: IntRange?) : InteractionEffect {
|
||||
override fun applyEffect(
|
||||
pokemon: PokemonEntity,
|
||||
player: ServerPlayer
|
||||
) {
|
||||
val item = player.registryAccess().registryOrThrow(Registries.ITEM).get(item) ?: throw IllegalArgumentException("Cannot load item with id: $item")
|
||||
val item = player.registryAccess().registryOrThrow(Registries.ITEM).get(item) ?: throw IllegalArgumentException(
|
||||
"Cannot load item with id: $item"
|
||||
)
|
||||
val stack = ItemStack(item)
|
||||
stack.count = amount?.randomOrNull() ?: 1
|
||||
if (stack.isEmpty)
|
||||
@@ -86,14 +140,29 @@ class GiveItemEffect(val item: ResourceLocation, val amount: IntRange?): Interac
|
||||
}
|
||||
}
|
||||
|
||||
class PlaySoundEffect(val sound: ResourceLocation, val soundSource: SoundSource?, val playAround: Boolean = true, val distance: Double = 64.0, val volume: Float = 1.0F, val pitch: Float = 1.0F): InteractionEffect {
|
||||
class PlaySoundEffect(
|
||||
val sound: ResourceLocation,
|
||||
val soundSource: SoundSource?,
|
||||
val playAround: Boolean = true,
|
||||
val distance: Double = 64.0,
|
||||
val volume: Float = 1.0F,
|
||||
val pitch: Float = 1.0F
|
||||
) : InteractionEffect {
|
||||
override fun applyEffect(
|
||||
pokemon: PokemonEntity,
|
||||
player: ServerPlayer
|
||||
) {
|
||||
val packet = UnvalidatedPlaySoundS2CPacket(sound, soundSource ?: SoundSource.NEUTRAL, pokemon.x, pokemon.y, pokemon.z, volume, pitch)
|
||||
val packet = UnvalidatedPlaySoundS2CPacket(
|
||||
sound,
|
||||
soundSource ?: SoundSource.NEUTRAL,
|
||||
pokemon.x,
|
||||
pokemon.y,
|
||||
pokemon.z,
|
||||
volume,
|
||||
pitch
|
||||
)
|
||||
if (playAround) {
|
||||
packet.sendToPlayersAround( pokemon.x, pokemon.y, pokemon.z, distance, pokemon.level().dimension())
|
||||
packet.sendToPlayersAround(pokemon.x, pokemon.y, pokemon.z, distance, pokemon.level().dimension())
|
||||
} else {
|
||||
packet.sendToPlayer(player)
|
||||
}
|
||||
@@ -104,7 +173,7 @@ class PlaySoundEffect(val sound: ResourceLocation, val soundSource: SoundSource?
|
||||
}
|
||||
}
|
||||
|
||||
class ShrinkItemEffect(val amount: Int = 1): InteractionEffect {
|
||||
class ShrinkItemEffect(val amount: Int = 1) : InteractionEffect {
|
||||
override fun applyEffect(
|
||||
pokemon: PokemonEntity,
|
||||
player: ServerPlayer
|
||||
@@ -120,7 +189,7 @@ class ShrinkItemEffect(val amount: Int = 1): InteractionEffect {
|
||||
}
|
||||
}
|
||||
|
||||
class ScriptEffect(val script: ExpressionLike): InteractionEffect {
|
||||
class ScriptEffect(val script: ExpressionLike) : InteractionEffect {
|
||||
override fun applyEffect(
|
||||
pokemon: PokemonEntity,
|
||||
player: ServerPlayer
|
||||
|
||||
@@ -779,6 +779,20 @@ object MoLangFunctions {
|
||||
battleStartResult.ifSuccessful { returnValue = it.struct }
|
||||
return@put returnValue
|
||||
}
|
||||
map.put("get_custom_stat") { params ->
|
||||
val statName = params.getString(0)
|
||||
|
||||
val resourceLocation = ResourceLocation.tryParse(statName) ?: return@put DoubleValue.ZERO
|
||||
val statResourceLocation = BuiltInRegistries.CUSTOM_STAT.get(resourceLocation) ?: return@put DoubleValue.ZERO
|
||||
|
||||
val exists = net.minecraft.stats.Stats.CUSTOM.contains(statResourceLocation)
|
||||
if (!exists) return@put DoubleValue.ZERO
|
||||
|
||||
val stat = net.minecraft.stats.Stats.CUSTOM.get(statResourceLocation)
|
||||
val value = player.stats.getValue(stat)
|
||||
|
||||
DoubleValue(value)
|
||||
}
|
||||
}
|
||||
map
|
||||
}
|
||||
@@ -1739,22 +1753,35 @@ object MoLangFunctions {
|
||||
pokemon.removeCosmeticItem()
|
||||
}
|
||||
map.put("add_marks") { params ->
|
||||
var appliedMark = false
|
||||
for (param in params.params) {
|
||||
val identifier = param.asString().asIdentifierDefaultingNamespace()
|
||||
val mark = Marks.getByIdentifier(identifier)
|
||||
if (mark != null) pokemon.exchangeMark(mark, true)
|
||||
if (mark != null) {
|
||||
pokemon.exchangeMark(mark, true)
|
||||
appliedMark = true
|
||||
}
|
||||
}
|
||||
|
||||
DoubleValue(appliedMark)
|
||||
}
|
||||
map.put("add_marks_with_chance") { params ->
|
||||
var appliedMark = false
|
||||
for (param in params.params) {
|
||||
val identifier = param.asString().asIdentifierDefaultingNamespace()
|
||||
val mark = Marks.getByIdentifier(identifier)
|
||||
|
||||
mark?.let {
|
||||
val probability = it.chance.coerceIn(0F, 1F) * 100
|
||||
val randomValue = Random.nextDouble(0.0, 100.0)
|
||||
if (randomValue < probability) pokemon.exchangeMark(it, true)
|
||||
if (randomValue < probability) {
|
||||
pokemon.exchangeMark(it, true)
|
||||
appliedMark = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DoubleValue(appliedMark)
|
||||
}
|
||||
map.put("add_potential_marks") { params ->
|
||||
for (param in params.params) {
|
||||
|
||||
+5
-4
@@ -12,6 +12,7 @@ import com.cobblemon.mod.common.entity.npc.NPCEntity
|
||||
import com.cobblemon.mod.common.pokemon.Pokemon
|
||||
import net.minecraft.server.level.ServerPlayer
|
||||
import net.minecraft.world.entity.LivingEntity
|
||||
import net.minecraft.world.entity.player.Player
|
||||
|
||||
/**
|
||||
* A [Requirement] that expects a [LivingEntity] to be attached to the [Pokemon].
|
||||
@@ -26,7 +27,7 @@ interface OwnerQueryRequirement : Requirement {
|
||||
override fun check(pokemon: Pokemon): Boolean {
|
||||
val owner = pokemon.getOwnerEntity() ?: return false
|
||||
return when (owner) {
|
||||
is ServerPlayer -> {
|
||||
is Player -> {
|
||||
this.checkPlayer(pokemon, owner)
|
||||
}
|
||||
is NPCEntity -> {
|
||||
@@ -37,13 +38,13 @@ interface OwnerQueryRequirement : Requirement {
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the given [Pokemon] & [ServerPlayer] satisfies the requirement.
|
||||
* Checks if the given [Pokemon] & [Player] satisfies the requirement.
|
||||
*
|
||||
* @param pokemon The [Pokemon] being queried.
|
||||
* @param owner The [ServerPlayer] that owns this [Pokemon].
|
||||
* @param owner The [Player] that owns this [Pokemon].
|
||||
* @return If the requirement was satisfied.
|
||||
*/
|
||||
fun checkPlayer(pokemon: Pokemon, owner: ServerPlayer): Boolean
|
||||
fun checkPlayer(pokemon: Pokemon, owner: Player): Boolean
|
||||
|
||||
/**
|
||||
* Checks if the given [Pokemon] & [NPCEntity] satisfies the requirement.
|
||||
|
||||
+8
-6
@@ -22,6 +22,7 @@ import com.cobblemon.mod.common.api.riding.posing.PoseOption
|
||||
import com.cobblemon.mod.common.api.riding.posing.PoseProvider
|
||||
import com.cobblemon.mod.common.api.riding.sound.RideSoundSettingsList
|
||||
import com.cobblemon.mod.common.api.riding.stats.RidingStat
|
||||
import com.cobblemon.mod.common.client.CobblemonClient
|
||||
import com.cobblemon.mod.common.entity.PoseType
|
||||
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity
|
||||
import com.cobblemon.mod.common.util.blockPositionsAsListRounded
|
||||
@@ -144,11 +145,12 @@ class HorseBehaviour : RidingBehaviour<HorseSettings, HorseState> {
|
||||
) {
|
||||
val sprintTimerTickLength = 7 // Emulate vanillas tick timer length
|
||||
var hasDoubleTapped = false
|
||||
val forward = Minecraft.getInstance().player?.input?.up == true
|
||||
|
||||
// If you are not sprinting and you just pressed down and theres no
|
||||
if (!state.forwardHeldLastTick.get() && Minecraft.getInstance().options.keyUp.isDown() && !state.sprinting.get() && state.sprintTickTimer.get() == 0) {
|
||||
if (!state.forwardHeldLastTick.get() && forward && !state.sprinting.get() && state.sprintTickTimer.get() == 0) {
|
||||
state.sprintTickTimer.set(sprintTimerTickLength)
|
||||
} else if (!state.forwardHeldLastTick.get() && Minecraft.getInstance().options.keyUp.isDown() && state.sprintTickTimer.get() != 0) { // If has double tapped
|
||||
} else if (!state.forwardHeldLastTick.get() && forward && state.sprintTickTimer.get() != 0) { // If has double tapped
|
||||
hasDoubleTapped = true
|
||||
}else if(!state.sprinting.get() && state.sprintTickTimer.get() > 0) {
|
||||
state.sprintTickTimer.set(state.sprintTickTimer.get() - 1)
|
||||
@@ -156,9 +158,9 @@ class HorseBehaviour : RidingBehaviour<HorseSettings, HorseState> {
|
||||
state.sprintTickTimer.set(0)
|
||||
}
|
||||
|
||||
val tryingToSprint = (Minecraft.getInstance().options.keySprint.isDown() && Minecraft.getInstance().options.keyUp.isDown()) || hasDoubleTapped
|
||||
val tryingToSprint = hasDoubleTapped || CobblemonClient.ridingSprintHandler.any { it.value.invoke() }
|
||||
|
||||
if (state.stamina.get() <= 0.0f || !Minecraft.getInstance().options.keyUp.isDown()) {
|
||||
if (state.stamina.get() <= 0.0f || !forward) {
|
||||
// If stamina runs out or the player is not holding forward then stop sprinting
|
||||
state.sprinting.set(false)
|
||||
if (state.stamina.get() <= 0.0f) {
|
||||
@@ -172,8 +174,8 @@ class HorseBehaviour : RidingBehaviour<HorseSettings, HorseState> {
|
||||
state.sprinting.set(true)
|
||||
}
|
||||
|
||||
// Take not of whether forward was held last tick
|
||||
state.forwardHeldLastTick.set(Minecraft.getInstance().options.keyUp.isDown())
|
||||
// Take note of whether forward was held last tick
|
||||
state.forwardHeldLastTick.set(forward)
|
||||
}
|
||||
|
||||
fun tickStamina(
|
||||
|
||||
@@ -12,6 +12,7 @@ package com.cobblemon.mod.common.api.riding.sound
|
||||
import com.cobblemon.mod.common.api.riding.behaviour.types.composite.CompositeBehaviour
|
||||
import com.cobblemon.mod.common.api.riding.behaviour.types.composite.CompositeState
|
||||
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity
|
||||
import com.cobblemon.mod.common.util.getIsSubmerged
|
||||
import com.cobblemon.mod.common.util.resolveDouble
|
||||
import net.minecraft.client.Minecraft
|
||||
import net.minecraft.client.resources.sounds.AbstractTickableSoundInstance
|
||||
@@ -65,6 +66,21 @@ class RideLoopSound(val ride: PokemonEntity, val soundSettings: RideSoundSetting
|
||||
return
|
||||
}
|
||||
|
||||
// Mute the sound if it's not meant to play for the passenger
|
||||
if (this.isPassenger && !this.soundSettings.playForPassengers) {
|
||||
this.volume = 0.0f
|
||||
return
|
||||
}
|
||||
|
||||
// Mute sounds when submerged unless they support underwater sounds, underwater sounds don't play above water
|
||||
if (this.ride.getIsSubmerged() && !this.soundSettings.submerged) {
|
||||
this.volume = 0.0f
|
||||
return
|
||||
} else if (!this.ride.getIsSubmerged() && this.soundSettings.submerged) {
|
||||
this.volume = 0.0f
|
||||
return
|
||||
}
|
||||
|
||||
// Perform data driven pitch and volume calculation
|
||||
this.volume = ((soundSettings.volumeExpr.let { ride.runtime.resolveDouble(it) })).toFloat()
|
||||
this.volume *= this.fade
|
||||
|
||||
+8
@@ -27,7 +27,9 @@ data class RideSoundSettings(
|
||||
val soundLocation: ResourceLocation,
|
||||
@SerializedName("volumeExpr") private val _volumeExpr: Expression? = "1.0".asExpression(),
|
||||
@SerializedName("pitchExpr") private val _pitchExpr: Expression? = "1.0".asExpression(),
|
||||
val playForPassengers: Boolean = true,
|
||||
val playForNonPassengers: Boolean = false,
|
||||
val submerged: Boolean = false,
|
||||
val muffleEnabled: Boolean = false,
|
||||
@SerializedName("attenuationModel") private val _attenuationModel: RideAttenuationModel? = RideAttenuationModel.NONE
|
||||
): Encodable {
|
||||
@@ -46,7 +48,9 @@ data class RideSoundSettings(
|
||||
buffer.writeResourceLocation(soundLocation)
|
||||
buffer.writeExpression(volumeExpr)
|
||||
buffer.writeExpression(pitchExpr)
|
||||
buffer.writeBoolean(playForPassengers)
|
||||
buffer.writeBoolean(playForNonPassengers)
|
||||
buffer.writeBoolean(submerged)
|
||||
buffer.writeBoolean(muffleEnabled)
|
||||
buffer.writeEnum(attenuationModel)
|
||||
}
|
||||
@@ -57,7 +61,9 @@ data class RideSoundSettings(
|
||||
val soundLocation = buffer.readResourceLocation()
|
||||
val volumeExpr = buffer.readExpression()
|
||||
val pitchExpr = buffer.readExpression()
|
||||
val playForPassengers = buffer.readBoolean()
|
||||
val playForNonPassengers = buffer.readBoolean()
|
||||
val submerged = buffer.readBoolean()
|
||||
val muffleEnabled = buffer.readBoolean()
|
||||
val attenuationModel = buffer.readEnum(RideAttenuationModel::class.java)
|
||||
|
||||
@@ -65,7 +71,9 @@ data class RideSoundSettings(
|
||||
soundLocation,
|
||||
volumeExpr,
|
||||
pitchExpr,
|
||||
playForPassengers,
|
||||
playForNonPassengers,
|
||||
submerged,
|
||||
muffleEnabled,
|
||||
attenuationModel
|
||||
)
|
||||
|
||||
@@ -8,30 +8,58 @@
|
||||
|
||||
package com.cobblemon.mod.common.api.stats
|
||||
|
||||
import com.cobblemon.mod.common.Cobblemon
|
||||
import net.minecraft.core.registries.BuiltInRegistries
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
import net.minecraft.stats.StatFormatter
|
||||
|
||||
object CobblemonStats {
|
||||
val stats = mutableMapOf<String, ResourceLocation>()
|
||||
val stats = mutableMapOf<String, CobblemonStat>()
|
||||
|
||||
var CAPTURED: ResourceLocation = ResourceLocation.fromNamespaceAndPath("cobblemon", "captured") //makeCustomStat("captured", StatFormatter.DEFAULT)
|
||||
val SHINIES_CAPTURED: ResourceLocation = ResourceLocation.fromNamespaceAndPath("cobblemon", "shinies_captured") //makeCustomStat("shinies_captured", StatFormatter.DEFAULT)
|
||||
val RELEASED: ResourceLocation = ResourceLocation.fromNamespaceAndPath("cobblemon", "released") //makeCustomStat("released", StatFormatter.DEFAULT)
|
||||
val EVOLVED: ResourceLocation = ResourceLocation.fromNamespaceAndPath("cobblemon", "evolved") //makeCustomStat("evolved", StatFormatter.DEFAULT)
|
||||
val LEVEL_UP: ResourceLocation = ResourceLocation.fromNamespaceAndPath("cobblemon", "level_up") //makeCustomStat("level_up", StatFormatter.DEFAULT)
|
||||
val BATTLES_WON: ResourceLocation = ResourceLocation.fromNamespaceAndPath("cobblemon", "battles_won") //makeCustomStat("battles_won", StatFormatter.DEFAULT)
|
||||
val BATTLES_LOST: ResourceLocation = ResourceLocation.fromNamespaceAndPath("cobblemon", "battles_lost") //makeCustomStat("battles_lost", StatFormatter.DEFAULT)
|
||||
val BATTLES_FLED: ResourceLocation = ResourceLocation.fromNamespaceAndPath("cobblemon", "battles_fled") //makeCustomStat("battles_fled", StatFormatter.DEFAULT)
|
||||
val BATTLES_TOTAL: ResourceLocation = ResourceLocation.fromNamespaceAndPath("cobblemon", "battles_total") //makeCustomStat("battles_total", StatFormatter.DEFAULT)
|
||||
val DEX_ENTRIES: ResourceLocation = ResourceLocation.fromNamespaceAndPath("cobblemon", "dex_entries") //makeCustomStat("dex_entries", StatFormatter.DEFAULT)
|
||||
val EGGS_COLLECTED: ResourceLocation = ResourceLocation.fromNamespaceAndPath("cobblemon", "eggs_collected") //makeCustomStat("eggs_collected", StatFormatter.DEFAULT)
|
||||
val EGGS_HATCHED: ResourceLocation = ResourceLocation.fromNamespaceAndPath("cobblemon", "eggs_hatched") //makeCustomStat("eggs_hatched", StatFormatter.DEFAULT)
|
||||
val TRADED: ResourceLocation = ResourceLocation.fromNamespaceAndPath("cobblemon", "traded") //makeCustomStat("traded", StatFormatter.DEFAULT)
|
||||
val FOSSILS_REVIVED: ResourceLocation = ResourceLocation.fromNamespaceAndPath("cobblemon", "fossils_revived") //makeCustomStat("fossils_revived", StatFormatter.DEFAULT)
|
||||
val TIMES_RIDDEN: ResourceLocation = ResourceLocation.fromNamespaceAndPath("cobblemon", "times_ridden")
|
||||
val ROD_CASTS: ResourceLocation = ResourceLocation.fromNamespaceAndPath("cobblemon", "rod_casts")
|
||||
val REEL_INS: ResourceLocation = ResourceLocation.fromNamespaceAndPath("cobblemon", "reel_ins")
|
||||
val POKEMON_INTERACTED_WITH: ResourceLocation = ResourceLocation.fromNamespaceAndPath("cobblemon", "pokemon_interacted_with") //makeCustomStat("pokemon_interacted_with", StatFormatter.DEFAULT)
|
||||
//TODO block, stats (interact, gimmi), riding (styles?)
|
||||
@JvmField
|
||||
var CAPTURED: CobblemonStat = CobblemonStat("captured")
|
||||
@JvmField
|
||||
val SHINIES_CAPTURED: CobblemonStat = CobblemonStat("shinies_captured")
|
||||
@JvmField
|
||||
val RELEASED: CobblemonStat = CobblemonStat("released")
|
||||
@JvmField
|
||||
val EVOLVED: CobblemonStat = CobblemonStat("evolved")
|
||||
@JvmField
|
||||
val LEVEL_UP: CobblemonStat = CobblemonStat("level_up")
|
||||
@JvmField
|
||||
val BATTLES_WON: CobblemonStat = CobblemonStat("battles_won")
|
||||
@JvmField
|
||||
val BATTLES_LOST: CobblemonStat = CobblemonStat("battles_lost")
|
||||
@JvmField
|
||||
val BATTLES_FLED: CobblemonStat = CobblemonStat("battles_fled")
|
||||
@JvmField
|
||||
val BATTLES_TOTAL: CobblemonStat = CobblemonStat("battles_total")
|
||||
@JvmField
|
||||
val DEX_ENTRIES: CobblemonStat = CobblemonStat("dex_entries")
|
||||
@JvmField
|
||||
val EGGS_COLLECTED: CobblemonStat = CobblemonStat("eggs_collected")
|
||||
@JvmField
|
||||
val EGGS_HATCHED: CobblemonStat = CobblemonStat("eggs_hatched")
|
||||
@JvmField
|
||||
val TRADED: CobblemonStat = CobblemonStat("traded")
|
||||
@JvmField
|
||||
val FOSSILS_REVIVED: CobblemonStat = CobblemonStat("fossils_revived")
|
||||
@JvmField
|
||||
val TIMES_RIDDEN: CobblemonStat = CobblemonStat("times_ridden")
|
||||
@JvmField
|
||||
val ROD_CASTS: CobblemonStat = CobblemonStat("rod_casts")
|
||||
@JvmField
|
||||
val REEL_INS: CobblemonStat = CobblemonStat("reel_ins")
|
||||
@JvmField
|
||||
val POKEMON_INTERACTED_WITH: CobblemonStat = CobblemonStat("pokemon_interacted_with")
|
||||
@JvmField
|
||||
val RIDING_LAND: CobblemonStat = CobblemonStat("riding_land", StatFormatter.DISTANCE)
|
||||
@JvmField
|
||||
val RIDING_AIR: CobblemonStat = CobblemonStat("riding_air", StatFormatter.DISTANCE)
|
||||
@JvmField
|
||||
val RIDING_LIQUID: CobblemonStat = CobblemonStat("riding_liquid", StatFormatter.DISTANCE)
|
||||
|
||||
//TODO block, stats (interact, gimmi)
|
||||
|
||||
fun registerStats() {
|
||||
stats["captured"] = CAPTURED
|
||||
@@ -52,5 +80,22 @@ object CobblemonStats {
|
||||
stats["rod_casts"] = ROD_CASTS
|
||||
stats["reel_ins"] = REEL_INS
|
||||
stats["pokemon_interacted_with"] = POKEMON_INTERACTED_WITH
|
||||
stats["riding_land"] = RIDING_LAND
|
||||
stats["riding_air"] = RIDING_AIR
|
||||
stats["riding_liquid"] = RIDING_LIQUID
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getStat(cobblemonStat: CobblemonStat) : ResourceLocation {
|
||||
val resourceLocation = cobblemonStat.resourceLocation
|
||||
val stat = BuiltInRegistries.CUSTOM_STAT.get(resourceLocation)
|
||||
if (stat == null) {
|
||||
Cobblemon.LOGGER.error("Could not find stat with id {}", resourceLocation)
|
||||
}
|
||||
return stat ?: throw NullPointerException("Could not find stat with id $resourceLocation")
|
||||
}
|
||||
|
||||
data class CobblemonStat(val path: String, val formatter: StatFormatter = StatFormatter.DEFAULT) {
|
||||
val resourceLocation: ResourceLocation = ResourceLocation.fromNamespaceAndPath("cobblemon", path);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,6 +74,7 @@ import com.cobblemon.mod.common.entity.boat.CobblemonBoatType
|
||||
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity
|
||||
import com.cobblemon.mod.common.platform.events.PlatformEvents
|
||||
import com.cobblemon.mod.common.pokedex.scanner.PokedexUsageContext
|
||||
import com.cobblemon.mod.common.util.cobblemonResource
|
||||
import com.cobblemon.mod.common.util.isLookingAt
|
||||
import net.minecraft.client.Minecraft
|
||||
import net.minecraft.client.color.block.BlockColor
|
||||
@@ -83,16 +84,19 @@ import net.minecraft.client.gui.screens.Screen
|
||||
import net.minecraft.client.model.BoatModel
|
||||
import net.minecraft.client.model.ChestBoatModel
|
||||
import net.minecraft.client.model.PlayerModel
|
||||
import net.minecraft.client.player.LocalPlayer
|
||||
import net.minecraft.client.renderer.RenderType
|
||||
import net.minecraft.client.renderer.blockentity.HangingSignRenderer
|
||||
import net.minecraft.client.renderer.blockentity.SignRenderer
|
||||
import net.minecraft.client.renderer.entity.EntityRenderer
|
||||
import net.minecraft.client.renderer.entity.LivingEntityRenderer
|
||||
import net.minecraft.client.resources.PlayerSkin
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
import net.minecraft.server.packs.resources.ResourceManager
|
||||
import net.minecraft.world.InteractionHand
|
||||
import net.minecraft.world.entity.player.Player
|
||||
import net.minecraft.world.phys.AABB
|
||||
import org.joml.Vector2d
|
||||
|
||||
object CobblemonClient {
|
||||
|
||||
@@ -112,6 +116,8 @@ object CobblemonClient {
|
||||
val battleOverlay: BattleOverlay by lazy { BattleOverlay() }
|
||||
val pokedexUsageContext: PokedexUsageContext by lazy { PokedexUsageContext() }
|
||||
val rideControlsOverlay: RideControlsOverlay by lazy { RideControlsOverlay() }
|
||||
val ridingTurnInputHandler: MutableMap<ResourceLocation, (LocalPlayer, Double, Double, Double) -> Vector2d> = mutableMapOf()
|
||||
val ridingSprintHandler: MutableMap<ResourceLocation, () -> Boolean> = mutableMapOf()
|
||||
|
||||
fun onLogin() {
|
||||
clientPlayerData = ClientGeneralPlayerData()
|
||||
@@ -195,6 +201,8 @@ object CobblemonClient {
|
||||
ClientPlayerIcon.onTick()
|
||||
PartyOverlayDataControl.tick(event.client.isPaused)
|
||||
}
|
||||
|
||||
ridingSprintHandler.put(cobblemonResource("normal")) { Minecraft.getInstance().options.keySprint.isDown }
|
||||
}
|
||||
|
||||
private fun registerTooltipManagers() {
|
||||
|
||||
+2
-2
@@ -74,12 +74,12 @@ class InteractWheelButton(
|
||||
y = y,
|
||||
width = width,
|
||||
height = height,
|
||||
vOffset = if (isHovered(mouseX.toFloat(), mouseY.toFloat()) && isEnabled) height else 0,
|
||||
vOffset = if ((isHovered(mouseX.toFloat(), mouseY.toFloat()) || isFocused) && isEnabled) height else 0,
|
||||
textureHeight = height * 2,
|
||||
alpha = if (isEnabled) 1f else 0.4F
|
||||
)
|
||||
|
||||
if(isEnabled && isHovered(mouseX.toFloat(), mouseY.toFloat())){
|
||||
if(isEnabled && (isHovered(mouseX.toFloat(), mouseY.toFloat()) || isFocused)){
|
||||
tooltipText?.let {
|
||||
context.renderTooltip(Minecraft.getInstance().font, Component.translatable(it), mouseX, mouseY)
|
||||
}
|
||||
|
||||
+4
-4
@@ -23,9 +23,9 @@ class InteractWheelGUI(private val options: Multimap<Orientation, InteractWheelO
|
||||
private val backgroundResource = cobblemonResource("textures/gui/interact/interact_wheel_base.png")
|
||||
}
|
||||
|
||||
private val buttons = mutableListOf<InteractWheelButton>()
|
||||
private var maxPage = 1
|
||||
private var currentPage = 0
|
||||
val buttons = mutableListOf<InteractWheelButton>()
|
||||
var maxPage = 1
|
||||
var currentPage = 0
|
||||
override fun renderBlurredBackground(delta: Float) { }
|
||||
override fun renderMenuBackground(context: GuiGraphics) {}
|
||||
|
||||
@@ -77,7 +77,7 @@ class InteractWheelGUI(private val options: Multimap<Orientation, InteractWheelO
|
||||
currentPage = page
|
||||
buttons.forEach { removeWidget(it) }
|
||||
buttons.clear()
|
||||
val orientations = Orientation.values()
|
||||
val orientations = Orientation.entries.toTypedArray()
|
||||
orientations.forEach { orientation ->
|
||||
val option = options[orientation].toList().getOrNull(page)
|
||||
addButton(orientation, option)
|
||||
|
||||
+319
@@ -0,0 +1,319 @@
|
||||
/*
|
||||
* 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.client.integration.controlify
|
||||
|
||||
import com.cobblemon.mod.common.CobblemonItems
|
||||
import com.cobblemon.mod.common.OrientationControllable
|
||||
import com.cobblemon.mod.common.client.CobblemonClient
|
||||
import com.cobblemon.mod.common.client.CobblemonClient.ridingTurnInputHandler
|
||||
import com.cobblemon.mod.common.client.gui.battle.BattleGUI
|
||||
import com.cobblemon.mod.common.client.gui.behaviour.BehaviourEditorScreen
|
||||
import com.cobblemon.mod.common.client.gui.config.CobblemonConfigScreen
|
||||
import com.cobblemon.mod.common.client.gui.cookingpot.CookingPotScreen
|
||||
import com.cobblemon.mod.common.client.gui.debug.riding.RidingStatsDebugGUI
|
||||
import com.cobblemon.mod.common.client.gui.dialogue.DialogueScreen
|
||||
import com.cobblemon.mod.common.client.gui.interact.battleRequest.BattleConfigureGUI
|
||||
import com.cobblemon.mod.common.client.gui.interact.moveselect.MoveSelectGUI
|
||||
import com.cobblemon.mod.common.client.gui.interact.partyselect.PartySelectGUI
|
||||
import com.cobblemon.mod.common.client.gui.interact.wheel.InteractWheelGUI
|
||||
import com.cobblemon.mod.common.client.gui.npc.NPCEditorScreen
|
||||
import com.cobblemon.mod.common.client.gui.pc.PCGUI
|
||||
import com.cobblemon.mod.common.client.gui.pokedex.PokedexGUI
|
||||
import com.cobblemon.mod.common.client.gui.pokenav.PokeNav
|
||||
import com.cobblemon.mod.common.client.gui.snapshots.SnapshotWarningScreen
|
||||
import com.cobblemon.mod.common.client.gui.startselection.StarterSelectionScreen
|
||||
import com.cobblemon.mod.common.client.gui.summary.Summary
|
||||
import com.cobblemon.mod.common.client.gui.trade.TradeGUI
|
||||
import com.cobblemon.mod.common.client.integration.controlify.gui.CobblemonGUIProcessor
|
||||
import com.cobblemon.mod.common.client.integration.controlify.gui.InteractWheelProcessor
|
||||
import com.cobblemon.mod.common.client.keybind.CobblemonKeyBinds
|
||||
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity
|
||||
import com.cobblemon.mod.common.util.cobblemonResource
|
||||
import dev.isxander.controlify.api.ControlifyApi
|
||||
import dev.isxander.controlify.api.bind.ControlifyBindApi
|
||||
import dev.isxander.controlify.api.bind.InputBindingBuilder
|
||||
import dev.isxander.controlify.api.bind.InputBindingSupplier
|
||||
import dev.isxander.controlify.api.entrypoint.ControlifyEntrypoint
|
||||
import dev.isxander.controlify.api.entrypoint.InitContext
|
||||
import dev.isxander.controlify.api.entrypoint.PreInitContext
|
||||
import dev.isxander.controlify.bindings.BindContext
|
||||
import dev.isxander.controlify.bindings.ControlifyBindings
|
||||
import dev.isxander.controlify.bindings.RadialIcons
|
||||
import dev.isxander.controlify.screenop.ScreenProcessorFactory
|
||||
import net.minecraft.client.Minecraft
|
||||
import net.minecraft.client.gui.screens.Screen
|
||||
import net.minecraft.client.player.LocalPlayer
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.world.item.Items
|
||||
import org.joml.Vector2d
|
||||
import kotlin.jvm.optionals.getOrNull
|
||||
import kotlin.reflect.KClass
|
||||
import kotlin.reflect.full.primaryConstructor
|
||||
|
||||
class CobblemonControlifyEntrypoint : ControlifyEntrypoint {
|
||||
override fun onControlifyInit(initContext: InitContext) {
|
||||
ridingTurnInputHandler.put(
|
||||
cobblemonResource("compat.controlify"),
|
||||
({ localPlayer: LocalPlayer, xDelta: Double, yDelta: Double, deltaTime: Double ->
|
||||
val vec = Vector2d(xDelta, yDelta)
|
||||
val controller = initContext.controlify().currentController.getOrNull()
|
||||
val vehicle = localPlayer.vehicle
|
||||
if (vehicle is OrientationControllable && vehicle.orientationController.isActive() && initContext.controlify().currentInputMode().isController && controller != null){
|
||||
val multiplier = deltaTime * 1500
|
||||
val config = controller.input().getOrNull()?.config()?.config()
|
||||
val vSensitivity = config?.vLookSensitivity ?: 0.9f
|
||||
val hSensitivity = config?.hLookSensitivity ?: 1f
|
||||
|
||||
// Should never be null once bindings are set
|
||||
var vAxis = (RIDING_DOWN!!.on(controller).analogueNow() - RIDING_UP!!.on(controller).analogueNow()).toDouble()
|
||||
var hAxis = (RIDING_RIGHT!!.on(controller).analogueNow() - RIDING_LEFT!!.on(controller).analogueNow()).toDouble()
|
||||
|
||||
vAxis *= multiplier * vSensitivity
|
||||
hAxis *= multiplier * hSensitivity
|
||||
vec.x = hAxis
|
||||
vec.y = vAxis
|
||||
}
|
||||
vec
|
||||
})
|
||||
)
|
||||
|
||||
CobblemonClient.ridingSprintHandler.put(
|
||||
cobblemonResource("compat.controlify")
|
||||
) {
|
||||
initContext.controlify().currentController.getOrNull()?.let { ControlifyBindings.SPRINT.on(it).digitalNow() } == true
|
||||
}
|
||||
}
|
||||
|
||||
override fun onControlifyPreInit(initContext: PreInitContext) {
|
||||
val bindings = ControlifyBindApi.get()
|
||||
bindings.registerBindContext(ORIENTATION_CONTROLLER_ACTIVE)
|
||||
|
||||
RIDING_UP =
|
||||
bindings.registerBinding { builder: InputBindingBuilder ->
|
||||
builder
|
||||
.id(cobblemonResource("riding_up"))
|
||||
.category(Component.translatable("controlify.category.cobblemon.cobblemon"))
|
||||
.name(Component.translatable("controlify.bind.cobblemon.riding_up"))
|
||||
.allowedContexts(ORIENTATION_CONTROLLER_ACTIVE, BindContext.IN_GAME)
|
||||
}
|
||||
|
||||
RIDING_DOWN =
|
||||
bindings.registerBinding { builder: InputBindingBuilder ->
|
||||
builder
|
||||
.id(cobblemonResource("riding_down"))
|
||||
.category(Component.translatable("controlify.category.cobblemon.cobblemon"))
|
||||
.name(Component.translatable("controlify.bind.cobblemon.riding_down"))
|
||||
.allowedContexts(ORIENTATION_CONTROLLER_ACTIVE, BindContext.IN_GAME)
|
||||
}
|
||||
|
||||
RIDING_LEFT =
|
||||
bindings.registerBinding { builder: InputBindingBuilder ->
|
||||
builder
|
||||
.id(cobblemonResource("riding_left"))
|
||||
.category(Component.translatable("controlify.category.cobblemon.cobblemon"))
|
||||
.name(Component.translatable("controlify.bind.cobblemon.riding_left"))
|
||||
.allowedContexts(ORIENTATION_CONTROLLER_ACTIVE, BindContext.IN_GAME)
|
||||
}
|
||||
|
||||
RIDING_RIGHT =
|
||||
bindings.registerBinding { builder: InputBindingBuilder ->
|
||||
builder
|
||||
.id(cobblemonResource("riding_right"))
|
||||
.category(Component.translatable("controlify.category.cobblemon.cobblemon"))
|
||||
.name(Component.translatable("controlify.bind.cobblemon.riding_right"))
|
||||
.allowedContexts(ORIENTATION_CONTROLLER_ACTIVE, BindContext.IN_GAME)
|
||||
}
|
||||
|
||||
HIDE_PARTY =
|
||||
bindings.registerBinding { builder: InputBindingBuilder ->
|
||||
builder
|
||||
.id(cobblemonResource("hide_party"))
|
||||
.category(Component.translatable("controlify.category.cobblemon.cobblemon"))
|
||||
.name(Component.translatable("key.cobblemon.hideparty"))
|
||||
.allowedContexts(BindContext.IN_GAME)
|
||||
.radialCandidate(RadialIcons.getItem(Items.BARRIER))
|
||||
.addKeyCorrelation(CobblemonKeyBinds.HIDE_PARTY)
|
||||
.keyEmulation(CobblemonKeyBinds.HIDE_PARTY)
|
||||
}
|
||||
|
||||
SUMMARY =
|
||||
bindings.registerBinding { builder: InputBindingBuilder ->
|
||||
builder
|
||||
.id(cobblemonResource("summary"))
|
||||
.category(Component.translatable("controlify.category.cobblemon.cobblemon"))
|
||||
.name(Component.translatable("key.cobblemon.summary"))
|
||||
.allowedContexts(BindContext.IN_GAME)
|
||||
.radialCandidate(RadialIcons.getItem(CobblemonItems.GREAT_BALL))
|
||||
.addKeyCorrelation(CobblemonKeyBinds.SUMMARY)
|
||||
.keyEmulation(CobblemonKeyBinds.SUMMARY)
|
||||
}
|
||||
|
||||
PARTY_OVERLAY_DOWN =
|
||||
bindings.registerBinding { builder: InputBindingBuilder ->
|
||||
builder
|
||||
.id(cobblemonResource("party_overlay_down"))
|
||||
.category(Component.translatable("controlify.category.cobblemon.cobblemon"))
|
||||
.name(Component.translatable("key.cobblemon.downshiftparty"))
|
||||
.allowedContexts(HAS_POKEMON, BindContext.IN_GAME)
|
||||
.radialCandidate(RadialIcons.EMPTY)
|
||||
.addKeyCorrelation(CobblemonKeyBinds.PARTY_OVERLAY_DOWN)
|
||||
.keyEmulation(CobblemonKeyBinds.PARTY_OVERLAY_DOWN)
|
||||
}
|
||||
|
||||
PARTY_OVERLAY_UP =
|
||||
bindings.registerBinding { builder: InputBindingBuilder ->
|
||||
builder
|
||||
.id(cobblemonResource("party_overlay_up"))
|
||||
.category(Component.translatable("controlify.category.cobblemon.cobblemon"))
|
||||
.name(Component.translatable("key.cobblemon.upshiftparty"))
|
||||
.allowedContexts(HAS_POKEMON, BindContext.IN_GAME)
|
||||
.radialCandidate(RadialIcons.EMPTY)
|
||||
.addKeyCorrelation(CobblemonKeyBinds.PARTY_OVERLAY_UP)
|
||||
.keyEmulation(CobblemonKeyBinds.PARTY_OVERLAY_DOWN)
|
||||
}
|
||||
|
||||
SEND_OUT_POKEMON =
|
||||
bindings.registerBinding { builder: InputBindingBuilder ->
|
||||
builder
|
||||
.id(cobblemonResource("send_out_pokemon"))
|
||||
.category(Component.translatable("controlify.category.cobblemon.cobblemon"))
|
||||
.name(Component.translatable("key.cobblemon.throwpartypokemon"))
|
||||
.allowedContexts(HAS_POKEMON, BindContext.IN_GAME)
|
||||
.radialCandidate(RadialIcons.getItem(CobblemonItems.POKE_BALL))
|
||||
.addKeyCorrelation(CobblemonKeyBinds.SEND_OUT_POKEMON)
|
||||
.keyEmulation(CobblemonKeyBinds.SEND_OUT_POKEMON)
|
||||
}
|
||||
|
||||
|
||||
RIDING_FREELOOK =
|
||||
bindings.registerBinding { builder: InputBindingBuilder ->
|
||||
builder
|
||||
.id(cobblemonResource("riding_freelook"))
|
||||
.category(Component.translatable("controlify.category.cobblemon.cobblemon"))
|
||||
.name(Component.translatable("key.cobblemon.ridingfreelook"))
|
||||
.allowedContexts(RIDING_POKEMON, BindContext.IN_GAME)
|
||||
.radialCandidate(RadialIcons.EMPTY)
|
||||
.addKeyCorrelation(CobblemonKeyBinds.RIDING_FREELOOK)
|
||||
.keyEmulation(CobblemonKeyBinds.RIDING_FREELOOK)
|
||||
}
|
||||
|
||||
INTERACT_WHEEL_UP_AXIS =
|
||||
bindings.registerBinding { builder: InputBindingBuilder ->
|
||||
builder
|
||||
.id(cobblemonResource("interact_wheel_up"))
|
||||
.category(Component.translatable("controlify.category.cobblemon.cobblemon"))
|
||||
.name(Component.translatable("controlify.bind.cobblemon.interact_wheel_up"))
|
||||
.allowedContexts(INTERACT_WHEEL_SCREEN, BindContext.IN_GAME)
|
||||
}
|
||||
|
||||
INTERACT_WHEEL_DOWN_AXIS =
|
||||
bindings.registerBinding { builder: InputBindingBuilder ->
|
||||
builder
|
||||
.id(cobblemonResource("interact_wheel_down"))
|
||||
.category(Component.translatable("controlify.category.cobblemon.cobblemon"))
|
||||
.name(Component.translatable("controlify.bind.cobblemon.interact_wheel_down"))
|
||||
.allowedContexts(INTERACT_WHEEL_SCREEN, BindContext.IN_GAME)
|
||||
}
|
||||
|
||||
INTERACT_WHEEL_RIGHT_AXIS =
|
||||
bindings.registerBinding { builder: InputBindingBuilder ->
|
||||
builder
|
||||
.id(cobblemonResource("interact_wheel_right"))
|
||||
.category(Component.translatable("controlify.category.cobblemon.cobblemon"))
|
||||
.name(Component.translatable("controlify.bind.cobblemon.interact_wheel_right"))
|
||||
.allowedContexts(INTERACT_WHEEL_SCREEN, BindContext.IN_GAME)
|
||||
}
|
||||
|
||||
INTERACT_WHEEL_LEFT_AXIS =
|
||||
bindings.registerBinding { builder: InputBindingBuilder ->
|
||||
builder
|
||||
.id(cobblemonResource("interact_wheel_left"))
|
||||
.category(Component.translatable("controlify.category.cobblemon.cobblemon"))
|
||||
.name(Component.translatable("controlify.bind.cobblemon.interact_wheel_left"))
|
||||
.allowedContexts(INTERACT_WHEEL_SCREEN, BindContext.IN_GAME)
|
||||
}
|
||||
|
||||
|
||||
addProcessor(InteractWheelGUI::class, InteractWheelProcessor::class)
|
||||
// This is the lazy way to do all of these (just using the vmouse), if someone with more time and dedication did this that would be better
|
||||
addProcessor(BattleGUI::class, CobblemonGUIProcessor::class)
|
||||
addProcessor(BehaviourEditorScreen::class, CobblemonGUIProcessor::class)
|
||||
addProcessor(CobblemonConfigScreen::class, CobblemonGUIProcessor::class)
|
||||
addProcessor(CookingPotScreen::class, CobblemonGUIProcessor::class)
|
||||
addProcessor(RidingStatsDebugGUI::class, CobblemonGUIProcessor::class)
|
||||
addProcessor(DialogueScreen::class, CobblemonGUIProcessor::class)
|
||||
addProcessor(BattleConfigureGUI::class, CobblemonGUIProcessor::class)
|
||||
addProcessor(MoveSelectGUI::class, CobblemonGUIProcessor::class)
|
||||
addProcessor(PartySelectGUI::class, CobblemonGUIProcessor::class)
|
||||
addProcessor(NPCEditorScreen::class, CobblemonGUIProcessor::class)
|
||||
addProcessor(PCGUI::class, CobblemonGUIProcessor::class)
|
||||
addProcessor(PokedexGUI::class, CobblemonGUIProcessor::class)
|
||||
addProcessor(PokeNav::class, CobblemonGUIProcessor::class)
|
||||
addProcessor(SnapshotWarningScreen::class, CobblemonGUIProcessor::class)
|
||||
addProcessor(StarterSelectionScreen::class, CobblemonGUIProcessor::class)
|
||||
addProcessor(Summary::class, CobblemonGUIProcessor::class)
|
||||
addProcessor(TradeGUI::class, CobblemonGUIProcessor::class)
|
||||
}
|
||||
|
||||
override fun onControllersDiscovered(controlifyApi: ControlifyApi) {
|
||||
}
|
||||
|
||||
// This is jank, but I did it after I got my wisdom teeth extracted so tbh I think I did good enough, but I won't be offended if someone changes it to something sane.
|
||||
fun addProcessor(t: KClass<out Screen>, processorClazz: KClass<out CobblemonGUIProcessor>) {
|
||||
ScreenProcessorFactory.registerProvider(t.java) {
|
||||
processorClazz.primaryConstructor?.call(it)
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
var RIDING_UP: InputBindingSupplier? = null
|
||||
var RIDING_DOWN: InputBindingSupplier? = null
|
||||
var RIDING_RIGHT: InputBindingSupplier? = null
|
||||
var RIDING_LEFT: InputBindingSupplier? = null
|
||||
var HIDE_PARTY: InputBindingSupplier? = null
|
||||
var SUMMARY: InputBindingSupplier? = null
|
||||
var PARTY_OVERLAY_DOWN: InputBindingSupplier? = null
|
||||
var PARTY_OVERLAY_UP: InputBindingSupplier? = null
|
||||
var SEND_OUT_POKEMON: InputBindingSupplier? = null
|
||||
var RIDING_FREELOOK: InputBindingSupplier? = null
|
||||
var INTERACT_WHEEL_UP_AXIS: InputBindingSupplier? = null
|
||||
var INTERACT_WHEEL_DOWN_AXIS: InputBindingSupplier? = null
|
||||
var INTERACT_WHEEL_LEFT_AXIS: InputBindingSupplier? = null
|
||||
var INTERACT_WHEEL_RIGHT_AXIS: InputBindingSupplier? = null
|
||||
|
||||
val RIDING_POKEMON: BindContext = BindContext(
|
||||
cobblemonResource("riding"),
|
||||
{ mc: Minecraft ->
|
||||
mc.player?.vehicle is PokemonEntity
|
||||
}
|
||||
)
|
||||
|
||||
val ORIENTATION_CONTROLLER_ACTIVE: BindContext = BindContext(
|
||||
cobblemonResource("orientation_controller_active"),
|
||||
{ mc: Minecraft ->
|
||||
val localPlayer = mc.player
|
||||
if (localPlayer == null) return@BindContext false
|
||||
val vehicle = localPlayer.vehicle
|
||||
vehicle is OrientationControllable && vehicle.getOrientationController().isActive()
|
||||
}
|
||||
)
|
||||
|
||||
val HAS_POKEMON: BindContext = BindContext(
|
||||
cobblemonResource("has_pokemon"),
|
||||
{mc: Minecraft ->
|
||||
!CobblemonClient.storage.party.isEmpty()
|
||||
}
|
||||
)
|
||||
|
||||
val INTERACT_WHEEL_SCREEN: BindContext = BindContext(
|
||||
cobblemonResource("wheel_screen"),
|
||||
{ it.screen is InteractWheelGUI}
|
||||
)
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* 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.client.integration.controlify.gui
|
||||
|
||||
import com.cobblemon.mod.common.client.integration.controlify.gui.component.ControllerComponentManager
|
||||
import dev.isxander.controlify.screenop.ScreenProcessor
|
||||
import dev.isxander.controlify.virtualmouse.VirtualMouseBehaviour
|
||||
import net.minecraft.client.gui.screens.Screen
|
||||
|
||||
open class CobblemonGUIProcessor(open val screen: Screen) : ScreenProcessor<Screen>(screen) {
|
||||
val controllerComponentManager = ControllerComponentManager(screen)
|
||||
|
||||
override fun virtualMouseBehaviour(): VirtualMouseBehaviour {
|
||||
return VirtualMouseBehaviour.DISABLED
|
||||
}
|
||||
}
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* 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.client.integration.controlify.gui
|
||||
|
||||
import com.cobblemon.mod.common.client.gui.interact.wheel.InteractWheelGUI
|
||||
import com.cobblemon.mod.common.client.integration.controlify.CobblemonControlifyEntrypoint
|
||||
import dev.isxander.controlify.controller.ControllerEntity
|
||||
import dev.isxander.controlify.controller.haptic.HapticEffects
|
||||
import dev.isxander.controlify.screenop.ScreenControllerEventListener
|
||||
import net.minecraft.util.Mth
|
||||
import kotlin.math.abs
|
||||
|
||||
|
||||
// Lots of this is taken from the RadialMenu in Controlify to make this screen feel consistent with it
|
||||
class InteractWheelProcessor(override val screen: InteractWheelGUI) : CobblemonGUIProcessor(screen), ScreenControllerEventListener {
|
||||
private var selectedButton = -1
|
||||
private var idleTicks: Int = 0
|
||||
private var idleTicksTimeout: Int? = null
|
||||
|
||||
init {
|
||||
addEventListener(this)
|
||||
}
|
||||
|
||||
override fun onControllerInput(controller: ControllerEntity) {
|
||||
if (idleTicksTimeout == null) {
|
||||
idleTicksTimeout = controller.input().orElseThrow().confObj().radialButtonFocusTimeoutTicks
|
||||
}
|
||||
|
||||
// If not created from entrypoint then something is very wrong
|
||||
val x = CobblemonControlifyEntrypoint.INTERACT_WHEEL_RIGHT_AXIS!!.on(controller).analogueNow()
|
||||
- CobblemonControlifyEntrypoint.INTERACT_WHEEL_LEFT_AXIS!!.on(controller).analogueNow()
|
||||
val y = CobblemonControlifyEntrypoint.INTERACT_WHEEL_DOWN_AXIS!!.on(controller).analogueNow()
|
||||
- CobblemonControlifyEntrypoint.INTERACT_WHEEL_UP_AXIS!!.on(controller).analogueNow()
|
||||
val threshold = controller.input().orElseThrow().config().config().buttonActivationThreshold
|
||||
|
||||
if (abs(x) >= threshold || abs(y) >= threshold) {
|
||||
val angle = Mth.wrapDegrees(Mth.RAD_TO_DEG * Mth.atan2(y.toDouble(), x.toDouble()) - 90f) + 180f
|
||||
val buttonCount = screen.buttons.size
|
||||
val each = 360f / buttonCount
|
||||
|
||||
val newSelected = Mth.floor((angle + each / 2f) / each) % buttonCount
|
||||
if (newSelected != selectedButton) {
|
||||
selectedButton = newSelected
|
||||
controller.hdHaptics().ifPresent { haptics -> haptics.playHaptic(HapticEffects.NAVIGATE) }
|
||||
}
|
||||
|
||||
for (button in 0..<buttonCount) {
|
||||
val selected = button == selectedButton
|
||||
screen.buttons[button].isFocused = selected
|
||||
}
|
||||
|
||||
idleTicks = 0
|
||||
} else {
|
||||
idleTicks = idleTicks+ 1
|
||||
if (idleTicks>= idleTicksTimeout!! && selectedButton != -1) {
|
||||
selectedButton = -1
|
||||
for (button in screen.buttons) {
|
||||
button.isFocused = false
|
||||
}
|
||||
controller.hdHaptics().ifPresent { haptics -> haptics.playHaptic(HapticEffects.NAVIGATE) }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
package com.cobblemon.mod.common.client.integration.controlify.gui.component
|
||||
|
||||
import net.minecraft.client.gui.components.events.GuiEventListener
|
||||
import net.minecraft.client.gui.screens.Screen
|
||||
|
||||
class ControllerComponent<T : Screen> {
|
||||
var left: (T) -> ControllerComponent<T>? = { null }
|
||||
var right: (T) -> ControllerComponent<T>? = { null }
|
||||
var up: (T) -> ControllerComponent<T>? = { null }
|
||||
var down: (T) -> ControllerComponent<T>? = { null }
|
||||
|
||||
var associatedGUIElement: GuiEventListener? = null
|
||||
|
||||
fun pairLeft(leftComponent: ControllerComponent<T>) {
|
||||
left = { leftComponent }
|
||||
leftComponent.right = { this }
|
||||
}
|
||||
|
||||
fun pairRight(rightComponent: ControllerComponent<T>) {
|
||||
right = { rightComponent }
|
||||
rightComponent.left = { this }
|
||||
}
|
||||
|
||||
fun pairUp(upComponent: ControllerComponent<T>) {
|
||||
up = { upComponent }
|
||||
upComponent.down = { this }
|
||||
}
|
||||
|
||||
fun pairDown(downComponent: ControllerComponent<T>) {
|
||||
down = { downComponent }
|
||||
downComponent.up = { this }
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package com.cobblemon.mod.common.client.integration.controlify.gui.component
|
||||
|
||||
import net.minecraft.client.gui.screens.Screen
|
||||
|
||||
class ControllerComponentManager<T : Screen>(val screen: T) {
|
||||
var focused: ControllerComponent<T>?
|
||||
get() = focused
|
||||
set(value) {
|
||||
focused = value
|
||||
focused?.associatedGUIElement?.let { screen.focused = it }
|
||||
}
|
||||
|
||||
fun left() = focused?.left?.invoke(screen)?.let { focused = it }
|
||||
fun right() = focused?.right?.invoke(screen)?.let { focused = it }
|
||||
fun up() = focused?.up?.invoke(screen)?.let { focused = it }
|
||||
fun down() = focused?.down?.invoke(screen)?.let { focused = it }
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* 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.client.net.data
|
||||
|
||||
import com.cobblemon.mod.common.api.interaction.PokemonInteractions
|
||||
import com.cobblemon.mod.common.api.net.ClientNetworkPacketHandler
|
||||
import com.cobblemon.mod.common.net.messages.client.data.PokemonInteractionsSyncPacket
|
||||
import net.minecraft.client.Minecraft
|
||||
|
||||
object PokemonInteractionsSyncHandler : ClientNetworkPacketHandler<PokemonInteractionsSyncPacket> {
|
||||
|
||||
override fun handle(
|
||||
packet: PokemonInteractionsSyncPacket,
|
||||
client: Minecraft,
|
||||
) {
|
||||
PokemonInteractions.speciesInteractions.clear()
|
||||
PokemonInteractions.speciesInteractions.addAll(packet.speciesInteractions)
|
||||
PokemonInteractions.generalInteractions.clear()
|
||||
PokemonInteractions.generalInteractions.addAll(packet.generalInteractions)
|
||||
}
|
||||
}
|
||||
+21
-5
@@ -8,6 +8,8 @@
|
||||
|
||||
package com.cobblemon.mod.common.client.persisted
|
||||
|
||||
import com.cobblemon.mod.common.Cobblemon
|
||||
import com.cobblemon.mod.common.Cobblemon.LOGGER
|
||||
import com.cobblemon.mod.common.config.CobblemonConfig
|
||||
import java.io.BufferedReader
|
||||
import java.io.BufferedWriter
|
||||
@@ -31,7 +33,14 @@ object ClientPersistedData {
|
||||
fun readSnapshotsData() : SnapshotAcknowledgementData? {
|
||||
if (snapshotsPath.exists()) {
|
||||
BufferedReader(InputStreamReader(FileInputStream(snapshotsPath.toFile()))).use { reader ->
|
||||
return gson.fromJson(reader, SnapshotAcknowledgementData::class.java)
|
||||
try {
|
||||
return gson.fromJson(reader, SnapshotAcknowledgementData::class.java)
|
||||
} catch (exception: Exception) {
|
||||
LOGGER.error("Failed to load snapshots.json... Resetting File")
|
||||
val data = SnapshotAcknowledgementData(Cobblemon.VERSION, false)
|
||||
writeSnapshotsData(data)
|
||||
return data
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,16 +55,23 @@ object ClientPersistedData {
|
||||
fun readRidingPerspectivesData() : RidingPerspectiveData? {
|
||||
if (ridingPerspectivesPath.exists()) {
|
||||
BufferedReader(InputStreamReader(FileInputStream(ridingPerspectivesPath.toFile()))).use { reader ->
|
||||
return gson.fromJson(reader, RidingPerspectiveData::class.java)
|
||||
try {
|
||||
return gson.fromJson(reader, RidingPerspectiveData::class.java)
|
||||
} catch (exception: Exception) {
|
||||
LOGGER.error("Failed to load riding_perspectives.json... Resetting File")
|
||||
val data = RidingPerspectiveData()
|
||||
saveRidingPerspectivesData(data)
|
||||
return data
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
fun saveRidingPerspectivesData() {
|
||||
fun saveRidingPerspectivesData(data: RidingPerspectiveData) {
|
||||
ridingPerspectivesPath.toFile().parentFile.mkdirs()
|
||||
BufferedWriter(FileWriter(ridingPerspectivesPath.toFile())).use { writer -> gson.toJson(ridingPerspectives, writer) }
|
||||
BufferedWriter(FileWriter(ridingPerspectivesPath.toFile())).use { writer -> gson.toJson(data, writer) }
|
||||
}
|
||||
|
||||
data class SnapshotAcknowledgementData(val version: String, val dontShowAgain: Boolean)
|
||||
@@ -64,7 +80,7 @@ object ClientPersistedData {
|
||||
) {
|
||||
fun updatePerspective(key: ResourceLocation, cameraType: CameraType) {
|
||||
perspectives[key] = cameraType
|
||||
saveRidingPerspectivesData()
|
||||
saveRidingPerspectivesData(this)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1208,14 +1208,13 @@ open class PokemonEntity(
|
||||
}
|
||||
}
|
||||
|
||||
if (hand == InteractionHand.MAIN_HAND && player is ServerPlayer) {
|
||||
if (player.isShiftKeyDown) {
|
||||
if (hand == InteractionHand.MAIN_HAND) {
|
||||
if (player.isShiftKeyDown && player is ServerPlayer) {
|
||||
showInteractionWheel(player, itemStack)
|
||||
return InteractionResult.sidedSuccess(level().isClientSide)
|
||||
}
|
||||
else if (pokemon.getOwnerPlayer() == player) {
|
||||
// TODO #105
|
||||
if (this.attemptItemInteraction(player, player.getItemInHand(hand))) return InteractionResult.SUCCESS
|
||||
else if (this.ownerUUID == player.uuid && this.attemptItemInteraction(player, player.getItemInHand(hand))) {
|
||||
return InteractionResult.sidedSuccess(level().isClientSide)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1391,18 +1390,24 @@ open class PokemonEntity(
|
||||
return bagItemLike.handleInteraction(player, battlePokemon, stack)
|
||||
}
|
||||
|
||||
if (player !is ServerPlayer || this.isBusy) {
|
||||
if (this.isBusy) {
|
||||
return false
|
||||
}
|
||||
|
||||
val interaction = PokemonInteractions.findInteraction(this)
|
||||
|
||||
if (interaction != null && !pokemon.isOnInteractionCooldown(interaction.grouping)) {
|
||||
interaction.effects.forEach { it.applyEffect(this, player) }
|
||||
pokemon.interactionCooldowns.put(interaction.grouping, runtime.resolveInt(interaction.cooldown))
|
||||
if (player is ServerPlayer) {
|
||||
interaction.effects.forEach { it.applyEffect(this, player) }
|
||||
pokemon.interactionCooldowns.put(interaction.grouping, runtime.resolveInt(interaction.cooldown))
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
if (player !is ServerPlayer) {
|
||||
return false
|
||||
}
|
||||
|
||||
// Evolution item logic
|
||||
if (pokemon.getOwnerPlayer() == player) {
|
||||
val context = ItemInteractionEvolution.ItemInteractionContext(stack, player.level())
|
||||
|
||||
@@ -30,21 +30,13 @@ import com.cobblemon.mod.common.api.events.battles.BattleStartedEvent
|
||||
import com.cobblemon.mod.common.api.events.battles.BattleVictoryEvent
|
||||
import com.cobblemon.mod.common.api.events.fishing.PokerodCastEvent
|
||||
import com.cobblemon.mod.common.api.events.fishing.PokerodReelEvent
|
||||
import com.cobblemon.mod.common.api.events.pokemon.CollectEggEvent
|
||||
import com.cobblemon.mod.common.api.events.pokemon.FossilRevivedEvent
|
||||
import com.cobblemon.mod.common.api.events.pokemon.HatchEggEvent
|
||||
import com.cobblemon.mod.common.api.events.pokemon.LevelUpEvent
|
||||
import com.cobblemon.mod.common.api.events.pokemon.PokemonCapturedEvent
|
||||
import com.cobblemon.mod.common.api.events.pokemon.PokemonGainedEvent
|
||||
import com.cobblemon.mod.common.api.events.pokemon.RidePokemonEvent
|
||||
import com.cobblemon.mod.common.api.events.pokemon.TradeEvent
|
||||
import com.cobblemon.mod.common.api.events.pokemon.*
|
||||
import com.cobblemon.mod.common.api.events.pokemon.evolution.EvolutionCompleteEvent
|
||||
import com.cobblemon.mod.common.api.events.storage.ReleasePokemonEvent
|
||||
import com.cobblemon.mod.common.api.stats.CobblemonStats.getStat
|
||||
import com.cobblemon.mod.common.util.getPlayer
|
||||
import net.minecraft.core.registries.BuiltInRegistries
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
import net.minecraft.server.level.ServerPlayer
|
||||
import java.util.UUID
|
||||
import java.util.*
|
||||
|
||||
object StatHandler : EventHandler {
|
||||
override fun registerListeners() {
|
||||
@@ -100,13 +92,13 @@ object StatHandler : EventHandler {
|
||||
|
||||
fun onBattleStart(event : BattleStartedEvent) {
|
||||
event.battle.players.forEach { player ->
|
||||
player.awardStat(this.getStat(getStat(Cobblemon.statistics.BATTLES_TOTAL)))
|
||||
player.awardStat(getStat(Cobblemon.statistics.BATTLES_TOTAL))
|
||||
}
|
||||
}
|
||||
|
||||
fun onDexEntryGain(event : PokemonGainedEvent) {
|
||||
val player = event.pokemon.getOwnerPlayer()
|
||||
player?.awardStat(getStat(getStat(Cobblemon.statistics.DEX_ENTRIES)))
|
||||
player?.awardStat(getStat(Cobblemon.statistics.DEX_ENTRIES))
|
||||
}
|
||||
|
||||
fun onCollectEgg(event : CollectEggEvent) {
|
||||
@@ -139,12 +131,4 @@ object StatHandler : EventHandler {
|
||||
fun onReelIn(event : PokerodReelEvent) {
|
||||
event.player.awardStat(getStat(Cobblemon.statistics.REEL_INS))
|
||||
}
|
||||
|
||||
fun getStat(resourceLocation: ResourceLocation) : ResourceLocation {
|
||||
val stat = BuiltInRegistries.CUSTOM_STAT.get(resourceLocation)
|
||||
if (stat == null) {
|
||||
Cobblemon.LOGGER.error("Could not find stat with id {}", resourceLocation)
|
||||
}
|
||||
return stat ?: throw NullPointerException("Could not find stat with id $resourceLocation")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,9 +25,7 @@ class MochiItem(stat: Stats): EVIncreaseItem(stat, 4) {
|
||||
}
|
||||
|
||||
pokemon.feedPokemon(1)
|
||||
|
||||
stack.consume(1, player)
|
||||
|
||||
|
||||
return super.applyToPokemon(player, stack, pokemon)
|
||||
}
|
||||
}
|
||||
+10
-3
@@ -35,9 +35,16 @@ class SinisterTeaItem : Item(
|
||||
val effectsComponent = stack.get(CobblemonItemComponents.MOB_EFFECTS)
|
||||
|
||||
if (effectsComponent != null) {
|
||||
for (effect in effectsComponent.mobEffects) {
|
||||
val effectCopy = MobEffectInstance(effect)
|
||||
user.addEffect(effectCopy)
|
||||
for (raw in effectsComponent.mobEffects) {
|
||||
val inst = MobEffectInstance(raw)
|
||||
val holder = inst.effect
|
||||
val effect = holder.value()
|
||||
|
||||
if (effect.isInstantenous) {
|
||||
effect.applyInstantenousEffect(user as? Player, null, user, inst.amplifier, 1.0)
|
||||
} else {
|
||||
user.addEffect(inst)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* 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.messages.client.data
|
||||
|
||||
import com.cobblemon.mod.common.api.interaction.PokemonInteractionSet
|
||||
import com.cobblemon.mod.common.api.net.NetworkPacket
|
||||
import com.cobblemon.mod.common.util.cobblemonResource
|
||||
import net.minecraft.network.RegistryFriendlyByteBuf
|
||||
|
||||
class PokemonInteractionsSyncPacket(
|
||||
val speciesInteractions: List<PokemonInteractionSet>,
|
||||
val generalInteractions: List<PokemonInteractionSet>,
|
||||
) : NetworkPacket<PokemonInteractionsSyncPacket> {
|
||||
override val id = ID
|
||||
|
||||
override fun encode(buffer: RegistryFriendlyByteBuf) {
|
||||
buffer.writeCollection(speciesInteractions) { it, speciesInteraction ->
|
||||
speciesInteraction.encode(it)
|
||||
}
|
||||
buffer.writeCollection(generalInteractions) { it, generalInteraction ->
|
||||
generalInteraction.encode(it)
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
val ID = cobblemonResource("pokemon_interactions_sync")
|
||||
|
||||
fun decode(buffer: RegistryFriendlyByteBuf): PokemonInteractionsSyncPacket {
|
||||
val speciesInteractions = buffer.readList { it ->
|
||||
PokemonInteractionSet.decode(it)
|
||||
}
|
||||
val generalInteractions = buffer.readList { it ->
|
||||
PokemonInteractionSet.decode(it)
|
||||
}
|
||||
|
||||
return PokemonInteractionsSyncPacket(
|
||||
speciesInteractions,
|
||||
generalInteractions,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
-1
@@ -21,7 +21,9 @@ class PokemonStateUpdatePacket(pokemon: () -> Pokemon?, value: PokemonState): Si
|
||||
value.writeToBuffer(buffer)
|
||||
}
|
||||
|
||||
override fun set(pokemon: Pokemon, value: PokemonState) { pokemon.state = value }
|
||||
override fun set(pokemon: Pokemon, value: PokemonState) {
|
||||
pokemon.state = value
|
||||
}
|
||||
|
||||
companion object {
|
||||
val ID = cobblemonResource("state_update")
|
||||
|
||||
+24
-10
@@ -13,30 +13,24 @@ import com.cobblemon.mod.common.api.mark.Marks
|
||||
import com.cobblemon.mod.common.api.pokeball.PokeBalls
|
||||
import com.cobblemon.mod.common.api.pokemon.PokemonSpecies
|
||||
import com.cobblemon.mod.common.api.riding.stats.RidingStat
|
||||
import com.cobblemon.mod.common.client.CobblemonClient
|
||||
import com.cobblemon.mod.common.entity.PlatformType
|
||||
import com.cobblemon.mod.common.entity.PoseType
|
||||
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity
|
||||
import com.cobblemon.mod.common.pokemon.Gender
|
||||
import com.cobblemon.mod.common.util.cobblemonResource
|
||||
import com.cobblemon.mod.common.util.readEnumConstant
|
||||
import com.cobblemon.mod.common.util.readIdentifier
|
||||
import com.cobblemon.mod.common.util.readString
|
||||
import com.cobblemon.mod.common.util.readText
|
||||
import com.cobblemon.mod.common.util.writeEnumConstant
|
||||
import com.cobblemon.mod.common.util.writeIdentifier
|
||||
import com.cobblemon.mod.common.util.writeString
|
||||
import com.cobblemon.mod.common.util.writeText
|
||||
import java.util.UUID
|
||||
import com.cobblemon.mod.common.util.*
|
||||
import net.minecraft.client.multiplayer.ClientLevel
|
||||
import net.minecraft.network.RegistryFriendlyByteBuf
|
||||
import net.minecraft.network.chat.MutableComponent
|
||||
import net.minecraft.network.protocol.game.ClientboundAddEntityPacket
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
import net.minecraft.world.entity.Entity
|
||||
import java.util.*
|
||||
|
||||
class SpawnPokemonPacket(
|
||||
var ownerId: UUID?,
|
||||
var pokemonUUID: UUID,
|
||||
var storageUUID: UUID?,
|
||||
var scaleModifier: Float,
|
||||
var speciesId: ResourceLocation,
|
||||
var gender: Gender,
|
||||
@@ -61,6 +55,7 @@ class SpawnPokemonPacket(
|
||||
var tickSpawned: Int,
|
||||
var rideBoosts: Map<RidingStat, Float>,
|
||||
var rideStamina: Float,
|
||||
var silent: Boolean,
|
||||
vanillaSpawnPacket: ClientboundAddEntityPacket,
|
||||
) : SpawnExtraDataEntityPacket<SpawnPokemonPacket, PokemonEntity>(vanillaSpawnPacket) {
|
||||
|
||||
@@ -69,6 +64,7 @@ class SpawnPokemonPacket(
|
||||
constructor(entity: PokemonEntity, vanillaSpawnPacket: ClientboundAddEntityPacket) : this(
|
||||
entity.ownerUUID,
|
||||
entity.pokemon.uuid,
|
||||
entity.pokemon.storeCoordinates.get()?.store?.uuid,
|
||||
entity.pokemon.scaleModifier,
|
||||
entity.exposedSpecies.resourceIdentifier,
|
||||
entity.pokemon.gender,
|
||||
@@ -93,12 +89,14 @@ class SpawnPokemonPacket(
|
||||
entity.tickCount,
|
||||
entity.entityData.get(PokemonEntity.RIDE_BOOSTS),
|
||||
entity.entityData.get(PokemonEntity.RIDE_STAMINA),
|
||||
entity.isSilent,
|
||||
vanillaSpawnPacket
|
||||
)
|
||||
|
||||
override fun encodeEntityData(buffer: RegistryFriendlyByteBuf) {
|
||||
buffer.writeNullable(ownerId) { _, v -> buffer.writeUUID(v) }
|
||||
buffer.writeUUID(this.pokemonUUID)
|
||||
buffer.writeNullable(this.storageUUID) { pb, value -> pb.writeUUID(value) }
|
||||
buffer.writeFloat(this.scaleModifier)
|
||||
buffer.writeIdentifier(this.speciesId)
|
||||
buffer.writeEnumConstant(this.gender)
|
||||
@@ -127,10 +125,21 @@ class SpawnPokemonPacket(
|
||||
{ _, value -> buffer.writeFloat(value) }
|
||||
)
|
||||
buffer.writeFloat(rideStamina)
|
||||
buffer.writeBoolean(silent)
|
||||
}
|
||||
|
||||
override fun applyData(entity: PokemonEntity, level: ClientLevel) {
|
||||
entity.ownerUUID = ownerId
|
||||
|
||||
// Reuse the stored Pokémon instance to avoid creating a duplicate,
|
||||
// preventing client/entity desync issues.
|
||||
this@SpawnPokemonPacket.storageUUID?.let {
|
||||
val storedPokemon = CobblemonClient.storage.locatePokemon(it, this@SpawnPokemonPacket.pokemonUUID)
|
||||
if (storedPokemon != null) {
|
||||
entity.pokemon = storedPokemon
|
||||
}
|
||||
}
|
||||
|
||||
entity.pokemon.apply {
|
||||
uuid = this@SpawnPokemonPacket.pokemonUUID
|
||||
scaleModifier = this@SpawnPokemonPacket.scaleModifier
|
||||
@@ -162,6 +171,7 @@ class SpawnPokemonPacket(
|
||||
entity.entityData.set(PokemonEntity.RIDE_BOOSTS, rideBoosts)
|
||||
entity.entityData.set(PokemonEntity.RIDE_STAMINA, rideStamina)
|
||||
entity.entityData.set(PokemonEntity.SCALE_MODIFIER, scaleModifier)
|
||||
entity.isSilent = silent
|
||||
|
||||
entity.ejectPassengers()
|
||||
passengers.forEach {
|
||||
@@ -179,6 +189,7 @@ class SpawnPokemonPacket(
|
||||
fun decode(buffer: RegistryFriendlyByteBuf): SpawnPokemonPacket {
|
||||
val ownerId = buffer.readNullable { buffer.readUUID() }
|
||||
val pokemonUUID = buffer.readUUID()
|
||||
val storageUUID = buffer.readNullable { buffer.readUUID() }
|
||||
val scaleModifier = buffer.readFloat()
|
||||
val speciesId = buffer.readIdentifier()
|
||||
val gender = buffer.readEnumConstant(Gender::class.java)
|
||||
@@ -206,11 +217,13 @@ class SpawnPokemonPacket(
|
||||
{ buffer.readFloat() }
|
||||
)
|
||||
val rideStamina = buffer.readFloat()
|
||||
val silent = buffer.readBoolean()
|
||||
val vanillaPacket = decodeVanillaPacket(buffer)
|
||||
|
||||
return SpawnPokemonPacket(
|
||||
ownerId,
|
||||
pokemonUUID,
|
||||
storageUUID,
|
||||
scaleModifier,
|
||||
speciesId,
|
||||
gender,
|
||||
@@ -235,6 +248,7 @@ class SpawnPokemonPacket(
|
||||
tickSpawned,
|
||||
rideBoosts,
|
||||
rideStamina,
|
||||
silent,
|
||||
vanillaPacket
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1437,6 +1437,11 @@ open class Pokemon : ShowdownIdentifiable {
|
||||
}
|
||||
|
||||
fun getOwnerEntity(): LivingEntity? {
|
||||
if (isClient) {
|
||||
val ownerUUID = entity?.ownerUUID ?: return null
|
||||
return entity?.level()?.getPlayerByUUID(ownerUUID)
|
||||
}
|
||||
|
||||
return storeCoordinates.get()?.let {
|
||||
if (isPlayerOwned()) {
|
||||
server()?.playerList?.getPlayer(it.store.uuid)
|
||||
|
||||
+55
-7
@@ -8,13 +8,22 @@
|
||||
|
||||
package com.cobblemon.mod.common.pokemon.adapters
|
||||
|
||||
import com.cobblemon.mod.common.api.interaction.InteractionEffect
|
||||
import com.cobblemon.mod.common.api.molang.ExpressionLike
|
||||
import com.cobblemon.mod.common.api.pokemon.PokemonProperties
|
||||
import com.cobblemon.mod.common.api.pokemon.adapters.RequirementAdapter
|
||||
import com.cobblemon.mod.common.api.pokemon.requirement.Requirement
|
||||
import com.cobblemon.mod.common.pokemon.evolution.adapters.LegacyItemConditionWrapperAdapter
|
||||
import com.cobblemon.mod.common.pokemon.requirements.*
|
||||
import com.cobblemon.mod.common.util.adapters.*
|
||||
import com.cobblemon.mod.common.util.readString
|
||||
import com.cobblemon.mod.common.util.writeString
|
||||
import com.google.common.collect.HashBiMap
|
||||
import com.google.gson.JsonDeserializationContext
|
||||
import com.google.gson.JsonElement
|
||||
import com.google.gson.JsonSerializationContext
|
||||
import com.google.gson.*
|
||||
import net.minecraft.advancements.critereon.ItemPredicate
|
||||
import net.minecraft.network.FriendlyByteBuf
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
import net.minecraft.util.LowerCaseEnumTypeAdapterFactory
|
||||
import java.lang.reflect.Type
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
@@ -60,21 +69,60 @@ object CobblemonRequirementAdapter : RequirementAdapter {
|
||||
this.registerType(OwnerHoldsItemRequirement.ADAPTER_VARIANT, OwnerHoldsItemRequirement::class)
|
||||
}
|
||||
|
||||
val gson: Gson by lazy {
|
||||
GsonBuilder()
|
||||
.registerTypeAdapter(ResourceLocation::class.java, IdentifierAdapter)
|
||||
.registerTypeAdapter(PokemonProperties::class.java, pokemonPropertiesShortAdapter)
|
||||
.registerTypeAdapter(ItemPredicate::class.java, LegacyItemConditionWrapperAdapter)
|
||||
.registerTypeAdapter(Requirement::class.java, CobblemonRequirementAdapter)
|
||||
.registerTypeAdapter(InteractionEffect::class.java, InteractionEffectAdapter)
|
||||
.registerTypeAdapter(ExpressionLike::class.java, ExpressionLikeAdapter)
|
||||
.registerTypeAdapter(IntRange::class.java, IntRangeAdapter)
|
||||
.registerTypeAdapterFactory(LowerCaseEnumTypeAdapterFactory())
|
||||
.setPrettyPrinting()
|
||||
.create()
|
||||
}
|
||||
|
||||
override fun <T : Requirement> registerType(id: String, type: KClass<T>) {
|
||||
this.types[id.lowercase()] = type
|
||||
}
|
||||
|
||||
override fun deserialize(json: JsonElement, typeOfT: Type, context: JsonDeserializationContext): Requirement {
|
||||
val variant = json.asJsonObject.get(VARIANT).asString.lowercase()
|
||||
val type = this.types[variant] ?: throw IllegalArgumentException("Cannot resolve evolution requirement type for variant $variant")
|
||||
val type = getRequirementType(variant)
|
||||
return context.deserialize(json, type.java)
|
||||
}
|
||||
|
||||
override fun serialize(src: Requirement, typeOfSrc: Type, context: JsonSerializationContext): JsonElement {
|
||||
val json = context.serialize(src, src::class.java).asJsonObject
|
||||
val variant = this.types.inverse()[src::class] ?: throw IllegalArgumentException("Cannot resolve evolution requirement for type ${src::class.qualifiedName}")
|
||||
override fun serialize(requirement: Requirement, typeOfSrc: Type, context: JsonSerializationContext): JsonElement {
|
||||
val json = context.serialize(requirement, requirement::class.java).asJsonObject
|
||||
val variant = getVariant(requirement)
|
||||
json.addProperty(VARIANT, variant)
|
||||
return json
|
||||
}
|
||||
|
||||
fun encode(requirement: Requirement, buffer: FriendlyByteBuf) {
|
||||
buffer.writeString(gson.toJson(requirement, Requirement::class.java))
|
||||
}
|
||||
|
||||
fun decode(buffer: FriendlyByteBuf): Requirement {
|
||||
return gson.fromJson(buffer.readString(), Requirement::class.java)
|
||||
}
|
||||
|
||||
private fun getVariant(requirement: Requirement): String {
|
||||
val variant = this.types.inverse()[requirement::class]
|
||||
if (variant == null) {
|
||||
throw IllegalArgumentException("Cannot resolve evolution requirement for type ${requirement::class.qualifiedName}")
|
||||
}
|
||||
|
||||
return variant
|
||||
}
|
||||
|
||||
private fun getRequirementType(variant: String): KClass<out Requirement> {
|
||||
val requirementType = this.types[variant]
|
||||
if (requirementType == null) {
|
||||
throw IllegalArgumentException("Cannot resolve evolution requirement type for variant $variant")
|
||||
}
|
||||
|
||||
return requirementType
|
||||
}
|
||||
}
|
||||
+7
-4
@@ -11,9 +11,9 @@ package com.cobblemon.mod.common.pokemon.requirements
|
||||
import com.cobblemon.mod.common.api.pokemon.requirement.OwnerQueryRequirement
|
||||
import com.cobblemon.mod.common.entity.npc.NPCEntity
|
||||
import com.cobblemon.mod.common.pokemon.Pokemon
|
||||
import net.minecraft.server.level.ServerPlayer
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
import kotlin.collections.iterator
|
||||
import net.minecraft.server.level.ServerPlayer
|
||||
import net.minecraft.world.entity.player.Player
|
||||
|
||||
/**
|
||||
* An [com.cobblemon.mod.common.api.pokemon.requirement.Requirement] that checks if the player has a certain [net.minecraft.advancements.Advancement]
|
||||
@@ -26,13 +26,16 @@ class AdvancementRequirement(val requiredAdvancement: ResourceLocation) : OwnerQ
|
||||
|
||||
override fun checkPlayer(
|
||||
pokemon: Pokemon,
|
||||
owner: ServerPlayer
|
||||
owner: Player
|
||||
): Boolean {
|
||||
for (entry in owner.advancements.progress) {
|
||||
val serverPlayer = owner as? ServerPlayer ?: return false
|
||||
|
||||
for (entry in serverPlayer.advancements.progress) {
|
||||
if (entry.key.id == requiredAdvancement && entry.value.isDone) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
+2
-4
@@ -12,11 +12,9 @@ import com.cobblemon.mod.common.api.pokemon.requirement.OwnerQueryRequirement
|
||||
import com.cobblemon.mod.common.entity.npc.NPCEntity
|
||||
import com.cobblemon.mod.common.pokemon.Pokemon
|
||||
import net.minecraft.advancements.critereon.ItemPredicate
|
||||
import net.minecraft.server.level.ServerPlayer
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
import net.minecraft.world.InteractionHand
|
||||
import net.minecraft.world.entity.LivingEntity
|
||||
import kotlin.collections.iterator
|
||||
import net.minecraft.world.entity.player.Player
|
||||
|
||||
/**
|
||||
* An [OwnerQueryRequirement] that checks if the player/npc is holding a certain [ItemPredicate]
|
||||
@@ -30,7 +28,7 @@ class OwnerHoldsItemRequirement(val itemCondition: ItemPredicate)
|
||||
|
||||
override fun checkPlayer(
|
||||
pokemon: Pokemon,
|
||||
owner: ServerPlayer
|
||||
owner: Player
|
||||
): Boolean {
|
||||
return checkItem(owner)
|
||||
}
|
||||
|
||||
+12
-8
@@ -8,22 +8,22 @@
|
||||
|
||||
package com.cobblemon.mod.common.util.adapters
|
||||
|
||||
import com.google.gson.JsonDeserializationContext
|
||||
import com.google.gson.JsonDeserializer
|
||||
import com.google.gson.JsonElement
|
||||
import com.google.gson.JsonSerializationContext
|
||||
import com.google.gson.JsonSerializer
|
||||
import com.google.gson.*
|
||||
import com.mojang.serialization.Codec
|
||||
import com.mojang.serialization.JsonOps
|
||||
import java.lang.reflect.Type
|
||||
|
||||
class CodecBackedAdapter<T>(val codec: Codec<T>) : JsonDeserializer<T>, JsonSerializer<T> {
|
||||
|
||||
override fun deserialize(
|
||||
jElement: JsonElement,
|
||||
typeOfT: Type,
|
||||
context: JsonDeserializationContext
|
||||
): T {
|
||||
return JsonOps.INSTANCE.withDecoder(codec).apply(jElement).result().get().first as T
|
||||
val ops = RegistryOpsProvider.getOpsWithDefaultFallback()
|
||||
val result = ops.withDecoder(codec).apply(jElement)
|
||||
return result.result().orElseThrow {
|
||||
IllegalStateException("Failed to deserialize $jElement: ${result.error().orElse(null)}")
|
||||
}.first
|
||||
}
|
||||
|
||||
override fun serialize(
|
||||
@@ -31,6 +31,10 @@ class CodecBackedAdapter<T>(val codec: Codec<T>) : JsonDeserializer<T>, JsonSeri
|
||||
typeOfSrc: Type?,
|
||||
context: JsonSerializationContext?
|
||||
): JsonElement {
|
||||
return JsonOps.INSTANCE.withEncoder(codec).apply(src).result().get()
|
||||
val ops = RegistryOpsProvider.getOpsWithDefaultFallback()
|
||||
val result = ops.withEncoder(codec).apply(src)
|
||||
return result.result().orElseThrow {
|
||||
IllegalStateException("Failed to serialize $src: ${result.error().orElse(null)}")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* 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.util.adapters
|
||||
|
||||
import com.cobblemon.mod.common.Cobblemon
|
||||
import com.cobblemon.mod.common.Environment
|
||||
import com.cobblemon.mod.common.util.server
|
||||
import com.google.gson.JsonElement
|
||||
import com.mojang.serialization.DynamicOps
|
||||
import com.mojang.serialization.JsonOps
|
||||
import net.minecraft.client.Minecraft
|
||||
import net.minecraft.resources.RegistryOps
|
||||
|
||||
/**
|
||||
* Utility for obtaining RegistryOps with the correct client/server registry access.
|
||||
* Used when manually encoding/decoding registry-backed values (e.g., items, predicates).
|
||||
*/
|
||||
object RegistryOpsProvider {
|
||||
fun getOpsWithDefaultFallback(): DynamicOps<JsonElement> {
|
||||
if (Cobblemon.implementation.environment() == Environment.CLIENT) {
|
||||
val minecraft = Minecraft.getInstance()
|
||||
if (minecraft != null && minecraft.level != null)
|
||||
return RegistryOps.create(JsonOps.INSTANCE, minecraft.level!!.registryAccess())
|
||||
}
|
||||
|
||||
|
||||
if (Cobblemon.implementation.environment() == Environment.SERVER) {
|
||||
val server = server()
|
||||
if (server != null)
|
||||
return RegistryOps.create(JsonOps.INSTANCE, server.registryAccess())
|
||||
}
|
||||
|
||||
return JsonOps.INSTANCE
|
||||
}
|
||||
}
|
||||
@@ -820,6 +820,14 @@
|
||||
"cobblemon.cooking.cooking_quality.medium": "Medium",
|
||||
"cobblemon.cooking.cooking_quality.high": "High",
|
||||
|
||||
"effect.cobblemon.cleanse_all": "Effect Cleanse",
|
||||
"effect.cobblemon.cleanse_negative": "Negative Effect Cleanse",
|
||||
"effect.cobblemon.mental_restoration": "Mental Restoration",
|
||||
|
||||
"effect.cobblemon.cleanse_all": "Effect Cleanse",
|
||||
"effect.cobblemon.cleanse_negative": "Negative Effect Cleanse",
|
||||
"effect.cobblemon.mental_restoration": "Mental Restoration",
|
||||
|
||||
"cobblemon.fossil.armor": "Armor",
|
||||
"cobblemon.fossil.bird": "Bird",
|
||||
"cobblemon.fossil.claw": "Claw",
|
||||
@@ -3515,6 +3523,7 @@
|
||||
"tag.item.cobblemon.plants": "Plants",
|
||||
"tag.item.cobblemon.seeds": "Seeds",
|
||||
"tag.item.cobblemon.boats": "Boats",
|
||||
"tag.item.cobblemon.chest_boats": "Chest Boats",
|
||||
"tag.item.cobblemon.hanging_signs": "Hanging Signs",
|
||||
"tag.item.cobblemon.signs": "Signs",
|
||||
"tag.item.cobblemon.dawn_stone_ores": "Dawn Stone Ores",
|
||||
@@ -9445,5 +9454,14 @@
|
||||
"stat.cobblemon.traded": "Pokémon Traded",
|
||||
"stat.cobblemon.times_ridden": "Pokémon Ridden",
|
||||
"stat.cobblemon.rod_casts": "PokéRod Casts",
|
||||
"stat.cobblemon.reel_ins": "PokéRod Catches"
|
||||
"stat.cobblemon.reel_ins": "PokéRod Catches",
|
||||
"stat.cobblemon.riding_land": "Distance by Pokémon on Land",
|
||||
"stat.cobblemon.riding_air": "Distance by Pokémon in Air",
|
||||
"stat.cobblemon.riding_liquid": "Distance by Pokémon in Liquid",
|
||||
|
||||
"controlify.category.cobblemon.cobblemon": "Cobblemon",
|
||||
"controlify.bind.cobblemon.riding_up": "Look Up",
|
||||
"controlify.bind.cobblemon.riding_down": "Look Down",
|
||||
"controlify.bind.cobblemon.riding_left": "Look Left",
|
||||
"controlify.bind.cobblemon.riding_right": "Look Right"
|
||||
}
|
||||
|
||||
@@ -1517,76 +1517,139 @@
|
||||
{ "name": "cobblemon:animation/wings/steel_wing_flap_medium_8", "volume": 0.25 }
|
||||
]
|
||||
},
|
||||
"ride.loop.wind": {
|
||||
"ride.loop.wind.mono": {
|
||||
"sounds": [
|
||||
{
|
||||
"name": "cobblemon:ride/loop/wind_loop",
|
||||
"name": "cobblemon:ride/loop/wind_loop_mono",
|
||||
"stream": true,
|
||||
"attenuation_distance": 48.0,
|
||||
"volume": 0.15
|
||||
}
|
||||
]
|
||||
},
|
||||
"ride.loop.leather": {
|
||||
"ride.loop.wind.stereo": {
|
||||
"sounds": [
|
||||
{
|
||||
"name": "cobblemon:ride/loop/leather_flight_loop",
|
||||
"name": "cobblemon:ride/loop/wind_loop_stereo",
|
||||
"stream": true,
|
||||
"volume": 0.04
|
||||
}
|
||||
]
|
||||
},
|
||||
"ride.loop.leather.mono": {
|
||||
"sounds": [
|
||||
{
|
||||
"name": "cobblemon:ride/loop/leather_flight_loop_mono",
|
||||
"stream": true,
|
||||
"attenuation_distance": 48.0,
|
||||
"volume": 0.25
|
||||
}
|
||||
]
|
||||
},
|
||||
"ride.loop.plumage": {
|
||||
"ride.loop.leather.stereo": {
|
||||
"sounds": [
|
||||
{
|
||||
"name": "cobblemon:ride/loop/plumage_flight_loop",
|
||||
"name": "cobblemon:ride/loop/leather_flight_loop_stereo",
|
||||
"stream": true,
|
||||
"volume": 0.05
|
||||
}
|
||||
]
|
||||
},
|
||||
"ride.loop.plumage.mono": {
|
||||
"sounds": [
|
||||
{
|
||||
"name": "cobblemon:ride/loop/plumage_flight_loop_mono",
|
||||
"stream": true,
|
||||
"attenuation_distance": 48.0,
|
||||
"volume": 0.25
|
||||
}
|
||||
]
|
||||
},
|
||||
"ride.loop.saucer": {
|
||||
"ride.loop.plumage.stereo": {
|
||||
"sounds": [
|
||||
{
|
||||
"name": "cobblemon:ride/loop/saucer_flight_loop",
|
||||
"name": "cobblemon:ride/loop/plumage_flight_loop_stereo",
|
||||
"stream": true,
|
||||
"volume": 0.05
|
||||
}
|
||||
]
|
||||
},
|
||||
"ride.loop.saucer.mono": {
|
||||
"sounds": [
|
||||
{
|
||||
"name": "cobblemon:ride/loop/saucer_flight_loop_mono",
|
||||
"stream": true,
|
||||
"attenuation_distance": 48.0,
|
||||
"volume": 0.25
|
||||
}
|
||||
]
|
||||
},
|
||||
"ride.loop.rocket": {
|
||||
"ride.loop.saucer.stereo": {
|
||||
"sounds": [
|
||||
{
|
||||
"name": "cobblemon:ride/loop/rocket_flight_loop",
|
||||
"name": "cobblemon:ride/loop/saucer_flight_loop_stereo",
|
||||
"stream": true,
|
||||
"volume": 0.1
|
||||
}
|
||||
]
|
||||
},
|
||||
"ride.loop.rocket.mono": {
|
||||
"sounds": [
|
||||
{
|
||||
"name": "cobblemon:ride/loop/rocket_flight_loop_mono",
|
||||
"stream": true,
|
||||
"attenuation_distance": 48.0,
|
||||
"volume": 0.4
|
||||
}
|
||||
]
|
||||
},
|
||||
"ride.loop.water_surface": {
|
||||
"ride.loop.rocket.stereo": {
|
||||
"sounds": [
|
||||
{
|
||||
"name": "cobblemon:ride/loop/water_surface_loop",
|
||||
"name": "cobblemon:ride/loop/rocket_flight_loop_stereo",
|
||||
"stream": true,
|
||||
"volume": 0.3
|
||||
}
|
||||
]
|
||||
},
|
||||
"ride.loop.water_surface.mono": {
|
||||
"sounds": [
|
||||
{
|
||||
"name": "cobblemon:ride/loop/water_surface_loop_mono",
|
||||
"stream": true,
|
||||
"attenuation_distance": 32.0,
|
||||
"volume": 0.4
|
||||
}
|
||||
]
|
||||
},
|
||||
"ride.loop.underwater": {
|
||||
"ride.loop.water_surface.stereo": {
|
||||
"sounds": [
|
||||
{
|
||||
"name": "cobblemon:ride/loop/underwater_loop",
|
||||
"name": "cobblemon:ride/loop/water_surface_loop_stereo",
|
||||
"stream": true,
|
||||
"volume": 0.13
|
||||
}
|
||||
]
|
||||
},
|
||||
"ride.loop.underwater.mono": {
|
||||
"sounds": [
|
||||
{
|
||||
"name": "cobblemon:ride/loop/underwater_loop_mono",
|
||||
"stream": true,
|
||||
"attenuation_distance": 16.0,
|
||||
"volume": 0.4
|
||||
}
|
||||
]
|
||||
},
|
||||
"ride.loop.underwater.stereo": {
|
||||
"sounds": [
|
||||
{
|
||||
"name": "cobblemon:ride/loop/underwater_loop_stereo",
|
||||
"stream": true,
|
||||
"volume": 0.2
|
||||
}
|
||||
]
|
||||
},
|
||||
"pokemon.bulbasaur.ambient": {
|
||||
"sounds": [ "cobblemon:pokemon/bulbasaur/bulbasaur_ambient" ]
|
||||
},
|
||||
|
||||
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 599 B |
Binary file not shown.
|
After Width: | Height: | Size: 606 B |
Binary file not shown.
|
After Width: | Height: | Size: 566 B |
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"defaults": {
|
||||
"cobblemon:riding_up": {
|
||||
"axis": "controlify:axis/right_stick_up"
|
||||
},
|
||||
"cobblemon:riding_down": {
|
||||
"axis": "controlify:axis/right_stick_down"
|
||||
},
|
||||
"cobblemon:riding_left": {
|
||||
"axis": "controlify:axis/right_stick_left"
|
||||
},
|
||||
"cobblemon:riding_right": {
|
||||
"axis": "controlify:axis/right_stick_right"
|
||||
},
|
||||
"cobblemon:interact_wheel_up": {
|
||||
"axis": "controlify:axis/right_stick_up"
|
||||
},
|
||||
"cobblemon:interact_wheel_down": {
|
||||
"axis": "controlify:axis/right_stick_down"
|
||||
},
|
||||
"cobblemon:interact_wheel_left": {
|
||||
"axis": "controlify:axis/right_stick_left"
|
||||
},
|
||||
"cobblemon:interact_wheel_right": {
|
||||
"axis": "controlify:axis/right_stick_right"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,7 @@
|
||||
"conditions": {
|
||||
"items": [
|
||||
{
|
||||
"items": "#cobblemon:mint_leaf"
|
||||
"items": "#cobblemon:mint_leaves"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
t.ticks_between_checks = 20 * 10;
|
||||
math.mod(q.player.world.game_time, t.ticks_between_checks) != 0 ? {
|
||||
return 0;
|
||||
};
|
||||
|
||||
t.steps_required = 10000;
|
||||
t.friendship_required = 200;
|
||||
|
||||
t.total_blocks =
|
||||
q.player.get_custom_stat('minecraft:walk_one_cm') +
|
||||
q.player.get_custom_stat('minecraft:crouch_one_cm') +
|
||||
q.player.get_custom_stat('minecraft:sprint_one_cm') +
|
||||
q.player.get_custom_stat('minecraft:walk_on_water_one_cm') +
|
||||
q.player.get_custom_stat('minecraft:fall_one_cm') +
|
||||
q.player.get_custom_stat('minecraft:climb_one_cm') +
|
||||
q.player.get_custom_stat('minecraft:fly_one_cm') +
|
||||
q.player.get_custom_stat('minecraft:walk_under_water_one_cm') +
|
||||
q.player.get_custom_stat('minecraft:minecart_one_cm') +
|
||||
q.player.get_custom_stat('minecraft:boat_one_cm') +
|
||||
q.player.get_custom_stat('minecraft:pig_one_cm') +
|
||||
q.player.get_custom_stat('minecraft:horse_one_cm') +
|
||||
q.player.get_custom_stat('minecraft:aviate_one_cm') +
|
||||
q.player.get_custom_stat('minecraft:swim_one_cm') +
|
||||
q.player.get_custom_stat('minecraft:strider_one_cm') +
|
||||
q.player.get_custom_stat('cobblemon:riding_land') +
|
||||
q.player.get_custom_stat('cobblemon:riding_air') +
|
||||
q.player.get_custom_stat('cobblemon:riding_liquid');
|
||||
|
||||
t.total_blocks = t.total_blocks / 100.0;
|
||||
t.player_data = q.player.data();
|
||||
|
||||
math.floor(t.total_blocks / t.steps_required) > math.floor(t.player_data.last_partner_mark_check / t.steps_required) ? {
|
||||
t.party = q.player.party;
|
||||
for_each(t.pokemon, t.party.pokemon, {
|
||||
t.pokemon.friendship >= t.friendship_required ? {
|
||||
t.pokemon.add_marks_with_chance('cobblemon:mark_partner');
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
t.player_data.last_partner_mark_check = t.total_blocks;
|
||||
@@ -4,5 +4,6 @@
|
||||
"titleColor": "40B282",
|
||||
"description": "cobblemon.mark.mark_partner.desc",
|
||||
"texture": "cobblemon:textures/gui/mark/mark_partner.png",
|
||||
"indexNumber": 104
|
||||
"indexNumber": 104,
|
||||
"chance": 0.01
|
||||
}
|
||||
@@ -26,7 +26,7 @@
|
||||
},
|
||||
{
|
||||
"content": 2,
|
||||
"tag": "#cobblemon:mint_leaf"
|
||||
"tag": "#cobblemon:mint_leaves"
|
||||
},
|
||||
{
|
||||
"content": 2,
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"ingredient": "cobblemon:mental_herb",
|
||||
"colour": "light_blue",
|
||||
"mobEffects": [
|
||||
{
|
||||
"effect": "cobblemon:mental_restoration",
|
||||
"duration": 200,
|
||||
"amplifier": 0,
|
||||
"ambient": false,
|
||||
"visible": true,
|
||||
"showIcon": true
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"ingredient": "minecraft:milk_bucket",
|
||||
"colour": "white",
|
||||
"mobEffects": [
|
||||
{
|
||||
"effect": "cobblemon:cleanse_all",
|
||||
"duration": 1,
|
||||
"amplifier": 0,
|
||||
"ambient": false,
|
||||
"visible": true,
|
||||
"showIcon": true
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"ingredient": "cobblemon:moomoo_milk",
|
||||
"colour": "white",
|
||||
"mobEffects": [
|
||||
{
|
||||
"effect": "cobblemon:cleanse_all",
|
||||
"duration": 1,
|
||||
"amplifier": 0,
|
||||
"ambient": false,
|
||||
"visible": true,
|
||||
"showIcon": true
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"ingredient": "cobblemon:white_herb",
|
||||
"colour": "white",
|
||||
"mobEffects": [
|
||||
{
|
||||
"effect": "cobblemon:cleanse_negative",
|
||||
"duration": 1,
|
||||
"amplifier": 0,
|
||||
"ambient": false,
|
||||
"visible": true,
|
||||
"showIcon": true
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -57,15 +57,33 @@
|
||||
{
|
||||
"muffleEnabled": true,
|
||||
"pitchExpr": "math.max(1.0 ,0.2 + math.pow(math.min(q.ride_velocity() / 1.5, 1.0),2))",
|
||||
"playForNonPassengers": true,
|
||||
"soundLocation": "cobblemon:ride.loop.wind",
|
||||
"playForPassengers": true,
|
||||
"playForNonPassengers": false,
|
||||
"soundLocation": "cobblemon:ride.loop.wind.stereo",
|
||||
"volumeExpr": "math.pow(math.min(q.ride_velocity() / 1.5, 1.0),2)"
|
||||
},
|
||||
{
|
||||
"muffleEnabled": true,
|
||||
"pitchExpr": "math.max(1.0 ,0.2 + math.pow(math.min(q.ride_velocity() / 1.5, 1.0),2))",
|
||||
"playForPassengers": false,
|
||||
"playForNonPassengers": true,
|
||||
"soundLocation": "cobblemon:ride.loop.leather",
|
||||
"soundLocation": "cobblemon:ride.loop.wind.mono",
|
||||
"volumeExpr": "math.pow(math.min(q.ride_velocity() / 1.5, 1.0),2)"
|
||||
},
|
||||
{
|
||||
"muffleEnabled": true,
|
||||
"pitchExpr": "math.max(1.0 ,0.2 + math.pow(math.min(q.ride_velocity() / 1.5, 1.0),2))",
|
||||
"playForPassengers": true,
|
||||
"playForNonPassengers": false,
|
||||
"soundLocation": "cobblemon:ride.loop.leather.stereo",
|
||||
"volumeExpr": "math.pow(math.min(q.ride_velocity() / 1.5, 1.0),2)"
|
||||
},
|
||||
{
|
||||
"muffleEnabled": true,
|
||||
"pitchExpr": "math.max(1.0 ,0.2 + math.pow(math.min(q.ride_velocity() / 1.5, 1.0),2))",
|
||||
"playForPassengers": false,
|
||||
"playForNonPassengers": true,
|
||||
"soundLocation": "cobblemon:ride.loop.leather.mono",
|
||||
"volumeExpr": "math.pow(math.min(q.ride_velocity() / 1.5, 1.0),2)"
|
||||
}
|
||||
],
|
||||
|
||||
@@ -58,14 +58,18 @@
|
||||
{
|
||||
"muffleEnabled": true,
|
||||
"pitchExpr": "math.max(1.0 ,0.2 + math.pow(math.min(q.ride_velocity() / 1.5, 1.0),2))",
|
||||
"playForPassengers": true,
|
||||
"playForNonPassengers": true,
|
||||
"submerged": false,
|
||||
"soundLocation": "cobblemon:ride.loop.wind",
|
||||
"volumeExpr": "math.pow(math.min(q.ride_velocity() / 1.5, 1.0),2)"
|
||||
},
|
||||
{
|
||||
"muffleEnabled": true,
|
||||
"pitchExpr": "math.max(1.0 ,0.2 + math.pow(math.min(q.ride_velocity() / 1.5, 1.0),2))",
|
||||
"playForPassengers": true,
|
||||
"playForNonPassengers": true,
|
||||
"submerged": false,
|
||||
"soundLocation": "cobblemon:ride.loop.leather",
|
||||
"volumeExpr": "math.pow(math.min(q.ride_velocity() / 1.5, 1.0),2)"
|
||||
}
|
||||
@@ -93,7 +97,44 @@
|
||||
},
|
||||
"LIQUID": {
|
||||
"key": "cobblemon:liquid/dolphin",
|
||||
"rideSounds": [],
|
||||
"rideSounds": [
|
||||
{
|
||||
"muffleEnabled": true,
|
||||
"pitchExpr": "math.max(1.0 ,0.2 + math.pow(math.min(q.ride_velocity() / 1.5, 1.0),2))",
|
||||
"playForPassengers": true,
|
||||
"playForNonPassengers": false,
|
||||
"submerged": false,
|
||||
"soundLocation": "cobblemon:ride.loop.water_surface.stereo",
|
||||
"volumeExpr": "math.pow(math.min(q.ride_velocity() / 1.5, 1.0),2)"
|
||||
},
|
||||
{
|
||||
"muffleEnabled": true,
|
||||
"pitchExpr": "math.max(1.0 ,0.2 + math.pow(math.min(q.ride_velocity() / 1.5, 1.0),2))",
|
||||
"playForPassengers": false,
|
||||
"playForNonPassengers": true,
|
||||
"submerged": false,
|
||||
"soundLocation": "cobblemon:ride.loop.water_surface.mono",
|
||||
"volumeExpr": "math.pow(math.min(q.ride_velocity() / 1.5, 1.0),2)"
|
||||
},
|
||||
{
|
||||
"muffleEnabled": true,
|
||||
"pitchExpr": "math.max(1.0 ,0.2 + math.pow(math.min(q.ride_velocity() / 1.5, 1.0),2))",
|
||||
"playForPassengers": true,
|
||||
"playForNonPassengers": false,
|
||||
"submerged": true,
|
||||
"soundLocation": "cobblemon:ride.loop.underwater.stereo",
|
||||
"volumeExpr": "math.pow(math.min(q.ride_velocity() / 1.5, 1.0),2)"
|
||||
},
|
||||
{
|
||||
"muffleEnabled": true,
|
||||
"pitchExpr": "math.max(1.0 ,0.2 + math.pow(math.min(q.ride_velocity() / 1.5, 1.0),2))",
|
||||
"playForPassengers": false,
|
||||
"playForNonPassengers": true,
|
||||
"submerged": true,
|
||||
"soundLocation": "cobblemon:ride.loop.underwater.mono",
|
||||
"volumeExpr": "math.pow(math.min(q.ride_velocity() / 1.5, 1.0),2)"
|
||||
}
|
||||
],
|
||||
"stats": {
|
||||
"ACCELERATION": "30-65",
|
||||
"JUMP": "55-85",
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"values": [
|
||||
"cobblemon:apricorn_boat",
|
||||
"cobblemon:apricorn_chest_boat"
|
||||
"cobblemon:saccharine_boat",
|
||||
"#cobblemon:chest_boats"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"values": [
|
||||
"cobblemon:apricorn_chest_boat",
|
||||
"cobblemon:saccharine_chest_boat"
|
||||
]
|
||||
}
|
||||
@@ -11,6 +11,7 @@
|
||||
"cobblemon:black_glasses",
|
||||
"cobblemon:black_sludge",
|
||||
"cobblemon:blunder_policy",
|
||||
"cobblemon:bright_powder",
|
||||
"cobblemon:cell_battery",
|
||||
"cobblemon:charcoal_stick",
|
||||
"cobblemon:choice_band",
|
||||
@@ -19,6 +20,7 @@
|
||||
"cobblemon:cleanse_tag",
|
||||
"cobblemon:clear_amulet",
|
||||
"cobblemon:covert_cloak",
|
||||
"cobblemon:damp_rock",
|
||||
"cobblemon:destiny_knot",
|
||||
"cobblemon:deep_sea_scale",
|
||||
"cobblemon:deep_sea_tooth",
|
||||
@@ -36,7 +38,9 @@
|
||||
"cobblemon:focus_sash",
|
||||
"cobblemon:grip_claw",
|
||||
"cobblemon:hard_stone",
|
||||
"cobblemon:heat_rock",
|
||||
"cobblemon:heavy_duty_boots",
|
||||
"cobblemon:icy_rock",
|
||||
"cobblemon:iron_ball",
|
||||
"cobblemon:kings_rock",
|
||||
"cobblemon:lagging_tail",
|
||||
@@ -48,9 +52,13 @@
|
||||
"cobblemon:lucky_egg",
|
||||
"cobblemon:luminous_moss",
|
||||
"cobblemon:magnet",
|
||||
"cobblemon:medicinal_leek",
|
||||
"cobblemon:mental_herb",
|
||||
"cobblemon:metal_powder",
|
||||
"cobblemon:metal_coat",
|
||||
"cobblemon:metronome",
|
||||
"cobblemon:miracle_seed",
|
||||
"cobblemon:mirror_herb",
|
||||
"cobblemon:muscle_band",
|
||||
"cobblemon:mystic_water",
|
||||
"cobblemon:never_melt_ice",
|
||||
@@ -59,11 +67,13 @@
|
||||
"cobblemon:power_band",
|
||||
"cobblemon:power_belt",
|
||||
"cobblemon:power_bracer",
|
||||
"cobblemon:power_herb",
|
||||
"cobblemon:power_lens",
|
||||
"cobblemon:power_weight",
|
||||
"cobblemon:protective_pads",
|
||||
"cobblemon:punching_glove",
|
||||
"cobblemon:quick_claw",
|
||||
"cobblemon:quick_powder",
|
||||
"cobblemon:razor_claw",
|
||||
"cobblemon:razor_fang",
|
||||
"cobblemon:red_card",
|
||||
@@ -78,7 +88,9 @@
|
||||
"cobblemon:silk_scarf",
|
||||
"cobblemon:silver_powder",
|
||||
"cobblemon:smoke_ball",
|
||||
"cobblemon:smooth_rock",
|
||||
"cobblemon:soft_sand",
|
||||
"cobblemon:soothe_bell",
|
||||
"cobblemon:spell_tag",
|
||||
"cobblemon:sticky_barb",
|
||||
"cobblemon:terrain_extender",
|
||||
@@ -87,41 +99,13 @@
|
||||
"cobblemon:twisted_spoon",
|
||||
"cobblemon:utility_umbrella",
|
||||
"cobblemon:weakness_policy",
|
||||
"cobblemon:white_herb",
|
||||
"cobblemon:wide_lens",
|
||||
"cobblemon:wise_glasses",
|
||||
"cobblemon:zoom_lens",
|
||||
"cobblemon:bright_powder",
|
||||
"cobblemon:metal_powder",
|
||||
"cobblemon:quick_powder",
|
||||
"cobblemon:mental_herb",
|
||||
"cobblemon:mirror_herb",
|
||||
"cobblemon:power_herb",
|
||||
"cobblemon:white_herb",
|
||||
"cobblemon:damp_rock",
|
||||
"cobblemon:heat_rock",
|
||||
"cobblemon:smooth_rock",
|
||||
"cobblemon:icy_rock",
|
||||
"cobblemon:life_orb",
|
||||
"cobblemon:toxic_orb",
|
||||
"cobblemon:flame_orb",
|
||||
"cobblemon:white_herb",
|
||||
"cobblemon:smoke_ball",
|
||||
"cobblemon:lucky_egg",
|
||||
"cobblemon:kings_rock",
|
||||
"cobblemon:deep_sea_scale",
|
||||
"cobblemon:deep_sea_tooth",
|
||||
"cobblemon:metal_coat",
|
||||
"cobblemon:medicinal_leek",
|
||||
"minecraft:bone",
|
||||
"minecraft:snowball",
|
||||
"#cobblemon:type_gems",
|
||||
|
||||
"#cobblemon:held/terrain_seeds",
|
||||
"cobblemon:scope_lens",
|
||||
"cobblemon:terrain_extender",
|
||||
"cobblemon:throat_spray",
|
||||
"cobblemon:utility_umbrella",
|
||||
"cobblemon:wide_lens",
|
||||
"cobblemon:zoom_lens"
|
||||
"#cobblemon:held/terrain_seeds"
|
||||
]
|
||||
}
|
||||
+5
-3
@@ -7,6 +7,8 @@
|
||||
"minecraft:dead_bush",
|
||||
"minecraft:honey_bottle",
|
||||
"minecraft:pink_petals",
|
||||
"minecraft:spore_blossom",
|
||||
"minecraft:chorus_flower",
|
||||
"minecraft:poisonous_potato",
|
||||
"minecraft:rotten_flesh",
|
||||
"minecraft:spore_blossom",
|
||||
@@ -15,9 +17,9 @@
|
||||
"cobblemon:big_root",
|
||||
"cobblemon:energy_root",
|
||||
"cobblemon:galarica_nuts",
|
||||
"cobblemon:mirror_herb",
|
||||
"#cobblemon:herbs",
|
||||
"cobblemon:pep_up_flower",
|
||||
"cobblemon:power_herb",
|
||||
"cobblemon:revival_herb"
|
||||
"minecraft:milk_bucket",
|
||||
"cobblemon:moomoo_milk"
|
||||
]
|
||||
}
|
||||
+3
-3
@@ -13,9 +13,9 @@
|
||||
"cobblemon:big_root",
|
||||
"cobblemon:energy_root",
|
||||
"cobblemon:galarica_nuts",
|
||||
"cobblemon:mirror_herb",
|
||||
"#cobblemon:herbs",
|
||||
"cobblemon:pep_up_flower",
|
||||
"cobblemon:power_herb",
|
||||
"cobblemon:revival_herb"
|
||||
"minecraft:milk_bucket",
|
||||
"cobblemon:moomoo_milk"
|
||||
]
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"replace": false,
|
||||
"values": [
|
||||
"cobblemon:apricorn_chest_boat"
|
||||
"#cobblemon:chest_boats"
|
||||
]
|
||||
}
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"parent": "adorn:block/templates/bench_leg",
|
||||
"textures": {
|
||||
"log": "cobblemon:block/apricorn_log",
|
||||
"end": "cobblemon:block/apricorn_log_top"
|
||||
"log": "cobblemon:block/wood/apricorn_log",
|
||||
"end": "cobblemon:block/wood/apricorn_log_top"
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"parent": "adorn:block/templates/bench_top",
|
||||
"textures": {
|
||||
"planks": "cobblemon:block/apricorn_planks"
|
||||
"planks": "cobblemon:block/wood/apricorn_planks"
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"parent": "adorn:block/templates/chair_lower",
|
||||
"textures": {
|
||||
"planks": "cobblemon:block/apricorn_planks"
|
||||
"planks": "cobblemon:block/wood/apricorn_planks"
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"parent": "adorn:block/templates/chair_upper",
|
||||
"textures": {
|
||||
"planks": "cobblemon:block/apricorn_planks"
|
||||
"planks": "cobblemon:block/wood/apricorn_planks"
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"parent": "adorn:block/templates/coffee_table",
|
||||
"textures": {
|
||||
"planks": "cobblemon:block/apricorn_planks",
|
||||
"leg": "cobblemon:block/apricorn_log",
|
||||
"rim": "cobblemon:block/apricorn_log"
|
||||
"planks": "cobblemon:block/wood/apricorn_planks",
|
||||
"leg": "cobblemon:block/wood/apricorn_log",
|
||||
"rim": "cobblemon:block/wood/apricorn_log"
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"parent": "adorn:block/templates/drawer",
|
||||
"textures": {
|
||||
"planks": "cobblemon:block/apricorn_planks"
|
||||
"planks": "cobblemon:block/wood/apricorn_planks"
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"parent": "adorn:block/templates/kitchen_counter",
|
||||
"textures": {
|
||||
"planks": "cobblemon:block/apricorn_planks"
|
||||
"planks": "cobblemon:block/wood/apricorn_planks"
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"parent": "adorn:block/templates/kitchen_counter_connection_left",
|
||||
"textures": {
|
||||
"planks": "cobblemon:block/apricorn_planks"
|
||||
"planks": "cobblemon:block/wood/apricorn_planks"
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"parent": "adorn:block/templates/kitchen_counter_connection_right",
|
||||
"textures": {
|
||||
"planks": "cobblemon:block/apricorn_planks"
|
||||
"planks": "cobblemon:block/wood/apricorn_planks"
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"parent": "adorn:block/templates/kitchen_cupboard_door",
|
||||
"textures": {
|
||||
"planks": "cobblemon:block/apricorn_planks"
|
||||
"planks": "cobblemon:block/wood/apricorn_planks"
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"parent": "adorn:block/templates/kitchen_sink",
|
||||
"textures": {
|
||||
"planks": "cobblemon:block/apricorn_planks"
|
||||
"planks": "cobblemon:block/wood/apricorn_planks"
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"parent": "adorn:block/templates/platform",
|
||||
"textures": {
|
||||
"texture": "cobblemon:block/apricorn_planks"
|
||||
"texture": "cobblemon:block/wood/apricorn_planks"
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"parent": "adorn:block/templates/post",
|
||||
"textures": {
|
||||
"texture": "cobblemon:block/apricorn_planks"
|
||||
"texture": "cobblemon:block/wood/apricorn_planks"
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"parent": "adorn:block/templates/shelf",
|
||||
"textures": {
|
||||
"texture": "cobblemon:block/apricorn_planks"
|
||||
"texture": "cobblemon:block/wood/apricorn_planks"
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"parent": "adorn:block/templates/step",
|
||||
"textures": {
|
||||
"texture": "cobblemon:block/apricorn_planks"
|
||||
"texture": "cobblemon:block/wood/apricorn_planks"
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user