Issues with Fake Players
oryfoxer opened this issue ยท 18 comments
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.
Could you make a video of how this happens? I assume that those "fake players" are deriving from EntityPlayer, right?
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)
Thank you very much for the info pitch-in @Ipsis ๐
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.
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.
@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! ๐
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.
@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 FakePlayer
s manually? Memory leaks by creating never ending references between a fake player and a world?
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. :)
@Ipsis oh, okay, so does problem with mob grinding still persists?
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.
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.
@mchorse on pre-release build.
https://hastebin.com/apemazizix.vbs
Caused by: java.lang.NoClassDefFoundError: net/minecraft/client/entity/EntityPlayerSP
@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
@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