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
6 changed files
with
102 additions
and
0 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
src/main/java/com/denizenscript/clientizen/access/LivingEntityMixinAccess.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,8 @@ | ||
package com.denizenscript.clientizen.access; | ||
|
||
public interface LivingEntityMixinAccess { | ||
|
||
double clientizen$getClimbingSpeed(); | ||
|
||
void clientizen$setClimbingSpeed(double climbingSpeed); | ||
} |
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
25 changes: 25 additions & 0 deletions
25
src/main/java/com/denizenscript/clientizen/mixin/ClientPlayerEntityMixin.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,25 @@ | ||
package com.denizenscript.clientizen.mixin; | ||
|
||
import com.denizenscript.clientizen.access.LivingEntityMixinAccess; | ||
import net.minecraft.client.MinecraftClient; | ||
import net.minecraft.client.network.ClientPlayNetworkHandler; | ||
import net.minecraft.client.network.ClientPlayerEntity; | ||
import net.minecraft.client.recipebook.ClientRecipeBook; | ||
import net.minecraft.client.world.ClientWorld; | ||
import net.minecraft.stat.StatHandler; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
@Mixin(ClientPlayerEntity.class) | ||
public abstract class ClientPlayerEntityMixin { | ||
|
||
// TODO: proper persistence system | ||
@Inject(method = "<init>", at = @At("TAIL")) | ||
private void clientizen$persistClimbingSpeed(MinecraftClient client, ClientWorld world, ClientPlayNetworkHandler networkHandler, StatHandler stats, ClientRecipeBook recipeBook, boolean lastSneaking, boolean lastSprinting, CallbackInfo ci) { | ||
if (client.player != null) { | ||
((LivingEntityMixinAccess) this).clientizen$setClimbingSpeed(((LivingEntityMixinAccess) client.player).clientizen$getClimbingSpeed()); | ||
} | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
src/main/java/com/denizenscript/clientizen/mixin/LivingEntityMixin.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,32 @@ | ||
package com.denizenscript.clientizen.mixin; | ||
|
||
import com.denizenscript.clientizen.access.LivingEntityMixinAccess; | ||
import net.minecraft.entity.LivingEntity; | ||
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.ModifyArg; | ||
|
||
@Mixin(LivingEntity.class) | ||
public abstract class LivingEntityMixin implements LivingEntityMixinAccess { | ||
|
||
double clientizen$climbingSpeed = 0.2; // Vanilla default | ||
|
||
@Override | ||
public double clientizen$getClimbingSpeed() { | ||
return clientizen$climbingSpeed; | ||
} | ||
|
||
@Override | ||
public void clientizen$setClimbingSpeed(double climbingSpeed) { | ||
clientizen$climbingSpeed = climbingSpeed; | ||
} | ||
|
||
@Shadow | ||
public abstract boolean isClimbing(); | ||
|
||
@ModifyArg(method = "applyMovementInput", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/Vec3d;<init>(DDD)V"), index = 1) | ||
private double clientizen$modifyClimbingSpeed(double y) { | ||
return isClimbing() ? clientizen$climbingSpeed : y; | ||
} | ||
} |
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