Skip to content

Commit

Permalink
Implement Coyote Time Jumping tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
ACGaming committed Nov 2, 2024
1 parent 73cfbd5 commit d59c583
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ All changes are toggleable via config files.
* **Connection Timeouts:** Allows configuring read/login timeouts
* Helps slow clients log into a server of a large modpack
* **Copy World Seed:** Enables clicking of `/seed` world seed in chat to copy to clipboard
* **Coyote Time Jumping:** Lets the player jump a couple frames after stepping off a ledge, similar to jumping in many platformers
* **Crafting Cache:** Adds an IRecipe cache to improve recipe performance in large modpacks
* **Creeper Confetti:** Replaces deadly creeper explosions with delightful confetti (with a configurable chance)
* **Critical Arrow Damage:** Sets the additional damage that critical arrows deal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,10 @@ public static class EntitiesCategory
@Config.Comment("Lets zombies burn in daylight")
public boolean utBurningZombiesToggle = true;

@Config.Name("Coyote Time Jumping")
@Config.Comment("Lets the player jump a couple frames after stepping off a ledge, similar to jumping in many platformers")
public boolean utCoyoteTimeJumpingToggle = false;

@Config.Name("Creeper Charged Spawning Chance")
@Config.Comment("Sets the chance for creepers to spawn charged")
@Config.RangeDouble(min = 0.0D, max = 1.0D)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package mod.acgaming.universaltweaks.tweaks.entities.jumping.coyotetime;

import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
import net.minecraftforge.fml.relauncher.Side;

import mod.acgaming.universaltweaks.UniversalTweaks;
import mod.acgaming.universaltweaks.config.UTConfigGeneral;
import mod.acgaming.universaltweaks.config.UTConfigTweaks;

// Courtesy of sparkflo
@Mod.EventBusSubscriber(modid = UniversalTweaks.MODID, value = Side.CLIENT)
public class UTCoyoteTimeJumping
{
private static boolean jumped = false;

@SubscribeEvent
public static void utCoyoteTimeJumping(TickEvent.PlayerTickEvent event)
{
if (!UTConfigTweaks.ENTITIES.utCoyoteTimeJumpingToggle) return;
if (UTConfigGeneral.DEBUG.utDebugToggle) UniversalTweaks.LOGGER.debug("UTCoyoteTimeJumping ::: Player tick event");
EntityPlayerSP player = Minecraft.getMinecraft().player;
if (event.phase != TickEvent.Phase.START || player == null) return;
UTCoyoteTimeJumping.attemptJump(player);
}

private static void attemptJump(EntityPlayerSP player)
{
if (player.onGround) jumped = false;
if (player.motionY > 0.1) jumped = true;
if (jumped || player.isOnLadder() || player.isInWater() || player.isInLava() || player.world.collidesWithAnyBlock(player.getEntityBoundingBox().expand(0, -0.001, 0))) return;
if (player.motionY < 0.1 && player.movementInput.jump && player.fallDistance < 1 && !player.isElytraFlying())
{
jumped = true;
player.jump();
}
}
}

0 comments on commit d59c583

Please sign in to comment.