Skip to content

Commit 3d411d2

Browse files
committed
Limit to 1.21.x Fix for 1.21.3
1 parent 6d66242 commit 3d411d2

File tree

7 files changed

+80
-92
lines changed

7 files changed

+80
-92
lines changed

pom.xml

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
<powermock.version>2.0.9</powermock.version>
5656
<!-- More visible way how to change dependency versions -->
5757
<spigot.version>1.21.3-R0.1-SNAPSHOT</spigot.version>
58+
<paper.version>1.21.3-R0.1-SNAPSHOT</paper.version>
5859
<bentobox.version>2.7.1-SNAPSHOT</bentobox.version>
5960
<!-- Revision variable removes warning about dynamic version -->
6061
<revision>${build.version}-SNAPSHOT</revision>
@@ -111,6 +112,10 @@
111112
</profiles>
112113

113114
<repositories>
115+
<repository>
116+
<id>papermc</id>
117+
<url>https://repo.papermc.io/repository/maven-public/</url>
118+
</repository>
114119
<repository>
115120
<id>spigot-repo</id>
116121
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots</url>
@@ -139,6 +144,20 @@
139144
</repositories>
140145

141146
<dependencies>
147+
<!-- Paper API -->
148+
<dependency>
149+
<groupId>io.papermc.paper</groupId>
150+
<artifactId>paper-api</artifactId>
151+
<version>${paper.version}</version>
152+
<scope>provided</scope>
153+
</dependency>
154+
<!-- PaperLib -->
155+
<dependency>
156+
<groupId>io.papermc</groupId>
157+
<artifactId>paperlib</artifactId>
158+
<version>1.0.6</version>
159+
<scope>compile</scope>
160+
</dependency>
142161
<!-- Spigot API -->
143162
<dependency>
144163
<groupId>org.spigotmc</groupId>
@@ -172,14 +191,7 @@
172191
<scope>provided</scope>
173192
</dependency>
174193
<!-- Spigot NMS. Used for chunk deletion and pasting. -->
175-
176-
<dependency>
177-
<groupId>org.spigotmc....</groupId>
178-
<artifactId>spigot</artifactId>
179-
<version>1.20.6-R0.1-SNAPSHOT</version>
180-
<scope>provided</scope>
181-
</dependency>
182-
<dependency>
194+
<dependency>
183195
<groupId>org.spigotmc</groupId>
184196
<artifactId>spigot</artifactId>
185197
<version>${spigot.version}</version>
@@ -191,24 +203,6 @@
191203
<version>1.21.1-R0.1-SNAPSHOT</version>
192204
<scope>provided</scope>
193205
</dependency>
194-
<dependency>
195-
<groupId>org.spigotmc.</groupId>
196-
<artifactId>spigot</artifactId>
197-
<version>1.20.4-R0.1-SNAPSHOT</version>
198-
<scope>provided</scope>
199-
</dependency>
200-
<dependency>
201-
<groupId>org.spigotmc..</groupId>
202-
<artifactId>spigot</artifactId>
203-
<version>1.20.2-R0.1-SNAPSHOT</version>
204-
<scope>provided</scope>
205-
</dependency>
206-
<dependency>
207-
<groupId>org.spigotmc...</groupId>
208-
<artifactId>spigot</artifactId>
209-
<version>1.20.1-R0.1-SNAPSHOT</version>
210-
<scope>provided</scope>
211-
</dependency>
212206
</dependencies>
213207

214208
<build>
@@ -318,10 +312,17 @@
318312
</argLine>
319313
</configuration>
320314
</plugin>
321-
<plugin>
322-
<groupId>org.apache.maven.plugins</groupId>
323-
<artifactId>maven-jar-plugin</artifactId>
324-
<version>3.1.0</version>
315+
<plugin>
316+
<groupId>org.apache.maven.plugins</groupId>
317+
<artifactId>maven-jar-plugin</artifactId>
318+
<version>3.4.1</version>
319+
<configuration>
320+
<archive>
321+
<manifestEntries>
322+
<paperweight-mappings-namespace>spigot</paperweight-mappings-namespace>
323+
</manifestEntries>
324+
</archive>
325+
</configuration>
325326
</plugin>
326327
<plugin>
327328
<groupId>org.apache.maven.plugins</groupId>

src/main/java/world/bentobox/boxed/AdvancementsManager.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,11 @@ public int getScore(Advancement a) {
250250
}
251251
if (advConfig.getBoolean("settings.automatic-scoring")) {
252252
if (!a.getKey().getKey().contains("recipes") && a.getDisplay() != null) {
253-
float x = a.getDisplay().getX();
254-
float y = a.getDisplay().getY();
255-
return (int) Math.round(Math.sqrt(x * x + y * y));
253+
int score = 1;
254+
while (a.getParent() != null) {
255+
score++;
256+
}
257+
return score;
256258
} else {
257259
return 0;
258260
}

src/main/java/world/bentobox/boxed/listeners/NewAreaListener.java

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -396,8 +396,7 @@ private void place(ConfigurationSection section, Location center, Environment en
396396
Location location = new Location(world, x, y, z);
397397
//BentoBox.getInstance().logDebug("Structure " + name + " will be placed at " + location);
398398
readyToBuild.computeIfAbsent(new Pair<>(x >> 4, z >> 4), k -> new ArrayList<>())
399-
.add(new StructureRecord(name, "minecraft:" + name, location,
400-
rotation, mirror, noMobs));
399+
.add(new StructureRecord(name, "minecraft:" + name, location, rotation, mirror, noMobs));
401400
this.itemsToBuild
402401
.add(new StructureRecord(name, "minecraft:" + name, location, rotation, mirror, noMobs));
403402
} else {
@@ -508,16 +507,21 @@ private static void processStructureBlock(Block b) {
508507
}
509508

510509
private static void processJigsaw(Block b, StructureRotation structureRotation, boolean pasteMobs) {
511-
String data = nmsData(b);
512-
if (data.isEmpty()) {
513-
return;
514-
}
515-
BoxedJigsawBlock bjb = gson.fromJson(data, BoxedJigsawBlock.class);
516-
String finalState = correctDirection(bjb.getFinal_state(), structureRotation);
517-
BlockData bd = Bukkit.createBlockData(finalState);
518-
b.setBlockData(bd);
519-
if (!bjb.getPool().equalsIgnoreCase("minecraft:empty") && pasteMobs) {
520-
spawnMob(b, bjb);
510+
try {
511+
String data = nmsData(b);
512+
if (data.isEmpty()) {
513+
return;
514+
}
515+
BoxedJigsawBlock bjb = gson.fromJson(data, BoxedJigsawBlock.class);
516+
String finalState = correctDirection(bjb.getFinal_state(), structureRotation);
517+
BlockData bd = Bukkit.createBlockData(finalState);
518+
b.setBlockData(bd);
519+
if (!bjb.getPool().equalsIgnoreCase("minecraft:empty") && pasteMobs) {
520+
spawnMob(b, bjb);
521+
}
522+
} catch (Exception e) {
523+
BentoBox.getInstance().logDebug("We have an error");
524+
e.printStackTrace();
521525
}
522526
}
523527

src/main/java/world/bentobox/boxed/nms/AbstractMetaData.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,20 @@
88
import net.minecraft.nbt.NBTTagCompound;
99
import net.minecraft.network.protocol.game.PacketPlayOutTileEntityData;
1010
import net.minecraft.world.level.block.entity.TileEntity;
11+
import world.bentobox.bentobox.BentoBox;
1112

12-
/**
13-
*
14-
*/
1513
public abstract class AbstractMetaData {
1614

1715
public abstract String nmsData(Block block);
1816

1917
protected String getData(TileEntity te, String method, String field) {
18+
/*
19+
for (Method m : te.getClass().getMethods()) {
20+
BentoBox.getInstance().logDebug(m.getName() + " returns " + m.getReturnType() + " and has these parameters "
21+
+ m.getParameterTypes());
22+
}
23+
te.getUpdateTag();
24+
*/
2025
try {
2126
// Check if the method 'j' exists
2227
Method updatePacketMethod = te.getClass().getDeclaredMethod(method);
@@ -30,7 +35,7 @@ protected String getData(TileEntity te, String method, String field) {
3035
Field fieldC = packet.getClass().getDeclaredField(field);
3136
fieldC.setAccessible(true);
3237
NBTTagCompound nbtTag = (NBTTagCompound) fieldC.get(packet);
33-
38+
3439
return nbtTag.toString(); // This will show what you want
3540
//} else {
3641
// throw new ClassNotFoundException(

src/main/java/world/bentobox/boxed/nms/v1_20_4_R0_1_SNAPSHOT/GetMetaData.java

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/main/java/world/bentobox/boxed/nms/v1_20_6_R0_1_SNAPSHOT/GetMetaData.java

Lines changed: 0 additions & 20 deletions
This file was deleted.
Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
11
package world.bentobox.boxed.nms.v1_21_3_R0_1_SNAPSHOT;
22

3-
public class GetMetaData extends world.bentobox.boxed.nms.v1_21_R0_1_SNAPSHOT.GetMetaData {
4-
// Identical to 1.21
3+
import org.bukkit.Location;
4+
import org.bukkit.block.Block;
5+
import org.bukkit.craftbukkit.v1_21_R2.CraftWorld;
6+
7+
import net.minecraft.core.BlockPosition;
8+
import net.minecraft.world.level.block.entity.TileEntity;
9+
import world.bentobox.boxed.nms.AbstractMetaData;
10+
11+
public class GetMetaData extends AbstractMetaData {
12+
13+
@Override
14+
public String nmsData(Block block) {
15+
Location w = block.getLocation();
16+
CraftWorld cw = (CraftWorld) w.getWorld(); // CraftWorld is NMS one
17+
// for 1.13+ (we have use WorldServer)
18+
TileEntity te = cw.getHandle().c_(new BlockPosition(w.getBlockX(), w.getBlockY(), w.getBlockZ()));
19+
return getData(te, "getUpdatePacket", "tag");
20+
}
21+
522
}

0 commit comments

Comments
 (0)