generated from LCLPYT/fabric-mod-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
62 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
kibu-hooks/src/main/java/work/lclpnet/kibu/hook/player/PlayerJumpCallback.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package work.lclpnet.kibu.hook.player; | ||
|
||
import net.minecraft.server.network.ServerPlayerEntity; | ||
import work.lclpnet.kibu.hook.Hook; | ||
import work.lclpnet.kibu.hook.HookFactory; | ||
|
||
public interface PlayerJumpCallback { | ||
|
||
Hook<PlayerJumpCallback> HOOK = HookFactory.createArrayBacked(PlayerJumpCallback.class, callbacks -> (player) -> { | ||
boolean cancel = false; | ||
|
||
for (var cb : callbacks) { | ||
if (cb.onJump(player)) { | ||
cancel = true; | ||
} | ||
} | ||
|
||
return cancel; | ||
}); | ||
|
||
boolean onJump(ServerPlayerEntity player); | ||
} |
18 changes: 18 additions & 0 deletions
18
kibu-hooks/src/main/java/work/lclpnet/kibu/hook/util/OnGroundDetector.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package work.lclpnet.kibu.hook.util; | ||
|
||
import net.minecraft.server.network.ServerPlayerEntity; | ||
import net.minecraft.util.math.Box; | ||
|
||
public class OnGroundDetector { | ||
|
||
public static boolean isOnGroundServer(ServerPlayerEntity player) { | ||
return isOnGroundServer(player, 0.02); | ||
} | ||
|
||
public static boolean isOnGroundServer(ServerPlayerEntity player, double tol) { | ||
double y = player.getY(); | ||
Box box = player.getBoundingBox().withMinY(y - tol).withMaxY(y + 1e-5); | ||
|
||
return player.getWorld().getBlockCollisions(player, box).iterator().hasNext(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters