Jump to content

[1.9][SOLVED]Entity's processInteract triggered twice


horsewithnoname

Recommended Posts

Hello guys!

 

I have encountered really weird behavior of processInteract: in forge's development environment processInteract method is triggered twice for some reason, while in regular minecraft version with forge installed sometimes it's either triggered twice or only once.

 

There's the all related code for processInteract:

 

/* Package and imports */

public class ActorEntity extends EntityCreature implements IEntityAdditionalSpawnData
{
    /**
     * Nasty workaround for processInteract double trigger.
     */
    private int tick = 0;

    /**
     * Process interact
     *
     * Inject UUID of actor to registering device, open GUI for changing
     * actor's skin, or start recording him
     */
    @Override
    protected boolean processInteract(EntityPlayer player, EnumHand p_184645_2_, ItemStack stack)
    {
        ItemStack item = player.getHeldItemMainhand();

        System.out.println(item + " " + this.worldObj.isRemote);

        if (item != null && (this.handleRegisterItem(item) || this.handleSkinItem(item, player)))
        {}
        else
        {
            if (this.tick-- > 0)
            {
                return false;
            }

            if (!this.worldObj.isRemote)
                this.startRecording(player);

            this.tick = 1;
        }

        return false;
    }

    /**
     * Set actor's id on register item (while using register item on this
     * actor)
     */
    private boolean handleRegisterItem(ItemStack stack)
    {
        if (this.worldObj.isRemote || !(stack.getItem() instanceof RegisterItem))
        {
            return false;
        }

        RegisterItem item = (RegisterItem) stack.getItem();

        item.registerStack(stack, this);

        return true;
    }

    /**
     * Open skin choosing GUI by using skin managing item
     */
    private boolean handleSkinItem(ItemStack stack, EntityPlayer player)
    {
        if (!this.worldObj.isRemote || !(stack.getItem() instanceof SkinManagerItem))
        {
            return false;
        }

        player.openGui(Blockbuster.instance, 1, this.worldObj, this.getEntityId(), 0, 0);

        return true;
    }
}

 

And the log:

 

10:29:12] [server thread/INFO]: player joined the game

[10:29:15] [server thread/INFO]: Saving and pausing game...

[10:29:15] [server thread/INFO]: Saving chunks for level 'New World'/Overworld

[10:29:16] [Thread-8/INFO]: [CHAT] §2AnimalBikes§f installed. For more info §9§nClick here

[10:29:16] [server thread/INFO]: Saving chunks for level 'New World'/Nether

[10:29:16] [server thread/INFO]: Saving chunks for level 'New World'/The End

[10:29:16] [server thread/WARN]: Can't keep up! Did the system time change, or is the server overloaded? Running 4431ms behind, skipping 88 tick(s)

[10:29:17] [pool-2-thread-1/WARN]: Couldn't look up profile properties for com.mojang.authlib.GameProfile@35986b1d[id=02a2b6ef-1d92-373a-92fd-153f3b082aa4,name=player,properties={},legacy=false]

com.mojang.authlib.exceptions.AuthenticationException: The client has sent too many requests within a certain amount of time

at com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService.makeRequest(YggdrasilAuthenticationService.java:65) ~[YggdrasilAuthenticationService.class:?]

at com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService.fillGameProfile(YggdrasilMinecraftSessionService.java:175) [YggdrasilMinecraftSessionService.class:?]

at com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService$1.load(YggdrasilMinecraftSessionService.java:59) [YggdrasilMinecraftSessionService$1.class:?]

at com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService$1.load(YggdrasilMinecraftSessionService.java:56) [YggdrasilMinecraftSessionService$1.class:?]

at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3524) [guava-17.0.jar:?]

at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2317) [guava-17.0.jar:?]

at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2280) [guava-17.0.jar:?]

at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2195) [guava-17.0.jar:?]

at com.google.common.cache.LocalCache.get(LocalCache.java:3934) [guava-17.0.jar:?]

at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3938) [guava-17.0.jar:?]

at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4821) [guava-17.0.jar:?]

at com.google.common.cache.LocalCache$LocalLoadingCache.getUnchecked(LocalCache.java:4827) [guava-17.0.jar:?]

at com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService.fillProfileProperties(YggdrasilMinecraftSessionService.java:165) [YggdrasilMinecraftSessionService.class:?]

at net.minecraft.client.Minecraft.getProfileProperties(Minecraft.java:3038) [Minecraft.class:?]

at net.minecraft.client.resources.SkinManager$3.run(SkinManager.java:130) [skinManager$3.class:?]

at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_91]

at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_91]

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [?:1.8.0_91]

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [?:1.8.0_91]

at java.lang.Thread.run(Thread.java:745) [?:1.8.0_91]

[10:29:23] [Client thread/INFO] [sTDOUT]: [noname.blockbuster.entity.ActorEntity:processInteract:348]: null true

[10:29:23] [Client thread/INFO] [sTDOUT]: [noname.blockbuster.entity.ActorEntity:processInteract:348]: null true

[10:29:23] [server thread/INFO] [sTDOUT]: [noname.blockbuster.entity.ActorEntity:processInteract:348]: null false

[10:29:23] [server thread/INFO] [sTDOUT]: [noname.blockbuster.entity.ActorEntity:processInteract:348]: null false

[10:29:23] [Client thread/INFO]: [CHAT] Started recording §rplayer§r to file Shia

[10:29:28] [Client thread/INFO] [sTDOUT]: [noname.blockbuster.entity.ActorEntity:processInteract:348]: null true

[10:29:28] [Client thread/INFO] [sTDOUT]: [noname.blockbuster.entity.ActorEntity:processInteract:348]: null true

[10:29:28] [server thread/INFO] [sTDOUT]: [noname.blockbuster.entity.ActorEntity:processInteract:348]: null false

[10:29:28] [server thread/INFO] [sTDOUT]: [noname.blockbuster.entity.ActorEntity:processInteract:348]: null false

[10:29:28] [Record Thread/INFO] [sTDOUT]: [noname.blockbuster.recording.RecordThread:run:90]: Exiting record thread.

[10:29:28] [Client thread/INFO]: [CHAT] Stopped recording §rplayer§r to file Shia

[10:29:29] [server thread/INFO]: Saving and pausing game...

[10:29:29] [server thread/INFO]: Saving chunks for level 'New World'/Overworld

[10:29:29] [server thread/INFO]: Saving chunks for level 'New World'/Nether

[10:29:29] [server thread/INFO]: Saving chunks for level 'New World'/The End

 

 

Look for the STDOUT, it's triggered twice on client and server. I don't understand why it's being triggered twice. If it's triggered once when playing on regular minecraft version, players will have to right click entities twice, which is annoying, and that happens sometimes.

 

Does somebody know how to solve this problem?

 

Thank you for attention!

Blockbuster – simple machinimas and cinematics for Minecraft
Link to comment
Share on other sites

The method is called once for each hand. Return

true

to prevent the other hand from being processed (e.g. when the player is holding the appropriate item).

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.