Skip to content

Commit

Permalink
Limit to 1.21.x Fix for 1.21.3
Browse files Browse the repository at this point in the history
  • Loading branch information
tastybento committed Nov 23, 2024
1 parent 6d66242 commit 3d411d2
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 92 deletions.
61 changes: 31 additions & 30 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
<powermock.version>2.0.9</powermock.version>
<!-- More visible way how to change dependency versions -->
<spigot.version>1.21.3-R0.1-SNAPSHOT</spigot.version>
<paper.version>1.21.3-R0.1-SNAPSHOT</paper.version>
<bentobox.version>2.7.1-SNAPSHOT</bentobox.version>
<!-- Revision variable removes warning about dynamic version -->
<revision>${build.version}-SNAPSHOT</revision>
Expand Down Expand Up @@ -111,6 +112,10 @@
</profiles>

<repositories>
<repository>
<id>papermc</id>
<url>https://repo.papermc.io/repository/maven-public/</url>
</repository>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots</url>
Expand Down Expand Up @@ -139,6 +144,20 @@
</repositories>

<dependencies>
<!-- Paper API -->
<dependency>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
<version>${paper.version}</version>
<scope>provided</scope>
</dependency>
<!-- PaperLib -->
<dependency>
<groupId>io.papermc</groupId>
<artifactId>paperlib</artifactId>
<version>1.0.6</version>
<scope>compile</scope>
</dependency>
<!-- Spigot API -->
<dependency>
<groupId>org.spigotmc</groupId>
Expand Down Expand Up @@ -172,14 +191,7 @@
<scope>provided</scope>
</dependency>
<!-- Spigot NMS. Used for chunk deletion and pasting. -->

<dependency>
<groupId>org.spigotmc....</groupId>
<artifactId>spigot</artifactId>
<version>1.20.6-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>${spigot.version}</version>
Expand All @@ -191,24 +203,6 @@
<version>1.21.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc.</groupId>
<artifactId>spigot</artifactId>
<version>1.20.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc..</groupId>
<artifactId>spigot</artifactId>
<version>1.20.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc...</groupId>
<artifactId>spigot</artifactId>
<version>1.20.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
Expand Down Expand Up @@ -318,10 +312,17 @@
</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.0</version>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.4.1</version>
<configuration>
<archive>
<manifestEntries>
<paperweight-mappings-namespace>spigot</paperweight-mappings-namespace>
</manifestEntries>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/world/bentobox/boxed/AdvancementsManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,11 @@ public int getScore(Advancement a) {
}
if (advConfig.getBoolean("settings.automatic-scoring")) {
if (!a.getKey().getKey().contains("recipes") && a.getDisplay() != null) {
float x = a.getDisplay().getX();
float y = a.getDisplay().getY();
return (int) Math.round(Math.sqrt(x * x + y * y));
int score = 1;
while (a.getParent() != null) {
score++;
}
return score;
} else {
return 0;
}
Expand Down
28 changes: 16 additions & 12 deletions src/main/java/world/bentobox/boxed/listeners/NewAreaListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -396,8 +396,7 @@ private void place(ConfigurationSection section, Location center, Environment en
Location location = new Location(world, x, y, z);
//BentoBox.getInstance().logDebug("Structure " + name + " will be placed at " + location);
readyToBuild.computeIfAbsent(new Pair<>(x >> 4, z >> 4), k -> new ArrayList<>())
.add(new StructureRecord(name, "minecraft:" + name, location,
rotation, mirror, noMobs));
.add(new StructureRecord(name, "minecraft:" + name, location, rotation, mirror, noMobs));
this.itemsToBuild
.add(new StructureRecord(name, "minecraft:" + name, location, rotation, mirror, noMobs));
} else {
Expand Down Expand Up @@ -508,16 +507,21 @@ private static void processStructureBlock(Block b) {
}

private static void processJigsaw(Block b, StructureRotation structureRotation, boolean pasteMobs) {
String data = nmsData(b);
if (data.isEmpty()) {
return;
}
BoxedJigsawBlock bjb = gson.fromJson(data, BoxedJigsawBlock.class);
String finalState = correctDirection(bjb.getFinal_state(), structureRotation);
BlockData bd = Bukkit.createBlockData(finalState);
b.setBlockData(bd);
if (!bjb.getPool().equalsIgnoreCase("minecraft:empty") && pasteMobs) {
spawnMob(b, bjb);
try {
String data = nmsData(b);
if (data.isEmpty()) {
return;
}
BoxedJigsawBlock bjb = gson.fromJson(data, BoxedJigsawBlock.class);
String finalState = correctDirection(bjb.getFinal_state(), structureRotation);
BlockData bd = Bukkit.createBlockData(finalState);
b.setBlockData(bd);
if (!bjb.getPool().equalsIgnoreCase("minecraft:empty") && pasteMobs) {
spawnMob(b, bjb);
}
} catch (Exception e) {
BentoBox.getInstance().logDebug("We have an error");
e.printStackTrace();
}
}

Expand Down
13 changes: 9 additions & 4 deletions src/main/java/world/bentobox/boxed/nms/AbstractMetaData.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,20 @@
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.protocol.game.PacketPlayOutTileEntityData;
import net.minecraft.world.level.block.entity.TileEntity;
import world.bentobox.bentobox.BentoBox;

/**
*
*/
public abstract class AbstractMetaData {

public abstract String nmsData(Block block);

protected String getData(TileEntity te, String method, String field) {
/*
for (Method m : te.getClass().getMethods()) {
BentoBox.getInstance().logDebug(m.getName() + " returns " + m.getReturnType() + " and has these parameters "
+ m.getParameterTypes());
}
te.getUpdateTag();
*/
try {
// Check if the method 'j' exists
Method updatePacketMethod = te.getClass().getDeclaredMethod(method);
Expand All @@ -30,7 +35,7 @@ protected String getData(TileEntity te, String method, String field) {
Field fieldC = packet.getClass().getDeclaredField(field);
fieldC.setAccessible(true);
NBTTagCompound nbtTag = (NBTTagCompound) fieldC.get(packet);

return nbtTag.toString(); // This will show what you want
//} else {
// throw new ClassNotFoundException(
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
package world.bentobox.boxed.nms.v1_21_3_R0_1_SNAPSHOT;

public class GetMetaData extends world.bentobox.boxed.nms.v1_21_R0_1_SNAPSHOT.GetMetaData {
// Identical to 1.21
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v1_21_R2.CraftWorld;

import net.minecraft.core.BlockPosition;
import net.minecraft.world.level.block.entity.TileEntity;
import world.bentobox.boxed.nms.AbstractMetaData;

public class GetMetaData extends AbstractMetaData {

@Override
public String nmsData(Block block) {
Location w = block.getLocation();
CraftWorld cw = (CraftWorld) w.getWorld(); // CraftWorld is NMS one
// for 1.13+ (we have use WorldServer)
TileEntity te = cw.getHandle().c_(new BlockPosition(w.getBlockX(), w.getBlockY(), w.getBlockZ()));
return getData(te, "getUpdatePacket", "tag");
}

}

0 comments on commit 3d411d2

Please sign in to comment.