Metamorph

Metamorph

4M Downloads

Issues with Fake Players

oryfoxer opened this issue ยท 18 comments

commented

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.

commented

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

commented

@oryfoxer7410 bump ๐Ÿ˜‚

commented

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)

commented

Thank you very much for the info pitch-in @Ipsis ๐Ÿ‘

commented

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.

commented

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.

commented

@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! ๐Ÿ˜ƒ

commented

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

commented

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

commented

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

commented

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

commented

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.

commented

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.

commented

@mchorse on pre-release build.

https://hastebin.com/apemazizix.vbs

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

commented

@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

commented

@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

commented

I guess this is fixed. I'm closing down this issue. Thanks to everyone for reporting and participation! ๐Ÿ˜„ ๐Ÿ‘