Add support for Spigot 1.12-pre2
parent
6132d84ad3
commit
dc9fb65c9e
|
@ -82,6 +82,7 @@ local.properties
|
||||||
### Intellij ###
|
### Intellij ###
|
||||||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
|
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
|
||||||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||||
|
.idea
|
||||||
|
|
||||||
# User-specific stuff:
|
# User-specific stuff:
|
||||||
.idea/workspace.xml
|
.idea/workspace.xml
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
<groupId>com.lishid</groupId>
|
<groupId>com.lishid</groupId>
|
||||||
<artifactId>orebfuscator</artifactId>
|
<artifactId>orebfuscator</artifactId>
|
||||||
<version>4.2.2-SNAPSHOT</version>
|
<version>4.3.0-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>Orebfuscator4</name>
|
<name>Orebfuscator4</name>
|
||||||
|
@ -81,6 +81,14 @@
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.lishid</groupId>
|
||||||
|
<artifactId>orebfuscator-v1_12_R1</artifactId>
|
||||||
|
<version>v1_12_R1</version>
|
||||||
|
<type>jar</type>
|
||||||
|
<scope>compile</scope>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
@ -117,8 +117,11 @@ public class Orebfuscator extends JavaPlugin {
|
||||||
private static INmsManager createNmsManager() {
|
private static INmsManager createNmsManager() {
|
||||||
|
|
||||||
String serverVersion = org.bukkit.Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3];
|
String serverVersion = org.bukkit.Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3];
|
||||||
|
|
||||||
if(serverVersion.equals("v1_11_R1")) {
|
if(serverVersion.equals("v1_12_R1")) {
|
||||||
|
return new com.lishid.orebfuscator.nms.v1_12_R1.NmsManager();
|
||||||
|
}
|
||||||
|
else if(serverVersion.equals("v1_11_R1")) {
|
||||||
return new com.lishid.orebfuscator.nms.v1_11_R1.NmsManager();
|
return new com.lishid.orebfuscator.nms.v1_11_R1.NmsManager();
|
||||||
}
|
}
|
||||||
else if(serverVersion.equals("v1_10_R1")) {
|
else if(serverVersion.equals("v1_10_R1")) {
|
||||||
|
|
9
pom.xml
9
pom.xml
|
@ -30,14 +30,19 @@
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
<module>Plugin</module>
|
<module>API</module>
|
||||||
<module>v1_9_R1</module>
|
<module>v1_9_R1</module>
|
||||||
<module>v1_9_R2</module>
|
<module>v1_9_R2</module>
|
||||||
<module>v1_10_R1</module>
|
<module>v1_10_R1</module>
|
||||||
<module>v1_11_R1</module>
|
<module>v1_11_R1</module>
|
||||||
<module>API</module>
|
<module>v1_12_R1</module>
|
||||||
|
<module>Plugin</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<defaultGoal>clean install</defaultGoal>
|
||||||
|
</build>
|
||||||
|
|
||||||
<scm>
|
<scm>
|
||||||
<connection>scm:git:git://github.com/lishid/Orebfuscator.git</connection>
|
<connection>scm:git:git://github.com/lishid/Orebfuscator.git</connection>
|
||||||
<developerConnection>scm:git:git@github.com:lishid/Orebfuscator.git</developerConnection>
|
<developerConnection>scm:git:git@github.com:lishid/Orebfuscator.git</developerConnection>
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
<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>
|
||||||
|
<groupId>com.lishid</groupId>
|
||||||
|
<artifactId>orebfuscator-v1_12_R1</artifactId>
|
||||||
|
<version>v1_12_R1</version>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
<name>Orebfuscator4 v1_12_R1</name>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>com.lishid.parent</groupId>
|
||||||
|
<artifactId>orebfuscator-parent</artifactId>
|
||||||
|
<version>parent</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.1</version>
|
||||||
|
<configuration>
|
||||||
|
<source>1.7</source>
|
||||||
|
<target>1.7</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.spigotmc</groupId>
|
||||||
|
<artifactId>spigot</artifactId>
|
||||||
|
<version>1.12-pre2-SNAPSHOT</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.lishid</groupId>
|
||||||
|
<artifactId>orebfuscator-api</artifactId>
|
||||||
|
<version>API</version>
|
||||||
|
<type>jar</type>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
</project>
|
|
@ -0,0 +1,65 @@
|
||||||
|
/**
|
||||||
|
* @author Aleksey Terzi
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.lishid.orebfuscator.nms.v1_12_R1;
|
||||||
|
|
||||||
|
import net.minecraft.server.v1_12_R1.Block;
|
||||||
|
import net.minecraft.server.v1_12_R1.IBlockData;
|
||||||
|
|
||||||
|
import com.lishid.orebfuscator.nms.IBlockInfo;
|
||||||
|
|
||||||
|
public class BlockInfo implements IBlockInfo {
|
||||||
|
private int x;
|
||||||
|
private int y;
|
||||||
|
private int z;
|
||||||
|
private IBlockData blockData;
|
||||||
|
|
||||||
|
public BlockInfo(int x, int y, int z, IBlockData blockData) {
|
||||||
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
this.z = z;
|
||||||
|
this.blockData = blockData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getX() {
|
||||||
|
return this.x;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getY() {
|
||||||
|
return this.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getZ() {
|
||||||
|
return this.z;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTypeId() {
|
||||||
|
return Block.getId(this.blockData.getBlock());
|
||||||
|
}
|
||||||
|
|
||||||
|
public IBlockData getBlockData() {
|
||||||
|
return this.blockData;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object other) {
|
||||||
|
if (other == null || !(other instanceof BlockInfo)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
BlockInfo object = (BlockInfo) other;
|
||||||
|
|
||||||
|
return this.x == object.x && this.y == object.y && this.z == object.z;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return this.x ^ this.y ^ this.z;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return this.x + " " + this.y + " " + this.z;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,85 @@
|
||||||
|
/**
|
||||||
|
* @author lishid
|
||||||
|
* @author Aleksey Terzi
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.lishid.orebfuscator.nms.v1_12_R1;
|
||||||
|
|
||||||
|
import java.io.DataInputStream;
|
||||||
|
import java.io.DataOutputStream;
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import net.minecraft.server.v1_12_R1.RegionFile;
|
||||||
|
|
||||||
|
import com.lishid.orebfuscator.nms.IChunkCache;
|
||||||
|
|
||||||
|
public class ChunkCache implements IChunkCache {
|
||||||
|
private static final HashMap<File, RegionFile> cachedRegionFiles = new HashMap<File, RegionFile>();
|
||||||
|
|
||||||
|
private int maxLoadedCacheFiles;
|
||||||
|
|
||||||
|
public ChunkCache(int maxLoadedCacheFiles) {
|
||||||
|
this.maxLoadedCacheFiles = maxLoadedCacheFiles;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DataInputStream getInputStream(File folder, int x, int z) {
|
||||||
|
RegionFile regionFile = getRegionFile(folder, x, z);
|
||||||
|
return regionFile.a(x & 0x1F, z & 0x1F);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DataOutputStream getOutputStream(File folder, int x, int z) {
|
||||||
|
RegionFile regionFile = getRegionFile(folder, x, z);
|
||||||
|
return regionFile.b(x & 0x1F, z & 0x1F);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void closeCacheFiles() {
|
||||||
|
closeCacheFilesInternal();
|
||||||
|
}
|
||||||
|
|
||||||
|
private synchronized RegionFile getRegionFile(File folder, int x, int z) {
|
||||||
|
File path = new File(folder, "region");
|
||||||
|
File file = new File(path, "r." + (x >> 5) + "." + (z >> 5) + ".mcr");
|
||||||
|
try {
|
||||||
|
RegionFile regionFile = cachedRegionFiles.get(file);
|
||||||
|
if (regionFile != null) {
|
||||||
|
return regionFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!path.exists()) {
|
||||||
|
path.mkdirs();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cachedRegionFiles.size() >= this.maxLoadedCacheFiles) {
|
||||||
|
closeCacheFiles();
|
||||||
|
}
|
||||||
|
|
||||||
|
regionFile = new RegionFile(file);
|
||||||
|
cachedRegionFiles.put(file, regionFile);
|
||||||
|
|
||||||
|
return regionFile;
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
try {
|
||||||
|
file.delete();
|
||||||
|
}
|
||||||
|
catch (Exception e2) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private synchronized void closeCacheFilesInternal() {
|
||||||
|
for (RegionFile regionFile : cachedRegionFiles.values()) {
|
||||||
|
try {
|
||||||
|
if (regionFile != null)
|
||||||
|
regionFile.c();
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cachedRegionFiles.clear();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,43 @@
|
||||||
|
/**
|
||||||
|
* @author Aleksey Terzi
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.lishid.orebfuscator.nms.v1_12_R1;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
|
||||||
|
import net.minecraft.server.v1_12_R1.EntityPlayer;
|
||||||
|
import net.minecraft.server.v1_12_R1.PacketPlayOutMapChunk;
|
||||||
|
import net.minecraft.server.v1_12_R1.PacketPlayOutUnloadChunk;
|
||||||
|
import net.minecraft.server.v1_12_R1.PlayerChunk;
|
||||||
|
import net.minecraft.server.v1_12_R1.PlayerChunkMap;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.lishid.orebfuscator.nms.IChunkManager;
|
||||||
|
|
||||||
|
public class ChunkManager implements IChunkManager {
|
||||||
|
private PlayerChunkMap chunkMap;
|
||||||
|
|
||||||
|
public ChunkManager(PlayerChunkMap chunkMap) {
|
||||||
|
this.chunkMap = chunkMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean resendChunk(int chunkX, int chunkZ, HashSet<Player> affectedPlayers) {
|
||||||
|
if(!this.chunkMap.isChunkInUse(chunkX, chunkZ)) return true;
|
||||||
|
|
||||||
|
PlayerChunk playerChunk = this.chunkMap.getChunk(chunkX, chunkZ);
|
||||||
|
|
||||||
|
if(playerChunk == null || playerChunk.chunk == null || !playerChunk.chunk.isReady()) return false;
|
||||||
|
|
||||||
|
for(EntityPlayer player : playerChunk.c) {
|
||||||
|
player.playerConnection.sendPacket(new PacketPlayOutUnloadChunk(chunkX, chunkZ));
|
||||||
|
player.playerConnection.sendPacket(new PacketPlayOutMapChunk(playerChunk.chunk, 0xffff));
|
||||||
|
|
||||||
|
affectedPlayers.add(player.getBukkitEntity());
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,73 @@
|
||||||
|
/**
|
||||||
|
* @author lishid
|
||||||
|
* @author Aleksey Terzi
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.lishid.orebfuscator.nms.v1_12_R1;
|
||||||
|
|
||||||
|
import java.io.DataInput;
|
||||||
|
import java.io.DataInputStream;
|
||||||
|
import java.io.DataOutput;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import net.minecraft.server.v1_12_R1.NBTCompressedStreamTools;
|
||||||
|
import net.minecraft.server.v1_12_R1.NBTTagCompound;
|
||||||
|
|
||||||
|
import com.lishid.orebfuscator.nms.INBT;
|
||||||
|
|
||||||
|
public class NBT implements INBT {
|
||||||
|
NBTTagCompound nbt = new NBTTagCompound();
|
||||||
|
|
||||||
|
public void reset() {
|
||||||
|
nbt = new NBTTagCompound();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInt(String tag, int value) {
|
||||||
|
nbt.setInt(tag, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLong(String tag, long value) {
|
||||||
|
nbt.setLong(tag, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBoolean(String tag, boolean value) {
|
||||||
|
nbt.setBoolean(tag, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setByteArray(String tag, byte[] value) {
|
||||||
|
nbt.setByteArray(tag, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIntArray(String tag, int[] value) {
|
||||||
|
nbt.setIntArray(tag, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getInt(String tag) {
|
||||||
|
return nbt.getInt(tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getLong(String tag) {
|
||||||
|
return nbt.getLong(tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getBoolean(String tag) {
|
||||||
|
return nbt.getBoolean(tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] getByteArray(String tag) {
|
||||||
|
return nbt.getByteArray(tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int[] getIntArray(String tag) {
|
||||||
|
return nbt.getIntArray(tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Read(DataInput stream) throws IOException {
|
||||||
|
nbt = NBTCompressedStreamTools.a((DataInputStream) stream);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Write(DataOutput stream) throws IOException {
|
||||||
|
NBTCompressedStreamTools.a(nbt, stream);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,138 @@
|
||||||
|
/**
|
||||||
|
* @author lishid
|
||||||
|
* @author Aleksey Terzi
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.lishid.orebfuscator.nms.v1_12_R1;
|
||||||
|
|
||||||
|
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.IBlockData;
|
||||||
|
import net.minecraft.server.v1_12_R1.IChatBaseComponent;
|
||||||
|
import net.minecraft.server.v1_12_R1.Packet;
|
||||||
|
import net.minecraft.server.v1_12_R1.PlayerChunkMap;
|
||||||
|
import net.minecraft.server.v1_12_R1.TileEntity;
|
||||||
|
import net.minecraft.server.v1_12_R1.WorldServer;
|
||||||
|
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.craftbukkit.v1_12_R1.CraftWorld;
|
||||||
|
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer;
|
||||||
|
import org.bukkit.craftbukkit.v1_12_R1.util.CraftChatMessage;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.lishid.orebfuscator.nms.IBlockInfo;
|
||||||
|
import com.lishid.orebfuscator.nms.IChunkCache;
|
||||||
|
import com.lishid.orebfuscator.nms.IChunkManager;
|
||||||
|
import com.lishid.orebfuscator.nms.INBT;
|
||||||
|
import com.lishid.orebfuscator.nms.INmsManager;
|
||||||
|
import com.lishid.orebfuscator.types.BlockCoord;
|
||||||
|
import com.lishid.orebfuscator.types.BlockState;
|
||||||
|
|
||||||
|
public class NmsManager implements INmsManager {
|
||||||
|
private int maxLoadedCacheFiles;
|
||||||
|
|
||||||
|
public void setMaxLoadedCacheFiles(int value) {
|
||||||
|
this.maxLoadedCacheFiles = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public INBT createNBT() {
|
||||||
|
return new NBT();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IChunkCache createChunkCache() {
|
||||||
|
return new ChunkCache(this.maxLoadedCacheFiles);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IChunkManager getChunkManager(World world) {
|
||||||
|
WorldServer worldServer = ((CraftWorld)world).getHandle();
|
||||||
|
PlayerChunkMap chunkMap = worldServer.getPlayerChunkMap();
|
||||||
|
|
||||||
|
return new ChunkManager(chunkMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateBlockTileEntity(BlockCoord blockCoord, Player player) {
|
||||||
|
CraftWorld world = (CraftWorld)player.getWorld();
|
||||||
|
TileEntity tileEntity = world.getTileEntityAt(blockCoord.x, blockCoord.y, blockCoord.z);
|
||||||
|
|
||||||
|
if (tileEntity == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Packet<?> packet = tileEntity.getUpdatePacket();
|
||||||
|
|
||||||
|
if (packet != null) {
|
||||||
|
CraftPlayer player2 = (CraftPlayer)player;
|
||||||
|
player2.getHandle().playerConnection.sendPacket(packet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void notifyBlockChange(World world, IBlockInfo blockInfo) {
|
||||||
|
BlockPosition blockPosition = new BlockPosition(blockInfo.getX(), blockInfo.getY(), blockInfo.getZ());
|
||||||
|
IBlockData blockData = ((BlockInfo)blockInfo).getBlockData();
|
||||||
|
|
||||||
|
((CraftWorld)world).getHandle().notify(blockPosition, blockData, blockData, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getBlockLightLevel(World world, int x, int y, int z) {
|
||||||
|
return ((CraftWorld)world).getHandle().getLightLevel(new BlockPosition(x, y, z));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IBlockInfo getBlockInfo(World world, int x, int y, int z) {
|
||||||
|
IBlockData blockData = getBlockData(world, x, y, z);
|
||||||
|
|
||||||
|
return blockData != null
|
||||||
|
? new BlockInfo(x, y, z, blockData)
|
||||||
|
: null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockState getBlockState(World world, int x, int y, int z) {
|
||||||
|
IBlockData blockData = getBlockData(world, x, y, z);
|
||||||
|
|
||||||
|
if(blockData == null) return null;
|
||||||
|
|
||||||
|
Block block = blockData.getBlock();
|
||||||
|
|
||||||
|
BlockState blockState = new BlockState();
|
||||||
|
blockState.id = Block.getId(block);
|
||||||
|
blockState.meta = block.toLegacyData(blockData);
|
||||||
|
|
||||||
|
return blockState;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getBlockId(World world, int x, int y, int z) {
|
||||||
|
IBlockData blockData = getBlockData(world, x, y, z);
|
||||||
|
|
||||||
|
return blockData != null ? Block.getId(blockData.getBlock()): -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTextFromChatComponent(String json) {
|
||||||
|
IChatBaseComponent component = IChatBaseComponent.ChatSerializer.a(json);
|
||||||
|
return CraftChatMessage.fromComponent(component);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static IBlockData getBlockData(World world, int x, int y, int z) {
|
||||||
|
int chunkX = x >> 4;
|
||||||
|
int chunkZ = z >> 4;
|
||||||
|
|
||||||
|
WorldServer worldServer = ((CraftWorld)world).getHandle();
|
||||||
|
ChunkProviderServer chunkProviderServer = worldServer.getChunkProviderServer();
|
||||||
|
|
||||||
|
if(!chunkProviderServer.isLoaded(chunkX, chunkZ)) return null;
|
||||||
|
|
||||||
|
Chunk chunk = chunkProviderServer.getOrLoadChunkAt(chunkX, chunkZ);
|
||||||
|
|
||||||
|
return chunk.getBlockData(new BlockPosition(x, y, z));
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue