Jump to content

[1.10.2]Keybinds only work inside workspace


Alexthe666

Recommended Posts

Hello. I have an event that tells me if certain keys are down. They work as intended in the workspace, but for some reason, outside of the workspace, isKeyDown() is never true.

 

my event code:

 

 

@SubscribeEvent
public void handleClientTick(ClientTickEvent event) {
	if (Minecraft.getMinecraft().inGameHasFocus && Minecraft.getMinecraft().thePlayer != null) {
	 Minecraft.getMinecraft().thePlayer.worldObj.spawnParticle(EnumParticleTypes.SWEEP_ATTACK, Minecraft.getMinecraft().thePlayer.posX, Minecraft.getMinecraft().thePlayer.posY + 2, Minecraft.getMinecraft().thePlayer.posZ, 0, 0, 0, new int[0]);
	}
	if (checkIfPlayer()) {
		 Minecraft.getMinecraft().thePlayer.worldObj.spawnParticle(EnumParticleTypes.CLOUD, Minecraft.getMinecraft().thePlayer.posX, Minecraft.getMinecraft().thePlayer.posY + 2, Minecraft.getMinecraft().thePlayer.posZ, 0, 0, 0, new int[0]);
		Entity dragon = Minecraft.getMinecraft().thePlayer.getRidingEntity();
		if (Minecraft.getMinecraft().gameSettings.keyBindJump.isKeyDown()) {
			IceAndFire.NETWORK_WRAPPER.sendToServer(new MessageDragonKeys(dragon.getEntityId(), 0));
		}
		if (Minecraft.getMinecraft().gameSettings.keyBindSneak.isKeyDown()) {
			 Minecraft.getMinecraft().thePlayer.worldObj.spawnParticle(EnumParticleTypes.FIREWORKS_SPARK, Minecraft.getMinecraft().thePlayer.posX, Minecraft.getMinecraft().thePlayer.posY + 2, Minecraft.getMinecraft().thePlayer.posZ, 0, 0, 0, new int[0]);
			IceAndFire.NETWORK_WRAPPER.sendToServer(new MessageDragonKeys(dragon.getEntityId(), 1));
		}
		if (ModKeys.dragon_fireAttack.isKeyDown()) {
			IceAndFire.NETWORK_WRAPPER.sendToServer(new MessageDragonKeys(dragon.getEntityId(), 2));
		}
		if (ModKeys.dragon_strike.isKeyDown()) {
			IceAndFire.NETWORK_WRAPPER.sendToServer(new MessageDragonKeys(dragon.getEntityId(), 3));
		}
		if (ModKeys.dragon_dismount.isKeyDown()) {
			IceAndFire.NETWORK_WRAPPER.sendToServer(new MessageDragonKeys(dragon.getEntityId(), 4));
		}
	}
}

public boolean checkIfPlayer() {
	if (Minecraft.getMinecraft().inGameHasFocus && Minecraft.getMinecraft().thePlayer != null) {
		return Minecraft.getMinecraft().thePlayer.ticksExisted % 2 == 0 && Minecraft.getMinecraft().thePlayer.worldObj.isRemote && Minecraft.getMinecraft().thePlayer.getRidingEntity() != null && Minecraft.getMinecraft().thePlayer.getRidingEntity() instanceof EntityDragonBase;
	} else {
		return false;
	}
}

 

 

 

The farthest particle that spawns is the CLOUD, meaning that the event is working but the keys are not working.

Link to comment
Share on other sites

1st of all - THIS!

 

public void handleClientTick(ClientTickEvent event)
{
Minecraft mc = Minecraft.getMinecraft();
EntityPlayer player = mc.thePlayer;
if (mc.inGameHasFocus && player != null)
{
	 player.worldObj.spawnParticle(EnumParticleTypes.SWEEP_ATTACK, player.posX, player.posY + 2, player.posZ, 0, 0, 0, new int[0]);

	 if (ticksExisted % 2 == 0 && player.getRidingEntity() instanceof EntityDragonBase)
	 {
	 	Entity dragon = player.getRidingEntity();

		player.worldObj.spawnParticle(EnumParticleTypes.CLOUD, player.posX, player.posY + 2, player.posZ, 0, 0, 0, new int[0]);

		if (mc.gameSettings.keyBindJump.isKeyDown())
		{
			IceAndFire.NETWORK_WRAPPER.sendToServer(new MessageDragonKeys(dragon.getEntityId(), 0));
		}
		if (mc.gameSettings.keyBindSneak.isKeyDown())
		{
			player.worldObj.spawnParticle(EnumParticleTypes.FIREWORKS_SPARK, player.posX, player.posY + 2, player.posZ, 0, 0, 0, new int[0]);
			IceAndFire.NETWORK_WRAPPER.sendToServer(new MessageDragonKeys(dragon.getEntityId(), 1));
		}
		if (ModKeys.dragon_fireAttack.isKeyDown())
		{
			IceAndFire.NETWORK_WRAPPER.sendToServer(new MessageDragonKeys(dragon.getEntityId(), 2));
		}
		if (ModKeys.dragon_strike.isKeyDown())
		{
			IceAndFire.NETWORK_WRAPPER.sendToServer(new MessageDragonKeys(dragon.getEntityId(), 3));
		}
		if (ModKeys.dragon_dismount.isKeyDown())
		{
			IceAndFire.NETWORK_WRAPPER.sendToServer(new MessageDragonKeys(dragon.getEntityId(), 4));
		}
	}
}
}

 

FASTER. CLEANER. BETTER.

 

2nd: Server alredy knows about sneak key being pressed (boolean in EntityPlayer I think, like #isSneaking()).

I think server also knows about space but idk, probably. :P

 

As to 3 others - they don't work meaning if statement doesn't pass or what?

1.7.10 is no longer supported by forge, you are on your own.

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.