Topic category: User side tutorials
Since using the Speed-up Potion to implement the zoom function is simpler,
I would appreciate it if you watch this tutorial just for fun. :)
The completed version looks like this.
Step1. I will create keybindings.
Step2. Zoom-in procedure.
The trigger below is temporarily added and will be removed later in the code.
Step3. Zoom-out procedure.
Step4. Zoom-in procedure Code.
import net.minecraft.client.Minecraft; //add
import net.minecraft.world.entity.player.Player; //add
import net.minecraft.client.Options; //add
public class ZoomInProcedure {
public static void execute(Entity entity) {
if (entity == null)
return;
if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getItem() == TestModItems.SNIPER.get()) {
entity.setTicksFrozen(0); //delete code
Player player = Minecraft.getInstance().player; //add
Minecraft.getInstance().options.fov().set(30); //add
The maximum zoom value is 30~110. Values higher than this will not work.
Step5. Zoom-out procedure Code.
import net.minecraft.client.Minecraft; //add
import net.minecraft.world.entity.player.Player; //add
import net.minecraft.client.Options; //add
public class ZoomOutProcedure {
public static void execute() {
Player player = Minecraft.getInstance().player; //add
if (player != null) { //add
Minecraft.getInstance().options.fov().set(70); //add
It’s complete.