Merge pull request #1700 from MellowArpeggiation/push-ups

Revert all that gradle bullshit and do reflection instead
This commit is contained in:
HbmMods 2024-09-26 11:35:29 +02:00 committed by GitHub
commit 56da81a7ae
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 43 additions and 17 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'

View File

@ -2,6 +2,7 @@ package com.hbm.packet.toclient;
import cpw.mods.fml.common.Loader;
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;
@ -103,24 +104,24 @@ public class BiomeSyncPacket implements IMessage {
chunk.isModified = true;
if(Loader.isModLoaded(Compat.MOD_EIDS)) {
if (m.biomeArray == null) {
short[] array = Compat.getBiomeShortArray(chunk);
if(array != null) array[(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) {
short[] array = Compat.getBiomeShortArray(chunk);
if(array != null) array[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,6 +3,10 @@ package com.hbm.world;
import com.hbm.packet.PacketDispatcher;
import com.hbm.packet.toclient.BiomeSyncPacket;
import com.hbm.util.Compat;
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;
@ -20,11 +24,27 @@ 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 = Compat.getBiomeShortArray(chunk);
if(array != null) array[(z & 15) << 4 | x & 15] = (short) biome.biomeID;
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);
}
@ -34,8 +54,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)) {
short[] array = Compat.getBiomeShortArray(chunk);
if(array != null) PacketDispatcher.wrapper.sendToAllAround(new BiomeSyncPacket(x >> 4, z >> 4, array), 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,8 +63,8 @@ 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[] array = Compat.getBiomeShortArray(chunk);
if(array != null) PacketDispatcher.wrapper.sendToAllAround(new BiomeSyncPacket(x, z, array[(z & 15) << 4 | (x & 15)]), new TargetPoint(world.provider.dimensionId, x, 128, z, 1024D));
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)];
PacketDispatcher.wrapper.sendToAllAround(new BiomeSyncPacket(x, z, biome), new TargetPoint(world.provider.dimensionId, x, 128, z, 1024D));
@ -65,13 +84,20 @@ public class WorldUtil {
/* this sucks ass */
ChunkCoordIntPair coord = chunk.getChunkCoordIntPair();
if(Loader.isModLoaded(Compat.MOD_EIDS)) {
short[] array = Compat.getBiomeShortArray(chunk);
if(array != null) PacketDispatcher.wrapper.sendToAllAround(new BiomeSyncPacket(coord.chunkXPos, coord.chunkZPos, array), 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**/