Skip to content

Commit d871e0e

Browse files
committed
Update for 1.21.3
1 parent 4d7a6c7 commit d871e0e

File tree

13 files changed

+235
-5
lines changed

13 files changed

+235
-5
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,3 +270,5 @@ gradle-app.setting
270270
*.hprof
271271

272272
# End of https://www.toptal.com/developers/gitignore/api/git,java,maven,eclipse,netbeans,jetbrains+all,visualstudiocode,gradle
273+
.paper-nms
274+
*.iml

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
allprojects {
33
group = "org.geysermc.geyser.adapters"
4-
version = "1.13-SNAPSHOT"
4+
version = "1.14-SNAPSHOT"
55
description = "Adapters for Geyser"
66
}

paper/all/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ val shadowOnly: Configuration by configurations.creating
99
dependencies {
1010
api(projects.paper.base)
1111
shadowOnly(projects.paper.v766)
12+
shadowOnly(projects.paper.v768)
1213
}
1314

1415
tasks {

paper/all/src/main/java/org/geysermc/geyser/adapters/paper/PaperAdapters.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
public final class PaperAdapters {
3131
private static PaperWorldAdapter worldAdapter;
3232

33-
private static final int[] protocols = new int[] {766};
33+
private static final int[] protocols = new int[] {766, 768};
3434

3535
public static void registerClosestWorldAdapter(int version) throws Exception {
3636
if (version < protocols[0]) {

paper/base/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ plugins {
55

66
dependencies {
77
api(projects.common)
8-
compileOnly("io.papermc.paper", "paper-api", "1.20.5-R0.1-SNAPSHOT") {
8+
compileOnly("io.papermc.paper", "paper-api", "1.20.6-R0.1-SNAPSHOT") {
99
attributes {
1010
attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 21)
1111
}

paper/v766/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ java {
1313

1414
dependencies {
1515
implementation(projects.paper.base)
16-
paperweight.paperDevBundle("1.20.5-R0.1-SNAPSHOT")
16+
paperweight.paperDevBundle("1.20.6-R0.1-SNAPSHOT")
1717
}

paper/v768/build.gradle.kts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
plugins {
3+
id("adapters.paper.paperweight-conventions")
4+
}
5+
6+
java {
7+
sourceCompatibility = JavaVersion.VERSION_21
8+
targetCompatibility = JavaVersion.VERSION_21
9+
toolchain {
10+
languageVersion = JavaLanguageVersion.of(21)
11+
}
12+
}
13+
14+
dependencies {
15+
implementation(projects.paper.base)
16+
paperweight.paperDevBundle("1.21.3-R0.1-SNAPSHOT")
17+
}
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
/*
2+
* Copyright (c) 2019-2024 GeyserMC. http://geysermc.org
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy
5+
* of this software and associated documentation files (the "Software"), to deal
6+
* in the Software without restriction, including without limitation the rights
7+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
* copies of the Software, and to permit persons to whom the Software is
9+
* furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in
12+
* all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20+
* THE SOFTWARE.
21+
*
22+
* @author GeyserMC
23+
* @link https://github.com/GeyserMC/Geyser
24+
*/
25+
26+
package org.geysermc.geyser.adapters.paper.v768;
27+
28+
import it.unimi.dsi.fastutil.ints.IntArrayList;
29+
import it.unimi.dsi.fastutil.ints.IntList;
30+
import net.minecraft.core.Registry;
31+
import net.minecraft.core.registries.Registries;
32+
import net.minecraft.resources.ResourceLocation;
33+
import net.minecraft.server.MinecraftServer;
34+
import net.minecraft.world.level.biome.Biome;
35+
import net.minecraft.world.level.block.Block;
36+
import net.minecraft.world.level.block.state.BlockState;
37+
import net.minecraft.world.level.chunk.LevelChunk;
38+
import net.minecraft.world.level.chunk.LevelChunkSection;
39+
import org.bukkit.World;
40+
import org.bukkit.craftbukkit.CraftWorld;
41+
import org.geysermc.geyser.adapters.paper.PaperWorldAdapter;
42+
43+
import java.util.ArrayList;
44+
import java.util.List;
45+
import java.util.stream.Stream;
46+
47+
public class WorldAdapter_v768 extends PaperWorldAdapter {
48+
@Override
49+
public int getBlockAt(World world, int x, int y, int z) {
50+
if (y < world.getMinHeight()) {
51+
return 0;
52+
}
53+
54+
LevelChunk chunk = ((CraftWorld) world).getHandle().getChunkIfLoaded(x >> 4, z >> 4);
55+
if (chunk == null) { // should never happen but just to be on the safe side
56+
return 0;
57+
}
58+
int worldOffset = world.getMinHeight() >> 4;
59+
int chunkOffset = (y >> 4) - worldOffset;
60+
if (chunkOffset < chunk.getSections().length) {
61+
LevelChunkSection section = chunk.getSections()[chunkOffset];
62+
if (section != null && !section.hasOnlyAir()) {
63+
return Block.getId(section.getBlockState(x & 15, y & 15, z & 15));
64+
}
65+
}
66+
return 0;
67+
}
68+
69+
@Override
70+
public IntList getAllBlockStates() {
71+
IntList blockStates = new IntArrayList();
72+
for (BlockState block : Block.BLOCK_STATE_REGISTRY) {
73+
blockStates.add(Block.getId(block));
74+
}
75+
return blockStates;
76+
}
77+
78+
@Override
79+
public String[] getBiomeSuggestions(boolean tags) {
80+
Registry<Biome> registry = MinecraftServer.getServer()
81+
.registryAccess()
82+
.lookupOrThrow(Registries.BIOME);
83+
if (!tags) {
84+
return getBiomes(registry).toArray(String[]::new);
85+
}
86+
87+
List<String> keys = new ArrayList<>(registry.getTags().map(tag -> "#" + tag.key().location()).toList());
88+
keys.addAll(getBiomes(registry).toList());
89+
return keys.toArray(new String[0]);
90+
}
91+
92+
private Stream<String> getBiomes(Registry<Biome> registry) {
93+
return registry.keySet().stream().map(ResourceLocation::toString);
94+
}
95+
}

settings.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ include(":spigot:v1_20_R2")
1818
include(":spigot:v1_20_R3")
1919
include(":spigot:v1_20_R4")
2020
include(":spigot:v1_21_R1")
21+
include(":spigot:v1_21_R2")
2122

2223
include(":paper")
2324
include(":paper:all")
2425
include(":paper:base")
2526
include(":paper:v766")
27+
include(":paper:v768")

spigot/all/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ dependencies {
2323
adapter("1_20_R3")
2424
adapter("1_20_R4")
2525
adapter("1_21_R1")
26+
adapter("1_21_R2")
2627
}
2728

2829
tasks {

0 commit comments

Comments
 (0)