Skip to content

Commit

Permalink
updating to 1.16.2 :D (#34)
Browse files Browse the repository at this point in the history
* updating to 1.16.2 :D

* Don't include modmenu, ignore latest log

Co-authored-by: tr7zw <[email protected]>
  • Loading branch information
KosmX and tr7zw authored Aug 16, 2020
1 parent 1832671 commit 43754d6
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 30 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ bin/

# fabric

run/
run/
logs/latest.log
18 changes: 13 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,24 @@ dependencies {
modCompile "net.fabricmc:fabric-loader:${project.loader_version}"


modCompile "io.github.prospector:modmenu:${project.modmenu_version}"
modApi "me.sargunvohra.mcmods:autoconfig1u:${project.autoconfig_version}"

modApi("io.github.prospector:modmenu:${project.modmenu_version}"){
exclude(group: "net.fabricmc.fabric-api")
}

modApi("me.sargunvohra.mcmods:autoconfig1u:${project.autoconfig_version}"){
exclude(group: "net.fabricmc.fabric-api")
}
include "me.sargunvohra.mcmods:autoconfig1u:${project.autoconfig_version}"
modApi "me.shedaniel.cloth:config-2:${project.cloth_version}"
modApi("me.shedaniel.cloth:config-2:${project.cloth_version}"){
exclude(group: "net.fabricmc.fabric-api")
}
include "me.shedaniel.cloth:config-2:${project.cloth_version}"
// https://mvnrepository.com/artifact/javax.annotation/javax.annotation-api
compile group: 'javax.annotation', name: 'javax.annotation-api', version: '1.3.2'

// Fabric API. This is technically optional, but you probably want it anyway.
//modCompile "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
// Fabric API. The keybinding registry is in this.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version}"

// PSA: Some older mods, compiled on Loom 0.2.1, might have outdated Maven POMs.
// You may need to force-disable transitiveness on them.
Expand Down
12 changes: 6 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
org.gradle.jvmargs = -Xmx1G

#Fabric properties
minecraft_version = 1.16.1
yarn_mappings = 1.16.1+build.21
loader_version = 0.8.8+build.202
minecraft_version = 1.16.2
yarn_mappings = 1.16.2+build.12
loader_version = 0.9.1+build.205

#Mod properties
mod_version = 1.3.0
maven_group = de.tr7zw
archives_base_name = FirstPersonMod

#Dependencies
fabric_api_version = 0.13.1+build.370-1.16
modmenu_version = 1.12.2+build.16
fabric_api_version = 0.18.0+build.397-1.16
modmenu_version = 1.14.6+build.31
autoconfig_version = 3.2.0-unstable
cloth_version = 4.5.6
cloth_version = 4.7.0-unstable
20 changes: 10 additions & 10 deletions src/main/java/de/tr7zw/firstperson/FirstPersonModelMod.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package de.tr7zw.firstperson;

import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
import net.minecraft.client.options.KeyBinding;
import net.minecraft.client.util.math.MatrixStack;
import org.lwjgl.glfw.GLFW;

import me.sargunvohra.mcmods.autoconfig1u.AutoConfig;
import me.sargunvohra.mcmods.autoconfig1u.serializer.GsonConfigSerializer;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.client.keybinding.FabricKeyBinding;
import net.fabricmc.fabric.api.client.keybinding.KeyBindingRegistry;
import net.fabricmc.fabric.api.event.client.ClientTickCallback;
import net.minecraft.util.Identifier;

import javax.annotation.Nullable;
Expand All @@ -22,7 +22,7 @@ public class FirstPersonModelMod implements ModInitializer {
public static MatrixStack hideHeadWithMatrixStack = null;
public static boolean enabled = true;
public static FirstPersonConfig config = null;
private static FabricKeyBinding keyBinding;
private static KeyBinding keyBinding;
private static boolean isHeld = false;

public static boolean fixBodyShadow(MatrixStack matrixStack){
Expand All @@ -42,15 +42,15 @@ public void onInitialize() {
AutoConfig.register(FirstPersonConfig.class, GsonConfigSerializer::new);
config = AutoConfig.getConfigHolder(FirstPersonConfig.class).getConfig();
enabled = config.enabledByDefault;
keyBinding = FabricKeyBinding.Builder.create(
new Identifier("firstperson", "toggle"),
keyBinding = new KeyBinding(
new Identifier("firstperson", "toggle").getPath(),
net.minecraft.client.util.InputUtil.Type.KEYSYM,
GLFW.GLFW_KEY_F6,
"Firstperson"
).build();
KeyBindingRegistry.INSTANCE.addCategory("Firstperson");
KeyBindingRegistry.INSTANCE.register(keyBinding);
ClientTickCallback.EVENT.register(e ->
);
//KeyBindingRegistry.INSTANCE.addCategory("Firstperson"); It is added automatically now
KeyBindingHelper.registerKeyBinding(keyBinding);
ClientTickEvents.END_CLIENT_TICK.register(e ->
{
if(keyBinding.isPressed()) {
if(isHeld)return;
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/de/tr7zw/firstperson/StaticMixinMethods.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.AbstractClientPlayerEntity;
import net.minecraft.client.options.Perspective;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
Expand All @@ -24,7 +25,7 @@ public static Vec3d getPositionOffset(AbstractClientPlayerEntity var1, Vec3d def
double x,y,z = x = y = z = 0;
AbstractClientPlayerEntity abstractClientPlayerEntity_1;
double realYaw;
if(var1 == MinecraftClient.getInstance().player && MinecraftClient.getInstance().options.perspective == 0 && FirstPersonModelMod.isRenderingPlayer) {
if(var1 == MinecraftClient.getInstance().player && MinecraftClient.getInstance().options.getPerspective() == Perspective.FIRST_PERSON && FirstPersonModelMod.isRenderingPlayer) {
abstractClientPlayerEntity_1 = (AbstractClientPlayerEntity) var1;
realYaw = MathHelper.lerpAngleDegrees(MinecraftClient.getInstance().getTickDelta(), abstractClientPlayerEntity_1.prevYaw, abstractClientPlayerEntity_1.yaw);
FirstPersonModelMod.isRenderingPlayer = false;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package de.tr7zw.firstperson.mixins;


import net.minecraft.client.options.Perspective;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
Expand All @@ -22,7 +23,7 @@
public class FishingBobberRendererMixin {

private boolean doCorrect(){
return FirstPersonModelMod.enabled && MinecraftClient.getInstance().options.perspective <= 0;
return FirstPersonModelMod.enabled && MinecraftClient.getInstance().options.getPerspective() == Perspective.FIRST_PERSON;
}

private Vec3d offsetvec3d = Vec3d.ZERO; //to not create @Nullable
Expand Down Expand Up @@ -72,11 +73,11 @@ private Vec3d getPositionOffset(PlayerEntity var1) {
}

@Redirect(method = "render", at = @At(
value = "FIELD",
target = "Lnet/minecraft/client/options/GameOptions;perspective:I"
value = "INVOKE",
target = "Lnet/minecraft/client/options/GameOptions;getPerspective()Lnet/minecraft/client/options/Perspective;"
))
private int redirect(GameOptions gameOptions){
return (doCorrect()) ? 1 : gameOptions.perspective;
private Perspective redirect(GameOptions gameOptions){
return (doCorrect()) ? Perspective.THIRD_PERSON_BACK : gameOptions.getPerspective();
}

@Inject(method = "render", at = @At("HEAD"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public void drawEntity(int i, int j, int k, float f, float g, LivingEntity livin
livingEntity.headYaw = 180.0F + h * 40.0F - (m - q);
livingEntity.prevHeadYaw = 180.0F + h * 40.0F - (prevBodyYaw - p);
}
EntityRenderDispatcher entityRenderDispatcher = MinecraftClient.getInstance().getEntityRenderManager();
EntityRenderDispatcher entityRenderDispatcher = MinecraftClient.getInstance().getEntityRenderDispatcher();
quaternion2.conjugate();
entityRenderDispatcher.setRotation(quaternion2);
entityRenderDispatcher.setRenderShadows(false);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package de.tr7zw.firstperson.mixins;

import de.tr7zw.firstperson.StaticMixinMethods;
import net.minecraft.client.options.Perspective;
import net.minecraft.client.render.Camera;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
Expand All @@ -25,7 +26,7 @@ private void renderEntity(Entity entity_1, double double_1, double double_2, dou
if (FirstPersonModelMod.hideNextHeadArmor) FirstPersonModelMod.hideNextHeadArmor = false;
if (entity_1 == MinecraftClient.getInstance().getCameraEntity() && FirstPersonModelMod.hideHeadWithMatrixStack == matrixStack_1) FirstPersonModelMod.hideNextHeadArmor = true; //if I don't wear any armor head then another helmet will be hidden without this

if(MinecraftClient.getInstance().options.perspective != 0)return;
if(MinecraftClient.getInstance().options.getPerspective() != Perspective.FIRST_PERSON)return;
if(entity_1 instanceof AbstractClientPlayerEntity) {
if(!((PlayerEntity) entity_1).isMainPlayer())return;
FirstPersonModelMod.isRenderingPlayer = true;
Expand Down

0 comments on commit 43754d6

Please sign in to comment.