diff --git a/README.md b/README.md index 6dab3d98..551e3b6e 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/src/main/java/mod/acgaming/universaltweaks/config/UTConfigTweaks.java b/src/main/java/mod/acgaming/universaltweaks/config/UTConfigTweaks.java index d7d8be44..8a5a64a5 100644 --- a/src/main/java/mod/acgaming/universaltweaks/config/UTConfigTweaks.java +++ b/src/main/java/mod/acgaming/universaltweaks/config/UTConfigTweaks.java @@ -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) diff --git a/src/main/java/mod/acgaming/universaltweaks/tweaks/entities/jumping/coyotetime/UTCoyoteTimeJumping.java b/src/main/java/mod/acgaming/universaltweaks/tweaks/entities/jumping/coyotetime/UTCoyoteTimeJumping.java new file mode 100644 index 00000000..fd1ef4d9 --- /dev/null +++ b/src/main/java/mod/acgaming/universaltweaks/tweaks/entities/jumping/coyotetime/UTCoyoteTimeJumping.java @@ -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(); + } + } +} \ No newline at end of file