GithubHelp home page GithubHelp logo

Issues with Fake Players about metamorph HOT 18 CLOSED

mchorse avatar mchorse commented on May 23, 2024
Issues with Fake Players

from metamorph.

Comments (18)

mchorse avatar mchorse commented on May 23, 2024

Could you make a video of how this happens? I assume that those "fake players" are deriving from EntityPlayer, right?

from metamorph.

mchorse avatar mchorse commented on May 23, 2024

@oryfoxer7410 bump 😂

from metamorph.

Vaygrim avatar Vaygrim commented on May 23, 2024

I'm getting this exactly same issue with the mod "Woot", used for mob grinding. The Woot 'machine' only spawns ghosts of the mobs being farmed, and never any loot. End result for a Witch Farm setup, is a massive collection of Witch Ghosts accruing under the bottom of the Woot setup.

from metamorph.

Ipsis avatar Ipsis commented on May 23, 2024

Woot uses a FakePlayer, which you are correct in saying derives from EntityPlayer. So every time the FakePlayer in the mob factory kills something you will get a LivingDeathEvent for that mob death.

Might just require a check to see if the event.getSource().getEntity() is a FakePlayer and ignore the event if it is.

I do something similar with the LivingDropsEvent to identify when the source is my FakePlayer, so I can process the loot information.

(Apologies if this is all obvious @mchorse)

from metamorph.

Vaygrim avatar Vaygrim commented on May 23, 2024

Thank you very much for the info pitch-in @Ipsis 👍

from metamorph.

mchorse avatar mchorse commented on May 23, 2024

Whoa guys, hold up, so much comments here 🤠

Guys, try out this pre-release build. I changed the expression from instanceof EntityPlayer to EntityPlayerMP. This, in theory, should fix this issue. However, I'm not 100% sure about it.

@Ipsis thanks for in-depth explanation. It is very helpful. I knew some of that stuff, and there's nothing to apologize for 😃

Could you explain for what FakePlayer is used? I using it in Blockbuster mod for block interactions, but I don't know the true purpose for it.

@looogin, you may also want to try it out.

from metamorph.

Ipsis avatar Ipsis commented on May 23, 2024

FakePlayer->EntityPlayerMP->EntityPlayer

A bunch of stuff in the Minecraft code needs a valid player to be called. However there are times when you want that code to be activated, but not have a valid player. Therefore you use a FakePlayer.

In my case I want all the processing and events to be called when I fake a mob being killed. That can only be called with a valid EntityPlayer ie. with a player holding a weapon, so I have a FakePlayer holding a weapon.

from metamorph.

mchorse avatar mchorse commented on May 23, 2024

@Ipsis so you use a FakePlayer it like this?:

FakePlayer player = new FakePlayer(world, new GameProfile(null, "lol_thatsafakeplayer"))
{
    @Override
    public boolean isSpectator()
    {
        return false;
        }

    @Override
    public boolean isCreative()
    {
        return false;
    }
};

/* For example, give him a sword */
player.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, new ItemStack(Items.DIAMOND_SWORD));

/* ... */

block.onBlockActivated(world, new BlockPos(...), blockState, player, ...);

You're right, FakePlayer extends EntityPlayerMP. I updated that build link above:
https://www.dropbox.com/s/url7zrmjhdsyee8/metamorph-1.1-pre-1.10.2.jar?dl=0

Now gimme all your stars!!! 😈 (just kidding) 🤣

Edit: @Ipsis I was surprised when I found that you're the mod developer of Woot, very cool mod! 😃

from metamorph.

Ipsis avatar Ipsis commented on May 23, 2024

I like to keep a low profile, keeps the people with pitchforks away :)

You have to be careful how you create FakePlayers.
See the below link for an example of using the Forge Factory to get one.
Well, to the best of my knowledge, this is how you get one.

https://github.com/Ipsis/Woot/blob/04626bf4a611041c1bc34dd24f19d2b142424164/src/main/java/ipsis/woot/util/FakePlayerPool.java

from metamorph.

mchorse avatar mchorse commented on May 23, 2024

@Ipsis hm, thanks for examples! Oh, I see that by amount of issues in the repo you've got so far 😆

Why is it so dangerous to create FakePlayers manually? Memory leaks by creating never ending references between a fake player and a world?

from metamorph.

Ipsis avatar Ipsis commented on May 23, 2024

Not sure.
MinecraftForge/MinecraftForge#1705
I basically read the above bug when I was starting to look at using a FakePlayer and then just followed along with what others have done. :)

from metamorph.

mchorse avatar mchorse commented on May 23, 2024

@Ipsis oh, okay, so does problem with mob grinding still persists?

from metamorph.

Ipsis avatar Ipsis commented on May 23, 2024

Ran a quick check with Woot.
Original version I was seeing Metamorph entities spawning.
metamorph-1.1-pre - no entities spawning

So I think that fixes the issue, granted it was a very quick test.

from metamorph.

oryfoxer avatar oryfoxer commented on May 23, 2024

@mchorse on pre-release build.

https://hastebin.com/apemazizix.vbs

Caused by: java.lang.NoClassDefFoundError: net/minecraft/client/entity/EntityPlayerSP

from metamorph.

mchorse avatar mchorse commented on May 23, 2024

@oryfoxer7410 ok, I think I fixed this issue. I forgot to put @SideOnly annotations on client network handlers 🤦‍♂️

The link is the same:
https://www.dropbox.com/s/url7zrmjhdsyee8/metamorph-1.1-pre-1.10.2.jar?dl=0

from metamorph.

oryfoxer avatar oryfoxer commented on May 23, 2024

@mchorse

https://hastebin.com/upogofunel.http

from metamorph.

mchorse avatar mchorse commented on May 23, 2024

@oryfoxer7410 thanks! Now, I checked the server, it doesn't crash, but I have no idea if it has any bugs (because it's nearly impossible to test server build due to the low performance of my computer).

https://www.dropbox.com/s/url7zrmjhdsyee8/metamorph-1.1-pre-1.10.2.jar?dl=0

from metamorph.

mchorse avatar mchorse commented on May 23, 2024

I guess this is fixed. I'm closing down this issue. Thanks to everyone for reporting and participation! 😄 👍

from metamorph.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.