Compare commits
125
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
488f38c690 | ||
|
|
d1b7dc6934 | ||
|
|
282bb4784e | ||
|
|
a8267b8ee0 | ||
|
|
81f36b2b15 | ||
|
|
73e96740d6 | ||
|
|
d53f9e5c63 | ||
|
|
560bd75fd0 | ||
|
|
8850d38820 | ||
|
|
34232b33c7 | ||
|
|
03c5a34fc8 | ||
|
|
866db3d350 | ||
|
|
ee51a8a34b | ||
|
|
2769733c51 | ||
|
|
8ae79d8e44 | ||
|
|
6f08d610eb | ||
|
|
75f3db16aa | ||
|
|
e4ee6b29ab | ||
|
|
cb6b2b9ec5 | ||
|
|
8eafe14f66 | ||
|
|
8176e14981 | ||
|
|
7d956500f2 | ||
|
|
c6853b84a6 | ||
|
|
3cb4984d51 | ||
|
|
930ed59234 | ||
|
|
3ea1918bc2 | ||
|
|
1dee9bc630 | ||
|
|
d761f2b4dc | ||
|
|
0d6028706d | ||
|
|
63d6851482 | ||
|
|
7c3158c63b | ||
|
|
e9e41933fe | ||
|
|
7c7fd6c982 | ||
|
|
6ec2820dd8 | ||
|
|
b1054bdf11 | ||
|
|
3b227ba3a2 | ||
|
|
96049abb98 | ||
|
|
d661e88a96 | ||
|
|
8510e05177 | ||
|
|
af4fe4d09d | ||
|
|
8b2ffd0f29 | ||
|
|
18cebc794b | ||
|
|
64e84dab64 | ||
|
|
9c5535a014 | ||
|
|
5993c1e588 | ||
|
|
e8f7983dd2 | ||
|
|
bdd172bd2d | ||
|
|
13842de7d6 | ||
|
|
f05e059445 | ||
|
|
038d9e858c | ||
|
|
9913826e24 | ||
|
|
8f971cc3d6 | ||
|
|
33c74372a4 | ||
|
|
5f11f4bdd6 | ||
|
|
13b4bdc204 | ||
|
|
451ae00da1 | ||
|
|
a8cc8278d3 | ||
|
|
58c0136ad1 | ||
|
|
45238058cb | ||
|
|
a326befcef | ||
|
|
52d8887514 | ||
|
|
02ae8065ac | ||
|
|
c37c608010 | ||
|
|
09c4ae96bf | ||
|
|
367264b06e | ||
|
|
3631fa909d | ||
|
|
fc29826bc7 | ||
|
|
8fb93dd488 | ||
|
|
b863554c84 | ||
|
|
699d6fea17 | ||
|
|
2cd066a4c1 | ||
|
|
68b44db35c | ||
|
|
18d3fb288a | ||
|
|
725b4b7e48 | ||
|
|
28ae27b926 | ||
|
|
21e9e73eee | ||
|
|
6bfb318e2d | ||
|
|
b7550f7699 | ||
|
|
9770d8ca6b | ||
|
|
04c3e182e7 | ||
|
|
bbcfe95bac | ||
|
|
82088651c2 | ||
|
|
e3ead8e3e5 | ||
|
|
9c4b9b35ab | ||
|
|
ae6091fc01 | ||
|
|
b905888a0b | ||
|
|
5917e52ffc | ||
|
|
deb20cb418 | ||
|
|
929e4b2391 | ||
|
|
c593a8b7e6 | ||
|
|
d0fc166e09 | ||
|
|
78f752b4a1 | ||
|
|
b4c971398d | ||
|
|
f0f78a01e0 | ||
|
|
8c36ee15cd | ||
|
|
3231d97cd3 | ||
|
|
9fce4d3b6b | ||
|
|
0f031545c1 | ||
|
|
2b80189a79 | ||
|
|
2e88b0194e | ||
|
|
b0e278d1a7 | ||
|
|
9c646d9d53 | ||
|
|
dd19140a83 | ||
|
|
be96e45c4e | ||
|
|
42eb08e715 | ||
|
|
03470aa623 | ||
|
|
d09d636113 | ||
|
|
ff335f779f | ||
|
|
b70316e347 | ||
|
|
a352e67c1b | ||
|
|
71297dfb3a | ||
|
|
9141694c2a | ||
|
|
1f8fa8cae3 | ||
|
|
42e405530c | ||
|
|
c76dfc3130 | ||
|
|
cca9de04a7 | ||
|
|
78d47004bf | ||
|
|
30f97e6243 | ||
|
|
d117d79d28 | ||
|
|
3d4d797e7f | ||
|
|
39feb9cf6c | ||
|
|
8f53757879 | ||
|
|
e1d2f125d6 | ||
|
|
fa3ed69ee2 | ||
|
|
8c02ca3576 |
No files matched your search
+18
-1
@@ -38,7 +38,7 @@
|
||||
- Lightning is now affected by a Pokemon's ability/typing
|
||||
- Pokémon with the ability Lightning Rod draw in lightning similar to a lightning rod block albeit with a lower priority and range, gain immunity to lightning damage, and receive a temporary damage buff.
|
||||
- Pokémon with the ability Motor Drive are immune to lightning damage and receive a temporary speed buff when struck by lightning
|
||||
- Pokémon with the ability Volt Absorb are immune to lightning damage and receive Regeneration II for a short duration
|
||||
- Pokémon with the ability Volt Absorb are immune to lightning damage and receive Instant Health II for a short duration
|
||||
- Ground type Pokémon are immune to lightning damage
|
||||
- Added functionality to Everstone when held by a Pokémon; suppresses evolution notification and hides evolve button in summary interface.
|
||||
- Added optional `filePath` parameter to MoLang functions to allow for global stores (ex. `../global/`). Path must end in a forward slash.
|
||||
@@ -58,6 +58,9 @@
|
||||
- Mooshtanks will switch between their red and brown variant when hit by lightning
|
||||
- Smeargle spawns with differing tail colour depending on its [Characteristic](https://bulbapedia.bulbagarden.net/wiki/Characteristic) stat
|
||||
- Added smooth level-up animations to the party overlay to replace chat messages.
|
||||
- Added `min_perfect_ivs` property to PokemonProperties to specify the minimum number of perfect IVs of the Pokemon.
|
||||
- Added `defaultKeyItems` config option to specify which key items players always have.
|
||||
- Added `scale_modifier` property to PokemonProperties to modify the scale of the Pokemon.
|
||||
|
||||
### Pokémon Added
|
||||
|
||||
@@ -518,6 +521,8 @@
|
||||
- Refactored dynamic lights compat to be more future proof. The dynamic light support is only tested with LambDynamicLights, on NeoForged use that mod in combination with Sinytra Connector
|
||||
- Shulker Boxes and Traveler's Backpacks AND Packed Up backpacks can no longer be held by Pokémon. Thanks Monocle ;) You could re-enable this with our datapack (but you'd be crazy).
|
||||
- Moomoo Milk now clears Pokémon stat changes when used in battle.
|
||||
- Updated Evolution Stone Block light levels
|
||||
- Added light levels to Evolution Stone Ores. These levels are reduced versions of the full blocks light levels
|
||||
|
||||
### Fixes
|
||||
- Fixed game crashing when removing national pokedex using datapacks
|
||||
@@ -606,6 +611,7 @@
|
||||
- The Corphish line will now sink in water.
|
||||
- Fixed the "use all berry bait" achievement not being progressed
|
||||
- Fixed bobber hook and berry sprouts texture sizes causing mipmap issues.
|
||||
- Fixed head locator not taking into account scale for positioning.
|
||||
|
||||
### Developer
|
||||
- A finished battle now has winners and losers set inside of `PokemonBattle` instead of them always being empty.
|
||||
@@ -662,6 +668,15 @@
|
||||
}
|
||||
```
|
||||
This will change the value of `mooshtank` from `red` to `brown` and vice versa when a lightning strikes this Pokémon. Only chains of which a value is the current value will be considered, so multiple entries for the same key with different chains can be added.
|
||||
- Removed Npc interface from NPCEntity, the interface is unused and in vanilla is only implemented by VillagerEntity as a means to disable villagers with the `spawn-npcs` server property.
|
||||
- Added new `Observable#subscribe` methods that take Java Consumers to make usage in Java a little cleaner.
|
||||
- Annotated a bunch of Kotlin methods and fields for cleaner Java names.
|
||||
- Added `PartyStore#isEmpty()`.
|
||||
- Added `ElementalTypes#getRandomType()`.
|
||||
- Added `IVs#getEffectiveBattleTotal()`.
|
||||
- Added `IVs.MAX_TOTAL` constant.
|
||||
- Added `PokemonStats#total()`.
|
||||
- Add `NatureAdapter` for serializing and deserializing Natures using Gson.
|
||||
|
||||
### MoLang & Datapacks
|
||||
- The following usages for item predicates can now use item conditions like advancements do, you can learn about them in the [Minecraft wiki](https://minecraft.wiki/w/Advancement_definition#minecraft:filled_bucket)
|
||||
@@ -769,6 +784,8 @@
|
||||
- Also changed the default from `cobblemon:empty_bait` to `any`
|
||||
- The previous default is still available by using the above as baitId
|
||||
- Added support for species-specific move action effects, using the format `{move_id}_{species}.json`.
|
||||
- Added `look_at_entity_types` variable for look_at_entities to specify what entity type or entity tag to look at.
|
||||
- Added `Looks At Players` behaviour preset that only sets the look target to players.
|
||||
|
||||
### Particles
|
||||
Added new/updated particles for the following moves:
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* 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.duck;
|
||||
|
||||
import com.mongodb.lang.Nullable;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import org.joml.Quaternionf;
|
||||
import org.joml.Vector3f;
|
||||
|
||||
public interface CameraDuck {
|
||||
BlockGetter cobblemon$getLevel();
|
||||
|
||||
@Nullable
|
||||
Entity cobblemon$getEntity();
|
||||
|
||||
Quaternionf cobblemon$getRotation();
|
||||
|
||||
Vector3f cobblemon$getForwards();
|
||||
|
||||
Vector3f cobblemon$getUp();
|
||||
|
||||
Vector3f cobblemon$getLeft();
|
||||
|
||||
float cobblemon$getXRot();
|
||||
void cobblemon$setXRot(float xRot);
|
||||
|
||||
float cobblemon$getYRot();
|
||||
void cobblemon$setYRot(float yRot);
|
||||
}
|
||||
@@ -52,7 +52,7 @@ public abstract class BeeOccupantMixin {
|
||||
var facing = state.getValue(HorizontalDirectionalBlock.FACING);
|
||||
newPos = pos.relative(facing).getCenter();
|
||||
newYaw = facing.toYRot();
|
||||
brain.setMemory(CobblemonMemories.INSTANCE.getHIVE_LOCATION(), pos); // This needs to be set in the case that the hive was picked up and moved.
|
||||
brain.setMemory(CobblemonMemories.HIVE_LOCATION, pos); // This needs to be set in the case that the hive was picked up and moved.
|
||||
} else {
|
||||
// Block has likely been destroyed
|
||||
var center = pos.getCenter();
|
||||
@@ -62,16 +62,16 @@ public abstract class BeeOccupantMixin {
|
||||
center.z + level.random.nextFloat() * 0.6 - 0.3
|
||||
);
|
||||
newYaw = level.random.nextFloat() * 360F;
|
||||
brain.eraseMemory(CobblemonMemories.INSTANCE.getHIVE_LOCATION());
|
||||
brain.eraseMemory(CobblemonMemories.HIVE_LOCATION);
|
||||
}
|
||||
entity.yRotO = newYaw;
|
||||
entity.setPos(newPos);
|
||||
// Do honey logic
|
||||
var hasNectar = brain.getMemory(CobblemonMemories.INSTANCE.getHAS_NECTAR()).orElse(false);
|
||||
var hasNectar = brain.getMemory(CobblemonMemories.HAS_NECTAR).orElse(false);
|
||||
if (hasNectar) {
|
||||
// Remove nectar and reset got to hive cooldown
|
||||
brain.eraseMemory(CobblemonMemories.INSTANCE.getHAS_NECTAR());
|
||||
brain.setMemoryWithExpiry(CobblemonMemories.INSTANCE.getHIVE_COOLDOWN(), true, PathToBeeHiveTaskConfig.STAY_OUT_OF_HIVE_COOLDOWN);
|
||||
brain.eraseMemory(CobblemonMemories.HAS_NECTAR);
|
||||
brain.setMemoryWithExpiry(CobblemonMemories.HIVE_COOLDOWN, true, PathToBeeHiveTaskConfig.STAY_OUT_OF_HIVE_COOLDOWN);
|
||||
// Increment honey level of the hive
|
||||
if (state.is(BlockTags.BEEHIVES, (blockStateBase) -> blockStateBase.hasProperty(BeehiveBlock.HONEY_LEVEL))) {
|
||||
int i = state.getValue(BeehiveBlock.HONEY_LEVEL);
|
||||
@@ -97,11 +97,10 @@ public abstract class BeeOccupantMixin {
|
||||
entity.save(compoundTag);
|
||||
Objects.requireNonNull(compoundTag);
|
||||
IGNORED_BEE_TAGS.forEach(compoundTag::remove);
|
||||
Boolean hasNectar = pokemonEntity.getBrain().getMemory(CobblemonMemories.INSTANCE.getHAS_NECTAR()).orElse(false);
|
||||
Boolean hasNectar = pokemonEntity.getBrain().getMemory(CobblemonMemories.HAS_NECTAR).orElse(false);
|
||||
cir.setReturnValue(new BeehiveBlockEntity.Occupant(CustomData.of(compoundTag), 0, hasNectar ? 2400 : 600));
|
||||
cir.cancel();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -38,6 +38,7 @@ import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.entity.EntityDimensions;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
@@ -317,7 +318,7 @@ public abstract class PlayerMixin extends LivingEntity implements ScannableEntit
|
||||
|
||||
@Override
|
||||
public void cobblemon$setRideXRot(float rideXRot) {
|
||||
this.cobblemon$rideXRot = rideXRot;
|
||||
this.cobblemon$rideXRot = Mth.wrapDegrees(rideXRot);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -327,7 +328,7 @@ public abstract class PlayerMixin extends LivingEntity implements ScannableEntit
|
||||
|
||||
@Override
|
||||
public void cobblemon$setRideYRot(float rideYRot) {
|
||||
this.cobblemon$rideYRot = rideYRot;
|
||||
this.cobblemon$rideYRot = Mth.wrapDegrees(rideYRot);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -15,8 +15,10 @@ import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
@Mixin(RecipeBookSettings.class)
|
||||
@@ -30,4 +32,14 @@ public class RecipeBookSettingsMixin {
|
||||
states.put(RecipeBookType.valueOf("COOKING_POT"), new RecipeBookSettings.TypeSettings(true, true));
|
||||
}
|
||||
|
||||
@Redirect( method = "read(Lnet/minecraft/network/FriendlyByteBuf;)Lnet/minecraft/stats/RecipeBookSettings;", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/inventory/RecipeBookType;values()[Lnet/minecraft/world/inventory/RecipeBookType;"))
|
||||
private static RecipeBookType[] cobblemon$valuesReadRedirect() {
|
||||
return Arrays.stream(RecipeBookType.values()).filter( recipeBookType -> !RecipeBookType.valueOf("COOKING_POT").equals(recipeBookType) ).toArray(RecipeBookType[]::new);
|
||||
}
|
||||
|
||||
@Redirect( method = "write(Lnet/minecraft/network/FriendlyByteBuf;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/inventory/RecipeBookType;values()[Lnet/minecraft/world/inventory/RecipeBookType;"))
|
||||
private RecipeBookType[] cobblemon$valuesWriteRedirect() {
|
||||
return Arrays.stream(RecipeBookType.values()).filter( recipeBookType -> !RecipeBookType.valueOf("COOKING_POT").equals(recipeBookType) ).toArray(RecipeBookType[]::new);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -55,86 +55,6 @@ public abstract class SoundEngineMixin implements SoundEngineDuck {
|
||||
@Shadow
|
||||
public abstract boolean isActive(SoundInstance sound);
|
||||
|
||||
@Inject(method = "play",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/client/sounds/ChannelAccess$ChannelHandle;execute(Ljava/util/function/Consumer;)V"
|
||||
),
|
||||
cancellable = true
|
||||
)
|
||||
private void cobblemon$overrideChannelExecute(
|
||||
SoundInstance sound,
|
||||
CallbackInfo ci,
|
||||
@Local(name = "h") float h,
|
||||
@Local(name = "i") float i,
|
||||
@Local(name = "g") float g,
|
||||
@Local(name = "bl2") boolean bl2,
|
||||
@Local(name = "bl3") boolean bl3,
|
||||
@Local(name = "bl") boolean bl,
|
||||
@Local(name = "vec3") Vec3 vec3,
|
||||
@Local(name = "channelHandle") ChannelAccess.ChannelHandle handle
|
||||
) {
|
||||
if (!(sound instanceof RideLoopSound rideSound)) return;
|
||||
|
||||
if (handle == null) return;
|
||||
|
||||
handle.execute((channel) -> {
|
||||
channel.setPitch(i);
|
||||
channel.setVolume(h);
|
||||
|
||||
if (rideSound.getRideAttenuation() == RideAttenuationModel.LINEAR) {
|
||||
channel.linearAttenuation(g);
|
||||
} else if (rideSound.getRideAttenuation() == RideAttenuationModel.EXPONENTIAL){
|
||||
((ChannelDuck) channel).cobblemon$inverseAttenuation(g);
|
||||
} else {
|
||||
channel.disableAttenuation();
|
||||
}
|
||||
|
||||
// Apply low pass filter if the rideSound dictate that it should be muffled
|
||||
if (rideSound.getShouldMuffle()) {
|
||||
((ChannelDuck) channel).cobblemon$applyLowPassFilter(1.0f, rideSound.getMuffleAmount());
|
||||
} else {
|
||||
((ChannelDuck) channel).cobblemon$clearFilters();
|
||||
}
|
||||
|
||||
channel.setLooping(bl2 && !bl3);
|
||||
channel.setSelfPosition(vec3);
|
||||
channel.setRelative(bl);
|
||||
});
|
||||
}
|
||||
|
||||
@Inject(
|
||||
method = "tickNonPaused",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/client/sounds/ChannelAccess$ChannelHandle;execute(Ljava/util/function/Consumer;)V",
|
||||
ordinal = 0
|
||||
)
|
||||
)
|
||||
private void cobblemon$tickableSoundTick(
|
||||
CallbackInfo ci,
|
||||
@Local(name = "tickableSoundInstance") TickableSoundInstance instance,
|
||||
@Local(name = "channelHandle", ordinal = 0) ChannelAccess.ChannelHandle handle,
|
||||
@Local(name = "f", ordinal = 0) float volume,
|
||||
@Local(name = "g", ordinal = 0) float pitch,
|
||||
@Local(name = "vec3", ordinal = 0) Vec3 vec3
|
||||
) {
|
||||
if (!(instance instanceof RideLoopSound rideSound)) return;
|
||||
|
||||
handle.execute(channel -> {
|
||||
channel.setVolume(volume);
|
||||
channel.setPitch(pitch);
|
||||
channel.setSelfPosition(vec3);
|
||||
|
||||
// Apply low pass filter if the rideSound dictate that it should be muffled
|
||||
if (rideSound.getShouldMuffle()) {
|
||||
((ChannelDuck) channel).cobblemon$applyLowPassFilter(1.0f, rideSound.getMuffleAmount());
|
||||
} else {
|
||||
((ChannelDuck) channel).cobblemon$clearFilters();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/** Resumes the Source belonging to the queried SoundInstance. */
|
||||
private void resume(SoundInstance sound) {
|
||||
ChannelAccess.ChannelHandle sourceManager = this.instanceToChannel.get(sound);
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Cobblemon Contributors
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package com.cobblemon.mod.common.mixin.accessor;
|
||||
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
@Mixin(Camera.class)
|
||||
public interface CameraAccessor {
|
||||
@Accessor("level")
|
||||
BlockGetter getLevel();
|
||||
}
|
||||
@@ -27,7 +27,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(BrewingStandMenu.class)
|
||||
public abstract class BrewingStandMenuMixin {
|
||||
|
||||
@Inject(method = "<init>(ILnet/minecraft/world/entity/player/Inventory;Lnet/minecraft/world/Container;Lnet/minecraft/world/inventory/ContainerData;)V", at = @At("TAIL"))
|
||||
private void captureLevel(int containerId, Inventory playerInventory, Container brewingStandContainer, ContainerData brewingStandData, CallbackInfo ci) {
|
||||
var recipeManager = playerInventory.player.level().getRecipeManager();
|
||||
@@ -37,9 +36,4 @@ public abstract class BrewingStandMenuMixin {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@WrapOperation(method = "quickMoveStack", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/inventory/BrewingStandMenu$PotionSlot;mayPlaceItem(Lnet/minecraft/world/item/ItemStack;)Z"))
|
||||
private boolean cobblemon$isPotionBottle(ItemStack stack, Operation<Boolean> original, @Local(argsOnly = true) Player player) {
|
||||
return BrewingStandRecipe.Companion.isBottle(stack, player.level().getRecipeManager()) || original.call(stack);
|
||||
}
|
||||
}
|
||||
@@ -8,97 +8,61 @@
|
||||
|
||||
package com.cobblemon.mod.common.mixin.client;
|
||||
|
||||
import com.cobblemon.mod.common.Cobblemon;
|
||||
import com.cobblemon.mod.common.OrientationControllable;
|
||||
import com.cobblemon.mod.common.api.orientation.OrientationController;
|
||||
import com.cobblemon.mod.common.api.riding.Rideable;
|
||||
import com.cobblemon.mod.common.client.MountedPokemonAnimationRenderController;
|
||||
import com.cobblemon.mod.common.client.render.camera.MountedCameraRenderer;
|
||||
import com.cobblemon.mod.common.duck.RidePassenger;
|
||||
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity;
|
||||
import com.cobblemon.mod.common.duck.CameraDuck;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import com.mojang.blaze3d.Blaze3D;
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.joml.Matrix3f;
|
||||
import org.joml.Quaternionf;
|
||||
import org.joml.Vector3f;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(Camera.class)
|
||||
public abstract class CameraMixin {
|
||||
@Shadow private Entity entity;
|
||||
@Shadow @Final private Quaternionf rotation;
|
||||
@Shadow @Final private Vector3f forwards;
|
||||
@Shadow @Final private Vector3f up;
|
||||
@Shadow @Final private Vector3f left;
|
||||
@Shadow private float xRot;
|
||||
@Shadow private float yRot;
|
||||
|
||||
public abstract class CameraMixin implements CameraDuck {
|
||||
@Shadow private float eyeHeight;
|
||||
@Shadow private float eyeHeightOld;
|
||||
@Shadow private BlockGetter level;
|
||||
@Shadow private Entity entity;
|
||||
@Final @Shadow private Quaternionf rotation;
|
||||
@Final @Shadow private Vector3f forwards;
|
||||
@Final @Shadow private Vector3f up;
|
||||
@Final @Shadow private Vector3f left;
|
||||
@Shadow private float yRot;
|
||||
@Shadow private float xRot;
|
||||
|
||||
@Shadow protected abstract void setPosition(Vec3 pos);
|
||||
|
||||
@Shadow private float partialTickTime;
|
||||
|
||||
// Used to help in camera rotation rendering when transitioning
|
||||
// from rolled to unrolled.
|
||||
@Unique private float cobblemon$returnTimer = 0;
|
||||
@Unique private float cobblemon$rollAngleStart = 0;
|
||||
|
||||
@Unique private double cobblemon$lastHandledRotationTime = Double.MIN_VALUE;
|
||||
@Unique private double cobblemon$frameTime = 0.0;
|
||||
|
||||
// Used to as the render rotation for the motion sick camera.
|
||||
@Unique @Nullable private Quaternionf cobblemon$smoothRotation = null;
|
||||
|
||||
|
||||
@Inject(method = "setRotation", at = @At("HEAD"), cancellable = true)
|
||||
public void cobblemon$setRotation(float f, float g, CallbackInfo ci) {
|
||||
// Calculate the current frametime
|
||||
double d = Blaze3D.getTime();
|
||||
this.cobblemon$frameTime = (this.cobblemon$lastHandledRotationTime != Double.MIN_VALUE) ? d - this.cobblemon$lastHandledRotationTime : 0.0;
|
||||
this.cobblemon$lastHandledRotationTime = d;
|
||||
|
||||
// Do no camera rotations if the game is paused
|
||||
if(Minecraft.getInstance().isPaused()) return;
|
||||
|
||||
// Don't assume the camera to be attached to an entity. Ponder Scenes from create et.al. for example aren't.
|
||||
if (this.entity == null) return;
|
||||
var vehicle = this.entity.getVehicle();
|
||||
if (!(vehicle instanceof OrientationControllable controllableVehicle)) return;
|
||||
var instance = (Camera)(Object)this;
|
||||
|
||||
// If the current vehicle has no orientation then return and perform
|
||||
// vanilla camera rotations
|
||||
var vehicleController = controllableVehicle.getOrientationController();
|
||||
if (vehicleController.getOrientation() == null) return;
|
||||
|
||||
// If the controller has been deactivated but the orientation isn't null yet
|
||||
// then perform transition from rolled ride/camera to vanilla
|
||||
if (!vehicleController.isActive() && vehicleController.getOrientation() != null) {
|
||||
cobblemon$applyTransitionRotation(vehicleController, ci);
|
||||
} else { // Otherwise perform cobblemon specific camera rotation and set transition helper variables
|
||||
cobblemon$applyRotation();
|
||||
this.cobblemon$returnTimer = 0;
|
||||
this.cobblemon$rollAngleStart = instance.rotation().getEulerAnglesYXZ(new Vector3f()).z();
|
||||
ci.cancel();
|
||||
}
|
||||
@Override public BlockGetter cobblemon$getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
@Override public Entity cobblemon$getEntity() {
|
||||
return entity;
|
||||
}
|
||||
|
||||
@Override public Quaternionf cobblemon$getRotation() { return rotation; }
|
||||
|
||||
@Override public Vector3f cobblemon$getForwards() { return forwards; }
|
||||
|
||||
@Override public Vector3f cobblemon$getUp() { return up; }
|
||||
|
||||
@Override public Vector3f cobblemon$getLeft() { return left; }
|
||||
|
||||
@Override public float cobblemon$getXRot() { return xRot; }
|
||||
@Override public void cobblemon$setXRot(float xRot) { this.xRot = xRot; }
|
||||
|
||||
@Override public float cobblemon$getYRot() { return yRot; }
|
||||
@Override public void cobblemon$setYRot(float yRot) { this.yRot = yRot; }
|
||||
|
||||
@WrapOperation(method = "setup", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Camera;setPosition(DDD)V"))
|
||||
public void cobblemon$positionCamera(Camera instance, double x, double y, double z, Operation<Void> original, @Local(ordinal = 1, argsOnly = true) boolean thirdPersonReverse) {
|
||||
Entity entity = instance.getEntity();
|
||||
@@ -107,177 +71,22 @@ public abstract class CameraMixin {
|
||||
|
||||
if(vehicle instanceof Rideable){
|
||||
Vec3 position = MountedCameraRenderer.INSTANCE.getCameraPosition(
|
||||
instance,
|
||||
entity,
|
||||
vehicle,
|
||||
x,
|
||||
y,
|
||||
z,
|
||||
thirdPersonReverse,
|
||||
eyeHeightOld,
|
||||
eyeHeight
|
||||
instance,
|
||||
entity,
|
||||
vehicle,
|
||||
thirdPersonReverse,
|
||||
eyeHeight,
|
||||
eyeHeightOld
|
||||
);
|
||||
|
||||
if(position != null){
|
||||
if(position != null) {
|
||||
setPosition(position);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// reset the rotation values if it is now not being ridden.
|
||||
cobblemon$smoothRotation = null;
|
||||
MountedCameraRenderer.INSTANCE.setSmoothRotation(null);
|
||||
original.call(instance, x, y, z);
|
||||
}
|
||||
|
||||
@Unique
|
||||
private void cobblemon$applyRotation(){
|
||||
var driver = this.entity;
|
||||
if (!(driver.getVehicle() instanceof OrientationControllable controllableVehicle) ||
|
||||
controllableVehicle.getOrientationController().getOrientation() == null ||
|
||||
!controllableVehicle.getOrientationController().getActive()
|
||||
) return;
|
||||
|
||||
// Grab the driver and vehicle orientation controllers.
|
||||
var vehicleController = controllableVehicle.getOrientationController();
|
||||
|
||||
var isDriving = driver.getControlledVehicle() != null;
|
||||
|
||||
// Grab the ride orientation
|
||||
var newRotation = new Quaternionf();
|
||||
|
||||
// If the player is driving then use the current orientation since the driver sets it.
|
||||
// If not then use the smoothed render orientation for passengers otherwise the vehicle rotation will be jerky
|
||||
if (isDriving) {
|
||||
newRotation = vehicleController.getOrientation().normal(new Matrix3f()).getNormalizedRotation(new Quaternionf());
|
||||
} else {
|
||||
newRotation = vehicleController.getRenderOrientation(this.partialTickTime);
|
||||
}
|
||||
|
||||
// Unroll the current rotation if no roll is requested and not currently freelooking.
|
||||
if (Cobblemon.config.getDisableRoll()) {
|
||||
// Init the smooth rotation if it has not been set yet.
|
||||
if (cobblemon$smoothRotation == null) {
|
||||
cobblemon$smoothRotation = new Quaternionf().set(this.rotation);
|
||||
}
|
||||
var rideAngs = newRotation.getEulerAnglesYXZ(new Vector3f());
|
||||
var cameraAngs = cobblemon$smoothRotation.getEulerAnglesYXZ(new Vector3f());
|
||||
|
||||
// var vehicle = (PokemonEntity)driver.getVehicle();
|
||||
// var vel = vehicle.getRidingAnimationData().getVelocitySpring().getInterpolated(this.partialTickTime, 0);
|
||||
// // Grab the target yaw as the current rides yaw. If the horizontal velocity is high enough to be used to
|
||||
// // derive a yaw then use it.
|
||||
// var targetYaw = (double) rideAngs.y();
|
||||
// if ( vel.horizontalDistance() > 0.01) {
|
||||
// // lerp the new rotation towards this y rot at a rate proportional to the horizontal movement speed?
|
||||
// targetYaw = Mth.wrapDegrees(Math.toDegrees(Mth.atan2(vel.x(), vel.z())) + 180.0f);
|
||||
// }
|
||||
|
||||
var degDiff = Mth.degreesDifference((float)Math.toDegrees(cameraAngs.y()), (float)Math.toDegrees(rideAngs.y));
|
||||
var pitchDeadzoneDeg = 15.0; // x degrees of deadzone about +-90 degrees of pitch.
|
||||
var pitchDeg = vehicleController.getPitch();
|
||||
// ConsiderPitch to be already 90 if within the deadzone around it.
|
||||
var cutoffPitch = Math.min(1.0,(Mth.abs(pitchDeg) / (90.0f - pitchDeadzoneDeg))) * 90.0f * Math.signum(pitchDeg);
|
||||
var lerpRateMod = Mth.cos((float)Math.toRadians(cutoffPitch));
|
||||
|
||||
// Apply smoothing from the cameras current yaw to the yaw of the velocity vector of the ride.
|
||||
var k = 10.0f; // Some smoothing constant k
|
||||
var smoothingFactor = lerpRateMod * cobblemon$frameTime * k;
|
||||
var newYaw = cameraAngs.y() + (Math.toRadians(degDiff) * smoothingFactor);
|
||||
|
||||
var newPitch = (float)Mth.lerp(cobblemon$frameTime * k, cameraAngs.x(), rideAngs.x());
|
||||
//var newYaw = (float)Mth.lerp(smoothingFactor, cameraAngs.y(), rideAngs.y());
|
||||
var maxRoll = Math.toRadians(15.0f);
|
||||
var newRoll = (float)Mth.lerp(cobblemon$frameTime * k / 2.0, cameraAngs.z(), Math.abs(lerpRateMod) * Math.sin(rideAngs.z()) * maxRoll);
|
||||
|
||||
// Set rotations
|
||||
var smoothedRot = new Quaternionf().rotateYXZ((float)newYaw, newPitch, newRoll);
|
||||
cobblemon$smoothRotation.set(smoothedRot);
|
||||
newRotation.set(smoothedRot);
|
||||
|
||||
}
|
||||
|
||||
var rotationOffset = 0;
|
||||
if (Minecraft.getInstance().options.getCameraType().isMirrored()) {
|
||||
newRotation.rotateY((float)Math.toRadians(180));
|
||||
rotationOffset = 180;
|
||||
}
|
||||
|
||||
// Get the drivers local look angle in relation to the ride and apply it.
|
||||
if (vehicleController.getActive()) {
|
||||
var vehicleMatrix = new Matrix3f().set(newRotation);
|
||||
var driverMatrix = new Matrix3f();// Base the driver
|
||||
var playerRotater = (RidePassenger)driver;
|
||||
newRotation = vehicleMatrix.mul(
|
||||
driverMatrix.rotateYXZ(
|
||||
-Mth.DEG_TO_RAD * (playerRotater.cobblemon$getRideYRot()),
|
||||
-Mth.DEG_TO_RAD * playerRotater.cobblemon$getRideXRot(),
|
||||
0.0f)
|
||||
).normal(new Matrix3f()).getNormalizedRotation(new Quaternionf());
|
||||
}
|
||||
this.rotation.set(newRotation);
|
||||
var eulerAngs = newRotation.getEulerAnglesXYZ(new Vector3f());
|
||||
this.xRot = eulerAngs.x() * Mth.RAD_TO_DEG;
|
||||
this.yRot = eulerAngs.y() * Mth.RAD_TO_DEG;
|
||||
// Set the drivers rotations to match
|
||||
var driverEulerAngs = new Quaternionf(this.rotation).getEulerAnglesYXZ(new Vector3f());
|
||||
driver.setXRot(-driverEulerAngs.x() * Mth.RAD_TO_DEG + rotationOffset);
|
||||
driver.setYRot(180.0f - (driverEulerAngs.y() * Mth.RAD_TO_DEG));
|
||||
|
||||
OrientationController.Companion.getFORWARDS().rotate(this.rotation, this.forwards);
|
||||
OrientationController.Companion.getUP().rotate(this.rotation, this.up);
|
||||
OrientationController.Companion.getLEFT().rotate(this.rotation, this.left);
|
||||
}
|
||||
|
||||
@Unique
|
||||
private void cobblemon$applyTransitionRotation(
|
||||
OrientationController vehicleController,
|
||||
CallbackInfo ci
|
||||
) {
|
||||
// If the transition has just started then
|
||||
if (this.cobblemon$returnTimer == 0.0) {
|
||||
MountedCameraRenderer.INSTANCE.resetDriverRotations((Camera)(Object)this, this.entity);
|
||||
}
|
||||
|
||||
if(this.cobblemon$returnTimer < 1) {
|
||||
//Rotation is taken from entity since we no longer handle mouse ourselves
|
||||
//Stops a period of time when you can't input anything.
|
||||
float interpolatedRoll = Mth.lerp(this.cobblemon$returnTimer, this.cobblemon$rollAngleStart, 0.0f);
|
||||
float pitch = (float) Math.toRadians(-this.entity.getXRot());
|
||||
float yaw = (float) Math.toRadians(180 - this.entity.getYRot());
|
||||
|
||||
Quaternionf interRot = new Quaternionf();
|
||||
interRot.rotationYXZ(yaw, pitch, interpolatedRoll);
|
||||
|
||||
this.rotation.set(interRot);
|
||||
var eulerAngs = interRot.getEulerAnglesXYZ(new Vector3f());
|
||||
this.xRot = eulerAngs.x() * Mth.RAD_TO_DEG;
|
||||
this.yRot = eulerAngs.y() * Mth.RAD_TO_DEG;
|
||||
OrientationController.Companion.getFORWARDS().rotate(this.rotation, this.forwards);
|
||||
OrientationController.Companion.getUP().rotate(this.rotation, this.up);
|
||||
OrientationController.Companion.getLEFT().rotate(this.rotation, this.left);
|
||||
|
||||
if(cobblemon$rollAngleStart == 0){
|
||||
this.cobblemon$returnTimer = 1;
|
||||
vehicleController.reset();
|
||||
MountedCameraRenderer.INSTANCE.resetDriverRotations((Camera)(Object)this, this.entity);
|
||||
return;
|
||||
}
|
||||
this.cobblemon$returnTimer += (partialTickTime * (1.0f/20.0f));
|
||||
ci.cancel();
|
||||
} else {
|
||||
this.cobblemon$returnTimer = 1;
|
||||
vehicleController.reset();
|
||||
MountedCameraRenderer.INSTANCE.resetDriverRotations((Camera)(Object)this, this.entity);
|
||||
}
|
||||
}
|
||||
|
||||
@WrapOperation(method = "setup", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Camera;move(FFF)V", ordinal = 0))
|
||||
public void stopMoveIfRolling(Camera instance, float zoom, float dy, float dx, Operation<Void> original) {
|
||||
Entity entity = instance.getEntity();
|
||||
Entity vehicle = entity.getVehicle();
|
||||
|
||||
if (!(vehicle instanceof PokemonEntity) || Cobblemon.config.getThirdPersonViewBobbing()) {
|
||||
original.call(instance, zoom, dy, dx);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -69,13 +69,17 @@ public class HumanoidModelMixin {
|
||||
behaviour.shouldRotateRiderHead(settings, state, pokemonEntity)
|
||||
);
|
||||
|
||||
if (entity instanceof RidePassenger playerRotater) {
|
||||
//this.head.yRot = playerRotater.cobblemon$getRideYRot();
|
||||
// If the player is on a rollable ride then use the ride local rotations to rotate the head
|
||||
// This is to allow the player head to face the correct direction when "freelooking"
|
||||
if (entity instanceof RidePassenger playerRotater &&
|
||||
vehicle instanceof OrientationControllable controller &&
|
||||
controller.getOrientationController().isActive()) {
|
||||
this.head.xRot = playerRotater.cobblemon$getRideXRot();
|
||||
headPitch = playerRotater.cobblemon$getRideXRot();
|
||||
this.head.yRot = playerRotater.cobblemon$getRideYRot();
|
||||
netHeadYaw = playerRotater.cobblemon$getRideYRot();
|
||||
}
|
||||
|
||||
|
||||
if (!shouldRotatePlayerHead) {
|
||||
netHeadYaw = 0f;
|
||||
headPitch = 0f;
|
||||
|
||||
+2
-2
@@ -36,9 +36,9 @@ public class ItemInHandRendererMixin {
|
||||
}
|
||||
}
|
||||
|
||||
@Redirect(method = "renderHandsWithItems", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/vertex/PoseStack;mulPose(Lorg/joml/Quaternionf;)V", ordinal = 1))
|
||||
@Redirect(method = "renderHandsWithItems", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/vertex/PoseStack;mulPose(Lorg/joml/Quaternionf;)V"))
|
||||
private void cobblemon$renderHandswithItems(PoseStack instance, Quaternionf quaternion) {
|
||||
if (!(Minecraft.getInstance().player instanceof OrientationControllable controllable && controllable.getOrientationController().isActive())) {
|
||||
if (!(Minecraft.getInstance().player != null && Minecraft.getInstance().player.getVehicle() instanceof OrientationControllable controllable && controllable.getOrientationController().isActive())) {
|
||||
instance.mulPose(quaternion);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -308,6 +308,7 @@ public abstract class MouseHandlerMixin {
|
||||
playerRotater.cobblemon$setRideXRot(playerRotater.cobblemon$getRideXRot() + f);
|
||||
playerRotater.cobblemon$setRideYRot(playerRotater.cobblemon$getRideYRot() + g);
|
||||
playerRotater.cobblemon$setRideXRot(Mth.clamp(playerRotater.cobblemon$getRideXRot(), -90.0F, 90.0F));
|
||||
playerRotater.cobblemon$setRideYRot(Mth.clamp(playerRotater.cobblemon$getRideYRot(), -105.0F, 105.0F));
|
||||
if (player.getVehicle() != null) {
|
||||
player.getVehicle().onPassengerTurned(player);
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import com.cobblemon.mod.common.duck.RidePassenger;
|
||||
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
@@ -68,6 +69,7 @@ public abstract class EntityMixin {
|
||||
)
|
||||
private void cobblemon$modifyEyePosition_partial(float partialTicks, CallbackInfoReturnable<Vec3> cir) {
|
||||
var entity = (Entity)(Object)this;
|
||||
if (entity.level().isClientSide) return;
|
||||
if (!(entity instanceof Player player)) return;
|
||||
if (!(player instanceof RidePassenger ridePassenger)) return;
|
||||
if (!(player.getVehicle() instanceof OrientationControllable vehicle)) return;
|
||||
@@ -78,7 +80,6 @@ public abstract class EntityMixin {
|
||||
// TODO: Determine if it needs partialtick involved.
|
||||
Vec3 customEyePos = ridePassenger.cobblemon$getRideEyePos();
|
||||
cir.setReturnValue(customEyePos);
|
||||
|
||||
}
|
||||
|
||||
@Inject(
|
||||
@@ -88,6 +89,7 @@ public abstract class EntityMixin {
|
||||
)
|
||||
private void cobblemon$modifyEyePosition_noPartial(CallbackInfoReturnable<Vec3> cir) {
|
||||
var entity = (Entity)(Object)this;
|
||||
if (entity.level().isClientSide) return;
|
||||
if (!(entity instanceof Player player)) return;
|
||||
if (!(player instanceof RidePassenger ridePassenger)) return;
|
||||
if (!(player.getVehicle() instanceof OrientationControllable vehicle)) return;
|
||||
|
||||
@@ -11,16 +11,26 @@ package com.cobblemon.mod.common
|
||||
import net.minecraft.world.entity.schedule.Activity
|
||||
|
||||
object CobblemonActivities {
|
||||
@JvmField
|
||||
val activities = mutableListOf<Activity>()
|
||||
@JvmField
|
||||
val BATTLING = register(Activity("battling"))
|
||||
@JvmField
|
||||
val ACTION_EFFECT = register(Activity("action_effect"))
|
||||
@JvmField
|
||||
val NPC_CHATTING = register(Activity("npc_chatting"))
|
||||
@JvmField
|
||||
val POKEMON_SLEEPING_ACTIVITY = register(Activity("pokemon_sleeping"))
|
||||
@JvmField
|
||||
val POKEMON_GROW_CROP = register(Activity("pokemon_grow_crop"))
|
||||
@JvmField
|
||||
val POKEMON_SLEEP_ON_TRAINER_BED = register(Activity("pokemon_sleep_on_trainer_bed"))
|
||||
@JvmField
|
||||
val POKEMON_HERD = register(Activity("pokemon_herd"))
|
||||
@JvmField
|
||||
val POKEMON_POLLINATION = register(Activity("pokemon_pollination"))
|
||||
|
||||
@JvmStatic
|
||||
fun register(activity: Activity): Activity {
|
||||
activities.add(activity)
|
||||
return activity
|
||||
|
||||
@@ -60,13 +60,13 @@ object CobblemonBlocks : PlatformRegistry<Registry<Block>, ResourceKey<Registry<
|
||||
|
||||
// Evolution Ores
|
||||
@JvmField
|
||||
val DAWN_STONE_ORE = evolutionStoneOre("dawn_stone_ore")
|
||||
val DAWN_STONE_ORE = evolutionStoneOre("dawn_stone_ore", 7)
|
||||
@JvmField
|
||||
val DUSK_STONE_ORE = evolutionStoneOre("dusk_stone_ore")
|
||||
@JvmField
|
||||
val FIRE_STONE_ORE = evolutionStoneOre("fire_stone_ore")
|
||||
val FIRE_STONE_ORE = evolutionStoneOre("fire_stone_ore", 10)
|
||||
@JvmField
|
||||
val NETHER_FIRE_STONE_ORE = evolutionStoneOre("nether_fire_stone_ore")
|
||||
val NETHER_FIRE_STONE_ORE = this.create("nether_fire_stone_ore", DropExperienceBlock(UniformInt.of(1, 2), BlockBehaviour.Properties.of().mapColor(MapColor.NETHER).instrument(NoteBlockInstrument.BASEDRUM).requiresCorrectToolForDrops().strength(3.0F, 3.0F).sound(SoundType.NETHER_ORE).lightLevel{10}))
|
||||
@JvmField
|
||||
val ICE_STONE_ORE = evolutionStoneOre("ice_stone_ore")
|
||||
@JvmField
|
||||
@@ -74,24 +74,24 @@ object CobblemonBlocks : PlatformRegistry<Registry<Block>, ResourceKey<Registry<
|
||||
@JvmField
|
||||
val MOON_STONE_ORE = evolutionStoneOre("moon_stone_ore")
|
||||
@JvmField
|
||||
val DRIPSTONE_MOON_STONE_ORE = evolutionStoneOre("dripstone_moon_stone_ore")
|
||||
val DRIPSTONE_MOON_STONE_ORE = this.create("dripstone_moon_stone_ore", DropExperienceBlock(UniformInt.of(1, 2), BlockBehaviour.Properties.of().mapColor(MapColor.TERRACOTTA_BROWN).instrument(NoteBlockInstrument.BASEDRUM).requiresCorrectToolForDrops().strength(3.0F, 3.0F).sound(SoundType.DRIPSTONE_BLOCK)))
|
||||
@JvmField
|
||||
val SHINY_STONE_ORE = evolutionStoneOre("shiny_stone_ore")
|
||||
val SHINY_STONE_ORE = evolutionStoneOre("shiny_stone_ore", 12)
|
||||
@JvmField
|
||||
val SUN_STONE_ORE = evolutionStoneOre("sun_stone_ore")
|
||||
val SUN_STONE_ORE = evolutionStoneOre("sun_stone_ore", 2)
|
||||
@JvmField
|
||||
val TERRACOTTA_SUN_STONE_ORE = evolutionStoneOre("terracotta_sun_stone_ore")
|
||||
val TERRACOTTA_SUN_STONE_ORE = this.create("terracotta_sun_stone_ore", DropExperienceBlock(UniformInt.of(1, 2), BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_ORANGE).instrument(NoteBlockInstrument.BASEDRUM).requiresCorrectToolForDrops().strength(3.0F, 3.0F).lightLevel{2}))
|
||||
@JvmField
|
||||
val THUNDER_STONE_ORE = evolutionStoneOre("thunder_stone_ore")
|
||||
val THUNDER_STONE_ORE = evolutionStoneOre("thunder_stone_ore", 6)
|
||||
@JvmField
|
||||
val WATER_STONE_ORE = evolutionStoneOre("water_stone_ore")
|
||||
|
||||
@JvmField
|
||||
val DEEPSLATE_DAWN_STONE_ORE = this.deepslateEvolutionStoneOre("deepslate_dawn_stone_ore")
|
||||
val DEEPSLATE_DAWN_STONE_ORE = this.deepslateEvolutionStoneOre("deepslate_dawn_stone_ore", 7)
|
||||
@JvmField
|
||||
val DEEPSLATE_DUSK_STONE_ORE = this.deepslateEvolutionStoneOre("deepslate_dusk_stone_ore")
|
||||
@JvmField
|
||||
val DEEPSLATE_FIRE_STONE_ORE = this.deepslateEvolutionStoneOre("deepslate_fire_stone_ore")
|
||||
val DEEPSLATE_FIRE_STONE_ORE = this.deepslateEvolutionStoneOre("deepslate_fire_stone_ore", 10)
|
||||
@JvmField
|
||||
val DEEPSLATE_ICE_STONE_ORE = this.deepslateEvolutionStoneOre("deepslate_ice_stone_ore")
|
||||
@JvmField
|
||||
@@ -99,11 +99,11 @@ object CobblemonBlocks : PlatformRegistry<Registry<Block>, ResourceKey<Registry<
|
||||
@JvmField
|
||||
val DEEPSLATE_MOON_STONE_ORE = this.deepslateEvolutionStoneOre("deepslate_moon_stone_ore")
|
||||
@JvmField
|
||||
val DEEPSLATE_SHINY_STONE_ORE = this.deepslateEvolutionStoneOre("deepslate_shiny_stone_ore")
|
||||
val DEEPSLATE_SHINY_STONE_ORE = this.deepslateEvolutionStoneOre("deepslate_shiny_stone_ore", 12)
|
||||
@JvmField
|
||||
val DEEPSLATE_SUN_STONE_ORE = this.deepslateEvolutionStoneOre("deepslate_sun_stone_ore")
|
||||
val DEEPSLATE_SUN_STONE_ORE = this.deepslateEvolutionStoneOre("deepslate_sun_stone_ore", 2)
|
||||
@JvmField
|
||||
val DEEPSLATE_THUNDER_STONE_ORE = this.deepslateEvolutionStoneOre("deepslate_thunder_stone_ore")
|
||||
val DEEPSLATE_THUNDER_STONE_ORE = this.deepslateEvolutionStoneOre("deepslate_thunder_stone_ore", 6)
|
||||
@JvmField
|
||||
val DEEPSLATE_WATER_STONE_ORE = this.deepslateEvolutionStoneOre("deepslate_water_stone_ore")
|
||||
|
||||
@@ -454,7 +454,7 @@ object CobblemonBlocks : PlatformRegistry<Registry<Block>, ResourceKey<Registry<
|
||||
|
||||
@JvmField
|
||||
val SOUL_CAMPFIRE = create("soul_campfire", CampfireBlock(BlockBehaviour.Properties.of().sound(SoundType.WOOD).noOcclusion().pushReaction(PushReaction.BLOCK).mapColor(MapColor.PODZOL).strength(2.0F).lightLevel{9}, true))
|
||||
|
||||
|
||||
@JvmField
|
||||
val RELIC_COIN_POUCH = create("relic_coin_pouch", CoinPouchBlock(BlockBehaviour.Properties.of().sound(CobblemonSounds.RELIC_COIN_POUCH_SOUNDS).pushReaction(PushReaction.DESTROY).noOcclusion(), true))
|
||||
@JvmField
|
||||
@@ -577,75 +577,145 @@ object CobblemonBlocks : PlatformRegistry<Registry<Block>, ResourceKey<Registry<
|
||||
|
||||
private val berries = mutableMapOf<ResourceLocation, BerryBlock>()
|
||||
|
||||
@JvmField
|
||||
val AGUAV_BERRY = this.berryBlock("aguav")
|
||||
@JvmField
|
||||
val APICOT_BERRY = this.berryBlock("apicot")
|
||||
@JvmField
|
||||
val ASPEAR_BERRY = this.berryBlock("aspear")
|
||||
@JvmField
|
||||
val BABIRI_BERRY = this.berryBlock("babiri")
|
||||
@JvmField
|
||||
val BELUE_BERRY = this.berryBlock("belue")
|
||||
@JvmField
|
||||
val BLUK_BERRY = this.berryBlock("bluk")
|
||||
@JvmField
|
||||
val CHARTI_BERRY = this.berryBlock("charti")
|
||||
@JvmField
|
||||
val CHERI_BERRY = this.berryBlock("cheri")
|
||||
@JvmField
|
||||
val CHESTO_BERRY = this.berryBlock("chesto")
|
||||
@JvmField
|
||||
val CHILAN_BERRY = this.berryBlock("chilan")
|
||||
@JvmField
|
||||
val CHOPLE_BERRY = this.berryBlock("chople")
|
||||
@JvmField
|
||||
val COBA_BERRY = this.berryBlock("coba")
|
||||
@JvmField
|
||||
val COLBUR_BERRY = this.berryBlock("colbur")
|
||||
@JvmField
|
||||
val CORNN_BERRY = this.berryBlock("cornn")
|
||||
@JvmField
|
||||
val CUSTAP_BERRY = this.berryBlock("custap")
|
||||
@JvmField
|
||||
val DURIN_BERRY = this.berryBlock("durin")
|
||||
@JvmField
|
||||
val EGGANT_BERRY = this.berryBlock("eggant")
|
||||
@JvmField
|
||||
val ENIGMA_BERRY = this.berryBlock("enigma")
|
||||
@JvmField
|
||||
val FIGY_BERRY = this.berryBlock("figy")
|
||||
@JvmField
|
||||
val GANLON_BERRY = this.berryBlock("ganlon")
|
||||
@JvmField
|
||||
val GREPA_BERRY = this.berryBlock("grepa")
|
||||
@JvmField
|
||||
val HABAN_BERRY = this.berryBlock("haban")
|
||||
@JvmField
|
||||
val HONDEW_BERRY = this.berryBlock("hondew")
|
||||
@JvmField
|
||||
val HOPO_BERRY = this.berryBlock("hopo")
|
||||
@JvmField
|
||||
val IAPAPA_BERRY = this.berryBlock("iapapa")
|
||||
@JvmField
|
||||
val JABOCA_BERRY = this.berryBlock("jaboca")
|
||||
@JvmField
|
||||
val KASIB_BERRY = this.berryBlock("kasib")
|
||||
@JvmField
|
||||
val KEBIA_BERRY = this.berryBlock("kebia")
|
||||
@JvmField
|
||||
val KEE_BERRY = this.berryBlock("kee")
|
||||
@JvmField
|
||||
val KELPSY_BERRY = this.berryBlock("kelpsy")
|
||||
@JvmField
|
||||
val LANSAT_BERRY = this.berryBlock("lansat")
|
||||
@JvmField
|
||||
val LEPPA_BERRY = this.berryBlock("leppa")
|
||||
@JvmField
|
||||
val LIECHI_BERRY = this.berryBlock("liechi")
|
||||
@JvmField
|
||||
val LUM_BERRY = this.berryBlock("lum")
|
||||
@JvmField
|
||||
val MAGO_BERRY = this.berryBlock("mago")
|
||||
@JvmField
|
||||
val MAGOST_BERRY = this.berryBlock("magost")
|
||||
@JvmField
|
||||
val MARANGA_BERRY = this.berryBlock("maranga")
|
||||
@JvmField
|
||||
val MICLE_BERRY = this.berryBlock("micle")
|
||||
@JvmField
|
||||
val NANAB_BERRY = this.berryBlock("nanab")
|
||||
@JvmField
|
||||
val NOMEL_BERRY = this.berryBlock("nomel")
|
||||
@JvmField
|
||||
val OCCA_BERRY = this.berryBlock("occa")
|
||||
@JvmField
|
||||
val ORAN_BERRY = this.berryBlock("oran")
|
||||
@JvmField
|
||||
val PAMTRE_BERRY = this.berryBlock("pamtre")
|
||||
@JvmField
|
||||
val PASSHO_BERRY = this.berryBlock("passho")
|
||||
@JvmField
|
||||
val PAYAPA_BERRY = this.berryBlock("payapa")
|
||||
@JvmField
|
||||
val PECHA_BERRY = this.berryBlock("pecha")
|
||||
@JvmField
|
||||
val PERSIM_BERRY = this.berryBlock("persim")
|
||||
@JvmField
|
||||
val PETAYA_BERRY = this.berryBlock("petaya")
|
||||
@JvmField
|
||||
val PINAP_BERRY = this.berryBlock("pinap")
|
||||
@JvmField
|
||||
val POMEG_BERRY = this.berryBlock("pomeg")
|
||||
@JvmField
|
||||
val QUALOT_BERRY = this.berryBlock("qualot")
|
||||
@JvmField
|
||||
val RABUTA_BERRY = this.berryBlock("rabuta")
|
||||
@JvmField
|
||||
val RAWST_BERRY = this.berryBlock("rawst")
|
||||
@JvmField
|
||||
val RAZZ_BERRY = this.berryBlock("razz")
|
||||
@JvmField
|
||||
val RINDO_BERRY = this.berryBlock("rindo")
|
||||
@JvmField
|
||||
val ROSELI_BERRY = this.berryBlock("roseli")
|
||||
@JvmField
|
||||
val ROWAP_BERRY = this.berryBlock("rowap")
|
||||
@JvmField
|
||||
val SALAC_BERRY = this.berryBlock("salac")
|
||||
@JvmField
|
||||
val SHUCA_BERRY = this.berryBlock("shuca")
|
||||
@JvmField
|
||||
val SITRUS_BERRY = this.berryBlock("sitrus")
|
||||
@JvmField
|
||||
val SPELON_BERRY = this.berryBlock("spelon")
|
||||
@JvmField
|
||||
val STARF_BERRY = this.berryBlock("starf")
|
||||
@JvmField
|
||||
val TAMATO_BERRY = this.berryBlock("tamato")
|
||||
@JvmField
|
||||
val TANGA_BERRY = this.berryBlock("tanga")
|
||||
@JvmField
|
||||
val TOUGA_BERRY = this.berryBlock("touga")
|
||||
@JvmField
|
||||
val WACAN_BERRY = this.berryBlock("wacan")
|
||||
@JvmField
|
||||
val WATMEL_BERRY = this.berryBlock("watmel")
|
||||
@JvmField
|
||||
val WEPEAR_BERRY = this.berryBlock("wepear")
|
||||
@JvmField
|
||||
val WIKI_BERRY = this.berryBlock("wiki")
|
||||
@JvmField
|
||||
val YACHE_BERRY = this.berryBlock("yache")
|
||||
//val BINDING_SOIL = this.create("binding_soil", BindingSoilBlock(BlockBehaviour.Properties.of()))
|
||||
|
||||
@@ -713,8 +783,10 @@ object CobblemonBlocks : PlatformRegistry<Registry<Block>, ResourceKey<Registry<
|
||||
}
|
||||
|
||||
private fun evolutionStoneOre(name: String) = this.create(name, DropExperienceBlock(UniformInt.of(1, 2), BlockBehaviour.Properties.ofFullCopy(Blocks.IRON_ORE)))
|
||||
private fun evolutionStoneOre(name: String, lightLevel: Int) = this.create(name, DropExperienceBlock(UniformInt.of(1, 2), BlockBehaviour.Properties.ofFullCopy(Blocks.IRON_ORE).lightLevel { lightLevel }))
|
||||
|
||||
private fun deepslateEvolutionStoneOre(name: String) = this.create(name, DropExperienceBlock(UniformInt.of(1, 2), BlockBehaviour.Properties.ofFullCopy(Blocks.DEEPSLATE_IRON_ORE)))
|
||||
private fun deepslateEvolutionStoneOre(name: String, lightLevel: Int) = this.create(name, DropExperienceBlock(UniformInt.of(1, 2), BlockBehaviour.Properties.ofFullCopy(Blocks.DEEPSLATE_IRON_ORE).lightLevel { lightLevel }))
|
||||
|
||||
/**
|
||||
* Helper method for creating leaves
|
||||
|
||||
@@ -43,6 +43,7 @@ object CobblemonCosmeticItems : JsonDataRegistry<CosmeticItemAssignment> {
|
||||
.registerTypeAdapter(ResourceLocation::class.java, IdentifierAdapter)
|
||||
.create()
|
||||
|
||||
@JvmField
|
||||
val cosmeticItems = mutableListOf<CosmeticItemAssignment>()
|
||||
|
||||
override fun reload(data: Map<ResourceLocation, CosmeticItemAssignment>) {
|
||||
@@ -55,7 +56,9 @@ object CobblemonCosmeticItems : JsonDataRegistry<CosmeticItemAssignment> {
|
||||
CosmeticItemAssignmentSyncPacket(cosmeticItems).sendToPlayer(player)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun findValidForPokemon(pokemon: Pokemon) = cosmeticItems.filter { it.pokemon.any { it.matches(pokemon) } }
|
||||
@JvmStatic
|
||||
fun findValidCosmeticForPokemonAndItem(registryAccess: RegistryAccess, pokemon: Pokemon, itemStack: ItemStack) = cosmeticItems
|
||||
.filter { it.pokemon.any { it.matches(pokemon) } }
|
||||
.flatMap { it.cosmeticItems }
|
||||
|
||||
@@ -21,61 +21,73 @@ import net.minecraft.resources.ResourceLocation
|
||||
|
||||
object CobblemonItemComponents : PlatformRegistry<Registry<DataComponentType<*>>, ResourceKey<Registry<DataComponentType<*>>>, DataComponentType<*>>() {
|
||||
|
||||
@JvmField
|
||||
val POKEMON_ITEM: DataComponentType<PokemonItemComponent> = create("pokemon_item", DataComponentType.builder<PokemonItemComponent>()
|
||||
.persistent(PokemonItemComponent.CODEC)
|
||||
.networkSynchronized(PokemonItemComponent.PACKET_CODEC)
|
||||
.build())
|
||||
|
||||
@JvmField
|
||||
val HELD_ITEM_EFFECT: DataComponentType<HeldItemEffectComponent> = create("held_item_effect", DataComponentType.builder<HeldItemEffectComponent>()
|
||||
.persistent(HeldItemEffectComponent.CODEC)
|
||||
.networkSynchronized(HeldItemEffectComponent.PACKET_CODEC)
|
||||
.build())
|
||||
|
||||
@JvmField
|
||||
val BAIT: DataComponentType<RodBaitComponent> = create("bait", DataComponentType.builder<RodBaitComponent>()
|
||||
.persistent(RodBaitComponent.CODEC)
|
||||
.networkSynchronized(RodBaitComponent.PACKET_CODEC)
|
||||
.build())
|
||||
|
||||
@JvmField
|
||||
val POT_DATA: DataComponentType<PotComponent> = create("cooking_pot_item", DataComponentType.builder<PotComponent>()
|
||||
.persistent(PotComponent.CODEC)
|
||||
.networkSynchronized(PotComponent.PACKET_CODEC)
|
||||
.build())
|
||||
|
||||
@JvmField
|
||||
val BAIT_EFFECTS: DataComponentType<BaitEffectsComponent> = create("bait_effects", DataComponentType.builder<BaitEffectsComponent>()
|
||||
.persistent(BaitEffectsComponent.CODEC)
|
||||
.networkSynchronized(BaitEffectsComponent.PACKET_CODEC)
|
||||
.build())
|
||||
|
||||
@JvmField
|
||||
val FLAVOUR: DataComponentType<FlavourComponent> = create("flavour", DataComponentType.builder<FlavourComponent>()
|
||||
.persistent(FlavourComponent.CODEC)
|
||||
.networkSynchronized(FlavourComponent.PACKET_CODEC)
|
||||
.build())
|
||||
|
||||
@JvmField
|
||||
val RIDE_BOOST: DataComponentType<RideBoostsComponent> = create("ride_boosts", DataComponentType.builder<RideBoostsComponent>()
|
||||
.persistent(RideBoostsComponent.CODEC)
|
||||
.networkSynchronized(RideBoostsComponent.PACKET_CODEC)
|
||||
.build())
|
||||
|
||||
@JvmField
|
||||
val FOOD_COLOUR: DataComponentType<FoodColourComponent> = create("food_colour", DataComponentType.builder<FoodColourComponent>()
|
||||
.persistent(FoodColourComponent.CODEC)
|
||||
.networkSynchronized(FoodColourComponent.PACKET_CODEC)
|
||||
.build())
|
||||
|
||||
@JvmField
|
||||
val INGREDIENT: DataComponentType<IngredientComponent> = create("ingredient", DataComponentType.builder<IngredientComponent>()
|
||||
.persistent(IngredientComponent.CODEC)
|
||||
.networkSynchronized(IngredientComponent.PACKET_CODEC)
|
||||
.build())
|
||||
|
||||
@JvmField
|
||||
val FOOD: DataComponentType<FoodComponent> = create("food", DataComponentType.builder<FoodComponent>()
|
||||
.persistent(FoodComponent.CODEC)
|
||||
.networkSynchronized(FoodComponent.PACKET_CODEC)
|
||||
.build())
|
||||
|
||||
@JvmField
|
||||
val MOB_EFFECTS: DataComponentType<MobEffectsComponent> = create("mob_effects", DataComponentType.builder<MobEffectsComponent>()
|
||||
.persistent(MobEffectsComponent.CODEC)
|
||||
.networkSynchronized(MobEffectsComponent.PACKET_CODEC)
|
||||
.build())
|
||||
|
||||
@JvmField
|
||||
val CRAFTED: DataComponentType<Boolean> = create("crafted", DataComponentType.builder<Boolean>()
|
||||
.persistent(Codec.BOOL)
|
||||
.networkSynchronized(ByteBufCodecs.BOOL)
|
||||
|
||||
@@ -16,6 +16,7 @@ import com.cobblemon.mod.common.mechanics.AprijuicesMechanic
|
||||
import com.cobblemon.mod.common.mechanics.BerriesMechanic
|
||||
import com.cobblemon.mod.common.mechanics.PotionsMechanic
|
||||
import com.cobblemon.mod.common.mechanics.RemediesMechanic
|
||||
import com.cobblemon.mod.common.net.messages.client.data.CobblemonMechanicsSyncPacket
|
||||
import com.cobblemon.mod.common.util.adapters.ExpressionAdapter
|
||||
import com.cobblemon.mod.common.util.adapters.ExpressionLikeAdapter
|
||||
import com.cobblemon.mod.common.util.cobblemonResource
|
||||
@@ -40,7 +41,14 @@ object CobblemonMechanics : DataRegistry {
|
||||
var potions = PotionsMechanic()
|
||||
var aprijuices = AprijuicesMechanic()
|
||||
|
||||
override fun sync(player: ServerPlayer) {}
|
||||
override fun sync(player: ServerPlayer) {
|
||||
CobblemonMechanicsSyncPacket(
|
||||
this.remedies,
|
||||
this.berries,
|
||||
this.potions,
|
||||
this.aprijuices,
|
||||
).sendToPlayer(player)
|
||||
}
|
||||
|
||||
override fun reload(manager: ResourceManager) {
|
||||
remedies = loadMechanic(manager, "remedies", RemediesMechanic::class.java)
|
||||
|
||||
@@ -30,49 +30,80 @@ object CobblemonMemories {
|
||||
* get serialized during relogs. This makes sense for things like battles which
|
||||
* do not survive a relog therefore any memory of it should be temporary.
|
||||
*/
|
||||
|
||||
@JvmField
|
||||
val BATTLING_POKEMON = register("battling_pokemon", ListCodec(UUIDUtil.CODEC, 0, 31))
|
||||
@JvmField
|
||||
val NPC_BATTLING = register("npc_battling", PrimitiveCodec.BOOL)
|
||||
@JvmField
|
||||
val DIALOGUES = register<List<ActiveDialogue>>("npc_dialogues")
|
||||
@JvmField
|
||||
val ACTIVE_ACTION_EFFECT = register<ActionEffectContext>("active_action_effect")
|
||||
@JvmField
|
||||
val POKEMON_FLYING = register("pokemon_flying", PrimitiveCodec.BOOL)
|
||||
@JvmField
|
||||
val POKEMON_DROWSY = register("pokemon_drowsy", PrimitiveCodec.BOOL)
|
||||
@JvmField
|
||||
val POKEMON_SLEEPING = register("pokemon_sleeping", PrimitiveCodec.BOOL)
|
||||
@JvmField
|
||||
val POKEMON_BATTLE = register<UUID>("pokemon_battle")
|
||||
@JvmField
|
||||
val PATH_COOLDOWN = register<Boolean>("path_cooldown")
|
||||
@JvmField
|
||||
val TARGETED_BATTLE_POKEMON = register<UUID>("targeted_battle_pokemon")
|
||||
@JvmField
|
||||
val NEAREST_VISIBLE_ATTACKER = register<LivingEntity>("nearest_visible_attacker")
|
||||
@JvmField
|
||||
val NEARBY_GROWABLE_CROPS = register<BlockPos>("nearby_growable_crops")
|
||||
@JvmField
|
||||
val NEARBY_SWEET_BERRY_BUSH = register<BlockPos>("nearest_sweet_berry_bush")
|
||||
@JvmField
|
||||
val DISABLE_WALK_TO_BERRY_BUSH = register<Boolean>("disable_walk_to_berry_bush")
|
||||
@JvmField
|
||||
val TIME_TRYING_TO_REACH_BERRY_BUSH = register<Int>("time_trying_to_reach_berry_bush")
|
||||
@JvmField
|
||||
val IS_CONSUMING_ITEM = register<Boolean>("is_consuming_item")
|
||||
@JvmField
|
||||
val RECENTLY_ATE_GRASS = register<Boolean>("recently_ate_grass")
|
||||
@JvmField
|
||||
val HIVE_LOCATION = register<BlockPos>("hive_location", BlockPos.CODEC)
|
||||
@JvmField
|
||||
val HIVE_BLACKLIST = register<List<BlockPos>>("hive_blacklist")
|
||||
@JvmField
|
||||
val HIVE_COOLDOWN = register<Boolean>("hive_cooldown")
|
||||
@JvmField
|
||||
val NEARBY_FLOWER = register<BlockPos>("nearby_flower", BlockPos.CODEC)
|
||||
@JvmField
|
||||
val PATH_TO_NEARBY_FLOWER_COOLDOWN = register<Boolean>("path_to_nearby_flower_cooldown")
|
||||
@JvmField
|
||||
val HAS_NECTAR = register<Boolean>("has_nectar", PrimitiveCodec.BOOL)
|
||||
@JvmField
|
||||
val NEARBY_SACC_LEAVES = register<BlockPos>("nearby_sacc_leaves", BlockPos.CODEC)
|
||||
/** who am i following rn? */
|
||||
@JvmField
|
||||
val HERD_LEADER = register<String>("herd_leader", PrimitiveCodec.STRING)
|
||||
/** how many are following me rn? */
|
||||
@JvmField
|
||||
val HERD_SIZE = register<Int>("herd_size") // Don't bother saving it, we'll try to keep count roughly.
|
||||
@JvmField
|
||||
val ATTACK_TARGET_DATA = register<CobblemonAttackTargetData>("attack_target_data") // This is used to store additional information about the attack target, such as when to give up pursuit.
|
||||
@JvmField
|
||||
val WANDER_CONTROL = register<CobblemonWanderControl>("wander_control")
|
||||
@JvmField
|
||||
val DISABLE_WALK_TO_WANTED_ITEM = register<Boolean>("disable_walk_to_wanted_item")
|
||||
@JvmField
|
||||
val TIME_TRYING_TO_REACH_WANTED_ITEM = register<Int>("time_trying_to_wanted_item")
|
||||
|
||||
@JvmStatic
|
||||
fun <U> register(id: String, codec: Codec<U>): MemoryModuleType<U> {
|
||||
val memoryModule = MemoryModuleType(Optional.of(codec))
|
||||
memories[id] = memoryModule
|
||||
return memoryModule
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun <U> register(id: String): MemoryModuleType<U> {
|
||||
val memoryModule = MemoryModuleType<U>(Optional.empty())
|
||||
memories[id] = memoryModule
|
||||
return memoryModule
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,7 @@ import com.cobblemon.mod.common.client.net.callback.move.OpenMoveCallbackHandler
|
||||
import com.cobblemon.mod.common.client.net.callback.party.OpenPartyCallbackHandler
|
||||
import com.cobblemon.mod.common.client.net.callback.partymove.OpenPartyMoveCallbackHandler
|
||||
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.RideSettingsSyncHandler
|
||||
import com.cobblemon.mod.common.client.net.dialogue.DialogueClosedHandler
|
||||
@@ -267,10 +268,13 @@ object CobblemonNetwork {
|
||||
fun ServerPlayer.sendPacket(packet: NetworkPacket<*>) {
|
||||
sendPacketToPlayer(this, packet)
|
||||
}
|
||||
@JvmStatic
|
||||
fun sendToServer(packet: NetworkPacket<*>) {
|
||||
Cobblemon.implementation.networkManager.sendToServer(packet)
|
||||
}
|
||||
@JvmStatic
|
||||
fun sendToAllPlayers(packet: NetworkPacket<*>) = sendPacketToPlayers(server()!!.playerList.players, packet)
|
||||
@JvmStatic
|
||||
fun sendPacketToPlayers(players: Iterable<ServerPlayer>, packet: NetworkPacket<*>) = players.forEach { sendPacketToPlayer(it, packet) }
|
||||
|
||||
val s2cPayloads = generateS2CPacketInfoList()
|
||||
@@ -392,6 +396,7 @@ object CobblemonNetwork {
|
||||
|
||||
// Data registries
|
||||
list.add(PacketRegisterInfo(AbilityRegistrySyncPacket.ID, AbilityRegistrySyncPacket::decode, DataRegistrySyncPacketHandler()))
|
||||
list.add(PacketRegisterInfo(CobblemonMechanicsSyncPacket.ID, CobblemonMechanicsSyncPacket::decode, CobblemonMechanicsSyncHandler))
|
||||
list.add(PacketRegisterInfo(MovesRegistrySyncPacket.ID, MovesRegistrySyncPacket::decode, DataRegistrySyncPacketHandler()))
|
||||
list.add(PacketRegisterInfo(BerryRegistrySyncPacket.ID, BerryRegistrySyncPacket::decode, DataRegistrySyncPacketHandler()))
|
||||
list.add(PacketRegisterInfo(SpeciesRegistrySyncPacket.ID, SpeciesRegistrySyncPacket::decode, DataRegistrySyncPacketHandler()))
|
||||
@@ -604,4 +609,4 @@ object CobblemonNetwork {
|
||||
fun sendPacketToPlayer(player: ServerPlayer, packet: NetworkPacket<*>) {
|
||||
Cobblemon.implementation.networkManager.sendPacketToPlayer(player, packet)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,32 +20,45 @@ import net.minecraft.world.entity.ai.sensing.SensorType
|
||||
object CobblemonSensors {
|
||||
val sensors = mutableMapOf<String, SensorType<*>>()
|
||||
|
||||
@JvmField
|
||||
val NPC_BATTLING = register("npc_battling", ::NPCBattlingSensor)
|
||||
@JvmField
|
||||
val BATTLING_POKEMON = register("battling_pokemon", ::BattlingPokemonSensor)
|
||||
// val NPC_BATTLING = register("npc_battling", ::NPCBattlingSensor)
|
||||
@JvmField
|
||||
val POKEMON_DROWSY = register("pokemon_drowsy", ::DrowsySensor)
|
||||
|
||||
@JvmField
|
||||
val POKEMON_ADULT = register("pokemon_adult_sensor", ::PokemonAdultSensor)
|
||||
|
||||
@JvmField
|
||||
val POKEMON_DISTURBANCE = register("pokemon_disturbance_sensor", ::PokemonDisturbancesSensor)
|
||||
|
||||
@JvmField
|
||||
val POKEMON_DEFEND_OWNER = register("pokemon_owner_under_attack", ::DefendOwnerSensor)
|
||||
|
||||
@JvmField
|
||||
val NEARBY_GROWABLE_CROPS = register("nearby_growable_crops", ::PokemonGrowableCropSensor)
|
||||
|
||||
@JvmField
|
||||
val NEARBY_BEE_HIVE = register("nearby_bee_hive", ::BeeHiveSensor)
|
||||
|
||||
@JvmField
|
||||
val NEARBY_FLOWER = register("nearby_flower", ::FlowerSensor)
|
||||
|
||||
@JvmField
|
||||
val NEARBY_SWEET_BERRY_BUSH = register("nearby_sweet_berry_bush", ::SweetBerryBushSensor)
|
||||
|
||||
@JvmField
|
||||
val POKEMON_NEARBY_WANTED_ITEM = register("pokemon_nearby_wanted_item", ::PokemonItemSensor)
|
||||
|
||||
@JvmField
|
||||
val NEARBY_SACC_LEAVES = register("nearby_sacc_leaves", ::SacLeavesSensor)
|
||||
|
||||
@JvmStatic
|
||||
fun <E : Entity, U : Sensor<E>> register(id: String, supplier: Supplier<U>): SensorType<U> {
|
||||
val sensor = SensorType(supplier)
|
||||
sensors[id] = sensor
|
||||
return sensor
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,43 +23,61 @@ import net.minecraft.resources.ResourceKey
|
||||
* @since October 26th, 2022
|
||||
*/
|
||||
object CobblemonCriteria : PlatformRegistry<Registry<CriterionTrigger<*>>, ResourceKey<Registry<CriterionTrigger<*>>>, CriterionTrigger<*>>(){
|
||||
@JvmField
|
||||
val PICK_STARTER = this.create("pick_starter", SimpleCriterionTrigger(PokemonCriterion.CODEC))
|
||||
|
||||
@JvmField
|
||||
val CATCH_POKEMON = this.create("catch_pokemon", SimpleCriterionTrigger(CaughtPokemonCriterion.CODEC))
|
||||
|
||||
@JvmField
|
||||
val CATCH_SHINY_POKEMON = this.create("catch_shiny_pokemon", SimpleCriterionTrigger(CountableCriterion.CODEC))
|
||||
|
||||
@JvmField
|
||||
val EGG_COLLECT = this.create("eggs_collected", SimpleCriterionTrigger(CountableCriterion.CODEC))
|
||||
|
||||
@JvmField
|
||||
val EGG_HATCH = this.create("eggs_hatched", SimpleCriterionTrigger(CountableCriterion.CODEC))
|
||||
|
||||
@JvmField
|
||||
val EVOLVE_POKEMON = this.create("pokemon_evolved", SimpleCriterionTrigger(EvolvePokemonCriterion.CODEC))
|
||||
|
||||
@JvmField
|
||||
val WIN_BATTLE = this.create("battles_won", SimpleCriterionTrigger(BattleCountableCriterion.CODEC))
|
||||
|
||||
@JvmField
|
||||
val DEFEAT_POKEMON = this.create("pokemon_defeated", SimpleCriterionTrigger(CountableCriterion.CODEC))
|
||||
|
||||
@JvmField
|
||||
val COLLECT_ASPECT = this.create("aspects_collected", SimpleCriterionTrigger(AspectCriterion.CODEC))
|
||||
|
||||
@JvmField
|
||||
val POKEMON_INTERACT = this.create("pokemon_interact", SimpleCriterionTrigger(PokemonInteractCriterion.CODEC))
|
||||
|
||||
@JvmField
|
||||
val PARTY_CHECK = this.create("party", SimpleCriterionTrigger(PartyCheckCriterion.CODEC))
|
||||
|
||||
@JvmField
|
||||
val LEVEL_UP = this.create("level_up", SimpleCriterionTrigger(LevelUpCriterion.CODEC))
|
||||
|
||||
@JvmField
|
||||
val PASTURE_USE = this.create("pasture_use", SimpleCriterionTrigger(PokemonCriterion.CODEC))
|
||||
|
||||
@JvmField
|
||||
val RESURRECT_POKEMON = this.create("resurrect_pokemon", SimpleCriterionTrigger(PokemonCriterion.CODEC))
|
||||
|
||||
@JvmField
|
||||
val TRADE_POKEMON = this.create("trade_pokemon", SimpleCriterionTrigger(TradePokemonCriterion.CODEC))
|
||||
|
||||
@JvmField
|
||||
val CAST_POKE_ROD = this.create("cast_poke_rod", SimpleCriterionTrigger(CastPokeRodCriterionCondition.CODEC))
|
||||
|
||||
@JvmField
|
||||
val REEL_IN_POKEMON = this.create("reel_in_pokemon", SimpleCriterionTrigger(ReelInPokemonCriterionCondition.CODEC))
|
||||
|
||||
// Advancement criteria for [grow_tumblestone.json]
|
||||
@JvmField
|
||||
val PLANT_TUMBLESTONE = this.create("plant_tumblestone", SimpleCriterionTrigger(PlantTumblestoneCriterion.CODEC))
|
||||
|
||||
override val registry = BuiltInRegistries.TRIGGER_TYPES
|
||||
override val resourceKey = Registries.TRIGGER_TYPE
|
||||
}
|
||||
}
|
||||
@@ -70,16 +70,23 @@ object Abilities : DataRegistry {
|
||||
AbilityRegistrySyncPacket(all()).sendToPlayer(player)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun register(ability: AbilityTemplate): AbilityTemplate {
|
||||
this.abilityMap[ability.name.lowercase()] = ability
|
||||
return ability
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun all() = this.abilityMap.values.toList()
|
||||
@JvmStatic
|
||||
fun first() = this.abilityMap.values.first()
|
||||
@JvmStatic
|
||||
fun get(name: String) = abilityMap[name.lowercase()]
|
||||
@JvmStatic
|
||||
fun getOrDummy(name: String) = get(name) ?: DUMMY
|
||||
@JvmStatic
|
||||
fun getOrException(name: String) = get(name) ?: throw IllegalArgumentException("Unable to find ability of name: $name")
|
||||
@JvmStatic
|
||||
fun count() = this.abilityMap.size
|
||||
|
||||
internal fun receiveSyncPacket(abilities: Collection<AbilityTemplate>) {
|
||||
|
||||
+17
-3
@@ -11,8 +11,7 @@ package com.cobblemon.mod.common.api.ai.config.task
|
||||
import com.cobblemon.mod.common.api.ai.BehaviourConfigurationContext
|
||||
import com.cobblemon.mod.common.api.ai.asVariables
|
||||
import com.cobblemon.mod.common.api.ai.config.task.SharedEntityVariables.SEE_DISTANCE
|
||||
import com.cobblemon.mod.common.api.molang.MoLangFunctions.asMostSpecificMoLangValue
|
||||
import com.cobblemon.mod.common.util.withQueryValue
|
||||
import com.cobblemon.mod.common.util.resolveEntityTypes
|
||||
import net.minecraft.world.entity.LivingEntity
|
||||
import net.minecraft.world.entity.ai.behavior.BehaviorControl
|
||||
import net.minecraft.world.entity.ai.behavior.SetEntityLookTarget
|
||||
@@ -22,13 +21,16 @@ import net.minecraft.world.entity.ai.sensing.SensorType
|
||||
class LookAtEntitiesTaskConfig : SingleTaskConfig {
|
||||
companion object {
|
||||
const val LOOK_AT_ENTITIES = "look_at_entities"
|
||||
const val LOOK_AT_ENTITY_TYPES = "look_at_entity_types"
|
||||
}
|
||||
|
||||
val condition = booleanVariable(SharedEntityVariables.LOOKING_CATEGORY, LOOK_AT_ENTITIES, true).asExpressible()
|
||||
val maxDistance = numberVariable(SharedEntityVariables.LOOKING_CATEGORY, SEE_DISTANCE, 15).asExpressible()
|
||||
val entityTypes = stringVariable(SharedEntityVariables.LOOKING_CATEGORY, LOOK_AT_ENTITY_TYPES, "").asExpressible()
|
||||
|
||||
override fun getVariables(entity: LivingEntity, behaviourConfigurationContext: BehaviourConfigurationContext) = listOf(
|
||||
condition,
|
||||
entityTypes,
|
||||
maxDistance
|
||||
).asVariables()
|
||||
|
||||
@@ -39,6 +41,18 @@ class LookAtEntitiesTaskConfig : SingleTaskConfig {
|
||||
if (!condition.resolveBoolean(behaviourConfigurationContext.runtime)) return null
|
||||
behaviourConfigurationContext.addMemories(MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES, MemoryModuleType.LOOK_TARGET)
|
||||
behaviourConfigurationContext.addSensors(SensorType.NEAREST_LIVING_ENTITIES)
|
||||
return SetEntityLookTarget.create(maxDistance.resolveFloat(behaviourConfigurationContext.runtime))
|
||||
|
||||
val lookDistance = maxDistance.resolveFloat(behaviourConfigurationContext.runtime)
|
||||
val lookAtTypesText = entityTypes.resolveString(behaviourConfigurationContext.runtime)
|
||||
if (lookAtTypesText.isBlank()) {
|
||||
return SetEntityLookTarget.create(lookDistance)
|
||||
}
|
||||
|
||||
val lookAtTypes = resolveEntityTypes(entity.registryAccess(), lookAtTypesText)
|
||||
return if (lookAtTypes.isNotEmpty()) {
|
||||
SetEntityLookTarget.create({ lookAtTypes.contains(it.type) }, lookDistance)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -85,6 +85,7 @@ object Berries : JsonDataRegistry<Berry> {
|
||||
BerryRegistrySyncPacket(this.all()).sendToPlayer(player)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun all() = this.berries.values.toList()
|
||||
|
||||
/**
|
||||
@@ -93,6 +94,7 @@ object Berries : JsonDataRegistry<Berry> {
|
||||
* @param identifier The identifier of the berry.
|
||||
* @return The [Berry] if loaded otherwise null.
|
||||
*/
|
||||
@JvmStatic
|
||||
fun getByIdentifier(identifier: ResourceLocation): Berry? = this.berries[identifier]
|
||||
|
||||
/**
|
||||
@@ -101,6 +103,7 @@ object Berries : JsonDataRegistry<Berry> {
|
||||
* @param name The path of the identifier of the berry under the [Cobblemon.MODID] namespace.
|
||||
* @return The [Berry] if loaded otherwise null.
|
||||
*/
|
||||
@JvmStatic
|
||||
fun getByName(name: String): Berry? = this.getByIdentifier(cobblemonResource(name))
|
||||
|
||||
}
|
||||
+100
-25
@@ -9,8 +9,13 @@
|
||||
package com.cobblemon.mod.common.api.cooking
|
||||
|
||||
import com.cobblemon.mod.common.api.riding.stats.RidingStat
|
||||
import com.cobblemon.mod.common.util.math.geometry.toDegrees
|
||||
import com.cobblemon.mod.common.util.math.geometry.toRadians
|
||||
import net.minecraft.util.FastColor
|
||||
import net.minecraft.world.item.ItemStack
|
||||
import kotlin.math.atan2
|
||||
import kotlin.math.cos
|
||||
import kotlin.math.sin
|
||||
|
||||
private val colourMap = mapOf(
|
||||
Flavour.SPICY to 0xFEB37D,
|
||||
@@ -50,41 +55,111 @@ fun getColourMixFromFlavours(dominantFlavours: List<Flavour>, forBubbles: Boolea
|
||||
|
||||
if (colors.isEmpty()) return null
|
||||
|
||||
val (alphaSum, redSum, greenSum, blueSum) = colors.fold(IntArray(4)) { acc, color ->
|
||||
acc[0] += FastColor.ARGB32.alpha(color)
|
||||
acc[1] += FastColor.ARGB32.red(color)
|
||||
acc[2] += FastColor.ARGB32.green(color)
|
||||
acc[3] += FastColor.ARGB32.blue(color)
|
||||
acc
|
||||
}
|
||||
|
||||
return FastColor.ARGB32.color(
|
||||
alphaSum / colors.size,
|
||||
redSum / colors.size,
|
||||
greenSum / colors.size,
|
||||
blueSum / colors.size
|
||||
)
|
||||
return getColourMixFromColors(colors)
|
||||
}
|
||||
|
||||
fun getColourMixFromRideStatBoosts(dominantBoosts: Iterable<RidingStat>, forBubbles: Boolean = false): Int? {
|
||||
return getColourMixFromFlavours(dominantBoosts.map { it.flavour }, forBubbles)
|
||||
}
|
||||
|
||||
// Mixing RGB colors directly often gives poor results
|
||||
// Converting them to HSL and averaging hues circularly produces more natural blends
|
||||
fun getColourMixFromColors(colors: List<Int>): Int? {
|
||||
if (colors.isEmpty()) return null
|
||||
if (colors.size == 1) return colors[0]
|
||||
|
||||
val (alphaSum, redSum, greenSum, blueSum) = colors.fold(IntArray(4)) { acc, color ->
|
||||
acc[0] += FastColor.ARGB32.alpha(color)
|
||||
acc[1] += FastColor.ARGB32.red(color)
|
||||
acc[2] += FastColor.ARGB32.green(color)
|
||||
acc[3] += FastColor.ARGB32.blue(color)
|
||||
acc
|
||||
val hslColors = colors.map {
|
||||
val red = FastColor.ARGB32.red(it)
|
||||
val green = FastColor.ARGB32.green(it)
|
||||
val blue = FastColor.ARGB32.blue(it)
|
||||
|
||||
rgbToHsl(red, green, blue)
|
||||
}
|
||||
|
||||
return FastColor.ARGB32.color(
|
||||
alphaSum / colors.size,
|
||||
redSum / colors.size,
|
||||
greenSum / colors.size,
|
||||
blueSum / colors.size
|
||||
val hues = hslColors.map { it.h.toDouble() }
|
||||
val huesAverage = hueAverage(hues).toFloat()
|
||||
val saturations = hslColors.map { it.s }
|
||||
val saturationsAverage = average(saturations)
|
||||
val lightness = hslColors.map { it.l }
|
||||
val lightnessAverage = average(lightness)
|
||||
|
||||
val rgbColor = hslToRgb(huesAverage, saturationsAverage, lightnessAverage)
|
||||
|
||||
return FastColor.ARGB32.color(rgbColor.r, rgbColor.g, rgbColor.b)
|
||||
}
|
||||
|
||||
// Based on https://iter.ca/post/hue-avg
|
||||
fun hueAverage(hues: List<Double>): Float {
|
||||
val points = hues.map { hue ->
|
||||
val rad = hue.toRadians()
|
||||
Pair(cos(rad), sin(rad))
|
||||
}
|
||||
|
||||
val avgX = points.sumOf { it.first.toDouble() } / points.size
|
||||
val avgY = points.sumOf { it.second.toDouble() } / points.size
|
||||
|
||||
var degrees = atan2(avgY, avgX).toDegrees()
|
||||
if (degrees < 0) {
|
||||
degrees += 360f
|
||||
} else if (degrees > 360) {
|
||||
degrees -= 360f
|
||||
}
|
||||
|
||||
return degrees
|
||||
}
|
||||
|
||||
fun average(values: List<Float>): Float {
|
||||
if (values.isEmpty()) return 0f
|
||||
return values.sum() / values.size
|
||||
}
|
||||
|
||||
data class HSL(val h: Float, val s: Float, val l: Float)
|
||||
|
||||
fun rgbToHsl(r: Int, g: Int, b: Int): HSL {
|
||||
val rf = r / 255f
|
||||
val gf = g / 255f
|
||||
val bf = b / 255f
|
||||
|
||||
val max = maxOf(rf, gf, bf)
|
||||
val min = minOf(rf, gf, bf)
|
||||
val delta = max - min
|
||||
|
||||
var h = 0f
|
||||
val l = (max + min) / 2f
|
||||
val s = if (delta == 0f) 0f else delta / (1f - kotlin.math.abs(2f * l - 1f))
|
||||
|
||||
if (delta != 0f) {
|
||||
h = when (max) {
|
||||
rf -> ((gf - bf) / delta) % 6f
|
||||
gf -> ((bf - rf) / delta) + 2f
|
||||
else -> ((rf - gf) / delta) + 4f
|
||||
}
|
||||
h *= 60f
|
||||
if (h < 0) h += 360f
|
||||
}
|
||||
|
||||
return HSL(h, s, l)
|
||||
}
|
||||
|
||||
data class RGB(val r: Int, val g: Int, val b: Int)
|
||||
|
||||
fun hslToRgb(h: Float, s: Float, l: Float): RGB {
|
||||
val c = (1f - kotlin.math.abs(2f * l - 1f)) * s
|
||||
val x = c * (1f - kotlin.math.abs((h / 60f) % 2f - 1f))
|
||||
val m = l - c / 2f
|
||||
|
||||
val (rf, gf, bf) = when {
|
||||
h < 60f -> Triple(c, x, 0f)
|
||||
h < 120f -> Triple(x, c, 0f)
|
||||
h < 180f -> Triple(0f, c, x)
|
||||
h < 240f -> Triple(0f, x, c)
|
||||
h < 300f -> Triple(x, 0f, c)
|
||||
else -> Triple(c, 0f, x)
|
||||
}
|
||||
|
||||
return RGB(
|
||||
((rf + m) * 255).toInt().coerceIn(0, 255),
|
||||
((gf + m) * 255).toInt().coerceIn(0, 255),
|
||||
((bf + m) * 255).toInt().coerceIn(0, 255)
|
||||
)
|
||||
}
|
||||
@@ -28,12 +28,14 @@ import net.minecraft.server.level.ServerPlayer
|
||||
object DialogueManager {
|
||||
val activeDialogues = mutableMapOf<UUID, ActiveDialogue>()
|
||||
|
||||
@JvmStatic
|
||||
fun startDialogue(playerEntity: ServerPlayer, dialogue: Dialogue): ActiveDialogue {
|
||||
val activeDialogue = ActiveDialogue(playerEntity, dialogue)
|
||||
startDialogue(activeDialogue)
|
||||
return activeDialogue
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun startDialogue(playerEntity: ServerPlayer, npcEntity: NPCEntity, dialogue: Dialogue): ActiveDialogue {
|
||||
val activeDialogue = ActiveDialogue(playerEntity, dialogue)
|
||||
activeDialogue.runtime.withNPCValue("npc", npcEntity)
|
||||
@@ -42,6 +44,7 @@ object DialogueManager {
|
||||
return activeDialogue
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun startDialogue(activeDialogue: ActiveDialogue) {
|
||||
activeDialogue.initialize()
|
||||
if (!activeDialogue.completion.isDone) {
|
||||
@@ -49,6 +52,7 @@ object DialogueManager {
|
||||
}
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun stopDialogue(playerEntity: ServerPlayer) {
|
||||
val activeDialogue = playerEntity.activeDialogue ?: return
|
||||
DialogueClosedPacket(activeDialogue.dialogueId).sendToPlayer(playerEntity)
|
||||
|
||||
@@ -10,14 +10,12 @@ package com.cobblemon.mod.common.api.drop
|
||||
|
||||
import com.cobblemon.mod.common.api.events.CobblemonEvents.LOOT_DROPPED
|
||||
import com.cobblemon.mod.common.api.events.drops.LootDroppedEvent
|
||||
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity
|
||||
import com.cobblemon.mod.common.pokemon.Pokemon
|
||||
import kotlin.random.Random
|
||||
import net.minecraft.network.RegistryFriendlyByteBuf
|
||||
import net.minecraft.server.level.ServerLevel
|
||||
import net.minecraft.server.level.ServerPlayer
|
||||
import net.minecraft.world.entity.LivingEntity
|
||||
import net.minecraft.world.item.ItemStack
|
||||
import net.minecraft.world.phys.Vec3
|
||||
|
||||
/**
|
||||
@@ -95,6 +93,16 @@ class DropTable {
|
||||
pokemon: Pokemon? = null,
|
||||
) {
|
||||
val drops = getDrops(amount, pokemon).toMutableList()
|
||||
postLootDroppedEvent(drops, entity, world, pos, player)
|
||||
}
|
||||
|
||||
fun postLootDroppedEvent(
|
||||
drops: MutableList<DropEntry>,
|
||||
entity: LivingEntity?,
|
||||
world: ServerLevel,
|
||||
pos: Vec3,
|
||||
player: ServerPlayer?,
|
||||
) {
|
||||
LOOT_DROPPED.postThen(
|
||||
event = LootDroppedEvent(this, player, entity, drops),
|
||||
ifSucceeded = { it.drops.forEach { it.drop(entity, world, pos, player) } }
|
||||
@@ -110,4 +118,4 @@ class DropTable {
|
||||
val entries = buffer.readInt()
|
||||
repeat(entries) { this.entries.add(ItemDropEntry().decode(buffer)) }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,7 @@ import com.cobblemon.mod.common.api.events.berry.BerryHarvestEvent
|
||||
import com.cobblemon.mod.common.api.events.berry.BerryMutationOfferEvent
|
||||
import com.cobblemon.mod.common.api.events.berry.BerryMutationResultEvent
|
||||
import com.cobblemon.mod.common.api.events.berry.BerryYieldCalculationEvent
|
||||
import com.cobblemon.mod.common.api.events.cooking.PokeSnackSpawnPokemonEvent
|
||||
import com.cobblemon.mod.common.api.events.drops.LootDroppedEvent
|
||||
import com.cobblemon.mod.common.api.events.entity.*
|
||||
import com.cobblemon.mod.common.api.events.farming.ApricornHarvestEvent
|
||||
@@ -327,6 +328,12 @@ object CobblemonEvents {
|
||||
@JvmField
|
||||
val BOBBER_SPAWN_POKEMON_POST = EventObservable<BobberSpawnPokemonEvent.Post>()
|
||||
|
||||
@JvmField
|
||||
val POKE_SNACK_SPAWN_POKEMON_PRE = CancelableObservable<PokeSnackSpawnPokemonEvent.Pre>()
|
||||
|
||||
@JvmField
|
||||
val POKE_SNACK_SPAWN_POKEMON_POST = EventObservable<PokeSnackSpawnPokemonEvent.Post>()
|
||||
|
||||
@JvmField
|
||||
val BAIT_EFFECT_REGISTRATION = EventObservable<BaitEffectFunctionRegistryEvent>()
|
||||
|
||||
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* 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.events.cooking
|
||||
|
||||
import com.bedrockk.molang.runtime.value.MoValue
|
||||
import com.cobblemon.mod.common.api.events.Cancelable
|
||||
import com.cobblemon.mod.common.api.molang.MoLangFunctions.moLangFunctionMap
|
||||
import com.cobblemon.mod.common.api.spawning.detail.SpawnAction
|
||||
import com.cobblemon.mod.common.block.entity.PokeSnackBlockEntity
|
||||
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity
|
||||
|
||||
interface PokeSnackSpawnPokemonEvent {
|
||||
|
||||
data class Pre(
|
||||
val pokeSnackBlockEntity: PokeSnackBlockEntity,
|
||||
val spawnAction: SpawnAction<*>,
|
||||
) : Cancelable(), PokeSnackSpawnPokemonEvent {
|
||||
val context = mapOf<String, MoValue>()
|
||||
val functions = moLangFunctionMap(
|
||||
cancelFunc
|
||||
)
|
||||
}
|
||||
|
||||
data class Post(
|
||||
val pokeSnackBlockEntity: PokeSnackBlockEntity,
|
||||
val spawnAction: SpawnAction<*>,
|
||||
val pokemonEntity: PokemonEntity,
|
||||
) : PokeSnackSpawnPokemonEvent {
|
||||
val context = mapOf<String, MoValue>()
|
||||
}
|
||||
|
||||
}
|
||||
@@ -57,6 +57,7 @@ object PokeRods : JsonDataRegistry<PokeRod> {
|
||||
* Gets a Pokerod from registry name.
|
||||
* @return the pokerod object if found otherwise null.
|
||||
*/
|
||||
@JvmStatic
|
||||
fun getPokeRod(name : ResourceLocation): PokeRod? = rods[name]
|
||||
|
||||
}
|
||||
@@ -68,6 +68,7 @@ class SpawnBait(
|
||||
val TYPING = cobblemonResource("typing")
|
||||
val EGG_GROUP = cobblemonResource("egg_group")
|
||||
val SHINY_REROLL = cobblemonResource("shiny_reroll")
|
||||
val DROPS_REROLL = cobblemonResource("drops_reroll")
|
||||
val HIDDEN_ABILITY_CHANCE = cobblemonResource("ha_chance")
|
||||
val POKEMON_CHANCE = cobblemonResource("pokemon_chance")
|
||||
val FRIENDSHIP = cobblemonResource("friendship")
|
||||
@@ -85,6 +86,7 @@ class SpawnBait(
|
||||
registerEffect(NATURE) { entity, effect -> FishingSpawnCause.alterNatureAttempt(entity, effect) }
|
||||
registerEffect(IV) { entity, effect -> FishingSpawnCause.alterIVAttempt(entity, effect) }
|
||||
registerEffect(SHINY_REROLL) { entity, effect -> FishingSpawnCause.shinyReroll(entity, effect) }
|
||||
registerEffect(DROPS_REROLL) { entity, effect -> FishingSpawnCause.saveDropsReroll(entity, effect) }
|
||||
registerEffect(GENDER_CHANCE) { entity, effect -> FishingSpawnCause.alterGenderAttempt(entity, effect) }
|
||||
registerEffect(LEVEL_RAISE) { entity, effect -> FishingSpawnCause.alterLevelAttempt(entity, effect) }
|
||||
registerEffect(HIDDEN_ABILITY_CHANCE) { entity, _ -> FishingSpawnCause.alterHAAttempt(entity) }
|
||||
|
||||
@@ -53,20 +53,24 @@ object SpawnBaitEffects : JsonDataRegistry<SpawnBait> {
|
||||
}
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getEffectsFromRodItemStack(stack: ItemStack): List<SpawnBait.Effect> {
|
||||
return getEffectsFromItemStack(stack.components.get(CobblemonItemComponents.BAIT)?.stack ?: ItemStack.EMPTY)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getEffectsFromItemStack(stack: ItemStack): List<SpawnBait.Effect> {
|
||||
val componentEffects = stack.get(CobblemonItemComponents.BAIT_EFFECTS)?.effects ?: emptyList()
|
||||
return componentEffects.mapNotNull(::getFromIdentifier).flatMap { it.effects } +
|
||||
getEffectsFromItem(stack.itemHolder)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getBaitIdentifiersFromItem(holder: Holder<Item>): List<ResourceLocation> {
|
||||
return effectsMap.entries.filter { it.value.item.fits(holder) }.map { it.key }
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getBaitFromItemStack(holder: Holder<Item>): List<SpawnBait> {
|
||||
return effectsMap.values.filter { it.item.fits(holder) }
|
||||
}
|
||||
@@ -75,6 +79,7 @@ object SpawnBaitEffects : JsonDataRegistry<SpawnBait> {
|
||||
return getBaitFromItemStack(holder).flatMap { it.effects }
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getFromIdentifier(identifier: ResourceLocation): SpawnBait? {
|
||||
// Check normal spawn bait registry
|
||||
effectsMap[identifier]?.let { return it }
|
||||
@@ -98,6 +103,7 @@ object SpawnBaitEffects : JsonDataRegistry<SpawnBait> {
|
||||
}
|
||||
|
||||
// if it has bait effects and is not listed as a seasoning then it is a bait
|
||||
@JvmStatic
|
||||
fun isFishingBait(stack: ItemStack): Boolean {
|
||||
val holder = stack.itemHolder
|
||||
return effectsMap.values.any { it.item.fits(holder) }
|
||||
|
||||
@@ -11,6 +11,7 @@ package com.cobblemon.mod.common.api.fishing
|
||||
import kotlin.math.ceil
|
||||
|
||||
object SpawnBaitUtils {
|
||||
@JvmStatic
|
||||
fun mergeEffects(effects: List<SpawnBait.Effect>): List<SpawnBait.Effect> {
|
||||
val grouped = effects.groupBy { Pair(it.type, it.subcategory) }
|
||||
|
||||
|
||||
@@ -69,6 +69,7 @@ object Fossils: JsonDataRegistry<Fossil> {
|
||||
/**
|
||||
* Gets all loaded [Fossil]s.
|
||||
*/
|
||||
@JvmStatic
|
||||
fun all() = this.fossils.values.toList()
|
||||
|
||||
/**
|
||||
@@ -76,6 +77,7 @@ object Fossils: JsonDataRegistry<Fossil> {
|
||||
* @param identifier The identifier of the fossil.
|
||||
* @return The [Fossil] if loaded, otherwise null.
|
||||
*/
|
||||
@JvmStatic
|
||||
fun getByIdentifier(identifier: ResourceLocation): Fossil? = this.fossils[identifier]
|
||||
|
||||
/**
|
||||
@@ -83,6 +85,7 @@ object Fossils: JsonDataRegistry<Fossil> {
|
||||
* @param fossilStacks The fossil [ItemStack]'s.
|
||||
* @return The [Fossil] if found, otherwise null.
|
||||
*/
|
||||
@JvmStatic
|
||||
fun getFossilByItemStacks(fossilStacks: List<ItemStack>): Fossil? {
|
||||
return this.all().firstOrNull { it.matchesIngredients(fossilStacks) }
|
||||
}
|
||||
@@ -92,6 +95,7 @@ object Fossils: JsonDataRegistry<Fossil> {
|
||||
* @param fossilStacks The fossil [ItemStack]'s.
|
||||
* @return The [Fossil] if found to be a superset, otherwise null.
|
||||
*/
|
||||
@JvmStatic
|
||||
fun getSubFossilByItemStacks(fossilStacks: List<ItemStack>): Fossil? {
|
||||
return this.all().firstOrNull { it.matchesIngredientsSubSet(fossilStacks) }
|
||||
}
|
||||
@@ -100,6 +104,7 @@ object Fossils: JsonDataRegistry<Fossil> {
|
||||
* @param itemStack The ingredient [ItemStack].
|
||||
* @return true if it's a fossil ingredient, otherwise false.
|
||||
*/
|
||||
@JvmStatic
|
||||
fun isFossilIngredient(itemStack: ItemStack): Boolean {
|
||||
return this.all().any { it.isIngredient(itemStack) }
|
||||
}
|
||||
|
||||
@@ -57,6 +57,7 @@ object NaturalMaterials : JsonDataRegistry<List<NaturalMaterial>>{
|
||||
}
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun isNaturalMaterial(item: ItemStack): Boolean {
|
||||
val itemId = BuiltInRegistries.ITEM.getKey(item.item)
|
||||
return itemId in itemMap.keys || tagMap.keys.any {
|
||||
@@ -64,6 +65,7 @@ object NaturalMaterials : JsonDataRegistry<List<NaturalMaterial>>{
|
||||
}
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getContent(item: ItemStack): Int? {
|
||||
val itemId = BuiltInRegistries.ITEM.getKey(item.item)
|
||||
if (itemId in itemMap.keys) {
|
||||
@@ -76,6 +78,7 @@ object NaturalMaterials : JsonDataRegistry<List<NaturalMaterial>>{
|
||||
return null
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getReturnItem(item: ItemStack): ResourceLocation? {
|
||||
val itemId = BuiltInRegistries.ITEM.getKey(item.item)
|
||||
if (itemId in itemMap.keys) {
|
||||
@@ -87,4 +90,4 @@ object NaturalMaterials : JsonDataRegistry<List<NaturalMaterial>>{
|
||||
}
|
||||
return null
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -56,7 +56,9 @@ object Marks: JsonDataRegistry<Mark> {
|
||||
/**
|
||||
* Gets all loaded [Mark]s.
|
||||
*/
|
||||
@JvmStatic
|
||||
fun all() = this.marks.values.toList()
|
||||
@JvmStatic
|
||||
fun identifiers(): Collection<String> = marks.keys.toSet().map { it.toString() }
|
||||
|
||||
/**
|
||||
@@ -64,5 +66,6 @@ object Marks: JsonDataRegistry<Mark> {
|
||||
* @param identifier The identifier of the mark.
|
||||
* @return The [Mark] if loaded, otherwise null.
|
||||
*/
|
||||
@JvmStatic
|
||||
fun getByIdentifier(identifier: ResourceLocation): Mark? = this.marks[identifier]
|
||||
}
|
||||
}
|
||||
@@ -590,10 +590,10 @@ object MoLangFunctions {
|
||||
}
|
||||
if (player is ServerPlayer) {
|
||||
map.put("seen_credits") { _ ->
|
||||
DoubleValue( DoubleValue(player.seenCredits) )
|
||||
DoubleValue(player.seenCredits)
|
||||
}
|
||||
map.put("is_in_dialogue") { _ ->
|
||||
DoubleValue( DoubleValue(player.isInDialogue) )
|
||||
DoubleValue(player.isInDialogue)
|
||||
}
|
||||
map.put("active_dialogue") { _ ->
|
||||
if (player.isInDialogue) {
|
||||
@@ -2655,5 +2655,4 @@ object MoLangFunctions {
|
||||
}
|
||||
}
|
||||
|
||||
fun Either<ResourceLocation, ExpressionLike>.runScript(runtime: MoLangRuntime) = map({ CobblemonScripts.run(it, runtime) }, { it.resolve(runtime) })
|
||||
|
||||
fun Either<ResourceLocation, ExpressionLike>.runScript(runtime: MoLangRuntime) = map({ CobblemonScripts.run(it, runtime) }, { it.resolve(runtime) })
|
||||
@@ -9,8 +9,8 @@
|
||||
package com.cobblemon.mod.common.api.molang
|
||||
|
||||
import com.bedrockk.molang.runtime.MoLangRuntime
|
||||
import com.bedrockk.molang.runtime.value.DoubleValue
|
||||
import com.bedrockk.molang.runtime.value.MoValue
|
||||
import com.bedrockk.molang.runtime.value.StringValue
|
||||
import com.cobblemon.mod.common.api.scripting.CobblemonScripts
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
|
||||
@@ -23,11 +23,11 @@ import net.minecraft.resources.ResourceLocation
|
||||
*/
|
||||
class ReferenceExpression(val identifier: ResourceLocation) : ExpressionLike {
|
||||
override fun resolve(runtime: MoLangRuntime, context: Map<String, MoValue>): MoValue {
|
||||
return getScript()?.resolve(runtime, context) ?: DoubleValue.ZERO
|
||||
return getScript()?.resolve(runtime, context) ?: StringValue(identifier.toString())
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
return getScript()?.getString() ?: "0"
|
||||
return getScript()?.getString() ?: identifier.toString()
|
||||
}
|
||||
|
||||
fun getScript() = CobblemonScripts.scripts[identifier]
|
||||
|
||||
@@ -33,6 +33,7 @@ object HiddenPowerUtil {
|
||||
ElementalTypes.DARK
|
||||
)
|
||||
|
||||
@JvmStatic
|
||||
fun getHiddenPowerType(pokemon: Pokemon?): ElementalType {
|
||||
if (pokemon == null) {
|
||||
return ElementalTypes.NORMAL
|
||||
|
||||
@@ -106,12 +106,19 @@ object Moves : DataRegistry {
|
||||
MovesRegistrySyncPacket(all()).sendToPlayer(player)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getByName(name: String) = allMoves[name.lowercase()]
|
||||
@JvmStatic
|
||||
fun getByNumericalId(id: Int) = idMapping[id]
|
||||
@JvmStatic
|
||||
fun getByNameOrDummy(name: String) = allMoves[name.lowercase()] ?: MoveTemplate.dummy(name.lowercase())
|
||||
@JvmStatic
|
||||
fun getExceptional() = getByName("tackle") ?: allMoves.values.random()
|
||||
@JvmStatic
|
||||
fun count() = allMoves.size
|
||||
@JvmStatic
|
||||
fun names(): Collection<String> = this.allMoves.keys.toSet()
|
||||
@JvmStatic
|
||||
fun all() = this.allMoves.values.toList()
|
||||
|
||||
internal fun receiveSyncPacket(moves: Collection<MoveTemplate>) {
|
||||
|
||||
@@ -97,6 +97,7 @@ object NPCClasses : JsonDataRegistry<NPCClass> {
|
||||
override val observable = SimpleObservable<NPCClasses>()
|
||||
private val npcClassesByIdentifier = hashMapOf<ResourceLocation, NPCClass>()
|
||||
|
||||
@JvmStatic
|
||||
val classes: Collection<NPCClass>
|
||||
get() = this.npcClassesByIdentifier.values
|
||||
|
||||
@@ -116,6 +117,7 @@ object NPCClasses : JsonDataRegistry<NPCClass> {
|
||||
* @param identifier The unique [NPCClass.id] of the [NPCClass].
|
||||
* @return The [NPCClass] if existing.
|
||||
*/
|
||||
@JvmStatic
|
||||
fun getByIdentifier(identifier: ResourceLocation) = this.npcClassesByIdentifier[identifier]
|
||||
|
||||
/**
|
||||
@@ -123,6 +125,7 @@ object NPCClasses : JsonDataRegistry<NPCClass> {
|
||||
*
|
||||
* @return The loaded NPC class amount.
|
||||
*/
|
||||
@JvmStatic
|
||||
fun count() = this.npcClassesByIdentifier.size
|
||||
|
||||
/**
|
||||
@@ -132,6 +135,7 @@ object NPCClasses : JsonDataRegistry<NPCClass> {
|
||||
*
|
||||
* @return A randomly selected [Species].
|
||||
*/
|
||||
@JvmStatic
|
||||
fun random(): NPCClass = this.npcClassesByIdentifier.values.random()
|
||||
|
||||
fun dummy(): NPCClass {
|
||||
|
||||
@@ -102,6 +102,7 @@ object NPCPresets : JsonDataRegistry<NPCPreset> {
|
||||
observable.emit(this)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getPreset(identifier: ResourceLocation): NPCPreset? {
|
||||
return npcPresetsByIdentifier[identifier]
|
||||
}
|
||||
|
||||
@@ -23,11 +23,14 @@ object PastureLinkManager {
|
||||
// Maps player UUID
|
||||
val links = mutableMapOf<UUID, PastureLink>()
|
||||
|
||||
@JvmStatic
|
||||
fun getLinkByPlayerId(playerId: UUID) = links[playerId]
|
||||
@JvmStatic
|
||||
fun createLink(playerId: UUID, link: PastureLink) {
|
||||
links[playerId] = link
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getLinkByPlayer(player: ServerPlayer): PastureLink? {
|
||||
val link = getLinkByPlayerId(player.uuid)
|
||||
if (link != null) {
|
||||
@@ -40,6 +43,7 @@ object PastureLinkManager {
|
||||
return link
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun removeAt(world: ServerLevel, pos: BlockPos) {
|
||||
links.removeIf { (uuid, pastureLink) ->
|
||||
val shouldRemove = world.dimensionTypeRegistration().`is`(pastureLink.dimension) && pastureLink.pos == pos
|
||||
|
||||
+1
@@ -28,6 +28,7 @@ import net.minecraft.server.level.ServerPlayer
|
||||
object PasturePermissionControllers {
|
||||
val controllers = PrioritizedList<PasturePermissionController>()
|
||||
|
||||
@JvmStatic
|
||||
fun permit(player: ServerPlayer, pastureBlockEntity: PokemonPastureBlockEntity): PasturePermissions {
|
||||
return controllers.firstNotNullOfOrNull { it.permit(player, pastureBlockEntity) }
|
||||
?: PasturePermissions(
|
||||
|
||||
@@ -147,6 +147,7 @@ object CobblemonPermissions {
|
||||
@JvmStatic
|
||||
val SEE_HIDDEN_NPCS = this.create("seehiddennpcs", PermissionLevel.CHEAT_COMMANDS_AND_COMMAND_BLOCKS)
|
||||
|
||||
@JvmStatic
|
||||
fun all(): Iterable<Permission> = this.permissions
|
||||
|
||||
private fun create(node: String, level: PermissionLevel): Permission {
|
||||
|
||||
@@ -53,100 +53,196 @@ object PokeBalls : JsonDataRegistry<PokeBall> {
|
||||
// ToDo datapack pokeball type here instead
|
||||
private val custom = hashMapOf<ResourceLocation, PokeBall>()
|
||||
|
||||
@JvmStatic
|
||||
@get:JvmName("getPokeBall")
|
||||
val POKE_BALL
|
||||
get() = this.byName("poke_ball")
|
||||
@JvmStatic
|
||||
@get:JvmName("getSlateBall")
|
||||
val SLATE_BALL
|
||||
get() = this.byName("slate_ball")
|
||||
@JvmStatic
|
||||
@get:JvmName("getAzureBall")
|
||||
val AZURE_BALL
|
||||
get() = this.byName("azure_ball")
|
||||
@JvmStatic
|
||||
@get:JvmName("getVerdantBall")
|
||||
val VERDANT_BALL
|
||||
get() = this.byName("verdant_ball")
|
||||
@JvmStatic
|
||||
@get:JvmName("getRoseateBall")
|
||||
val ROSEATE_BALL
|
||||
get() = this.byName("roseate_ball")
|
||||
@JvmStatic
|
||||
@get:JvmName("getCitrineBall")
|
||||
val CITRINE_BALL
|
||||
get() = this.byName("citrine_ball")
|
||||
@JvmStatic
|
||||
@get:JvmName("getGreatBall")
|
||||
val GREAT_BALL
|
||||
get() = this.byName("great_ball")
|
||||
@JvmStatic
|
||||
@get:JvmName("getUltraBall")
|
||||
val ULTRA_BALL
|
||||
get() = this.byName("ultra_ball")
|
||||
@JvmStatic
|
||||
@get:JvmName("getMasterBall")
|
||||
val MASTER_BALL
|
||||
get() = this.byName("master_ball")
|
||||
@JvmStatic
|
||||
@get:JvmName("getSafariBall")
|
||||
val SAFARI_BALL
|
||||
get() = this.byName("safari_ball")
|
||||
@JvmStatic
|
||||
@get:JvmName("getFastBall")
|
||||
val FAST_BALL
|
||||
get() = this.byName("fast_ball")
|
||||
@JvmStatic
|
||||
@get:JvmName("getLevelBall")
|
||||
val LEVEL_BALL
|
||||
get() = this.byName("level_ball")
|
||||
@JvmStatic
|
||||
@get:JvmName("getLureBall")
|
||||
val LURE_BALL
|
||||
get() = this.byName("lure_ball")
|
||||
@JvmStatic
|
||||
@get:JvmName("getHeavyBall")
|
||||
val HEAVY_BALL
|
||||
get() = this.byName("heavy_ball")
|
||||
@JvmStatic
|
||||
@get:JvmName("getLoveBall")
|
||||
val LOVE_BALL
|
||||
get() = this.byName("love_ball")
|
||||
@JvmStatic
|
||||
@get:JvmName("getFriendBall")
|
||||
val FRIEND_BALL
|
||||
get() = this.byName("friend_ball")
|
||||
@JvmStatic
|
||||
@get:JvmName("getMoonBall")
|
||||
val MOON_BALL
|
||||
get() = this.byName("moon_ball")
|
||||
@JvmStatic
|
||||
@get:JvmName("getSportBall")
|
||||
val SPORT_BALL
|
||||
get() = this.byName("sport_ball")
|
||||
@JvmStatic
|
||||
@get:JvmName("getNetBall")
|
||||
val NET_BALL
|
||||
get() = this.byName("net_ball")
|
||||
@JvmStatic
|
||||
@get:JvmName("getDiveBall")
|
||||
val DIVE_BALL
|
||||
get() = this.byName("dive_ball")
|
||||
@JvmStatic
|
||||
@get:JvmName("getNestBall")
|
||||
val NEST_BALL
|
||||
get() = this.byName("nest_ball")
|
||||
@JvmStatic
|
||||
@get:JvmName("getRepeatBall")
|
||||
val REPEAT_BALL
|
||||
get() = this.byName("repeat_ball")
|
||||
@JvmStatic
|
||||
@get:JvmName("getTimerBall")
|
||||
val TIMER_BALL
|
||||
get() = this.byName("timer_ball")
|
||||
@JvmStatic
|
||||
@get:JvmName("getLuxuryBall")
|
||||
val LUXURY_BALL
|
||||
get() = this.byName("luxury_ball")
|
||||
@JvmStatic
|
||||
@get:JvmName("getPremierBall")
|
||||
val PREMIER_BALL
|
||||
get() = this.byName("premier_ball")
|
||||
@JvmStatic
|
||||
@get:JvmName("getDuskBall")
|
||||
val DUSK_BALL
|
||||
get() = this.byName("dusk_ball")
|
||||
@JvmStatic
|
||||
@get:JvmName("getHealBall")
|
||||
val HEAL_BALL
|
||||
get() = this.byName("heal_ball")
|
||||
@JvmStatic
|
||||
@get:JvmName("getQuickBall")
|
||||
val QUICK_BALL
|
||||
get() = this.byName("quick_ball")
|
||||
@JvmStatic
|
||||
@get:JvmName("getCherishBall")
|
||||
val CHERISH_BALL
|
||||
get() = this.byName("cherish_ball")
|
||||
@JvmStatic
|
||||
@get:JvmName("getParkBall")
|
||||
val PARK_BALL
|
||||
get() = this.byName("park_ball")
|
||||
@JvmStatic
|
||||
@get:JvmName("getDreamBall")
|
||||
val DREAM_BALL
|
||||
get() = this.byName("dream_ball")
|
||||
@JvmStatic
|
||||
@get:JvmName("getBeastBall")
|
||||
val BEAST_BALL
|
||||
get() = this.byName("beast_ball")
|
||||
@JvmStatic
|
||||
@get:JvmName("getAncientPokeBall")
|
||||
val ANCIENT_POKE_BALL
|
||||
get() = this.byName("ancient_poke_ball")
|
||||
@JvmStatic
|
||||
@get:JvmName("getAncientCitrineBall")
|
||||
val ANCIENT_CITRINE_BALL
|
||||
get() = this.byName("ancient_citrine_ball")
|
||||
@JvmStatic
|
||||
@get:JvmName("getAncientVerdantBall")
|
||||
val ANCIENT_VERDANT_BALL
|
||||
get() = this.byName("ancient_verdant_ball")
|
||||
@JvmStatic
|
||||
@get:JvmName("getAncientAzureBall")
|
||||
val ANCIENT_AZURE_BALL
|
||||
get() = this.byName("ancient_azure_ball")
|
||||
@JvmStatic
|
||||
@get:JvmName("getAncientRoseateBall")
|
||||
val ANCIENT_ROSEATE_BALL
|
||||
get() = this.byName("ancient_roseate_ball")
|
||||
@JvmStatic
|
||||
@get:JvmName("getAncientSlateBall")
|
||||
val ANCIENT_SLATE_BALL
|
||||
get() = this.byName("ancient_slate_ball")
|
||||
@JvmStatic
|
||||
@get:JvmName("getAncientIvoryBall")
|
||||
val ANCIENT_IVORY_BALL
|
||||
get() = this.byName("ancient_ivory_ball")
|
||||
@JvmStatic
|
||||
@get:JvmName("getAncientGreatBall")
|
||||
val ANCIENT_GREAT_BALL
|
||||
get() = this.byName("ancient_great_ball")
|
||||
@JvmStatic
|
||||
@get:JvmName("getAncientUltraBall")
|
||||
val ANCIENT_ULTRA_BALL
|
||||
get() = this.byName("ancient_ultra_ball")
|
||||
@JvmStatic
|
||||
@get:JvmName("getAncientHeavyBall")
|
||||
val ANCIENT_HEAVY_BALL
|
||||
get() = this.byName("ancient_heavy_ball")
|
||||
@JvmStatic
|
||||
@get:JvmName("getAncientLeadenBall")
|
||||
val ANCIENT_LEADEN_BALL
|
||||
get() = this.byName("ancient_leaden_ball")
|
||||
@JvmStatic
|
||||
@get:JvmName("getAncientGigatonBall")
|
||||
val ANCIENT_GIGATON_BALL
|
||||
get() = this.byName("ancient_gigaton_ball")
|
||||
@JvmStatic
|
||||
@get:JvmName("getAncientFeatherBall")
|
||||
val ANCIENT_FEATHER_BALL
|
||||
get() = this.byName("ancient_feather_ball")
|
||||
@JvmStatic
|
||||
@get:JvmName("getAncientWingBall")
|
||||
val ANCIENT_WING_BALL
|
||||
get() = this.byName("ancient_wing_ball")
|
||||
@JvmStatic
|
||||
@get:JvmName("getAncientJetBall")
|
||||
val ANCIENT_JET_BALL
|
||||
get() = this.byName("ancient_jet_ball")
|
||||
@JvmStatic
|
||||
@get:JvmName("getAncientOriginBall")
|
||||
val ANCIENT_ORIGIN_BALL
|
||||
get() = this.byName("ancient_origin_ball")
|
||||
|
||||
@@ -225,8 +321,10 @@ object PokeBalls : JsonDataRegistry<PokeBall> {
|
||||
* Gets a Pokeball from registry name.
|
||||
* @return the pokeball object if found otherwise null.
|
||||
*/
|
||||
@JvmStatic
|
||||
fun getPokeBall(name : ResourceLocation): PokeBall? = this.custom[name] ?: this.defaults[name]
|
||||
|
||||
@JvmStatic
|
||||
fun all() = this.defaults.filterKeys { !this.custom.containsKey(it) }.values + this.custom.values
|
||||
|
||||
private fun createDefault(
|
||||
@@ -250,4 +348,196 @@ object PokeBalls : JsonDataRegistry<PokeBall> {
|
||||
val identifier = cobblemonResource(name)
|
||||
return this.custom[identifier] ?: this.defaults[identifier]!!
|
||||
}
|
||||
|
||||
/**
|
||||
* Backwards compatibility getters
|
||||
*/
|
||||
@JvmName("getPOKE_BALL")
|
||||
@Deprecated("Use PokeBalls.getPokeBall(), provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getPOKE_BALL() = POKE_BALL
|
||||
|
||||
@JvmName("getSLATE_BALL")
|
||||
@Deprecated("Use PokeBalls.getSlateBall(), provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getSLATE_BALL() = SLATE_BALL
|
||||
|
||||
@JvmName("getAZURE_BALL")
|
||||
@Deprecated("Use PokeBalls.getAzureBall(), provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getAZURE_BALL() = AZURE_BALL
|
||||
|
||||
@JvmName("getVERDANT_BALL")
|
||||
@Deprecated("Use PokeBalls.getVerdantBall(), provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getVERDANT_BALL() = VERDANT_BALL
|
||||
|
||||
@JvmName("getROSEATE_BALL")
|
||||
@Deprecated("Use PokeBalls.getRoseateBall(), provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getROSEATE_BALL() = ROSEATE_BALL
|
||||
|
||||
@JvmName("getCITRINE_BALL")
|
||||
@Deprecated("Use PokeBalls.getCitrineBall(), provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getCITRINE_BALL() = CITRINE_BALL
|
||||
|
||||
@JvmName("getGREAT_BALL")
|
||||
@Deprecated("Use PokeBalls.getGreatBall(), provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getGREAT_BALL() = GREAT_BALL
|
||||
|
||||
@JvmName("getULTRA_BALL")
|
||||
@Deprecated("Use PokeBalls.getUltraBall(), provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getULTRA_BALL() = ULTRA_BALL
|
||||
|
||||
@JvmName("getMASTER_BALL")
|
||||
@Deprecated("Use PokeBalls.getMasterBall(), provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getMASTER_BALL() = MASTER_BALL
|
||||
|
||||
@JvmName("getSAFARI_BALL")
|
||||
@Deprecated("Use PokeBalls.getSafariBall(), provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getSAFARI_BALL() = SAFARI_BALL
|
||||
|
||||
@JvmName("getFAST_BALL")
|
||||
@Deprecated("Use PokeBalls.getFastBall(), provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getFAST_BALL() = FAST_BALL
|
||||
|
||||
@JvmName("getLEVEL_BALL")
|
||||
@Deprecated("Use PokeBalls.getLevelBall(), provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getLEVEL_BALL() = LEVEL_BALL
|
||||
|
||||
@JvmName("getLURE_BALL")
|
||||
@Deprecated("Use PokeBalls.getLureBall(), provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getLURE_BALL() = LURE_BALL
|
||||
|
||||
@JvmName("getHEAVY_BALL")
|
||||
@Deprecated("Use PokeBalls.getHeavyBall(), provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getHEAVY_BALL() = HEAVY_BALL
|
||||
|
||||
@JvmName("getLOVE_BALL")
|
||||
@Deprecated("Use PokeBalls.getLoveBall(), provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getLOVE_BALL() = LOVE_BALL
|
||||
|
||||
@JvmName("getFRIEND_BALL")
|
||||
@Deprecated("Use PokeBalls.getFriendBall(), provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getFRIEND_BALL() = FRIEND_BALL
|
||||
|
||||
@JvmName("getMOON_BALL")
|
||||
@Deprecated("Use PokeBalls.getMoonBall(), provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getMOON_BALL() = MOON_BALL
|
||||
|
||||
@JvmName("getSPORT_BALL")
|
||||
@Deprecated("Use PokeBalls.getSportBall(), provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getSPORT_BALL() = SPORT_BALL
|
||||
|
||||
@JvmName("getNET_BALL")
|
||||
@Deprecated("Use PokeBalls.getNetBall(), provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getNET_BALL() = NET_BALL
|
||||
|
||||
@JvmName("getNEST_BALL")
|
||||
@Deprecated("Use PokeBalls.getNestBall(), provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getNEST_BALL() = NEST_BALL
|
||||
|
||||
@JvmName("getREPEAT_BALL")
|
||||
@Deprecated("Use PokeBalls.getRepeatBall(), provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getREPEAT_BALL() = REPEAT_BALL
|
||||
|
||||
@JvmName("getTIMER_BALL")
|
||||
@Deprecated("Use PokeBalls.getTimerBall(), provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getTIMER_BALL() = TIMER_BALL
|
||||
|
||||
@JvmName("getLUXURY_BALL")
|
||||
@Deprecated("Use PokeBalls.getLuxuryBall(), provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getLUXURY_BALL() = LUXURY_BALL
|
||||
|
||||
@JvmName("getPREMIER_BALL")
|
||||
@Deprecated("Use PokeBalls.getPremierBall(), provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getPREMIER_BALL() = PREMIER_BALL
|
||||
|
||||
@JvmName("getDUSK_BALL")
|
||||
@Deprecated("Use PokeBalls.getDuskBall(), provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getDUSK_BALL() = DUSK_BALL
|
||||
|
||||
@JvmName("getHEAL_BALL")
|
||||
@Deprecated("Use PokeBalls.getHealBall(), provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getHEAL_BALL() = HEAL_BALL
|
||||
|
||||
@JvmName("getQUICK_BALL")
|
||||
@Deprecated("Use PokeBalls.getQuickBall(), provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getQUICK_BALL() = QUICK_BALL
|
||||
|
||||
@JvmName("getCHERISH_BALL")
|
||||
@Deprecated("Use PokeBalls.getCherishBall(), provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getCHERISH_BALL() = CHERISH_BALL
|
||||
|
||||
@JvmName("getPARK_BALL")
|
||||
@Deprecated("Use PokeBalls.getParkBall(), provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getPARK_BALL() = PARK_BALL
|
||||
|
||||
@JvmName("getDREAM_BALL")
|
||||
@Deprecated("Use PokeBalls.getDreamBall(), provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getDREAM_BALL() = DREAM_BALL
|
||||
|
||||
@JvmName("getBEAST_BALL")
|
||||
@Deprecated("Use PokeBalls.getBeastBall(), provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getBEAST_BALL() = BEAST_BALL
|
||||
|
||||
@JvmName("getANCIENT_POKE_BALL")
|
||||
@Deprecated("Use PokeBalls.getAncientPokeBall(), provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getANCIENT_POKE_BALL() = ANCIENT_POKE_BALL
|
||||
|
||||
@JvmName("getANCIENT_CITRINE_BALL")
|
||||
@Deprecated("Use PokeBalls.getAncientCitrineBall(), provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getANCIENT_CITRINE_BALL() = ANCIENT_CITRINE_BALL
|
||||
|
||||
@JvmName("getANCIENT_VERDANT_BALL")
|
||||
@Deprecated("Use PokeBalls.getAncientVerdantBall(), provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getANCIENT_VERDANT_BALL() = ANCIENT_VERDANT_BALL
|
||||
|
||||
@JvmName("getANCIENT_AZURE_BALL")
|
||||
@Deprecated("Use PokeBalls.getAncientAzureBall(), provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getANCIENT_AZURE_BALL() = ANCIENT_AZURE_BALL
|
||||
|
||||
@JvmName("getANCIENT_ROSEATE_BALL")
|
||||
@Deprecated("Use PokeBalls.getAncientRoseateBall(), provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getANCIENT_ROSEATE_BALL() = ANCIENT_ROSEATE_BALL
|
||||
|
||||
@JvmName("getANCIENT_SLATE_BALL")
|
||||
@Deprecated("Use PokeBalls.getAncientSlateBall(), provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getANCIENT_SLATE_BALL() = ANCIENT_SLATE_BALL
|
||||
|
||||
@JvmName("getANCIENT_IVORY_BALL")
|
||||
@Deprecated("Use PokeBalls.getAncientIvoryBall(), provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getANCIENT_IVORY_BALL() = ANCIENT_IVORY_BALL
|
||||
|
||||
@JvmName("getANCIENT_GREAT_BALL")
|
||||
@Deprecated("Use PokeBalls.getAncientGreatBall(), provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getANCIENT_GREAT_BALL() = ANCIENT_GREAT_BALL
|
||||
|
||||
@JvmName("getANCIENT_ULTRA_BALL")
|
||||
@Deprecated("Use PokeBalls.getAncientUltraBall(), provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getANCIENT_ULTRA_BALL() = ANCIENT_ULTRA_BALL
|
||||
|
||||
@JvmName("getANCIENT_HEAVY_BALL")
|
||||
@Deprecated("Use PokeBalls.getAncientHeavyBall(), provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getANCIENT_HEAVY_BALL() = ANCIENT_HEAVY_BALL
|
||||
|
||||
@JvmName("getANCIENT_LEADEN_BALL")
|
||||
@Deprecated("Use PokeBalls.getAncientLeadenBall(), provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getANCIENT_LEADEN_BALL() = ANCIENT_LEADEN_BALL
|
||||
|
||||
@JvmName("getANCIENT_GIGATON_BALL")
|
||||
@Deprecated("Use PokeBalls.getAncientGigatonBall(), provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getANCIENT_GIGATON_BALL() = ANCIENT_GIGATON_BALL
|
||||
|
||||
@JvmName("getANCIENT_FEATHER_BALL")
|
||||
@Deprecated("Use PokeBalls.getAncientFeatherBall(), provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getANCIENT_FEATHER_BALL() = ANCIENT_FEATHER_BALL
|
||||
|
||||
@JvmName("getANCIENT_WING_BALL")
|
||||
@Deprecated("Use PokeBalls.getAncientWingBall(), provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getANCIENT_WING_BALL() = ANCIENT_WING_BALL
|
||||
|
||||
@JvmName("getANCIENT_JET_BALL")
|
||||
@Deprecated("Use PokeBalls.getAncientJetBall(), provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getANCIENT_JET_BALL() = ANCIENT_JET_BALL
|
||||
|
||||
@JvmName("getANCIENT_ORIGIN_BALL")
|
||||
@Deprecated("Use PokeBalls.getAncientOriginBall(), provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getANCIENT_ORIGIN_BALL() = ANCIENT_ORIGIN_BALL
|
||||
|
||||
}
|
||||
@@ -24,126 +24,151 @@ import net.minecraft.resources.ResourceLocation
|
||||
object Natures {
|
||||
private val allNatures = mutableListOf<Nature>()
|
||||
|
||||
@JvmField
|
||||
val HARDY = registerNature(
|
||||
Nature(cobblemonResource("hardy"), "cobblemon.nature.hardy",
|
||||
null, null, null, null)
|
||||
)
|
||||
|
||||
@JvmField
|
||||
val LONELY = registerNature(
|
||||
Nature(cobblemonResource("lonely"), "cobblemon.nature.lonely",
|
||||
Stats.ATTACK, Stats.DEFENCE, Flavour.SPICY, Flavour.SOUR)
|
||||
)
|
||||
|
||||
@JvmField
|
||||
val BRAVE = registerNature(
|
||||
Nature(cobblemonResource("brave"), "cobblemon.nature.brave",
|
||||
Stats.ATTACK, Stats.SPEED, Flavour.SPICY, Flavour.SWEET)
|
||||
)
|
||||
|
||||
@JvmField
|
||||
val ADAMANT = registerNature(
|
||||
Nature(cobblemonResource("adamant"), "cobblemon.nature.adamant",
|
||||
Stats.ATTACK, Stats.SPECIAL_ATTACK, Flavour.SPICY, Flavour.DRY)
|
||||
)
|
||||
|
||||
@JvmField
|
||||
val NAUGHTY = registerNature(
|
||||
Nature(cobblemonResource("naughty"), "cobblemon.nature.naughty",
|
||||
Stats.ATTACK, Stats.SPECIAL_DEFENCE, Flavour.SPICY, Flavour.BITTER)
|
||||
)
|
||||
|
||||
@JvmField
|
||||
val BOLD = registerNature(
|
||||
Nature(cobblemonResource("bold"), "cobblemon.nature.bold",
|
||||
Stats.DEFENCE, Stats.ATTACK, Flavour.SOUR, Flavour.SPICY)
|
||||
)
|
||||
|
||||
@JvmField
|
||||
val DOCILE = registerNature(
|
||||
Nature(cobblemonResource("docile"), "cobblemon.nature.docile",
|
||||
null, null, null, null)
|
||||
)
|
||||
|
||||
@JvmField
|
||||
val RELAXED = registerNature(
|
||||
Nature(cobblemonResource("relaxed"), "cobblemon.nature.relaxed",
|
||||
Stats.DEFENCE, Stats.SPEED, Flavour.SOUR, Flavour.SWEET)
|
||||
)
|
||||
|
||||
@JvmField
|
||||
val IMPISH = registerNature(
|
||||
Nature(cobblemonResource("impish"), "cobblemon.nature.impish",
|
||||
Stats.DEFENCE, Stats.SPECIAL_ATTACK, Flavour.SOUR, Flavour.DRY)
|
||||
)
|
||||
|
||||
@JvmField
|
||||
val LAX = registerNature(
|
||||
Nature(cobblemonResource("lax"), "cobblemon.nature.lax",
|
||||
Stats.DEFENCE, Stats.SPECIAL_DEFENCE, Flavour.SOUR, Flavour.BITTER)
|
||||
)
|
||||
|
||||
@JvmField
|
||||
val TIMID = registerNature(
|
||||
Nature(cobblemonResource("timid"), "cobblemon.nature.timid",
|
||||
Stats.SPEED, Stats.ATTACK, Flavour.SWEET, Flavour.SPICY)
|
||||
)
|
||||
|
||||
@JvmField
|
||||
val HASTY = registerNature(
|
||||
Nature(cobblemonResource("hasty"), "cobblemon.nature.hasty",
|
||||
Stats.SPEED, Stats.DEFENCE, Flavour.SWEET, Flavour.SOUR)
|
||||
)
|
||||
|
||||
@JvmField
|
||||
val SERIOUS = registerNature(
|
||||
Nature(cobblemonResource("serious"), "cobblemon.nature.serious",
|
||||
null, null, null, null)
|
||||
)
|
||||
|
||||
@JvmField
|
||||
val JOLLY = registerNature(
|
||||
Nature(cobblemonResource("jolly"), "cobblemon.nature.jolly",
|
||||
Stats.SPEED, Stats.SPECIAL_ATTACK, Flavour.SWEET, Flavour.DRY)
|
||||
)
|
||||
|
||||
@JvmField
|
||||
val NAIVE = registerNature(
|
||||
Nature(cobblemonResource("naive"), "cobblemon.nature.naive",
|
||||
Stats.SPEED, Stats.SPECIAL_DEFENCE, Flavour.SWEET, Flavour.BITTER)
|
||||
)
|
||||
|
||||
@JvmField
|
||||
val MODEST = registerNature(
|
||||
Nature(cobblemonResource("modest"), "cobblemon.nature.modest",
|
||||
Stats.SPECIAL_ATTACK, Stats.ATTACK, null, null)
|
||||
)
|
||||
|
||||
@JvmField
|
||||
val MILD = registerNature(
|
||||
Nature(cobblemonResource("mild"), "cobblemon.nature.mild",
|
||||
Stats.SPECIAL_ATTACK, Stats.DEFENCE, Flavour.DRY, Flavour.SOUR)
|
||||
)
|
||||
|
||||
@JvmField
|
||||
val QUIET = registerNature(
|
||||
Nature(cobblemonResource("quiet"), "cobblemon.nature.quiet",
|
||||
Stats.SPECIAL_ATTACK, Stats.SPEED, Flavour.DRY, Flavour.SWEET)
|
||||
)
|
||||
|
||||
@JvmField
|
||||
val BASHFUL = registerNature(
|
||||
Nature(cobblemonResource("bashful"), "cobblemon.nature.bashful",
|
||||
null, null, null, null)
|
||||
)
|
||||
|
||||
@JvmField
|
||||
val RASH = registerNature(
|
||||
Nature(cobblemonResource("rash"), "cobblemon.nature.rash",
|
||||
Stats.SPECIAL_ATTACK, Stats.SPECIAL_DEFENCE, Flavour.DRY, Flavour.BITTER)
|
||||
)
|
||||
|
||||
@JvmField
|
||||
val CALM = registerNature(
|
||||
Nature(cobblemonResource("calm"), "cobblemon.nature.calm",
|
||||
Stats.SPECIAL_DEFENCE, Stats.ATTACK, Flavour.BITTER, Flavour.SPICY)
|
||||
)
|
||||
|
||||
@JvmField
|
||||
val GENTLE = registerNature(
|
||||
Nature(cobblemonResource("gentle"), "cobblemon.nature.gentle",
|
||||
Stats.SPECIAL_DEFENCE, Stats.DEFENCE, Flavour.BITTER, Flavour.SOUR)
|
||||
)
|
||||
|
||||
@JvmField
|
||||
val SASSY = registerNature(
|
||||
Nature(cobblemonResource("sassy"), "cobblemon.nature.sassy",
|
||||
Stats.SPECIAL_DEFENCE, Stats.SPEED, Flavour.BITTER, Flavour.SWEET)
|
||||
)
|
||||
|
||||
@JvmField
|
||||
val CAREFUL = registerNature(
|
||||
Nature(cobblemonResource("careful"), "cobblemon.nature.careful",
|
||||
Stats.SPECIAL_DEFENCE, Stats.SPECIAL_ATTACK, Flavour.BITTER, Flavour.DRY)
|
||||
)
|
||||
|
||||
@JvmField
|
||||
val QUIRKY = registerNature(
|
||||
Nature(cobblemonResource("quirky"), "cobblemon.nature.quirky",
|
||||
null, null, null, null)
|
||||
@@ -153,6 +178,7 @@ object Natures {
|
||||
/**
|
||||
* Registers a new nature type
|
||||
*/
|
||||
@JvmStatic
|
||||
fun registerNature(nature: Nature): Nature {
|
||||
allNatures.add(nature)
|
||||
return nature
|
||||
@@ -162,6 +188,7 @@ object Natures {
|
||||
* Gets a nature by registry name
|
||||
* @return a nature type or null
|
||||
*/
|
||||
@JvmStatic
|
||||
fun getNature(name: ResourceLocation): Nature? {
|
||||
return allNatures.find { nature -> nature.name == name }
|
||||
}
|
||||
@@ -170,6 +197,7 @@ object Natures {
|
||||
* Utility method to get a nature by string
|
||||
* @return a nature type or null
|
||||
*/
|
||||
@JvmStatic
|
||||
fun getNature(identifier: String) = getNature(cobblemonResource(identifier))
|
||||
?: getNature(ResourceLocation.parse(identifier))
|
||||
|
||||
@@ -177,10 +205,114 @@ object Natures {
|
||||
* Helper function for a random Nature
|
||||
* @return a random nature type
|
||||
*/
|
||||
@JvmStatic
|
||||
fun getRandomNature(): Nature {
|
||||
return allNatures.random()
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun all(): Collection<Nature> = this.allNatures.toList()
|
||||
|
||||
/**
|
||||
* Backwards compatibility getters
|
||||
*/
|
||||
@JvmName("getHARDY")
|
||||
@Deprecated("Use Natures.HARDY, provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getHARDY() = HARDY
|
||||
|
||||
@JvmName("getLONELY")
|
||||
@Deprecated("Use Natures.LONELY, provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getLONELY() = LONELY
|
||||
|
||||
@JvmName("getBRAVE")
|
||||
@Deprecated("Use Natures.BRAVE, provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getBRAVE() = BRAVE
|
||||
|
||||
@JvmName("getADAMANT")
|
||||
@Deprecated("Use Natures.ADAMANT, provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getADAMANT() = ADAMANT
|
||||
|
||||
@JvmName("getNAUGHTY")
|
||||
@Deprecated("Use Natures.NAUGHTY, provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getNAUGHTY() = NAUGHTY
|
||||
|
||||
@JvmName("getBOLD")
|
||||
@Deprecated("Use Natures.BOLD, provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getBOLD() = BOLD
|
||||
|
||||
@JvmName("getDOCILE")
|
||||
@Deprecated("Use Natures.DOCILE, provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getDOCILE() = DOCILE
|
||||
|
||||
@JvmName("getRELAXED")
|
||||
@Deprecated("Use Natures.RELAXED, provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getRELAXED() = RELAXED
|
||||
|
||||
@JvmName("getIMPISH")
|
||||
@Deprecated("Use Natures.IMPISH, provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getIMPISH() = IMPISH
|
||||
|
||||
@JvmName("getLAX")
|
||||
@Deprecated("Use Natures.LAX, provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getLAX() = LAX
|
||||
|
||||
@JvmName("getTIMID")
|
||||
@Deprecated("Use Natures.TIMID, provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getTIMID() = TIMID
|
||||
|
||||
@JvmName("getHASTY")
|
||||
@Deprecated("Use Natures.HASTY, provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getHASTY() = HASTY
|
||||
|
||||
@JvmName("getSERIOUS")
|
||||
@Deprecated("Use Natures.SERIOUS, provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getSERIOUS() = SERIOUS
|
||||
|
||||
@JvmName("getJOLLY")
|
||||
@Deprecated("Use Natures.JOLLY, provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getJOLLY() = JOLLY
|
||||
|
||||
@JvmName("getNAIVE")
|
||||
@Deprecated("Use Natures.NAIVE, provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getNAIVE() = NAIVE
|
||||
|
||||
@JvmName("getMODEST")
|
||||
@Deprecated("Use Natures.MODEST, provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getMODEST() = MODEST
|
||||
|
||||
@JvmName("getMILD")
|
||||
@Deprecated("Use Natures.MILD, provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getMILD() = MILD
|
||||
|
||||
@JvmName("getQUIET")
|
||||
@Deprecated("Use Natures.QUIET, provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getQUIET() = QUIET
|
||||
|
||||
@JvmName("getBASHFUL")
|
||||
@Deprecated("Use Natures.BASHFUL, provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getBASHFUL() = BASHFUL
|
||||
|
||||
@JvmName("getRASH")
|
||||
@Deprecated("Use Natures.RASH, provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getRASH() = RASH
|
||||
|
||||
@JvmName("getCALM")
|
||||
@Deprecated("Use Natures.CALM, provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getCALM() = CALM
|
||||
|
||||
@JvmName("getGENTLE")
|
||||
@Deprecated("Use Natures.GENTLE, provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getGENTLE() = GENTLE
|
||||
|
||||
@JvmName("getSASSY")
|
||||
@Deprecated("Use Natures.SASSY, provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getSASSY() = SASSY
|
||||
|
||||
@JvmName("getCAREFUL")
|
||||
@Deprecated("Use Natures.CAREFUL, provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getCAREFUL() = CAREFUL
|
||||
|
||||
@JvmName("getQUIRKY")
|
||||
@Deprecated("Use Natures.QUIRKY, provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getQUIRKY() = QUIRKY
|
||||
}
|
||||
@@ -17,6 +17,7 @@ import com.cobblemon.mod.common.api.events.pokemon.ShinyChanceCalculationEvent
|
||||
import com.cobblemon.mod.common.api.moves.Moves
|
||||
import com.cobblemon.mod.common.api.pokeball.PokeBalls
|
||||
import com.cobblemon.mod.common.api.pokemon.aspect.AspectProvider
|
||||
import com.cobblemon.mod.common.api.pokemon.stats.Stat
|
||||
import com.cobblemon.mod.common.api.pokemon.stats.Stats
|
||||
import com.cobblemon.mod.common.api.pokemon.status.Statuses
|
||||
import com.cobblemon.mod.common.api.properties.CustomPokemonProperty
|
||||
@@ -31,10 +32,12 @@ import com.cobblemon.mod.common.pokemon.IVs
|
||||
import com.cobblemon.mod.common.pokemon.OriginalTrainerType
|
||||
import com.cobblemon.mod.common.pokemon.Pokemon
|
||||
import com.cobblemon.mod.common.pokemon.RenderablePokemon
|
||||
import com.cobblemon.mod.common.pokemon.stat.CobblemonStatProvider
|
||||
import com.cobblemon.mod.common.pokemon.status.PersistentStatus
|
||||
import com.cobblemon.mod.common.util.DataKeys
|
||||
import com.cobblemon.mod.common.util.asIdentifierDefaultingNamespace
|
||||
import com.cobblemon.mod.common.util.isDouble
|
||||
import com.cobblemon.mod.common.util.isFloat
|
||||
import com.cobblemon.mod.common.util.isUuid
|
||||
import com.cobblemon.mod.common.util.server
|
||||
import com.cobblemon.mod.common.util.simplify
|
||||
@@ -146,6 +149,8 @@ open class PokemonProperties {
|
||||
props.originalTrainer = parsePlayerProperty(keyPairs, listOf("originaltrainer", "ot"))
|
||||
props.moves = parseString(keyPairs, listOf("moves"))?.split(",")
|
||||
props.heldItem = parseString(keyPairs, listOf("helditem", "held_item"))
|
||||
props.minPerfectIVs = parseIntProperty(keyPairs, listOf("min_perfect_ivs"))?.coerceIn(0, Stats.PERMANENT.size)
|
||||
props.scaleModifier = parseFloatProperty(keyPairs, listOf("scale_modifier"))
|
||||
|
||||
val maybeIVs = IVs()
|
||||
val maybeEVs = EVs()
|
||||
@@ -195,6 +200,16 @@ open class PokemonProperties {
|
||||
}
|
||||
}
|
||||
|
||||
private fun parseFloatProperty(keyPairs: MutableList<Pair<String, String?>>, labels: Iterable<String>): Float? {
|
||||
val matchingKeyPair = getMatchedKeyPair(keyPairs, labels) ?: return null
|
||||
val value = matchingKeyPair.second
|
||||
return if (value == null || !value.isFloat()) {
|
||||
null
|
||||
} else {
|
||||
value.toFloat()
|
||||
}
|
||||
}
|
||||
|
||||
private fun parseIdentifierOfRegistry(keyPairs: MutableList<Pair<String, String?>>, validKeys: List<String>, valueFetcher: (ResourceLocation) -> String?): String? {
|
||||
val matched = getMatchedKeyPair(keyPairs, validKeys) ?: return null
|
||||
val value = matched.second?.lowercase() ?: return null
|
||||
@@ -343,7 +358,9 @@ open class PokemonProperties {
|
||||
var moves: List<String>? = null
|
||||
var heldItem: String? = null
|
||||
var cosmeticItem: String? = null
|
||||
var scaleModifier: Float? = null
|
||||
|
||||
var minPerfectIVs: Int? = null
|
||||
var ivs: IVs? = null
|
||||
var evs: EVs? = null
|
||||
var customProperties = mutableListOf<CustomPokemonProperty>()
|
||||
@@ -413,6 +430,11 @@ open class PokemonProperties {
|
||||
pokemon.hyperTrainIV(stat.key, stat.value)
|
||||
}
|
||||
}
|
||||
minPerfectIVs?.let {
|
||||
CobblemonStatProvider.ofType(Stat.Type.PERMANENT).shuffled().take(it).forEach { stat ->
|
||||
pokemon.setIV(stat, IVs.MAX_VALUE)
|
||||
}
|
||||
}
|
||||
evs?.let { evs ->
|
||||
evs.forEach { stat ->
|
||||
pokemon.setEV(stat.key, stat.value)
|
||||
@@ -469,6 +491,7 @@ open class PokemonProperties {
|
||||
if (stack.isEmpty) return@let
|
||||
pokemon.swapHeldItem(stack, decrement = true, aiCanDrop = false)
|
||||
}
|
||||
scaleModifier?.let { pokemon.scaleModifier = it }
|
||||
pokemon.updateAspects()
|
||||
}
|
||||
|
||||
@@ -512,6 +535,7 @@ open class PokemonProperties {
|
||||
nature?.takeIf { it != pokemon.nature.name.toString() }?.let { return false }
|
||||
ability?.takeIf { it != pokemon.ability.name }?.let { return false }
|
||||
status?.takeIf { it != pokemon.status?.status?.showdownName }?.let { return false }
|
||||
minPerfectIVs?.takeIf { pokemon.ivs.count { stat -> stat.value == IVs.MAX_VALUE } < it }?.let { return false }
|
||||
ivs?.forEach{ stat ->
|
||||
if (stat.value != pokemon.ivs[stat.key]) { return false }
|
||||
}
|
||||
@@ -542,6 +566,7 @@ open class PokemonProperties {
|
||||
|
||||
return@takeIf false
|
||||
}?.let { return false }
|
||||
scaleModifier?.takeIf { it != pokemon.scaleModifier }?.let { return false }
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -570,6 +595,7 @@ open class PokemonProperties {
|
||||
nature?.takeIf { it != properties.nature }?.let { return false }
|
||||
ability?.takeIf { it != properties.ability }?.let { return false }
|
||||
status?.takeIf { it != properties.status }?.let { return false }
|
||||
minPerfectIVs?.takeIf { it != properties.minPerfectIVs }?.let { return false }
|
||||
ivs?.let{ ivs ->
|
||||
ivs.forEach{ stat ->
|
||||
//If the potential subset has IV and the main set does not then it cant be a subset
|
||||
@@ -593,6 +619,7 @@ open class PokemonProperties {
|
||||
originalTrainerType?.takeIf { it != properties.originalTrainerType }?.let{ return false }
|
||||
moves?.takeIf { it.any { move -> properties.moves?.none { it == move } == true } }?.let { return false }
|
||||
fullness?.takeIf { it != properties.fullness }?.let { return false }
|
||||
scaleModifier?.takeIf { it != properties.scaleModifier }?.let { return false }
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -646,6 +673,7 @@ open class PokemonProperties {
|
||||
nature?.let { nbt.putString(DataKeys.POKEMON_NATURE, it) }
|
||||
ability?.let { nbt.putString(DataKeys.POKEMON_ABILITY, it) }
|
||||
status?.let { nbt.putString(DataKeys.POKEMON_STATUS_NAME, it) }
|
||||
minPerfectIVs?.let { nbt.putInt(DataKeys.POKEMON_MIN_PERFECT_IVS, it) }
|
||||
ivs?.let { nbt.put(DataKeys.POKEMON_IVS, IVs.CODEC.encodeStart(NbtOps.INSTANCE, it).result().get()) }
|
||||
evs?.let { nbt.put(DataKeys.POKEMON_EVS, EVs.CODEC.encodeStart(NbtOps.INSTANCE, it).result().get()) }
|
||||
type?.let { nbt.putString(DataKeys.ELEMENTAL_TYPE, it) }
|
||||
@@ -657,6 +685,7 @@ open class PokemonProperties {
|
||||
originalTrainer?.let { nbt.putString(DataKeys.POKEMON_ORIGINAL_TRAINER, it) }
|
||||
moves?.let { nbt.putString(DataKeys.POKEMON_PROPERTIES_MOVES, it.joinToString(separator = ",")) }
|
||||
heldItem?.let {nbt.putString(DataKeys.POKEMON_PROPERTIES_HELDITEM, it)}
|
||||
scaleModifier?.let { nbt.putFloat(DataKeys.POKEMON_SCALE_MODIFIER, it) }
|
||||
val custom = ListTag()
|
||||
customProperties.map { StringTag.valueOf(it.asString()) }.forEach { custom.add(it) }
|
||||
nbt.put(DataKeys.POKEMON_PROPERTIES_CUSTOM, custom)
|
||||
@@ -678,6 +707,7 @@ open class PokemonProperties {
|
||||
nature = if (tag.contains(DataKeys.POKEMON_NATURE)) tag.getString(DataKeys.POKEMON_NATURE) else null
|
||||
ability = if (tag.contains(DataKeys.POKEMON_ABILITY)) tag.getString(DataKeys.POKEMON_ABILITY) else null
|
||||
status = if (tag.contains(DataKeys.POKEMON_STATUS_NAME)) tag.getString(DataKeys.POKEMON_STATUS_NAME) else null
|
||||
minPerfectIVs = if (tag.contains(DataKeys.POKEMON_MIN_PERFECT_IVS)) tag.getInt(DataKeys.POKEMON_MIN_PERFECT_IVS) else null
|
||||
ivs = if (tag.contains(DataKeys.POKEMON_IVS)) IVs.CODEC.decode(NbtOps.INSTANCE, tag.getCompound(DataKeys.POKEMON_IVS)).result().getOrNull()?.first else null
|
||||
evs = if (tag.contains(DataKeys.POKEMON_EVS)) EVs.CODEC.decode(NbtOps.INSTANCE, tag.getCompound(DataKeys.POKEMON_EVS)).result().getOrNull()?.first else null
|
||||
type = if (tag.contains(DataKeys.ELEMENTAL_TYPE)) tag.getString(DataKeys.ELEMENTAL_TYPE) else null
|
||||
@@ -689,6 +719,7 @@ open class PokemonProperties {
|
||||
originalTrainer = if (tag.contains(DataKeys.POKEMON_ORIGINAL_TRAINER)) tag.getString(DataKeys.POKEMON_ORIGINAL_TRAINER) else null
|
||||
moves = if (tag.contains(DataKeys.POKEMON_PROPERTIES_MOVES)) tag.getString(DataKeys.POKEMON_PROPERTIES_MOVES).split(",") else null
|
||||
heldItem = if (tag.contains(DataKeys.POKEMON_PROPERTIES_HELDITEM)) tag.getString(DataKeys.POKEMON_PROPERTIES_HELDITEM) else null
|
||||
scaleModifier = if (tag.contains(DataKeys.POKEMON_SCALE_MODIFIER)) tag.getFloat(DataKeys.POKEMON_SCALE_MODIFIER) else null
|
||||
val custom = tag.getList(DataKeys.POKEMON_PROPERTIES_CUSTOM, Tag.TAG_STRING.toInt())
|
||||
// This is kinda gross
|
||||
custom.forEach { customProperties.addAll(parse(it.asString).customProperties) }
|
||||
@@ -712,6 +743,7 @@ open class PokemonProperties {
|
||||
nature?.let { json.addProperty(DataKeys.POKEMON_NATURE, it) }
|
||||
ability?.let { json.addProperty(DataKeys.POKEMON_ABILITY, it) }
|
||||
status?.let { json.addProperty(DataKeys.POKEMON_STATUS_NAME, it) }
|
||||
minPerfectIVs?.let { json.addProperty(DataKeys.POKEMON_MIN_PERFECT_IVS, it) }
|
||||
ivs?.let { json.add(DataKeys.POKEMON_IVS, IVs.CODEC.encodeStart(JsonOps.INSTANCE, it).result().get()) }
|
||||
evs?.let { json.add(DataKeys.POKEMON_EVS, EVs.CODEC.encodeStart(JsonOps.INSTANCE, it).result().get()) }
|
||||
type?.let { json.addProperty(DataKeys.ELEMENTAL_TYPE, it) }
|
||||
@@ -723,6 +755,7 @@ open class PokemonProperties {
|
||||
originalTrainer?.let { json.addProperty(DataKeys.POKEMON_ORIGINAL_TRAINER, it) }
|
||||
moves?.let { json.addProperty(DataKeys.POKEMON_PROPERTIES_MOVES, it.joinToString(separator = ",")) }
|
||||
heldItem?.let {json.addProperty(DataKeys.POKEMON_PROPERTIES_HELDITEM, it)}
|
||||
scaleModifier?.let { json.addProperty(DataKeys.POKEMON_SCALE_MODIFIER, it) }
|
||||
val custom = JsonArray()
|
||||
customProperties.map { it.asString() }.forEach { custom.add(it) }
|
||||
json.add(DataKeys.POKEMON_PROPERTIES_CUSTOM, custom)
|
||||
@@ -745,6 +778,7 @@ open class PokemonProperties {
|
||||
nature = json.get(DataKeys.POKEMON_NATURE)?.asString
|
||||
ability = json.get(DataKeys.POKEMON_ABILITY)?.asString
|
||||
status = json.get(DataKeys.POKEMON_STATUS_NAME)?.asString
|
||||
minPerfectIVs = json.get(DataKeys.POKEMON_MIN_PERFECT_IVS)?.asInt
|
||||
ivs = json.getAsJsonObject(DataKeys.POKEMON_IVS)?.let { IVs.CODEC.decode(JsonOps.INSTANCE, it).result().getOrNull()?.first }
|
||||
evs = json.getAsJsonObject(DataKeys.POKEMON_EVS)?.let { EVs.CODEC.decode(JsonOps.INSTANCE, it).result().getOrNull()?.first }
|
||||
type = json.get(DataKeys.ELEMENTAL_TYPE)?.asString
|
||||
@@ -756,6 +790,7 @@ open class PokemonProperties {
|
||||
originalTrainer = json.get(DataKeys.POKEMON_ORIGINAL_TRAINER)?.asString
|
||||
moves = json.get(DataKeys.POKEMON_PROPERTIES_MOVES)?.asString?.split(",")
|
||||
heldItem = json.get(DataKeys.POKEMON_PROPERTIES_HELDITEM)?.asString
|
||||
scaleModifier = json.get(DataKeys.POKEMON_SCALE_MODIFIER)?.asFloat
|
||||
val custom = json.get(DataKeys.POKEMON_PROPERTIES_CUSTOM)?.asJsonArray
|
||||
// This is still kinda gross
|
||||
custom?.forEach { customProperties.addAll(parse(it.asString).customProperties) }
|
||||
@@ -777,6 +812,7 @@ open class PokemonProperties {
|
||||
nature?.let { pieces.add("nature=$it") }
|
||||
ability?.let { pieces.add("ability=$it") }
|
||||
status?.let { pieces.add("status=$it") }
|
||||
minPerfectIVs?.let { pieces.add("min_perfect_ivs=$it") }
|
||||
ivs?.forEach{ stat ->
|
||||
pieces.add("${stat.key}_iv=${stat.value}")
|
||||
}
|
||||
@@ -793,6 +829,7 @@ open class PokemonProperties {
|
||||
customProperties.forEach { pieces.add(it.asString()) }
|
||||
moves?.let { pieces.add("moves=${it.joinToString(separator = ",")}") }
|
||||
heldItem?.let {pieces.add("helditem=$it")}
|
||||
scaleModifier?.let { pieces.add("scale_modifier=$it") }
|
||||
return pieces.joinToString(separator)
|
||||
}
|
||||
|
||||
|
||||
@@ -142,8 +142,10 @@ object PokemonSpecies : JsonDataRegistry<Species> {
|
||||
private val speciesByIdentifier = hashMapOf<ResourceLocation, Species>()
|
||||
private val speciesByDex = HashBasedTable.create<String, Int, Species>()
|
||||
|
||||
@JvmStatic
|
||||
val species: Collection<Species>
|
||||
get() = this.speciesByIdentifier.values
|
||||
@JvmStatic
|
||||
val implemented: List<Species>
|
||||
get() = this.species.filter { it.implemented }
|
||||
|
||||
@@ -169,6 +171,7 @@ object PokemonSpecies : JsonDataRegistry<Species> {
|
||||
* @param name The path of the species asset.
|
||||
* @return The [Species] if existing.
|
||||
*/
|
||||
@JvmStatic
|
||||
fun getByName(name: String) = this.getByIdentifier(cobblemonResource(name))
|
||||
|
||||
/**
|
||||
@@ -177,6 +180,7 @@ object PokemonSpecies : JsonDataRegistry<Species> {
|
||||
* @param ndex The [Species.nationalPokedexNumber].
|
||||
* @return The [Species] if existing.
|
||||
*/
|
||||
@JvmStatic
|
||||
fun getByPokedexNumber(ndex: Int, namespace: String = Cobblemon.MODID) = this.speciesByDex.get(namespace, ndex)
|
||||
|
||||
/**
|
||||
@@ -185,6 +189,7 @@ object PokemonSpecies : JsonDataRegistry<Species> {
|
||||
* @param identifier The unique [Species.resourceIdentifier] of the [Species].
|
||||
* @return The [Species] if existing.
|
||||
*/
|
||||
@JvmStatic
|
||||
fun getByIdentifier(identifier: ResourceLocation) = this.speciesByIdentifier[identifier]
|
||||
|
||||
/**
|
||||
@@ -192,6 +197,7 @@ object PokemonSpecies : JsonDataRegistry<Species> {
|
||||
*
|
||||
* @return The loaded species amount.
|
||||
*/
|
||||
@JvmStatic
|
||||
fun count() = this.speciesByIdentifier.size
|
||||
|
||||
/**
|
||||
@@ -199,6 +205,7 @@ object PokemonSpecies : JsonDataRegistry<Species> {
|
||||
*
|
||||
* @return The dex numbers map to species.
|
||||
*/
|
||||
@JvmStatic
|
||||
fun getSpeciesInNamespace(namespace: String = Cobblemon.MODID): MutableMap<Int, Species> = speciesByDex.row(namespace)
|
||||
|
||||
/**
|
||||
@@ -206,6 +213,7 @@ object PokemonSpecies : JsonDataRegistry<Species> {
|
||||
*
|
||||
* @return The list of loaded namespaces.
|
||||
*/
|
||||
@JvmStatic
|
||||
fun getNamespaces() = speciesByDex.rowKeySet().toList()
|
||||
|
||||
/**
|
||||
@@ -215,6 +223,7 @@ object PokemonSpecies : JsonDataRegistry<Species> {
|
||||
*
|
||||
* @return A randomly selected [Species].
|
||||
*/
|
||||
@JvmStatic
|
||||
fun random(): Species = this.implemented.random()
|
||||
|
||||
override fun reload(data: Map<ResourceLocation, Species>) {
|
||||
@@ -314,4 +323,4 @@ object PokemonSpecies : JsonDataRegistry<Species> {
|
||||
}
|
||||
return result
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
@@ -36,12 +36,16 @@ object ShoulderEffectRegistry {
|
||||
PlatformEvents.SERVER_PLAYER_LOGIN.subscribe { this.refreshEffects(it.player) }
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun register(name: String, effect: Class<out ShoulderEffect>) = effect.also { effects[name] = it }
|
||||
|
||||
@JvmStatic
|
||||
fun unregister(name: String) = effects.remove(name)
|
||||
|
||||
@JvmStatic
|
||||
fun getName(clazz: Class<out ShoulderEffect>) = effects.firstNotNullOf { if (it.value == clazz) it.key else null }
|
||||
|
||||
@JvmStatic
|
||||
fun get(name: String): Class<out ShoulderEffect>? = effects[name]
|
||||
|
||||
// It was removed by a source such as milk, reapply
|
||||
|
||||
+7
@@ -62,10 +62,14 @@ object GlobalSpeciesFeatures : JsonDataRegistry<SpeciesFeatureProvider<*>> {
|
||||
data.forEach(this::registerFromAssets)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getCodeFeature(name: String) = codeFeatures[name]
|
||||
@JvmStatic
|
||||
fun getResourceFeature(name: String) = resourceFeatures[name]
|
||||
@JvmStatic
|
||||
fun getFeature(name: String) = getCodeFeature(name) ?: getResourceFeature(name)
|
||||
|
||||
@JvmStatic
|
||||
fun getFeatures() = (resourceFeatures.keys + codeFeatures.keys).mapNotNull(this::getFeature)
|
||||
|
||||
fun loadOnClient(entries: Collection<Map.Entry<String, SpeciesFeatureProvider<*>>>) {
|
||||
@@ -83,7 +87,9 @@ object GlobalSpeciesFeatures : JsonDataRegistry<SpeciesFeatureProvider<*>> {
|
||||
mapping[name] = provider
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun register(name: String, provider: SpeciesFeatureProvider<*>) = register(name, provider, isCoded = true)
|
||||
@JvmStatic
|
||||
fun <T : SpeciesFeature> register(name: String, providerLambda: () -> T) {
|
||||
register(name, object : SpeciesFeatureProvider<T> {
|
||||
override fun invoke(pokemon: Pokemon) = providerLambda()
|
||||
@@ -93,6 +99,7 @@ object GlobalSpeciesFeatures : JsonDataRegistry<SpeciesFeatureProvider<*>> {
|
||||
}
|
||||
private fun registerFromAssets(identifier: ResourceLocation, provider: SpeciesFeatureProvider<*>) = register(identifier.path, provider, isCoded = false)
|
||||
|
||||
@JvmStatic
|
||||
fun unregister(name: String) {
|
||||
var coded = true
|
||||
val value = getResourceFeature(name)?.also { coded = false } ?: getCodeFeature(name) ?: return
|
||||
|
||||
+1
@@ -60,5 +60,6 @@ object SpeciesFeatureAssignments : JsonDataRegistry<SpeciesFeatureAssignment> {
|
||||
this.assignments.putAll(data)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getFeatures(species: Species) = assignments[species.resourceIdentifier] ?: emptySet()
|
||||
}
|
||||
@@ -68,14 +68,19 @@ object SpeciesFeatures : JsonDataRegistry<SpeciesFeatureProvider<*>> {
|
||||
data.forEach(this::registerFromAssets)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getCodeFeature(name: String) = codeFeatures[name]
|
||||
@JvmStatic
|
||||
fun getResourceFeature(name: String) = resourceFeatures[name]
|
||||
@JvmStatic
|
||||
fun getFeature(name: String) = getCodeFeature(name) ?: getResourceFeature(name) ?: GlobalSpeciesFeatures.getFeature(name)
|
||||
fun loadOnClient(entries: Collection<Map.Entry<String, SpeciesFeatureProvider<*>>>) {
|
||||
codeFeatures.putAll(entries.map { it.toPair() })
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getFeatures() = (resourceFeatures.keys + codeFeatures.keys).mapNotNull(this::getFeature)
|
||||
@JvmStatic
|
||||
fun getFeaturesFor(species: Species): List<SpeciesFeatureProvider<*>> {
|
||||
val mentionedFeatures = species.features.mapNotNull(this::getFeature)
|
||||
val globalFeatures = GlobalSpeciesFeatures.getFeatures()
|
||||
@@ -95,9 +100,11 @@ object SpeciesFeatures : JsonDataRegistry<SpeciesFeatureProvider<*>> {
|
||||
mapping[name] = provider
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun register(name: String, provider: SpeciesFeatureProvider<*>) = register(name, provider, isCoded = true)
|
||||
private fun registerFromAssets(identifier: ResourceLocation, provider: SpeciesFeatureProvider<*>) = register(identifier.path, provider, isCoded = false)
|
||||
|
||||
@JvmStatic
|
||||
fun unregister(name: String) {
|
||||
var coded = true
|
||||
val value = getResourceFeature(name)?.also { coded = false } ?: getCodeFeature(name) ?: return
|
||||
|
||||
+7
@@ -29,6 +29,7 @@ object HeldItemProvider {
|
||||
* @param pokemon The [Pokemon] being queried.
|
||||
* @return The [HeldItemManager] that can provide for the given [pokemon], if non match returns the [HeldItemManager.EMPTY].
|
||||
*/
|
||||
@JvmStatic
|
||||
fun provide(pokemon: BattlePokemon): HeldItemManager = this.managers.firstOrNull { manager -> manager.showdownId(pokemon) != null } ?: HeldItemManager.EMPTY
|
||||
|
||||
/**
|
||||
@@ -37,6 +38,7 @@ object HeldItemProvider {
|
||||
* @param pokemon The [Pokemon] being queried.
|
||||
* @return The showdownId string that [pokemon] is holding, otherwise null.
|
||||
*/
|
||||
@JvmStatic
|
||||
fun provideShowdownId(pokemon: BattlePokemon) = this.managers.firstNotNullOfOrNull { manager -> manager.showdownId(pokemon) }
|
||||
|
||||
/**
|
||||
@@ -45,6 +47,8 @@ object HeldItemProvider {
|
||||
* @param manager The [HeldItemManager] being registered.
|
||||
* @param priority The [Priority] to register it under.
|
||||
*/
|
||||
@JvmStatic
|
||||
@JvmOverloads
|
||||
fun register(manager: HeldItemManager, priority: Priority = Priority.NORMAL) {
|
||||
this.managers.add(priority, manager)
|
||||
}
|
||||
@@ -56,6 +60,8 @@ object HeldItemProvider {
|
||||
* @param priority The [Priority] to specifically remove the instance from, if null it will remove from all.
|
||||
*/
|
||||
@Suppress("unused")
|
||||
@JvmStatic
|
||||
@JvmOverloads
|
||||
fun unregister(manager: HeldItemManager, priority: Priority? = null) {
|
||||
if (priority != null) {
|
||||
this.managers.remove(priority, manager)
|
||||
@@ -69,6 +75,7 @@ object HeldItemProvider {
|
||||
*
|
||||
* @return The read-only copy of the registered [HeldItemManager]s.
|
||||
*/
|
||||
@JvmStatic
|
||||
fun managers(): List<HeldItemManager> = this.managers.toList()
|
||||
|
||||
}
|
||||
@@ -34,17 +34,24 @@ object Statuses {
|
||||
private val volatileStatuses = mutableListOf<Status>()
|
||||
private val allStatuses = mutableListOf<Status>()
|
||||
|
||||
@JvmField
|
||||
val POISON = registerStatus(PoisonStatus())
|
||||
@JvmField
|
||||
val POISON_BADLY = registerStatus(PoisonBadlyStatus())
|
||||
@JvmField
|
||||
val PARALYSIS = registerStatus(ParalysisStatus())
|
||||
@JvmField
|
||||
val SLEEP = registerStatus(SleepStatus())
|
||||
@JvmField
|
||||
val FROZEN = registerStatus(FrozenStatus())
|
||||
@JvmField
|
||||
val BURN = registerStatus(BurnStatus())
|
||||
@JvmField
|
||||
val ATTRACT = registerStatus(AttractStatus())
|
||||
@JvmField
|
||||
val CONFUSE = registerStatus(ConfuseStatus())
|
||||
|
||||
|
||||
|
||||
@JvmStatic
|
||||
fun <T: Status> registerStatus(status: T) : T {
|
||||
if (status is PersistentStatus) {
|
||||
persistentStatuses.add(status)
|
||||
@@ -56,7 +63,10 @@ object Statuses {
|
||||
return status
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getStatus(name: ResourceLocation) = allStatuses.find { status -> status.name == name }
|
||||
@JvmStatic
|
||||
fun getStatus(showdownName: String) = allStatuses.find { it.showdownName == showdownName }
|
||||
@JvmStatic
|
||||
fun getPersistentStatuses() = persistentStatuses
|
||||
}
|
||||
@@ -17,6 +17,7 @@ import com.cobblemon.mod.common.api.reactive.pipes.StopAfterTransform
|
||||
import com.cobblemon.mod.common.api.reactive.pipes.TakeFirstTransform
|
||||
import java.lang.Thread.sleep
|
||||
import java.util.concurrent.CompletableFuture
|
||||
import java.util.function.Consumer
|
||||
|
||||
/**
|
||||
* An object that emits values of the generic type. This can be subscribed to and unsubscribed from, as well as
|
||||
@@ -30,6 +31,8 @@ import java.util.concurrent.CompletableFuture
|
||||
*/
|
||||
interface Observable<T> {
|
||||
fun subscribe(priority: Priority = Priority.NORMAL, handler: (T) -> Unit): ObservableSubscription<T>
|
||||
fun subscribe(handler: Consumer<T>): ObservableSubscription<T> = subscribe(Priority.NORMAL) { handler.accept(it) }
|
||||
fun subscribe(priority: Priority, handler: Consumer<T>): ObservableSubscription<T> = subscribe(priority) { handler.accept(it) }
|
||||
fun unsubscribe(subscription: ObservableSubscription<T>)
|
||||
|
||||
// This isn't pretty, ik
|
||||
|
||||
+3
-1
@@ -39,13 +39,15 @@ object RidingBehaviours {
|
||||
register(CompositeBehaviour.KEY, CompositeBehaviour())
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun register(key: ResourceLocation, behaviour: RidingBehaviour<out RidingBehaviourSettings, out RidingBehaviourState>) {
|
||||
if (behaviours.contains(key)) error("Behaviour already registered to key $key")
|
||||
behaviours[key] = behaviour as RidingBehaviour<RidingBehaviourSettings, RidingBehaviourState>
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun get(key: ResourceLocation): RidingBehaviour<RidingBehaviourSettings, RidingBehaviourState> {
|
||||
if (!behaviours.contains(key)) error("Behaviour not registered to key $key")
|
||||
return behaviours[key]!!
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -54,7 +54,7 @@ class RidingController(
|
||||
// If transitioning to air then give an upward boost
|
||||
if (newTransition == RidingStyle.AIR && context?.style != RidingStyle.AIR && context?.state != null) {
|
||||
val currVel = context!!.state.rideVelocity.get()
|
||||
context!!.state.rideVelocity.set(Vec3(currVel.x, max(0.4, currVel.y), currVel.z))
|
||||
context!!.state.rideVelocity.set(Vec3(currVel.x, max(0.1, currVel.y), currVel.z))
|
||||
}
|
||||
val behaviourSettings = entity.pokemon.riding.behaviours?.get(newTransition)
|
||||
if (newTransition != context?.style) {
|
||||
|
||||
@@ -64,6 +64,7 @@ object CobblemonScripts : DataRegistry {
|
||||
player.sendPacket(ScriptRegistrySyncPacket(clientScripts.entries))
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun run(identifier: ResourceLocation, runtime: MoLangRuntime): MoValue? {
|
||||
return scripts[identifier]?.resolve(runtime, runtime.contextOrEmpty)
|
||||
}
|
||||
|
||||
+6
@@ -46,6 +46,8 @@ class FishingSpawnCause(
|
||||
) : SpawnCause(spawner, entity) {
|
||||
companion object {
|
||||
const val FISHED_ASPECT = "fished"
|
||||
const val DROPS_REROLL_ASPECT = "drops_reroll"
|
||||
|
||||
fun shinyReroll(pokemonEntity: PokemonEntity, effect: SpawnBait.Effect) {
|
||||
if (pokemonEntity.pokemon.shiny) return
|
||||
|
||||
@@ -60,6 +62,10 @@ class FishingSpawnCause(
|
||||
}
|
||||
}
|
||||
|
||||
fun saveDropsReroll(pokemonEntity: PokemonEntity, effect: SpawnBait.Effect) {
|
||||
pokemonEntity.pokemon.forcedAspects += DROPS_REROLL_ASPECT
|
||||
}
|
||||
|
||||
fun alterNatureAttempt(pokemonEntity: PokemonEntity, effect: SpawnBait.Effect) {
|
||||
val baitStat = effect.subcategory?.let { it1 -> Stats.getStat(it1.path).identifier } ?: run {
|
||||
LOGGER.warn("One of your nature baits is missing a subcategory and failed to effect a fished Pokemon")
|
||||
|
||||
@@ -87,6 +87,8 @@ open class PartyStore(override val uuid: UUID) : PokemonStore<PartyPosition>() {
|
||||
/** The amount of party slots that are occupied by a [Pokemon]. */
|
||||
fun occupied() = slots.filterNotNull().count()
|
||||
|
||||
fun isEmpty() = occupied() == 0
|
||||
|
||||
override fun sendTo(player: ServerPlayer) {
|
||||
player.sendPacket(InitializePartyPacket(false, uuid, slots.size))
|
||||
slots.forEachIndexed { index, pokemon ->
|
||||
@@ -280,5 +282,4 @@ open class PartyStore(override val uuid: UUID) : PokemonStore<PartyPosition>() {
|
||||
remove(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+10
-2
@@ -36,6 +36,15 @@ data class GeneralPlayerData(
|
||||
player.sendPacket(SetClientPlayerDataPacket(PlayerInstancedDataStoreTypes.GENERAL, this.toClientData()))
|
||||
}
|
||||
|
||||
override fun initialize() {
|
||||
// For any existing players, ensure they have all default key items
|
||||
Cobblemon.config.defaultKeyItems.forEach {
|
||||
if (!keyItems.contains(it)) {
|
||||
keyItems.add(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun toClientData(): ClientInstancedPlayerData {
|
||||
return ClientGeneralPlayerData(
|
||||
false,
|
||||
@@ -48,5 +57,4 @@ data class GeneralPlayerData(
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -34,7 +34,7 @@ class PlayerDataJsonBackend: JsonBackedPlayerDataStoreBackend<GeneralPlayerData>
|
||||
starterLocked = !Cobblemon.starterConfig.allowStarterOnJoin,
|
||||
starterSelected = false,
|
||||
starterUUID = null,
|
||||
keyItems = mutableSetOf(),
|
||||
keyItems = Cobblemon.config.defaultKeyItems,
|
||||
extraData = mutableMapOf(),
|
||||
battleTheme = CobblemonSounds.PVP_BATTLE.location
|
||||
)}
|
||||
|
||||
+1
-1
@@ -35,7 +35,7 @@ class PlayerDataMongoBackend(mongoClient: MongoClient, databaseName: String, col
|
||||
starterLocked = !Cobblemon.starterConfig.allowStarterOnJoin,
|
||||
starterSelected = false,
|
||||
starterUUID = null,
|
||||
keyItems = mutableSetOf(),
|
||||
keyItems = Cobblemon.config.defaultKeyItems,
|
||||
extraData = mutableMapOf(),
|
||||
battleTheme = CobblemonSounds.PVP_BATTLE.location
|
||||
)}
|
||||
|
||||
@@ -18,6 +18,7 @@ object ElementalTypes {
|
||||
|
||||
private val allTypes = mutableListOf<ElementalType>()
|
||||
|
||||
@JvmField
|
||||
val NORMAL = register(
|
||||
name = "Normal",
|
||||
displayName = Component.translatable("cobblemon.type.normal"),
|
||||
@@ -25,6 +26,7 @@ object ElementalTypes {
|
||||
textureXMultiplier = 0
|
||||
)
|
||||
|
||||
@JvmField
|
||||
val FIRE = register(
|
||||
name = "Fire",
|
||||
displayName = Component.translatable("cobblemon.type.fire"),
|
||||
@@ -32,6 +34,7 @@ object ElementalTypes {
|
||||
textureXMultiplier = 1
|
||||
)
|
||||
|
||||
@JvmField
|
||||
val WATER = register(
|
||||
name = "Water",
|
||||
displayName = Component.translatable("cobblemon.type.water"),
|
||||
@@ -39,6 +42,7 @@ object ElementalTypes {
|
||||
textureXMultiplier = 2
|
||||
)
|
||||
|
||||
@JvmField
|
||||
val GRASS = register(
|
||||
name = "Grass",
|
||||
displayName = Component.translatable("cobblemon.type.grass"),
|
||||
@@ -46,6 +50,7 @@ object ElementalTypes {
|
||||
textureXMultiplier = 3
|
||||
)
|
||||
|
||||
@JvmField
|
||||
val ELECTRIC = register(
|
||||
name = "Electric",
|
||||
displayName = Component.translatable("cobblemon.type.electric"),
|
||||
@@ -53,6 +58,7 @@ object ElementalTypes {
|
||||
textureXMultiplier = 4
|
||||
)
|
||||
|
||||
@JvmField
|
||||
val ICE = register(
|
||||
name = "Ice",
|
||||
displayName = Component.translatable("cobblemon.type.ice"),
|
||||
@@ -60,6 +66,7 @@ object ElementalTypes {
|
||||
textureXMultiplier = 5
|
||||
)
|
||||
|
||||
@JvmField
|
||||
val FIGHTING = register(
|
||||
name = "Fighting",
|
||||
displayName = Component.translatable("cobblemon.type.fighting"),
|
||||
@@ -67,6 +74,7 @@ object ElementalTypes {
|
||||
textureXMultiplier = 6
|
||||
)
|
||||
|
||||
@JvmField
|
||||
val POISON = register(
|
||||
name = "Poison",
|
||||
displayName = Component.translatable("cobblemon.type.poison"),
|
||||
@@ -74,6 +82,7 @@ object ElementalTypes {
|
||||
textureXMultiplier = 7
|
||||
)
|
||||
|
||||
@JvmField
|
||||
val GROUND = register(
|
||||
name = "Ground",
|
||||
displayName = Component.translatable("cobblemon.type.ground"),
|
||||
@@ -81,6 +90,7 @@ object ElementalTypes {
|
||||
textureXMultiplier = 8
|
||||
)
|
||||
|
||||
@JvmField
|
||||
val FLYING = register(
|
||||
name = "Flying",
|
||||
displayName = Component.translatable("cobblemon.type.flying"),
|
||||
@@ -88,6 +98,7 @@ object ElementalTypes {
|
||||
textureXMultiplier = 9
|
||||
)
|
||||
|
||||
@JvmField
|
||||
val PSYCHIC = register(
|
||||
name = "Psychic",
|
||||
displayName = Component.translatable("cobblemon.type.psychic"),
|
||||
@@ -95,6 +106,7 @@ object ElementalTypes {
|
||||
textureXMultiplier = 10
|
||||
)
|
||||
|
||||
@JvmField
|
||||
val BUG = register(
|
||||
name = "Bug",
|
||||
displayName = Component.translatable("cobblemon.type.bug"),
|
||||
@@ -102,6 +114,7 @@ object ElementalTypes {
|
||||
textureXMultiplier = 11
|
||||
)
|
||||
|
||||
@JvmField
|
||||
val ROCK = register(
|
||||
name = "Rock",
|
||||
displayName = Component.translatable("cobblemon.type.rock"),
|
||||
@@ -109,6 +122,7 @@ object ElementalTypes {
|
||||
textureXMultiplier = 12
|
||||
)
|
||||
|
||||
@JvmField
|
||||
val GHOST = register(
|
||||
name = "Ghost",
|
||||
displayName = Component.translatable("cobblemon.type.ghost"),
|
||||
@@ -116,6 +130,7 @@ object ElementalTypes {
|
||||
textureXMultiplier = 13
|
||||
)
|
||||
|
||||
@JvmField
|
||||
val DRAGON = register(
|
||||
name = "Dragon",
|
||||
displayName = Component.translatable("cobblemon.type.dragon"),
|
||||
@@ -123,6 +138,7 @@ object ElementalTypes {
|
||||
textureXMultiplier = 14
|
||||
)
|
||||
|
||||
@JvmField
|
||||
val DARK = register(
|
||||
name = "Dark",
|
||||
displayName = Component.translatable("cobblemon.type.dark"),
|
||||
@@ -130,6 +146,7 @@ object ElementalTypes {
|
||||
textureXMultiplier = 15
|
||||
)
|
||||
|
||||
@JvmField
|
||||
val STEEL = register(
|
||||
name = "Steel",
|
||||
displayName = Component.translatable("cobblemon.type.steel"),
|
||||
@@ -137,6 +154,7 @@ object ElementalTypes {
|
||||
textureXMultiplier = 16
|
||||
)
|
||||
|
||||
@JvmField
|
||||
val FAIRY = register(
|
||||
name = "Fairy",
|
||||
displayName = Component.translatable("cobblemon.type.fairy"),
|
||||
@@ -144,6 +162,7 @@ object ElementalTypes {
|
||||
textureXMultiplier = 17
|
||||
)
|
||||
|
||||
@JvmStatic
|
||||
fun register(name: String, displayName: MutableComponent, hue: Int, textureXMultiplier: Int): ElementalType {
|
||||
return ElementalType(
|
||||
name = name,
|
||||
@@ -155,20 +174,103 @@ object ElementalTypes {
|
||||
}
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun register(elementalType: ElementalType): ElementalType {
|
||||
allTypes.add(elementalType)
|
||||
return elementalType
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun get(name: String): ElementalType? {
|
||||
return allTypes.firstOrNull { type -> type.name.equals(name, ignoreCase = true) }
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getOrException(name: String): ElementalType {
|
||||
return allTypes.first { type -> type.name.equals(name, ignoreCase = true) }
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun count() = allTypes.size
|
||||
|
||||
@JvmStatic
|
||||
fun all() = this.allTypes.toList()
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getRandomType(): ElementalType = this.allTypes.random()
|
||||
|
||||
/**
|
||||
* Backwards compatibility getters
|
||||
*/
|
||||
@JvmName("getNORMAL")
|
||||
@Deprecated("Use ElementalTypes.NORMAL, provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getNORMAL() = NORMAL
|
||||
|
||||
@JvmName("getFIRE")
|
||||
@Deprecated("Use ElementalTypes.FIRE, provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getFIRE() = FIRE
|
||||
|
||||
@JvmName("getWATER")
|
||||
@Deprecated("Use ElementalTypes.WATER, provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getWATER() = WATER
|
||||
|
||||
@JvmName("getGRASS")
|
||||
@Deprecated("Use ElementalTypes.GRASS, provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getGRASS() = GRASS
|
||||
|
||||
@JvmName("getELECTRIC")
|
||||
@Deprecated("Use ElementalTypes.ELECTRIC, provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getELECTRIC() = ELECTRIC
|
||||
|
||||
@JvmName("getICE")
|
||||
@Deprecated("Use ElementalTypes.ICE, provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getICE() = ICE
|
||||
|
||||
@JvmName("getFIGHTING")
|
||||
@Deprecated("Use ElementalTypes.FIGHTING, provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getFIGHTING() = FIGHTING
|
||||
|
||||
@JvmName("getPOISON")
|
||||
@Deprecated("Use ElementalTypes.POISON, provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getPOISON() = POISON
|
||||
|
||||
@JvmName("getGROUND")
|
||||
@Deprecated("Use ElementalTypes.GROUND, provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getGROUND() = GROUND
|
||||
|
||||
@JvmName("getFLYING")
|
||||
@Deprecated("Use ElementalTypes.FLYING, provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getFLYING() = FLYING
|
||||
|
||||
@JvmName("getPSYCHIC")
|
||||
@Deprecated("Use ElementalTypes.PSYCHIC, provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getPSYCHIC() = PSYCHIC
|
||||
|
||||
@JvmName("getBUG")
|
||||
@Deprecated("Use ElementalTypes.BUG, provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getBUG() = BUG
|
||||
|
||||
@JvmName("getROCK")
|
||||
@Deprecated("Use ElementalTypes.ROCK, provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getROCK() = ROCK
|
||||
|
||||
@JvmName("getGHOST")
|
||||
@Deprecated("Use ElementalTypes.GHOST, provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getGHOST() = GHOST
|
||||
|
||||
@JvmName("getDRAGON")
|
||||
@Deprecated("Use ElementalTypes.DRAGON, provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getDRAGON() = DRAGON
|
||||
|
||||
@JvmName("getDARK")
|
||||
@Deprecated("Use ElementalTypes.DARK, provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getDARK() = DARK
|
||||
|
||||
@JvmName("getSTEEL")
|
||||
@Deprecated("Use ElementalTypes.STEEL, provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getSTEEL() = STEEL
|
||||
|
||||
@JvmName("getFAIRY")
|
||||
@Deprecated("Use ElementalTypes.FAIRY, provided for backwards compatibility until Cobblemon 1.8.")
|
||||
fun getFAIRY() = FAIRY
|
||||
}
|
||||
@@ -39,6 +39,7 @@ object BagItems : DataRegistry {
|
||||
val bagItems = PrioritizedList<BagItemLike>()
|
||||
internal val bagItemsScripts = mutableMapOf<String, String>() // itemId to JavaScript
|
||||
|
||||
@JvmStatic
|
||||
fun getConvertibleForStack(stack: ItemStack): BagItemLike? {
|
||||
return bagItems.firstOrNull { it.getBagItem(stack) != null }
|
||||
}
|
||||
|
||||
@@ -193,6 +193,7 @@ object BattleRegistry {
|
||||
* This creates the battle and hands it off to Showdown - YOU WILL GET ISSUES IF THE BATTLE IS INVALID!
|
||||
* See [BattleBuilder] functions for how the various types of battles are built and validated.
|
||||
*/
|
||||
@JvmStatic
|
||||
fun startBattle(
|
||||
battleFormat: BattleFormat,
|
||||
side1: BattleSide,
|
||||
@@ -216,19 +217,23 @@ object BattleRegistry {
|
||||
return ErroredBattleStart(mutableSetOf(BattleStartError.canceledByEvent(preBattleEvent.reason)))
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun closeBattle(battle: PokemonBattle) {
|
||||
battle.onEndHandlers.forEach { it(battle) }
|
||||
battleMap.remove(battle.battleId)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getBattle(id: UUID): PokemonBattle? {
|
||||
return battleMap[id]
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getBattleByParticipatingPlayer(serverPlayer: ServerPlayer): PokemonBattle? {
|
||||
return battleMap.values.find { it.getActor(serverPlayer) != null }
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getBattleByParticipatingPlayerId(playerId: UUID): PokemonBattle? {
|
||||
return battleMap.values.find { playerId in it.playerUUIDs }
|
||||
}
|
||||
|
||||
@@ -30,10 +30,13 @@ object DispenserBehaviorRegistry {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Seems like there can only 1 behavior per item, so registering the leaves with the honey bottle overrode the honey bottle behavior for the log.
|
||||
// Registering a new behavior with `DispenserBlock.registerBehavior` will override any existing ones for that item, possibly even ones from Minecraft and other mods
|
||||
// Will probably need to use an alternate way of implementing this to avoid conflicts.
|
||||
fun registerDispenserBehaviors() {
|
||||
register(listOf(PotionContents.createItemStack(Items.POTION, Potions.WATER).item)) { SaccharineLogSlatheredBlock.createBehavior() }
|
||||
register(listOf(Items.HONEY_BOTTLE)) { SaccharineLogBlock.createBehavior() }
|
||||
register(listOf(Items.HONEY_BOTTLE, Items.GLASS_BOTTLE)) { item -> SaccharineLeafBlock.createBehavior(item)}
|
||||
// register(listOf(PotionContents.createItemStack(Items.POTION, Potions.WATER).item)) { SaccharineLogSlatheredBlock.createBehavior() }
|
||||
// register(listOf(Items.HONEY_BOTTLE)) { SaccharineLogBlock.createBehavior() }
|
||||
// register(listOf(Items.HONEY_BOTTLE, Items.GLASS_BOTTLE)) { item -> SaccharineLeafBlock.createBehavior(item)}
|
||||
applyBehaviors()
|
||||
}
|
||||
}
|
||||
@@ -10,11 +10,13 @@ package com.cobblemon.mod.common.block
|
||||
|
||||
import com.cobblemon.mod.common.CobblemonBlocks
|
||||
import com.cobblemon.mod.common.block.entity.PokeSnackBlockEntity
|
||||
import com.cobblemon.mod.common.util.rotateShape
|
||||
import com.cobblemon.mod.common.util.toEquipmentSlot
|
||||
import com.mojang.serialization.MapCodec
|
||||
import com.mojang.serialization.codecs.PrimitiveCodec
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder
|
||||
import net.minecraft.core.BlockPos
|
||||
import net.minecraft.core.Direction
|
||||
import net.minecraft.core.particles.BlockParticleOption
|
||||
import net.minecraft.core.particles.ColorParticleOption
|
||||
import net.minecraft.core.particles.ParticleTypes
|
||||
@@ -35,11 +37,13 @@ import net.minecraft.world.entity.player.Player
|
||||
import net.minecraft.world.entity.projectile.Projectile
|
||||
import net.minecraft.world.item.ItemStack
|
||||
import net.minecraft.world.item.Items
|
||||
import net.minecraft.world.item.context.BlockPlaceContext
|
||||
import net.minecraft.world.level.BlockGetter
|
||||
import net.minecraft.world.level.Level
|
||||
import net.minecraft.world.level.LevelAccessor
|
||||
import net.minecraft.world.level.LevelReader
|
||||
import net.minecraft.world.level.block.*
|
||||
import net.minecraft.world.level.block.HorizontalDirectionalBlock.FACING
|
||||
import net.minecraft.world.level.block.entity.BlockEntity
|
||||
import net.minecraft.world.level.block.state.BlockState
|
||||
import net.minecraft.world.level.block.state.StateDefinition
|
||||
@@ -89,7 +93,7 @@ class PokeSnackBlock(settings: Properties, val isLure: Boolean): BaseEntityBlock
|
||||
|
||||
private val CANDLE_SHAPE = Shapes.box(0.4375, CAKE_HEIGHT, 0.4375, 0.5625, 0.8125, 0.5625)
|
||||
|
||||
private val SHAPES = listOf(
|
||||
private val SOUTH_SHAPES = listOf(
|
||||
Shapes.box(0.0625, 0.0, 0.0625, 0.9375, CAKE_HEIGHT, 0.9375),
|
||||
Shapes.or(
|
||||
Shapes.box(0.3125, 0.0, 0.0625, 0.9375, CAKE_HEIGHT, 0.9375),
|
||||
@@ -112,10 +116,19 @@ class PokeSnackBlock(settings: Properties, val isLure: Boolean): BaseEntityBlock
|
||||
Shapes.box(0.0625, 0.0, 0.3125, 0.6875, CAKE_HEIGHT, 0.6875),
|
||||
Shapes.box(0.3125, 0.0, 0.3125, 0.6875, CAKE_HEIGHT, 0.6875)
|
||||
)
|
||||
|
||||
private val NORTH_SHAPES = createShapes(Direction.NORTH)
|
||||
private val WEST_SHAPES = createShapes(Direction.WEST)
|
||||
private val EAST_SHAPES = createShapes(Direction.EAST)
|
||||
|
||||
private fun createShapes(to: Direction): List<VoxelShape> {
|
||||
return SOUTH_SHAPES.map { rotateShape(Direction.SOUTH, to, it) }
|
||||
}
|
||||
}
|
||||
|
||||
init {
|
||||
registerDefaultState(stateDefinition.any()
|
||||
.setValue(FACING, Direction.NORTH)
|
||||
.setValue(BITES, 0)
|
||||
.setValue(CANDLE, 0)
|
||||
.setValue(BlockStateProperties.LIT, false)
|
||||
@@ -128,27 +141,56 @@ class PokeSnackBlock(settings: Properties, val isLure: Boolean): BaseEntityBlock
|
||||
).apply(it, ::PokeSnackBlock) }
|
||||
|
||||
override fun createBlockStateDefinition(builder: StateDefinition.Builder<Block?, BlockState?>) {
|
||||
builder.add(BITES, CANDLE, BlockStateProperties.LIT)
|
||||
builder.add(FACING, BITES, CANDLE, BlockStateProperties.LIT)
|
||||
}
|
||||
|
||||
override fun newBlockEntity(pos: BlockPos, state: BlockState): BlockEntity = PokeSnackBlockEntity(pos, state)
|
||||
|
||||
override fun getShape(state: BlockState, level: BlockGetter, pos: BlockPos, context: CollisionContext): VoxelShape? {
|
||||
if (hasCandle(state)) {
|
||||
return Shapes.or(SHAPES[state.getValue(BITES)], CANDLE_SHAPE)
|
||||
val snackShapes = when (state.getValue(FACING)) {
|
||||
Direction.SOUTH -> SOUTH_SHAPES
|
||||
Direction.WEST -> WEST_SHAPES
|
||||
Direction.EAST -> EAST_SHAPES
|
||||
else -> NORTH_SHAPES
|
||||
}
|
||||
|
||||
return SHAPES[state.getValue(BITES)]
|
||||
var snackShape = snackShapes[state.getValue(BITES)]
|
||||
if (hasCandle(state)) {
|
||||
snackShape = Shapes.or(snackShape, CANDLE_SHAPE)
|
||||
}
|
||||
|
||||
return snackShape
|
||||
}
|
||||
|
||||
override fun getRenderShape(blockState: BlockState) = RenderShape.MODEL
|
||||
|
||||
override fun getStateForPlacement(ctx: BlockPlaceContext): BlockState? {
|
||||
var blockState = defaultBlockState()
|
||||
val worldView = ctx.level
|
||||
val blockPos = ctx.clickedPos
|
||||
ctx.nearestLookingDirections.forEach { direction ->
|
||||
if (direction.axis.isHorizontal) {
|
||||
blockState = blockState
|
||||
.setValue(FACING, direction)
|
||||
as BlockState
|
||||
if (blockState.canSurvive(worldView, blockPos)) {
|
||||
return blockState
|
||||
}
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
override fun setPlacedBy(level: Level, pos: BlockPos, state: BlockState, placer: LivingEntity?, stack: ItemStack) {
|
||||
super.setPlacedBy(level, pos, state, placer, stack)
|
||||
|
||||
val blockEntity = level.getBlockEntity(pos) as? PokeSnackBlockEntity ?: return
|
||||
|
||||
blockEntity.initializeFromItemStack(stack)
|
||||
blockEntity.placedBy = placer?.uuid
|
||||
|
||||
blockEntity.setChanged()
|
||||
level.sendBlockUpdated(pos, state, state, UPDATE_CLIENTS)
|
||||
}
|
||||
|
||||
override fun getCloneItemStack(level: LevelReader, pos: BlockPos, state: BlockState): ItemStack {
|
||||
|
||||
@@ -358,7 +358,7 @@ class BerryBlockEntity(pos: BlockPos, state: BlockState) : BlockEntity(Cobblemon
|
||||
if (blockEntity.stageTimer >= 0) {
|
||||
blockEntity.stageTimer--
|
||||
}
|
||||
if (blockEntity.stageTimer == 0) {
|
||||
if (blockEntity.stageTimer <= 0) {
|
||||
(state.block as BerryBlock).growHelper(world as ServerLevel, world.random, pos, state)
|
||||
}
|
||||
}
|
||||
@@ -372,4 +372,4 @@ class BerryBlockEntity(pos: BlockPos, state: BlockState) : BlockEntity(Cobblemon
|
||||
private const val MULCH_VARIANT = "MulchVariant"
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+74
-31
@@ -11,12 +11,15 @@ package com.cobblemon.mod.common.block.entity
|
||||
import com.cobblemon.mod.common.Cobblemon
|
||||
import com.cobblemon.mod.common.CobblemonBlockEntities
|
||||
import com.cobblemon.mod.common.CobblemonItemComponents
|
||||
import com.cobblemon.mod.common.api.cooking.getColourMixFromFlavours
|
||||
import com.cobblemon.mod.common.api.cooking.getColourMixFromColors
|
||||
import com.cobblemon.mod.common.api.events.CobblemonEvents
|
||||
import com.cobblemon.mod.common.api.events.cooking.PokeSnackSpawnPokemonEvent
|
||||
import com.cobblemon.mod.common.api.fishing.SpawnBait
|
||||
import com.cobblemon.mod.common.api.fishing.SpawnBait.Effect
|
||||
import com.cobblemon.mod.common.api.fishing.SpawnBaitEffects
|
||||
import com.cobblemon.mod.common.api.spawning.CobblemonSpawnPools
|
||||
import com.cobblemon.mod.common.api.spawning.SpawnCause
|
||||
import com.cobblemon.mod.common.api.spawning.detail.EntitySpawnResult
|
||||
import com.cobblemon.mod.common.api.spawning.detail.PokemonHerdSpawnDetail
|
||||
import com.cobblemon.mod.common.api.spawning.detail.SpawnAction
|
||||
import com.cobblemon.mod.common.api.spawning.detail.SpawnDetail
|
||||
@@ -29,7 +32,7 @@ import com.cobblemon.mod.common.api.spawning.spawner.FixedAreaSpawner
|
||||
import com.cobblemon.mod.common.block.PokeSnackBlock
|
||||
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity
|
||||
import com.cobblemon.mod.common.item.components.BaitEffectsComponent
|
||||
import com.cobblemon.mod.common.item.components.FlavourComponent
|
||||
import com.cobblemon.mod.common.item.components.FoodColourComponent
|
||||
import com.cobblemon.mod.common.item.components.IngredientComponent
|
||||
import com.cobblemon.mod.common.net.messages.client.effect.PokeSnackBlockParticlesPacket
|
||||
import com.cobblemon.mod.common.util.DataKeys
|
||||
@@ -38,11 +41,15 @@ import net.minecraft.core.BlockPos
|
||||
import net.minecraft.core.HolderLookup
|
||||
import net.minecraft.nbt.CompoundTag
|
||||
import net.minecraft.nbt.NbtOps
|
||||
import net.minecraft.network.protocol.Packet
|
||||
import net.minecraft.network.protocol.game.ClientGamePacketListener
|
||||
import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket
|
||||
import net.minecraft.server.level.ServerLevel
|
||||
import net.minecraft.world.entity.Entity
|
||||
import net.minecraft.world.entity.player.Player
|
||||
import net.minecraft.world.item.ItemStack
|
||||
import net.minecraft.world.level.block.state.BlockState
|
||||
import java.util.*
|
||||
|
||||
open class PokeSnackBlockEntity(pos: BlockPos, state: BlockState) :
|
||||
TintBlockEntity(CobblemonBlockEntities.POKE_SNACK, pos, state),
|
||||
@@ -119,18 +126,18 @@ open class PokeSnackBlockEntity(pos: BlockPos, state: BlockState) :
|
||||
|
||||
var placedBy: UUID? = null
|
||||
var amountSpawned: Int = 0
|
||||
var flavourComponent: FlavourComponent? = null
|
||||
var foodColourComponent: FoodColourComponent? = null
|
||||
var baitEffectsComponent: BaitEffectsComponent? = null
|
||||
var ingredientComponent: IngredientComponent? = null
|
||||
var randomTicksUntilNextSpawn: Float = getRandomTicksBetweenSpawns()
|
||||
|
||||
fun initializeFromItemStack(itemStack: ItemStack) {
|
||||
flavourComponent = itemStack.get(CobblemonItemComponents.FLAVOUR)
|
||||
foodColourComponent = itemStack.get(CobblemonItemComponents.FOOD_COLOUR)
|
||||
ingredientComponent = itemStack.get(CobblemonItemComponents.INGREDIENT)
|
||||
if (isLure()) baitEffectsComponent = itemStack.get(CobblemonItemComponents.BAIT_EFFECTS)
|
||||
|
||||
flavourComponent?.let {
|
||||
getColourMixFromFlavours(it.getDominantFlavours())?.let(::setTint)
|
||||
foodColourComponent?.let {
|
||||
getColourMixFromColors(it.getColoursAsARGB())?.let(::setTint)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,23 +151,51 @@ open class PokeSnackBlockEntity(pos: BlockPos, state: BlockState) :
|
||||
|
||||
fun randomTick() {
|
||||
randomTicksUntilNextSpawn--
|
||||
if (randomTicksUntilNextSpawn <= 0) {
|
||||
val nearestPlayer = level?.getNearestPlayer(
|
||||
blockPos.x.toDouble(),
|
||||
blockPos.y.toDouble(),
|
||||
blockPos.z.toDouble(),
|
||||
Cobblemon.config.maximumSpawningZoneDistanceFromPlayer.toDouble(),
|
||||
false, // true here makes it so creative players aren't considered
|
||||
)
|
||||
// High simulation distances may cause the player to be null here, we don't want to spawn without a player nearby.
|
||||
if (nearestPlayer != null) {
|
||||
spawner.run(
|
||||
cause = SpawnCause(spawner = spawner, entity = nearestPlayer),
|
||||
maxSpawns = 1
|
||||
)
|
||||
}
|
||||
randomTicksUntilNextSpawn = getRandomTicksBetweenSpawns()
|
||||
if (randomTicksUntilNextSpawn > 0) {
|
||||
return
|
||||
}
|
||||
|
||||
val nearestPlayer = level?.getNearestPlayer(
|
||||
blockPos.x.toDouble(),
|
||||
blockPos.y.toDouble(),
|
||||
blockPos.z.toDouble(),
|
||||
Cobblemon.config.maximumSpawningZoneDistanceFromPlayer.toDouble(),
|
||||
false, // true here makes it so creative players aren't considered
|
||||
)
|
||||
|
||||
// High simulation distances may cause the player to be null here, we don't want to spawn without a player nearby.
|
||||
if (nearestPlayer != null) {
|
||||
attemptSpawn(nearestPlayer)
|
||||
}
|
||||
|
||||
randomTicksUntilNextSpawn = getRandomTicksBetweenSpawns()
|
||||
}
|
||||
|
||||
fun attemptSpawn(player: Player) {
|
||||
val cause = SpawnCause(spawner = spawner, entity = player)
|
||||
val zoneInput = spawner.getZoneInput(cause)
|
||||
val spawnAction = spawner.calculateSpawnActionsForArea(zoneInput, 1).firstOrNull()
|
||||
|
||||
if (spawnAction == null) {
|
||||
return
|
||||
}
|
||||
|
||||
CobblemonEvents.POKE_SNACK_SPAWN_POKEMON_PRE.postThen(
|
||||
PokeSnackSpawnPokemonEvent.Pre(this, spawnAction),
|
||||
{ },
|
||||
{ event ->
|
||||
spawnAction.complete()
|
||||
val result = spawnAction.future
|
||||
val resultingSpawn = result.get()
|
||||
|
||||
if (resultingSpawn is EntitySpawnResult) {
|
||||
val pokemonEntity = resultingSpawn.entities.firstOrNull() as PokemonEntity
|
||||
CobblemonEvents.POKE_SNACK_SPAWN_POKEMON_POST.post(
|
||||
PokeSnackSpawnPokemonEvent.Post(this, spawnAction, pokemonEntity)
|
||||
)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
fun getRandomTicksBetweenSpawns(): Float {
|
||||
@@ -188,8 +223,8 @@ open class PokeSnackBlockEntity(pos: BlockPos, state: BlockState) :
|
||||
stack.set(CobblemonItemComponents.BAIT_EFFECTS, baitEffectsComponent)
|
||||
}
|
||||
|
||||
if (flavourComponent != null) {
|
||||
stack.set(CobblemonItemComponents.FLAVOUR, flavourComponent)
|
||||
if (foodColourComponent != null) {
|
||||
stack.set(CobblemonItemComponents.FOOD_COLOUR, foodColourComponent)
|
||||
}
|
||||
|
||||
if (ingredientComponent != null) {
|
||||
@@ -215,12 +250,12 @@ open class PokeSnackBlockEntity(pos: BlockPos, state: BlockState) :
|
||||
|
||||
tag.putInt(DataKeys.AMOUNT_SPAWNED, amountSpawned)
|
||||
|
||||
flavourComponent?.let { component ->
|
||||
CobblemonItemComponents.FLAVOUR.codec()!!
|
||||
foodColourComponent?.let { component ->
|
||||
CobblemonItemComponents.FOOD_COLOUR.codec()!!
|
||||
.encodeStart(NbtOps.INSTANCE, component)
|
||||
.result()
|
||||
.ifPresent { encodedTag ->
|
||||
tag.put(DataKeys.FLAVOUR, encodedTag)
|
||||
tag.put(DataKeys.FOOD_COLOUR, encodedTag)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -254,12 +289,12 @@ open class PokeSnackBlockEntity(pos: BlockPos, state: BlockState) :
|
||||
|
||||
amountSpawned = tag.getInt(DataKeys.AMOUNT_SPAWNED)
|
||||
|
||||
if (tag.contains(DataKeys.FLAVOUR)) {
|
||||
CobblemonItemComponents.FLAVOUR.codec()
|
||||
?.parse(NbtOps.INSTANCE, tag.get(DataKeys.FLAVOUR))
|
||||
if (tag.contains(DataKeys.FOOD_COLOUR)) {
|
||||
CobblemonItemComponents.FOOD_COLOUR.codec()
|
||||
?.parse(NbtOps.INSTANCE, tag.get(DataKeys.FOOD_COLOUR))
|
||||
?.result()
|
||||
?.ifPresent { component ->
|
||||
flavourComponent = component
|
||||
foodColourComponent = component
|
||||
}
|
||||
}
|
||||
|
||||
@@ -289,4 +324,12 @@ open class PokeSnackBlockEntity(pos: BlockPos, state: BlockState) :
|
||||
placedBy = tag.getUUID(DataKeys.PLACED_BY)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getUpdateTag(registryLookup: HolderLookup.Provider): CompoundTag {
|
||||
return saveWithoutMetadata(registryLookup)
|
||||
}
|
||||
|
||||
override fun getUpdatePacket(): Packet<ClientGamePacketListener?>? {
|
||||
return ClientboundBlockEntityDataPacket.create(this)
|
||||
}
|
||||
}
|
||||
@@ -231,7 +231,8 @@ object CobblemonClient {
|
||||
this.implementation.registerBlockRenderType(
|
||||
RenderType.cutoutMipped(),
|
||||
CobblemonBlocks.APRICORN_LEAVES,
|
||||
CobblemonBlocks.SACCHARINE_LEAVES
|
||||
CobblemonBlocks.SACCHARINE_LEAVES,
|
||||
CobblemonBlocks.POKE_CAKE
|
||||
)
|
||||
|
||||
this.implementation.registerBlockRenderType(
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* 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
|
||||
|
||||
import org.joml.Quaternionf
|
||||
import org.spongepowered.asm.mixin.Unique
|
||||
|
||||
interface RidingCameraInterface {
|
||||
// Used to help in camera rotation rendering when transitioning
|
||||
// from rolled to unrolled.
|
||||
@Unique
|
||||
fun `getCobblemon$returnTimer`(): Float
|
||||
|
||||
@Unique
|
||||
fun `setCobblemon$returnTimer`(time: Float)
|
||||
|
||||
@Unique
|
||||
fun `getCobblemon$lastHandledRotationTime`(): Double
|
||||
|
||||
@Unique
|
||||
fun `setCobblemon$lastHandledRotationTime`(time: Double)
|
||||
|
||||
@Unique
|
||||
fun `getCobblemon$frameTime`(): Double
|
||||
|
||||
@Unique
|
||||
fun `setCobblemon$frameTime`(time: Double)
|
||||
|
||||
@Unique
|
||||
fun `getCobblemon$partialTickTime`(): Float
|
||||
|
||||
@Unique
|
||||
fun `setCobblemon$partialTickTime`(time: Float)
|
||||
|
||||
@Unique
|
||||
fun `getCobblemon$rollAngleStart`(): Float
|
||||
|
||||
@Unique
|
||||
fun `setCobblemon$rollAngleStart`(angle: Float)
|
||||
|
||||
fun `getCobblemon$smoothRotation`(): Quaternionf?
|
||||
|
||||
fun `setCobblemon$smoothRotation`(smoothRotation: Quaternionf)
|
||||
}
|
||||
+3
-1
@@ -341,6 +341,8 @@ class PokemonClientDelegate : PosableState(), PokemonSideDelegate {
|
||||
} else {
|
||||
phaseTarget = null
|
||||
}
|
||||
} else if (data == PokemonEntity.SCALE_MODIFIER) {
|
||||
currentEntity.pokemon.scaleModifier = currentEntity.entityData.get(PokemonEntity.SCALE_MODIFIER)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -525,4 +527,4 @@ class PokemonClientDelegate : PosableState(), PokemonSideDelegate {
|
||||
this.getEntity().z + offset.z
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
+7
-2
@@ -260,8 +260,13 @@ class StatWidget(
|
||||
val barPosX = x + 9F
|
||||
var drawY = y + 15F
|
||||
|
||||
val featuresList: MutableList<Any> = renderableFeatures.toMutableList()
|
||||
featuresList.addAll(0, universalFeatures)
|
||||
val featuresList: MutableList<Any> = renderableFeatures.filter {
|
||||
!pokemon.aspects.contains("hide-" + it.name)
|
||||
}.toMutableList()
|
||||
|
||||
featuresList.addAll(0, universalFeatures.filter {
|
||||
!pokemon.aspects.contains("hide-" + it.name)
|
||||
})
|
||||
|
||||
val pageFeatures = featuresList.subList(
|
||||
otherStatsPageIndex * OTHER_STAT_BARS_PER_PAGE,
|
||||
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* 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.CobblemonMechanics
|
||||
import com.cobblemon.mod.common.api.net.ClientNetworkPacketHandler
|
||||
import com.cobblemon.mod.common.net.messages.client.data.CobblemonMechanicsSyncPacket
|
||||
import net.minecraft.client.Minecraft
|
||||
|
||||
object CobblemonMechanicsSyncHandler : ClientNetworkPacketHandler<CobblemonMechanicsSyncPacket> {
|
||||
|
||||
override fun handle(packet: CobblemonMechanicsSyncPacket, client: Minecraft) {
|
||||
CobblemonMechanics.remedies = packet.remedies
|
||||
CobblemonMechanics.berries = packet.berries
|
||||
CobblemonMechanics.potions = packet.potions
|
||||
CobblemonMechanics.aprijuices = packet.aprijuices
|
||||
}
|
||||
}
|
||||
+19
@@ -23,12 +23,31 @@ import net.minecraft.client.renderer.MultiBufferSource
|
||||
import net.minecraft.client.renderer.RenderType
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider
|
||||
import net.minecraft.core.Direction
|
||||
import net.minecraft.world.level.block.HorizontalDirectionalBlock.FACING
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties.LIT
|
||||
|
||||
open class PokeSnackBlockEntityRenderer(ctx: BlockEntityRendererProvider.Context) : BlockEntityRenderer<PokeSnackBlockEntity> {
|
||||
override fun render(blockEntity: PokeSnackBlockEntity, partialTick: Float, poseStack: PoseStack, bufferSource: MultiBufferSource, packedLight: Int, packedOverlay: Int) {
|
||||
poseStack.pushPose()
|
||||
|
||||
val facing = blockEntity.blockState.getValue(FACING)
|
||||
val rotationAngle = when (facing) {
|
||||
Direction.NORTH -> 180F
|
||||
Direction.SOUTH -> 0F
|
||||
Direction.WEST -> 90F
|
||||
Direction.EAST -> -90F
|
||||
else -> 0f
|
||||
}
|
||||
|
||||
poseStack.translate(0.5, 0.5, 0.5)
|
||||
poseStack.mulPose(com.mojang.math.Axis.YP.rotationDegrees(rotationAngle))
|
||||
poseStack.translate(-0.5, -0.5, -0.5)
|
||||
|
||||
val hasCandle = renderCandle(blockEntity, poseStack, bufferSource, packedLight, packedOverlay)
|
||||
renderBerries(blockEntity, poseStack, bufferSource, packedLight, packedOverlay, hasCandle)
|
||||
|
||||
poseStack.popPose()
|
||||
}
|
||||
|
||||
fun renderCandle(blockEntity: PokeSnackBlockEntity, poseStack: PoseStack, bufferSource: MultiBufferSource, packedLight: Int, packedOverlay: Int): Boolean {
|
||||
|
||||
+234
-34
@@ -10,15 +10,20 @@ package com.cobblemon.mod.common.client.render.camera
|
||||
|
||||
import com.cobblemon.mod.common.Cobblemon
|
||||
import com.cobblemon.mod.common.OrientationControllable
|
||||
import com.cobblemon.mod.common.client.MountedPokemonAnimationRenderController.setup
|
||||
import com.cobblemon.mod.common.api.orientation.OrientationController
|
||||
import com.cobblemon.mod.common.api.orientation.OrientationController.Companion.FORWARDS
|
||||
import com.cobblemon.mod.common.api.orientation.OrientationController.Companion.LEFT
|
||||
import com.cobblemon.mod.common.api.orientation.OrientationController.Companion.UP
|
||||
import com.cobblemon.mod.common.client.MountedPokemonAnimationRenderController
|
||||
import com.cobblemon.mod.common.client.entity.PokemonClientDelegate
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.FloatingState
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.PosableModel
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.repository.VaryingModelRepository.getPoser
|
||||
import com.cobblemon.mod.common.duck.CameraDuck
|
||||
import com.cobblemon.mod.common.duck.RidePassenger
|
||||
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity
|
||||
import com.cobblemon.mod.common.mixin.accessor.CameraAccessor
|
||||
import com.cobblemon.mod.common.util.math.geometry.toRadians
|
||||
import com.mojang.blaze3d.Blaze3D
|
||||
import net.minecraft.client.Camera
|
||||
import net.minecraft.client.CameraType
|
||||
import net.minecraft.client.Minecraft
|
||||
@@ -27,21 +32,28 @@ import net.minecraft.world.entity.Entity
|
||||
import net.minecraft.world.level.ClipContext
|
||||
import net.minecraft.world.phys.HitResult
|
||||
import net.minecraft.world.phys.Vec3
|
||||
import org.joml.Matrix3f
|
||||
import org.joml.Quaternionf
|
||||
import org.joml.Vector3f
|
||||
import kotlin.math.min
|
||||
import kotlin.math.sign
|
||||
import kotlin.math.sin
|
||||
|
||||
object MountedCameraRenderer {
|
||||
private var returnTimer: Float = 0f
|
||||
private var lastHandledRotationTime: Double = Double.MIN_VALUE
|
||||
private var frameTime: Double = 0.0
|
||||
private var rollAngleStart: Float = 0f
|
||||
|
||||
var smoothRotation: Quaternionf? = null
|
||||
|
||||
object MountedCameraRenderer
|
||||
{
|
||||
fun getCameraPosition(
|
||||
instance: Camera,
|
||||
driver: Entity,
|
||||
vehicle: Entity,
|
||||
x: Double,
|
||||
y: Double,
|
||||
z: Double,
|
||||
thirdPersonReverse: Boolean,
|
||||
eyeHeightOld: Double,
|
||||
eyeHeight: Double
|
||||
eyeHeight: Double,
|
||||
eyeHeightOld: Double
|
||||
): Vec3? {
|
||||
if (vehicle !is PokemonEntity) {
|
||||
return null
|
||||
@@ -53,7 +65,7 @@ object MountedCameraRenderer
|
||||
Mth.lerp(instance.partialTickTime.toDouble(), vehicle.yOld, vehicle.y),
|
||||
Mth.lerp(instance.partialTickTime.toDouble(), vehicle.zOld, vehicle.z)
|
||||
)
|
||||
setup(vehicle, instance.partialTickTime)
|
||||
MountedPokemonAnimationRenderController.setup(vehicle, instance.partialTickTime)
|
||||
val rollable = vehicle as OrientationControllable
|
||||
val vehicleController = rollable.getOrientationController()
|
||||
|
||||
@@ -62,44 +74,40 @@ object MountedCameraRenderer
|
||||
val locatorName = delegate.getSeatLocator(driver)
|
||||
val locator = delegate.locatorStates[locatorName] ?: return null
|
||||
|
||||
// Get additional offset from poser and add to the eyeHeight offset
|
||||
val currEyeHeight: Double = Mth.lerp(instance.partialTickTime.toDouble(), eyeHeight, eyeHeightOld)
|
||||
val offset = Vector3f(0f, (currEyeHeight - (driver.bbHeight / 2)).toFloat(), 0f)
|
||||
val eyeOffset = Vector3f(0f, (currEyeHeight - (driver.bbHeight / 2)).toFloat(), 0f)
|
||||
|
||||
// Get additional offset from poser and add to the eyeHeight offset
|
||||
val shouldFlip = !(vehicleController.active && vehicleController.orientation != null) // Do not flip the offset for 3rd person reverse unless we are using normal mc camera rotation.
|
||||
val isFirstPerson = Minecraft.getInstance().options.getCameraType() == CameraType.FIRST_PERSON
|
||||
val isFirstPerson = Minecraft.getInstance().options.cameraType == CameraType.FIRST_PERSON
|
||||
|
||||
val rotMatrix = if (vehicleController.isActive()) vehicleController.getRenderOrientation(instance.partialTickTime)
|
||||
val offsetQuat = if (vehicleController.isActive()) vehicleController.getRenderOrientation(instance.partialTickTime)
|
||||
else Quaternionf()
|
||||
.rotateY((180f - Mth.lerp(instance.partialTickTime, vehicle.yBodyRotO, vehicle.yBodyRot).toRadians()))
|
||||
.rotateX(-1 * Mth.lerp(instance.partialTickTime, vehicle.xRotO, vehicle.xRot).toRadians())
|
||||
.rotateY((Math.PI.toFloat() - Mth.lerp(instance.partialTickTime, vehicle.yRotO, vehicle.yRot).toRadians()))
|
||||
|
||||
eyeOffset.add(getFirstPersonOffset(model, locatorName))
|
||||
if (isFirstPerson) {
|
||||
offset.add(
|
||||
offset.add(
|
||||
if (isFirstPerson) {
|
||||
getFirstPersonOffset(model, locatorName)
|
||||
)
|
||||
} else if (Cobblemon.config.thirdPersonViewBobbing) {
|
||||
offset.add(
|
||||
} else if (Cobblemon.config.thirdPersonViewBobbing) {
|
||||
getThirdPersonOffset(thirdPersonReverse, model.thirdPersonCameraOffset, locatorName, shouldFlip)
|
||||
)
|
||||
} else {
|
||||
offset.add(
|
||||
} else {
|
||||
getThirdPersonOffset(thirdPersonReverse, model.thirdPersonCameraOffsetNoViewBobbing, locatorName, shouldFlip)
|
||||
)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
// Grab the pokemon's orientation to use as the offset rotation.
|
||||
rotMatrix.transform(offset)
|
||||
rotMatrix.transform(eyeOffset)
|
||||
offsetQuat.transform(offset)
|
||||
offsetQuat.transform(eyeOffset)
|
||||
|
||||
val eyeLocatorOffset = Vec3(locator.matrix.getTranslation(Vector3f()))
|
||||
val eyePos = eyeLocatorOffset.add(entityPos).toVector3f()
|
||||
|
||||
// Get the camera position. If 3rd person viewbobbing is enabled or the player is
|
||||
// in first person then base the camera position off the seat locator offset
|
||||
val pos = if (!isFirstPerson || Cobblemon.config.thirdPersonViewBobbing) {
|
||||
val pos = if (isFirstPerson || Cobblemon.config.thirdPersonViewBobbing) {
|
||||
val locatorOffset = Vec3(locator.matrix.getTranslation(Vector3f()))
|
||||
locatorOffset.add(entityPos).toVector3f()
|
||||
} else {
|
||||
@@ -109,10 +117,9 @@ object MountedCameraRenderer
|
||||
val pivot = Vector3f(pokemonCenter)
|
||||
val locatorName = delegate.getSeatLocator(driver)
|
||||
if (pivotOffsets.containsKey(locatorName)) {
|
||||
val orientation = vehicleController.getRenderOrientation(instance.partialTickTime)
|
||||
pivot.add(orientation.transform(pivotOffsets[locatorName]!!.toVector3f()))
|
||||
pivot.add(offsetQuat.transform(pivotOffsets[locatorName]!!.toVector3f()))
|
||||
}
|
||||
entityPos.toVector3f().add(pivot)
|
||||
pivot.add(entityPos.toVector3f())
|
||||
}
|
||||
|
||||
val offsetDistance = offset.length()
|
||||
@@ -130,6 +137,192 @@ object MountedCameraRenderer
|
||||
return Vec3(offsetDirection.mul(maxZoom).add(pos))
|
||||
}
|
||||
|
||||
// Return value determines whether vanilla rotations are applied
|
||||
fun setRotation(instance: Camera): Boolean {
|
||||
val cameraDuck = instance as CameraDuck
|
||||
|
||||
// Calculate the current frametime
|
||||
val d = Blaze3D.getTime()
|
||||
frameTime = if (lastHandledRotationTime != Double.Companion.MIN_VALUE) d - lastHandledRotationTime else 0.0
|
||||
lastHandledRotationTime = d
|
||||
|
||||
// Don't assume the camera to be attached to an entity. Ponder Scenes from create et.al. for example aren't.
|
||||
val vehicle: Entity? = cameraDuck.`cobblemon$getEntity`()?.vehicle ?: return false
|
||||
if (vehicle !is OrientationControllable) return false
|
||||
|
||||
// If the current vehicle has no orientation then return and perform
|
||||
// vanilla camera rotations
|
||||
val vehicleController = vehicle.getOrientationController()
|
||||
if (vehicleController.orientation == null) return false
|
||||
|
||||
|
||||
// If the controller has been deactivated but the orientation isn't null yet
|
||||
// then perform transition from rolled ride/camera to vanilla
|
||||
if (!vehicleController.isActive() && vehicleController.orientation != null) {
|
||||
return applyTransitionRotation(vehicleController, instance)
|
||||
} else { // Otherwise perform cobblemon specific camera rotation and set transition helper variables
|
||||
applyCameraRotation(instance)
|
||||
returnTimer = 0f
|
||||
rollAngleStart = instance.rotation().getEulerAnglesYXZ(Vector3f()).z()
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
fun applyCameraRotation(instance: Camera) {
|
||||
val cameraDuck = instance as CameraDuck
|
||||
|
||||
val driver = cameraDuck.`cobblemon$getEntity`() ?: return
|
||||
val vehicle = driver.vehicle ?: return
|
||||
val controllableVehicle = vehicle as? OrientationControllable ?: return
|
||||
if (vehicle.getOrientationController().orientation == null || !controllableVehicle.getOrientationController().active) return
|
||||
|
||||
// Grab the driver and vehicle orientation controllers.
|
||||
val vehicleController: OrientationController = controllableVehicle.getOrientationController()
|
||||
|
||||
val isDriving = driver.controlledVehicle != null
|
||||
|
||||
|
||||
// Grab the ride orientation
|
||||
// If the player is driving then use the current orientation since the driver sets it.
|
||||
// If not then use the smoothed render orientation for passengers otherwise the vehicle rotation will be jerky
|
||||
var newRotation = if (isDriving) {
|
||||
vehicleController.orientation!!.normal(Matrix3f()).getNormalizedRotation(Quaternionf())
|
||||
} else {
|
||||
vehicleController.getRenderOrientation(instance.partialTickTime)
|
||||
}
|
||||
|
||||
// Unroll the current rotation if no roll is requested and not currently freelooking
|
||||
if (Cobblemon.config.disableRoll) {
|
||||
// Init the smooth rotation if it has not been set yet.
|
||||
if (smoothRotation == null) {
|
||||
smoothRotation = Quaternionf().set(cameraDuck.`cobblemon$getRotation`())
|
||||
}
|
||||
val rideAngs = newRotation.getEulerAnglesYXZ(Vector3f())
|
||||
val cameraAngs = smoothRotation!!.getEulerAnglesYXZ(Vector3f())
|
||||
|
||||
val degDiff = Mth.degreesDifference(
|
||||
Math.toDegrees(cameraAngs.y().toDouble()).toFloat(),
|
||||
Math.toDegrees(rideAngs.y().toDouble()).toFloat()
|
||||
)
|
||||
|
||||
val pitchDeadzoneDeg = 15.0 // x degrees of deadzone about +-90 degrees of pitch.
|
||||
val pitchDeg = vehicleController.pitch
|
||||
// ConsiderPitch to be already 90 if within the deadzone around it.
|
||||
val cutoffPitch = min(1.0, (Mth.abs(pitchDeg) / (90.0f - pitchDeadzoneDeg))) * 90.0f * sign(pitchDeg)
|
||||
val lerpRateMod = Mth.cos(Math.toRadians(cutoffPitch).toFloat())
|
||||
|
||||
// Apply smoothing from the cameras current yaw to the yaw of the velocity
|
||||
// vector of the ride
|
||||
|
||||
// Some smoothing constant k. 0.0 when game is paused to prevent lerping when game isn't running.
|
||||
val k = if(Minecraft.getInstance().isPaused) 0.0f else 10.0f
|
||||
val smoothingFactor: Double = lerpRateMod * frameTime * k
|
||||
val newYaw = cameraAngs.y() + (Math.toRadians(degDiff.toDouble()) * smoothingFactor)
|
||||
|
||||
val newPitch = Mth.lerp(
|
||||
frameTime * k,
|
||||
cameraAngs.x().toDouble(),
|
||||
rideAngs.x().toDouble()
|
||||
)
|
||||
|
||||
//var newYaw = (float)Mth.lerp(smoothingFactor, cameraAngs.y(), rideAngs.y());
|
||||
val maxRoll = Math.toRadians(15.0)
|
||||
val newRoll = Mth.lerp(
|
||||
frameTime * k / 2.0,
|
||||
cameraAngs.z().toDouble(),
|
||||
Math.abs(lerpRateMod) * sin(rideAngs.z()) * maxRoll
|
||||
).toFloat()
|
||||
|
||||
// Set rotations
|
||||
val smoothedRot = Quaternionf().rotateYXZ(newYaw.toFloat(), newPitch.toFloat(), newRoll)
|
||||
smoothRotation?.set(smoothedRot)
|
||||
newRotation.set(smoothedRot)
|
||||
|
||||
}
|
||||
|
||||
var rotationOffset = 0
|
||||
if (Minecraft.getInstance().options.getCameraType().isMirrored()) {
|
||||
newRotation.rotateY(Math.toRadians(180.0).toFloat())
|
||||
rotationOffset = 180
|
||||
}
|
||||
|
||||
|
||||
// Get the drivers local look angle in relation to the ride and apply it.
|
||||
if (vehicleController.active) {
|
||||
val vehicleMatrix = Matrix3f().set(newRotation)
|
||||
val driverMatrix = Matrix3f() // Base the driver
|
||||
val playerRotater = driver as RidePassenger
|
||||
newRotation = vehicleMatrix.mul(
|
||||
driverMatrix.rotateYXZ(
|
||||
-Mth.DEG_TO_RAD * (playerRotater.`cobblemon$getRideYRot`()),
|
||||
-Mth.DEG_TO_RAD * playerRotater.`cobblemon$getRideXRot`(),
|
||||
0.0f
|
||||
)
|
||||
).normal(Matrix3f()).getNormalizedRotation(Quaternionf())
|
||||
}
|
||||
cameraDuck.`cobblemon$getRotation`().set(newRotation)
|
||||
val eulerAngs = newRotation.getEulerAnglesYXZ(Vector3f())
|
||||
cameraDuck.`cobblemon$setXRot`(eulerAngs.x() * Mth.RAD_TO_DEG)
|
||||
cameraDuck.`cobblemon$setYRot`(eulerAngs.y() * Mth.RAD_TO_DEG)
|
||||
|
||||
// Set the drivers rotations to match
|
||||
val driverEulerAngs: Vector3f = Quaternionf(cameraDuck.`cobblemon$getRotation`()).getEulerAnglesYXZ(Vector3f())
|
||||
driver.xRot = -driverEulerAngs.x() * Mth.RAD_TO_DEG + rotationOffset
|
||||
driver.yRot = 180.0f - (driverEulerAngs.y() * Mth.RAD_TO_DEG)
|
||||
|
||||
val cameraRotation = cameraDuck.`cobblemon$getRotation`()
|
||||
FORWARDS.rotate(cameraRotation, cameraDuck.`cobblemon$getForwards`())
|
||||
UP.rotate(cameraRotation, cameraDuck.`cobblemon$getUp`())
|
||||
LEFT.rotate(cameraRotation, cameraDuck.`cobblemon$getLeft`())
|
||||
}
|
||||
|
||||
private fun applyTransitionRotation(
|
||||
vehicleController: OrientationController,
|
||||
instance: Camera
|
||||
): Boolean {
|
||||
val cameraDuck = instance as CameraDuck
|
||||
val entity = cameraDuck.`cobblemon$getEntity`()!!
|
||||
// If the transition has just started then
|
||||
if (returnTimer == 0f) {
|
||||
resetDriverRotations(instance, entity)
|
||||
}
|
||||
|
||||
if (returnTimer < 1f) {
|
||||
// Rotation is taken from entity since we no longer handle mouse ourselves
|
||||
// Stops a period of time when you can't input anything.
|
||||
val interpolatedRoll = Mth.lerp(returnTimer, rollAngleStart, 0.0f)
|
||||
val pitch = Math.toRadians(-entity.xRot.toDouble()).toFloat()
|
||||
val yaw = Math.toRadians((180 - entity.yRot).toDouble()).toFloat()
|
||||
|
||||
val interRot = Quaternionf()
|
||||
interRot.rotationYXZ(yaw, pitch, interpolatedRoll)
|
||||
|
||||
cameraDuck.`cobblemon$getRotation`().set(interRot)
|
||||
val eulerAngs = interRot.getEulerAnglesYXZ(Vector3f())
|
||||
cameraDuck.`cobblemon$setXRot`(eulerAngs.x() * Mth.RAD_TO_DEG)
|
||||
cameraDuck.`cobblemon$setYRot`(eulerAngs.y() * Mth.RAD_TO_DEG)
|
||||
|
||||
val cameraRotation = cameraDuck.`cobblemon$getRotation`()
|
||||
FORWARDS.rotate(cameraRotation, cameraDuck.`cobblemon$getForwards`())
|
||||
UP.rotate(cameraRotation, cameraDuck.`cobblemon$getUp`())
|
||||
LEFT.rotate(cameraRotation, cameraDuck.`cobblemon$getLeft`())
|
||||
|
||||
if (rollAngleStart == 0f) {
|
||||
rollAngleStart = 1f
|
||||
vehicleController.reset()
|
||||
resetDriverRotations(instance, entity)
|
||||
return false
|
||||
}
|
||||
returnTimer += instance.partialTickTime * (1.0f / 20.0f)
|
||||
return true
|
||||
} else {
|
||||
returnTimer = 1f
|
||||
vehicleController.reset()
|
||||
resetDriverRotations(instance, entity)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
fun resetDriverRotations(
|
||||
instance: Camera,
|
||||
driver: Entity,
|
||||
@@ -153,7 +346,7 @@ object MountedCameraRenderer
|
||||
} else if (cameraOffsets.containsKey(locatorName)) {
|
||||
cameraOffsets[locatorName]!!.toVector3f()
|
||||
} else {
|
||||
Vector3f(0f, 2f, 4f)
|
||||
Vector3f(0f, 0f, 0f)
|
||||
}
|
||||
|
||||
// Don't need to account for this since orientation is derived from camera rotation and that z is already flipped.
|
||||
@@ -182,9 +375,16 @@ object MountedCameraRenderer
|
||||
val j = ((i shr 2 and 1) * 2 - 1).toFloat()
|
||||
val vec3 = pos.add((g * 0.1f).toDouble(), (h * 0.1f).toDouble(), (j * 0.1f).toDouble())
|
||||
val vec32 = vec3.add(Vec3(directionVector).scale(maxZoom.toDouble()))
|
||||
val level = (instance as CameraAccessor).level
|
||||
val hitResult: HitResult =
|
||||
level.clip(ClipContext(vec3, vec32, ClipContext.Block.VISUAL, ClipContext.Fluid.NONE, instance.entity))
|
||||
val level = (instance as CameraDuck).`cobblemon$getLevel`()
|
||||
val hitResult: HitResult = level.clip(
|
||||
ClipContext(
|
||||
vec3,
|
||||
vec32,
|
||||
ClipContext.Block.VISUAL,
|
||||
ClipContext.Fluid.NONE,
|
||||
instance.entity
|
||||
)
|
||||
)
|
||||
if (hitResult.type != HitResult.Type.MISS) {
|
||||
val k = hitResult.getLocation().distanceToSqr(pos).toFloat()
|
||||
if (k < Mth.square(maxZoom)) {
|
||||
|
||||
+5
-3
@@ -9,7 +9,7 @@
|
||||
package com.cobblemon.mod.common.client.render.color
|
||||
|
||||
import com.cobblemon.mod.common.CobblemonItemComponents
|
||||
import com.cobblemon.mod.common.api.cooking.getColourMixFromFlavours
|
||||
import com.cobblemon.mod.common.api.cooking.getColourMixFromColors
|
||||
import net.minecraft.client.color.item.ItemColor
|
||||
import net.minecraft.world.item.ItemStack
|
||||
|
||||
@@ -17,11 +17,13 @@ object PokeSnackItemColorProvider : ItemColor {
|
||||
private const val BASE_LAYER_INDEX = 0
|
||||
|
||||
override fun getColor(stack: ItemStack, layer: Int): Int {
|
||||
val flavourComponent = stack.get(CobblemonItemComponents.FLAVOUR) ?: return -1
|
||||
val colorComponent = stack.get(CobblemonItemComponents.FOOD_COLOUR) ?: return -1
|
||||
|
||||
if (layer == BASE_LAYER_INDEX) {
|
||||
val colorMix = getColourMixFromFlavours(flavourComponent.getDominantFlavours())
|
||||
val colorMix = getColourMixFromColors(colorComponent.getColoursAsARGB())
|
||||
if (colorMix != null) return colorMix
|
||||
}
|
||||
|
||||
return -1
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -101,7 +101,7 @@ class LocatorAccess(
|
||||
// If we have the entity, put in a "top" locator for top center of hitbox.
|
||||
matrixStack.pushPose()
|
||||
matrixStack.mulPose(Axis.ZP.rotationDegrees(180f)) //Undo rotation from previous flip
|
||||
matrixStack.translate(0.0, entity.boundingBox.ysize, 0.0)
|
||||
matrixStack.translate(0.0, entity.boundingBox.ysize / scale, 0.0)
|
||||
state.getOrPut("top") { MatrixWrapper() }.updateMatrix(matrixStack.last().pose())
|
||||
matrixStack.popPose()
|
||||
}
|
||||
|
||||
+1
-1
@@ -841,4 +841,4 @@ open class PosableModel(@Transient override val rootPart: Bone) : ModelFrame {
|
||||
)
|
||||
|
||||
fun isReadyForAnimation() = ::context.isInitialized
|
||||
}
|
||||
}
|
||||
+26
-6
@@ -27,6 +27,7 @@ object FishingRodTooltipGenerator : TooltipGenerator() {
|
||||
|
||||
val rod = (stack.item as? PokerodItem)?.pokeRodId?.let { PokeRods.getPokeRod(it) } ?: return null
|
||||
val ball = PokeBalls.getPokeBall(rod.pokeBallId) ?: return null
|
||||
val baitComponent = stack.get(CobblemonItemComponents.BAIT)
|
||||
|
||||
// Add the description of the Poke Ball used in the rod
|
||||
ball.item.description.let {
|
||||
@@ -40,7 +41,7 @@ object FishingRodTooltipGenerator : TooltipGenerator() {
|
||||
val client = Minecraft.getInstance()
|
||||
val itemRegistry = client.level?.registryAccess()?.registryOrThrow(Registries.ITEM)
|
||||
itemRegistry?.let { registry ->
|
||||
stack.get(CobblemonItemComponents.BAIT)?.stack?.item?.description
|
||||
baitComponent?.stack?.item?.description
|
||||
?.let { // maybe this can be simplified to not use the FishingBaits to get the stack and just use PokerodItem to get the stack since we have it already
|
||||
val baitDescription = "cobblemon.pokerod.bait".asTranslated(it.copy().gray(), PokerodItem.getBaitStackOnRod(stack).count)
|
||||
resultLines.add(baitDescription)
|
||||
@@ -48,13 +49,32 @@ object FishingRodTooltipGenerator : TooltipGenerator() {
|
||||
}
|
||||
|
||||
// grey text for context for players on how to apply/remove bait to/from rod
|
||||
val greyText = if (SpawnBaitEffects.isFishingBait(stack)) {
|
||||
Component.translatable("cobblemon.pokerod.remove").gray()
|
||||
} else {
|
||||
Component.translatable("cobblemon.pokerod.apply").gray()
|
||||
}
|
||||
val greyText =
|
||||
if (baitComponent != null && SpawnBaitEffects.isFishingBait(baitComponent.stack)) {
|
||||
Component.translatable("cobblemon.pokerod.remove").gray()
|
||||
} else {
|
||||
Component.translatable("cobblemon.pokerod.apply").gray()
|
||||
}
|
||||
|
||||
resultLines.addLast(greyText)
|
||||
|
||||
return resultLines
|
||||
}
|
||||
|
||||
override fun generateAdditionalTooltip(
|
||||
stack: ItemStack,
|
||||
lines: MutableList<Component>
|
||||
): MutableList<Component>? {
|
||||
val resultLines = mutableListOf<Component>()
|
||||
|
||||
val baitComponent = stack.get(CobblemonItemComponents.BAIT)
|
||||
baitComponent?.let { component ->
|
||||
val effectLines = SeasoningTooltipGenerator.generateAdditionalTooltip(component.stack, lines)
|
||||
effectLines?.let { lines ->
|
||||
resultLines.addAll(lines)
|
||||
}
|
||||
}
|
||||
|
||||
return resultLines
|
||||
}
|
||||
}
|
||||
+11
-18
@@ -186,17 +186,15 @@ fun generateAdditionalBaitEffectTooltip(stack: ItemStack): MutableList<Component
|
||||
val resultLines = mutableListOf<Component>()
|
||||
|
||||
val rawEffects = mutableListOf<SpawnBait.Effect>().apply {
|
||||
if (stack.item is PokerodItem) {
|
||||
addAll(SpawnBaitEffects.getEffectsFromRodItemStack(stack))
|
||||
} else {
|
||||
addAll(SpawnBaitEffects.getEffectsFromItemStack(stack))
|
||||
}
|
||||
|
||||
if (Seasonings.isSeasoning(stack)) {
|
||||
val seasoningEffects = Seasonings.getBaitEffectsFromItemStack(stack)
|
||||
if (seasoningEffects.isNotEmpty()) {
|
||||
addAll(seasoningEffects)
|
||||
}
|
||||
} else if (stack.item is PokerodItem) {
|
||||
addAll(SpawnBaitEffects.getEffectsFromRodItemStack(stack))
|
||||
} else {
|
||||
addAll(SpawnBaitEffects.getEffectsFromItemStack(stack))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,6 +217,7 @@ fun generateAdditionalBaitEffectTooltip(stack: ItemStack): MutableList<Component
|
||||
val effectChance = effect.chance * 100
|
||||
var effectValue = when (effectType) {
|
||||
"bite_time" -> (effect.value * 100).toInt()
|
||||
"shiny_reroll" -> (effect.value + 1).toInt()
|
||||
else -> effect.value.toInt()
|
||||
}
|
||||
|
||||
@@ -244,18 +243,12 @@ fun generateAdditionalBaitEffectTooltip(stack: ItemStack): MutableList<Component
|
||||
} ?: Component.literal("cursed").obfuscate()
|
||||
} else Component.literal("cursed").obfuscate()
|
||||
|
||||
if (effectType == "shiny_reroll") {
|
||||
effectValue++
|
||||
}
|
||||
|
||||
resultLines.add(
|
||||
lang(
|
||||
"fishing_bait_effects.$effectType.tooltip",
|
||||
Component.literal(formatter.format(effectChance)).yellow(),
|
||||
subcategoryString.copy().gold(),
|
||||
Component.literal(formatter.format(effectValue)).green()
|
||||
)
|
||||
)
|
||||
resultLines.add(lang(
|
||||
"fishing_bait_effects.$effectType.tooltip",
|
||||
Component.literal(formatter.format(effectChance)).yellow(),
|
||||
subcategoryString.copy().gold(),
|
||||
Component.literal(formatter.format(effectValue)).green()
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -58,6 +58,9 @@ class CobblemonConfig {
|
||||
@LastChangedVersion("1.4.0")
|
||||
var ambientPokemonCryTicks = 1080
|
||||
|
||||
@CobblemonConfigField(Category.Storage, lang = "default_key_items", SERVER)
|
||||
var defaultKeyItems = mutableSetOf<ResourceLocation>()
|
||||
|
||||
@CobblemonConfigField(Category.Storage, lang = "default_box_count", SERVER)
|
||||
@IntConstraint(min = 1, max = 1000)
|
||||
@LastChangedVersion("1.7.0")
|
||||
@@ -315,7 +318,7 @@ class CobblemonConfig {
|
||||
var disableRoll = false
|
||||
|
||||
@CobblemonConfigField(Category.Riding, lang = "display_controls_duration_seconds", CLIENT)
|
||||
var displayControlSeconds = 3
|
||||
var displayControlSeconds = 0
|
||||
|
||||
@CobblemonConfigField(Category.Riding, lang = "infinite_ride_stamina", SERVER)
|
||||
var infiniteRideStamina = false
|
||||
@@ -328,13 +331,13 @@ class CobblemonConfig {
|
||||
|
||||
@CobblemonConfigField(Category.Spawning, lang = "despawner_near_distance", SERVER)
|
||||
var despawnerNearDistance = 32f
|
||||
|
||||
|
||||
@CobblemonConfigField(Category.Spawning, lang = "despawner_far_distance", SERVER)
|
||||
var despawnerFarDistance = 96f
|
||||
|
||||
|
||||
@CobblemonConfigField(Category.Spawning, lang = "despawner_min_age_ticks", SERVER)
|
||||
var despawnerMinAgeTicks = 600
|
||||
|
||||
|
||||
@CobblemonConfigField(Category.Spawning, lang = "despawner_max_age_ticks", SERVER)
|
||||
var despawnerMaxAgeTicks = 3600
|
||||
|
||||
@@ -351,4 +354,4 @@ class CobblemonConfig {
|
||||
}
|
||||
return newConfig
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -96,7 +96,7 @@ import net.minecraft.world.entity.player.Player
|
||||
import net.minecraft.world.level.Level
|
||||
import net.minecraft.world.level.material.FluidState
|
||||
|
||||
class NPCEntity(world: Level) : AgeableMob(CobblemonEntities.NPC, world), Npc, PosableEntity, PokemonSender, Schedulable, MoLangScriptingEntity, OmniPathingEntity {
|
||||
class NPCEntity(world: Level) : AgeableMob(CobblemonEntities.NPC, world), PosableEntity, PokemonSender, Schedulable, MoLangScriptingEntity, OmniPathingEntity {
|
||||
override val schedulingTracker = SchedulingTracker()
|
||||
|
||||
override val struct = this.asMoLangValue()
|
||||
|
||||
@@ -11,14 +11,8 @@ package com.cobblemon.mod.common.entity.pokemon
|
||||
import com.bedrockk.molang.runtime.MoLangRuntime
|
||||
import com.bedrockk.molang.runtime.struct.VariableStruct
|
||||
import com.bedrockk.molang.runtime.value.DoubleValue
|
||||
import com.cobblemon.mod.common.Cobblemon
|
||||
import com.cobblemon.mod.common.CobblemonCosmeticItems
|
||||
import com.cobblemon.mod.common.CobblemonEntities
|
||||
import com.cobblemon.mod.common.CobblemonItems
|
||||
import com.cobblemon.mod.common.CobblemonMemories
|
||||
import com.cobblemon.mod.common.*
|
||||
import com.cobblemon.mod.common.CobblemonNetwork.sendPacket
|
||||
import com.cobblemon.mod.common.CobblemonSounds
|
||||
import com.cobblemon.mod.common.OrientationControllable
|
||||
import com.cobblemon.mod.common.api.battles.model.PokemonBattle
|
||||
import com.cobblemon.mod.common.api.drop.DropTable
|
||||
import com.cobblemon.mod.common.api.entity.Despawner
|
||||
@@ -76,13 +70,7 @@ import com.cobblemon.mod.common.battles.SuccessfulBattleStart
|
||||
import com.cobblemon.mod.common.block.entity.PokemonPastureBlockEntity
|
||||
import com.cobblemon.mod.common.client.MountedCameraTypeHandler
|
||||
import com.cobblemon.mod.common.client.entity.PokemonClientDelegate
|
||||
import com.cobblemon.mod.common.entity.BehaviourEditingTracker
|
||||
import com.cobblemon.mod.common.entity.EntityCallbacks
|
||||
import com.cobblemon.mod.common.entity.MoLangScriptingEntity
|
||||
import com.cobblemon.mod.common.entity.OmniPathingEntity
|
||||
import com.cobblemon.mod.common.entity.PlatformType
|
||||
import com.cobblemon.mod.common.entity.PosableEntity
|
||||
import com.cobblemon.mod.common.entity.PoseType
|
||||
import com.cobblemon.mod.common.entity.*
|
||||
import com.cobblemon.mod.common.entity.PoseType.Companion.NO_GRAV_POSES
|
||||
import com.cobblemon.mod.common.entity.ai.OmniPathNavigation
|
||||
import com.cobblemon.mod.common.entity.generic.GenericBedrockEntity
|
||||
@@ -119,17 +107,12 @@ import com.cobblemon.mod.common.pokemon.properties.UncatchableProperty
|
||||
import com.cobblemon.mod.common.util.*
|
||||
import com.cobblemon.mod.common.util.math.geometry.toRadians
|
||||
import com.cobblemon.mod.common.world.gamerules.CobblemonGameRules
|
||||
import com.google.common.collect.UnmodifiableIterator
|
||||
import com.mojang.serialization.Codec
|
||||
import com.mojang.serialization.Dynamic
|
||||
import net.minecraft.client.Minecraft
|
||||
import java.util.Optional
|
||||
import java.util.UUID
|
||||
import java.util.concurrent.CompletableFuture
|
||||
import kotlin.math.PI
|
||||
import kotlin.math.ceil
|
||||
import kotlin.math.max
|
||||
import kotlin.math.min
|
||||
import net.minecraft.core.BlockPos
|
||||
import net.minecraft.core.Direction
|
||||
import net.minecraft.core.component.DataComponents
|
||||
import net.minecraft.core.registries.BuiltInRegistries
|
||||
import net.minecraft.nbt.CompoundTag
|
||||
@@ -173,6 +156,7 @@ import net.minecraft.world.entity.ai.sensing.SensorType
|
||||
import net.minecraft.world.entity.animal.Animal
|
||||
import net.minecraft.world.entity.animal.ShoulderRidingEntity
|
||||
import net.minecraft.world.entity.player.Player
|
||||
import net.minecraft.world.entity.vehicle.DismountHelper
|
||||
import net.minecraft.world.item.DyeItem
|
||||
import net.minecraft.world.item.ItemStack
|
||||
import net.minecraft.world.item.ItemUtils
|
||||
@@ -187,6 +171,12 @@ import net.minecraft.world.level.material.FluidState
|
||||
import net.minecraft.world.level.pathfinder.PathType
|
||||
import net.minecraft.world.phys.AABB
|
||||
import net.minecraft.world.phys.Vec3
|
||||
import java.util.*
|
||||
import java.util.concurrent.CompletableFuture
|
||||
import kotlin.math.PI
|
||||
import kotlin.math.ceil
|
||||
import kotlin.math.max
|
||||
import kotlin.math.min
|
||||
|
||||
@Suppress("unused")
|
||||
open class PokemonEntity(
|
||||
@@ -221,6 +211,7 @@ open class PokemonEntity(
|
||||
@JvmStatic var SHOWN_HELD_ITEM = SynchedEntityData.defineId(PokemonEntity::class.java, EntityDataSerializers.ITEM_STACK)
|
||||
@JvmStatic var RIDE_BOOSTS = SynchedEntityData.defineId(PokemonEntity::class.java, RideBoostsDataSerializer)
|
||||
@JvmStatic var RIDE_STAMINA = SynchedEntityData.defineId(PokemonEntity::class.java, EntityDataSerializers.FLOAT)
|
||||
@JvmStatic var SCALE_MODIFIER = SynchedEntityData.defineId(PokemonEntity::class.java, EntityDataSerializers.FLOAT)
|
||||
|
||||
const val BATTLE_LOCK = "battle"
|
||||
const val EVOLUTION_LOCK = "evolving"
|
||||
@@ -468,6 +459,7 @@ open class PokemonEntity(
|
||||
builder.define(SHOWN_HELD_ITEM, ItemStack.EMPTY)
|
||||
builder.define(RIDE_BOOSTS, emptyMap())
|
||||
builder.define(RIDE_STAMINA, 1F)
|
||||
builder.define(SCALE_MODIFIER, 1F)
|
||||
}
|
||||
|
||||
override fun onSyncedDataUpdated(data: EntityDataAccessor<*>) {
|
||||
@@ -504,6 +496,8 @@ open class PokemonEntity(
|
||||
busyLocks.remove(EVOLUTION_LOCK)
|
||||
}
|
||||
}
|
||||
|
||||
SCALE_MODIFIER -> refreshDimensions()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -567,7 +561,7 @@ open class PokemonEntity(
|
||||
true
|
||||
}
|
||||
"motordrive" -> {
|
||||
this.addEffect(MobEffectInstance(MobEffects.MOVEMENT_SPEED, 1200, 0))
|
||||
this.addEffect(MobEffectInstance(MobEffects.MOVEMENT_SPEED, 1200, 1))
|
||||
true
|
||||
}
|
||||
"voltabsorb" -> {
|
||||
@@ -877,6 +871,7 @@ open class PokemonEntity(
|
||||
dataResult.resultOrPartial(::error).ifPresent { brain ->
|
||||
nbt.put("Brain", brain)
|
||||
}
|
||||
nbt.putFloat(DataKeys.POKEMON_SCALE_MODIFIER, entityData.get(SCALE_MODIFIER))
|
||||
|
||||
// save active effects
|
||||
nbt.put(DataKeys.ENTITY_EFFECTS, effects.saveToNbt(this.level().registryAccess()))
|
||||
@@ -979,6 +974,10 @@ open class PokemonEntity(
|
||||
|
||||
remakeBrain()
|
||||
|
||||
if (nbt.contains(DataKeys.POKEMON_SCALE_MODIFIER)) {
|
||||
entityData.set(SCALE_MODIFIER, nbt.getFloat(DataKeys.POKEMON_SCALE_MODIFIER))
|
||||
}
|
||||
|
||||
CobblemonEvents.POKEMON_ENTITY_LOAD.postThen(
|
||||
event = PokemonEntityLoadEvent(this, nbt),
|
||||
ifSucceeded = {},
|
||||
@@ -2322,9 +2321,60 @@ open class PokemonEntity(
|
||||
}
|
||||
|
||||
override fun getDismountLocationForPassenger(passenger: LivingEntity): Vec3 {
|
||||
return Vec3(this.x, this.getBoundingBox().minY, this.z)
|
||||
val vec3 = getCollisionHorizontalEscapeVector(
|
||||
this.bbWidth.toDouble(),
|
||||
passenger.bbWidth.toDouble(),
|
||||
this.yRot + (if (passenger.mainArm == HumanoidArm.RIGHT) 90.0f else -90.0f)
|
||||
)
|
||||
val vec32: Vec3? = this.getDismountLocationInDirection(vec3, passenger)
|
||||
if (vec32 != null) {
|
||||
return vec32
|
||||
} else {
|
||||
val vec33 = getCollisionHorizontalEscapeVector(
|
||||
this.bbWidth.toDouble(),
|
||||
passenger.bbWidth.toDouble(),
|
||||
this.yRot + (if (passenger.mainArm == HumanoidArm.LEFT) 90.0f else -90.0f)
|
||||
)
|
||||
val vec34: Vec3? = this.getDismountLocationInDirection(vec33, passenger)
|
||||
return vec34 ?: this.position()
|
||||
}
|
||||
}
|
||||
private fun getDismountLocationInDirection(direction: Vec3, passenger: LivingEntity): Vec3? {
|
||||
val d = this.x + direction.x
|
||||
val e = this.boundingBox.minY
|
||||
val f = this.z + direction.z
|
||||
val mutableBlockPos = BlockPos.MutableBlockPos()
|
||||
val var10: UnmodifiableIterator<*> = passenger.dismountPoses.iterator()
|
||||
|
||||
while (var10.hasNext()) {
|
||||
val pose = var10.next() as Pose
|
||||
mutableBlockPos.set(d, e, f)
|
||||
val g = this.boundingBox.maxY + 0.75
|
||||
|
||||
while (true) {
|
||||
val h = this.level().getBlockFloorHeight(mutableBlockPos)
|
||||
if (mutableBlockPos.getY().toDouble() + h > g) {
|
||||
break
|
||||
}
|
||||
|
||||
if (DismountHelper.isBlockFloorValid(h)) {
|
||||
val aABB = passenger.getLocalBoundsForPose(pose)
|
||||
val vec3 = Vec3(d, mutableBlockPos.getY().toDouble() + h, f)
|
||||
if (DismountHelper.canDismountTo(this.level(), passenger, aABB.move(vec3))) {
|
||||
passenger.pose = pose
|
||||
return vec3
|
||||
}
|
||||
}
|
||||
|
||||
mutableBlockPos.move(Direction.UP)
|
||||
if (!(mutableBlockPos.y.toDouble() < g)) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
override fun getRiddenInput(controller: Player, movementInput: Vec3): Vec3 {
|
||||
return ifRidingAvailableSupply(fallback = Vec3.ZERO) { behaviour, settings, state ->
|
||||
behaviour.velocity(settings, state, this, controller, movementInput)
|
||||
@@ -2571,4 +2621,4 @@ open class PokemonEntity(
|
||||
herdLeader.behaviour.herd.bestMatchLeader(follower = this, possibleLeader = herdLeader)?.tier ?: 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+13
-2
@@ -22,6 +22,7 @@ import com.cobblemon.mod.common.api.molang.MoLangFunctions.addPokemonFunctions
|
||||
import com.cobblemon.mod.common.api.molang.ObjectValue
|
||||
import com.cobblemon.mod.common.api.pokemon.PokemonProperties
|
||||
import com.cobblemon.mod.common.api.pokemon.status.Statuses
|
||||
import com.cobblemon.mod.common.api.spawning.fishing.FishingSpawnCause.Companion.DROPS_REROLL_ASPECT
|
||||
import com.cobblemon.mod.common.api.tags.CobblemonItemTags
|
||||
import com.cobblemon.mod.common.battles.BattleRegistry
|
||||
import com.cobblemon.mod.common.entity.PoseType
|
||||
@@ -214,6 +215,7 @@ class PokemonServerDelegate : PokemonSideDelegate {
|
||||
val trackedMark = entity.pokemon.activeMark?.identifier.toString()
|
||||
val trackedAspects = mock?.aspects ?: entity.pokemon.aspects
|
||||
val trackedBall = mock?.pokeball ?: entity.pokemon.caughtBall.name.toString()
|
||||
val trackedScaleModifier = mock?.scaleModifier ?: entity.pokemon.scaleModifier
|
||||
|
||||
entity.ownerUUID = entity.pokemon.getOwnerUUID()
|
||||
entity.entityData.set(PokemonEntity.SPECIES, trackedSpecies)
|
||||
@@ -235,6 +237,7 @@ class PokemonServerDelegate : PokemonSideDelegate {
|
||||
|
||||
entity.entityData.set(PokemonEntity.FRIENDSHIP, entity.pokemon.friendship)
|
||||
entity.entityData.set(PokemonEntity.CAUGHT_BALL, trackedBall)
|
||||
entity.entityData.set(PokemonEntity.SCALE_MODIFIER, trackedScaleModifier)
|
||||
if (entity.pokemon.rideStamina != entity.entityData.get(PokemonEntity.RIDE_STAMINA) && entity.passengers.isEmpty()) {
|
||||
entity.entityData.set(PokemonEntity.RIDE_STAMINA, entity.pokemon.rideStamina)
|
||||
}
|
||||
@@ -377,7 +380,15 @@ class PokemonServerDelegate : PokemonSideDelegate {
|
||||
if (entity.ownerUUID == null && entity.owner == null && entity.level().gameRules.getBoolean(CobblemonGameRules.DO_POKEMON_LOOT)) {
|
||||
val heldItem = (entity as PokemonEntity?)?.pokemon?.heldItemNoCopy() ?: ItemStack.EMPTY
|
||||
if (!heldItem.isEmpty) entity.spawnAtLocation(heldItem.item)
|
||||
(entity.drops ?: entity.pokemon.form.drops).drop(entity, entity.level() as ServerLevel, entity.position(), entity.killer)
|
||||
|
||||
val dropTable = (entity.drops ?: entity.pokemon.form.drops)
|
||||
val drops = dropTable.getDrops().toMutableList()
|
||||
if (entity.pokemon.forcedAspects.contains(DROPS_REROLL_ASPECT)) {
|
||||
val dropsReroll = dropTable.getDrops()
|
||||
drops.addAll(dropsReroll)
|
||||
}
|
||||
|
||||
dropTable.postLootDroppedEvent(drops, entity, entity.level() as ServerLevel, entity.position(), entity.killer)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -440,4 +451,4 @@ class PokemonServerDelegate : PokemonSideDelegate {
|
||||
this.entity.z + offset.z
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -77,6 +77,8 @@ object CallbackHandler {
|
||||
CobblemonEvents.POKEROD_REEL.subscribe { CobblemonCallbacks.run(cobblemonResource("pokerod_reel"), it.context, it.functions) }
|
||||
CobblemonEvents.BOBBER_SPAWN_POKEMON_PRE.subscribe { CobblemonCallbacks.run(cobblemonResource("bobber_spawn_pokemon_pre"), it.context, it.functions) }
|
||||
CobblemonEvents.BOBBER_SPAWN_POKEMON_POST.subscribe { CobblemonCallbacks.run(cobblemonResource("bobber_spawn_pokemon_post"), it.context) }
|
||||
CobblemonEvents.POKE_SNACK_SPAWN_POKEMON_PRE.subscribe { CobblemonCallbacks.run(cobblemonResource("poke_snack_spawn_pokemon_pre"), it.context, it.functions) }
|
||||
CobblemonEvents.POKE_SNACK_SPAWN_POKEMON_POST.subscribe { CobblemonCallbacks.run(cobblemonResource("poke_snack_spawn_pokemon_post"), it.context) }
|
||||
CobblemonEvents.TRADE_EVENT_PRE.subscribe { CobblemonCallbacks.run(cobblemonResource("trade_event_pre"), it.context, it.functions) }
|
||||
CobblemonEvents.TRADE_EVENT_POST.subscribe { CobblemonCallbacks.run(cobblemonResource("trade_event_post"), it.context) }
|
||||
CobblemonEvents.RIDE_EVENT_PRE.subscribe { CobblemonCallbacks.run(cobblemonResource("ride_event_pre"), it.context, it.functions) }
|
||||
|
||||
+16
-1
@@ -27,6 +27,21 @@ class FoodColourComponent(
|
||||
companion object {
|
||||
val CODEC: Codec<FoodColourComponent> = DyeColor.CODEC.listOf().xmap(::FoodColourComponent, FoodColourComponent::colours)
|
||||
val PACKET_CODEC: StreamCodec<ByteBuf, FoodColourComponent> = ByteBufCodecs.fromCodec(CODEC)
|
||||
|
||||
private val COLORS = mapOf<DyeColor, Int>(
|
||||
DyeColor.RED to FastColor.ARGB32.color(255, 255, 175, 215),
|
||||
DyeColor.ORANGE to FastColor.ARGB32.color(255, 255, 195, 175),
|
||||
DyeColor.YELLOW to FastColor.ARGB32.color(255, 255, 225, 175),
|
||||
DyeColor.LIME to FastColor.ARGB32.color(255, 205, 255, 175),
|
||||
DyeColor.GREEN to FastColor.ARGB32.color(255, 175, 255, 180),
|
||||
DyeColor.CYAN to FastColor.ARGB32.color(255, 135, 235, 215),
|
||||
DyeColor.LIGHT_BLUE to FastColor.ARGB32.color(255, 120, 195, 235),
|
||||
DyeColor.BLUE to FastColor.ARGB32.color(255, 120, 165, 255),
|
||||
DyeColor.PURPLE to FastColor.ARGB32.color(255, 145, 145, 255),
|
||||
DyeColor.MAGENTA to FastColor.ARGB32.color(255, 175, 140, 255),
|
||||
DyeColor.PINK to FastColor.ARGB32.color(255, 225, 160, 255),
|
||||
DyeColor.WHITE to FastColor.ARGB32.color(255, 255, 255, 255)
|
||||
)
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
@@ -36,7 +51,7 @@ class FoodColourComponent(
|
||||
}
|
||||
|
||||
fun getColoursAsARGB(): List<Int> {
|
||||
return colours.map { dye -> dye.textureDiffuseColor }
|
||||
return colours.map { dye -> COLORS[dye] ?: COLORS[DyeColor.WHITE]!! }
|
||||
}
|
||||
|
||||
override fun hashCode() = colours.hashCode()
|
||||
|
||||
@@ -119,7 +119,7 @@ class PokerodItem(val pokeRodId: ResourceLocation, settings: Properties) : Fishi
|
||||
|
||||
// Add as much as possible
|
||||
if (baitStack != ItemStack.EMPTY) {
|
||||
if (baitStack.item == itemStack2.item) {
|
||||
if (ItemStack.isSameItemSameComponents(baitStack, itemStack2)) {
|
||||
|
||||
playAttachSound(player)
|
||||
// Calculate how much bait to add
|
||||
|
||||
@@ -11,6 +11,7 @@ package com.cobblemon.mod.common.mechanics
|
||||
import com.cobblemon.mod.common.api.apricorn.Apricorn
|
||||
import com.cobblemon.mod.common.api.riding.stats.RidingStat
|
||||
import com.cobblemon.mod.common.client.pot.CookingQuality
|
||||
import net.minecraft.network.RegistryFriendlyByteBuf
|
||||
|
||||
/**
|
||||
* Mechanic to hold various properties that motivate aprijuice as a mechanic.
|
||||
@@ -25,4 +26,61 @@ class AprijuicesMechanic {
|
||||
val statPointFlavourThresholds = mutableMapOf<Int, Int>()
|
||||
/** Maps stat points for riding stats to what cooking quality that represents. It's for tooltips. */
|
||||
val cookingQualityPointThresholds = mutableMapOf<Int, CookingQuality>()
|
||||
|
||||
internal fun encode(buffer: RegistryFriendlyByteBuf) {
|
||||
buffer.writeMap(this.apricornStatEffects,
|
||||
{ _, apricorn -> buffer.writeEnum(apricorn) },
|
||||
{ _, ridingStats ->
|
||||
buffer.writeMap(ridingStats,
|
||||
{ _, ridingStat -> buffer.writeEnum(ridingStat) },
|
||||
{ _, value -> buffer.writeVarInt(value) }
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
buffer.writeMap(this.statPointFlavourThresholds,
|
||||
{ _, key -> buffer.writeVarInt(key) },
|
||||
{ _, value -> buffer.writeVarInt(value) }
|
||||
)
|
||||
|
||||
buffer.writeMap(this.cookingQualityPointThresholds,
|
||||
{ _, key -> buffer.writeVarInt(key) },
|
||||
{ _, cookingQuality -> buffer.writeEnum(cookingQuality) }
|
||||
)
|
||||
}
|
||||
|
||||
companion object {
|
||||
internal fun decode(buffer: RegistryFriendlyByteBuf): AprijuicesMechanic {
|
||||
val mechanic = AprijuicesMechanic()
|
||||
|
||||
val decodedApricornStatEffects = buffer.readMap(
|
||||
{ buffer.readEnum<Apricorn>(Apricorn::class.java) },
|
||||
{
|
||||
buffer.readMap(
|
||||
{ buffer.readEnum<RidingStat>(RidingStat::class.java) },
|
||||
{ buffer.readVarInt() }
|
||||
).toMutableMap()
|
||||
}
|
||||
).toMutableMap()
|
||||
|
||||
mechanic.apricornStatEffects.clear()
|
||||
mechanic.apricornStatEffects.putAll(decodedApricornStatEffects)
|
||||
|
||||
val decodedStatPointFlavourThresholds = buffer.readMap(
|
||||
{ buffer.readVarInt() },
|
||||
{ buffer.readVarInt() }
|
||||
)
|
||||
mechanic.statPointFlavourThresholds.clear()
|
||||
mechanic.statPointFlavourThresholds.putAll(decodedStatPointFlavourThresholds)
|
||||
|
||||
val decodedCookingQualityPointThresholds = buffer.readMap(
|
||||
{ buffer.readVarInt() },
|
||||
{ buffer.readEnum(CookingQuality::class.java) }
|
||||
)
|
||||
mechanic.cookingQualityPointThresholds.clear()
|
||||
mechanic.cookingQualityPointThresholds.putAll(decodedCookingQualityPointThresholds)
|
||||
|
||||
return mechanic
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,12 +10,40 @@ package com.cobblemon.mod.common.mechanics
|
||||
|
||||
import com.cobblemon.mod.common.api.molang.ExpressionLike
|
||||
import com.cobblemon.mod.common.util.asExpressionLike
|
||||
import com.cobblemon.mod.common.util.readExpressionLike
|
||||
import com.cobblemon.mod.common.util.writeExpressionLike
|
||||
import net.minecraft.network.RegistryFriendlyByteBuf
|
||||
|
||||
class BerriesMechanic {
|
||||
val portionHealRatio: ExpressionLike = "0.33".asExpressionLike()
|
||||
val sitrusHealAmount: ExpressionLike = "v.pokemon.max_hp * 0.33".asExpressionLike()
|
||||
val friendshipRaiseAmount: ExpressionLike = "v.pokemon.friendship < 100 ? 10 : (v.pokemon.friendship < 200 ? 5 : 1)".asExpressionLike()
|
||||
val evLowerAmount: ExpressionLike = "10".asExpressionLike()
|
||||
val ppRestoreAmount: ExpressionLike = "10".asExpressionLike()
|
||||
val oranRestoreAmount: ExpressionLike = "10".asExpressionLike()
|
||||
class BerriesMechanic(
|
||||
val portionHealRatio: ExpressionLike = "0.33".asExpressionLike(),
|
||||
val sitrusHealAmount: ExpressionLike = "v.pokemon.max_hp * 0.33".asExpressionLike(),
|
||||
val friendshipRaiseAmount: ExpressionLike = "v.pokemon.friendship < 100 ? 10 : (v.pokemon.friendship < 200 ? 5 : 1)".asExpressionLike(),
|
||||
val evLowerAmount: ExpressionLike = "10".asExpressionLike(),
|
||||
val ppRestoreAmount: ExpressionLike = "10".asExpressionLike(),
|
||||
val oranRestoreAmount: ExpressionLike = "10".asExpressionLike(),
|
||||
) {
|
||||
|
||||
internal fun encode(buffer: RegistryFriendlyByteBuf) {
|
||||
buffer.writeExpressionLike(portionHealRatio)
|
||||
buffer.writeExpressionLike(sitrusHealAmount)
|
||||
buffer.writeExpressionLike(friendshipRaiseAmount)
|
||||
buffer.writeExpressionLike(evLowerAmount)
|
||||
buffer.writeExpressionLike(ppRestoreAmount)
|
||||
buffer.writeExpressionLike(oranRestoreAmount)
|
||||
}
|
||||
|
||||
companion object {
|
||||
internal fun decode(buffer: RegistryFriendlyByteBuf): BerriesMechanic {
|
||||
val mechanic = BerriesMechanic(
|
||||
buffer.readExpressionLike(),
|
||||
buffer.readExpressionLike(),
|
||||
buffer.readExpressionLike(),
|
||||
buffer.readExpressionLike(),
|
||||
buffer.readExpressionLike(),
|
||||
buffer.readExpressionLike(),
|
||||
)
|
||||
|
||||
return mechanic
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,9 +10,30 @@ package com.cobblemon.mod.common.mechanics
|
||||
|
||||
import com.cobblemon.mod.common.api.molang.ExpressionLike
|
||||
import com.cobblemon.mod.common.util.asExpressionLike
|
||||
import com.cobblemon.mod.common.util.readExpressionLike
|
||||
import com.cobblemon.mod.common.util.writeExpressionLike
|
||||
import net.minecraft.network.RegistryFriendlyByteBuf
|
||||
|
||||
class PotionsMechanic {
|
||||
val potionRestoreAmount: ExpressionLike = "60".asExpressionLike()
|
||||
val superPotionRestoreAmount: ExpressionLike = "100".asExpressionLike()
|
||||
val hyperPotionRestoreAmount: ExpressionLike = "150".asExpressionLike()
|
||||
class PotionsMechanic(
|
||||
val potionRestoreAmount: ExpressionLike = "60".asExpressionLike(),
|
||||
val superPotionRestoreAmount: ExpressionLike = "100".asExpressionLike(),
|
||||
val hyperPotionRestoreAmount: ExpressionLike = "150".asExpressionLike(),
|
||||
) {
|
||||
internal fun encode(buffer: RegistryFriendlyByteBuf) {
|
||||
buffer.writeExpressionLike(potionRestoreAmount)
|
||||
buffer.writeExpressionLike(superPotionRestoreAmount)
|
||||
buffer.writeExpressionLike(hyperPotionRestoreAmount)
|
||||
}
|
||||
|
||||
companion object {
|
||||
internal fun decode(buffer: RegistryFriendlyByteBuf): PotionsMechanic {
|
||||
val mechanic = PotionsMechanic(
|
||||
buffer.readExpressionLike(),
|
||||
buffer.readExpressionLike(),
|
||||
buffer.readExpressionLike(),
|
||||
)
|
||||
|
||||
return mechanic
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,11 +10,47 @@ package com.cobblemon.mod.common.mechanics
|
||||
|
||||
import com.bedrockk.molang.runtime.MoLangRuntime
|
||||
import com.cobblemon.mod.common.api.molang.ExpressionLike
|
||||
import com.cobblemon.mod.common.util.asExpressionLike
|
||||
import com.cobblemon.mod.common.util.readExpressionLike
|
||||
import com.cobblemon.mod.common.util.readString
|
||||
import com.cobblemon.mod.common.util.resolveInt
|
||||
import com.cobblemon.mod.common.util.writeExpressionLike
|
||||
import com.cobblemon.mod.common.util.writeString
|
||||
import net.minecraft.network.RegistryFriendlyByteBuf
|
||||
|
||||
class RemediesMechanic {
|
||||
val remedies = mutableMapOf<String, RemedyEntry>()
|
||||
|
||||
internal fun encode(buffer: RegistryFriendlyByteBuf) {
|
||||
buffer.writeMap(this.remedies,
|
||||
{ _, key -> buffer.writeString(key) },
|
||||
{ _, entry ->
|
||||
buffer.writeExpressionLike(entry.healingAmount)
|
||||
buffer.writeExpressionLike(entry.friendshipDrop)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
companion object {
|
||||
internal fun decode(buffer: RegistryFriendlyByteBuf): RemediesMechanic {
|
||||
val mechanic = RemediesMechanic()
|
||||
|
||||
val decodedRemedies = buffer.readMap(
|
||||
{ buffer.readString() },
|
||||
{
|
||||
val healingExpression = buffer.readExpressionLike()
|
||||
val friendshipExpression = buffer.readExpressionLike()
|
||||
RemedyEntry(healingExpression, friendshipExpression)
|
||||
}
|
||||
)
|
||||
|
||||
mechanic.remedies.clear()
|
||||
mechanic.remedies.putAll(decodedRemedies)
|
||||
|
||||
return mechanic
|
||||
}
|
||||
}
|
||||
|
||||
fun getHealingAmount(type: String, runtime: MoLangRuntime, default: Int = 20) = remedies[type]?.let { runtime.resolveInt(it.healingAmount) } ?: default
|
||||
fun getFriendshipDrop(type: String, runtime: MoLangRuntime, default: Int = 0) = remedies[type]?.let { runtime.resolveInt(it.friendshipDrop) } ?: default
|
||||
}
|
||||
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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.net.NetworkPacket
|
||||
import com.cobblemon.mod.common.mechanics.AprijuicesMechanic
|
||||
import com.cobblemon.mod.common.mechanics.BerriesMechanic
|
||||
import com.cobblemon.mod.common.mechanics.PotionsMechanic
|
||||
import com.cobblemon.mod.common.mechanics.RemediesMechanic
|
||||
import com.cobblemon.mod.common.util.cobblemonResource
|
||||
import net.minecraft.network.RegistryFriendlyByteBuf
|
||||
|
||||
class CobblemonMechanicsSyncPacket(
|
||||
val remedies: RemediesMechanic,
|
||||
val berries: BerriesMechanic,
|
||||
val potions: PotionsMechanic,
|
||||
val aprijuices: AprijuicesMechanic,
|
||||
) : NetworkPacket<CobblemonMechanicsSyncPacket> {
|
||||
override val id = ID
|
||||
|
||||
override fun encode(buffer: RegistryFriendlyByteBuf) {
|
||||
remedies.encode(buffer)
|
||||
berries.encode(buffer)
|
||||
potions.encode(buffer)
|
||||
aprijuices.encode(buffer)
|
||||
}
|
||||
|
||||
companion object {
|
||||
val ID = cobblemonResource("cobblemon_mechanics_sync")
|
||||
|
||||
fun decode(buffer: RegistryFriendlyByteBuf): CobblemonMechanicsSyncPacket {
|
||||
return CobblemonMechanicsSyncPacket(
|
||||
RemediesMechanic.decode(buffer),
|
||||
BerriesMechanic.decode(buffer),
|
||||
PotionsMechanic.decode(buffer),
|
||||
AprijuicesMechanic.decode(buffer),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
@@ -161,6 +161,7 @@ class SpawnPokemonPacket(
|
||||
entity.entityData.set(PokemonEntity.FREEZE_FRAME, freezeFrame)
|
||||
entity.entityData.set(PokemonEntity.RIDE_BOOSTS, rideBoosts)
|
||||
entity.entityData.set(PokemonEntity.RIDE_STAMINA, rideStamina)
|
||||
entity.entityData.set(PokemonEntity.SCALE_MODIFIER, scaleModifier)
|
||||
|
||||
entity.ejectPassengers()
|
||||
passengers.forEach {
|
||||
|
||||
@@ -10,6 +10,7 @@ package com.cobblemon.mod.common.pokemon
|
||||
|
||||
import com.cobblemon.mod.common.Cobblemon
|
||||
import com.cobblemon.mod.common.api.pokemon.stats.Stat
|
||||
import com.cobblemon.mod.common.api.pokemon.stats.Stats
|
||||
import com.cobblemon.mod.common.util.DataKeys
|
||||
import com.mojang.serialization.Codec
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder
|
||||
@@ -47,8 +48,17 @@ class IVs : PokemonStats() {
|
||||
return (this.hyperTrainedIVs[stat] ?: this[stat]) as Int
|
||||
}
|
||||
|
||||
fun getEffectiveBattleTotal(): Int {
|
||||
var total = 0
|
||||
for(stat in Stats.PERMANENT) {
|
||||
total += getEffectiveBattleIV(stat)
|
||||
}
|
||||
return total
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val MAX_VALUE = 31
|
||||
const val MAX_TOTAL = 186
|
||||
|
||||
@JvmStatic
|
||||
fun createRandomIVs(minPerfectIVs: Int = 0): IVs = Cobblemon.statProvider.createEmptyIVs(minPerfectIVs)
|
||||
|
||||
@@ -68,4 +68,6 @@ abstract class PokemonStats : Iterable<Map.Entry<Stat, Int>> {
|
||||
protected open fun canSet(stat: Stat, value: Int) = value in acceptableRange
|
||||
|
||||
fun getOrDefault(stat: Stat) = this[stat] ?: this.defaultValue
|
||||
|
||||
fun total(): Int = stats.values.sum()
|
||||
}
|
||||
+3
-1
@@ -149,6 +149,8 @@ internal object PropertiesCompletionProvider : DataRegistry {
|
||||
this.inject(setOf("originaltrainertype", "ottype"), setOf("None", "Player", "NPC"))
|
||||
this.inject(setOf("nickname", "nick"), setOf(""))
|
||||
this.inject(setOf("helditem", "held_item"), setOf("cobblemon:exp_share"))
|
||||
this.inject(setOf("min_perfect_ivs"), setOf("0", "6"))
|
||||
this.inject(setOf("scale_modifier"), setOf("0.5", "2.0"))
|
||||
|
||||
Stats.PERMANENT.forEach{ stat ->
|
||||
val statName = stat.toString().lowercase()
|
||||
@@ -173,4 +175,4 @@ internal object PropertiesCompletionProvider : DataRegistry {
|
||||
val suggestions: Collection<String>
|
||||
)
|
||||
|
||||
}
|
||||
}
|
||||
Loaded 100 of 2163 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user