Skip to content

Commit

Permalink
Merge branch '1.3.2-forge' into 1.4-forge
Browse files Browse the repository at this point in the history
# Conflicts:
#	build.gradle
#	src/main/java/cpw/mods/fml/relauncher/FMLRelauncher.java
#	src/main/java/fr/catcore/fabricatedforge/mixin/forgefml/nbt/Client_NbtIoMixin.java
  • Loading branch information
thecatcore committed Sep 3, 2024
2 parents 5e9eb4c + c48f96c commit cadc9d4
Show file tree
Hide file tree
Showing 15 changed files with 288 additions and 72 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Fabricated Forge
# Fabricated Legacy Forge

Load Forge/ModLoader mods as if they were Fabric Loader mods.

Supported Minecraft versions: 1.3.2, 1.4.0, 1.4.1, 1.4.2, 1.4.3, 1.4.4 and 1.4.5.
Supported Minecraft versions: 1.3.2, 1.4.0, 1.4.1, 1.4.2, 1.4.3, 1.4.4, 1.4.5, 1.4.6 and 1.4.7.

This mod requires [Mod-Remapping-API](https://modrinth.com/mod/mod-remapping-api).

Expand Down Expand Up @@ -39,6 +39,6 @@ This mod requires [Mod-Remapping-API](https://modrinth.com/mod/mod-remapping-api
### ClassLoaderFixer
- ThexXTURBOXx

### Fabricated Forge itself
### Fabricated Legacy Forge itself
- CatCore (aka. arthurbambou)
- Contributors
13 changes: 2 additions & 11 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -173,17 +173,8 @@ modrinth {
projectId = "JpHZ1Cyv" // This can be the project ID or the slug. Either will work!
versionName = displayVersion
changelog = """
# Changelog
Fix fabric mods icon in Forge mod list.\\
# 2.7.0 Changelog
Update MRAPI to 1.22.0.\\
Make use of MRAPI v1 api.\\
Fix most reflection related crashes.\\
Improve compatibility with coremods by a lot.\\
Fix NEI plugins not loading.\\
Fix crashes related to a badly ported patch.\\
Fix some class loading before coremods were discovered, preventing them from being modified by ClassTransformers.\\
Cleaned up existing compatibility patches after mentioned improvements and fixes.
Ensure Forge always loads before Minecraft classes.
Fix crash on server.
"""
uploadFile = remapJar
gameVersions = [project.minecraft_version] // Must be an array, even with only one version
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ org.gradle.jvmargs=-Xmx2G
spasm_version=0.2

# Mod Properties
mod_version = 2.7.1
mod_version = 2.7.2
maven_group = fr.catcore
archives_base_name = fabricated-forge
48 changes: 40 additions & 8 deletions src/main/java/cpw/mods/fml/relauncher/FMLRelauncher.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ public static void handleServerRelaunch(ArgsWrapper wrap) {
instance().relaunchServer(wrap);
}

public static void handleServerPreLaunch() {
logFileNamePattern = "ForgeModLoader-server-%g.log";
side = "SERVER";
instance().preLaunchCommon(false);
}

static FMLRelauncher instance() {
if (INSTANCE == null) {
INSTANCE = new FMLRelauncher();
Expand Down Expand Up @@ -85,7 +91,7 @@ private void relaunchClient(ArgsWrapper wrap) {

Class<? super Object> client;
try {
File minecraftHome = this.computeExistingClientHome();
File minecraftHome = this.computeExistingGameDir();
this.setupHome(minecraftHome);
client = this.setupNewClientHome(minecraftHome);
} finally {
Expand Down Expand Up @@ -115,9 +121,9 @@ private Class<? super Object> setupNewClientHome(File minecraftHome) {
}

private void relaunchServer(ArgsWrapper wrap) {
this.showWindow(false);
File minecraftHome = new File(".");
this.setupHome(minecraftHome);
// this.showWindow(false);
// File minecraftHome = new File(".");
// this.setupHome(minecraftHome);
Class<? super Object> server = ReflectionHelper.getClass(this.classLoader, "net.minecraft.server.MinecraftServer");

try {
Expand Down Expand Up @@ -165,7 +171,7 @@ private void setupHome(File minecraftHome) {
}
}

private File computeExistingClientHome() {
private File computeExistingGameDir() {
return FabricLoader.getInstance().getGameDir().toFile();
}

Expand All @@ -175,6 +181,31 @@ public static void appletEntry(Applet minecraftApplet) {
instance().relaunchApplet(minecraftApplet);
}

public static void preLaunchClientEntry() {
side = "CLIENT";
logFileNamePattern = "ForgeModLoader-client-%g.log";
instance().preLaunchClient();
}

public File preLaunchCommon(boolean showWindow) {
this.showWindow(showWindow);

File mcDir = this.computeExistingGameDir();
this.setupHome(mcDir);

return mcDir;
}

public void preLaunchClient() {
File mcDir = preLaunchCommon(true);
this.setupNewClientHome(mcDir);

if (this.popupWindow != null) {
this.popupWindow.setVisible(false);
this.popupWindow.dispose();
}
}

private void relaunchApplet(Applet minecraftApplet) {
this.showWindow(true);
this.appletClass = ReflectionHelper.getClass(this.classLoader, "net.minecraft.client.MinecraftApplet");
Expand All @@ -197,9 +228,10 @@ private void relaunchApplet(Applet minecraftApplet) {
throw new RuntimeException(var11);
}
} else {
File mcDir = this.computeExistingClientHome();
this.setupHome(mcDir);
this.setupNewClientHome(mcDir);
System.out.println(minecraftApplet.getClass().getClassLoader().getClass().getName());
// File mcDir = this.computeExistingClientHome();
// this.setupHome(mcDir);
// this.setupNewClientHome(mcDir);
Class<? super Object> parentAppletClass = ReflectionHelper.getClass(this.getClass().getClassLoader(), "java.applet.Applet");

try {
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/fr/catcore/fabricatedforge/FabricatedForge.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package fr.catcore.fabricatedforge;

import cpw.mods.fml.relauncher.FMLRelauncher;
import net.fabricmc.api.EnvType;
import net.fabricmc.loader.api.FabricLoader;
import net.fabricmc.loader.api.entrypoint.PreLaunchEntrypoint;

public class FabricatedForge implements PreLaunchEntrypoint {
@Override
public void onPreLaunch() {
if (FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT) FMLRelauncher.preLaunchClientEntry();
else FMLRelauncher.handleServerPreLaunch();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,13 @@ public static boolean isSolid(int id) {
@Shadow @Final public static Block NETHER_BRICK_FENCE;
@Shadow @Final public static Block GLASS_BLOCK;

@Environment(EnvType.CLIENT)
@Shadow public abstract int method_479();

@Environment(EnvType.CLIENT)
@Shadow public abstract int method_407(World world, int i, int j, int k);

@Environment(EnvType.CLIENT)
@Shadow public abstract int method_463(World world, int i, int j, int k);

@Shadow @Final public static Block CACTUS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import fr.catcore.fabricatedforge.mixininterface.IBlock;
import fr.catcore.fabricatedforge.mixininterface.IItem;
import fr.catcore.fabricatedforge.mixininterface.IServerPlayerInteractionManager;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
Expand Down Expand Up @@ -32,8 +34,10 @@ public abstract class ItemMixin implements ItemProxy, IItem {

@Shadow public abstract boolean isDamageable();

@Environment(EnvType.CLIENT)
@Shadow public abstract int method_3378(ItemStack itemStack);

@Environment(EnvType.CLIENT)
@Shadow public abstract boolean method_3397();

@Shadow public abstract boolean isFood();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public abstract class ItemGroupMixin implements IItemGroup {

@Shadow @Final private int index;

@Environment(EnvType.CLIENT)
@Shadow public abstract Item method_3320();

@Inject(method = "<init>", at = @At(value = "FIELD", opcode = Opcodes.PUTFIELD, target = "Lnet/minecraft/item/itemgroup/ItemGroup;index:I"))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package fr.catcore.fabricatedforge.mixin.forgefml.nbt;

import fr.catcore.cursedmixinextensions.annotations.Public;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtIo;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;

import java.io.*;

@Environment(EnvType.SERVER)
@Mixin(NbtIo.class)
public abstract class Server_NbtIoMixin {

@Shadow
public static void method_1345(NbtCompound nbtCompound, DataOutput dataOutput) {
}

@Shadow
public static NbtCompound read(DataInput input) {
return null;
}

/**
* @author Minecraft Forge
* @reason none
*/
@Public
private static void method_1352(NbtCompound par0NBTTagCompound, File par1File) throws IOException {
DataOutputStream var2 = new DataOutputStream(new FileOutputStream(par1File));

try {
method_1345(par0NBTTagCompound, var2);
} finally {
var2.close();
}

}

/**
* @author Minecraft Forge
* @reason none
*/
@Public
private static NbtCompound method_1349(File par0File) throws IOException {
if (!par0File.exists()) {
return null;
} else {
DataInputStream var1 = new DataInputStream(new FileInputStream(par0File));

NbtCompound var2;
try {
var2 = read(var1);
} finally {
var1.close();
}

return var2;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package fr.catcore.fabricatedforge.mixin.forgefml.util;

import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.util.Language;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;

@Environment(EnvType.SERVER)
@Mixin(Language.class)
public class Server_LanguageMixin {
@Shadow
public String code;

public String method_636() {
return this.code;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package fr.catcore.fabricatedforge.mixin.forgefml.world;

import fr.catcore.fabricatedforge.mixininterface.IBlock;
import fr.catcore.fabricatedforge.mixininterface.IWorld;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.block.Block;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.dimension.Dimension;
import net.minecraftforge.common.ForgeDirection;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;

@Environment(EnvType.CLIENT)
@Mixin(World.class)
public abstract class Client_WorldMixin implements IWorld {

@Shadow @Final public Dimension dimension;

@Shadow public abstract int getBlock(int x, int y, int z);

/**
* @author Minecraft Forge
* @reason none
*/
@Overwrite
public Biome getBiome(int par1, int par2) {
return this.dimension.getBiomeGenForCoords(par1, par2);
}

/**
* @author Minecraft Forge
* @reason none
*/
@Overwrite
public boolean isAir(int par1, int par2, int par3) {
int id = this.getBlock(par1, par2, par3);
return id == 0 || Block.BLOCKS[id] == null || ((IBlock)Block.BLOCKS[id]).isAirBlock((World)(Object) this, par1, par2, par3);
}

/**
* @author Minecraft Forge
* @reason none
*/
@Overwrite
public boolean isBlockSolid(int par1, int par2, int par3) {
Block block = Block.BLOCKS[this.getBlock(par1, par2, par3)];
return block != null && ((IBlock)block).isBlockNormalCube((World)(Object) this, par1, par2, par3);
}

/**
* @author Minecraft Forge
* @reason none
*/
@Overwrite
public boolean isTopSolid(int par1, int par2, int par3) {
return this.isBlockSolidOnSide(par1, par2, par3, ForgeDirection.UP);
}

/**
* @author Minecraft Forge
* @reason none
*/
@Overwrite
public int getMaxBuildHeight() {
return this.dimension.getHeight();
}
}
Loading

0 comments on commit cadc9d4

Please sign in to comment.