Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented zoom functionality #721

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/main/java/com/gtnewhorizons/angelica/mixins/Mixins.java
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,13 @@ public enum Mixins {
.addMixinClasses("mcpatcherforge.ctm_cc.MixinTextureMap")
),
//End from NotFine

//SkidZoom
SKIDZOOM(new Builder("zoom zoom")
Copy link
Member

@Alexdoru Alexdoru Nov 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove all the word "skid" that you put everywhere, it means "stealing code" and that is not appropriate

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sorry I just seen all these. I'm not super familiar with the way that pull requests work and stuff so I missed all of these my apologies. And as for the word skid, its a copy pasta implementation of a mod I made for myself a while ago that was also called SkidZoom so I apologize for not seeing these messages, that is all. I will turn on notifications for any potential future pull requests.

.setSide(Side.CLIENT).setPhase(Phase.LATE)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if it's vanilla it should be Phase.EARLY

.addTargetedMod(TargetedMod.VANILLA)
.addMixinClasses("client.skidzoom.InventoryPlayerMixin")
),
//End SkidZoom
QPR(new Builder("Adds a QuadProvider field to blocks without populating it")
.setSide(Side.CLIENT)
.setPhase(Phase.EARLY)
Expand Down
55 changes: 55 additions & 0 deletions src/main/java/net/loudcats/wyatt/skidzoom/SkidZoom.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package net.loudcats.wyatt.skidzoom;

import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import net.minecraft.client.settings.KeyBinding;
import net.minecraftforge.client.event.FOVUpdateEvent;
import net.minecraftforge.common.MinecraftForge;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;

@Mod(modid = "skidzoom", name = "SkidZoom", version = "1.0")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please don't create another mod, just hook it up to angelica

public class SkidZoom {

public KeyBinding zoomKey;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't need to be public

private static boolean zoom;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is one field static and not the 2 others

private int zoomamt = -7;

@Mod.EventHandler
public void init(FMLInitializationEvent event) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only register stuff on the client

MinecraftForge.EVENT_BUS.register(this);
zoomKey = new KeyBinding("key.skidzoom", Keyboard.KEY_C, "key.categories.misc");
zoom = false;
ClientRegistry.registerKeyBinding(zoomKey);
}

@SubscribeEvent
public void ZoomyZoomZoom(FOVUpdateEvent e) {
if (zoomKey.getIsKeyPressed() || zoomKey.isPressed()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't use isPressed(), only use getIsKeyPressed()

zoom = true;
if (zoom) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

zoom = true followed by if(zoom) is this thing made by chat GPT ? and then you make us review it ?

// Adjust zoom level with mouse wheel while holding zoom key
int dWheel = Mouse.getDWheel();
if (dWheel != 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This entire if can be replaced with zoomamt -= Integer.signum(dWheel);

if (dWheel > 0) {
zoomamt--; // decrease fov when scrolling up
} else {
zoomamt++; // increase fov when scrolling down
}
}

// Apply the shit
e.newfov = (float) (e.fov * (1.0 + zoomamt * 0.1));
}
} else {
zoom = false;
zoomamt = -7;
}
}

public static boolean isZooming() {
return zoom;
}
}
1 change: 1 addition & 0 deletions src/main/resources/assets/angelica/lang/en_US.lang
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
options.button.shader=Shaders...

key.skidzoom=Zoom
options.chunks=%s chunks
options.entityShadows=Entity Shadows
options.droppedItems=%s items
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/angelica/lang/pl_PL.lang
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jfc

proper one would be "Przybliżenie"

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
options.button.shader=Shadery...

key.skidzoom=Brzęczenie
options.chunks=%s chunków
options.entityShadows=Cienie bytów
sodium.option_impact.low=Niski
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/angelica/lang/ru_RU.lang
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
options.button.shader=Шейдеры...

key.skidzoom=Увеличить
options.chunks=%s чанков
options.entityShadows=Тени сущностей
sodium.option_impact.low=Низкий
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/angelica/lang/zh_CN.lang
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
options.button.shader=光影包……

key.skidzoom=飛漲
options.chunks=%s 区块
options.entityShadows=实体阴影
sodium.option_impact.low=低
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.gtnewhorizons.angelica.mixins.late.client.skidzoom;

import net.loudcats.wyatt.skidzoom.SkidZoom;
import net.minecraft.entity.player.InventoryPlayer;
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(InventoryPlayer.class)
public abstract class InventoryPlayerMixin {
@Inject(method = "changeCurrentItem", at = @At("HEAD"), cancellable = true)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer that you wrap the int i = Mouse.getEventDWheel(); line in the Minecraft.runTick() method and make it return 0 when it's zooming

public void changeCurrentItem(int direction, CallbackInfo ci) {
if(SkidZoom.isZooming()) {
ci.cancel();
}
}
}
Loading