Skip to content

Commit

Permalink
Continue porting to LF. Nearly done, missing OneConfig feats
Browse files Browse the repository at this point in the history
  • Loading branch information
Deftu committed Dec 20, 2024
1 parent 1448165 commit cb82d6e
Show file tree
Hide file tree
Showing 11 changed files with 85 additions and 10 deletions.
6 changes: 4 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,13 @@ toolkitLoomHelper {
}
}

if (mcData.isForge) {
loom {
loom {
if (mcData.isLegacyForge) {
forge {
accessTransformer(rootProject.file("src/main/resources/hytils_at.cfg"))
}
} else if (mcData.isLegacyFabric) {
accessWidenerPath.set(rootProject.file("src/main/resources/hytils_aw.accesswidener"))
}
}

Expand Down
31 changes: 26 additions & 5 deletions src/main/java/org/polyfrost/hytils/forge/HytilsMixinPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,14 @@

package org.polyfrost.hytils.forge;


//#if FORGE
import net.minecraftforge.fml.common.asm.transformers.deobf.FMLDeobfuscatingRemapper;
import org.objectweb.asm.Opcodes;
import org.spongepowered.asm.lib.tree.*;
//#else
//$$ import org.objectweb.asm.tree.*;
//#endif

import org.objectweb.asm.Opcodes;
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;

Expand Down Expand Up @@ -65,7 +69,6 @@ public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {

@Override
public void acceptTargets(Set<String> myTargets, Set<String> otherTargets) {

}

@Override
Expand All @@ -74,12 +77,30 @@ public List<String> getMixins() {
}

@Override
public void preApply(String targetClassName, org.spongepowered.asm.lib.tree.ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
public void preApply(
String targetClassName,
//#if FORGE && MC <= 1.12.2
org.spongepowered.asm.lib.tree.ClassNode targetClass,
//#else
//$$ org.objectweb.asm.tree.ClassNode targetClass,
//#endif
String mixinClassName,
IMixinInfo mixinInfo
) {

}

@Override
public void postApply(String targetClassName, org.spongepowered.asm.lib.tree.ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
public void postApply(
String targetClassName,
//#if FORGE && MC <= 1.12.2
org.spongepowered.asm.lib.tree.ClassNode targetClass,
//#else
//$$ org.objectweb.asm.tree.ClassNode targetClass,
//#endif
String mixinClassName,
IMixinInfo mixinInfo
) {
if (!hasAppliedModifyName && !hasAppliedRenderHeads && targetClass != null && Objects.equals(targetClassName, "net.minecraft.client.gui.GuiPlayerTabOverlay")) {
for (MethodNode method : targetClass.methods) {
final String methodName = FMLDeobfuscatingRemapper.INSTANCE.mapMethodName(targetClass.name, method.name, method.desc);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@

package org.polyfrost.hytils.handlers.general;


import net.minecraftforge.fml.client.ExtendedServerListData;
import org.polyfrost.hytils.HytilsReborn;
import org.polyfrost.hytils.config.HytilsConfig;
import net.minecraft.client.Minecraft;
Expand Down
9 changes: 8 additions & 1 deletion src/main/java/org/polyfrost/hytils/hooks/BedModelHook.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@

package org.polyfrost.hytils.hooks;

//#if FORGE
import net.minecraft.client.resources.model.ModelRotation;
//#endif

import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.renderer.block.model.BlockPartFace;
import net.minecraft.client.renderer.block.model.BreakingFour;
Expand All @@ -32,7 +36,6 @@
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.resources.model.IBakedModel;
import net.minecraft.client.resources.model.ModelRotation;
import net.minecraft.client.resources.model.SimpleBakedModel;
import net.minecraft.init.Blocks;
import net.minecraft.util.BlockPos;
Expand Down Expand Up @@ -94,7 +97,11 @@ public static IBakedModel getBedModel(IBlockState state, BlockPos pos, IBakedMod
for (BakedQuad quad : model.getFaceQuads(facing)) {
faceQuads.get(quad.getFace().ordinal()).add(new BreakingFour(quad, particles));
}
//#if FORGE
ModelRotation rotation = ModelRotation.getModelRotation(0, facing.getHorizontalIndex() * 90 - 180);
//#else
//$$ net.minecraft.client.render.model.ModelRotation rotation = net.minecraft.client.render.model.ModelRotation.get(0, facing.getHorizontal() * 90 - 180);
//#endif
int footPadding = (bedPart == BlockBed.EnumPartType.FOOT) ? 16 : 0;
float funnyMultipler = 0.25f;
quads.add(faceBakery.makeBakedQuad(new Vector3f(0.0f, 3.0f, 0.0f), new Vector3f(16.0f, 3.0f, 16.0f), new BlockPartFace(EnumFacing.DOWN, -1, OAK, new BlockFaceUV(new float[]{0.0f, 0.0f, 16.0f, 16.0f}, 0)), Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(OAK), EnumFacing.DOWN, rotation, new BlockPartRotation(new Vector3f(8.0f, 0.0f, 8.0f), EnumFacing.Axis.Y, 0.0f, false), false, true));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

package org.polyfrost.hytils.mixin;

//#if FORGE
import net.hypixel.data.type.GameType;
import org.polyfrost.hytils.config.HytilsConfig;
import net.minecraftforge.client.GuiIngameForge;
Expand All @@ -35,3 +36,4 @@ public class GuiIngameForgeMixin_HideActionbar {
ci.cancel();
}
}
//#endif
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

package org.polyfrost.hytils.mixin;

//#if FORGE
import net.hypixel.data.type.GameType;
import org.polyfrost.hytils.config.HytilsConfig;
import net.minecraft.client.Minecraft;
Expand Down Expand Up @@ -189,3 +190,4 @@ public class GuiIngameForgeMixin_HideHotbar {
}
}
}
//#endif
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

package org.polyfrost.hytils.mixin;

//#if FORGE
import org.polyfrost.oneconfig.api.hypixel.v1.HypixelUtils;
import org.polyfrost.hytils.HytilsReborn;
import org.polyfrost.hytils.events.TitleEvent;
Expand Down Expand Up @@ -57,3 +58,4 @@ public GuiIngameForgeMixin_TitleEvent(Minecraft mcIn) {
}
}
}
//#endif
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@

@Mixin(value = VertexLighterFlat.class, remap = false)
public class VertexLighterFlatMixin {

@Shadow
@Final
protected BlockInfo blockInfo;
Expand Down Expand Up @@ -69,4 +70,5 @@ public class VertexLighterFlatMixin {
return false;
}
}

}
6 changes: 6 additions & 0 deletions src/main/java/org/polyfrost/hytils/util/WaypointUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@

package org.polyfrost.hytils.util;

//#if FABRIC
//$$ import net.minecraft.util.math.BlockPos;
//$$ import net.minecraft.util.math.Box;
//$$ import net.minecraft.util.math.MathHelper;
//#endif

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.GlStateManager;
Expand Down
30 changes: 30 additions & 0 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"schemaVersion": 1,
"id": "${mod_id}",
"version": "${mod_version}",
"name": "${mod_name}",
"authors": [
"Polyfrost"
],
"contact": {
"issues": "https://github.com/Polyfrost/${mod_name}/issues",
"sources": "https://github.com/Polyfrost/${mod_name}"
},
"license": "GPL-3.0-or-later",
"environment": "*",
"entrypoints": {
"client": [
{
"adapter": "kotlin",
"value": "org.polyfrost.hytils.HytilsReborn"
}
]
},
"mixins": [
"mixins.${mod_id}.json"
],
"depends": {
"fabricloader": ">=0.15.11",
"fabric-language-kotlin": "*"
}
}
3 changes: 3 additions & 0 deletions src/main/resources/hytils_aw.accesswidener
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessWidener v2 named

accessible class net/minecraft/client/render/block/BlockModelRenderer$AmbientOcclusionCalculator

0 comments on commit cb82d6e

Please sign in to comment.