First working version
This commit is contained in:
1 parent
b5e0a91a26
commit
cfd814d4a0
2 files changed
+34
-8
No files matched your search
+2
-2
@@ -1,7 +1,7 @@
|
||||
# Done to increase the memory available to gradle.
|
||||
org.gradle.jvmargs=-Xmx1G
|
||||
org.gradle.parallel=true
|
||||
org.gradle.configuration-cache=true
|
||||
org.gradle.configuration-cache=false
|
||||
|
||||
# Fabric Properties
|
||||
# check these on https://fabricmc.net/develop
|
||||
@@ -10,7 +10,7 @@ loader_version=0.20.1
|
||||
loom_version=1.19-SNAPSHOT
|
||||
|
||||
# Mod Properties
|
||||
version=1.0.0
|
||||
version=26.3.0
|
||||
group=net.almtesh.stickyparrots
|
||||
|
||||
# Dependencies
|
||||
|
||||
@@ -1,15 +1,41 @@
|
||||
package net.almtesh.stickyparrots.mixin;
|
||||
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(MinecraftServer.class)
|
||||
public class ParrotMixin {
|
||||
@Inject(at = @At("HEAD"), method = "loadLevel")
|
||||
private void init(CallbackInfo info) {
|
||||
// This code is injected into the start of MinecraftServer.loadLevel()V
|
||||
@Mixin(ServerPlayer.class)
|
||||
public abstract class ParrotMixin {
|
||||
@Shadow
|
||||
private long timeEntitySatOnShoulder;
|
||||
|
||||
@Inject (
|
||||
method = "removeEntitiesOnShoulder",
|
||||
at = @At ("HEAD"),
|
||||
cancellable = true
|
||||
)
|
||||
private void stickyparrots$filterShoulderRelease (CallbackInfo ci) {
|
||||
ServerPlayer player = (ServerPlayer) (Object) this;
|
||||
|
||||
boolean allowed =
|
||||
player.isUnderWater ()
|
||||
|| player.isInPowderSnow
|
||||
|| player.isSleeping ()
|
||||
|| player.isDeadOrDying ()
|
||||
|| player.isSpectator ()
|
||||
|| (!player.onGround ()
|
||||
&& player.isCrouching ()
|
||||
&& player.fallDistance > 0.75F);
|
||||
|
||||
if (!allowed) {
|
||||
ci.cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
// Skip the 20 ticks delay to parrot release
|
||||
this.timeEntitySatOnShoulder = player.level ().getGameTime () - 21L;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user