Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
91aac1d75e |
No files matched your search
@@ -40,9 +40,7 @@
|
||||
- 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 new optional property `attachment_options` for most EmitterShapes to be attached to the locator/entities scale, rotation, and/or position. Position is true by default.
|
||||
- Galarica Nut bushes now generate on beaches.
|
||||
- Some Pokémon now pitch their bodies in the direction they're moving.
|
||||
- Added `/runmolang <molang> [<npc>|<player>|<pokemon>]` command that executes a MoLang expression with the provided options as environment variables, as well as the entity (as `q.entity`) that executed the command.
|
||||
- Galarica Nut bushes now generate on beaches
|
||||
|
||||
### Pokémon Added
|
||||
|
||||
@@ -243,10 +241,6 @@
|
||||
- Not specifying a dex in `/pokedex printcalculations {player} {dex}` will now print the National Dex statistics instead of showing all dexes. `/pokedex printcalculations {player} all` is how to view all dex statistics in one command.
|
||||
- Removed Braised Vivichoke
|
||||
- Updated Pokémon state icons shown in party interfaces
|
||||
- MoLang `face` function can now be run on any `PosableEntity` (Like Pokémon!) instead of just NPCs.
|
||||
- MoLang `run_action_effect` now works on Pokémon.
|
||||
- Changed MoLang entity function `is_standing_on` to allow for block tags in the list.
|
||||
- Added entity (as `q.entity`) that executed the command to the `executemolangscript` command.
|
||||
|
||||
### Fixes
|
||||
- Fixed game crashing when removing national pokedex using datapacks
|
||||
@@ -405,7 +399,6 @@
|
||||
- Added `q.has_argument(<argument_name>, [argument_value])` MoLang function to several battle-related action effect contexts.
|
||||
- Added `q.has_argument_at(<index>, [argument_value])` MoLang function to several battle-related action effect contexts.
|
||||
- Added `q.hit_count` MoLang function to move action effect contexts.
|
||||
- Added `is_included`, `to_lower`, `to_upper`, and `string_length` as available Molang functions.
|
||||
|
||||
## [1.6.1 (January 26th, 2025)](#1-6-1)
|
||||
|
||||
|
||||
@@ -9,6 +9,15 @@
|
||||
package com.cobblemon.mod.common;
|
||||
|
||||
import com.cobblemon.mod.common.api.orientation.OrientationController;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.util.SmoothDouble;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.joml.Matrix3f;
|
||||
import org.joml.Vector3f;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
public interface OrientationControllable {
|
||||
OrientationController getOrientationController();
|
||||
|
||||
@@ -10,9 +10,6 @@ package com.cobblemon.mod.common.duck;
|
||||
|
||||
import org.joml.Vector3f;
|
||||
|
||||
public interface PlayerDuck {
|
||||
public interface ServerEntityDuck {
|
||||
void setDriverInput(Vector3f driverInput);
|
||||
Vector3f getDriverInput();
|
||||
void setLastSentDriverInput(Vector3f driverInput);
|
||||
Vector3f getLastSentDriverInput();
|
||||
}
|
||||
@@ -8,44 +8,17 @@
|
||||
|
||||
package com.cobblemon.mod.common.mixin;
|
||||
|
||||
import com.cobblemon.mod.common.OrientationControllable;
|
||||
import com.cobblemon.mod.common.api.orientation.OrientationController;
|
||||
import com.cobblemon.mod.common.api.pokemon.effect.ShoulderEffectRegistry;
|
||||
import com.cobblemon.mod.common.api.riding.Seat;
|
||||
import com.cobblemon.mod.common.client.entity.PokemonClientDelegate;
|
||||
import com.cobblemon.mod.common.client.render.MatrixWrapper;
|
||||
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.effect.MobEffectInstance;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.level.ClipContext;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.phys.HitResult;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.joml.Quaternionf;
|
||||
import org.joml.Vector3f;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
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(LivingEntity.class)
|
||||
public abstract class LivingEntityMixin extends Entity implements OrientationControllable {
|
||||
|
||||
public LivingEntityMixin(EntityType<?> entityType, Level level) {
|
||||
super(entityType, level);
|
||||
}
|
||||
|
||||
@Unique
|
||||
private final OrientationController cobblemon$orientationController = new OrientationController((LivingEntity) (Object) this);
|
||||
|
||||
public OrientationController getOrientationController() {
|
||||
return cobblemon$orientationController;
|
||||
}
|
||||
public abstract class LivingEntityMixin {
|
||||
|
||||
@Inject(method = "onEffectRemoved", at = @At(value = "TAIL"))
|
||||
private void cobblemon$onEffectRemoved(MobEffectInstance effect, CallbackInfo ci) {
|
||||
@@ -55,67 +28,4 @@ public abstract class LivingEntityMixin extends Entity implements OrientationCon
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull HitResult pick(double hitDistance, float partialTicks, boolean hitFluids) {
|
||||
Entity vehicle = this.getVehicle();
|
||||
if (vehicle instanceof PokemonEntity pokemonEntity) {
|
||||
int seatIndex = pokemonEntity.getPassengers().indexOf(this);
|
||||
Seat seat = pokemonEntity.getSeats().get(seatIndex);
|
||||
|
||||
PokemonClientDelegate delegate = (PokemonClientDelegate) pokemonEntity.getDelegate();
|
||||
MatrixWrapper locator = delegate.getLocatorStates().get(seat.getLocator());
|
||||
|
||||
Vec3 locatorOffset = new Vec3(locator.getMatrix().getTranslation(new Vector3f()));
|
||||
|
||||
Vec3 eyePosition = cobblemon$getEyePosition(partialTicks, pokemonEntity, locatorOffset);
|
||||
|
||||
Vec3 viewVector = this.getViewVector(partialTicks);
|
||||
Vec3 viewDistanceVector = eyePosition.add(viewVector.x * hitDistance, viewVector.y * hitDistance, viewVector.z * hitDistance);
|
||||
|
||||
return this.level()
|
||||
.clip(
|
||||
new ClipContext(
|
||||
eyePosition, viewDistanceVector, ClipContext.Block.OUTLINE, hitFluids ? net.minecraft.world.level.ClipContext.Fluid.ANY : net.minecraft.world.level.ClipContext.Fluid.NONE, this
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return super.pick(hitDistance, partialTicks, hitFluids);
|
||||
}
|
||||
|
||||
@Unique
|
||||
private Vec3 cobblemon$getEyePosition(float partialTicks, PokemonEntity pokemonEntity, Vec3 locatorOffset) {
|
||||
OrientationController controller = this.getOrientationController();
|
||||
|
||||
float currEyeHeight = this.getEyeHeight();
|
||||
Vec3 offset = locatorOffset.add(pokemonEntity.position());
|
||||
if (controller.isActive() && controller.getOrientation() != null) {
|
||||
Quaternionf orientation = controller.getRenderOrientation(partialTicks);
|
||||
Vec3 rotatedEyeHeight = new Vec3(orientation.transform(new Vector3f(0f, currEyeHeight - (this.getBbHeight() / 2), 0f)));
|
||||
|
||||
offset.add(rotatedEyeHeight);
|
||||
}
|
||||
|
||||
return offset;
|
||||
}
|
||||
|
||||
@Inject(method = "tick", at = @At("HEAD"))
|
||||
private void cobblemon$updateRenderOrientation(CallbackInfo ci) {
|
||||
this.cobblemon$orientationController.tick();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void absMoveTo(double x, double y, double z, float yaw, float pitch) {
|
||||
if (cobblemon$orientationController.getActive()) {
|
||||
this.absMoveTo(x, y, z);
|
||||
this.setYRot(yaw % 360.0f);
|
||||
this.setXRot(pitch % 360.0f);
|
||||
this.yRotO = this.getYRot();
|
||||
this.xRotO = this.getXRot();
|
||||
} else {
|
||||
this.absMoveTo(x, y, z);
|
||||
this.absRotateTo(yaw, pitch);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -18,7 +18,6 @@ import com.cobblemon.mod.common.api.pokemon.PokemonSpecies;
|
||||
import com.cobblemon.mod.common.api.storage.party.PartyStore;
|
||||
import com.cobblemon.mod.common.api.storage.party.PlayerPartyStore;
|
||||
import com.cobblemon.mod.common.api.tags.CobblemonItemTags;
|
||||
import com.cobblemon.mod.common.duck.PlayerDuck;
|
||||
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity;
|
||||
import com.cobblemon.mod.common.pokedex.scanner.PokedexEntityData;
|
||||
import com.cobblemon.mod.common.pokedex.scanner.ScannableEntity;
|
||||
@@ -48,7 +47,6 @@ import net.minecraft.world.food.FoodProperties;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.joml.Vector3f;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@@ -63,12 +61,7 @@ import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Mixin(Player.class)
|
||||
public abstract class PlayerMixin extends LivingEntity implements ScannableEntity, OrientationControllable, PlayerDuck {
|
||||
|
||||
@Unique
|
||||
private Vector3f cobblemon$driverInput;
|
||||
@Unique
|
||||
private Vector3f cobblemon$lastSentDriverInput;
|
||||
public abstract class PlayerMixin extends LivingEntity implements ScannableEntity, OrientationControllable {
|
||||
|
||||
@Shadow public abstract CompoundTag getShoulderEntityLeft();
|
||||
|
||||
@@ -286,25 +279,4 @@ public abstract class PlayerMixin extends LivingEntity implements ScannableEntit
|
||||
public OrientationController getOrientationController() {
|
||||
return cobblemon$orientationController;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDriverInput(Vector3f driverInput) {
|
||||
cobblemon$driverInput = driverInput;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector3f getDriverInput() {
|
||||
return cobblemon$driverInput;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLastSentDriverInput(Vector3f lastSentDriverInput) {
|
||||
cobblemon$lastSentDriverInput = lastSentDriverInput;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector3f getLastSentDriverInput() {
|
||||
return cobblemon$lastSentDriverInput;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,7 +12,7 @@ import com.cobblemon.mod.common.CobblemonNetwork;
|
||||
import com.cobblemon.mod.common.OrientationControllable;
|
||||
import com.cobblemon.mod.common.api.net.NetworkPacket;
|
||||
import com.cobblemon.mod.common.api.orientation.OrientationController;
|
||||
import com.cobblemon.mod.common.duck.PlayerDuck;
|
||||
import com.cobblemon.mod.common.duck.ServerEntityDuck;
|
||||
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity;
|
||||
import com.cobblemon.mod.common.mixin.accessor.ChunkMapAccessor;
|
||||
import com.cobblemon.mod.common.mixin.accessor.TrackedEntityAccessor;
|
||||
@@ -41,7 +41,7 @@ import java.util.Set;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@Mixin(ServerEntity.class)
|
||||
public abstract class ServerEntityMixin {
|
||||
public abstract class ServerEntityMixin implements ServerEntityDuck {
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
@@ -53,6 +53,10 @@ public abstract class ServerEntityMixin {
|
||||
private Matrix3f cobblemon$lastSentOrientation;
|
||||
@Unique
|
||||
private boolean cobblemon$lastSentActive;
|
||||
@Unique
|
||||
private Vector3f cobblemon$driverInput;
|
||||
@Unique
|
||||
private Vector3f cobblemon$lastSentDriverInput;
|
||||
|
||||
@Inject(method = "sendChanges", at = @At("TAIL"))
|
||||
private void cobblemon$sendChanges(CallbackInfo ci) {
|
||||
@@ -89,14 +93,12 @@ public abstract class ServerEntityMixin {
|
||||
private void cobblemon$sendDriverInput() {
|
||||
if (!(this.entity instanceof ServerPlayer serverPlayer)) return;
|
||||
if(!(serverPlayer.getVehicle() instanceof PokemonEntity)) return;
|
||||
Vector3f driverInput = ((PlayerDuck)serverPlayer).getDriverInput();
|
||||
if(driverInput == null) return;
|
||||
if(cobblemon$driverInput == null) return;
|
||||
|
||||
// If no change in input is detected then don't send a new packet
|
||||
Vector3f lastSentDriverInput = ((PlayerDuck)serverPlayer).getLastSentDriverInput();
|
||||
if (driverInput.equals(lastSentDriverInput)) return;
|
||||
((PlayerDuck)serverPlayer).setLastSentDriverInput(driverInput);
|
||||
cobblemon$broadcast(new ClientboundUpdateDriverInputPacket(driverInput, entity.getId()));
|
||||
if (cobblemon$driverInput.equals(cobblemon$lastSentDriverInput)) return;
|
||||
cobblemon$lastSentDriverInput = cobblemon$driverInput;
|
||||
cobblemon$broadcast(new ClientboundUpdateDriverInputPacket(cobblemon$driverInput, entity.getId()));
|
||||
}
|
||||
|
||||
private void cobblemon$broadcast(NetworkPacket<?> packet) {
|
||||
@@ -114,4 +116,9 @@ public abstract class ServerEntityMixin {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDriverInput(Vector3f driverInput) {
|
||||
cobblemon$driverInput = driverInput;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,7 +8,6 @@
|
||||
|
||||
package com.cobblemon.mod.common.mixin.client;
|
||||
|
||||
import com.cobblemon.mod.common.OrientationControllable;
|
||||
import com.cobblemon.mod.common.client.render.player.MountedPlayerRenderer;
|
||||
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity;
|
||||
import net.minecraft.client.model.HumanoidModel;
|
||||
@@ -60,9 +59,9 @@ public class HumanoidModelMixin {
|
||||
}
|
||||
|
||||
Entity vehicle = entity.getVehicle();
|
||||
if (vehicle instanceof PokemonEntity pokemonEntity && entity instanceof OrientationControllable) {
|
||||
if (vehicle instanceof PokemonEntity pokemonEntity && entity instanceof AbstractClientPlayer) {
|
||||
var shouldRotatePlayerHead = pokemonEntity.ifRidingAvailableSupply(false, (behaviour, settings, state) -> {
|
||||
return behaviour.shouldRotateRiderHead(settings, state, pokemonEntity);
|
||||
return behaviour.shouldRotatePlayerHead(settings, state, pokemonEntity);
|
||||
});
|
||||
|
||||
if (!shouldRotatePlayerHead) {
|
||||
@@ -74,9 +73,7 @@ public class HumanoidModelMixin {
|
||||
}
|
||||
}
|
||||
|
||||
if (!(entity instanceof AbstractClientPlayer player)) return;
|
||||
|
||||
MountedPlayerRenderer.INSTANCE.animate(pokemonEntity, player, relevantPartsByName, netHeadYaw, headPitch, ageInTicks, limbSwing, limbSwingAmount);
|
||||
MountedPlayerRenderer.INSTANCE.animate(pokemonEntity, (AbstractClientPlayer) entity, relevantPartsByName, netHeadYaw, headPitch, ageInTicks, limbSwing, limbSwingAmount);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,37 +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.client;
|
||||
|
||||
import com.cobblemon.mod.common.client.render.entity.MountedLivingEntityRenderer;
|
||||
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.model.EntityModel;
|
||||
import net.minecraft.client.renderer.entity.LivingEntityRenderer;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(LivingEntityRenderer.class)
|
||||
public class LivingEntityRendererMixin<T extends LivingEntity, M extends EntityModel<T>> {
|
||||
|
||||
@Inject(
|
||||
method = "setupRotations",
|
||||
at = @At("HEAD")
|
||||
)
|
||||
private void cobblemon$modifyRoll(LivingEntity entity, PoseStack poseStack, float bob, float yBodyRot, float partialTick, float scale, CallbackInfo ci) {
|
||||
if (entity.isPassenger()) {
|
||||
var vehicle = entity.getVehicle();
|
||||
if (vehicle instanceof PokemonEntity pokemonEntity) {
|
||||
MountedLivingEntityRenderer.INSTANCE.render(entity, pokemonEntity, poseStack, bob, yBodyRot, partialTick, scale);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,6 @@ import com.cobblemon.mod.common.client.render.MatrixWrapper;
|
||||
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;
|
||||
import com.cobblemon.mod.common.duck.PlayerDuck;
|
||||
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity;
|
||||
import com.cobblemon.mod.common.net.messages.server.orientation.ServerboundUpdateOrientationPacket;
|
||||
import com.cobblemon.mod.common.net.messages.server.riding.ServerboundUpdateDriverInputPacket;
|
||||
@@ -30,7 +29,6 @@ import net.minecraft.client.player.LocalPlayer;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.ClipContext;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.phys.HitResult;
|
||||
@@ -90,17 +88,7 @@ public abstract class LocalPlayerMixin extends AbstractClientPlayer implements O
|
||||
private void cobblemon$updateDriverInputRideTick(CallbackInfo ci) {
|
||||
if (Minecraft.getInstance().player != (Object)this) return;
|
||||
if (!(this.getVehicle() instanceof PokemonEntity pokemonEntity)) return;
|
||||
|
||||
// Gather driver Input
|
||||
float vertInput = this.jumping ? 1.0f : (((Player)this).isShiftKeyDown() ? -1.0f : 0.0f);
|
||||
Vector3f driverInput = new Vector3f(Math.signum(this.xxa), vertInput, Math.signum(this.zza));
|
||||
|
||||
// Check if player input has changed. If it has then update the last sent and send it
|
||||
Vector3f lastSentDriverInput = ((PlayerDuck)this).getLastSentDriverInput();
|
||||
if (driverInput.equals(lastSentDriverInput)) return;
|
||||
((PlayerDuck)this).setLastSentDriverInput(driverInput);
|
||||
|
||||
CobblemonNetwork.INSTANCE.sendToServer(new ServerboundUpdateDriverInputPacket(driverInput));
|
||||
CobblemonNetwork.INSTANCE.sendToServer(new ServerboundUpdateDriverInputPacket(this.xxa, this.zza, this.jumping, this.isShiftKeyDown()));
|
||||
}
|
||||
|
||||
@Unique
|
||||
|
||||
@@ -9,10 +9,12 @@
|
||||
package com.cobblemon.mod.common.mixin.client;
|
||||
|
||||
import com.cobblemon.mod.common.client.render.ClientPlayerIcon;
|
||||
import com.cobblemon.mod.common.client.render.player.MountedPlayerRenderer;
|
||||
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.model.EntityModel;
|
||||
import net.minecraft.client.model.PlayerModel;
|
||||
import net.minecraft.client.player.AbstractClientPlayer;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
@@ -53,4 +55,17 @@ public abstract class PlayerRendererMixin extends LivingEntityRenderer<AbstractC
|
||||
playerModel.crouching = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(
|
||||
method = "setupRotations(Lnet/minecraft/client/player/AbstractClientPlayer;Lcom/mojang/blaze3d/vertex/PoseStack;FFFF)V",
|
||||
at = @At("HEAD")
|
||||
)
|
||||
private void cobblemon$modifyRoll(AbstractClientPlayer player, PoseStack poseStack, float a, float b, float partialTicks, float i, CallbackInfo ci) {
|
||||
if (player.isPassenger()) {
|
||||
var vehicle = player.getVehicle();
|
||||
if (vehicle instanceof PokemonEntity entity) {
|
||||
MountedPlayerRenderer.INSTANCE.render(player, entity, poseStack, a, b, partialTicks, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,7 @@ 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;
|
||||
|
||||
@Mixin(Entity.class)
|
||||
@@ -29,4 +30,19 @@ public abstract class EntityMixin {
|
||||
}
|
||||
}
|
||||
|
||||
@Redirect(
|
||||
method = "collide(Lnet/minecraft/world/phys/Vec3;)Lnet/minecraft/world/phys/Vec3;",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/entity/Entity;onGround()Z"
|
||||
)
|
||||
)
|
||||
private boolean cobblemon$forceOnGroundForStepUp(Entity entity) {
|
||||
if (entity instanceof PokemonEntity pokemon && entity.hasControllingPassenger()) {
|
||||
return true;
|
||||
}
|
||||
return entity.onGround();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -59,7 +59,6 @@ object CobblemonCommands {
|
||||
ApplyPlayerTextureCommand.register(dispatcher)
|
||||
RenameBoxCommand.register(dispatcher)
|
||||
ChangeBoxWallpaperCommand.register(dispatcher)
|
||||
RunMolangCommand.register(dispatcher)
|
||||
RunMolangScriptCommand.register(dispatcher)
|
||||
SpectateBattleCommand.register(dispatcher)
|
||||
CobblemonConfigCommand.register(dispatcher)
|
||||
|
||||
@@ -38,7 +38,6 @@ import com.cobblemon.mod.common.api.moves.Moves
|
||||
import com.cobblemon.mod.common.api.moves.animations.ActionEffectContext
|
||||
import com.cobblemon.mod.common.api.moves.animations.ActionEffects
|
||||
import com.cobblemon.mod.common.api.moves.animations.NPCProvider
|
||||
import com.cobblemon.mod.common.api.moves.animations.TargetsProvider
|
||||
import com.cobblemon.mod.common.api.npc.NPCClasses
|
||||
import com.cobblemon.mod.common.api.npc.configuration.interaction.DialogueNPCInteractionConfiguration
|
||||
import com.cobblemon.mod.common.api.npc.configuration.interaction.ScriptNPCInteractionConfiguration
|
||||
@@ -169,20 +168,6 @@ object MoLangFunctions {
|
||||
val replace = params.getString(2)
|
||||
return@Function StringValue(text.replace(search, replace))
|
||||
},
|
||||
"is_included" to java.util.function.Function { params ->
|
||||
val text = params.getString(0)
|
||||
val search = params.getString(1)
|
||||
return@Function DoubleValue(text.contains(search))
|
||||
},
|
||||
"to_lower" to java.util.function.Function { params ->
|
||||
return@Function StringValue(params.getString(0).lowercase())
|
||||
},
|
||||
"to_upper" to java.util.function.Function { params ->
|
||||
return@Function StringValue(params.getString(0).uppercase())
|
||||
},
|
||||
"string_length" to java.util.function.Function { params ->
|
||||
return@Function DoubleValue(params.getString(0).length)
|
||||
},
|
||||
"is_blank" to java.util.function.Function { params ->
|
||||
val arg = params.get<MoValue>(0)
|
||||
return@Function DoubleValue((arg is StringValue && (arg.value.isBlank() || arg.value.toDoubleOrNull() == 0.0)) || (arg is DoubleValue && arg.value == 0.0))
|
||||
@@ -708,9 +693,6 @@ object MoLangFunctions {
|
||||
val owner = entity.owner
|
||||
return@put owner?.asMostSpecificMoLangValue() ?: DoubleValue.ZERO
|
||||
}
|
||||
map.put("delta_movement") {
|
||||
return@put listOf(entity.deltaMovement.x, entity.deltaMovement.y, entity.deltaMovement.z).asArrayValue(::DoubleValue)
|
||||
}
|
||||
|
||||
if (entity is MoLangScriptingEntity) {
|
||||
map.put("add_callback") { params ->
|
||||
@@ -855,12 +837,14 @@ object MoLangFunctions {
|
||||
}
|
||||
map.put("is_standing_on_blocks") { params ->
|
||||
val depth = params.getDouble(0).toInt()
|
||||
val blockStrings: MutableSet<String> = mutableSetOf()
|
||||
val blocks: MutableSet<Block> = mutableSetOf()
|
||||
for (blockIndex in 1..<params.params.size) {
|
||||
blockStrings.add(params.getString(blockIndex))
|
||||
val blockString = params.getString(blockIndex)
|
||||
val block = BuiltInRegistries.BLOCK.get(blockString.asIdentifierDefaultingNamespace("minecraft"))
|
||||
blocks.add(block)
|
||||
}
|
||||
|
||||
return@put if (entity.isStandingOn(blockStrings, depth)) DoubleValue.ONE else DoubleValue.ZERO
|
||||
return@put if (entity.isStandingOn(blocks, depth)) DoubleValue.ONE else DoubleValue.ZERO
|
||||
}
|
||||
if (entity is PosableEntity) {
|
||||
map.put("play_animation") { params ->
|
||||
@@ -886,10 +870,6 @@ object MoLangFunctions {
|
||||
return@put DoubleValue.ONE
|
||||
}
|
||||
}
|
||||
|
||||
map.put("face") { params -> ObjectValue(ReferenceDialogueFaceProvider(entity.id, params.getBooleanOrNull(0) != false))
|
||||
|
||||
}
|
||||
}
|
||||
if (entity is Schedulable) {
|
||||
map.put("run_molang_after") { params ->
|
||||
@@ -1059,6 +1039,7 @@ object MoLangFunctions {
|
||||
map.put("name") { StringValue(npc.name.string) }
|
||||
map.put("level") { DoubleValue(npc.level) }
|
||||
map.put("has_aspect") { params -> DoubleValue(npc.aspects.contains(params.getString(0))) }
|
||||
map.put("face") { params -> ObjectValue(ReferenceDialogueFaceProvider(npc.id, params.getBooleanOrNull(0) != false)) }
|
||||
map.put("in_battle") { DoubleValue(npc.isInBattle()) }
|
||||
map.put("battles") { ArrayStruct(npc.battleIds.mapNotNull { BattleRegistry.getBattle(it)?.struct }.mapIndexed { index, value -> "$index" to value }.toMap()) }
|
||||
map.put("stop_battles") { _ -> npc.battleIds.forEach { BattleRegistry.getBattle(it)?.stop() } }
|
||||
@@ -1683,34 +1664,6 @@ object MoLangFunctions {
|
||||
map.put("pasture_conflict_enabled") {
|
||||
DoubleValue(pokemonEntity.getBehaviourFlag(PokemonBehaviourFlag.PASTURE_CONFLICT))
|
||||
}
|
||||
map.put("run_action_effect") { params ->
|
||||
val runtime = MoLangRuntime().setup()
|
||||
runtime.environment.cloneFrom(params.environment)
|
||||
runtime.withQueryValue("entity", pokemonEntity.struct)
|
||||
val actionEffect = ActionEffects.actionEffects[params.getString(0).asIdentifierDefaultingNamespace()]
|
||||
if (actionEffect != null) {
|
||||
val context = ActionEffectContext(
|
||||
actionEffect = actionEffect,
|
||||
providers = mutableListOf(TargetsProvider(pokemonEntity)),
|
||||
runtime = runtime,
|
||||
level = pokemonEntity.level()
|
||||
)
|
||||
// This was taken from NPC run_action_effect but this variable isn't used, so I just commented it out.
|
||||
// pokemonEntity.actionEffect = context
|
||||
pokemonEntity.brain.setMemory(CobblemonMemories.ACTIVE_ACTION_EFFECT, context)
|
||||
pokemonEntity.brain.setActiveActivityIfPossible(CobblemonActivities.ACTION_EFFECT)
|
||||
actionEffect.run(context).thenRun {
|
||||
val pokemonActionEffect = pokemonEntity.brain.getMemory(CobblemonMemories.ACTIVE_ACTION_EFFECT).orElse(null)
|
||||
if (pokemonActionEffect == context && pokemonEntity.brain.isActive(CobblemonActivities.ACTION_EFFECT)) {
|
||||
pokemonEntity.brain.eraseMemory(CobblemonMemories.ACTIVE_ACTION_EFFECT)
|
||||
//pokemonEntity.actionEffect = null
|
||||
}
|
||||
}
|
||||
|
||||
return@put DoubleValue.ONE
|
||||
}
|
||||
return@put DoubleValue.ZERO
|
||||
}
|
||||
map
|
||||
}
|
||||
)
|
||||
|
||||
@@ -10,12 +10,14 @@ package com.cobblemon.mod.common.api.orientation
|
||||
|
||||
import com.cobblemon.mod.common.util.math.geometry.toDegrees
|
||||
import com.cobblemon.mod.common.util.math.geometry.toRadians
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
import net.minecraft.util.Mth
|
||||
import net.minecraft.world.entity.LivingEntity
|
||||
import org.joml.Matrix3f
|
||||
import org.joml.Quaternionf
|
||||
import org.joml.Vector3f
|
||||
import kotlin.math.asin
|
||||
import kotlin.math.sign
|
||||
|
||||
open class OrientationController(val entity: LivingEntity) {
|
||||
|
||||
|
||||
@@ -132,8 +132,6 @@ object CobblemonPermissions {
|
||||
@JvmStatic
|
||||
val ABANDON_MULTITEAM = this.create("${COMMAND_PREFIX}abandonmultiteam", PermissionLevel.NONE)
|
||||
@JvmStatic
|
||||
val RUN_MOLANG = this.create("${COMMAND_PREFIX}runmolang", PermissionLevel.CHEAT_COMMANDS_AND_COMMAND_BLOCKS)
|
||||
@JvmStatic
|
||||
val RUN_MOLANG_SCRIPT = this.create("${COMMAND_PREFIX}runmolangscript", PermissionLevel.CHEAT_COMMANDS_AND_COMMAND_BLOCKS)
|
||||
@JvmStatic
|
||||
val COBBLEMON_CONFIG_RELOAD = this.create("${COMMAND_PREFIX}cobblemonconfig.reload", PermissionLevel.CHEAT_COMMANDS_AND_COMMAND_BLOCKS)
|
||||
|
||||
@@ -87,7 +87,7 @@ interface RidingBehaviour<Settings : RidingBehaviourSettings, State : RidingBeha
|
||||
|
||||
fun shouldRotatePokemonHead(settings: Settings, state: State, vehicle: PokemonEntity): Boolean
|
||||
|
||||
fun shouldRotateRiderHead(settings: Settings, state: State, vehicle: PokemonEntity): Boolean
|
||||
fun shouldRotatePlayerHead(settings: Settings, state: State, vehicle: PokemonEntity): Boolean
|
||||
|
||||
fun getRideSounds(settings: Settings, state: State, vehicle: PokemonEntity): RideSoundSettingsList
|
||||
|
||||
|
||||
@@ -120,9 +120,9 @@ class RidingController<Settings : RidingBehaviourSettings, State : RidingBehavio
|
||||
return behaviour.canJump(settings, state, vehicle, driver)
|
||||
}
|
||||
|
||||
override fun shouldRotateRiderHead(settings: Settings, state: State, vehicle: PokemonEntity): Boolean {
|
||||
override fun shouldRotatePlayerHead(settings: Settings, state: State, vehicle: PokemonEntity): Boolean {
|
||||
if (!isActive(settings, state, vehicle)) return false
|
||||
return behaviour.shouldRotateRiderHead(settings, state, vehicle)
|
||||
return behaviour.shouldRotatePlayerHead(settings, state, vehicle)
|
||||
}
|
||||
|
||||
override fun shouldRotatePokemonHead(settings: Settings, state: State, vehicle: PokemonEntity): Boolean {
|
||||
|
||||
@@ -16,6 +16,7 @@ import com.cobblemon.mod.common.api.riding.RidingStyle
|
||||
import com.cobblemon.mod.common.api.riding.behaviour.*
|
||||
import com.cobblemon.mod.common.api.riding.posing.PoseOption
|
||||
import com.cobblemon.mod.common.api.riding.posing.PoseProvider
|
||||
import com.cobblemon.mod.common.api.riding.sound.RideLoopSound
|
||||
import com.cobblemon.mod.common.api.riding.sound.RideSoundSettingsList
|
||||
import com.cobblemon.mod.common.entity.PoseType
|
||||
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity
|
||||
@@ -24,6 +25,7 @@ import com.cobblemon.mod.common.util.math.geometry.toRadians
|
||||
import net.minecraft.network.FriendlyByteBuf
|
||||
import net.minecraft.network.RegistryFriendlyByteBuf
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
import net.minecraft.sounds.SoundEvent
|
||||
import net.minecraft.util.SmoothDouble
|
||||
import net.minecraft.world.entity.LivingEntity
|
||||
import net.minecraft.world.entity.player.Player
|
||||
@@ -449,7 +451,7 @@ class BirdBehaviour : RidingBehaviour<BirdSettings, BirdState> {
|
||||
return false
|
||||
}
|
||||
|
||||
override fun shouldRotateRiderHead(
|
||||
override fun shouldRotatePlayerHead(
|
||||
settings: BirdSettings,
|
||||
state: BirdState,
|
||||
vehicle: PokemonEntity
|
||||
|
||||
@@ -409,7 +409,7 @@ class BirdNoRollBehaviour : RidingBehaviour<BirdNoRollSettings, BirdNoRollState>
|
||||
return false
|
||||
}
|
||||
|
||||
override fun shouldRotateRiderHead(
|
||||
override fun shouldRotatePlayerHead(
|
||||
settings: BirdNoRollSettings,
|
||||
state: BirdNoRollState,
|
||||
vehicle: PokemonEntity
|
||||
|
||||
@@ -184,7 +184,7 @@ class GliderBehaviour : RidingBehaviour<GliderSettings, RidingBehaviourState> {
|
||||
return false
|
||||
}
|
||||
|
||||
override fun shouldRotateRiderHead(settings: GliderSettings, state: RidingBehaviourState, vehicle: PokemonEntity): Boolean {
|
||||
override fun shouldRotatePlayerHead(settings: GliderSettings, state: RidingBehaviourState, vehicle: PokemonEntity): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
@@ -12,9 +12,9 @@ import com.bedrockk.molang.Expression
|
||||
import com.cobblemon.mod.common.Cobblemon
|
||||
import com.cobblemon.mod.common.OrientationControllable
|
||||
import com.cobblemon.mod.common.api.riding.RidingStyle
|
||||
import com.cobblemon.mod.common.api.riding.behaviour.RidingBehaviourState
|
||||
import com.cobblemon.mod.common.api.riding.behaviour.RidingBehaviour
|
||||
import com.cobblemon.mod.common.api.riding.behaviour.RidingBehaviourSettings
|
||||
import com.cobblemon.mod.common.api.riding.behaviour.RidingBehaviourState
|
||||
import com.cobblemon.mod.common.api.riding.posing.PoseOption
|
||||
import com.cobblemon.mod.common.api.riding.posing.PoseProvider
|
||||
import com.cobblemon.mod.common.api.riding.sound.RideSoundSettingsList
|
||||
@@ -269,11 +269,7 @@ class HelicopterBehaviour : RidingBehaviour<HelicopterSettings, RidingBehaviourS
|
||||
return false
|
||||
}
|
||||
|
||||
override fun shouldRotateRiderHead(
|
||||
settings: HelicopterSettings,
|
||||
state: RidingBehaviourState,
|
||||
vehicle: PokemonEntity
|
||||
): Boolean {
|
||||
override fun shouldRotatePlayerHead(settings: HelicopterSettings, state: RidingBehaviourState, vehicle: PokemonEntity): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ import com.cobblemon.mod.common.api.riding.RidingStyle
|
||||
import com.cobblemon.mod.common.api.riding.behaviour.*
|
||||
import com.cobblemon.mod.common.api.riding.posing.PoseOption
|
||||
import com.cobblemon.mod.common.api.riding.posing.PoseProvider
|
||||
import com.cobblemon.mod.common.api.riding.sound.RideLoopSound
|
||||
import com.cobblemon.mod.common.api.riding.sound.RideSoundSettingsList
|
||||
import com.cobblemon.mod.common.entity.PoseType
|
||||
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity
|
||||
@@ -451,7 +452,7 @@ class HoverBehaviour : RidingBehaviour<HoverSettings, HoverState> {
|
||||
return false
|
||||
}
|
||||
|
||||
override fun shouldRotateRiderHead(
|
||||
override fun shouldRotatePlayerHead(
|
||||
settings: HoverSettings,
|
||||
state: HoverState,
|
||||
vehicle: PokemonEntity
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.cobblemon.mod.common.entity.pokemon.PokemonEntity
|
||||
import com.cobblemon.mod.common.util.*
|
||||
import net.minecraft.network.FriendlyByteBuf
|
||||
import net.minecraft.network.RegistryFriendlyByteBuf
|
||||
import com.bedrockk.molang.runtime.MoLangMath.lerp
|
||||
import com.cobblemon.mod.common.api.riding.sound.RideSoundSettingsList
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
import net.minecraft.util.SmoothDouble
|
||||
@@ -367,7 +368,7 @@ class JetBehaviour : RidingBehaviour<JetSettings, JetState> {
|
||||
return false
|
||||
}
|
||||
|
||||
override fun shouldRotateRiderHead(
|
||||
override fun shouldRotatePlayerHead(
|
||||
settings: JetSettings,
|
||||
state: JetState,
|
||||
vehicle: PokemonEntity
|
||||
|
||||
@@ -351,7 +351,7 @@ class JetNoRollBehaviour : RidingBehaviour<JetNoRollSettings, JetNoRollState> {
|
||||
return false
|
||||
}
|
||||
|
||||
override fun shouldRotateRiderHead(
|
||||
override fun shouldRotatePlayerHead(
|
||||
settings: JetNoRollSettings,
|
||||
state: JetNoRollState,
|
||||
vehicle: PokemonEntity
|
||||
|
||||
@@ -437,7 +437,7 @@ class RocketBehaviour : RidingBehaviour<RocketSettings, RocketState> {
|
||||
return false
|
||||
}
|
||||
|
||||
override fun shouldRotateRiderHead(
|
||||
override fun shouldRotatePlayerHead(
|
||||
settings: RocketSettings,
|
||||
state: RocketState,
|
||||
vehicle: PokemonEntity
|
||||
|
||||
@@ -107,13 +107,13 @@ class CompositeBehaviour : RidingBehaviour<CompositeSettings, CompositeState> {
|
||||
}
|
||||
}
|
||||
|
||||
override fun shouldRotateRiderHead(
|
||||
override fun shouldRotatePlayerHead(
|
||||
settings: CompositeSettings,
|
||||
state: CompositeState,
|
||||
vehicle: PokemonEntity
|
||||
): Boolean {
|
||||
return chooseBehaviour(settings, state) { behaviour, behaviourSettings, behaviourState ->
|
||||
behaviour.shouldRotateRiderHead(behaviourSettings, behaviourState, vehicle)
|
||||
behaviour.shouldRotatePlayerHead(behaviourSettings, behaviourState, vehicle)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -212,8 +212,11 @@ class HorseBehaviour : RidingBehaviour<HorseSettings, HorseState> {
|
||||
//Flag for determining if player is actively inputting
|
||||
var activeInput = false
|
||||
|
||||
var newVelocity = Vec3(state.rideVelocity.get().x, state.rideVelocity.get().y, state.rideVelocity.get().z).normalize().scale(vehicle.deltaMovement.length())
|
||||
//var newVelocity = vehicle.deltaMovement.normalize()
|
||||
// Gather the previous velocity and set the horizontal fields of the velocity vector to the magnitude of the
|
||||
// ones from deltaMovement. This is important as when a collision happens the Deltamovement will reflect it
|
||||
// but rideVelocity won't.
|
||||
var newVelocity = Vec3(state.rideVelocity.get().x, 0.0, state.rideVelocity.get().z).normalize().scale(vehicle.deltaMovement.horizontalDistance())
|
||||
newVelocity = newVelocity.add(0.0, state.rideVelocity.get().y, 0.0)
|
||||
|
||||
//speed up and slow down based on input
|
||||
if (driver.zza != 0.0f && state.stamina.get() > 0.0) {
|
||||
@@ -428,7 +431,7 @@ class HorseBehaviour : RidingBehaviour<HorseSettings, HorseState> {
|
||||
return false
|
||||
}
|
||||
|
||||
override fun shouldRotateRiderHead(
|
||||
override fun shouldRotatePlayerHead(
|
||||
settings: HorseSettings,
|
||||
state: HorseState,
|
||||
vehicle: PokemonEntity
|
||||
|
||||
@@ -434,7 +434,7 @@ class MinekartBehaviour : RidingBehaviour<MinekartSettings, MinekartState> {
|
||||
return false
|
||||
}
|
||||
|
||||
override fun shouldRotateRiderHead(
|
||||
override fun shouldRotatePlayerHead(
|
||||
settings: MinekartSettings,
|
||||
state: MinekartState,
|
||||
vehicle: PokemonEntity
|
||||
|
||||
@@ -393,7 +393,7 @@ class VehicleBehaviour : RidingBehaviour<VehicleSettings, VehicleState> {
|
||||
return false
|
||||
}
|
||||
|
||||
override fun shouldRotateRiderHead(
|
||||
override fun shouldRotatePlayerHead(
|
||||
settings: VehicleSettings,
|
||||
state: VehicleState,
|
||||
vehicle: PokemonEntity
|
||||
|
||||
@@ -330,7 +330,7 @@ class BoatBehaviour : RidingBehaviour<BoatSettings, BoatState> {
|
||||
return vehicle.runtime.resolveBoolean(settings.rotatePokemonHead)
|
||||
}
|
||||
|
||||
override fun shouldRotateRiderHead(
|
||||
override fun shouldRotatePlayerHead(
|
||||
settings: BoatSettings,
|
||||
state: BoatState,
|
||||
vehicle: PokemonEntity
|
||||
|
||||
@@ -215,7 +215,7 @@ class BurstBehaviour : RidingBehaviour<BurstSettings, BurstState> {
|
||||
return false
|
||||
}
|
||||
|
||||
override fun shouldRotateRiderHead(
|
||||
override fun shouldRotatePlayerHead(
|
||||
settings: BurstSettings,
|
||||
state: BurstState,
|
||||
vehicle: PokemonEntity
|
||||
|
||||
@@ -306,7 +306,7 @@ class DolphinBehaviour : RidingBehaviour<DolphinSettings, DolphinState> {
|
||||
return false
|
||||
}
|
||||
|
||||
override fun shouldRotateRiderHead(
|
||||
override fun shouldRotatePlayerHead(
|
||||
settings: DolphinSettings,
|
||||
state: DolphinState,
|
||||
vehicle: PokemonEntity
|
||||
|
||||
@@ -19,15 +19,7 @@ import com.cobblemon.mod.common.api.molang.ObjectValue
|
||||
import com.cobblemon.mod.common.api.text.text
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.ExcludedLabels
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.PosableModel
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.animation.ActiveAnimation
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.animation.BimanualSwingAnimation
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.animation.BipedWalkAnimation
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.animation.PitchTiltAnimation
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.animation.PrimaryAnimation
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.animation.PunchAnimation
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.animation.QuadrupedWalkAnimation
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.animation.SingleBoneLookAnimation
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.animation.WingFlapIdleAnimation
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.animation.*
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.pose.ModelPartTransformation
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.wavefunction.WaveFunction
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.wavefunction.sineFunction
|
||||
@@ -125,22 +117,6 @@ object ClientMoLangFunctions {
|
||||
ObjectValue(anim)
|
||||
}
|
||||
},
|
||||
"pitch_tilt" to Function {
|
||||
model -> Function { params ->
|
||||
val bone = params.getStringOrNull(0) ?: "root"
|
||||
val maxChangePerTick = params.getDoubleOrNull(1) ?: 1.5F
|
||||
val minPitch = params.getDoubleOrNull(2) ?: -45F
|
||||
val maxPitch = params.getDoubleOrNull(3) ?: 45F
|
||||
ObjectValue(
|
||||
PitchTiltAnimation(
|
||||
bone = model.getPart(bone),
|
||||
minPitch = minPitch.toFloat(),
|
||||
maxPitch = maxPitch.toFloat(),
|
||||
maxChangePerTick = maxChangePerTick.toFloat()
|
||||
)
|
||||
)
|
||||
}
|
||||
},
|
||||
"look" to Function {
|
||||
model -> Function { params ->
|
||||
val boneName = params.getString(0)
|
||||
|
||||
@@ -719,7 +719,6 @@ class PCGUI(
|
||||
if (pasture.pastureScrollList.isHovered) pasture.pastureScrollList.mouseScrolled(mouseX, mouseY, amount, verticalAmount)
|
||||
}
|
||||
if (storageWidget.isHovered && mouseX < (storageWidget.x + StorageWidget.SCREEN_WIDTH)) this.storageWidget.box -= verticalAmount.toInt()
|
||||
if (wallpaperWidget.isHovered) wallpaperWidget.mouseScrolled(mouseX, mouseY, amount, verticalAmount)
|
||||
return super.mouseScrolled(mouseX, mouseY, amount, verticalAmount)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,70 +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.client.render.entity
|
||||
|
||||
import com.cobblemon.mod.common.api.riding.Rideable
|
||||
import com.cobblemon.mod.common.client.MountedPokemonAnimationRenderController
|
||||
import com.cobblemon.mod.common.client.entity.PokemonClientDelegate
|
||||
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity
|
||||
import com.mojang.blaze3d.vertex.PoseStack
|
||||
import com.mojang.math.Axis
|
||||
import net.minecraft.util.Mth
|
||||
import net.minecraft.world.entity.LivingEntity
|
||||
import net.minecraft.world.phys.Vec3
|
||||
import org.joml.AxisAngle4f
|
||||
import org.joml.Vector3f
|
||||
|
||||
object MountedLivingEntityRenderer {
|
||||
fun render(
|
||||
entity: LivingEntity,
|
||||
pokemon: PokemonEntity,
|
||||
stack: PoseStack,
|
||||
bob: Float,
|
||||
yBodyRot: Float,
|
||||
partialTicks: Float,
|
||||
i: Float
|
||||
) {
|
||||
if (entity.vehicle !is Rideable) return
|
||||
val matrix = stack.last().pose()
|
||||
|
||||
val seatIndex = pokemon.passengers.indexOf(entity)
|
||||
val seat = pokemon.seats[seatIndex]
|
||||
val delegate = pokemon.delegate as PokemonClientDelegate
|
||||
val locator = delegate.locatorStates[seat.locator]
|
||||
|
||||
//Positions player
|
||||
if (locator != null) {
|
||||
MountedPokemonAnimationRenderController.setup(pokemon, partialTicks)
|
||||
|
||||
//Undo seat position
|
||||
val playerPos = Vec3(
|
||||
Mth.lerp(partialTicks.toDouble(), entity.xOld, entity.x),
|
||||
Mth.lerp(partialTicks.toDouble(), entity.yOld, entity.y),
|
||||
Mth.lerp(partialTicks.toDouble(), entity.zOld, entity.z),
|
||||
)
|
||||
|
||||
val entityPos = Vec3(
|
||||
Mth.lerp(partialTicks.toDouble(), pokemon.xOld, pokemon.x),
|
||||
Mth.lerp(partialTicks.toDouble(), pokemon.yOld, pokemon.y),
|
||||
Mth.lerp(partialTicks.toDouble(), pokemon.zOld, pokemon.z),
|
||||
)
|
||||
|
||||
matrix.translate(playerPos.subtract(entityPos).toVector3f().negate())
|
||||
matrix.translate(locator.matrix.getTranslation(Vector3f()))
|
||||
|
||||
val offset = Vector3f(0f, entity.bbHeight / 2, 0f).mul(-1f)
|
||||
|
||||
matrix.rotate(locator.matrix.getRotation(AxisAngle4f()))
|
||||
matrix.rotate(Axis.YP.rotationDegrees(180 + yBodyRot))
|
||||
matrix.translate(offset)
|
||||
|
||||
matrix.translate(Vector3f(0f, 0.35f, 0f))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -607,7 +607,6 @@ open class PosableModel(@Transient override val rootPart: Bone) : ModelFrame {
|
||||
setDefault()
|
||||
// Applies any of the state's queued actions.
|
||||
state.preRender()
|
||||
state.renderMarkers.clear()
|
||||
// Performs a check that the current pose is correct and returns back which pose we should be applying. Even if
|
||||
// a change of pose is necessary, if it's going to gradually transition there then we're still going to keep
|
||||
// applying our current pose until that process is done.
|
||||
@@ -774,8 +773,8 @@ open class PosableModel(@Transient override val rootPart: Bone) : ModelFrame {
|
||||
matrixStack.scale(scale, scale, scale)
|
||||
matrixStack.mulPose(Axis.YP.rotationDegrees(yRot))
|
||||
|
||||
// Entities' locators are positioned upside-down so this fixes that
|
||||
if(entity != null) matrixStack.mulPose(Axis.ZP.rotationDegrees(180f))
|
||||
//For some reason locators are positioned upside-down so this fixes that
|
||||
matrixStack.mulPose(Axis.ZP.rotationDegrees(180f))
|
||||
|
||||
locatorAccess.update(matrixStack, entity, scale, state.locatorStates, isRoot = true)
|
||||
}
|
||||
|
||||
@@ -131,14 +131,6 @@ abstract class PosableState : Schedulable {
|
||||
/** A list of items to be rendered on a PosableModel during an animation */
|
||||
val animationItems = mutableMapOf<String, ItemStack>()
|
||||
|
||||
/** Just some numbers that might be getting arbitrarily set and referenced. */
|
||||
val numbers = mutableMapOf<String, Float>()
|
||||
/**
|
||||
* Markers that have been added to the state this render, cleared when animation is about to start.
|
||||
* This is used to hand basic state from one animation to another.
|
||||
*/
|
||||
val renderMarkers = mutableSetOf<String>()
|
||||
|
||||
/** All of the MoLang functions that can be expose current riding data. */
|
||||
val ridingFunctions = QueryStruct(hashMapOf())
|
||||
.addFunction("pitch") { params ->
|
||||
@@ -326,31 +318,6 @@ abstract class PosableState : Schedulable {
|
||||
}
|
||||
}
|
||||
}
|
||||
.addFunction("recurring_sound") { params ->
|
||||
if (params.get<MoValue>(0) !is StringValue) {
|
||||
return@addFunction Unit
|
||||
}
|
||||
//param 0 - sound
|
||||
//param 1 - offset
|
||||
//param 2 -
|
||||
val curr_time = reusableAnimTime.value
|
||||
val entity = getEntity()
|
||||
val soundEvent = SoundEvent.createVariableRangeEvent(params.getString(0).asIdentifierDefaultingNamespace())
|
||||
val offset = params.getDouble(1)
|
||||
val loopLength = params.getDouble(2)
|
||||
if (soundEvent != null) {
|
||||
val volume = 1F
|
||||
val pitch = 1F
|
||||
if( )
|
||||
if (entity != null) {
|
||||
if (!entity.isSilent) {
|
||||
entity.level().playLocalSound(entity, soundEvent, entity.soundSource, volume, pitch)
|
||||
}
|
||||
} else {
|
||||
Minecraft.getInstance().soundManager.play(SimpleSoundInstance.forUI(soundEvent, volume, pitch))
|
||||
}
|
||||
}
|
||||
}
|
||||
.addFunction("render_item") { params ->
|
||||
if (params.get<MoValue>(0) !is StringValue) return@addFunction Unit
|
||||
|
||||
|
||||
@@ -10,12 +10,15 @@ package com.cobblemon.mod.common.client.render.models.blockbench
|
||||
|
||||
import com.bedrockk.molang.runtime.MoLangRuntime
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.animation.ActiveAnimation
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.pokemon.PokemonPosableModel
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.pose.Pose
|
||||
import com.cobblemon.mod.common.entity.PosableEntity
|
||||
import com.cobblemon.mod.common.util.asExpressionLike
|
||||
import com.cobblemon.mod.common.util.isBattling
|
||||
import com.cobblemon.mod.common.util.isDusk
|
||||
import com.cobblemon.mod.common.util.isStandingOn
|
||||
import com.cobblemon.mod.common.util.isStandingOnRedSand
|
||||
import com.cobblemon.mod.common.util.isStandingOnSand
|
||||
import com.cobblemon.mod.common.util.isStandingOnSandOrRedSand
|
||||
import com.google.gson.JsonDeserializationContext
|
||||
import com.google.gson.JsonDeserializer
|
||||
import com.google.gson.JsonElement
|
||||
@@ -54,9 +57,9 @@ class PoseAdapter(
|
||||
addCondition("isUnderWater") { entity, expectedValue -> entity.isUnderWater == expectedValue }
|
||||
|
||||
// Kept for compatibility
|
||||
addCondition("isStandingOnRedSand") { entity, expectedValue -> entity.isStandingOn(setOf("minecraft:red_sand")) == expectedValue }
|
||||
addCondition("isStandingOnSand") { entity, expectedValue -> entity.isStandingOn(setOf("minecraft:sand")) == expectedValue }
|
||||
addCondition("isStandingOnSandOrRedSand") { entity, expectedValue -> entity.isStandingOn(setOf("minecraft:sand", "minecraft:red_sand")) == expectedValue }
|
||||
addCondition("isStandingOnRedSand") { entity, expectedValue -> entity.isStandingOnRedSand() == expectedValue }
|
||||
addCondition("isStandingOnSand") { entity, expectedValue -> entity.isStandingOnSand() == expectedValue }
|
||||
addCondition("isStandingOnSandOrRedSand") { entity, expectedValue -> entity.isStandingOnSandOrRedSand() == expectedValue }
|
||||
|
||||
addCondition("isDusk") { entity, expectedValue -> entity.isDusk() == expectedValue }
|
||||
|
||||
|
||||
@@ -1,83 +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.client.render.models.blockbench.animation
|
||||
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.PosableModel
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.PosableState
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.addRotation
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.pose.Bone
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.repository.RenderContext
|
||||
import com.cobblemon.mod.common.util.math.geometry.toDegrees
|
||||
import com.cobblemon.mod.common.util.math.geometry.toRadians
|
||||
import net.minecraft.util.Mth
|
||||
|
||||
/**
|
||||
* Animation used to tilt the targeted bone of the entity by a pitch that is proportionate
|
||||
* to the direction the entity is moving. This is used to make birds and fish tilt upwards
|
||||
* or downwards based on their motion.
|
||||
*
|
||||
* @author Hiroku
|
||||
* @since August 9th, 2025
|
||||
*/
|
||||
class PitchTiltAnimation(
|
||||
val bone: Bone,
|
||||
val maxChangePerTick: Float = 1F,
|
||||
val minPitch: Float = -45F,
|
||||
val maxPitch: Float = 45F,
|
||||
) : PoseAnimation() {
|
||||
companion object {
|
||||
const val PREVIOUS_ANGLE = "previous_pitch_tilt_angle"
|
||||
const val PITCHED_TILT = "has_pitched_tilt"
|
||||
}
|
||||
|
||||
override fun setupAnim(
|
||||
context: RenderContext,
|
||||
model: PosableModel,
|
||||
state: PosableState,
|
||||
limbSwing: Float,
|
||||
limbSwingAmount: Float,
|
||||
ageInTicks: Float,
|
||||
headYaw: Float,
|
||||
headPitch: Float,
|
||||
intensity: Float
|
||||
) {
|
||||
val entity = context.entity ?: return
|
||||
if (entity.passengers.isNotEmpty()) {
|
||||
return
|
||||
}
|
||||
val delta = entity.deltaMovement
|
||||
// The angleOfMotion should be 0 in the case that horizontal movement is 1 and vertical movement is 0.
|
||||
// It should be the angle in degrees that becomes higher as the entity's motion becomes more upwards, and negative as the entity's motion becomes more downwards
|
||||
val vertical = delta.y
|
||||
val horizontal = delta.horizontalDistance()
|
||||
val angleOfMotion = if (horizontal == 0.0) {
|
||||
when {
|
||||
vertical > 0 -> maxPitch
|
||||
vertical < 0 -> minPitch
|
||||
else -> 0F
|
||||
}
|
||||
} else {
|
||||
Mth.atan2(vertical, horizontal).toDegrees()
|
||||
}.coerceIn(minPitch, maxPitch)
|
||||
|
||||
val maxChangePerTick = this.maxChangePerTick * intensity
|
||||
|
||||
val lastAngle = state.numbers[PREVIOUS_ANGLE] ?: 0F
|
||||
val interpolatedAngle = if (angleOfMotion - lastAngle > maxChangePerTick) {
|
||||
lastAngle + maxChangePerTick
|
||||
} else if (angleOfMotion - lastAngle < -maxChangePerTick) {
|
||||
lastAngle - maxChangePerTick
|
||||
} else {
|
||||
angleOfMotion
|
||||
}
|
||||
bone.addRotation(0, -interpolatedAngle.toRadians())
|
||||
state.numbers[PREVIOUS_ANGLE] = interpolatedAngle
|
||||
state.renderMarkers += PITCHED_TILT
|
||||
}
|
||||
}
|
||||
@@ -11,8 +11,6 @@ package com.cobblemon.mod.common.client.render.models.blockbench.animation
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.PosableModel
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.PosableState
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.addRotation
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.animation.PitchTiltAnimation.Companion.PITCHED_TILT
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.animation.PitchTiltAnimation.Companion.PREVIOUS_ANGLE
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.frame.HeadedFrame
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.pose.Bone
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.pose.ModelPartTransformation.Companion.X_AXIS
|
||||
@@ -65,10 +63,7 @@ class SingleBoneLookAnimation(
|
||||
val head = bone ?: return
|
||||
val pitch = pitchMultiplier * headPitch.coerceIn(minPitch, maxPitch)
|
||||
val yaw = yawMultiplier * headYaw.coerceIn(minYaw, maxYaw)
|
||||
// If PitchTiltAnimation was applied then we should counteract that tilt. It does kinda
|
||||
// assume that the tilt was on the body bone, though.
|
||||
val counterTiltDegrees = if (PITCHED_TILT in state.renderMarkers) { state.numbers[PREVIOUS_ANGLE] ?: 0 } else 0F
|
||||
head.addRotation(X_AXIS, (pitch.toRadians() * intensity) + counterTiltDegrees.toRadians())
|
||||
head.addRotation(X_AXIS, pitch.toRadians() * intensity)
|
||||
head.addRotation(Y_AXIS, yaw.toRadians() * intensity)
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,6 @@
|
||||
|
||||
package com.cobblemon.mod.common.client.render.models.blockbench.pokemon.gen1
|
||||
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.animation.PitchTiltAnimation
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.createTransformation
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.frame.HeadedFrame
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.pokemon.CryProvider
|
||||
@@ -87,7 +86,6 @@ class PidgeyModel(root: ModelPart) : PokemonPosableModel(root), HeadedFrame {
|
||||
transformTicks = 10,
|
||||
quirks = arrayOf(blink),
|
||||
animations = arrayOf(
|
||||
PitchTiltAnimation(bone = getPart("body"), maxChangePerTick = 1F),
|
||||
singleBoneLook(),
|
||||
bedrock("pidgey", "air_idle")
|
||||
)
|
||||
@@ -105,7 +103,6 @@ class PidgeyModel(root: ModelPart) : PokemonPosableModel(root), HeadedFrame {
|
||||
transformTicks = 10,
|
||||
quirks = arrayOf(blink),
|
||||
animations = arrayOf(
|
||||
PitchTiltAnimation(bone = getPart("body"), maxChangePerTick = 1F),
|
||||
singleBoneLook(),
|
||||
bedrock("pidgey", "air_fly")
|
||||
)
|
||||
|
||||
@@ -15,7 +15,9 @@ import com.cobblemon.mod.common.client.render.models.blockbench.pokemon.PokemonP
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.pose.CobblemonPose
|
||||
import com.cobblemon.mod.common.entity.PoseType
|
||||
import com.cobblemon.mod.common.util.isBattling
|
||||
import com.cobblemon.mod.common.util.isStandingOn
|
||||
import com.cobblemon.mod.common.util.isStandingOnRedSand
|
||||
import com.cobblemon.mod.common.util.isStandingOnSand
|
||||
import com.cobblemon.mod.common.util.isStandingOnSandOrRedSand
|
||||
import net.minecraft.client.model.geom.ModelPart
|
||||
import net.minecraft.world.phys.Vec3
|
||||
|
||||
@@ -61,7 +63,7 @@ class HippowdonModel (root: ModelPart) : PokemonPosableModel(root), HeadedFrame
|
||||
sleep = registerPose(
|
||||
poseName = "sleep",
|
||||
poseType = PoseType.SLEEP,
|
||||
condition = { it.getEntity()?.isStandingOn(setOf("minecraft:sand")) != true },
|
||||
condition = { it.getEntity()?.isStandingOnSand() != true },
|
||||
transformedParts = arrayOf(
|
||||
sand.createTransformation().withVisibility(visibility = false),
|
||||
redsand.createTransformation().withVisibility(visibility = false)
|
||||
@@ -75,7 +77,7 @@ class HippowdonModel (root: ModelPart) : PokemonPosableModel(root), HeadedFrame
|
||||
sleepredsand = registerPose(
|
||||
poseName = "sleepsand",
|
||||
poseType = PoseType.SLEEP,
|
||||
condition = { it.getEntity()?.isStandingOn(setOf("minecraft:red_sand")) == true },
|
||||
condition = { it.getEntity()?.isStandingOnRedSand() == true },
|
||||
transformedParts = arrayOf(
|
||||
sand.createTransformation().withVisibility(visibility = false),
|
||||
redsand.createTransformation().withVisibility(visibility = false)
|
||||
@@ -89,7 +91,7 @@ class HippowdonModel (root: ModelPart) : PokemonPosableModel(root), HeadedFrame
|
||||
standing = registerPose(
|
||||
poseName = "standing",
|
||||
poseTypes = PoseType.UI_POSES + PoseType.STATIONARY_POSES,
|
||||
condition = { !it.isBattling && it.getEntity()?.isStandingOn(setOf("minecraft:sand", "minecraft:red_sand")) != true },
|
||||
condition = { !it.isBattling && it.getEntity()?.isStandingOnSandOrRedSand() != true },
|
||||
quirks = arrayOf(blink, idlequirk),
|
||||
transformedParts = arrayOf(
|
||||
sand.createTransformation().withVisibility(visibility = false),
|
||||
@@ -104,7 +106,7 @@ class HippowdonModel (root: ModelPart) : PokemonPosableModel(root), HeadedFrame
|
||||
walk = registerPose(
|
||||
poseName = "walk",
|
||||
poseTypes = PoseType.MOVING_POSES,
|
||||
condition = { it.getEntity()?.isStandingOn(setOf("minecraft:sand", "minecraft:red_sand")) != true },
|
||||
condition = { it.getEntity()?.isStandingOnSandOrRedSand() != true },
|
||||
quirks = arrayOf(blink),
|
||||
transformedParts = arrayOf(
|
||||
sand.createTransformation().withVisibility(visibility = false),
|
||||
@@ -120,7 +122,7 @@ class HippowdonModel (root: ModelPart) : PokemonPosableModel(root), HeadedFrame
|
||||
poseName = "standingsand",
|
||||
poseTypes = PoseType.STATIONARY_POSES,
|
||||
quirks = arrayOf(blink, idlequirk),
|
||||
condition = { !it.isBattling && it.getEntity()?.isStandingOn(setOf("minecraft:sand")) == true },
|
||||
condition = { !it.isBattling && it.getEntity()?.isStandingOnSand() == true },
|
||||
transformedParts = arrayOf(
|
||||
sand.createTransformation().withVisibility(visibility = false),
|
||||
redsand.createTransformation().withVisibility(visibility = false)
|
||||
@@ -135,7 +137,7 @@ class HippowdonModel (root: ModelPart) : PokemonPosableModel(root), HeadedFrame
|
||||
poseName = "standingredsand",
|
||||
poseTypes = PoseType.STATIONARY_POSES,
|
||||
quirks = arrayOf(blink, idlequirk),
|
||||
condition = { !it.isBattling && it.getEntity()?.isStandingOn(setOf("minecraft:red_sand")) == true },
|
||||
condition = { !it.isBattling && it.getEntity()?.isStandingOnRedSand() == true },
|
||||
transformedParts = arrayOf(
|
||||
sand.createTransformation().withVisibility(visibility = false),
|
||||
redsand.createTransformation().withVisibility(visibility = false)
|
||||
@@ -149,7 +151,7 @@ class HippowdonModel (root: ModelPart) : PokemonPosableModel(root), HeadedFrame
|
||||
walksand = registerPose(
|
||||
poseName = "walksand",
|
||||
poseTypes = PoseType.MOVING_POSES,
|
||||
condition = { it.getEntity()?.isStandingOn(setOf("minecraft:sand")) == true },
|
||||
condition = { it.getEntity()?.isStandingOnSand() == true },
|
||||
quirks = arrayOf(blink),
|
||||
transformedParts = arrayOf(
|
||||
sand.createTransformation().withVisibility(visibility = false),
|
||||
@@ -163,7 +165,7 @@ class HippowdonModel (root: ModelPart) : PokemonPosableModel(root), HeadedFrame
|
||||
walkredsand = registerPose(
|
||||
poseName = "walkredsand",
|
||||
poseTypes = PoseType.MOVING_POSES,
|
||||
condition = { it.getEntity()?.isStandingOn(setOf("minecraft:red_sand")) == true },
|
||||
condition = { it.getEntity()?.isStandingOnRedSand() == true },
|
||||
quirks = arrayOf(blink),
|
||||
transformedParts = arrayOf(
|
||||
sand.createTransformation().withVisibility(visibility = false),
|
||||
@@ -177,7 +179,7 @@ class HippowdonModel (root: ModelPart) : PokemonPosableModel(root), HeadedFrame
|
||||
battleidle = registerPose(
|
||||
poseName = "battleidle",
|
||||
poseTypes = PoseType.STATIONARY_POSES,
|
||||
condition = { it.isBattling && it.getEntity()?.isStandingOn(setOf("minecraft:sand", "minecraft:red_sand")) != true },
|
||||
condition = { it.isBattling && it.getEntity()?.isStandingOnSandOrRedSand() != true },
|
||||
quirks = arrayOf(blink),
|
||||
transformedParts = arrayOf(
|
||||
sand.createTransformation().withVisibility(visibility = false),
|
||||
@@ -192,7 +194,7 @@ class HippowdonModel (root: ModelPart) : PokemonPosableModel(root), HeadedFrame
|
||||
battleidlesand = registerPose(
|
||||
poseName = "battleidlesand",
|
||||
poseTypes = PoseType.STATIONARY_POSES,
|
||||
condition = { it.getEntity()?.isStandingOn(setOf("minecraft:sand")) == true && it.isBattling },
|
||||
condition = { it.getEntity()?.isStandingOnSand() == true && it.isBattling },
|
||||
quirks = arrayOf(blink),
|
||||
transformedParts = arrayOf(
|
||||
sand.createTransformation().withVisibility(visibility = true),
|
||||
@@ -207,7 +209,7 @@ class HippowdonModel (root: ModelPart) : PokemonPosableModel(root), HeadedFrame
|
||||
battleidleredsand = registerPose(
|
||||
poseName = "battleidleredsand",
|
||||
poseTypes = PoseType.STATIONARY_POSES,
|
||||
condition = { it.getEntity()?.isStandingOn(setOf("minecraft:red_sand")) == true && it.isBattling },
|
||||
condition = { it.getEntity()?.isStandingOnRedSand() == true && it.isBattling },
|
||||
quirks = arrayOf(blink),
|
||||
transformedParts = arrayOf(
|
||||
sand.createTransformation().withVisibility(visibility = false),
|
||||
|
||||
@@ -36,26 +36,16 @@ import com.cobblemon.mod.common.entity.pokeball.EmptyPokeBallEntity
|
||||
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity
|
||||
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity.Companion.SPAWN_DIRECTION
|
||||
import com.cobblemon.mod.common.pokeball.PokeBall
|
||||
import com.cobblemon.mod.common.util.effectiveName
|
||||
import com.cobblemon.mod.common.util.isLookingAt
|
||||
import com.cobblemon.mod.common.util.lang
|
||||
import com.cobblemon.mod.common.util.*
|
||||
import com.cobblemon.mod.common.util.math.DoubleRange
|
||||
import com.cobblemon.mod.common.util.math.geometry.toRadians
|
||||
import com.cobblemon.mod.common.util.math.remap
|
||||
import com.mojang.blaze3d.vertex.PoseStack
|
||||
import com.mojang.math.Axis
|
||||
import kotlin.math.PI
|
||||
import kotlin.math.ceil
|
||||
import kotlin.math.max
|
||||
import kotlin.math.min
|
||||
import kotlin.math.pow
|
||||
import kotlin.math.sqrt
|
||||
import net.minecraft.ChatFormatting
|
||||
import net.minecraft.client.Minecraft
|
||||
import net.minecraft.client.gui.Font.DisplayMode
|
||||
import net.minecraft.client.renderer.LightTexture
|
||||
import net.minecraft.client.renderer.MultiBufferSource
|
||||
import net.minecraft.client.renderer.RenderType
|
||||
import net.minecraft.client.renderer.*
|
||||
import net.minecraft.client.renderer.entity.EntityRendererProvider
|
||||
import net.minecraft.client.renderer.entity.ItemRenderer
|
||||
import net.minecraft.client.renderer.entity.MobRenderer
|
||||
@@ -67,11 +57,8 @@ import net.minecraft.resources.ResourceLocation
|
||||
import net.minecraft.util.Mth
|
||||
import net.minecraft.world.entity.Entity
|
||||
import net.minecraft.world.phys.Vec3
|
||||
import org.joml.Math
|
||||
import org.joml.Matrix4f
|
||||
import org.joml.Quaternionf
|
||||
import org.joml.Vector3f
|
||||
import org.joml.Vector4f
|
||||
import org.joml.*
|
||||
import kotlin.math.*
|
||||
|
||||
class PokemonRenderer(
|
||||
context: EntityRendererProvider.Context
|
||||
@@ -140,7 +127,7 @@ class PokemonRenderer(
|
||||
clientDelegate
|
||||
)
|
||||
}
|
||||
if (entity.platform != PlatformType.NONE) {
|
||||
if(entity.platform != PlatformType.NONE) {
|
||||
drawPlatform(
|
||||
poseMatrix,
|
||||
entity,
|
||||
@@ -157,7 +144,8 @@ class PokemonRenderer(
|
||||
|
||||
if (entity.passengers.isNotEmpty()) {
|
||||
renderRiding(entity, entityYaw, partialTicks, poseMatrix, buffer, packedLight)
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
super.render(entity, entityYaw, partialTicks, poseMatrix, buffer, packedLight)
|
||||
}
|
||||
|
||||
@@ -194,7 +182,7 @@ class PokemonRenderer(
|
||||
val controller = rollable.orientationController
|
||||
poseMatrix.pushPose()
|
||||
|
||||
if (!DISABLE_ROLLING_DEBUG && controller.active) {
|
||||
if(!DISABLE_ROLLING_DEBUG && controller.active){
|
||||
val matrix = poseMatrix.last().pose()
|
||||
val yaw = Mth.rotLerp(partialTicks, entity.yBodyRotO, entity.yBodyRot)
|
||||
val center = Vector3f(0f, entity.bbHeight/2, 0f)
|
||||
|
||||
@@ -1,100 +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.command
|
||||
|
||||
import com.bedrockk.molang.runtime.MoLangRuntime
|
||||
import com.cobblemon.mod.common.api.molang.MoLangFunctions.asMoLangValue
|
||||
import com.cobblemon.mod.common.api.molang.MoLangFunctions.asMostSpecificMoLangValue
|
||||
import com.cobblemon.mod.common.api.molang.MoLangFunctions.setup
|
||||
import com.cobblemon.mod.common.api.permission.CobblemonPermissions
|
||||
import com.cobblemon.mod.common.entity.npc.NPCEntity
|
||||
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity
|
||||
import com.cobblemon.mod.common.util.asExpressionLike
|
||||
import com.cobblemon.mod.common.util.commandLang
|
||||
import com.cobblemon.mod.common.util.entity
|
||||
import com.cobblemon.mod.common.util.permission
|
||||
import com.cobblemon.mod.common.util.player
|
||||
import com.cobblemon.mod.common.util.string
|
||||
import com.cobblemon.mod.common.util.withQueryValue
|
||||
import com.mojang.brigadier.Command
|
||||
import com.mojang.brigadier.CommandDispatcher
|
||||
import com.mojang.brigadier.arguments.StringArgumentType
|
||||
import com.mojang.brigadier.context.CommandContext
|
||||
import net.minecraft.commands.CommandSourceStack
|
||||
import net.minecraft.commands.Commands.argument
|
||||
import net.minecraft.commands.Commands.literal
|
||||
import net.minecraft.commands.arguments.EntityArgument
|
||||
import net.minecraft.server.level.ServerPlayer
|
||||
import net.minecraft.world.entity.Entity
|
||||
|
||||
object RunMolangCommand {
|
||||
private const val NAME = "runmolang"
|
||||
private const val MOLANG = "molang"
|
||||
private const val PLAYER = "player"
|
||||
private const val NPC = "npc"
|
||||
private const val POKEMON = "pokemon"
|
||||
|
||||
fun register(dispatcher : CommandDispatcher<CommandSourceStack>) {
|
||||
dispatcher.register(literal(NAME)
|
||||
.permission(CobblemonPermissions.RUN_MOLANG)
|
||||
.then(
|
||||
argument(MOLANG, StringArgumentType.string())
|
||||
.executes { execute(it, it.string(MOLANG), null, null, null) }
|
||||
.then(argument(PLAYER, EntityArgument.player())
|
||||
.executes { execute(it, it.string(MOLANG), it.player(PLAYER), null, null) }
|
||||
.then(argument(NPC, EntityArgument.entity())
|
||||
.executes { execute(it, it.string(MOLANG), it.player(PLAYER), it.entity(
|
||||
NPC
|
||||
), null) }
|
||||
.then(argument(POKEMON, EntityArgument.entity())
|
||||
.executes { execute(it, it.string(MOLANG), it.player(PLAYER), it.entity(
|
||||
NPC
|
||||
), it.entity(POKEMON)) }
|
||||
)
|
||||
)
|
||||
.then(argument(POKEMON, EntityArgument.entity())
|
||||
.executes { execute(it, it.string(MOLANG), it.player(PLAYER), null, it.entity(
|
||||
POKEMON
|
||||
)) }
|
||||
)
|
||||
)
|
||||
.then(argument(NPC, EntityArgument.entity())
|
||||
.executes { execute(it, it.string(MOLANG), null, it.entity(NPC), null) }
|
||||
.then(argument(POKEMON, EntityArgument.entity())
|
||||
.executes { execute(it, it.string(MOLANG), null, it.entity(NPC), it.entity(
|
||||
POKEMON
|
||||
)) }
|
||||
)
|
||||
)
|
||||
.then(argument(POKEMON, StringArgumentType.string())
|
||||
.executes { execute(it, it.string(MOLANG), null, null, it.entity(POKEMON)) }
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
private fun execute(context: CommandContext<CommandSourceStack>, molang: String, player: ServerPlayer?, npc: Entity?, pokemon: Entity? = null): Int {
|
||||
try {
|
||||
val runtime = MoLangRuntime().setup()
|
||||
val entity = context.source.entity
|
||||
|
||||
(npc as? NPCEntity)?.let { runtime.withQueryValue("npc", npc.struct) }
|
||||
(pokemon as? PokemonEntity)?.let { runtime.withQueryValue("pokemon", pokemon.struct) }
|
||||
player?.let { runtime.withQueryValue("player", player.asMoLangValue()) }
|
||||
entity?.let { runtime.withQueryValue("entity", entity.asMostSpecificMoLangValue()) }
|
||||
|
||||
val out = molang.asExpressionLike().resolve(runtime)
|
||||
context.source.sendSuccess({ commandLang("molang.out", out.asString()) }, true)
|
||||
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
return Command.SINGLE_SUCCESS
|
||||
}
|
||||
}
|
||||
@@ -10,20 +10,20 @@ package com.cobblemon.mod.common.command
|
||||
|
||||
import com.bedrockk.molang.runtime.MoLangRuntime
|
||||
import com.cobblemon.mod.common.api.molang.MoLangFunctions.asMoLangValue
|
||||
import com.cobblemon.mod.common.api.molang.MoLangFunctions.asMostSpecificMoLangValue
|
||||
import com.cobblemon.mod.common.api.molang.MoLangFunctions.setup
|
||||
import com.cobblemon.mod.common.api.permission.CobblemonPermissions
|
||||
import com.cobblemon.mod.common.api.scripting.CobblemonScripts
|
||||
import com.cobblemon.mod.common.entity.npc.NPCEntity
|
||||
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity
|
||||
import com.cobblemon.mod.common.util.entity
|
||||
import com.cobblemon.mod.common.util.permission
|
||||
import com.cobblemon.mod.common.util.player
|
||||
import com.cobblemon.mod.common.util.resourceLocation
|
||||
import com.cobblemon.mod.common.util.uuid
|
||||
import com.cobblemon.mod.common.util.withQueryValue
|
||||
import com.mojang.brigadier.Command
|
||||
import com.mojang.brigadier.CommandDispatcher
|
||||
import com.mojang.brigadier.arguments.StringArgumentType
|
||||
import com.mojang.brigadier.context.CommandContext
|
||||
import java.util.UUID
|
||||
import net.minecraft.commands.CommandSourceStack
|
||||
import net.minecraft.commands.Commands.argument
|
||||
import net.minecraft.commands.Commands.literal
|
||||
@@ -31,7 +31,6 @@ import net.minecraft.commands.arguments.EntityArgument
|
||||
import net.minecraft.commands.arguments.ResourceLocationArgument
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
import net.minecraft.server.level.ServerPlayer
|
||||
import net.minecraft.world.entity.Entity
|
||||
|
||||
object RunMolangScriptCommand {
|
||||
private const val NAME = "runmolangscript"
|
||||
@@ -48,38 +47,38 @@ object RunMolangScriptCommand {
|
||||
.executes { execute(it, it.resourceLocation(SCRIPT), null, null, null) }
|
||||
.then(argument(PLAYER, EntityArgument.player())
|
||||
.executes { execute(it, it.resourceLocation(SCRIPT), it.player(PLAYER), null, null) }
|
||||
.then(argument(NPC, EntityArgument.entity())
|
||||
.executes { execute(it, it.resourceLocation(SCRIPT), it.player(PLAYER), it.entity(NPC), null) }
|
||||
.then(argument(POKEMON, EntityArgument.entity())
|
||||
.executes { execute(it, it.resourceLocation(SCRIPT), it.player(PLAYER), it.entity(NPC), it.entity(POKEMON)) }
|
||||
.then(argument(NPC, StringArgumentType.string())
|
||||
.executes { execute(it, it.resourceLocation(SCRIPT), it.player(PLAYER), it.uuid(NPC), null) }
|
||||
.then(argument(POKEMON, StringArgumentType.string())
|
||||
.executes { execute(it, it.resourceLocation(SCRIPT), it.player(PLAYER), it.uuid(NPC), it.uuid(POKEMON)) }
|
||||
)
|
||||
)
|
||||
.then(argument(POKEMON, EntityArgument.entity())
|
||||
.executes { execute(it, it.resourceLocation(SCRIPT), it.player(PLAYER), null, it.entity(POKEMON)) }
|
||||
.then(argument(POKEMON, StringArgumentType.string())
|
||||
.executes { execute(it, it.resourceLocation(SCRIPT), it.player(PLAYER), null, it.uuid(POKEMON)) }
|
||||
)
|
||||
)
|
||||
.then(argument(NPC, EntityArgument.entity())
|
||||
.executes { execute(it, it.resourceLocation(SCRIPT), null, it.entity(NPC), null) }
|
||||
.then(argument(POKEMON, EntityArgument.entity())
|
||||
.executes { execute(it, it.resourceLocation(SCRIPT), null, it.entity(NPC), it.entity(POKEMON)) }
|
||||
.then(argument(NPC, StringArgumentType.string())
|
||||
.executes { execute(it, it.resourceLocation(SCRIPT), null, it.uuid(NPC), null) }
|
||||
.then(argument(POKEMON, StringArgumentType.string())
|
||||
.executes { execute(it, it.resourceLocation(SCRIPT), null, it.uuid(NPC), it.uuid(POKEMON)) }
|
||||
)
|
||||
)
|
||||
.then(argument(POKEMON, EntityArgument.entity())
|
||||
.executes { execute(it, it.resourceLocation(SCRIPT), null, null, it.entity(POKEMON)) }
|
||||
.then(argument(POKEMON, StringArgumentType.string())
|
||||
.executes { execute(it, it.resourceLocation(SCRIPT), null, null, it.uuid(POKEMON)) }
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
private fun execute(context: CommandContext<CommandSourceStack>, scriptId: ResourceLocation, player: ServerPlayer?, npc: Entity?, pokemon: Entity? = null): Int {
|
||||
private fun execute(context: CommandContext<CommandSourceStack>, scriptId: ResourceLocation, player: ServerPlayer?, npcId: UUID?, pokemonId: UUID? = null): Int {
|
||||
try {
|
||||
val runtime = MoLangRuntime().setup()
|
||||
val entity = context.source.entity
|
||||
val npc = npcId?.let { context.source.level.getEntity(it) as? NPCEntity }
|
||||
val pokemon = pokemonId?.let { context.source.level.getEntity(it) as? NPCEntity }
|
||||
|
||||
(npc as? NPCEntity)?.let { runtime.withQueryValue("npc", npc.struct) }
|
||||
(pokemon as? PokemonEntity)?.let { runtime.withQueryValue("pokemon", pokemon.struct) }
|
||||
npc?.let { runtime.withQueryValue("npc", npc.struct) }
|
||||
pokemon?.let { runtime.withQueryValue("pokemon", pokemon.struct) }
|
||||
player?.let { runtime.withQueryValue("player", player.asMoLangValue()) }
|
||||
entity?.let { runtime.withQueryValue("entity", entity.asMostSpecificMoLangValue()) }
|
||||
|
||||
CobblemonScripts.run(scriptId, runtime)
|
||||
} catch (e: Exception) {
|
||||
|
||||
@@ -52,6 +52,7 @@ import com.cobblemon.mod.common.api.riding.behaviour.RidingBehaviourSettings
|
||||
import com.cobblemon.mod.common.api.riding.behaviour.RidingBehaviourState
|
||||
import com.cobblemon.mod.common.api.riding.behaviour.RidingBehaviours
|
||||
import com.cobblemon.mod.common.api.riding.events.SelectDriverEvent
|
||||
import com.cobblemon.mod.common.api.riding.sound.RideLoopSound
|
||||
import com.cobblemon.mod.common.api.riding.sound.RideSoundManager
|
||||
import com.cobblemon.mod.common.api.riding.stats.RidingStat
|
||||
import com.cobblemon.mod.common.api.riding.util.RidingAnimationData
|
||||
@@ -111,7 +112,6 @@ import kotlin.math.PI
|
||||
import kotlin.math.ceil
|
||||
import net.minecraft.client.Minecraft
|
||||
import net.minecraft.core.BlockPos
|
||||
import net.minecraft.core.component.DataComponents
|
||||
import net.minecraft.core.registries.BuiltInRegistries
|
||||
import net.minecraft.core.registries.Registries
|
||||
import net.minecraft.nbt.CompoundTag
|
||||
@@ -160,7 +160,6 @@ import net.minecraft.world.item.ItemUtils
|
||||
import net.minecraft.world.item.Items
|
||||
import net.minecraft.world.level.Level
|
||||
import net.minecraft.world.level.LightLayer
|
||||
import net.minecraft.world.level.block.SuspiciousEffectHolder
|
||||
import net.minecraft.world.level.gameevent.GameEvent
|
||||
import net.minecraft.world.level.material.FluidState
|
||||
import net.minecraft.world.level.pathfinder.PathType
|
||||
@@ -1077,10 +1076,22 @@ open class PokemonEntity(
|
||||
player.playSound(SoundEvents.MOOSHROOM_MILK, 1.0f, 1.0f)
|
||||
// if the Mooshtank ate a Flower beforehand
|
||||
if (pokemon.lastFlowerFed != ItemStack.EMPTY && pokemon.aspects.any { it.contains("mooshtank-brown") }) {
|
||||
SuspiciousEffectHolder.tryGet(pokemon.lastFlowerFed.item)?.let {
|
||||
when (pokemon.lastFlowerFed.item) {
|
||||
Items.ALLIUM -> MobEffects.FIRE_RESISTANCE to 80
|
||||
Items.AZURE_BLUET -> MobEffects.BLINDNESS to 160
|
||||
Items.BLUE_ORCHID, Items.DANDELION -> MobEffects.SATURATION to 7
|
||||
Items.CORNFLOWER -> MobEffects.JUMP to 120
|
||||
Items.LILY_OF_THE_VALLEY -> MobEffects.POISON to 240
|
||||
Items.OXEYE_DAISY -> MobEffects.REGENERATION to 160
|
||||
Items.POPPY, Items.TORCHFLOWER -> MobEffects.NIGHT_VISION to 100
|
||||
Items.PINK_TULIP, Items.RED_TULIP, Items.WHITE_TULIP, Items.ORANGE_TULIP -> MobEffects.WEAKNESS to 180
|
||||
Items.WITHER_ROSE -> MobEffects.WITHER to 160
|
||||
CobblemonItems.PEP_UP_FLOWER -> MobEffects.LEVITATION to 160
|
||||
else -> null
|
||||
}?.let {
|
||||
// modify the suspicious stew with the effect
|
||||
val susStewStack = Items.SUSPICIOUS_STEW.defaultInstance.copy()
|
||||
susStewStack.set(DataComponents.SUSPICIOUS_STEW_EFFECTS, it.suspiciousEffects)
|
||||
val susStewStack = Items.SUSPICIOUS_STEW.defaultInstance
|
||||
//SuspiciousStewItem.addEffectsToStew(susStewStack, listOf(StewEffect(it.first, it.second)))
|
||||
val susStewEffect = ItemUtils.createFilledResult(itemStack, player, susStewStack)
|
||||
//give player modified Suspicious Stew
|
||||
player.setItemInHand(hand, susStewEffect)
|
||||
@@ -1113,7 +1124,7 @@ open class PokemonEntity(
|
||||
itemStack.`is`(Items.WITHER_ROSE) ||
|
||||
itemStack.`is`(CobblemonItems.PEP_UP_FLOWER)
|
||||
) {
|
||||
if (pokemon.aspects.any { it.contains("mooshtank-brown") }) {
|
||||
if (pokemon.aspects.any { it.contains("mooshtank") }) {
|
||||
player.playSound(SoundEvents.MOOSHROOM_EAT, 1.0f, 1.0f)
|
||||
pokemon.lastFlowerFed = itemStack
|
||||
return InteractionResult.sidedSuccess(level().isClientSide)
|
||||
|
||||
@@ -11,21 +11,29 @@ package com.cobblemon.mod.common.net.messages.server.riding
|
||||
import com.cobblemon.mod.common.api.net.NetworkPacket
|
||||
import com.cobblemon.mod.common.util.cobblemonResource
|
||||
import net.minecraft.network.RegistryFriendlyByteBuf
|
||||
import org.joml.Vector3f
|
||||
|
||||
class ServerboundUpdateDriverInputPacket internal constructor(
|
||||
val driverInput: Vector3f
|
||||
val xxa: Float,
|
||||
val zza: Float,
|
||||
val jumping: Boolean,
|
||||
val crouching: Boolean
|
||||
) : NetworkPacket<ServerboundUpdateDriverInputPacket> {
|
||||
override val id = ID
|
||||
override fun encode(buffer: RegistryFriendlyByteBuf) {
|
||||
buffer.writeVector3f(driverInput)
|
||||
buffer.writeFloat(xxa)
|
||||
buffer.writeFloat(zza)
|
||||
buffer.writeBoolean(jumping)
|
||||
buffer.writeBoolean(crouching)
|
||||
}
|
||||
|
||||
companion object {
|
||||
val ID = cobblemonResource("c2s_update_driver_input")
|
||||
fun decode(buffer: RegistryFriendlyByteBuf): ServerboundUpdateDriverInputPacket {
|
||||
val driverInput = buffer.readVector3f()
|
||||
return ServerboundUpdateDriverInputPacket(driverInput)
|
||||
val xxa = buffer.readFloat()
|
||||
val zza = buffer.readFloat()
|
||||
val jumping = buffer.readBoolean()
|
||||
val crouching = buffer.readBoolean()
|
||||
return ServerboundUpdateDriverInputPacket(xxa, zza, jumping, crouching)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,10 +9,14 @@
|
||||
package com.cobblemon.mod.common.net.serverhandling.riding
|
||||
|
||||
import com.cobblemon.mod.common.api.net.ServerNetworkPacketHandler
|
||||
import com.cobblemon.mod.common.duck.PlayerDuck
|
||||
import com.cobblemon.mod.common.duck.ServerEntityDuck
|
||||
import com.cobblemon.mod.common.mixin.accessor.ChunkMapAccessor
|
||||
import com.cobblemon.mod.common.mixin.accessor.TrackedEntityAccessor
|
||||
import com.cobblemon.mod.common.net.messages.server.riding.ServerboundUpdateDriverInputPacket
|
||||
import net.minecraft.server.MinecraftServer
|
||||
import net.minecraft.server.level.ServerPlayer
|
||||
import org.joml.Vector3f
|
||||
import kotlin.math.sign
|
||||
|
||||
object DriverInputPacketHandler : ServerNetworkPacketHandler<ServerboundUpdateDriverInputPacket> {
|
||||
|
||||
@@ -21,8 +25,22 @@ object DriverInputPacketHandler : ServerNetworkPacketHandler<ServerboundUpdateDr
|
||||
server: MinecraftServer,
|
||||
player: ServerPlayer
|
||||
) {
|
||||
if (player is PlayerDuck) {
|
||||
player.setDriverInput(packet.driverInput)
|
||||
val chunkMap = player.serverLevel().chunkSource.chunkMap
|
||||
val entityMap = (chunkMap as ChunkMapAccessor).entityMap
|
||||
val trackedEntity = entityMap[player.id]
|
||||
if (trackedEntity is TrackedEntityAccessor) {
|
||||
val serverEntity = trackedEntity.getServerEntity()
|
||||
if (serverEntity is ServerEntityDuck) {
|
||||
val vertInput = when {
|
||||
packet.jumping-> 1.0f
|
||||
packet.crouching -> -1.0f
|
||||
else -> 0.0f
|
||||
}
|
||||
val driverInput = Vector3f(packet.xxa.sign, vertInput, packet.zza.sign)
|
||||
serverEntity.setDriverInput(driverInput)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -16,5 +16,4 @@ import net.minecraft.commands.arguments.ResourceLocationArgument
|
||||
fun CommandContext<CommandSourceStack>.player(argumentName: String = "player") = EntityArgument.getPlayer(this, argumentName)
|
||||
fun CommandContext<CommandSourceStack>.string(argumentName: String) = this.getArgument(argumentName, String::class.java)
|
||||
fun CommandContext<CommandSourceStack>.uuid(argumentName: String) = this.getArgument(argumentName, String::class.java).asUUID
|
||||
fun CommandContext<CommandSourceStack>.resourceLocation(argumentName: String) = ResourceLocationArgument.getId(this, argumentName)
|
||||
fun CommandContext<CommandSourceStack>.entity(argumentName: String) = EntityArgument.getEntity(this, argumentName)
|
||||
fun CommandContext<CommandSourceStack>.resourceLocation(argumentName: String) = ResourceLocationArgument.getId(this, argumentName)
|
||||
@@ -10,22 +10,20 @@ package com.cobblemon.mod.common.util
|
||||
|
||||
import com.google.common.collect.ImmutableMap
|
||||
import com.mojang.serialization.Dynamic
|
||||
import com.mojang.serialization.JavaOps
|
||||
import java.util.ArrayDeque
|
||||
import kotlin.math.ceil
|
||||
import kotlin.math.floor
|
||||
import kotlin.math.min
|
||||
import net.minecraft.core.BlockPos
|
||||
import net.minecraft.core.Direction
|
||||
import net.minecraft.core.registries.Registries
|
||||
import net.minecraft.nbt.NbtOps
|
||||
import net.minecraft.nbt.Tag
|
||||
import net.minecraft.network.syncher.EntityDataAccessor
|
||||
import net.minecraft.network.syncher.SynchedEntityData
|
||||
import net.minecraft.tags.TagKey
|
||||
import net.minecraft.util.ExtraCodecs
|
||||
import net.minecraft.world.entity.Entity
|
||||
import net.minecraft.world.level.Level
|
||||
import net.minecraft.world.level.block.Block
|
||||
import net.minecraft.world.level.block.Blocks
|
||||
import net.minecraft.world.phys.AABB
|
||||
import net.minecraft.world.phys.Vec3
|
||||
import net.minecraft.world.phys.shapes.BooleanOp
|
||||
@@ -181,21 +179,25 @@ fun Entity.isDusk(): Boolean {
|
||||
return time in 12000..13000
|
||||
}
|
||||
|
||||
fun Entity.isStandingOn(blocks: Set<String>, depth: Int = 2): Boolean {
|
||||
fun Entity.isStandingOnSand(): Boolean {
|
||||
return isStandingOn(setOf(Blocks.SAND))
|
||||
}
|
||||
|
||||
fun Entity.isStandingOnRedSand(): Boolean {
|
||||
return isStandingOn(setOf(Blocks.RED_SAND))
|
||||
}
|
||||
|
||||
fun Entity.isStandingOnSandOrRedSand(): Boolean {
|
||||
return isStandingOn(setOf(Blocks.SAND, Blocks.RED_SAND))
|
||||
}
|
||||
|
||||
fun Entity.isStandingOn(blocks: Set<Block>, depth: Int = 2): Boolean {
|
||||
for (currentDepth in 1..depth) {
|
||||
val bellowBlockPos = blockPosition().below(currentDepth)
|
||||
val blockState = level().getBlockState(bellowBlockPos)
|
||||
|
||||
if (blockState.isAir || !blockState.isCollisionShapeFullBlock(level(), bellowBlockPos)) continue
|
||||
|
||||
val elementOrTags = ExtraCodecs.TAG_OR_ELEMENT_ID.listOf().decode(JavaOps.INSTANCE, blocks).result().get().first
|
||||
elementOrTags.forEach {
|
||||
if (it.tag) {
|
||||
if (blockState.blockHolder.`is`(TagKey.create(Registries.BLOCK, it.id))) return true
|
||||
} else {
|
||||
if (blockState.blockHolder.`is`(it.id)) return true
|
||||
}
|
||||
}
|
||||
if (blocks.contains(blockState.block)) return true
|
||||
}
|
||||
|
||||
return false
|
||||
|
||||
@@ -17503,10 +17503,6 @@
|
||||
"3.1667": {
|
||||
"effect": "animation.leather.wing_flap.medium"
|
||||
}
|
||||
},
|
||||
"timeline": {
|
||||
"1.125": "q.has_entity ? { q.sound('animation.chitin.wing_flap.medium'); };",
|
||||
"3.1667": "q.has_entity ? { q.particle('cobblemon:ambient_shiny_sparkle', 'root'); };"
|
||||
}
|
||||
},
|
||||
"animation.charizard.air_fly": {
|
||||
@@ -18795,10 +18791,6 @@
|
||||
"3.0833": {
|
||||
"effect": "animation.leather.wing_flap.medium"
|
||||
}
|
||||
},
|
||||
"timeline": {
|
||||
"1.0833": "q.particle('cobblemon:ambient_shiny_sparkle', 'root');",
|
||||
"3.0833": "q.sound('animation.chitin.wing_flap.medium');"
|
||||
}
|
||||
},
|
||||
"animation.charizard.air_glide_TEST": {
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
"namedAnimations": {
|
||||
"faint": "q.bedrock_primary('magikarp', 'water_faint', q.curve('one'))"
|
||||
},
|
||||
"animations": ["q.pitch_tilt('body', 0.22)", "q.look('head')", "q.bedrock('magikarp', 'water_idle')"],
|
||||
"animations": ["q.look('head')", "q.bedrock('magikarp', 'water_idle')"],
|
||||
"quirks": ["q.bedrock_quirk('magikarp', 'blink')"]
|
||||
},
|
||||
"swim": {
|
||||
@@ -42,7 +42,7 @@
|
||||
"namedAnimations": {
|
||||
"faint": "q.bedrock_primary('magikarp', 'water_faint', q.curve('one'))"
|
||||
},
|
||||
"animations": ["q.pitch_tilt('body', 0.22)", "q.look('head')", "q.bedrock('magikarp', 'water_swim')"],
|
||||
"animations": ["q.look('head')", "q.bedrock('magikarp', 'water_swim')"],
|
||||
"quirks": ["q.bedrock_quirk('magikarp', 'blink')"]
|
||||
},
|
||||
"sleep": {
|
||||
|
||||
@@ -2340,7 +2340,6 @@
|
||||
"cobblemon.command.takemark": "%1$s was taken from %2$s's %3$s.",
|
||||
"cobblemon.command.takemark.does_not_have": "%1$s's %2$s does not have a %3$s!",
|
||||
"cobblemon.command.mark.invalid": "Invalid mark name.",
|
||||
"cobblemon.command.molang.out": "MoLang output: %1$s",
|
||||
"cobblemon.command.pokeheal.in_battle": "You cannot heal your party while in a battle!",
|
||||
"cobblemon.command.spawnpokemonfrompool": "A %1$s has spawned in the area.",
|
||||
"cobblemon.command.spawnpokemonfrompool.unable_to_spawn": "Unable to spawn a Pokémon.",
|
||||
|
||||
|
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 25 KiB |
|
Before Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 21 KiB |
|
Before Width: | Height: | Size: 24 KiB |
|
Before Width: | Height: | Size: 9.1 KiB After Width: | Height: | Size: 7.4 KiB |
|
Before Width: | Height: | Size: 8.6 KiB |
|
Before Width: | Height: | Size: 8.7 KiB |
|
Before Width: | Height: | Size: 6.0 KiB |
|
Before Width: | Height: | Size: 9.6 KiB |
@@ -5,33 +5,9 @@ math.mod(q.player.world.game_time, 20) != 0 ? {
|
||||
|
||||
t.pc = q.player.pc;
|
||||
|
||||
t.pc.has_unlocked_wallpaper('cobblemon:biome_cave') == 0 ? {
|
||||
q.player.biome.is_in('#cobblemon:is_cave') ? {
|
||||
t.pc.unlock_wallpaper('cobblemon:biome_cave', 1);
|
||||
};
|
||||
};
|
||||
|
||||
t.pc.has_unlocked_wallpaper('cobblemon:biome_forest') == 0 ? {
|
||||
q.player.biome.is_in('#cobblemon:is_forest') ? {
|
||||
t.pc.unlock_wallpaper('cobblemon:biome_forest', 1);
|
||||
};
|
||||
};
|
||||
|
||||
t.pc.has_unlocked_wallpaper('cobblemon:biome_ocean') == 0 ? {
|
||||
q.player.biome.is_in('#cobblemon:is_ocean') ? {
|
||||
t.pc.unlock_wallpaper('cobblemon:biome_ocean', 1);
|
||||
};
|
||||
};
|
||||
|
||||
t.pc.has_unlocked_wallpaper('cobblemon:biome_nether') == 0 ? {
|
||||
t.pc.has_unlocked_wallpaper('cobblemon:dark_mode') == 0 ? {
|
||||
q.player.biome.is_in('#minecraft:is_nether') ? {
|
||||
t.pc.unlock_wallpaper('cobblemon:biome_nether', 1);
|
||||
};
|
||||
};
|
||||
|
||||
t.pc.has_unlocked_wallpaper('cobblemon:biome_the_end') == 0 ? {
|
||||
q.player.biome.is_in('#cobblemon:is_end') ? {
|
||||
t.pc.unlock_wallpaper('cobblemon:biome_the_end', 1);
|
||||
t.pc.unlock_wallpaper('cobblemon:dark_mode', 1);
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"type": "minecraft:chest",
|
||||
"pools": [
|
||||
{
|
||||
"rolls": 3,
|
||||
"rolls": 1,
|
||||
"bonus_rolls": 0.0,
|
||||
"entries": [
|
||||
{
|
||||
@@ -12,8 +12,8 @@
|
||||
"add": false,
|
||||
"count": {
|
||||
"type": "minecraft:uniform",
|
||||
"max": 1.0,
|
||||
"min": 3.0
|
||||
"max": 3.0,
|
||||
"min": 9.0
|
||||
},
|
||||
"function": "minecraft:set_count"
|
||||
}
|
||||
@@ -29,28 +29,12 @@
|
||||
"count": {
|
||||
"type": "minecraft:uniform",
|
||||
"max": 1.0,
|
||||
"min": 1.0
|
||||
"min": 3.0
|
||||
},
|
||||
"function": "minecraft:set_count"
|
||||
}
|
||||
],
|
||||
"name": "cobblemon:exp_candy_m",
|
||||
"weight": 10
|
||||
},
|
||||
{
|
||||
"type": "minecraft:item",
|
||||
"functions": [
|
||||
{
|
||||
"add": false,
|
||||
"count": {
|
||||
"type": "minecraft:uniform",
|
||||
"max": 1.0,
|
||||
"min": 1.0
|
||||
},
|
||||
"function": "minecraft:set_count"
|
||||
}
|
||||
],
|
||||
"name": "minecraft:golden_apple",
|
||||
"name": "cobblemon:rare_candy",
|
||||
"weight": 10
|
||||
}
|
||||
]
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"type": "minecraft:chest",
|
||||
"pools": [
|
||||
{
|
||||
"rolls": 6,
|
||||
"rolls": 1,
|
||||
"bonus_rolls": 0.0,
|
||||
"entries": [
|
||||
{
|
||||
@@ -12,8 +12,8 @@
|
||||
"add": false,
|
||||
"count": {
|
||||
"type": "minecraft:uniform",
|
||||
"max": 1.0,
|
||||
"min": 3.0
|
||||
"max": 6.0,
|
||||
"min": 18.0
|
||||
},
|
||||
"function": "minecraft:set_count"
|
||||
}
|
||||
@@ -28,29 +28,13 @@
|
||||
"add": false,
|
||||
"count": {
|
||||
"type": "minecraft:uniform",
|
||||
"max": 1.0,
|
||||
"min": 2.0
|
||||
"max": 3.0,
|
||||
"min": 5.0
|
||||
},
|
||||
"function": "minecraft:set_count"
|
||||
}
|
||||
],
|
||||
"name": "cobblemon:exp_candy_m",
|
||||
"weight": 10
|
||||
},
|
||||
{
|
||||
"type": "minecraft:item",
|
||||
"functions": [
|
||||
{
|
||||
"add": false,
|
||||
"count": {
|
||||
"type": "minecraft:uniform",
|
||||
"max": 1.0,
|
||||
"min": 2.0
|
||||
},
|
||||
"function": "minecraft:set_count"
|
||||
}
|
||||
],
|
||||
"name": "minecraft:golden_apple",
|
||||
"name": "cobblemon:rare_candy",
|
||||
"weight": 10
|
||||
}
|
||||
]
|
||||
|
||||
@@ -2,7 +2,7 @@ t.wander_control = q.entity.get_wander_control_memory();
|
||||
t.wander_control.reset();
|
||||
|
||||
t.wander_control.set_allow_land((q.entity.behaviour.moving.walk.can_walk && !q.entity.behaviour.moving.walk.avoids_land) || (!q.entity.behaviour.moving.walk.can_walk && q.entity.behaviour.moving.fly.can_fly));
|
||||
t.wander_control.set_allow_water(q.entity.behaviour.moving.swim.can_swim_in_water && !q.entity.behaviour.moving.swim.avoids_water);
|
||||
t.wander_control.set_allow_water(q.entity.behaviour.moving.swim.can_swim && !q.entity.behaviour.moving.swim.avoids_water);
|
||||
t.wander_control.set_allow_air(q.entity.behaviour.moving.fly.can_fly && !q.entity.behaviour.moving.walk.can_walk);
|
||||
|
||||
t.wander_control.set_walk_speed(0.35);
|
||||
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"replace": false,
|
||||
"values": [
|
||||
"cobblemon:pep_up_flower"
|
||||
]
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
{
|
||||
"texture": "cobblemon:textures/gui/pc/wallpaper/wallpaper_biome_cave.png",
|
||||
"enabled": true
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
{
|
||||
"texture": "cobblemon:textures/gui/pc/wallpaper/wallpaper_biome_forest.png",
|
||||
"enabled": true
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
{
|
||||
"texture": "cobblemon:textures/gui/pc/wallpaper/wallpaper_biome_nether.png",
|
||||
"enabled": true
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
{
|
||||
"texture": "cobblemon:textures/gui/pc/wallpaper/wallpaper_biome_ocean.png",
|
||||
"enabled": true
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
{
|
||||
"texture": "cobblemon:textures/gui/pc/wallpaper/wallpaper_biome_the_end.png",
|
||||
"enabled": true
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"texture": "cobblemon:textures/gui/pc/wallpaper/wallpaper_basic_11.png",
|
||||
"enabled": true
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"replace": false,
|
||||
"values": [
|
||||
"#cobblemon:small_flowers"
|
||||
]
|
||||
}
|
||||