Sollace / Unicopia

The pony powers mod to power in your pony pony pony
https://modrinth.com/mod/unicopia
56 stars 22 forks source link

Unicorn shield oddities. #24

Closed kerplamp closed 3 years ago

kerplamp commented 3 years ago
  1. The unicorn shield detects dropped items as if they were players and subtracts from the purple stamina bar thing.
  2. When I was testing the mod the unicorn shield hardly depleted the, or depleted inconsistently. (I messed around with the code and getting rid of the age % 20 == 0 thing and replacing it with age > 50 or some other number fixed inconsistency. But when I did it made it deplete really fast so I changed the "4 + (source... " part with a lower number. But now the hunger bar does this weird thing where it doesn't actually get depleted and when I get hit I get hunger back. I think having the shield spell just turn off when out of purple stamina would avoid that issue.)

I've never done anything with java or minecraft mods. It took me like 4 hours to figure out how to add haste to earth ponies, and even then its not really a good solution. So idk how you would fix the unicorn shield stuff.

I feel bad just dumping issues so I hope including what I tried will help.

Sorry for all the comments so quickly but this mod is so awesome and promising I can't help but get excited.

Sollace commented 3 years ago

I may have sorted out most of the oddities with the shield. The thing to consider is that the amount of energy it consumes is dependent upon the number of entities it's defending against. When it's unchallenged it really shouldn't be depleting your mana reserves.

kerplamp commented 3 years ago

After a lot more testing with the shield I found a few more things.

  1. XP orbs and arrows that have been stuck in the ground are still detected by shield and drain stamina. ( I tried to fix arrow thing but my knowledge of minecraft modding begins at when I made my first post on this github, sorry.)

  2. The shield is off center. Entities coming from the south-east are able to get further into the shield. South east is the direction where coordinates decrease.

Also I'm attaching a video of what I was talking about originally with the whole- if (source.getMaster().age > 20 ) { double cost = 1 + (source.getLevel().get() * 2); -thing.

The first clip is testing the above settings. The second clip is using what it currently is set at. https://www.youtube.com/watch?v=yDxAxoz0l84

Setting the "1" to a lower number should decrease drain rate.

Sollace commented 3 years ago

These three most recent commits should help with your issues. https://github.com/Sollace/Unicopia/commit/f8851980852c5676971cef08dc8cca1351b752b9 , https://github.com/Sollace/Unicopia/commit/8f654177ec0a72b563b66b611140018f8897bd5f and https://github.com/Sollace/Unicopia/commit/b43ed1975b20de87bb1645941f242eeb652e0a07

kerplamp commented 3 years ago

The shield still seems to have inconsistency but I think I've figured out why.

@Override

public boolean updateOnPerson(Caster<?> source) {

    int costMultiplier = applyEntities(source);

    if (costMultiplier > 0) {

        if (source.getMaster().age % 20 == 0) {
            double cost = 2 + source.getLevel().get();

            cost *= Math.max(1, costMultiplier / 12F);

            if (!source.subtractEnergyCost(cost)) {
                onDestroyed(source);
            }
        }
    }

every tick (atleast I think it's every tick) it sets the costMultiplier to whatever is touching the shield and every 20 ticks(?) it uses costMultiplier in its equation. This means that a mob has to be in contact with the shield the exact moment the age is divisible by 20.

The problem is that the shield bounces enemies back. Enemies bump into the shield every now and then and aren't in constant contact with the shield. That means the bumps into the shield have to sync up with the 20 tick(?) check. And what all that means is that the shield depletion is almost luck based.

I've messed with the code and came up with this:

@Override
public boolean updateOnPerson(Caster<?> source) {
    costMultiplier += applyEntities(source);
    if (costMultiplier > 0) {
        if (source.getMaster().age % 20 == 0) {
            double cost = 2 + source.getLevel().get();

            cost *= (costMultiplier / 5F);
            costMultiplier = 0;
            if (!source.subtractEnergyCost(cost)) {
                onDestroyed(source);
            }
        }

    }

This should store the mobs that bump into the shield until the next time it checks to deplete the shield. But there is the problem that the same entity could bump into the shield over and over and increase the count but you could just change how much costMultiplier is divided by when cost is set, that's what I did atleast.

*costMultiplier is declared outside the public boolean up where I saw other variable type stuff being declared

double costMultiplier = 0;

@Override
public String getName() {
    return "shield";
}

@Override
public Affinity getAffinity() {
    return Affinity.NEUTRAL;
}

Also uhh, I haven't mentioned it because I think you already know but I just want to make sure. Everytime I start my minecraft with a version that I compiled myself (DISCLAIMER: I HAVE NO IDEA HOW COMPILING WORKS I GOT IT TO WORK BY BLIND LUCK) my game immediately crashes from this error: https://pastebin.com/z3PXvSbV

I've managed to get it "working" by deleting "client.MixinWorldRenderer" in \Unicopia-beta-4\src\main\resources\unicopia.mixin.json but I doubt that counts as an actual fix.

Sorry if I'm bothersome but I do try to make sure I at least try to fix it or do something before I post an issue. Well, if I think I'll be able to figure anything out. That whole renderer thing is beyond my comprehension. My best guess is that I'm missing some sort of compile setting.

Sollace commented 3 years ago

You can now try the beta5 release and see if the inconsistency is fixed. I believe it should be better in that version.

Mixin error is also fixed. Thanks!