#I'm making a Minecraft mod which some mechanics was working and suddenly failed when code modified

11 messages · Page 1 of 1 (latest)

tranquil marlin
#

First, by describing what I want:
I'm making an Item called Aero-Shock Core That Stomps the wall (or the ground)
when flying with elytra at a specific speed
I was trying to make animation for it but suddenly when done the mechanics of stomping ground (and just for the ground) isn't working but for wall it's all good

marble doveBOT
#

<@&987246717831381062> please have a look, thanks.

#

Here is an AI assisted attempt to answer your question 🤖. Maybe it helps! In any case, a human is on the way 👍. To continue talking to the AI, you can use </chatgpt:1108714622413963314>.

#
TJ-Bot
First, by describing what I want: I'm making an Item called Aero-Shock Core That Stomps the wall (or the ground) when flying with elytra at a specific speed I was trying to make animation for it but suddenly when done the mechanics of stomping ground (and

Your goal is clear: you want the Aero-Shock Core item in your Minecraft mod to trigger a stomp animation when the player is flying with an elytra at a certain speed and collides with a wall or ground.

From your description and typical issues in similar mods, here are key points to check rather than rewriting your code:

  • Speed detection: Ensure your code accurately reads player velocity and checks the threshold before triggering the effect. Small changes in how velocity vectors are calculated or compared can cause the stomp not to trigger.
  • Collision detection: Verify collision events with walls/ground are still properly detected. Changes in event hooks or world interaction code may break detection.
  • Animation timing: Confirm the animation triggers at the right time post-collision and that any new code did not disrupt animation states or rendering calls.
  • State flags: If you use flags to prevent repeated stomps mid-flight, check their reset conditions; these often cause the stomp to stop working after initial trigger.

Focus on reviewing recent changes against these areas, comparing with your older working code.


Useful links:

tranquil marlin
#

`@Mixin(PlayerEntity.class)
public class AeroShockCoreMixin {
@Inject(method = "damage", at = @At("HEAD"), cancellable = true)
private void onAeroShockDamage(ServerWorld world, DamageSource source, float amount, CallbackInfoReturnable<Boolean> cir) {
PlayerEntity player = (PlayerEntity) (Object) this;

    if (source.isOf(DamageTypes.FLY_INTO_WALL) || source.isOf(DamageTypes.FALL)) {

        ItemStack coreStack = ItemStack.EMPTY;
        for (int i = 0; i < player.getInventory().size(); i++) {
            ItemStack stack = player.getInventory().getStack(i);
            if (stack.isOf(ModItems.AERO_SHOCK_CORE)) {
                coreStack = stack;
                break;
            }
        }`
#

`
if (!coreStack.isEmpty()) {
cir.setReturnValue(false);

            float shockwaveRadius = Math.min(3.0f + (amount / 4.0f), 7.0f);
            if (EchoingGroveStealth.isWearingEchoingGroveElytra(player)) {
                EchoingGroveStealth.silenceZone(world, player.getBlockPos(), shockwaveRadius + 2.0, 8L);
            }

// AeroShockAnimationPayload payload = new AeroShockAnimationPayload(player.getId());
// ServerPlayNetworking.send((ServerPlayerEntity) player, payload);
// for (ServerPlayerEntity trackingPlayer : PlayerLookup.tracking(player)) {
// ServerPlayNetworking.send(trackingPlayer, payload);
// }

            world.spawnParticles(ParticleTypes.EXPLOSION_EMITTER, player.getX(), player.getY(), player.getZ(), 1, 0.0, 0.0, 0.0, 0.0);
            world.playSound(null, player.getX(), player.getY(), player.getZ(), SoundEvents.ENTITY_WIND_CHARGE_THROW, SoundCategory.PLAYERS, 2.0F, 0.5F);
            world.playSound(null, player.getX(), player.getY(), player.getZ(), SoundEvents.ENTITY_LIGHTNING_BOLT_THUNDER, SoundCategory.PLAYERS, 1.0F, 1.2F);

            Box searchBox = player.getBoundingBox().expand(shockwaveRadius);
            List<LivingEntity> targets = world.getEntitiesByClass(LivingEntity.class, searchBox,
                new Predicate<LivingEntity>() {
                    @Override
                    public boolean test(LivingEntity entity) {
                        return entity != player && entity.isAlive();
                    }
                }
            );`
#

`
for (LivingEntity target : targets) {
target.damage(world, world.getDamageSources().explosion(player, player), amount * 1.5f);

                double dX = target.getX() - player.getX();
                double dZ = target.getZ() - player.getZ();
                target.takeKnockback(1.5, -dX, -dZ);
            }

            if (player.isCreative()) return;

            coreStack.damage(1, (ServerWorld) world, null, item -> {
                player.playSound(SoundEvents.ITEM_LEAD_BREAK, 1.0f, 1.0f);
            });
        }
    }
}

}`

#

this is the full code unfortunately I had to send in multiple messages

marble doveBOT
#

@tranquil marlin

Your question has been closed due to inactivity.

If it was not resolved yet, click the button below to keep it
open, or feel free to create a new thread.

Note that usually the reason for nobody calling back is that your
question may have been not well asked and hence no one felt confident
enough answering.

When you reopen the thread, try to use your time to improve the quality
of the question by elaborating, providing details, context, all relevant code
snippets, any errors you are getting, concrete examples and perhaps also some
screenshots. Share your attempt, explain the expected results and compare
them to the current results.

Also try to make the information easily accessible by sharing code
or assignment descriptions directly on Discord, not behind a link or
PDF-file; provide some guidance for long code snippets and ensure
the code is well formatted and has syntax highlighting. Kindly read through
https://stackoverflow.com/help/how-to-ask for more.

With enough info, someone knows the answer for sure 👍

twilit jay
#

@tranquil marlin

#

what is ur problem

#

t3al bsa3dk