Initial Spigot/Paper 1.20 support

This commit is contained in:
Michael Primm 2023-06-09 02:05:17 -04:00
parent 130953bc12
commit 43a86b820c
7 changed files with 27 additions and 16 deletions

View File

@ -43,6 +43,7 @@ import net.minecraft.nbt.NBTTagString;
import net.minecraft.resources.MinecraftKey;
import net.minecraft.nbt.NBTBase;
import net.minecraft.server.MinecraftServer;
import net.minecraft.tags.TagsBlock;
import net.minecraft.world.level.BlockAccessAir;
import net.minecraft.world.level.biome.BiomeBase;
import net.minecraft.world.level.block.Block;
@ -189,13 +190,15 @@ public class BukkitVersionHelperSpigot120 extends BukkitVersionHelper {
int lightAtten = b.g(bd, BlockAccessAir.a, BlockPosition.b); // getLightBlock
//Log.info("statename=" + bname + "[" + sb + "], lightAtten=" + lightAtten);
// Fill in base attributes
bld.setBaseState(lastbs).setStateIndex(idx).setBlockName(bname).setStateName(sb).setMaterial(mat.toString()).setAttenuatesLight(lightAtten);
if (mat.b()) { bld.setSolid(); }
if (b instanceof BlockAir) { bld.setAir(); }
if (b instanceof BlockRotatable) { bld.setLog(); }
if (b instanceof BlockLeaves) { bld.setLeaves(); }
if ((!bd.r().c()) && ((bd.b() instanceof BlockFluids) == false)) { // Test if fluid type for block is not empty
bld.setBaseState(lastbs).setStateIndex(idx).setBlockName(bname).setStateName(sb).setAttenuatesLight(lightAtten);
if (bd.w() != null) { bld.setMaterial(bd.w().toString()); }
if (bd.e()) { bld.setSolid(); }
if (bd.i()) { bld.setAir(); }
if (bd.a(TagsBlock.t)) { bld.setLog(); }
if (bd.a(TagsBlock.O)) { bld.setLeaves(); }
if ((!bd.u().c()) && ((bd.b() instanceof BlockFluids) == false)) { // Test if fluid type for block is not empty
bld.setWaterlogged();
//Log.info("statename=" + bname + "[" + sb + "] = waterlogged");
}
DynmapBlockState dbs = bld.build(); // Build state
@ -338,12 +341,12 @@ public class BukkitVersionHelperSpigot120 extends BukkitVersionHelper {
@Override
public long getInhabitedTicks(Chunk c) {
return ((CraftChunk)c).getHandle(ChunkStatus.o).u();
return ((CraftChunk)c).getHandle(ChunkStatus.n).u();
}
@Override
public Map<?, ?> getTileEntitiesForChunk(Chunk c) {
return ((CraftChunk)c).getHandle(ChunkStatus.o).i;
return ((CraftChunk)c).getHandle(ChunkStatus.n).k;
}
@Override
@ -398,7 +401,7 @@ public class BukkitVersionHelperSpigot120 extends BukkitVersionHelper {
return ((NBTTagByteArray)val).d();
}
else if(val instanceof NBTTagString) {
return ((NBTTagString)val).f_();
return ((NBTTagString)val).m_();
}
else if(val instanceof NBTTagIntArray) {
return ((NBTTagIntArray)val).f();

View File

@ -3,7 +3,7 @@ package org.dynmap.bukkit.helper.v120;
import net.minecraft.world.level.biome.BiomeBase;
import net.minecraft.world.level.biome.BiomeFog;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_19_R3.CraftWorld;
import org.bukkit.craftbukkit.v1_20_R1.CraftWorld;
import org.dynmap.DynmapChunk;
import org.dynmap.bukkit.helper.BukkitVersionHelper;
import org.dynmap.bukkit.helper.BukkitWorld;
@ -53,7 +53,7 @@ public class MapChunkCache119_4 extends GenericMapChunkCache {
CraftWorld cw = (CraftWorld) w;
if (!cw.isChunkLoaded(chunk.x, chunk.z)) return null;
Chunk c = cw.getHandle().getChunkIfLoaded(chunk.x, chunk.z);
if (c == null || !c.o) return null; // c.loaded
if (c == null || !c.q) return null; // c.loaded
NBTTagCompound nbt = ChunkRegionLoader.a(cw.getHandle(), c);
return nbt != null ? parseChunkFromNBT(new NBT.NBTCompound(nbt)) : null;
}
@ -85,7 +85,7 @@ public class MapChunkCache119_4 extends GenericMapChunkCache {
ChunkCoordIntPair cc = new ChunkCoordIntPair(chunk.x, chunk.z);
GenericChunk gc = null;
try { // BUGBUG - convert this all to asyn properly, since now native async
nbt = cw.getHandle().k().a.f(cc).join().get(); // playerChunkMap
nbt = cw.getHandle().k().a.e(cc).join().get(); // playerChunkMap
} catch (CancellationException cx) {
} catch (NoSuchElementException snex) {
}

View File

@ -82,7 +82,7 @@ public class NBT {
}
@Override
public String getAsString(String s) {
return obj.c(s).f_();
return obj.c(s).m_();
}
@Override
public GenericBitStorage makeBitStorage(int bits, int count, long[] data) {

View File

@ -34,7 +34,7 @@ minecraft {
}
}
project.archivesBaseName = "${project.archivesBaseName}-forge-1.19.3"
project.archivesBaseName = "${project.archivesBaseName}-forge-1.20"
dependencies {
implementation project(path: ":DynmapCore", configuration: "shadow")

View File

@ -22,7 +22,7 @@ include ':bukkit-helper-118-2'
include ':bukkit-helper-119'
include ':bukkit-helper-119-3'
include ':bukkit-helper-119-4'
//include ':bukkit-helper-120'
include ':bukkit-helper-120'
include ':bukkit-helper'
include ':dynmap-api'
include ':DynmapCore'
@ -61,7 +61,7 @@ project(':bukkit-helper-118-2').projectDir = "$rootDir/bukkit-helper-118-2" as F
project(':bukkit-helper-119').projectDir = "$rootDir/bukkit-helper-119" as File
project(':bukkit-helper-119-3').projectDir = "$rootDir/bukkit-helper-119-3" as File
project(':bukkit-helper-119-4').projectDir = "$rootDir/bukkit-helper-119-4" as File
//project(':bukkit-helper-120').projectDir = "$rootDir/bukkit-helper-120" as File
project(':bukkit-helper-120').projectDir = "$rootDir/bukkit-helper-120" as File
project(':bukkit-helper').projectDir = "$rootDir/bukkit-helper" as File
project(':dynmap-api').projectDir = "$rootDir/dynmap-api" as File
project(':DynmapCore').projectDir = "$rootDir/DynmapCore" as File

View File

@ -72,6 +72,9 @@ dependencies {
implementation(project(':bukkit-helper-119-4')) {
transitive = false
}
implementation(project(':bukkit-helper-120')) {
transitive = false
}
}
processResources {
@ -108,6 +111,7 @@ shadowJar {
include(dependency(':bukkit-helper-119'))
include(dependency(':bukkit-helper-119-3'))
include(dependency(':bukkit-helper-119-4'))
include(dependency(':bukkit-helper-120'))
}
relocate('org.bstats', 'org.dynmap.bstats')
destinationDir = file '../target'

View File

@ -18,6 +18,7 @@ import org.dynmap.bukkit.helper.v118_2.BukkitVersionHelperSpigot118_2;
import org.dynmap.bukkit.helper.v119.BukkitVersionHelperSpigot119;
import org.dynmap.bukkit.helper.v119_3.BukkitVersionHelperSpigot119_3;
import org.dynmap.bukkit.helper.v119_4.BukkitVersionHelperSpigot119_4;
import org.dynmap.bukkit.helper.v120.BukkitVersionHelperSpigot120;
public class Helper {
@ -43,6 +44,9 @@ public class Helper {
Log.info("Loading Glowstone support");
BukkitVersionHelper.helper = new BukkitVersionHelperGlowstone();
}
else if (v.contains("(MC: 1.20")) {
BukkitVersionHelper.helper = new BukkitVersionHelperSpigot120();
}
else if (v.contains("(MC: 1.19)") || v.contains("(MC: 1.19.1)") || v.contains("(MC: 1.19.2)")) {
BukkitVersionHelper.helper = new BukkitVersionHelperSpigot119();
}