Skip to content

Commit

Permalink
1.16 support (#24)
Browse files Browse the repository at this point in the history
* feat: 1.16 support *hopefully*

* feat: added config

* feat: added version 1.16.1 to buildtools.sh

* feat: v16 VarBitBuffer support

* fix: empty ChunkSections breaking obfuscation

* fix: NullPointer in Chunk class

* feat: updated 1.16.1 config

Co-authored-by: NgLoader <[email protected]>
  • Loading branch information
Ingrim4 and NgLoader authored Jul 10, 2020
1 parent aba6a6c commit 8a5db26
Show file tree
Hide file tree
Showing 29 changed files with 822 additions and 83 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/buildtools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ checkVersion 1.12.2
checkVersion 1.13
checkVersion 1.13.2
checkVersion 1.14.4
checkVersion 1.15.1
checkVersion 1.15.1
checkVersion 1.16.1
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import net.imprex.orebfuscator.util.BlockCoords;
import net.minecraft.server.v1_10_R1.Block;
import net.minecraft.server.v1_10_R1.BlockPosition;
import net.minecraft.server.v1_10_R1.Chunk;
import net.minecraft.server.v1_10_R1.ChunkProviderServer;
import net.minecraft.server.v1_10_R1.EntityPlayer;
import net.minecraft.server.v1_10_R1.IBlockData;
import net.minecraft.server.v1_10_R1.MathHelper;
Expand All @@ -44,9 +46,12 @@ private static boolean isChunkLoaded(WorldServer world, int chunkX, int chunkZ)

private static IBlockData getBlockData(World world, int x, int y, int z, boolean loadChunk) {
WorldServer worldServer = world(world);
ChunkProviderServer chunkProviderServer = worldServer.getChunkProviderServer();

if (isChunkLoaded(worldServer, x >> 4, z >> 4) || loadChunk) {
// will load chunk if not loaded already
return worldServer.getType(new BlockPosition(x, y, z));
Chunk chunk = chunkProviderServer.getOrLoadChunkAt(x >> 4, z >> 4);
return chunk != null ? chunk.getBlockData(new BlockPosition(x, y, z)) : null;
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import net.imprex.orebfuscator.util.BlockCoords;
import net.minecraft.server.v1_11_R1.Block;
import net.minecraft.server.v1_11_R1.BlockPosition;
import net.minecraft.server.v1_11_R1.Chunk;
import net.minecraft.server.v1_11_R1.ChunkProviderServer;
import net.minecraft.server.v1_11_R1.EntityPlayer;
import net.minecraft.server.v1_11_R1.IBlockData;
import net.minecraft.server.v1_11_R1.MathHelper;
Expand All @@ -44,9 +46,12 @@ private static boolean isChunkLoaded(WorldServer world, int chunkX, int chunkZ)

private static IBlockData getBlockData(World world, int x, int y, int z, boolean loadChunk) {
WorldServer worldServer = world(world);
ChunkProviderServer chunkProviderServer = worldServer.getChunkProviderServer();

if (isChunkLoaded(worldServer, x >> 4, z >> 4) || loadChunk) {
// will load chunk if not loaded already
return worldServer.getType(new BlockPosition(x, y, z));
Chunk chunk = chunkProviderServer.getOrLoadChunkAt(x >> 4, z >> 4);
return chunk != null ? chunk.getBlockData(new BlockPosition(x, y, z)) : null;
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import net.imprex.orebfuscator.util.BlockCoords;
import net.minecraft.server.v1_12_R1.Block;
import net.minecraft.server.v1_12_R1.BlockPosition;
import net.minecraft.server.v1_12_R1.Chunk;
import net.minecraft.server.v1_12_R1.ChunkProviderServer;
import net.minecraft.server.v1_12_R1.EntityPlayer;
import net.minecraft.server.v1_12_R1.IBlockData;
import net.minecraft.server.v1_12_R1.MathHelper;
Expand All @@ -44,9 +46,12 @@ private static boolean isChunkLoaded(WorldServer world, int chunkX, int chunkZ)

private static IBlockData getBlockData(World world, int x, int y, int z, boolean loadChunk) {
WorldServer worldServer = world(world);
ChunkProviderServer chunkProviderServer = worldServer.getChunkProviderServer();

if (isChunkLoaded(worldServer, x >> 4, z >> 4) || loadChunk) {
// will load chunk if not loaded already
return worldServer.getType(new BlockPosition(x, y, z));
Chunk chunk = chunkProviderServer.getOrLoadChunkAt(x >> 4, z >> 4);
return chunk != null ? chunk.getBlockData(new BlockPosition(x, y, z)) : null;
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import net.imprex.orebfuscator.util.BlockCoords;
import net.minecraft.server.v1_13_R1.Block;
import net.minecraft.server.v1_13_R1.BlockPosition;
import net.minecraft.server.v1_13_R1.Chunk;
import net.minecraft.server.v1_13_R1.ChunkProviderServer;
import net.minecraft.server.v1_13_R1.EntityPlayer;
import net.minecraft.server.v1_13_R1.IBlockData;
import net.minecraft.server.v1_13_R1.MathHelper;
Expand All @@ -45,9 +47,12 @@ private static boolean isChunkLoaded(WorldServer world, int chunkX, int chunkZ)

private static IBlockData getBlockData(World world, int x, int y, int z, boolean loadChunk) {
WorldServer worldServer = world(world);
ChunkProviderServer chunkProviderServer = worldServer.getChunkProviderServer();

if (isChunkLoaded(worldServer, x >> 4, z >> 4) || loadChunk) {
// will load chunk if not loaded already
return worldServer.getType(new BlockPosition(x, y, z));
Chunk chunk = chunkProviderServer.getOrLoadChunkAt(x >> 4, z >> 4);
return chunk != null ? chunk.getType(new BlockPosition(x, y, z)) : null;
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import net.imprex.orebfuscator.util.BlockCoords;
import net.minecraft.server.v1_13_R2.Block;
import net.minecraft.server.v1_13_R2.BlockPosition;
import net.minecraft.server.v1_13_R2.Chunk;
import net.minecraft.server.v1_13_R2.ChunkProviderServer;
import net.minecraft.server.v1_13_R2.EntityPlayer;
import net.minecraft.server.v1_13_R2.IBlockData;
import net.minecraft.server.v1_13_R2.IRegistry;
Expand All @@ -46,9 +48,12 @@ private static boolean isChunkLoaded(WorldServer world, int chunkX, int chunkZ)

private static IBlockData getBlockData(World world, int x, int y, int z, boolean loadChunk) {
WorldServer worldServer = world(world);
ChunkProviderServer chunkProviderServer = worldServer.getChunkProvider();

if (isChunkLoaded(worldServer, x >> 4, z >> 4) || loadChunk) {
// will load chunk if not loaded already
return worldServer.getType(new BlockPosition(x, y, z));
Chunk chunk = chunkProviderServer.getChunkAt(x >> 4, z >> 4, true, false);
return chunk != null ? chunk.getType(new BlockPosition(x, y, z)) : null;
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import net.imprex.orebfuscator.util.BlockCoords;
import net.minecraft.server.v1_14_R1.Block;
import net.minecraft.server.v1_14_R1.BlockPosition;
import net.minecraft.server.v1_14_R1.Chunk;
import net.minecraft.server.v1_14_R1.ChunkProviderServer;
import net.minecraft.server.v1_14_R1.EntityPlayer;
import net.minecraft.server.v1_14_R1.IBlockData;
import net.minecraft.server.v1_14_R1.IRegistry;
Expand All @@ -45,9 +47,12 @@ private static boolean isChunkLoaded(WorldServer world, int chunkX, int chunkZ)

private static IBlockData getBlockData(World world, int x, int y, int z, boolean loadChunk) {
WorldServer worldServer = world(world);
ChunkProviderServer chunkProviderServer = worldServer.getChunkProvider();

if (isChunkLoaded(worldServer, x >> 4, z >> 4) || loadChunk) {
// will load chunk if not loaded already
return worldServer.getType(new BlockPosition(x, y, z));
Chunk chunk = chunkProviderServer.getChunkAt(x >> 4, z >> 4, false);
return chunk != null ? chunk.getType(new BlockPosition(x, y, z)) : null;
}
return null;
}
Expand Down
6 changes: 4 additions & 2 deletions orebfuscator-nms/orebfuscator-nms-v1_15_R1/pom.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>net.imprex</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import net.imprex.orebfuscator.util.BlockCoords;
import net.minecraft.server.v1_15_R1.Block;
import net.minecraft.server.v1_15_R1.BlockPosition;
import net.minecraft.server.v1_15_R1.Chunk;
import net.minecraft.server.v1_15_R1.ChunkProviderServer;
import net.minecraft.server.v1_15_R1.EntityPlayer;
import net.minecraft.server.v1_15_R1.IBlockData;
import net.minecraft.server.v1_15_R1.IRegistry;
Expand All @@ -45,9 +47,12 @@ private static boolean isChunkLoaded(WorldServer world, int chunkX, int chunkZ)

private static IBlockData getBlockData(World world, int x, int y, int z, boolean loadChunk) {
WorldServer worldServer = world(world);
ChunkProviderServer chunkProviderServer = worldServer.getChunkProvider();

if (isChunkLoaded(worldServer, x >> 4, z >> 4) || loadChunk) {
// will load chunk if not loaded already
return worldServer.getType(new BlockPosition(x, y, z));
Chunk chunk = chunkProviderServer.getChunkAt(x >> 4, z >> 4, false);
return chunk != null ? chunk.getType(new BlockPosition(x, y, z)) : null;
}
return null;
}
Expand Down
29 changes: 29 additions & 0 deletions orebfuscator-nms/orebfuscator-nms-v1_16_R1/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>net.imprex</groupId>
<artifactId>orebfuscator-nms</artifactId>
<version>${orebfuscator.version}</version>
</parent>

<artifactId>orebfuscator-nms-v1_16_R1</artifactId>
<packaging>jar</packaging>

<dependencies>
<dependency>
<groupId>net.imprex</groupId>
<artifactId>orebfuscator-nms-api</artifactId>
<version>${orebfuscator.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.16.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package net.imprex.orebfuscator.nms.v1_16_R1;

import org.bukkit.World;
import org.bukkit.craftbukkit.v1_16_R1.CraftWorld;

import net.imprex.orebfuscator.nms.AbstractBlockState;
import net.minecraft.server.v1_16_R1.BlockPosition;
import net.minecraft.server.v1_16_R1.IBlockData;
import net.minecraft.server.v1_16_R1.WorldServer;

public class BlockState extends AbstractBlockState<IBlockData> {

public BlockState(int x, int y, int z, World world, IBlockData state) {
super(x, y, z, world, state);
}

@Override
public int getBlockId() {
return NmsManager.getBlockId(this.state);
}

@Override
public void notifyBlockChange() {
WorldServer worldServer = ((CraftWorld) this.world).getHandle();
worldServer.notify(new BlockPosition(this.x, this.y, this.z), this.state, this.state, 0);
}
}
Loading

0 comments on commit 8a5db26

Please sign in to comment.