mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
Merge pull request #1700 from MellowArpeggiation/push-ups
Revert all that gradle bullshit and do reflection instead
This commit is contained in:
commit
56da81a7ae
@ -32,7 +32,6 @@ if(!mod_build_number.isEmpty()) {
|
|||||||
group = "com.hbm" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
group = "com.hbm" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||||
archivesBaseName = "HBM-NTM"
|
archivesBaseName = "HBM-NTM"
|
||||||
compileJava.options.encoding = 'UTF-8'
|
compileJava.options.encoding = 'UTF-8'
|
||||||
compileJava.options.compilerArgs += '-proc:none'
|
|
||||||
|
|
||||||
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8'
|
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8'
|
||||||
|
|
||||||
|
|||||||
@ -2,6 +2,7 @@ package com.hbm.packet.toclient;
|
|||||||
|
|
||||||
import cpw.mods.fml.common.Loader;
|
import cpw.mods.fml.common.Loader;
|
||||||
import com.hbm.util.Compat;
|
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.IMessage;
|
||||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||||
@ -103,24 +104,24 @@ public class BiomeSyncPacket implements IMessage {
|
|||||||
chunk.isModified = true;
|
chunk.isModified = true;
|
||||||
|
|
||||||
if(Loader.isModLoaded(Compat.MOD_EIDS)) {
|
if(Loader.isModLoaded(Compat.MOD_EIDS)) {
|
||||||
if (m.biomeArray == null) {
|
short[] target = WorldUtil.getBiomeShortArray(chunk);
|
||||||
short[] array = Compat.getBiomeShortArray(chunk);
|
if(m.biomeArray == null) {
|
||||||
if(array != null) array[(m.blockZ & 15) << 4 | m.blockX & 15] = m.biome;
|
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);
|
world.markBlockRangeForRenderUpdate(m.chunkX << 4, 0, m.chunkZ << 4, m.chunkX << 4, 255, m.chunkZ << 4);
|
||||||
} else {
|
} else {
|
||||||
for (int i = 0; i < 255; ++i) {
|
for(int i = 0; i < 255; ++i) {
|
||||||
short[] array = Compat.getBiomeShortArray(chunk);
|
target[i] = m.biomeArray[i];
|
||||||
if(array != null) array[i] = m.biomeArray[i];
|
|
||||||
world.markBlockRangeForRenderUpdate(m.chunkX << 4, 0, m.chunkZ << 4, (m.chunkX << 4) + 15, 255, (m.chunkZ << 4) + 15);
|
world.markBlockRangeForRenderUpdate(m.chunkX << 4, 0, m.chunkZ << 4, (m.chunkX << 4) + 15, 255, (m.chunkZ << 4) + 15);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
byte[] target = chunk.getBiomeArray();
|
||||||
if(m.biomeArray == null) {
|
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);
|
world.markBlockRangeForRenderUpdate(m.chunkX << 4, 0, m.chunkZ << 4, m.chunkX << 4, 255, m.chunkZ << 4);
|
||||||
} else {
|
} else {
|
||||||
for(int i = 0; i < 256; i++) {
|
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);
|
world.markBlockRangeForRenderUpdate(m.chunkX << 4, 0, m.chunkZ << 4, (m.chunkX << 4) + 15, 255, (m.chunkZ << 4) + 15);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,6 +3,10 @@ package com.hbm.world;
|
|||||||
import com.hbm.packet.PacketDispatcher;
|
import com.hbm.packet.PacketDispatcher;
|
||||||
import com.hbm.packet.toclient.BiomeSyncPacket;
|
import com.hbm.packet.toclient.BiomeSyncPacket;
|
||||||
import com.hbm.util.Compat;
|
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.Loader;
|
||||||
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
|
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
@ -20,11 +24,27 @@ import net.minecraftforge.event.entity.EntityJoinWorldEvent;
|
|||||||
|
|
||||||
public class WorldUtil {
|
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) {
|
public static void setBiome(World world, int x, int z, BiomeGenBase biome) {
|
||||||
Chunk chunk = world.getChunkFromBlockCoords(x, z);
|
Chunk chunk = world.getChunkFromBlockCoords(x, z);
|
||||||
if(Loader.isModLoaded(Compat.MOD_EIDS)) {
|
if(Loader.isModLoaded(Compat.MOD_EIDS)) {
|
||||||
short[] array = Compat.getBiomeShortArray(chunk);
|
short[] array = getBiomeShortArray(chunk);
|
||||||
if(array != null) array[(z & 15) << 4 | x & 15] = (short) biome.biomeID;
|
array[(z & 15) << 4 | x & 15] = (short) biome.biomeID;
|
||||||
} else {
|
} else {
|
||||||
chunk.getBiomeArray()[(z & 15) << 4 | (x & 15)] = (byte)(biome.biomeID & 255);
|
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) {
|
public static void syncBiomeChange(World world, int x, int z) {
|
||||||
Chunk chunk = world.getChunkFromBlockCoords(x, z);
|
Chunk chunk = world.getChunkFromBlockCoords(x, z);
|
||||||
if(Loader.isModLoaded(Compat.MOD_EIDS)) {
|
if(Loader.isModLoaded(Compat.MOD_EIDS)) {
|
||||||
short[] array = Compat.getBiomeShortArray(chunk);
|
PacketDispatcher.wrapper.sendToAllAround(new BiomeSyncPacket(x >> 4, z >> 4, getBiomeShortArray(chunk)), new TargetPoint(world.provider.dimensionId, x, 128, z, 1024D));
|
||||||
if(array != null) PacketDispatcher.wrapper.sendToAllAround(new BiomeSyncPacket(x >> 4, z >> 4, array), new TargetPoint(world.provider.dimensionId, x, 128, z, 1024D));
|
|
||||||
} else {
|
} else {
|
||||||
PacketDispatcher.wrapper.sendToAllAround(new BiomeSyncPacket(x >> 4, z >> 4, chunk.getBiomeArray()), new TargetPoint(world.provider.dimensionId, x, 128, z, 1024D));
|
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) {
|
public static void syncBiomeChangeBlock(World world, int x, int z) {
|
||||||
Chunk chunk = world.getChunkFromBlockCoords(x, z);
|
Chunk chunk = world.getChunkFromBlockCoords(x, z);
|
||||||
if(Loader.isModLoaded(Compat.MOD_EIDS)) {
|
if(Loader.isModLoaded(Compat.MOD_EIDS)) {
|
||||||
short[] array = Compat.getBiomeShortArray(chunk);
|
short biome = getBiomeShortArray(chunk)[(z & 15) << 4 | (x & 15)];
|
||||||
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));
|
PacketDispatcher.wrapper.sendToAllAround(new BiomeSyncPacket(x, z, biome), new TargetPoint(world.provider.dimensionId, x, 128, z, 1024D));
|
||||||
} else {
|
} else {
|
||||||
byte biome = chunk.getBiomeArray()[(z & 15) << 4 | (x & 15)];
|
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));
|
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 */
|
/* this sucks ass */
|
||||||
ChunkCoordIntPair coord = chunk.getChunkCoordIntPair();
|
ChunkCoordIntPair coord = chunk.getChunkCoordIntPair();
|
||||||
if(Loader.isModLoaded(Compat.MOD_EIDS)) {
|
if(Loader.isModLoaded(Compat.MOD_EIDS)) {
|
||||||
short[] array = Compat.getBiomeShortArray(chunk);
|
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));
|
||||||
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));
|
|
||||||
} else {
|
} 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));
|
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
|
/**Chunkloads the chunk the entity is going to spawn in and then spawns it
|
||||||
* @param entity The entity to be spawned**/
|
* @param entity The entity to be spawned**/
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user