Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/1.4.6-forge' into 1.4.7-forge
Browse files Browse the repository at this point in the history
# Conflicts:
#	build.gradle
#	src/main/resources/fabricated-forge.forge.mixins.json
  • Loading branch information
thecatcore committed Sep 6, 2024
2 parents e2182a1 + b01aedf commit 2e37b31
Show file tree
Hide file tree
Showing 15 changed files with 228 additions and 93 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
34 changes: 3 additions & 31 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -175,37 +175,9 @@ 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.\\
You can now interact again with the second slot of any inventory.\\
Fix immibis core crash.\\
Fix TreeCapitator crash.
# 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.
# 2.6.2 Changelog
Update MRAPI to 1.20.0.\\
Fix crash on Fabric Loader 0.15+.\\
CodeChickenCore and NEI are finally working on 1.4.6 and 1.4.7.
# 2.6.1 Changelog
Update MRAPI to 1.15.0.\\
ClassTransformers now run after mixins are applied on a class instead of before, improving compatibility with ClassTransformers by a lot.\\
Some more improvements on NEI Compatibility.\\
# 2.6.0 Changelog
Update to MRAPI 1.14.2.\\
Fix more compatibility issues with CodeChickenCore and NEI.\\
NEI plugins still do not work for now.
# 2.5.0 Changelog
Update to Mod-Remapping-API 1.8.0.\\
ClassTransformers are now applied!!\\
Meaning Coremods are more likely to work.\\
Implement special fixes to get CodeChickenCore and NEI working.
Ensure Forge always loads before Minecraft classes.
Fix crash on server.
Fix compatibility with forge servers.
"""
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 @@ -44,6 +44,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 @@ -86,7 +92,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 @@ -116,9 +122,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, new String[]{"net.minecraft.server.MinecraftServer"});

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

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

Expand All @@ -179,6 +185,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 @@ -201,9 +232,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(), new String[]{"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 @@ -79,10 +79,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 @@ -5,6 +5,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 @@ -36,14 +38,17 @@ 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();

@Shadow public abstract Item getRecipeRemainder();

@Environment(EnvType.CLIENT)
@Shadow public abstract ItemGroup getItemGroup();

@Shadow public abstract int method_3369(int i, int j);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,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
Expand Up @@ -4,6 +4,7 @@
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.ArgsWrapper;
import cpw.mods.fml.relauncher.FMLRelauncher;
import fr.catcore.cursedmixinextensions.annotations.Public;
import fr.catcore.fabricatedforge.mixininterface.IMinecraftServer;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
Expand Down Expand Up @@ -478,7 +479,8 @@ public static void main(String[] par0ArrayOfStr) {
}

@Environment(EnvType.SERVER)
protected static void fmlReentry(ArgsWrapper wrap) {
@Public
private static void fmlReentry(ArgsWrapper wrap) {
String[] par0ArrayOfStr = wrap.args;
Stats.method_2269();

Expand Down
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();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
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.BlockView;
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.SERVER)
@Mixin(World.class)
public abstract class Server_WorldMixin implements BlockView, IWorld {
@Shadow @Final public Dimension dimension;

@Override
public Biome getBiome(int par1, int par2) {
return this.dimension.getBiomeGenForCoords(par1, par2);
}

@Override
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
*/
@Override
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
*/
@Override
public boolean isTopSolid(int par1, int par2, int par3) {
return this.isBlockSolidOnSide(par1, par2, par3, ForgeDirection.UP);
}

@Override
public int getMaxBuildHeight() {
return this.dimension.getHeight();
}
}
Loading

0 comments on commit 2e37b31

Please sign in to comment.