-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c2d2a04
commit 3b2d4a2
Showing
5 changed files
with
114 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<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"> | ||
<parent> | ||
<groupId>org.patheloper</groupId> | ||
<artifactId>pathetic-main</artifactId> | ||
<version>2.4.1</version> | ||
<relativePath>../../pom.xml</relativePath> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>v1_20_R4</artifactId> | ||
|
||
<properties> | ||
<maven.compiler.source>21</maven.compiler.source> | ||
<maven.compiler.target>21</maven.compiler.target> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
|
||
<repositories> | ||
<repository> | ||
<id>codemc-repo</id> | ||
<url>https://repo.codemc.org/repository/nms/</url> | ||
</repository> | ||
</repositories> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.spigotmc</groupId> | ||
<artifactId>spigot</artifactId> | ||
<version>1.20.5-R0.1-SNAPSHOT</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.patheloper</groupId> | ||
<artifactId>pathetic-api</artifactId> | ||
<version>2.4.1</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
</dependencies> | ||
</project> |
58 changes: 58 additions & 0 deletions
58
...tic-nms/v1_20_R4/src/main/java/org/patheloper/nms/v1_20_R4/OneTwentyFourNMSInterface.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package org.patheloper.nms.v1_20_R4; | ||
|
||
import net.minecraft.server.level.WorldServer; | ||
import net.minecraft.world.level.block.state.IBlockData; | ||
import net.minecraft.world.level.chunk.DataPaletteBlock; | ||
import net.minecraft.world.level.chunk.status.ChunkStatus; | ||
import org.bukkit.ChunkSnapshot; | ||
import org.bukkit.World; | ||
import org.bukkit.block.BlockState; | ||
import org.bukkit.craftbukkit.v1_20_R4.CraftChunk; | ||
import org.bukkit.craftbukkit.v1_20_R4.CraftWorld; | ||
import org.patheloper.api.snapshot.NMSInterface; | ||
|
||
import java.lang.reflect.Field; | ||
|
||
public class OneTwentyFourNMSInterface implements NMSInterface { | ||
|
||
private static final Field blockIDField; | ||
|
||
static { | ||
try { | ||
blockIDField = CraftChunk.class.getDeclaredField("emptyBlockIDs"); | ||
blockIDField.setAccessible(true); | ||
} catch (NoSuchFieldException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
@Override | ||
@SuppressWarnings("unchecked") | ||
public ChunkSnapshot getSnapshot(World world, int chunkX, int chunkZ) { | ||
try { | ||
|
||
WorldServer server = ((CraftWorld) world).getHandle(); | ||
CraftChunk newCraftChunk = new CraftChunk(server, chunkX, chunkZ); | ||
|
||
server.l().a(chunkX, chunkZ, ChunkStatus.n, true); | ||
DataPaletteBlock<IBlockData> dataDataPaletteBlock = | ||
(DataPaletteBlock<IBlockData>) blockIDField.get(newCraftChunk); | ||
|
||
dataDataPaletteBlock.b(); | ||
dataDataPaletteBlock.a(); | ||
ChunkSnapshot chunkSnapshot = newCraftChunk.getChunkSnapshot(); | ||
dataDataPaletteBlock.b(); | ||
|
||
return chunkSnapshot; | ||
|
||
} catch (IllegalAccessException e) { | ||
e.printStackTrace(); | ||
return null; | ||
} | ||
} | ||
|
||
@Override | ||
public BlockState getBlockState(ChunkSnapshot snapshot, int x, int y, int z) { | ||
return snapshot.getBlockData(x, y, z).createBlockState(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters