-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: kurrycat <[email protected]>
- Loading branch information
1 parent
0e4421f
commit 7fb8cde
Showing
10 changed files
with
161 additions
and
36 deletions.
There are no files selected for viewing
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
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
5 changes: 5 additions & 0 deletions
5
src/main/java/com/gtnewhorizons/angelica/zoom/IMouseFilterExt.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,5 @@ | ||
package com.gtnewhorizons.angelica.zoom; | ||
|
||
public interface IMouseFilterExt { | ||
void angelica$reset(); | ||
} |
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,53 @@ | ||
package com.gtnewhorizons.angelica.zoom; | ||
|
||
import cpw.mods.fml.client.registry.ClientRegistry; | ||
import cpw.mods.fml.common.FMLCommonHandler; | ||
import cpw.mods.fml.common.eventhandler.SubscribeEvent; | ||
import cpw.mods.fml.common.gameevent.InputEvent; | ||
import lombok.Getter; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.settings.KeyBinding; | ||
import net.minecraft.util.MathHelper; | ||
import org.lwjgl.input.Keyboard; | ||
|
||
public class Zoom { | ||
|
||
@Getter | ||
private static float zoom = 4.0F; | ||
@Getter | ||
private static final KeyBinding zoomKey = new KeyBinding("Zoom", 0, "key.categories.misc"); | ||
|
||
public static final float ZOOM_MIN = 1.0F; | ||
public static final float ZOOM_MAX = 64.0F; | ||
public static final float ZOOM_STEP = 1.2F; | ||
|
||
private static boolean lastSmoothCameraState = false; | ||
|
||
public static void init() { | ||
ClientRegistry.registerKeyBinding(zoomKey); | ||
FMLCommonHandler.instance().bus().register(new Zoom()); | ||
} | ||
|
||
public static void modifyZoom(int eventDWheel) { | ||
if (eventDWheel == 0) return; | ||
zoom = MathHelper.clamp_float((float) (zoom * Math.pow(ZOOM_STEP, Integer.signum(eventDWheel))), ZOOM_MIN, ZOOM_MAX); | ||
} | ||
|
||
@SubscribeEvent | ||
public void onKeyPress(InputEvent.KeyInputEvent e) { | ||
final int keyCode = zoomKey.getKeyCode(); | ||
if (keyCode == 0 || Keyboard.getEventKey() != keyCode || Keyboard.isRepeatEvent()) return; | ||
final Minecraft mc = Minecraft.getMinecraft(); | ||
if (Keyboard.getEventKeyState()) { | ||
lastSmoothCameraState = mc.gameSettings.smoothCamera; | ||
mc.gameSettings.smoothCamera = true; | ||
} else { | ||
zoom = 4.0F; | ||
if (mc.gameSettings.smoothCamera != lastSmoothCameraState) { | ||
((IMouseFilterExt) mc.entityRenderer.mouseFilterXAxis).angelica$reset(); | ||
((IMouseFilterExt) mc.entityRenderer.mouseFilterYAxis).angelica$reset(); | ||
} | ||
mc.gameSettings.smoothCamera = lastSmoothCameraState; | ||
} | ||
} | ||
} |
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
30 changes: 30 additions & 0 deletions
30
.../java/com/gtnewhorizons/angelica/mixins/early/angelica/zoom/MixinEntityRenderer_Zoom.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,30 @@ | ||
package com.gtnewhorizons.angelica.mixins.early.angelica.zoom; | ||
|
||
import com.gtnewhorizons.angelica.zoom.Zoom; | ||
import com.llamalad7.mixinextras.injector.ModifyReturnValue; | ||
import net.minecraft.client.renderer.EntityRenderer; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Constant; | ||
import org.spongepowered.asm.mixin.injection.ModifyConstant; | ||
|
||
@Mixin(EntityRenderer.class) | ||
public class MixinEntityRenderer_Zoom { | ||
|
||
@ModifyReturnValue(method = "getFOVModifier", at = @At("RETURN")) | ||
private float angelica$modifyFOV(float original) { | ||
if (Zoom.getZoomKey().getIsKeyPressed()) { | ||
return original / Zoom.getZoom(); | ||
} | ||
return original; | ||
} | ||
|
||
@ModifyConstant(method = "updateCameraAndRender", constant = @Constant(floatValue = 8.0F)) | ||
private float angelica$modifyMouseSensitivity(float original) { | ||
if (Zoom.getZoomKey().getIsKeyPressed()) { | ||
return original / (1.0F + 0.2F * (Zoom.getZoom() - Zoom.ZOOM_MIN)); | ||
} | ||
return original; | ||
} | ||
|
||
} |
21 changes: 21 additions & 0 deletions
21
...mixin/java/com/gtnewhorizons/angelica/mixins/early/angelica/zoom/MixinMinecraft_Zoom.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,21 @@ | ||
package com.gtnewhorizons.angelica.mixins.early.angelica.zoom; | ||
|
||
import com.gtnewhorizons.angelica.zoom.Zoom; | ||
import com.llamalad7.mixinextras.injector.ModifyExpressionValue; | ||
import net.minecraft.client.Minecraft; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
|
||
@Mixin(Minecraft.class) | ||
public class MixinMinecraft_Zoom { | ||
|
||
@ModifyExpressionValue(method = "runTick", at = @At(value = "INVOKE", target = "Lorg/lwjgl/input/Mouse;getEventDWheel()I", remap = false)) | ||
private int angelica$captureMouseWheel(int original) { | ||
if (Zoom.getZoomKey().getIsKeyPressed()) { | ||
Zoom.modifyZoom(original); | ||
return 0; | ||
} | ||
return original; | ||
} | ||
|
||
} |
26 changes: 26 additions & 0 deletions
26
src/mixin/java/com/gtnewhorizons/angelica/mixins/early/angelica/zoom/MixinMouseFilter.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,26 @@ | ||
package com.gtnewhorizons.angelica.mixins.early.angelica.zoom; | ||
|
||
import com.gtnewhorizons.angelica.zoom.IMouseFilterExt; | ||
import net.minecraft.util.MouseFilter; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
|
||
@Mixin(MouseFilter.class) | ||
public class MixinMouseFilter implements IMouseFilterExt { | ||
|
||
@Shadow | ||
private float field_76336_a; | ||
|
||
@Shadow | ||
private float field_76334_b; | ||
|
||
@Shadow | ||
private float field_76335_c; | ||
|
||
@Override | ||
public void angelica$reset() { | ||
this.field_76336_a = 0.0F; | ||
this.field_76334_b = 0.0F; | ||
this.field_76335_c = 0.0F; | ||
} | ||
} |