Revert all that gradle bullshit and do reflection instead

This commit is contained in:
George Paton 2024-09-26 19:27:20 +10:00
parent f2b7ce48dc
commit 441a46f24f
3 changed files with 42 additions and 25 deletions

View File

@ -32,7 +32,6 @@ if(!mod_build_number.isEmpty()) {
group = "com.hbm" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "HBM-NTM"
compileJava.options.encoding = 'UTF-8'
compileJava.options.compilerArgs += '-proc:none'
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8'
@ -76,14 +75,6 @@ repositories {
name = "gt"
url = "https://gregtech.mechaenetia.com/"
}
maven {
name = 'FalsePattern'
url = "https://mvn.falsepattern.com/releases/"
}
maven {
name = "GitHub"
url = "https://jitpack.io"
}
//maven {
// name = "CurseForge"
// url = "https://minecraft.curseforge.com/api/maven/"
@ -103,8 +94,6 @@ dependencies {
compileOnly "inventorytweaks:InventoryTweaks:1.59-dev:deobf"
implementation "li.cil.oc:OpenComputers:MC1.7.10-1.5.+:api"
compileOnly 'com.falsepattern:endlessids-mc1.7.10:1.5.4:dev'
}
processResources {

View File

@ -1,8 +1,8 @@
package com.hbm.packet.toclient;
import cpw.mods.fml.common.Loader;
import com.falsepattern.endlessids.mixin.helpers.ChunkBiomeHook;
import com.hbm.util.Compat;
import com.hbm.world.WorldUtil;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
@ -104,24 +104,24 @@ public class BiomeSyncPacket implements IMessage {
chunk.isModified = true;
if(Loader.isModLoaded(Compat.MOD_EIDS)) {
if (m.biomeArray == null) {
ChunkBiomeHook hook = (ChunkBiomeHook) chunk;
hook.getBiomeShortArray()[(m.blockZ & 15) << 4 | m.blockX & 15] = m.biome;
short[] target = WorldUtil.getBiomeShortArray(chunk);
if(m.biomeArray == null) {
target[(m.blockZ & 15) << 4 | m.blockX & 15] = m.biome;
world.markBlockRangeForRenderUpdate(m.chunkX << 4, 0, m.chunkZ << 4, m.chunkX << 4, 255, m.chunkZ << 4);
} else {
for (int i = 0; i < 255; ++i) {
ChunkBiomeHook hook = (ChunkBiomeHook) chunk;
hook.getBiomeShortArray()[i] = m.biomeArray[i];
for(int i = 0; i < 255; ++i) {
target[i] = m.biomeArray[i];
world.markBlockRangeForRenderUpdate(m.chunkX << 4, 0, m.chunkZ << 4, (m.chunkX << 4) + 15, 255, (m.chunkZ << 4) + 15);
}
}
} else {
byte[] target = chunk.getBiomeArray();
if(m.biomeArray == null) {
chunk.getBiomeArray()[(m.blockZ & 15) << 4 | (m.blockX & 15)] = (byte) m.biome;
target[(m.blockZ & 15) << 4 | (m.blockX & 15)] = (byte) m.biome;
world.markBlockRangeForRenderUpdate(m.chunkX << 4, 0, m.chunkZ << 4, m.chunkX << 4, 255, m.chunkZ << 4);
} else {
for(int i = 0; i < 256; i++) {
chunk.getBiomeArray()[i] = (byte) m.biomeArray[i];
target[i] = (byte) m.biomeArray[i];
world.markBlockRangeForRenderUpdate(m.chunkX << 4, 0, m.chunkZ << 4, (m.chunkX << 4) + 15, 255, (m.chunkZ << 4) + 15);
}
}

View File

@ -3,7 +3,11 @@ package com.hbm.world;
import com.hbm.packet.PacketDispatcher;
import com.hbm.packet.toclient.BiomeSyncPacket;
import com.hbm.util.Compat;
import com.falsepattern.endlessids.mixin.helpers.ChunkBiomeHook;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
import net.minecraft.entity.Entity;
@ -21,10 +25,26 @@ import net.minecraftforge.event.entity.EntityJoinWorldEvent;
public class WorldUtil {
private static final MethodHandle getBiomeShortHandle;
static {
if(Loader.isModLoaded(Compat.MOD_EIDS)) {
try {
MethodHandles.Lookup lookup = MethodHandles.publicLookup();
MethodType methodType = MethodType.methodType(short[].class);
getBiomeShortHandle = lookup.findVirtual(Chunk.class, "getBiomeShortArray", methodType);
} catch(Exception e) {
throw new AssertionError();
}
} else {
getBiomeShortHandle = null;
}
}
public static void setBiome(World world, int x, int z, BiomeGenBase biome) {
Chunk chunk = world.getChunkFromBlockCoords(x, z);
if(Loader.isModLoaded(Compat.MOD_EIDS)) {
short[] array = ((ChunkBiomeHook) chunk).getBiomeShortArray();
short[] array = getBiomeShortArray(chunk);
array[(z & 15) << 4 | x & 15] = (short) biome.biomeID;
} else {
chunk.getBiomeArray()[(z & 15) << 4 | (x & 15)] = (byte)(biome.biomeID & 255);
@ -35,7 +55,7 @@ public class WorldUtil {
public static void syncBiomeChange(World world, int x, int z) {
Chunk chunk = world.getChunkFromBlockCoords(x, z);
if(Loader.isModLoaded(Compat.MOD_EIDS)) {
PacketDispatcher.wrapper.sendToAllAround(new BiomeSyncPacket(x >> 4, z >> 4, ((ChunkBiomeHook) chunk).getBiomeShortArray()), new TargetPoint(world.provider.dimensionId, x, 128, z, 1024D));
PacketDispatcher.wrapper.sendToAllAround(new BiomeSyncPacket(x >> 4, z >> 4, getBiomeShortArray(chunk)), new TargetPoint(world.provider.dimensionId, x, 128, z, 1024D));
} else {
PacketDispatcher.wrapper.sendToAllAround(new BiomeSyncPacket(x >> 4, z >> 4, chunk.getBiomeArray()), new TargetPoint(world.provider.dimensionId, x, 128, z, 1024D));
}
@ -44,7 +64,7 @@ public class WorldUtil {
public static void syncBiomeChangeBlock(World world, int x, int z) {
Chunk chunk = world.getChunkFromBlockCoords(x, z);
if(Loader.isModLoaded(Compat.MOD_EIDS)) {
short biome = ((ChunkBiomeHook) chunk).getBiomeShortArray()[(z & 15) << 4 | (x & 15)];
short biome = getBiomeShortArray(chunk)[(z & 15) << 4 | (x & 15)];
PacketDispatcher.wrapper.sendToAllAround(new BiomeSyncPacket(x, z, biome), new TargetPoint(world.provider.dimensionId, x, 128, z, 1024D));
} else {
byte biome = chunk.getBiomeArray()[(z & 15) << 4 | (x & 15)];
@ -65,12 +85,20 @@ public class WorldUtil {
/* this sucks ass */
ChunkCoordIntPair coord = chunk.getChunkCoordIntPair();
if(Loader.isModLoaded(Compat.MOD_EIDS)) {
PacketDispatcher.wrapper.sendToAllAround(new BiomeSyncPacket(coord.chunkXPos, coord.chunkZPos, ((ChunkBiomeHook) chunk).getBiomeShortArray()), new TargetPoint(world.provider.dimensionId, coord.getCenterXPos(), 128, coord.getCenterZPosition() /* who named you? */, 1024D));
PacketDispatcher.wrapper.sendToAllAround(new BiomeSyncPacket(coord.chunkXPos, coord.chunkZPos, getBiomeShortArray(chunk)), new TargetPoint(world.provider.dimensionId, coord.getCenterXPos(), 128, coord.getCenterZPosition() /* who named you? */, 1024D));
} else {
PacketDispatcher.wrapper.sendToAllAround(new BiomeSyncPacket(coord.chunkXPos, coord.chunkZPos, chunk.getBiomeArray()), new TargetPoint(world.provider.dimensionId, coord.getCenterXPos(), 128, coord.getCenterZPosition() /* who named you? */, 1024D));
}
}
public static short[] getBiomeShortArray(Chunk chunk) {
try {
return (short[]) getBiomeShortHandle.invokeExact(chunk);
} catch(Throwable ex) {
throw new AssertionError();
}
}
/**Chunkloads the chunk the entity is going to spawn in and then spawns it
* @param entity The entity to be spawned**/