Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues with Fake Players #9

Closed
oryfoxer opened this issue Jan 4, 2017 · 18 comments
Closed

Issues with Fake Players #9

oryfoxer opened this issue Jan 4, 2017 · 18 comments
Labels

Comments

@oryfoxer
Copy link

oryfoxer commented Jan 4, 2017

Having issues with Draconic Evolution (grinder) - metamorph will spawn ghosts for fake players, is there a way to bypass this? It ends up breaking the machines.

@mchorse
Copy link
Owner

mchorse commented Jan 8, 2017

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

@mchorse
Copy link
Owner

mchorse commented Jan 10, 2017

@oryfoxer7410 bump 😂

@Vaygrim
Copy link

Vaygrim commented Jan 14, 2017

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.

@Ipsis
Copy link

Ipsis commented Jan 14, 2017

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)

@Vaygrim
Copy link

Vaygrim commented Jan 14, 2017

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

@mchorse
Copy link
Owner

mchorse commented Jan 14, 2017

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.

@Ipsis
Copy link

Ipsis commented Jan 14, 2017

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.

@mchorse
Copy link
Owner

mchorse commented Jan 14, 2017

@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! 😃

@Ipsis
Copy link

Ipsis commented Jan 14, 2017

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

@mchorse
Copy link
Owner

mchorse commented Jan 14, 2017

@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?

@Ipsis
Copy link

Ipsis commented Jan 14, 2017

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. :)

@mchorse
Copy link
Owner

mchorse commented Jan 14, 2017

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

@Ipsis
Copy link

Ipsis commented Jan 15, 2017

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.

@oryfoxer
Copy link
Author

@mchorse on pre-release build.

https://hastebin.com/apemazizix.vbs

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

@mchorse
Copy link
Owner

mchorse commented Jan 18, 2017

@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

@oryfoxer
Copy link
Author

@mchorse
Copy link
Owner

mchorse commented Jan 19, 2017

@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

@mchorse
Copy link
Owner

mchorse commented Jan 31, 2017

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants