Tweak Jumping Speed and Movement Speed
This commit is contained in:
parent
caf78d54ba
commit
6ebf8e9c2f
@ -1,5 +1,8 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
**1.0.5**
|
||||||
|
* Tweak Jumping Speed and Movement Speed
|
||||||
|
|
||||||
**1.0.4**
|
**1.0.4**
|
||||||
* Scale Fall Damage and Reach Distance By Size
|
* Scale Fall Damage and Reach Distance By Size
|
||||||
* Namespace Lang
|
* Namespace Lang
|
||||||
|
@ -10,7 +10,7 @@ org.gradle.jvmargs = -Xmx1G
|
|||||||
fabric_loader_version = 0.7.8+build.189
|
fabric_loader_version = 0.7.8+build.189
|
||||||
|
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
mod_version = 1.0.4
|
mod_version = 1.0.5
|
||||||
maven_group = com.thebrokenrail
|
maven_group = com.thebrokenrail
|
||||||
archives_base_name = gulliver-reloaded
|
archives_base_name = gulliver-reloaded
|
||||||
|
|
||||||
|
@ -5,6 +5,10 @@ import com.thebrokenrail.gulliverreloaded.ScaledEntity;
|
|||||||
import net.minecraft.entity.EntityDimensions;
|
import net.minecraft.entity.EntityDimensions;
|
||||||
import net.minecraft.entity.EntityPose;
|
import net.minecraft.entity.EntityPose;
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.entity.LivingEntity;
|
||||||
|
import net.minecraft.entity.attribute.EntityAttribute;
|
||||||
|
import net.minecraft.entity.attribute.EntityAttributeInstance;
|
||||||
|
import net.minecraft.entity.attribute.EntityAttributeModifier;
|
||||||
|
import net.minecraft.entity.attribute.EntityAttributes;
|
||||||
import net.minecraft.entity.data.DataTracker;
|
import net.minecraft.entity.data.DataTracker;
|
||||||
import net.minecraft.entity.data.TrackedData;
|
import net.minecraft.entity.data.TrackedData;
|
||||||
import net.minecraft.entity.data.TrackedDataHandlerRegistry;
|
import net.minecraft.entity.data.TrackedDataHandlerRegistry;
|
||||||
@ -18,15 +22,19 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
@Mixin(LivingEntity.class)
|
@Mixin(LivingEntity.class)
|
||||||
public abstract class MixinLivingEntity implements ScaledEntity {
|
public abstract class MixinLivingEntity implements ScaledEntity {
|
||||||
|
private static final UUID SCALED_SPEED_ID = UUID.fromString("c5267238-6a78-4257-ae83-a2a5e34c1128");
|
||||||
private static final TrackedData<Float> SCALE = DataTracker.registerData(LivingEntity.class, TrackedDataHandlerRegistry.FLOAT);
|
private static final TrackedData<Float> SCALE = DataTracker.registerData(LivingEntity.class, TrackedDataHandlerRegistry.FLOAT);
|
||||||
|
|
||||||
@Shadow
|
@Shadow
|
||||||
public abstract Map<StatusEffect, StatusEffectInstance> getActiveStatusEffects();
|
public abstract Map<StatusEffect, StatusEffectInstance> getActiveStatusEffects();
|
||||||
|
|
||||||
|
@Shadow public abstract EntityAttributeInstance getAttributeInstance(EntityAttribute attribute);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getScale() {
|
public float getScale() {
|
||||||
return ((LivingEntity) (Object) this).getDataTracker().get(SCALE);
|
return ((LivingEntity) (Object) this).getDataTracker().get(SCALE);
|
||||||
@ -61,12 +69,7 @@ public abstract class MixinLivingEntity implements ScaledEntity {
|
|||||||
|
|
||||||
@Inject(at = @At("RETURN"), method = "getJumpVelocity", cancellable = true)
|
@Inject(at = @At("RETURN"), method = "getJumpVelocity", cancellable = true)
|
||||||
public void getJumpVelocity(CallbackInfoReturnable<Float> info) {
|
public void getJumpVelocity(CallbackInfoReturnable<Float> info) {
|
||||||
info.setReturnValue(info.getReturnValue() * (float) Math.pow(getScale(), 0.2f));
|
info.setReturnValue(info.getReturnValue() * (float) Math.pow(getScale(), 0.4f));
|
||||||
}
|
|
||||||
|
|
||||||
@Inject(at = @At("RETURN"), method = "getMovementSpeed()F", cancellable = true)
|
|
||||||
public void getMovementSpeed(CallbackInfoReturnable<Float> info) {
|
|
||||||
info.setReturnValue(info.getReturnValue() * (float) Math.pow(getScale(), 0.2f));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(at = @At("RETURN"), method = "getEyeHeight", cancellable = true)
|
@Inject(at = @At("RETURN"), method = "getEyeHeight", cancellable = true)
|
||||||
@ -79,8 +82,17 @@ public abstract class MixinLivingEntity implements ScaledEntity {
|
|||||||
@Inject(at = @At("HEAD"), method = "tick")
|
@Inject(at = @At("HEAD"), method = "tick")
|
||||||
public void tick(CallbackInfo info) {
|
public void tick(CallbackInfo info) {
|
||||||
if (!((LivingEntity) (Object) this).getEntityWorld().isClient()) {
|
if (!((LivingEntity) (Object) this).getEntityWorld().isClient()) {
|
||||||
((LivingEntity) (Object) this).getDataTracker().set(SCALE, computeScale());
|
float scale = computeScale();
|
||||||
|
if (((LivingEntity) (Object) this).getDataTracker().get(SCALE) != scale) {
|
||||||
|
((LivingEntity) (Object) this).getDataTracker().set(SCALE, computeScale());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EntityAttributeInstance speedAttribute = getAttributeInstance(EntityAttributes.MOVEMENT_SPEED);
|
||||||
|
if (speedAttribute.getModifier(SCALED_SPEED_ID) != null) {
|
||||||
|
speedAttribute.removeModifier(SCALED_SPEED_ID);
|
||||||
|
}
|
||||||
|
speedAttribute.addModifier((new EntityAttributeModifier(SCALED_SPEED_ID, "Scaled speed multiplier", getScale() - 1, EntityAttributeModifier.Operation.MULTIPLY_TOTAL)).setSerialize(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(at = @At("RETURN"), method = "initDataTracker")
|
@Inject(at = @At("RETURN"), method = "initDataTracker")
|
||||||
|
@ -4,27 +4,14 @@ import com.thebrokenrail.gulliverreloaded.ScaledEntity;
|
|||||||
import net.minecraft.entity.EntityDimensions;
|
import net.minecraft.entity.EntityDimensions;
|
||||||
import net.minecraft.entity.EntityPose;
|
import net.minecraft.entity.EntityPose;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import org.spongepowered.asm.mixin.Final;
|
|
||||||
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.CallbackInfoReturnable;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
@Mixin(PlayerEntity.class)
|
@Mixin(PlayerEntity.class)
|
||||||
public abstract class MixinPlayerEntity {
|
public abstract class MixinPlayerEntity {
|
||||||
@Shadow
|
|
||||||
@Final
|
|
||||||
private static Map<EntityPose, EntityDimensions> POSE_DIMENSIONS;
|
|
||||||
|
|
||||||
@Inject(at = @At("RETURN"), method = "getMovementSpeed()F", cancellable = true)
|
|
||||||
public void getMovementSpeed(CallbackInfoReturnable<Float> info) {
|
|
||||||
info.setReturnValue(info.getReturnValue() * ((ScaledEntity) this).getScale());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Inject(at = @At("RETURN"), method = "getDimensions", cancellable = true)
|
@Inject(at = @At("RETURN"), method = "getDimensions", cancellable = true)
|
||||||
public void getDimensions(EntityPose pose, CallbackInfoReturnable<EntityDimensions> info) {
|
public void getDimensions(EntityPose pose, CallbackInfoReturnable<EntityDimensions> info) {
|
||||||
info.setReturnValue(((ScaledEntity) this).scaleDimensions(info.getReturnValue()));
|
info.setReturnValue(((ScaledEntity) this).scaleDimensions(info.getReturnValue()));
|
||||||
|
Reference in New Issue
Block a user