First working version

This commit is contained in:
Almtesh committed 2026-11-29 05:24:03 +01:00
1 parent b5e0a91a26
commit cfd814d4a0
2 files changed
+34 -8

No files matched your search

+2 -2
View File
@@ -1,7 +1,7 @@
# Done to increase the memory available to gradle. # Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx1G org.gradle.jvmargs=-Xmx1G
org.gradle.parallel=true org.gradle.parallel=true
org.gradle.configuration-cache=true org.gradle.configuration-cache=false
# Fabric Properties # Fabric Properties
# check these on https://fabricmc.net/develop # check these on https://fabricmc.net/develop
@@ -10,7 +10,7 @@ loader_version=0.20.1
loom_version=1.19-SNAPSHOT loom_version=1.19-SNAPSHOT
# Mod Properties # Mod Properties
version=1.0.0 version=26.3.0
group=net.almtesh.stickyparrots group=net.almtesh.stickyparrots
# Dependencies # Dependencies
@@ -1,15 +1,41 @@
package net.almtesh.stickyparrots.mixin; 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.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(MinecraftServer.class) @Mixin(ServerPlayer.class)
public class ParrotMixin { public abstract class ParrotMixin {
@Inject(at = @At("HEAD"), method = "loadLevel") @Shadow
private void init(CallbackInfo info) { private long timeEntitySatOnShoulder;
// This code is injected into the start of MinecraftServer.loadLevel()V
@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;
} }
} }