Skip to content

Commit

Permalink
Fix crash on server
Browse files Browse the repository at this point in the history
  • Loading branch information
thecatcore committed Sep 3, 2024
1 parent 87226b3 commit 9c9ef59
Show file tree
Hide file tree
Showing 10 changed files with 229 additions and 51 deletions.
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;id:Ljava/lang/String;"))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package fr.catcore.fabricatedforge.mixin.forgefml.nbt;

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;
Expand All @@ -8,8 +10,9 @@

import java.io.*;

@Environment(EnvType.CLIENT)
@Mixin(NbtIo.class)
public abstract class NbtIoMixin {
public abstract class Client_NbtIoMixin {

@Shadow
public static void method_1345(NbtCompound nbtCompound, DataOutput dataOutput) {
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();
}
}
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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,6 @@ public abstract class WorldMixin implements BlockView, IWorld {
@Unique
private static SaveHandler s_savehandler;

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

@Override
public Biome getBiomeGenForCoordsBody(int par1, int par2) {
if (this.isPosLoaded(par1, 0, par2)) {
Expand Down Expand Up @@ -257,16 +248,6 @@ private PersistentStateManager getMapStorage(SaveHandler savehandler) {
// ci.cancel();
// }

/**
* @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
Expand Down Expand Up @@ -957,25 +938,6 @@ public void method_3725(int par1, int par2, int 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
Expand Down Expand Up @@ -1622,15 +1584,6 @@ public boolean isHighHumidity(int par1, int par2, int par3) {
return this.dimension.isBlockHighHumidity(par1, par2, par3);
}

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

/**
* @author Minecraft Forge
* @reason none
Expand Down
10 changes: 7 additions & 3 deletions src/main/resources/fabricated-forge.forge.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
"compatibilityLevel": "JAVA_8",
"plugin": "fr.catcore.fabricatedforge.mixin.FabricatedForgeMixinPlugin",
"server": [
"server.dedicated.gui.PlayerStatsGuiMixin"
"nbt.Server_NbtIoMixin",
"server.dedicated.gui.PlayerStatsGuiMixin",
"util.Server_LanguageMixin",
"world.Server_WorldMixin"
],
"mixins": [
"block.AbstractButtonBlockMixin",
Expand Down Expand Up @@ -79,7 +82,6 @@
"item.ToolItemMixin",
"item.itemgroup.ItemGroupMixin",
"item.map.MapStateMixin",
"nbt.NbtIoMixin",
"network.class_690Mixin",
"network.IntegratedConnectionMixin",
"network.OutboundConnectionMixin",
Expand Down Expand Up @@ -189,7 +191,9 @@
"client.sound.SoundSystemMixin",
"client.texture.ClockSpriteMixin",
"client.texture.CompassSpriteMixin",
"client.world.ClientWorldMixin"
"client.world.ClientWorldMixin",
"nbt.Client_NbtIoMixin",
"world.Client_WorldMixin"
],
"injectors": {
"defaultRequire": 1
Expand Down

0 comments on commit 9c9ef59

Please sign in to comment.