From 30995c0cc36e2d747237760420a9f6e0c31d0cd7 Mon Sep 17 00:00:00 2001 From: TheBrokenRail Date: Fri, 27 Mar 2020 14:31:47 -0400 Subject: [PATCH] 1.0.7 Fix Speed When Giant Fix Third-Person View Fix Inventory View --- CHANGELOG.md | 5 +++ gradle.properties | 2 +- .../gulliverreloaded/mixin/MixinCamera.java | 29 ++++++++++++++++++ .../MixinClientPlayerInteractionManager.java | 2 ++ .../mixin/MixinInventoryScreen.java | 24 +++++++++++++++ .../mixin/MixinLivingEntity.java | 8 +++-- .../textures/mob_effect/shrink.png | Bin 307 -> 342 bytes .../resources/gulliver-reloaded.mixins.json | 6 ++-- 8 files changed, 71 insertions(+), 5 deletions(-) create mode 100644 src/main/java/com/thebrokenrail/gulliverreloaded/mixin/MixinCamera.java create mode 100644 src/main/java/com/thebrokenrail/gulliverreloaded/mixin/MixinInventoryScreen.java diff --git a/CHANGELOG.md b/CHANGELOG.md index 389464d..cbc8f30 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +**1.0.7** +* Fix Speed When Giant +* Fix Third-Person View +* Fix Inventory View + **1.0.6** * Fix Gradle Script * Automatically Adjust Shadow Size diff --git a/gradle.properties b/gradle.properties index 8d641d5..d528e09 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,7 +10,7 @@ org.gradle.jvmargs = -Xmx1G fabric_loader_version = 0.7.8+build.189 # Mod Properties - mod_version = 1.0.6 + mod_version = 1.0.7 maven_group = com.thebrokenrail archives_base_name = gulliver-reloaded diff --git a/src/main/java/com/thebrokenrail/gulliverreloaded/mixin/MixinCamera.java b/src/main/java/com/thebrokenrail/gulliverreloaded/mixin/MixinCamera.java new file mode 100644 index 0000000..4f096c4 --- /dev/null +++ b/src/main/java/com/thebrokenrail/gulliverreloaded/mixin/MixinCamera.java @@ -0,0 +1,29 @@ +package com.thebrokenrail.gulliverreloaded.mixin; + +import com.thebrokenrail.gulliverreloaded.ScaledEntity; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.minecraft.client.render.Camera; +import net.minecraft.entity.Entity; +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.Redirect; + +@SuppressWarnings("unused") +@Environment(EnvType.CLIENT) +@Mixin(Camera.class) +public abstract class MixinCamera { + @Shadow + private Entity focusedEntity; + @Shadow + protected abstract double clipToSpace(double distance); + @Shadow + protected abstract void moveBy(double x, double y, double z); + + @Redirect(method = "update", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/Camera;clipToSpace(D)D")) + public double onUpdateClipToSpaceProxy(Camera obj, double distance) { + float scale = focusedEntity instanceof ScaledEntity ? ((ScaledEntity) focusedEntity).getScale() : 1f; + return clipToSpace(distance * scale); + } +} \ No newline at end of file diff --git a/src/main/java/com/thebrokenrail/gulliverreloaded/mixin/MixinClientPlayerInteractionManager.java b/src/main/java/com/thebrokenrail/gulliverreloaded/mixin/MixinClientPlayerInteractionManager.java index 219e8b3..1850c54 100644 --- a/src/main/java/com/thebrokenrail/gulliverreloaded/mixin/MixinClientPlayerInteractionManager.java +++ b/src/main/java/com/thebrokenrail/gulliverreloaded/mixin/MixinClientPlayerInteractionManager.java @@ -4,6 +4,8 @@ import com.thebrokenrail.gulliverreloaded.ScaledEntity; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.screen.ingame.CreativeInventoryScreen; +import net.minecraft.client.gui.screen.ingame.InventoryScreen; import net.minecraft.client.network.ClientPlayerInteractionManager; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; diff --git a/src/main/java/com/thebrokenrail/gulliverreloaded/mixin/MixinInventoryScreen.java b/src/main/java/com/thebrokenrail/gulliverreloaded/mixin/MixinInventoryScreen.java new file mode 100644 index 0000000..2a99d61 --- /dev/null +++ b/src/main/java/com/thebrokenrail/gulliverreloaded/mixin/MixinInventoryScreen.java @@ -0,0 +1,24 @@ +package com.thebrokenrail.gulliverreloaded.mixin; + +import com.thebrokenrail.gulliverreloaded.ScaledEntity; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.minecraft.client.gui.screen.ingame.InventoryScreen; +import net.minecraft.entity.LivingEntity; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.ModifyVariable; + +@SuppressWarnings("unused") +@Environment(EnvType.CLIENT) +@Mixin(InventoryScreen.class) +public class MixinInventoryScreen { + @ModifyVariable(at = @At("HEAD"), method = "drawEntity", argsOnly = true, index = 2) + private static int adjustEntitySize(int initial, int x, int y, int size, float mouseX, float mouseY, LivingEntity entity) { + if (entity instanceof ScaledEntity) { + return (int) (initial / ((ScaledEntity) entity).getScale()); + } else { + return initial; + } + } +} diff --git a/src/main/java/com/thebrokenrail/gulliverreloaded/mixin/MixinLivingEntity.java b/src/main/java/com/thebrokenrail/gulliverreloaded/mixin/MixinLivingEntity.java index 53b9f1a..02555cf 100644 --- a/src/main/java/com/thebrokenrail/gulliverreloaded/mixin/MixinLivingEntity.java +++ b/src/main/java/com/thebrokenrail/gulliverreloaded/mixin/MixinLivingEntity.java @@ -16,6 +16,7 @@ import net.minecraft.entity.effect.StatusEffect; import net.minecraft.entity.effect.StatusEffectInstance; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @@ -27,13 +28,16 @@ import java.util.UUID; @SuppressWarnings("unused") @Mixin(LivingEntity.class) public abstract class MixinLivingEntity implements ScaledEntity { + @Unique private static final UUID SCALED_SPEED_ID = UUID.fromString("c5267238-6a78-4257-ae83-a2a5e34c1128"); + @Unique private static final TrackedData SCALE = DataTracker.registerData(LivingEntity.class, TrackedDataHandlerRegistry.FLOAT); @Shadow public abstract Map getActiveStatusEffects(); - @Shadow public abstract EntityAttributeInstance getAttributeInstance(EntityAttribute attribute); + @Shadow + public abstract EntityAttributeInstance getAttributeInstance(EntityAttribute attribute); @Override public float getScale() { @@ -92,7 +96,7 @@ public abstract class MixinLivingEntity implements ScaledEntity { 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)); + speedAttribute.addModifier((new EntityAttributeModifier(SCALED_SPEED_ID, "Scaled speed multiplier", Math.pow(getScale(), 0.4) - 1, EntityAttributeModifier.Operation.MULTIPLY_TOTAL)).setSerialize(false)); } @Inject(at = @At("RETURN"), method = "initDataTracker") diff --git a/src/main/resources/assets/gulliver-reloaded/textures/mob_effect/shrink.png b/src/main/resources/assets/gulliver-reloaded/textures/mob_effect/shrink.png index 1fb23d164ec804f2443cfd44e361a832130a7a3a..c08128fb8e6e0a18426b6c9b182ec646e4e7c203 100644 GIT binary patch delta 295 zcmV+?0oeYt0@ebMIDY{MNklqG;Fj_)_bO? z?F0e~?nD-iEM?}{H5@!6*$Fd85r{CFq)EAU)|lQZV#;9;B{xT;eh9@?Iz2OQzDe^Z+8>eb^iP8u;@7!> t=&BaH`E!yR$Y4F6*hgI!=zKJ{IF0i97%U*QisTVdJeNpLIUL8Yi zS8UA912Y0Vg%$T(LH=w-{=c-s`S3HM7Zu60EV^&_-+kB+^a2I?t!Gm^Bx(Qv002ov JPDHLkV1n@Vcb@