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

fixed horizontal mode #28

Open
wants to merge 5 commits into
base: 2.x
Choose a base branch
from
Open

fixed horizontal mode #28

wants to merge 5 commits into from

Conversation

Tofugrass
Copy link
Contributor

can I test this build as soon as possible and get back to you?
I think this implementation of horizontal mode is better than easy elytra.

swapping now checks config
added jump to horizontal mode. if it works like this then it should be perfect.
made math easier to update
from my testing, I believe this would be the best implementation of horizontal mode
i had accidentally removed the wrong part of the ternary operator, switching it back. should be good to go now.
@Szum123321
Copy link
Owner

Szum123321 commented Sep 9, 2020

But... That's basically what it was before...

The main point of our disagreement was that I wasn't multiplying y component the speed update vector by the sine of player's pitch.

Also are you decreasing player's launch speed in horizontal mode? I found that you should rather increase it to be useful.

@Tofugrass
Copy link
Contributor Author

yes after a lot of testing i agree with you on the initial launch angle being fine.

and the low velocity shouldnt matter because we are engaging the wings immediately, but it is still configurable so i can test it,

@Tofugrass
Copy link
Contributor Author

Tofugrass commented Sep 9, 2020

having the wings being automatically engaged for the player in horizontal mode is a huge change already and would make it act drastically different from vertical mode

@Szum123321
Copy link
Owner

Actually, in that can I don't think we need horizontal mode at all, as automatically inserting elytra would be just a better solution.

I think I'm going to close this pr, remove few las commits and add the insertion think then.

Is that okay with you?

@Tofugrass
Copy link
Contributor Author

wait, before u undo everything, could at least just add the jump to horizontal mode, and send me a test build. i think itll be perfect. u dont have to change anything else.

@Tofugrass
Copy link
Contributor Author

imagine ur in a small house and u want to fly out of the window. it wouldnt be possible with only vertical mode, because u would smash ur head on the ceiling every time. with horizontal mode, u can fly straight out of the window easily.

i think horizontal mode adds a lot of value to the mod.

@Tofugrass
Copy link
Contributor Author

and the reason why i preserved your launch angle, is because it is immediately overwritten when we do the jump. so its not that ur original launch angle was perfect, its moreso the fact that it immediately gets overwritten by vanilla mechanics.

and i dont understand what you mean by automatically inserting elytra. i am wearing elytra at all times, i just want to takeoff with right click without smashing the spacebar.

@Tofugrass
Copy link
Contributor Author

ur mod makes it super easy to modify redstone contraptions, because ur mod allows the player to fit into one high spaces without jumping, but only in horizontal mode. ur mod is sick bro but it need horizontal mode.

@Szum123321
Copy link
Owner

Sorry, but I don't have much time left today. We'll have to continue tomorrow.

@Tofugrass
Copy link
Contributor Author

i dont see why u want to revert it. you made horizontal mode disabled by default so all you did was add additional functionality. having additional functionality is good.

@Tofugrass
Copy link
Contributor Author

the way the mod works, after the player uses the firework, the player has to jump to takeoff. since the player pretty much has to jump every time, I changed horizontal mode to automatic jump mode in this pull request, (or automatic takeoff mode). it even keeps the same launch angle as vertical mode, all it does is add a jump. im sure many of ur users would find it extremely useful, since the players currently have to jump manually everytime.

plus its already done, you just have to rebuild.

having the player jump by themselves is fine in most situations, but in order to give the player enough time to jump on high ping, you have to set the kickSpeed to a fairly large number (>1,2).

setting the kickspeed to accommodate high ping causes issues

  1. player can not takeoff with a roof above them (they hit their head and land instantly, giving no time to jump)
  2. player can not fly through a 1x1 hole they are looking at (because they fly up first, so then they are above the hole)
  3. player travels farther than they would (because of the kickspeed)

i already fixed these issues in this pull request in automatic jump mode. i set the kickspeed to a lower value, and added the automatic jump. by having the automatic jump, the wings engage instantly, so we can have a very low velocity, just enough to get the player of the ground for the jump to engage flight.

i think having automatic jump mode would be great. dont u already jump after every firework?

@Szum123321
Copy link
Owner

Ok, so I spent some time on the TakeoffHandler and here's what I came up with:

public static void sendUpdate(World world, PlayerEntity player, Hand hand) {
		if(!ElytraSwap.CONFIG.horizontalMode.getState() && !checkSpaceOverPlayer(player, ElytraSwap.CONFIG.requiredHeightAbovePlayer))
			return;

			ServerSidePacketRegistry.INSTANCE.sendToPlayer(player,
					new EntityVelocityUpdateS2CPacket(player.getEntityId(),
							new Vec3d(-Math.sin(Math.toRadians(player.yaw)) * ElytraSwap.CONFIG.kickSpeed,
									ElytraSwap.CONFIG.kickSpeed * (ElytraSwap.CONFIG.horizontalMode.getState() ? -Math.sin(Math.toRadians(player.pitch)) : 1),
									Math.cos(Math.toRadians(player.yaw)) * ElytraSwap.CONFIG.kickSpeed
							)
					)
			);

		world.spawnEntity(new FireworkRocketEntity(world, player.getStackInHand(hand), player));

		if(ElytraSwap.CONFIG.horizontalMode.getState()) {
			if(ElytraSwap.CONFIG.globalSwapEnable.getState()) {
				InventoryHelper.replaceChestplateWithElytra(new FlatInventory(player));
				player.startFallFlying();
			}

			player.jump();
		}
	}

Form my test I seem like decreasing kick speed would give player too litle velcity to successfully takeoff

@Tofugrass
Copy link
Contributor Author

Tofugrass commented Sep 15, 2020

Another way to fix the issue besides increasing velocity is to have a pause before the jump.

For testing purposes it would be nice to have it be configurable, but for main release we should pick the best one from testing.

I think you need to add this https://www.javatpoint.com/sleep()-method.

From my testing with a mouse macro, the takeoff works well with 110 ms.

@Tofugrass
Copy link
Contributor Author

thats also why I made the launch angle vertical again, so the player has an easier time taking off.

@Tofugrass
Copy link
Contributor Author

I merged this branch with your 2.x master and then added the sleep method.
Can I get an updated testing build please?

@Szum123321
Copy link
Owner

Using sleep is a horrible idea. Remember that all of this will run on main server thread. Pausing it would dramatically decrease TPS count

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

Successfully merging this pull request may close these issues.

2 participants