Minecraft 1.21

This commit is contained in:
LOOHP 2024-06-14 21:00:41 +01:00
parent dfbbc49f67
commit 642c7bd5f4
1592 changed files with 57384 additions and 2685 deletions

View File

@ -1,6 +1,6 @@
# Limbo # Limbo
[![Build Status](http://ci.loohpjames.com/job/Limbo/badge/icon)](http://ci.loohpjames.com/job/Limbo/) [![Build Status](http://ci.loohpjames.com/job/Limbo/badge/icon)](http://ci.loohpjames.com/job/Limbo/)
## Standalone Limbo Minecraft Server (Currently 1.20.6) ## Standalone Limbo Minecraft Server (Currently 1.21)
### Starting the server ### Starting the server
Use the following command lines to start the limbo server just like any other minecraft server Use the following command lines to start the limbo server just like any other minecraft server
@ -16,7 +16,7 @@ IP: mc.loohpjames.com
``` ```
![Server Banner](https://api.loohpjames.com/serverbanner.png?ip=mc.loohpjames.com&width=918&name=IP:%20mc.loohpjames.com) ![Server Banner](https://api.loohpjames.com/serverbanner.png?ip=mc.loohpjames.com&width=918&name=IP:%20mc.loohpjames.com)
*** ***
### Downloads (1.17.1-1.20.6) ### Downloads (1.17.1-1.21)
- [Jenkins](http://ci.loohpjames.com/job/Limbo/) - [Jenkins](http://ci.loohpjames.com/job/Limbo/)
*** ***
### Maven ### Maven

View File

@ -24,7 +24,7 @@
<groupId>com.loohp</groupId> <groupId>com.loohp</groupId>
<artifactId>Limbo</artifactId> <artifactId>Limbo</artifactId>
<name>Limbo</name> <name>Limbo</name>
<version>0.7.9-ALPHA</version> <version>0.7.10-ALPHA</version>
<description>Standalone Limbo Minecraft Server.</description> <description>Standalone Limbo Minecraft Server.</description>
<url>https://github.com/LOOHP/Limbo</url> <url>https://github.com/LOOHP/Limbo</url>
@ -136,7 +136,7 @@
</executions> </executions>
</plugin> </plugin>
</plugins> </plugins>
<finalName>${project.artifactId}-${project.version}-1.20.6</finalName> <finalName>${project.artifactId}-${project.version}-1.21</finalName>
</build> </build>
<profiles> <profiles>

View File

@ -35,9 +35,6 @@ import com.loohp.limbo.inventory.InventoryType;
import com.loohp.limbo.location.Location; import com.loohp.limbo.location.Location;
import com.loohp.limbo.metrics.Metrics; import com.loohp.limbo.metrics.Metrics;
import com.loohp.limbo.network.ServerConnection; import com.loohp.limbo.network.ServerConnection;
import com.loohp.limbo.network.protocol.packets.Packet;
import com.loohp.limbo.network.protocol.packets.PacketIn;
import com.loohp.limbo.network.protocol.packets.PacketOut;
import com.loohp.limbo.network.protocol.packets.PacketPlayOutBoss; import com.loohp.limbo.network.protocol.packets.PacketPlayOutBoss;
import com.loohp.limbo.permissions.PermissionsManager; import com.loohp.limbo.permissions.PermissionsManager;
import com.loohp.limbo.player.Player; import com.loohp.limbo.player.Player;
@ -60,7 +57,6 @@ import net.querz.nbt.io.NBTUtil;
import net.querz.nbt.tag.CompoundTag; import net.querz.nbt.tag.CompoundTag;
import org.json.simple.JSONArray; import org.json.simple.JSONArray;
import org.json.simple.JSONObject; import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException; import org.json.simple.parser.ParseException;
import javax.swing.UnsupportedLookAndFeelException; import javax.swing.UnsupportedLookAndFeelException;
@ -74,13 +70,11 @@ import java.io.InputStreamReader;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.net.URL; import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files; import java.nio.file.Files;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -138,8 +132,8 @@ public final class Limbo {
//=========================== //===========================
public final String SERVER_IMPLEMENTATION_VERSION = "1.20.6"; public final String SERVER_IMPLEMENTATION_VERSION = "1.21";
public final int SERVER_IMPLEMENTATION_PROTOCOL = 766; public final int SERVER_IMPLEMENTATION_PROTOCOL = 767;
public final String LIMBO_IMPLEMENTATION_VERSION; public final String LIMBO_IMPLEMENTATION_VERSION;
private final AtomicBoolean isRunning; private final AtomicBoolean isRunning;
@ -204,95 +198,6 @@ public final class Limbo {
console.sendMessage("Starting Limbo server in bungeecord mode!"); console.sendMessage("Starting Limbo server in bungeecord mode!");
} }
String mappingName = "mapping.json";
InputStream mappingStream = getClass().getClassLoader().getResourceAsStream(mappingName);
if (mappingStream == null) {
throw new RuntimeException("Failed to load " + mappingName + " from jar!");
}
console.sendMessage("Loading packet id mappings...");
InputStreamReader reader = new InputStreamReader(mappingStream, StandardCharsets.UTF_8);
JSONObject json = (JSONObject) new JSONParser().parse(reader);
reader.close();
String classPrefix = Packet.class.getName().substring(0, Packet.class.getName().lastIndexOf(".") + 1);
int mappingsCount = 0;
Map<Integer, Class<? extends PacketIn>> HandshakeIn = new HashMap<>();
for (Object key : ((JSONObject) json.get("HandshakeIn")).keySet()) {
int packetId = Integer.decode((String) key);
HandshakeIn.put(packetId, (Class<? extends PacketIn>) Class.forName(classPrefix + ((JSONObject) json.get("HandshakeIn")).get(key)));
}
Packet.setHandshakeIn(HandshakeIn);
mappingsCount += HandshakeIn.size();
Map<Integer, Class<? extends PacketIn>> StatusIn = new HashMap<>();
for (Object key : ((JSONObject) json.get("StatusIn")).keySet()) {
int packetId = Integer.decode((String) key);
StatusIn.put(packetId, (Class<? extends PacketIn>) Class.forName(classPrefix + ((JSONObject) json.get("StatusIn")).get(key)));
}
Packet.setStatusIn(StatusIn);
mappingsCount += StatusIn.size();
Map<Class<? extends PacketOut>, Integer> StatusOut = new HashMap<>();
for (Object key : ((JSONObject) json.get("StatusOut")).keySet()) {
Class<? extends PacketOut> packetClass = (Class<? extends PacketOut>) Class.forName(classPrefix + key);
StatusOut.put(packetClass, Integer.decode((String) ((JSONObject) json.get("StatusOut")).get(key)));
}
Packet.setStatusOut(StatusOut);
mappingsCount += StatusOut.size();
Map<Integer, Class<? extends PacketIn>> LoginIn = new HashMap<>();
for (Object key : ((JSONObject) json.get("LoginIn")).keySet()) {
int packetId = Integer.decode((String) key);
LoginIn.put(packetId, (Class<? extends PacketIn>) Class.forName(classPrefix + ((JSONObject) json.get("LoginIn")).get(key)));
}
Packet.setLoginIn(LoginIn);
mappingsCount += LoginIn.size();
Map<Class<? extends PacketOut>, Integer> LoginOut = new HashMap<>();
for (Object key : ((JSONObject) json.get("LoginOut")).keySet()) {
Class<? extends PacketOut> packetClass = (Class<? extends PacketOut>) Class.forName(classPrefix + key);
LoginOut.put(packetClass, Integer.decode((String) ((JSONObject) json.get("LoginOut")).get(key)));
}
Packet.setLoginOut(LoginOut);
mappingsCount += LoginOut.size();
Map<Integer, Class<? extends PacketIn>> ConfigurationIn = new HashMap<>();
for (Object key : ((JSONObject) json.get("ConfigurationIn")).keySet()) {
int packetId = Integer.decode((String) key);
ConfigurationIn.put(packetId, (Class<? extends PacketIn>) Class.forName(classPrefix + ((JSONObject) json.get("ConfigurationIn")).get(key)));
}
Packet.setConfigurationIn(ConfigurationIn);
mappingsCount += ConfigurationIn.size();
Map<Class<? extends PacketOut>, Integer> ConfigurationOut = new HashMap<>();
for (Object key : ((JSONObject) json.get("ConfigurationOut")).keySet()) {
Class<? extends PacketOut> packetClass = (Class<? extends PacketOut>) Class.forName(classPrefix + key);
ConfigurationOut.put(packetClass, Integer.decode((String) ((JSONObject) json.get("ConfigurationOut")).get(key)));
}
Packet.setConfigurationOut(ConfigurationOut);
mappingsCount += ConfigurationOut.size();
Map<Integer, Class<? extends PacketIn>> PlayIn = new HashMap<>();
for (Object key : ((JSONObject) json.get("PlayIn")).keySet()) {
int packetId = Integer.decode((String) key);
PlayIn.put(packetId, (Class<? extends PacketIn>) Class.forName(classPrefix + ((JSONObject) json.get("PlayIn")).get(key)));
}
Packet.setPlayIn(PlayIn);
mappingsCount += PlayIn.size();
Map<Class<? extends PacketOut>, Integer> PlayOut = new HashMap<>();
for (Object key : ((JSONObject) json.get("PlayOut")).keySet()) {
Class<? extends PacketOut> packetClass = (Class<? extends PacketOut>) Class.forName(classPrefix + key);
PlayOut.put(packetClass, Integer.decode((String) ((JSONObject) json.get("PlayOut")).get(key)));
}
Packet.setPlayOut(PlayOut);
mappingsCount += PlayOut.size();
console.sendMessage("Loaded all " + mappingsCount + " packet id mappings!");
worlds.add(loadDefaultWorld()); worlds.add(loadDefaultWorld());
Location spawn = properties.getWorldSpawn(); Location spawn = properties.getWorldSpawn();
properties.setWorldSpawn(new Location(getWorld(properties.getLevelName().value()), spawn.getX(), spawn.getY(), spawn.getZ(), spawn.getYaw(), spawn.getPitch())); properties.setWorldSpawn(new Location(getWorld(properties.getLevelName().value()), spawn.getX(), spawn.getY(), spawn.getZ(), spawn.getYaw(), spawn.getPitch()));
@ -346,7 +251,7 @@ public final class Limbo {
} }
} }
server = new ServerConnection(properties.getServerIp(), properties.getServerPort()); server = new ServerConnection(properties.getServerIp(), properties.getServerPort(), false);
metrics = new Metrics(); metrics = new Metrics();

View File

@ -43,7 +43,6 @@ import com.loohp.limbo.inventory.ItemStack;
import com.loohp.limbo.location.Location; import com.loohp.limbo.location.Location;
import com.loohp.limbo.network.protocol.packets.ClientboundFinishConfigurationPacket; import com.loohp.limbo.network.protocol.packets.ClientboundFinishConfigurationPacket;
import com.loohp.limbo.network.protocol.packets.ClientboundRegistryDataPacket; import com.loohp.limbo.network.protocol.packets.ClientboundRegistryDataPacket;
import com.loohp.limbo.network.protocol.packets.Packet;
import com.loohp.limbo.network.protocol.packets.PacketHandshakingIn; import com.loohp.limbo.network.protocol.packets.PacketHandshakingIn;
import com.loohp.limbo.network.protocol.packets.PacketIn; import com.loohp.limbo.network.protocol.packets.PacketIn;
import com.loohp.limbo.network.protocol.packets.PacketLoginInLoginStart; import com.loohp.limbo.network.protocol.packets.PacketLoginInLoginStart;
@ -99,6 +98,7 @@ import com.loohp.limbo.network.protocol.packets.ServerboundLoginAcknowledgedPack
import com.loohp.limbo.player.Player; import com.loohp.limbo.player.Player;
import com.loohp.limbo.player.PlayerInteractManager; import com.loohp.limbo.player.PlayerInteractManager;
import com.loohp.limbo.player.PlayerInventory; import com.loohp.limbo.player.PlayerInventory;
import com.loohp.limbo.registry.PacketRegistry;
import com.loohp.limbo.registry.RegistryCustom; import com.loohp.limbo.registry.RegistryCustom;
import com.loohp.limbo.utils.BungeecordAdventureConversionUtils; import com.loohp.limbo.utils.BungeecordAdventureConversionUtils;
import com.loohp.limbo.utils.CheckedBiConsumer; import com.loohp.limbo.utils.CheckedBiConsumer;
@ -288,26 +288,7 @@ public class ClientConnection extends Thread {
DataInput input = read.getDataInput(); DataInput input = read.getDataInput();
int size = read.getSize(); int size = read.getSize();
int packetId = read.getPacketId(); int packetId = read.getPacketId();
Class<? extends PacketIn> packetType; Class<? extends PacketIn> packetType = PacketRegistry.getPacketClass(packetId, PacketRegistry.NetworkPhase.fromClientState(state), PacketRegistry.PacketBound.SERVERBOUND);
switch (state) {
case HANDSHAKE:
packetType = Packet.getHandshakeIn().get(packetId);
break;
case STATUS:
packetType = Packet.getStatusIn().get(packetId);
break;
case LOGIN:
packetType = Packet.getLoginIn().get(packetId);
break;
case CONFIGURATION:
packetType = Packet.getConfigurationIn().get(packetId);
break;
case PLAY:
packetType = Packet.getPlayIn().get(packetId);
break;
default:
throw new IllegalStateException("Illegal ClientState!");
}
if (packetType == null) { if (packetType == null) {
input.skipBytes(size - DataTypeIO.getVarIntLength(packetId)); input.skipBytes(size - DataTypeIO.getVarIntLength(packetId));
return null; return null;
@ -569,22 +550,10 @@ public class ClientConnection extends Thread {
TimeUnit.MILLISECONDS.sleep(500); TimeUnit.MILLISECONDS.sleep(500);
ClientboundRegistryDataPacket registryDataPacket1 = new ClientboundRegistryDataPacket(RegistryCustom.WORLDGEN_BIOME); for (RegistryCustom registryCustom : RegistryCustom.getRegistries()) {
sendPacket(registryDataPacket1); ClientboundRegistryDataPacket registryDataPacket = new ClientboundRegistryDataPacket(registryCustom);
ClientboundRegistryDataPacket registryDataPacket2 = new ClientboundRegistryDataPacket(RegistryCustom.CHAT_TYPE); sendPacket(registryDataPacket);
sendPacket(registryDataPacket2); }
ClientboundRegistryDataPacket registryDataPacket3 = new ClientboundRegistryDataPacket(RegistryCustom.TRIM_PATTERN);
sendPacket(registryDataPacket3);
ClientboundRegistryDataPacket registryDataPacket4 = new ClientboundRegistryDataPacket(RegistryCustom.TRIM_MATERIAL);
sendPacket(registryDataPacket4);
ClientboundRegistryDataPacket registryDataPacket5 = new ClientboundRegistryDataPacket(RegistryCustom.WOLF_VARIANT);
sendPacket(registryDataPacket5);
ClientboundRegistryDataPacket registryDataPacket6 = new ClientboundRegistryDataPacket(RegistryCustom.DIMENSION_TYPE);
sendPacket(registryDataPacket6);
ClientboundRegistryDataPacket registryDataPacket7 = new ClientboundRegistryDataPacket(RegistryCustom.DAMAGE_TYPE);
sendPacket(registryDataPacket7);
ClientboundRegistryDataPacket registryDataPacket8 = new ClientboundRegistryDataPacket(RegistryCustom.BANNER_PATTERN);
sendPacket(registryDataPacket8);
ClientboundFinishConfigurationPacket clientboundFinishConfigurationPacket = new ClientboundFinishConfigurationPacket(); ClientboundFinishConfigurationPacket clientboundFinishConfigurationPacket = new ClientboundFinishConfigurationPacket();
sendPacket(clientboundFinishConfigurationPacket); sendPacket(clientboundFinishConfigurationPacket);

View File

@ -30,15 +30,17 @@ import java.util.List;
public class ServerConnection extends Thread { public class ServerConnection extends Thread {
private final String ip;
private final int port;
private final boolean silent;
private ServerSocket serverSocket; private ServerSocket serverSocket;
private List<ClientConnection> clients; private List<ClientConnection> clients;
private String ip;
private int port;
public ServerConnection(String ip, int port) { public ServerConnection(String ip, int port, boolean silent) {
clients = new ArrayList<ClientConnection>(); this.clients = new ArrayList<>();
this.ip = ip; this.ip = ip;
this.port = port; this.port = port;
this.silent = silent;
start(); start();
} }
@ -46,7 +48,9 @@ public class ServerConnection extends Thread {
public void run() { public void run() {
try { try {
serverSocket = new ServerSocket(port, 50, InetAddress.getByName(ip)); serverSocket = new ServerSocket(port, 50, InetAddress.getByName(ip));
if (!silent) {
Limbo.getInstance().getConsole().sendMessage("Limbo server listening on /" + serverSocket.getInetAddress().getHostName() + ":" + serverSocket.getLocalPort()); Limbo.getInstance().getConsole().sendMessage("Limbo server listening on /" + serverSocket.getInetAddress().getHostName() + ":" + serverSocket.getLocalPort());
}
while (true) { while (true) {
Socket connection = serverSocket.accept(); Socket connection = serverSocket.accept();
ClientConnection sc = new ClientConnection(connection); ClientConnection sc = new ClientConnection(connection);

View File

@ -19,6 +19,7 @@
package com.loohp.limbo.network.protocol.packets; package com.loohp.limbo.network.protocol.packets;
import com.loohp.limbo.registry.PacketRegistry;
import com.loohp.limbo.utils.DataTypeIO; import com.loohp.limbo.utils.DataTypeIO;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
@ -42,7 +43,7 @@ public class ClientboundChunkBatchFinishedPacket extends PacketOut {
ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ByteArrayOutputStream buffer = new ByteArrayOutputStream();
DataOutputStream output = new DataOutputStream(buffer); DataOutputStream output = new DataOutputStream(buffer);
output.writeByte(Packet.getPlayOut().get(getClass())); output.writeByte(PacketRegistry.getPacketId(getClass()));
DataTypeIO.writeVarInt(output, batchSize); DataTypeIO.writeVarInt(output, batchSize);

View File

@ -19,6 +19,8 @@
package com.loohp.limbo.network.protocol.packets; package com.loohp.limbo.network.protocol.packets;
import com.loohp.limbo.registry.PacketRegistry;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream; import java.io.DataOutputStream;
import java.io.IOException; import java.io.IOException;
@ -33,7 +35,7 @@ public class ClientboundChunkBatchStartPacket extends PacketOut {
ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ByteArrayOutputStream buffer = new ByteArrayOutputStream();
DataOutputStream output = new DataOutputStream(buffer); DataOutputStream output = new DataOutputStream(buffer);
output.writeByte(Packet.getPlayOut().get(getClass())); output.writeByte(PacketRegistry.getPacketId(getClass()));
return buffer.toByteArray(); return buffer.toByteArray();
} }

View File

@ -19,13 +19,15 @@
package com.loohp.limbo.network.protocol.packets; package com.loohp.limbo.network.protocol.packets;
import com.loohp.limbo.registry.PacketRegistry;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream; import java.io.DataOutputStream;
import java.io.IOException; import java.io.IOException;
public class ClientboundClearTitlesPacket extends PacketOut { public class ClientboundClearTitlesPacket extends PacketOut {
private boolean reset; private final boolean reset;
public ClientboundClearTitlesPacket(boolean reset) { public ClientboundClearTitlesPacket(boolean reset) {
this.reset = reset; this.reset = reset;
@ -40,7 +42,7 @@ public class ClientboundClearTitlesPacket extends PacketOut {
ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ByteArrayOutputStream buffer = new ByteArrayOutputStream();
DataOutputStream output = new DataOutputStream(buffer); DataOutputStream output = new DataOutputStream(buffer);
output.writeByte(Packet.getPlayOut().get(getClass())); output.writeByte(PacketRegistry.getPacketId(getClass()));
output.writeBoolean(reset); output.writeBoolean(reset);
return buffer.toByteArray(); return buffer.toByteArray();

View File

@ -19,6 +19,8 @@
package com.loohp.limbo.network.protocol.packets; package com.loohp.limbo.network.protocol.packets;
import com.loohp.limbo.registry.PacketRegistry;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream; import java.io.DataOutputStream;
import java.io.IOException; import java.io.IOException;
@ -33,7 +35,7 @@ public class ClientboundFinishConfigurationPacket extends PacketOut {
ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ByteArrayOutputStream buffer = new ByteArrayOutputStream();
DataOutputStream output = new DataOutputStream(buffer); DataOutputStream output = new DataOutputStream(buffer);
output.writeByte(Packet.getConfigurationOut().get(getClass())); output.writeByte(PacketRegistry.getPacketId(getClass()));
return buffer.toByteArray(); return buffer.toByteArray();
} }

View File

@ -20,6 +20,7 @@
package com.loohp.limbo.network.protocol.packets; package com.loohp.limbo.network.protocol.packets;
import com.loohp.limbo.registry.BuiltInRegistries; import com.loohp.limbo.registry.BuiltInRegistries;
import com.loohp.limbo.registry.PacketRegistry;
import com.loohp.limbo.utils.BitsUtils; import com.loohp.limbo.utils.BitsUtils;
import com.loohp.limbo.utils.DataTypeIO; import com.loohp.limbo.utils.DataTypeIO;
import com.loohp.limbo.world.Environment; import com.loohp.limbo.world.Environment;
@ -40,16 +41,16 @@ import java.util.List;
public class ClientboundLevelChunkWithLightPacket extends PacketOut { public class ClientboundLevelChunkWithLightPacket extends PacketOut {
private int chunkX; private final int chunkX;
private int chunkZ; private final int chunkZ;
private Chunk chunk; private final Chunk chunk;
private Environment environment; private final Environment environment;
private long[] skyLightBitMasks; private final long[] skyLightBitMasks;
private long[] blockLightBitMasks; private final long[] blockLightBitMasks;
private long[] skyLightBitMasksEmpty; private final long[] skyLightBitMasksEmpty;
private long[] blockLightBitMasksEmpty; private final long[] blockLightBitMasksEmpty;
private List<Byte[]> skylightArrays; private final List<Byte[]> skylightArrays;
private List<Byte[]> blocklightArrays; private final List<Byte[]> blocklightArrays;
public ClientboundLevelChunkWithLightPacket(int chunkX, int chunkZ, Chunk chunk, Environment environment, List<Byte[]> skylightArrays, List<Byte[]> blocklightArrays) { public ClientboundLevelChunkWithLightPacket(int chunkX, int chunkZ, Chunk chunk, Environment environment, List<Byte[]> skylightArrays, List<Byte[]> blocklightArrays) {
this.chunkX = chunkX; this.chunkX = chunkX;
@ -115,7 +116,7 @@ public class ClientboundLevelChunkWithLightPacket extends PacketOut {
ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ByteArrayOutputStream buffer = new ByteArrayOutputStream();
DataOutputStream output = new DataOutputStream(buffer); DataOutputStream output = new DataOutputStream(buffer);
output.writeByte(Packet.getPlayOut().get(getClass())); output.writeByte(PacketRegistry.getPacketId(getClass()));
output.writeInt(chunkX); output.writeInt(chunkX);
output.writeInt(chunkZ); output.writeInt(chunkZ);

View File

@ -19,6 +19,7 @@
package com.loohp.limbo.network.protocol.packets; package com.loohp.limbo.network.protocol.packets;
import com.loohp.limbo.registry.PacketRegistry;
import com.loohp.limbo.registry.RegistryCustom; import com.loohp.limbo.registry.RegistryCustom;
import com.loohp.limbo.utils.DataTypeIO; import com.loohp.limbo.utils.DataTypeIO;
import net.kyori.adventure.key.Key; import net.kyori.adventure.key.Key;
@ -47,7 +48,7 @@ public class ClientboundRegistryDataPacket extends PacketOut {
ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ByteArrayOutputStream buffer = new ByteArrayOutputStream();
DataOutputStream output = new DataOutputStream(buffer); DataOutputStream output = new DataOutputStream(buffer);
output.writeByte(Packet.getConfigurationOut().get(getClass())); output.writeByte(PacketRegistry.getPacketId(getClass()));
DataTypeIO.writeString(output, registry.getIdentifier().asString(), StandardCharsets.UTF_8); DataTypeIO.writeString(output, registry.getIdentifier().asString(), StandardCharsets.UTF_8);
DataTypeIO.writeVarInt(output, registry.getEntries().size()); DataTypeIO.writeVarInt(output, registry.getEntries().size());

View File

@ -19,9 +19,9 @@
package com.loohp.limbo.network.protocol.packets; package com.loohp.limbo.network.protocol.packets;
import com.loohp.limbo.registry.PacketRegistry;
import com.loohp.limbo.utils.DataTypeIO; import com.loohp.limbo.utils.DataTypeIO;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream; import java.io.DataOutputStream;
@ -75,7 +75,7 @@ public class ClientboundResourcePackPushPacket extends PacketOut {
ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ByteArrayOutputStream buffer = new ByteArrayOutputStream();
DataOutputStream output = new DataOutputStream(buffer); DataOutputStream output = new DataOutputStream(buffer);
output.writeByte(Packet.getPlayOut().get(getClass())); output.writeByte(PacketRegistry.getPacketId(getClass()));
DataTypeIO.writeUUID(output, id); DataTypeIO.writeUUID(output, id);
DataTypeIO.writeString(output, url, StandardCharsets.UTF_8); DataTypeIO.writeString(output, url, StandardCharsets.UTF_8);
DataTypeIO.writeString(output, hash, StandardCharsets.UTF_8); DataTypeIO.writeString(output, hash, StandardCharsets.UTF_8);

View File

@ -19,6 +19,7 @@
package com.loohp.limbo.network.protocol.packets; package com.loohp.limbo.network.protocol.packets;
import com.loohp.limbo.registry.PacketRegistry;
import com.loohp.limbo.utils.DataTypeIO; import com.loohp.limbo.utils.DataTypeIO;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
@ -28,7 +29,7 @@ import java.io.IOException;
public class ClientboundSetActionBarTextPacket extends PacketOut { public class ClientboundSetActionBarTextPacket extends PacketOut {
private Component actionBar; private final Component actionBar;
public ClientboundSetActionBarTextPacket(Component actionBar) { public ClientboundSetActionBarTextPacket(Component actionBar) {
this.actionBar = actionBar; this.actionBar = actionBar;
@ -43,7 +44,7 @@ public class ClientboundSetActionBarTextPacket extends PacketOut {
ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ByteArrayOutputStream buffer = new ByteArrayOutputStream();
DataOutputStream output = new DataOutputStream(buffer); DataOutputStream output = new DataOutputStream(buffer);
output.writeByte(Packet.getPlayOut().get(getClass())); output.writeByte(PacketRegistry.getPacketId(getClass()));
DataTypeIO.writeComponent(output, actionBar); DataTypeIO.writeComponent(output, actionBar);
return buffer.toByteArray(); return buffer.toByteArray();

View File

@ -19,6 +19,7 @@
package com.loohp.limbo.network.protocol.packets; package com.loohp.limbo.network.protocol.packets;
import com.loohp.limbo.registry.PacketRegistry;
import com.loohp.limbo.utils.DataTypeIO; import com.loohp.limbo.utils.DataTypeIO;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
@ -28,7 +29,7 @@ import java.io.IOException;
public class ClientboundSetSubtitleTextPacket extends PacketOut { public class ClientboundSetSubtitleTextPacket extends PacketOut {
private Component subTitle; private final Component subTitle;
public ClientboundSetSubtitleTextPacket(Component subTitle) { public ClientboundSetSubtitleTextPacket(Component subTitle) {
this.subTitle = subTitle; this.subTitle = subTitle;
@ -43,7 +44,7 @@ public class ClientboundSetSubtitleTextPacket extends PacketOut {
ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ByteArrayOutputStream buffer = new ByteArrayOutputStream();
DataOutputStream output = new DataOutputStream(buffer); DataOutputStream output = new DataOutputStream(buffer);
output.writeByte(Packet.getPlayOut().get(getClass())); output.writeByte(PacketRegistry.getPacketId(getClass()));
DataTypeIO.writeComponent(output, subTitle); DataTypeIO.writeComponent(output, subTitle);
return buffer.toByteArray(); return buffer.toByteArray();

View File

@ -19,6 +19,7 @@
package com.loohp.limbo.network.protocol.packets; package com.loohp.limbo.network.protocol.packets;
import com.loohp.limbo.registry.PacketRegistry;
import com.loohp.limbo.utils.DataTypeIO; import com.loohp.limbo.utils.DataTypeIO;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
@ -28,7 +29,7 @@ import java.io.IOException;
public class ClientboundSetTitleTextPacket extends PacketOut { public class ClientboundSetTitleTextPacket extends PacketOut {
private Component titleText; private final Component titleText;
public ClientboundSetTitleTextPacket(Component titleText) { public ClientboundSetTitleTextPacket(Component titleText) {
this.titleText = titleText; this.titleText = titleText;
@ -43,7 +44,7 @@ public class ClientboundSetTitleTextPacket extends PacketOut {
ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ByteArrayOutputStream buffer = new ByteArrayOutputStream();
DataOutputStream output = new DataOutputStream(buffer); DataOutputStream output = new DataOutputStream(buffer);
output.writeByte(Packet.getPlayOut().get(getClass())); output.writeByte(PacketRegistry.getPacketId(getClass()));
DataTypeIO.writeComponent(output, titleText); DataTypeIO.writeComponent(output, titleText);
return buffer.toByteArray(); return buffer.toByteArray();

View File

@ -19,15 +19,17 @@
package com.loohp.limbo.network.protocol.packets; package com.loohp.limbo.network.protocol.packets;
import com.loohp.limbo.registry.PacketRegistry;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream; import java.io.DataOutputStream;
import java.io.IOException; import java.io.IOException;
public class ClientboundSetTitlesAnimationPacket extends PacketOut { public class ClientboundSetTitlesAnimationPacket extends PacketOut {
private int fadeIn; private final int fadeIn;
private int stay; private final int stay;
private int fadeOut; private final int fadeOut;
public ClientboundSetTitlesAnimationPacket(int fadeIn, int stay, int fadeOut) { public ClientboundSetTitlesAnimationPacket(int fadeIn, int stay, int fadeOut) {
this.fadeIn = fadeIn; this.fadeIn = fadeIn;
@ -52,7 +54,7 @@ public class ClientboundSetTitlesAnimationPacket extends PacketOut {
ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ByteArrayOutputStream buffer = new ByteArrayOutputStream();
DataOutputStream output = new DataOutputStream(buffer); DataOutputStream output = new DataOutputStream(buffer);
output.writeByte(Packet.getPlayOut().get(getClass())); output.writeByte(PacketRegistry.getPacketId(getClass()));
output.writeInt(fadeIn); output.writeInt(fadeIn);
output.writeInt(stay); output.writeInt(stay);

View File

@ -19,6 +19,7 @@
package com.loohp.limbo.network.protocol.packets; package com.loohp.limbo.network.protocol.packets;
import com.loohp.limbo.registry.PacketRegistry;
import com.loohp.limbo.utils.DataTypeIO; import com.loohp.limbo.utils.DataTypeIO;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
@ -28,8 +29,8 @@ import java.io.IOException;
public class ClientboundSystemChatPacket extends PacketOut { public class ClientboundSystemChatPacket extends PacketOut {
private Component message; private final Component message;
private boolean overlay; private final boolean overlay;
public ClientboundSystemChatPacket(Component message, boolean overlay) { public ClientboundSystemChatPacket(Component message, boolean overlay) {
this.message = message; this.message = message;
@ -49,7 +50,7 @@ public class ClientboundSystemChatPacket extends PacketOut {
ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ByteArrayOutputStream buffer = new ByteArrayOutputStream();
DataOutputStream output = new DataOutputStream(buffer); DataOutputStream output = new DataOutputStream(buffer);
output.writeByte(Packet.getPlayOut().get(getClass())); output.writeByte(PacketRegistry.getPacketId(getClass()));
DataTypeIO.writeComponent(output, message); DataTypeIO.writeComponent(output, message);
output.writeBoolean(overlay); output.writeBoolean(overlay);

View File

@ -20,112 +20,12 @@
package com.loohp.limbo.network.protocol.packets; package com.loohp.limbo.network.protocol.packets;
import com.loohp.limbo.network.ClientConnection; import com.loohp.limbo.network.ClientConnection;
import com.loohp.limbo.registry.PacketRegistry;
import java.util.Map;
public abstract class Packet { public abstract class Packet {
private static Map<Integer, Class<? extends PacketIn>> handshakeIn;
private static Map<Integer, Class<? extends PacketIn>> statusIn;
private static Map<Class<? extends PacketOut>, Integer> statusOut;
private static Map<Integer, Class<? extends PacketIn>> loginIn;
private static Map<Class<? extends PacketOut>, Integer> loginOut;
private static Map<Integer, Class<? extends PacketIn>> configurationIn;
private static Map<Class<? extends PacketOut>, Integer> configurationOut;
private static Map<Integer, Class<? extends PacketIn>> playIn;
private static Map<Class<? extends PacketOut>, Integer> playOut;
public static Map<Integer, Class<? extends PacketIn>> getHandshakeIn() {
return handshakeIn;
}
public static void setHandshakeIn(Map<Integer, Class<? extends PacketIn>> handshakeIn) {
Packet.handshakeIn = handshakeIn;
}
public static Map<Integer, Class<? extends PacketIn>> getStatusIn() {
return statusIn;
}
public static void setStatusIn(Map<Integer, Class<? extends PacketIn>> statusIn) {
Packet.statusIn = statusIn;
}
public static Map<Class<? extends PacketOut>, Integer> getStatusOut() {
return statusOut;
}
public static void setStatusOut(Map<Class<? extends PacketOut>, Integer> statusOut) {
Packet.statusOut = statusOut;
}
public static Map<Integer, Class<? extends PacketIn>> getLoginIn() {
return loginIn;
}
public static void setLoginIn(Map<Integer, Class<? extends PacketIn>> loginIn) {
Packet.loginIn = loginIn;
}
public static Map<Class<? extends PacketOut>, Integer> getLoginOut() {
return loginOut;
}
public static void setLoginOut(Map<Class<? extends PacketOut>, Integer> loginOut) {
Packet.loginOut = loginOut;
}
public static Map<Integer, Class<? extends PacketIn>> getConfigurationIn() {
return configurationIn;
}
public static void setConfigurationIn(Map<Integer, Class<? extends PacketIn>> configurationIn) {
Packet.configurationIn = configurationIn;
}
public static Map<Class<? extends PacketOut>, Integer> getConfigurationOut() {
return configurationOut;
}
public static void setConfigurationOut(Map<Class<? extends PacketOut>, Integer> configurationOut) {
Packet.configurationOut = configurationOut;
}
public static Map<Integer, Class<? extends PacketIn>> getPlayIn() {
return playIn;
}
public static void setPlayIn(Map<Integer, Class<? extends PacketIn>> playIn) {
Packet.playIn = playIn;
}
public static Map<Class<? extends PacketOut>, Integer> getPlayOut() {
return playOut;
}
public static void setPlayOut(Map<Class<? extends PacketOut>, Integer> playOut) {
Packet.playOut = playOut;
}
public ClientConnection.ClientState getPacketState() { public ClientConnection.ClientState getPacketState() {
Class<? extends Packet> type = getClass(); return PacketRegistry.getPacketInfo(getClass()).getNetworkPhase().getClientState();
if (handshakeIn.containsValue(type)) {
return ClientConnection.ClientState.HANDSHAKE;
} else if (statusIn.containsValue(type) || statusOut.containsKey(type)) {
return ClientConnection.ClientState.STATUS;
} else if (loginIn.containsValue(type) || loginOut.containsKey(type)) {
return ClientConnection.ClientState.LOGIN;
} else if (configurationIn.containsValue(type) || configurationOut.containsKey(type)) {
return ClientConnection.ClientState.CONFIGURATION;
} else if (playIn.containsValue(type) || playOut.containsKey(type)) {
return ClientConnection.ClientState.PLAY;
} else {
throw new IllegalStateException("This packet of class " + type + " is not registered!");
}
} }
} }

View File

@ -54,10 +54,10 @@ public class PacketHandshakingIn extends PacketIn {
//============================== //==============================
private int protocolVersion; private final int protocolVersion;
private String serverAddress; private final String serverAddress;
private int serverPort; private final int serverPort;
private HandshakeType handshakeType; private final HandshakeType handshakeType;
public PacketHandshakingIn(int protocolVersion, String serverAddress, int serverPort, HandshakeType handshakeType) { public PacketHandshakingIn(int protocolVersion, String serverAddress, int serverPort, HandshakeType handshakeType) {
this.protocolVersion = protocolVersion; this.protocolVersion = protocolVersion;

View File

@ -27,9 +27,9 @@ import java.util.Optional;
public class PacketLoginInPluginMessaging extends PacketIn { public class PacketLoginInPluginMessaging extends PacketIn {
private int messageId; private final int messageId;
private boolean successful; private final boolean successful;
private Optional<byte[]> data; private final Optional<byte[]> data;
public PacketLoginInPluginMessaging(int messageId, boolean successful, byte[] data) { public PacketLoginInPluginMessaging(int messageId, boolean successful, byte[] data) {
this.messageId = messageId; this.messageId = messageId;

View File

@ -19,6 +19,7 @@
package com.loohp.limbo.network.protocol.packets; package com.loohp.limbo.network.protocol.packets;
import com.loohp.limbo.registry.PacketRegistry;
import com.loohp.limbo.utils.DataTypeIO; import com.loohp.limbo.utils.DataTypeIO;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
@ -28,7 +29,7 @@ import java.io.IOException;
public class PacketLoginOutDisconnect extends PacketOut { public class PacketLoginOutDisconnect extends PacketOut {
private Component reason; private final Component reason;
public PacketLoginOutDisconnect(Component reason) { public PacketLoginOutDisconnect(Component reason) {
this.reason = reason; this.reason = reason;
@ -43,7 +44,7 @@ public class PacketLoginOutDisconnect extends PacketOut {
ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ByteArrayOutputStream buffer = new ByteArrayOutputStream();
DataOutputStream output = new DataOutputStream(buffer); DataOutputStream output = new DataOutputStream(buffer);
output.writeByte(Packet.getLoginOut().get(getClass())); output.writeByte(PacketRegistry.getPacketId(getClass()));
DataTypeIO.writeComponent(output, reason); DataTypeIO.writeComponent(output, reason);
return buffer.toByteArray(); return buffer.toByteArray();

View File

@ -19,6 +19,7 @@
package com.loohp.limbo.network.protocol.packets; package com.loohp.limbo.network.protocol.packets;
import com.loohp.limbo.registry.PacketRegistry;
import com.loohp.limbo.utils.DataTypeIO; import com.loohp.limbo.utils.DataTypeIO;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
@ -56,7 +57,7 @@ public class PacketLoginOutLoginSuccess extends PacketOut {
ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ByteArrayOutputStream buffer = new ByteArrayOutputStream();
DataOutputStream output = new DataOutputStream(buffer); DataOutputStream output = new DataOutputStream(buffer);
output.writeByte(Packet.getLoginOut().get(getClass())); output.writeByte(PacketRegistry.getPacketId(getClass()));
DataTypeIO.writeUUID(output, uuid); DataTypeIO.writeUUID(output, uuid);
DataTypeIO.writeString(output, username, StandardCharsets.UTF_8); DataTypeIO.writeString(output, username, StandardCharsets.UTF_8);
DataTypeIO.writeVarInt(output, 0); DataTypeIO.writeVarInt(output, 0);

View File

@ -19,6 +19,7 @@
package com.loohp.limbo.network.protocol.packets; package com.loohp.limbo.network.protocol.packets;
import com.loohp.limbo.registry.PacketRegistry;
import com.loohp.limbo.utils.DataTypeIO; import com.loohp.limbo.utils.DataTypeIO;
import net.kyori.adventure.key.Key; import net.kyori.adventure.key.Key;
@ -29,9 +30,9 @@ import java.nio.charset.StandardCharsets;
public class PacketLoginOutPluginMessaging extends PacketOut { public class PacketLoginOutPluginMessaging extends PacketOut {
private int messageId; private final int messageId;
private Key channel; private final Key channel;
private byte[] data; private final byte[] data;
public PacketLoginOutPluginMessaging(int messageId, Key channel) { public PacketLoginOutPluginMessaging(int messageId, Key channel) {
this(messageId, channel, null); this(messageId, channel, null);
@ -60,7 +61,7 @@ public class PacketLoginOutPluginMessaging extends PacketOut {
ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ByteArrayOutputStream buffer = new ByteArrayOutputStream();
DataOutputStream output = new DataOutputStream(buffer); DataOutputStream output = new DataOutputStream(buffer);
output.writeByte(Packet.getLoginOut().get(getClass())); output.writeByte(PacketRegistry.getPacketId(getClass()));
DataTypeIO.writeVarInt(output, messageId); DataTypeIO.writeVarInt(output, messageId);
DataTypeIO.writeString(output, channel.toString(), StandardCharsets.UTF_8); DataTypeIO.writeString(output, channel.toString(), StandardCharsets.UTF_8);
if (data != null) { if (data != null) {

View File

@ -40,10 +40,10 @@ public class PacketPlayInBlockDig extends PacketIn {
} }
private PlayerDigType action; private final PlayerDigType action;
private BlockPosition pos; private final BlockPosition pos;
private BlockFace direction; private final BlockFace direction;
private int sequence; private final int sequence;
public PacketPlayInBlockDig(PlayerDigType action, BlockPosition pos, BlockFace direction, int sequence) { public PacketPlayInBlockDig(PlayerDigType action, BlockPosition pos, BlockFace direction, int sequence) {
this.action = action; this.action = action;

View File

@ -27,8 +27,8 @@ import java.io.IOException;
public class PacketPlayInBlockPlace extends PacketIn { public class PacketPlayInBlockPlace extends PacketIn {
private EquipmentSlot hand; private final EquipmentSlot hand;
private int sequence; private final int sequence;
public PacketPlayInBlockPlace(EquipmentSlot hand, int sequence) { public PacketPlayInBlockPlace(EquipmentSlot hand, int sequence) {
this.hand = hand; this.hand = hand;

View File

@ -30,11 +30,11 @@ import java.time.Instant;
public class PacketPlayInChat extends PacketIn { public class PacketPlayInChat extends PacketIn {
private String message; private final String message;
private Instant time; private final Instant time;
private long salt; private final long salt;
private MessageSignature signature; private final MessageSignature signature;
private LastSeenMessages.b lastSeenMessages; private final LastSeenMessages.b lastSeenMessages;
public PacketPlayInChat(String message, Instant time, long salt, MessageSignature signature, LastSeenMessages.b lastSeenMessages) { public PacketPlayInChat(String message, Instant time, long salt, MessageSignature signature, LastSeenMessages.b lastSeenMessages) {
this.message = message; this.message = message;

View File

@ -24,7 +24,7 @@ import java.io.IOException;
public class PacketPlayInCloseWindow extends PacketIn { public class PacketPlayInCloseWindow extends PacketIn {
private int containerId; private final int containerId;
public PacketPlayInCloseWindow(int containerId) { public PacketPlayInCloseWindow(int containerId) {
this.containerId = containerId; this.containerId = containerId;

View File

@ -24,7 +24,7 @@ import java.io.IOException;
public class PacketPlayInHeldItemChange extends PacketIn { public class PacketPlayInHeldItemChange extends PacketIn {
private short slot; private final short slot;
public PacketPlayInHeldItemChange(short slot) { public PacketPlayInHeldItemChange(short slot) {
this.slot = slot; this.slot = slot;

View File

@ -27,7 +27,7 @@ import java.nio.charset.StandardCharsets;
public class PacketPlayInItemName extends PacketIn { public class PacketPlayInItemName extends PacketIn {
private String name; private final String name;
public PacketPlayInItemName(String name) { public PacketPlayInItemName(String name) {
this.name = name; this.name = name;

View File

@ -24,7 +24,7 @@ import java.io.IOException;
public class PacketPlayInKeepAlive extends PacketIn { public class PacketPlayInKeepAlive extends PacketIn {
private long payload; private final long payload;
public PacketPlayInKeepAlive(long payload) { public PacketPlayInKeepAlive(long payload) {
this.payload = payload; this.payload = payload;

View File

@ -26,7 +26,7 @@ import java.io.IOException;
public class PacketPlayInPickItem extends PacketIn { public class PacketPlayInPickItem extends PacketIn {
private int slot; private final int slot;
public PacketPlayInPickItem(int slot) { public PacketPlayInPickItem(int slot) {
this.slot = slot; this.slot = slot;

View File

@ -27,8 +27,8 @@ import java.nio.charset.StandardCharsets;
public class PacketPlayInPluginMessaging extends PacketIn { public class PacketPlayInPluginMessaging extends PacketIn {
private String channel; private final String channel;
private byte[] data; private final byte[] data;
public PacketPlayInPluginMessaging(String channel, byte[] data) { public PacketPlayInPluginMessaging(String channel, byte[] data) {
this.channel = channel; this.channel = channel;

View File

@ -24,10 +24,10 @@ import java.io.IOException;
public class PacketPlayInPosition extends PacketIn { public class PacketPlayInPosition extends PacketIn {
private double x; private final double x;
private double y; private final double y;
private double z; private final double z;
private boolean onGround; private final boolean onGround;
public PacketPlayInPosition(double x, double y, double z, boolean onGround) { public PacketPlayInPosition(double x, double y, double z, boolean onGround) {
this.x = x; this.x = x;

View File

@ -24,12 +24,12 @@ import java.io.IOException;
public class PacketPlayInPositionAndLook extends PacketIn { public class PacketPlayInPositionAndLook extends PacketIn {
private double x; private final double x;
private double y; private final double y;
private double z; private final double z;
private float yaw; private final float yaw;
private float pitch; private final float pitch;
private boolean onGround; private final boolean onGround;
public PacketPlayInPositionAndLook(double x, double y, double z, float yaw, float pitch, boolean onGround) { public PacketPlayInPositionAndLook(double x, double y, double z, float yaw, float pitch, boolean onGround) {
this.x = x; this.x = x;

View File

@ -24,9 +24,9 @@ import java.io.IOException;
public class PacketPlayInRotation extends PacketIn { public class PacketPlayInRotation extends PacketIn {
private float yaw; private final float yaw;
private float pitch; private final float pitch;
private boolean onGround; private final boolean onGround;
public PacketPlayInRotation(float yaw, float pitch, boolean onGround) { public PacketPlayInRotation(float yaw, float pitch, boolean onGround) {
this.yaw = yaw; this.yaw = yaw;

View File

@ -27,8 +27,8 @@ import java.nio.charset.StandardCharsets;
public class PacketPlayInTabComplete extends PacketIn { public class PacketPlayInTabComplete extends PacketIn {
private int id; private final int id;
private String text; private final String text;
public PacketPlayInTabComplete(int id, String text) { public PacketPlayInTabComplete(int id, String text) {
this.id = id; this.id = id;

View File

@ -28,9 +28,9 @@ import java.io.IOException;
public class PacketPlayInUseItem extends PacketIn { public class PacketPlayInUseItem extends PacketIn {
private EquipmentSlot hand; private final EquipmentSlot hand;
private MovingObjectPositionBlock blockHit; private final MovingObjectPositionBlock blockHit;
private int sequence; private final int sequence;
public PacketPlayInUseItem(EquipmentSlot hand, MovingObjectPositionBlock blockHit, int sequence) { public PacketPlayInUseItem(EquipmentSlot hand, MovingObjectPositionBlock blockHit, int sequence) {
this.hand = hand; this.hand = hand;

View File

@ -20,6 +20,7 @@
package com.loohp.limbo.network.protocol.packets; package com.loohp.limbo.network.protocol.packets;
import com.loohp.limbo.bossbar.KeyedBossBar; import com.loohp.limbo.bossbar.KeyedBossBar;
import com.loohp.limbo.registry.PacketRegistry;
import com.loohp.limbo.utils.DataTypeIO; import com.loohp.limbo.utils.DataTypeIO;
import net.kyori.adventure.bossbar.BossBar; import net.kyori.adventure.bossbar.BossBar;
@ -52,8 +53,8 @@ public class PacketPlayOutBoss extends PacketOut {
return i; return i;
} }
private KeyedBossBar bossBar; private final KeyedBossBar bossBar;
private BossBarAction action; private final BossBarAction action;
public PacketPlayOutBoss(KeyedBossBar bossBar, BossBarAction action) { public PacketPlayOutBoss(KeyedBossBar bossBar, BossBarAction action) {
this.bossBar = bossBar; this.bossBar = bossBar;
@ -73,7 +74,7 @@ public class PacketPlayOutBoss extends PacketOut {
ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ByteArrayOutputStream buffer = new ByteArrayOutputStream();
DataOutputStream output = new DataOutputStream(buffer); DataOutputStream output = new DataOutputStream(buffer);
output.writeByte(Packet.getPlayOut().get(getClass())); output.writeByte(PacketRegistry.getPacketId(getClass()));
DataTypeIO.writeUUID(output, bossBar.getUniqueId()); DataTypeIO.writeUUID(output, bossBar.getUniqueId());
DataTypeIO.writeVarInt(output, action.ordinal()); DataTypeIO.writeVarInt(output, action.ordinal());

View File

@ -19,13 +19,15 @@
package com.loohp.limbo.network.protocol.packets; package com.loohp.limbo.network.protocol.packets;
import com.loohp.limbo.registry.PacketRegistry;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream; import java.io.DataOutputStream;
import java.io.IOException; import java.io.IOException;
public class PacketPlayOutCloseWindow extends PacketOut { public class PacketPlayOutCloseWindow extends PacketOut {
private int containerId; private final int containerId;
public PacketPlayOutCloseWindow(int containerId) { public PacketPlayOutCloseWindow(int containerId) {
this.containerId = containerId; this.containerId = containerId;
@ -40,7 +42,7 @@ public class PacketPlayOutCloseWindow extends PacketOut {
ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ByteArrayOutputStream buffer = new ByteArrayOutputStream();
DataOutputStream output = new DataOutputStream(buffer); DataOutputStream output = new DataOutputStream(buffer);
output.writeByte(Packet.getPlayOut().get(getClass())); output.writeByte(PacketRegistry.getPacketId(getClass()));
output.writeByte(containerId); output.writeByte(containerId);

View File

@ -19,13 +19,15 @@
package com.loohp.limbo.network.protocol.packets; package com.loohp.limbo.network.protocol.packets;
import com.loohp.limbo.registry.PacketRegistry;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream; import java.io.DataOutputStream;
import java.io.IOException; import java.io.IOException;
public class PacketPlayOutDeclareCommands extends PacketOut { public class PacketPlayOutDeclareCommands extends PacketOut {
private byte[] data; private final byte[] data;
public PacketPlayOutDeclareCommands(byte[] data) { public PacketPlayOutDeclareCommands(byte[] data) {
this.data = data; this.data = data;
@ -40,7 +42,7 @@ public class PacketPlayOutDeclareCommands extends PacketOut {
ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ByteArrayOutputStream buffer = new ByteArrayOutputStream();
DataOutputStream output = new DataOutputStream(buffer); DataOutputStream output = new DataOutputStream(buffer);
output.writeByte(Packet.getPlayOut().get(getClass())); output.writeByte(PacketRegistry.getPacketId(getClass()));
output.write(data); output.write(data);
return buffer.toByteArray(); return buffer.toByteArray();

View File

@ -19,6 +19,7 @@
package com.loohp.limbo.network.protocol.packets; package com.loohp.limbo.network.protocol.packets;
import com.loohp.limbo.registry.PacketRegistry;
import com.loohp.limbo.utils.DataTypeIO; import com.loohp.limbo.utils.DataTypeIO;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
@ -28,7 +29,7 @@ import java.io.IOException;
public class PacketPlayOutDisconnect extends PacketOut { public class PacketPlayOutDisconnect extends PacketOut {
private Component reason; private final Component reason;
public PacketPlayOutDisconnect(Component reason) { public PacketPlayOutDisconnect(Component reason) {
this.reason = reason; this.reason = reason;
@ -43,7 +44,7 @@ public class PacketPlayOutDisconnect extends PacketOut {
ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ByteArrayOutputStream buffer = new ByteArrayOutputStream();
DataOutputStream output = new DataOutputStream(buffer); DataOutputStream output = new DataOutputStream(buffer);
output.writeByte(Packet.getPlayOut().get(getClass())); output.writeByte(PacketRegistry.getPacketId(getClass()));
DataTypeIO.writeComponent(output, reason); DataTypeIO.writeComponent(output, reason);
return buffer.toByteArray(); return buffer.toByteArray();

View File

@ -19,6 +19,7 @@
package com.loohp.limbo.network.protocol.packets; package com.loohp.limbo.network.protocol.packets;
import com.loohp.limbo.registry.PacketRegistry;
import com.loohp.limbo.utils.DataTypeIO; import com.loohp.limbo.utils.DataTypeIO;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
@ -27,7 +28,7 @@ import java.io.IOException;
public class PacketPlayOutEntityDestroy extends PacketOut { public class PacketPlayOutEntityDestroy extends PacketOut {
private int[] entityIds; private final int[] entityIds;
public PacketPlayOutEntityDestroy(int... entityIds) { public PacketPlayOutEntityDestroy(int... entityIds) {
this.entityIds = entityIds; this.entityIds = entityIds;
@ -42,7 +43,7 @@ public class PacketPlayOutEntityDestroy extends PacketOut {
ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ByteArrayOutputStream buffer = new ByteArrayOutputStream();
DataOutputStream output = new DataOutputStream(buffer); DataOutputStream output = new DataOutputStream(buffer);
output.writeByte(Packet.getPlayOut().get(getClass())); output.writeByte(PacketRegistry.getPacketId(getClass()));
DataTypeIO.writeVarInt(output, entityIds.length); DataTypeIO.writeVarInt(output, entityIds.length);
for (int entityId : entityIds) { for (int entityId : entityIds) {
DataTypeIO.writeVarInt(output, entityId); DataTypeIO.writeVarInt(output, entityId);

View File

@ -23,6 +23,7 @@ import com.loohp.limbo.entity.DataWatcher.WatchableObject;
import com.loohp.limbo.entity.DataWatcher.WatchableObjectType; import com.loohp.limbo.entity.DataWatcher.WatchableObjectType;
import com.loohp.limbo.entity.Entity; import com.loohp.limbo.entity.Entity;
import com.loohp.limbo.entity.Pose; import com.loohp.limbo.entity.Pose;
import com.loohp.limbo.registry.PacketRegistry;
import com.loohp.limbo.utils.DataTypeIO; import com.loohp.limbo.utils.DataTypeIO;
import com.loohp.limbo.utils.Rotation3f; import com.loohp.limbo.utils.Rotation3f;
import com.loohp.limbo.world.BlockPosition; import com.loohp.limbo.world.BlockPosition;
@ -45,9 +46,9 @@ public class PacketPlayOutEntityMetadata extends PacketOut {
public static final int END_OFF_METADATA = 0xff; public static final int END_OFF_METADATA = 0xff;
private Entity entity; private final Entity entity;
public boolean allFields; public final boolean allFields;
public Field[] fields; public final Field[] fields;
public PacketPlayOutEntityMetadata(Entity entity, boolean allFields, Field... fields) { public PacketPlayOutEntityMetadata(Entity entity, boolean allFields, Field... fields) {
this.entity = entity; this.entity = entity;
@ -68,7 +69,7 @@ public class PacketPlayOutEntityMetadata extends PacketOut {
ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ByteArrayOutputStream buffer = new ByteArrayOutputStream();
DataOutputStream output = new DataOutputStream(buffer); DataOutputStream output = new DataOutputStream(buffer);
output.writeByte(Packet.getPlayOut().get(getClass())); output.writeByte(PacketRegistry.getPacketId(getClass()));
DataTypeIO.writeVarInt(output, entity.getEntityId()); DataTypeIO.writeVarInt(output, entity.getEntityId());
Collection<WatchableObject> watches; Collection<WatchableObject> watches;
if (allFields) { if (allFields) {

View File

@ -19,6 +19,8 @@
package com.loohp.limbo.network.protocol.packets; package com.loohp.limbo.network.protocol.packets;
import com.loohp.limbo.registry.PacketRegistry;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream; import java.io.DataOutputStream;
import java.io.IOException; import java.io.IOException;
@ -52,8 +54,8 @@ public class PacketPlayOutGameStateChange extends PacketOut {
} }
} }
private GameStateChangeEvent event; private final GameStateChangeEvent event;
private float value; private final float value;
public PacketPlayOutGameStateChange(GameStateChangeEvent event, float value) { public PacketPlayOutGameStateChange(GameStateChangeEvent event, float value) {
this.event = event; this.event = event;
@ -72,7 +74,7 @@ public class PacketPlayOutGameStateChange extends PacketOut {
ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ByteArrayOutputStream buffer = new ByteArrayOutputStream();
DataOutputStream output = new DataOutputStream(buffer); DataOutputStream output = new DataOutputStream(buffer);
output.writeByte(Packet.getPlayOut().get(getClass())); output.writeByte(PacketRegistry.getPacketId(getClass()));
output.writeByte(event.getId()); output.writeByte(event.getId());
output.writeFloat(value); output.writeFloat(value);

View File

@ -19,6 +19,8 @@
package com.loohp.limbo.network.protocol.packets; package com.loohp.limbo.network.protocol.packets;
import com.loohp.limbo.registry.PacketRegistry;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream; import java.io.DataOutputStream;
import java.io.IOException; import java.io.IOException;
@ -40,7 +42,7 @@ public class PacketPlayOutHeldItemChange extends PacketOut {
ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ByteArrayOutputStream buffer = new ByteArrayOutputStream();
DataOutputStream output = new DataOutputStream(buffer); DataOutputStream output = new DataOutputStream(buffer);
output.writeByte(Packet.getPlayOut().get(getClass())); output.writeByte(PacketRegistry.getPacketId(getClass()));
output.writeByte(slot); output.writeByte(slot);
return buffer.toByteArray(); return buffer.toByteArray();

View File

@ -19,13 +19,15 @@
package com.loohp.limbo.network.protocol.packets; package com.loohp.limbo.network.protocol.packets;
import com.loohp.limbo.registry.PacketRegistry;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream; import java.io.DataOutputStream;
import java.io.IOException; import java.io.IOException;
public class PacketPlayOutKeepAlive extends PacketOut { public class PacketPlayOutKeepAlive extends PacketOut {
private long payload; private final long payload;
public PacketPlayOutKeepAlive(long payload) { public PacketPlayOutKeepAlive(long payload) {
this.payload = payload; this.payload = payload;
@ -40,7 +42,7 @@ public class PacketPlayOutKeepAlive extends PacketOut {
ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ByteArrayOutputStream buffer = new ByteArrayOutputStream();
DataOutputStream output = new DataOutputStream(buffer); DataOutputStream output = new DataOutputStream(buffer);
output.writeByte(Packet.getPlayOut().get(getClass())); output.writeByte(PacketRegistry.getPacketId(getClass()));
output.writeLong(payload); output.writeLong(payload);
return buffer.toByteArray(); return buffer.toByteArray();

View File

@ -19,6 +19,7 @@
package com.loohp.limbo.network.protocol.packets; package com.loohp.limbo.network.protocol.packets;
import com.loohp.limbo.registry.PacketRegistry;
import com.loohp.limbo.registry.RegistryCustom; import com.loohp.limbo.registry.RegistryCustom;
import com.loohp.limbo.utils.DataTypeIO; import com.loohp.limbo.utils.DataTypeIO;
import com.loohp.limbo.utils.GameMode; import com.loohp.limbo.utils.GameMode;
@ -145,7 +146,7 @@ public class PacketPlayOutLogin extends PacketOut {
ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ByteArrayOutputStream buffer = new ByteArrayOutputStream();
DataOutputStream output = new DataOutputStream(buffer); DataOutputStream output = new DataOutputStream(buffer);
output.writeByte(Packet.getPlayOut().get(getClass())); output.writeByte(PacketRegistry.getPacketId(getClass()));
output.writeInt(entityId); output.writeInt(entityId);
output.writeBoolean(isHardcore); output.writeBoolean(isHardcore);
DataTypeIO.writeVarInt(output, worlds.size()); DataTypeIO.writeVarInt(output, worlds.size());

View File

@ -19,6 +19,7 @@
package com.loohp.limbo.network.protocol.packets; package com.loohp.limbo.network.protocol.packets;
import com.loohp.limbo.registry.PacketRegistry;
import com.loohp.limbo.sounds.SoundEffect; import com.loohp.limbo.sounds.SoundEffect;
import com.loohp.limbo.utils.DataTypeIO; import com.loohp.limbo.utils.DataTypeIO;
import net.kyori.adventure.sound.Sound; import net.kyori.adventure.sound.Sound;
@ -31,14 +32,14 @@ import java.util.Optional;
public class PacketPlayOutNamedSoundEffect extends PacketOut { public class PacketPlayOutNamedSoundEffect extends PacketOut {
private SoundEffect sound; private final SoundEffect sound;
private Sound.Source source; private final Sound.Source source;
private int x; private final int x;
private int y; private final int y;
private int z; private final int z;
private float volume; private final float volume;
private float pitch; private final float pitch;
private long seed; private final long seed;
public PacketPlayOutNamedSoundEffect(SoundEffect sound, Sound.Source source, double x, double y, double z, float volume, float pitch, long seed) { public PacketPlayOutNamedSoundEffect(SoundEffect sound, Sound.Source source, double x, double y, double z, float volume, float pitch, long seed) {
this.sound = sound; this.sound = sound;
@ -88,7 +89,7 @@ public class PacketPlayOutNamedSoundEffect extends PacketOut {
ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ByteArrayOutputStream buffer = new ByteArrayOutputStream();
DataOutputStream output = new DataOutputStream(buffer); DataOutputStream output = new DataOutputStream(buffer);
output.writeByte(Packet.getPlayOut().get(getClass())); output.writeByte(PacketRegistry.getPacketId(getClass()));
DataTypeIO.writeVarInt(output, 0); DataTypeIO.writeVarInt(output, 0);
DataTypeIO.writeString(output, sound.getSound().toString(), StandardCharsets.UTF_8); DataTypeIO.writeString(output, sound.getSound().toString(), StandardCharsets.UTF_8);

View File

@ -20,6 +20,7 @@
package com.loohp.limbo.network.protocol.packets; package com.loohp.limbo.network.protocol.packets;
import com.loohp.limbo.registry.BuiltInRegistries; import com.loohp.limbo.registry.BuiltInRegistries;
import com.loohp.limbo.registry.PacketRegistry;
import com.loohp.limbo.utils.DataTypeIO; import com.loohp.limbo.utils.DataTypeIO;
import net.kyori.adventure.key.Key; import net.kyori.adventure.key.Key;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
@ -30,9 +31,9 @@ import java.io.IOException;
public class PacketPlayOutOpenWindow extends PacketOut { public class PacketPlayOutOpenWindow extends PacketOut {
private int containerId; private final int containerId;
private Key type; private final Key type;
private Component title; private final Component title;
public PacketPlayOutOpenWindow(int containerId, Key type, Component title) { public PacketPlayOutOpenWindow(int containerId, Key type, Component title) {
this.containerId = containerId; this.containerId = containerId;
@ -57,7 +58,7 @@ public class PacketPlayOutOpenWindow extends PacketOut {
ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ByteArrayOutputStream buffer = new ByteArrayOutputStream();
DataOutputStream output = new DataOutputStream(buffer); DataOutputStream output = new DataOutputStream(buffer);
output.writeByte(Packet.getPlayOut().get(getClass())); output.writeByte(PacketRegistry.getPacketId(getClass()));
DataTypeIO.writeVarInt(output, containerId); DataTypeIO.writeVarInt(output, containerId);
DataTypeIO.writeVarInt(output, BuiltInRegistries.MENU_REGISTRY.getId(type)); DataTypeIO.writeVarInt(output, BuiltInRegistries.MENU_REGISTRY.getId(type));

View File

@ -19,6 +19,8 @@
package com.loohp.limbo.network.protocol.packets; package com.loohp.limbo.network.protocol.packets;
import com.loohp.limbo.registry.PacketRegistry;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream; import java.io.DataOutputStream;
import java.io.IOException; import java.io.IOException;
@ -42,9 +44,9 @@ public class PacketPlayOutPlayerAbilities extends PacketOut {
} }
} }
private PlayerAbilityFlags[] flags; private final PlayerAbilityFlags[] flags;
private float flySpeed; private final float flySpeed;
private float fieldOfField; private final float fieldOfField;
public PacketPlayOutPlayerAbilities(float flySpeed, float fieldOfField, PlayerAbilityFlags... flags) { public PacketPlayOutPlayerAbilities(float flySpeed, float fieldOfField, PlayerAbilityFlags... flags) {
this.flags = flags; this.flags = flags;
@ -69,7 +71,7 @@ public class PacketPlayOutPlayerAbilities extends PacketOut {
ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ByteArrayOutputStream buffer = new ByteArrayOutputStream();
DataOutputStream output = new DataOutputStream(buffer); DataOutputStream output = new DataOutputStream(buffer);
output.writeByte(Packet.getPlayOut().get(getClass())); output.writeByte(PacketRegistry.getPacketId(getClass()));
byte value = 0; byte value = 0;
for (PlayerAbilityFlags flag : flags) { for (PlayerAbilityFlags flag : flags) {
value = (byte) (value | flag.getValue()); value = (byte) (value | flag.getValue());

View File

@ -20,6 +20,7 @@
package com.loohp.limbo.network.protocol.packets; package com.loohp.limbo.network.protocol.packets;
import com.loohp.limbo.network.protocol.packets.PacketPlayOutPlayerInfo.PlayerInfoData.PlayerInfoDataAddPlayer; import com.loohp.limbo.network.protocol.packets.PacketPlayOutPlayerInfo.PlayerInfoData.PlayerInfoDataAddPlayer;
import com.loohp.limbo.registry.PacketRegistry;
import com.loohp.limbo.utils.DataTypeIO; import com.loohp.limbo.utils.DataTypeIO;
import com.loohp.limbo.utils.GameMode; import com.loohp.limbo.utils.GameMode;
@ -42,9 +43,9 @@ public class PacketPlayOutPlayerInfo extends PacketOut {
UPDATE_DISPLAY_NAME; UPDATE_DISPLAY_NAME;
} }
private EnumSet<PlayerInfoAction> actions; private final EnumSet<PlayerInfoAction> actions;
private UUID uuid; private final UUID uuid;
private PlayerInfoData data; private final PlayerInfoData data;
public PacketPlayOutPlayerInfo(EnumSet<PlayerInfoAction> actions, UUID uuid, PlayerInfoData data) { public PacketPlayOutPlayerInfo(EnumSet<PlayerInfoAction> actions, UUID uuid, PlayerInfoData data) {
this.actions = actions; this.actions = actions;
@ -69,7 +70,7 @@ public class PacketPlayOutPlayerInfo extends PacketOut {
ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ByteArrayOutputStream buffer = new ByteArrayOutputStream();
DataOutputStream output = new DataOutputStream(buffer); DataOutputStream output = new DataOutputStream(buffer);
output.writeByte(Packet.getPlayOut().get(getClass())); output.writeByte(PacketRegistry.getPacketId(getClass()));
DataTypeIO.writeEnumSet(output, actions, PlayerInfoAction.class); DataTypeIO.writeEnumSet(output, actions, PlayerInfoAction.class);
DataTypeIO.writeVarInt(output, 1); DataTypeIO.writeVarInt(output, 1);

View File

@ -19,6 +19,7 @@
package com.loohp.limbo.network.protocol.packets; package com.loohp.limbo.network.protocol.packets;
import com.loohp.limbo.registry.PacketRegistry;
import com.loohp.limbo.utils.DataTypeIO; import com.loohp.limbo.utils.DataTypeIO;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
@ -28,8 +29,8 @@ import java.io.IOException;
public class PacketPlayOutPlayerListHeaderFooter extends PacketOut{ public class PacketPlayOutPlayerListHeaderFooter extends PacketOut{
private Component header; private final Component header;
private Component footer; private final Component footer;
public PacketPlayOutPlayerListHeaderFooter(Component header, Component footer) { public PacketPlayOutPlayerListHeaderFooter(Component header, Component footer) {
this.header = header; this.header = header;
@ -50,7 +51,7 @@ public class PacketPlayOutPlayerListHeaderFooter extends PacketOut{
ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ByteArrayOutputStream buffer = new ByteArrayOutputStream();
DataOutputStream output = new DataOutputStream(buffer); DataOutputStream output = new DataOutputStream(buffer);
output.writeByte(Packet.getPlayOut().get(getClass())); output.writeByte(PacketRegistry.getPacketId(getClass()));
DataTypeIO.writeComponent(output, header); DataTypeIO.writeComponent(output, header);
DataTypeIO.writeComponent(output, footer); DataTypeIO.writeComponent(output, footer);
return buffer.toByteArray(); return buffer.toByteArray();

View File

@ -19,6 +19,7 @@
package com.loohp.limbo.network.protocol.packets; package com.loohp.limbo.network.protocol.packets;
import com.loohp.limbo.registry.PacketRegistry;
import com.loohp.limbo.utils.DataTypeIO; import com.loohp.limbo.utils.DataTypeIO;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
@ -28,8 +29,8 @@ import java.nio.charset.StandardCharsets;
public class PacketPlayOutPluginMessaging extends PacketOut { public class PacketPlayOutPluginMessaging extends PacketOut {
private String channel; private final String channel;
private byte[] data; private final byte[] data;
public PacketPlayOutPluginMessaging(String channel, byte[] data) { public PacketPlayOutPluginMessaging(String channel, byte[] data) {
this.channel = channel; this.channel = channel;
@ -49,7 +50,7 @@ public class PacketPlayOutPluginMessaging extends PacketOut {
ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ByteArrayOutputStream buffer = new ByteArrayOutputStream();
DataOutputStream output = new DataOutputStream(buffer); DataOutputStream output = new DataOutputStream(buffer);
output.writeByte(Packet.getPlayOut().get(getClass())); output.writeByte(PacketRegistry.getPacketId(getClass()));
DataTypeIO.writeString(output, channel, StandardCharsets.UTF_8); DataTypeIO.writeString(output, channel, StandardCharsets.UTF_8);
output.write(data); output.write(data);

View File

@ -19,6 +19,7 @@
package com.loohp.limbo.network.protocol.packets; package com.loohp.limbo.network.protocol.packets;
import com.loohp.limbo.registry.PacketRegistry;
import com.loohp.limbo.utils.DataTypeIO; import com.loohp.limbo.utils.DataTypeIO;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
@ -48,13 +49,13 @@ public class PacketPlayOutPositionAndLook extends PacketOut {
} }
} }
private double x; private final double x;
private double y; private final double y;
private double z; private final double z;
private float yaw; private final float yaw;
private float pitch; private final float pitch;
private Set<PlayerTeleportFlags> flags; private final Set<PlayerTeleportFlags> flags;
private int teleportId; private final int teleportId;
public PacketPlayOutPositionAndLook(double x, double y, double z, float yaw, float pitch, int teleportId, PlayerTeleportFlags... flags) { public PacketPlayOutPositionAndLook(double x, double y, double z, float yaw, float pitch, int teleportId, PlayerTeleportFlags... flags) {
this.x = x; this.x = x;
@ -99,7 +100,7 @@ public class PacketPlayOutPositionAndLook extends PacketOut {
ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ByteArrayOutputStream buffer = new ByteArrayOutputStream();
DataOutputStream output = new DataOutputStream(buffer); DataOutputStream output = new DataOutputStream(buffer);
output.writeByte(Packet.getPlayOut().get(getClass())); output.writeByte(PacketRegistry.getPacketId(getClass()));
output.writeDouble(x); output.writeDouble(x);
output.writeDouble(y); output.writeDouble(y);
output.writeDouble(z); output.writeDouble(z);

View File

@ -19,14 +19,13 @@
package com.loohp.limbo.network.protocol.packets; package com.loohp.limbo.network.protocol.packets;
import com.loohp.limbo.registry.PacketRegistry;
import com.loohp.limbo.registry.RegistryCustom; import com.loohp.limbo.registry.RegistryCustom;
import com.loohp.limbo.utils.DataTypeIO; import com.loohp.limbo.utils.DataTypeIO;
import com.loohp.limbo.utils.GameMode; import com.loohp.limbo.utils.GameMode;
import com.loohp.limbo.world.Environment; import com.loohp.limbo.world.Environment;
import com.loohp.limbo.world.World; import com.loohp.limbo.world.World;
import net.kyori.adventure.key.Key; import net.kyori.adventure.key.Key;
import net.querz.nbt.tag.CompoundTag;
import net.querz.nbt.tag.ListTag;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream; import java.io.DataOutputStream;
@ -35,13 +34,13 @@ import java.nio.charset.StandardCharsets;
public class PacketPlayOutRespawn extends PacketOut { public class PacketPlayOutRespawn extends PacketOut {
private Environment dimension; private final Environment dimension;
private World world; private final World world;
private long hashedSeed; private final long hashedSeed;
private GameMode gamemode; private final GameMode gamemode;
private boolean isDebug; private final boolean isDebug;
private boolean isFlat; private final boolean isFlat;
private boolean copyMetaData; private final boolean copyMetaData;
public PacketPlayOutRespawn(World world, long hashedSeed, GameMode gamemode, boolean isDebug, boolean isFlat, boolean copyMetaData) { public PacketPlayOutRespawn(World world, long hashedSeed, GameMode gamemode, boolean isDebug, boolean isFlat, boolean copyMetaData) {
this.dimension = world.getEnvironment(); this.dimension = world.getEnvironment();
@ -86,7 +85,7 @@ public class PacketPlayOutRespawn extends PacketOut {
ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ByteArrayOutputStream buffer = new ByteArrayOutputStream();
DataOutputStream output = new DataOutputStream(buffer); DataOutputStream output = new DataOutputStream(buffer);
output.writeByte(Packet.getPlayOut().get(getClass())); output.writeByte(PacketRegistry.getPacketId(getClass()));
DataTypeIO.writeVarInt(output, RegistryCustom.DIMENSION_TYPE.indexOf(world.getEnvironment().getKey())); DataTypeIO.writeVarInt(output, RegistryCustom.DIMENSION_TYPE.indexOf(world.getEnvironment().getKey()));
DataTypeIO.writeString(output, Key.key(world.getName()).toString(), StandardCharsets.UTF_8); DataTypeIO.writeString(output, Key.key(world.getName()).toString(), StandardCharsets.UTF_8);

View File

@ -20,6 +20,7 @@
package com.loohp.limbo.network.protocol.packets; package com.loohp.limbo.network.protocol.packets;
import com.loohp.limbo.inventory.ItemStack; import com.loohp.limbo.inventory.ItemStack;
import com.loohp.limbo.registry.PacketRegistry;
import com.loohp.limbo.utils.DataTypeIO; import com.loohp.limbo.utils.DataTypeIO;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
@ -61,7 +62,7 @@ public class PacketPlayOutSetSlot extends PacketOut {
ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ByteArrayOutputStream buffer = new ByteArrayOutputStream();
DataOutputStream output = new DataOutputStream(buffer); DataOutputStream output = new DataOutputStream(buffer);
output.writeByte(Packet.getPlayOut().get(getClass())); output.writeByte(PacketRegistry.getPacketId(getClass()));
output.writeByte(containerId); output.writeByte(containerId);
DataTypeIO.writeVarInt(output, stateId); DataTypeIO.writeVarInt(output, stateId);

View File

@ -20,6 +20,7 @@
package com.loohp.limbo.network.protocol.packets; package com.loohp.limbo.network.protocol.packets;
import com.loohp.limbo.entity.EntityType; import com.loohp.limbo.entity.EntityType;
import com.loohp.limbo.registry.PacketRegistry;
import com.loohp.limbo.utils.DataTypeIO; import com.loohp.limbo.utils.DataTypeIO;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
@ -29,19 +30,19 @@ import java.util.UUID;
public class PacketPlayOutSpawnEntity extends PacketOut { public class PacketPlayOutSpawnEntity extends PacketOut {
private int entityId; private final int entityId;
private UUID uuid; private final UUID uuid;
private EntityType type; private final EntityType type;
private double x; private final double x;
private double y; private final double y;
private double z; private final double z;
private float pitch; private final float pitch;
private float yaw; private final float yaw;
private float headYaw; private final float headYaw;
private int data; private final int data;
private short velocityX; private final short velocityX;
private short velocityY; private final short velocityY;
private short velocityZ; private final short velocityZ;
public PacketPlayOutSpawnEntity(int entityId, UUID uuid, EntityType type, double x, double y, double z, float pitch, float yaw, float headYaw, int data, short velocityX, short velocityY, short velocityZ) { public PacketPlayOutSpawnEntity(int entityId, UUID uuid, EntityType type, double x, double y, double z, float pitch, float yaw, float headYaw, int data, short velocityX, short velocityY, short velocityZ) {
this.entityId = entityId; this.entityId = entityId;
@ -116,7 +117,7 @@ public class PacketPlayOutSpawnEntity extends PacketOut {
ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ByteArrayOutputStream buffer = new ByteArrayOutputStream();
DataOutputStream output = new DataOutputStream(buffer); DataOutputStream output = new DataOutputStream(buffer);
output.writeByte(Packet.getPlayOut().get(getClass())); output.writeByte(PacketRegistry.getPacketId(getClass()));
DataTypeIO.writeVarInt(output, entityId); DataTypeIO.writeVarInt(output, entityId);
DataTypeIO.writeUUID(output, uuid); DataTypeIO.writeUUID(output, uuid);
DataTypeIO.writeVarInt(output, type.getTypeId()); DataTypeIO.writeVarInt(output, type.getTypeId());

View File

@ -19,6 +19,7 @@
package com.loohp.limbo.network.protocol.packets; package com.loohp.limbo.network.protocol.packets;
import com.loohp.limbo.registry.PacketRegistry;
import com.loohp.limbo.utils.DataTypeIO; import com.loohp.limbo.utils.DataTypeIO;
import com.loohp.limbo.world.BlockPosition; import com.loohp.limbo.world.BlockPosition;
@ -28,8 +29,8 @@ import java.io.IOException;
public class PacketPlayOutSpawnPosition extends PacketOut { public class PacketPlayOutSpawnPosition extends PacketOut {
private BlockPosition position; private final BlockPosition position;
private float angle; private final float angle;
public PacketPlayOutSpawnPosition(BlockPosition position, float angle) { public PacketPlayOutSpawnPosition(BlockPosition position, float angle) {
this.position = position; this.position = position;
@ -48,7 +49,7 @@ public class PacketPlayOutSpawnPosition extends PacketOut {
ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ByteArrayOutputStream buffer = new ByteArrayOutputStream();
DataOutputStream output = new DataOutputStream(buffer); DataOutputStream output = new DataOutputStream(buffer);
output.writeByte(Packet.getPlayOut().get(getClass())); output.writeByte(PacketRegistry.getPacketId(getClass()));
DataTypeIO.writeBlockPosition(output, position); DataTypeIO.writeBlockPosition(output, position);
output.writeFloat(angle); output.writeFloat(angle);

View File

@ -19,6 +19,7 @@
package com.loohp.limbo.network.protocol.packets; package com.loohp.limbo.network.protocol.packets;
import com.loohp.limbo.registry.PacketRegistry;
import com.loohp.limbo.utils.DataTypeIO; import com.loohp.limbo.utils.DataTypeIO;
import net.kyori.adventure.key.Key; import net.kyori.adventure.key.Key;
import net.kyori.adventure.sound.Sound; import net.kyori.adventure.sound.Sound;
@ -30,8 +31,8 @@ import java.nio.charset.StandardCharsets;
public class PacketPlayOutStopSound extends PacketOut { public class PacketPlayOutStopSound extends PacketOut {
private Key sound; private final Key sound;
private Sound.Source source; private final Sound.Source source;
public PacketPlayOutStopSound(Key sound, Sound.Source source) { public PacketPlayOutStopSound(Key sound, Sound.Source source) {
this.sound = sound; this.sound = sound;
@ -51,7 +52,7 @@ public class PacketPlayOutStopSound extends PacketOut {
ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ByteArrayOutputStream buffer = new ByteArrayOutputStream();
DataOutputStream output = new DataOutputStream(buffer); DataOutputStream output = new DataOutputStream(buffer);
output.writeByte(Packet.getPlayOut().get(getClass())); output.writeByte(PacketRegistry.getPacketId(getClass()));
if (source != null) { if (source != null) {
if (sound != null) { if (sound != null) {

View File

@ -19,6 +19,7 @@
package com.loohp.limbo.network.protocol.packets; package com.loohp.limbo.network.protocol.packets;
import com.loohp.limbo.registry.PacketRegistry;
import com.loohp.limbo.utils.DataTypeIO; import com.loohp.limbo.utils.DataTypeIO;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
@ -30,10 +31,10 @@ import java.util.Optional;
public class PacketPlayOutTabComplete extends PacketOut { public class PacketPlayOutTabComplete extends PacketOut {
private int id; private final int id;
private int start; private final int start;
private int length; private final int length;
private TabCompleteMatches[] matches; private final TabCompleteMatches[] matches;
public PacketPlayOutTabComplete(int id, int start, int length, TabCompleteMatches... matches) { public PacketPlayOutTabComplete(int id, int start, int length, TabCompleteMatches... matches) {
this.id = id; this.id = id;
@ -63,7 +64,7 @@ public class PacketPlayOutTabComplete extends PacketOut {
ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ByteArrayOutputStream buffer = new ByteArrayOutputStream();
DataOutputStream output = new DataOutputStream(buffer); DataOutputStream output = new DataOutputStream(buffer);
output.writeByte(Packet.getPlayOut().get(getClass())); output.writeByte(PacketRegistry.getPacketId(getClass()));
DataTypeIO.writeVarInt(output, id); DataTypeIO.writeVarInt(output, id);
DataTypeIO.writeVarInt(output, start); DataTypeIO.writeVarInt(output, start);
DataTypeIO.writeVarInt(output, length); DataTypeIO.writeVarInt(output, length);

View File

@ -19,14 +19,16 @@
package com.loohp.limbo.network.protocol.packets; package com.loohp.limbo.network.protocol.packets;
import com.loohp.limbo.registry.PacketRegistry;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream; import java.io.DataOutputStream;
import java.io.IOException; import java.io.IOException;
public class PacketPlayOutUnloadChunk extends PacketOut { public class PacketPlayOutUnloadChunk extends PacketOut {
private int chunkX; private final int chunkX;
private int chunkZ; private final int chunkZ;
public PacketPlayOutUnloadChunk(int chunkX, int chunkZ) { public PacketPlayOutUnloadChunk(int chunkX, int chunkZ) {
this.chunkX = chunkX; this.chunkX = chunkX;
@ -46,7 +48,7 @@ public class PacketPlayOutUnloadChunk extends PacketOut {
ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ByteArrayOutputStream buffer = new ByteArrayOutputStream();
DataOutputStream output = new DataOutputStream(buffer); DataOutputStream output = new DataOutputStream(buffer);
output.writeByte(Packet.getPlayOut().get(getClass())); output.writeByte(PacketRegistry.getPacketId(getClass()));
output.writeInt(chunkX); output.writeInt(chunkX);
output.writeInt(chunkZ); output.writeInt(chunkZ);

View File

@ -19,6 +19,7 @@
package com.loohp.limbo.network.protocol.packets; package com.loohp.limbo.network.protocol.packets;
import com.loohp.limbo.registry.PacketRegistry;
import com.loohp.limbo.utils.DataTypeIO; import com.loohp.limbo.utils.DataTypeIO;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
@ -27,8 +28,8 @@ import java.io.IOException;
public class PacketPlayOutUpdateViewPosition extends PacketOut { public class PacketPlayOutUpdateViewPosition extends PacketOut {
private int chunkX; private final int chunkX;
private int chunkZ; private final int chunkZ;
public PacketPlayOutUpdateViewPosition(int chunkX, int chunkZ) { public PacketPlayOutUpdateViewPosition(int chunkX, int chunkZ) {
this.chunkX = chunkX; this.chunkX = chunkX;
@ -48,7 +49,7 @@ public class PacketPlayOutUpdateViewPosition extends PacketOut {
ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ByteArrayOutputStream buffer = new ByteArrayOutputStream();
DataOutputStream output = new DataOutputStream(buffer); DataOutputStream output = new DataOutputStream(buffer);
output.writeByte(Packet.getPlayOut().get(getClass())); output.writeByte(PacketRegistry.getPacketId(getClass()));
DataTypeIO.writeVarInt(output, chunkX); DataTypeIO.writeVarInt(output, chunkX);
DataTypeIO.writeVarInt(output, chunkZ); DataTypeIO.writeVarInt(output, chunkZ);

View File

@ -19,15 +19,17 @@
package com.loohp.limbo.network.protocol.packets; package com.loohp.limbo.network.protocol.packets;
import com.loohp.limbo.registry.PacketRegistry;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream; import java.io.DataOutputStream;
import java.io.IOException; import java.io.IOException;
public class PacketPlayOutWindowData extends PacketOut { public class PacketPlayOutWindowData extends PacketOut {
private int containerId; private final int containerId;
private int id; private final int id;
private int value; private final int value;
public PacketPlayOutWindowData(int containerId, int id, int value) { public PacketPlayOutWindowData(int containerId, int id, int value) {
this.containerId = containerId; this.containerId = containerId;
@ -52,7 +54,7 @@ public class PacketPlayOutWindowData extends PacketOut {
ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ByteArrayOutputStream buffer = new ByteArrayOutputStream();
DataOutputStream output = new DataOutputStream(buffer); DataOutputStream output = new DataOutputStream(buffer);
output.writeByte(Packet.getPlayOut().get(getClass())); output.writeByte(PacketRegistry.getPacketId(getClass()));
output.writeByte(containerId); output.writeByte(containerId);
output.writeShort(id); output.writeShort(id);

View File

@ -20,6 +20,7 @@
package com.loohp.limbo.network.protocol.packets; package com.loohp.limbo.network.protocol.packets;
import com.loohp.limbo.inventory.ItemStack; import com.loohp.limbo.inventory.ItemStack;
import com.loohp.limbo.registry.PacketRegistry;
import com.loohp.limbo.utils.DataTypeIO; import com.loohp.limbo.utils.DataTypeIO;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
@ -29,10 +30,10 @@ import java.util.List;
public class PacketPlayOutWindowItems extends PacketOut { public class PacketPlayOutWindowItems extends PacketOut {
private int containerId; private final int containerId;
private int stateId; private final int stateId;
private List<ItemStack> items; private final List<ItemStack> items;
private ItemStack carriedItem; private final ItemStack carriedItem;
public PacketPlayOutWindowItems(int containerId, int stateId, List<ItemStack> items, ItemStack carriedItem) { public PacketPlayOutWindowItems(int containerId, int stateId, List<ItemStack> items, ItemStack carriedItem) {
this.containerId = containerId; this.containerId = containerId;
@ -62,7 +63,7 @@ public class PacketPlayOutWindowItems extends PacketOut {
ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ByteArrayOutputStream buffer = new ByteArrayOutputStream();
DataOutputStream output = new DataOutputStream(buffer); DataOutputStream output = new DataOutputStream(buffer);
output.writeByte(Packet.getPlayOut().get(getClass())); output.writeByte(PacketRegistry.getPacketId(getClass()));
output.writeByte(containerId); output.writeByte(containerId);
DataTypeIO.writeVarInt(output, stateId); DataTypeIO.writeVarInt(output, stateId);

View File

@ -24,7 +24,7 @@ import java.io.IOException;
public class PacketStatusInPing extends PacketIn { public class PacketStatusInPing extends PacketIn {
private long payload; private final long payload;
public PacketStatusInPing(long payload) { public PacketStatusInPing(long payload) {
this.payload = payload; this.payload = payload;

View File

@ -24,7 +24,6 @@ import java.io.DataInputStream;
public class PacketStatusInRequest extends PacketIn { public class PacketStatusInRequest extends PacketIn {
public PacketStatusInRequest() { public PacketStatusInRequest() {
} }
public PacketStatusInRequest(DataInputStream in) { public PacketStatusInRequest(DataInputStream in) {

View File

@ -19,13 +19,15 @@
package com.loohp.limbo.network.protocol.packets; package com.loohp.limbo.network.protocol.packets;
import com.loohp.limbo.registry.PacketRegistry;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream; import java.io.DataOutputStream;
import java.io.IOException; import java.io.IOException;
public class PacketStatusOutPong extends PacketOut { public class PacketStatusOutPong extends PacketOut {
private long payload; private final long payload;
public PacketStatusOutPong(long payload) { public PacketStatusOutPong(long payload) {
this.payload = payload; this.payload = payload;
@ -40,7 +42,7 @@ public class PacketStatusOutPong extends PacketOut {
ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ByteArrayOutputStream buffer = new ByteArrayOutputStream();
DataOutputStream output = new DataOutputStream(buffer); DataOutputStream output = new DataOutputStream(buffer);
output.writeByte(Packet.getStatusOut().get(getClass())); output.writeByte(PacketRegistry.getPacketId(getClass()));
output.writeLong(payload); output.writeLong(payload);
return buffer.toByteArray(); return buffer.toByteArray();

View File

@ -19,6 +19,7 @@
package com.loohp.limbo.network.protocol.packets; package com.loohp.limbo.network.protocol.packets;
import com.loohp.limbo.registry.PacketRegistry;
import com.loohp.limbo.utils.DataTypeIO; import com.loohp.limbo.utils.DataTypeIO;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
@ -28,7 +29,7 @@ import java.nio.charset.StandardCharsets;
public class PacketStatusOutResponse extends PacketOut { public class PacketStatusOutResponse extends PacketOut {
private String json; private final String json;
public PacketStatusOutResponse(String json) { public PacketStatusOutResponse(String json) {
this.json = json; this.json = json;
@ -43,7 +44,7 @@ public class PacketStatusOutResponse extends PacketOut {
ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ByteArrayOutputStream buffer = new ByteArrayOutputStream();
DataOutputStream output = new DataOutputStream(buffer); DataOutputStream output = new DataOutputStream(buffer);
output.writeByte(Packet.getStatusOut().get(getClass())); output.writeByte(PacketRegistry.getPacketId(getClass()));
DataTypeIO.writeString(output, json, StandardCharsets.UTF_8); DataTypeIO.writeString(output, json, StandardCharsets.UTF_8);
return buffer.toByteArray(); return buffer.toByteArray();

View File

@ -0,0 +1,349 @@
/*
* This file is part of Limbo.
*
* Copyright (C) 2024. LoohpJames <jamesloohp@gmail.com>
* Copyright (C) 2024. Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.loohp.limbo.registry;
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
import com.loohp.limbo.Limbo;
import com.loohp.limbo.network.ClientConnection;
import com.loohp.limbo.network.protocol.packets.ClientboundChunkBatchFinishedPacket;
import com.loohp.limbo.network.protocol.packets.ClientboundChunkBatchStartPacket;
import com.loohp.limbo.network.protocol.packets.ClientboundClearTitlesPacket;
import com.loohp.limbo.network.protocol.packets.ClientboundFinishConfigurationPacket;
import com.loohp.limbo.network.protocol.packets.ClientboundLevelChunkWithLightPacket;
import com.loohp.limbo.network.protocol.packets.ClientboundRegistryDataPacket;
import com.loohp.limbo.network.protocol.packets.ClientboundResourcePackPushPacket;
import com.loohp.limbo.network.protocol.packets.ClientboundSetActionBarTextPacket;
import com.loohp.limbo.network.protocol.packets.ClientboundSetSubtitleTextPacket;
import com.loohp.limbo.network.protocol.packets.ClientboundSetTitleTextPacket;
import com.loohp.limbo.network.protocol.packets.ClientboundSetTitlesAnimationPacket;
import com.loohp.limbo.network.protocol.packets.ClientboundSystemChatPacket;
import com.loohp.limbo.network.protocol.packets.Packet;
import com.loohp.limbo.network.protocol.packets.PacketHandshakingIn;
import com.loohp.limbo.network.protocol.packets.PacketLoginInLoginStart;
import com.loohp.limbo.network.protocol.packets.PacketLoginInPluginMessaging;
import com.loohp.limbo.network.protocol.packets.PacketLoginOutDisconnect;
import com.loohp.limbo.network.protocol.packets.PacketLoginOutLoginSuccess;
import com.loohp.limbo.network.protocol.packets.PacketLoginOutPluginMessaging;
import com.loohp.limbo.network.protocol.packets.PacketPlayInBlockDig;
import com.loohp.limbo.network.protocol.packets.PacketPlayInBlockPlace;
import com.loohp.limbo.network.protocol.packets.PacketPlayInChat;
import com.loohp.limbo.network.protocol.packets.PacketPlayInCloseWindow;
import com.loohp.limbo.network.protocol.packets.PacketPlayInHeldItemChange;
import com.loohp.limbo.network.protocol.packets.PacketPlayInItemName;
import com.loohp.limbo.network.protocol.packets.PacketPlayInKeepAlive;
import com.loohp.limbo.network.protocol.packets.PacketPlayInPickItem;
import com.loohp.limbo.network.protocol.packets.PacketPlayInPluginMessaging;
import com.loohp.limbo.network.protocol.packets.PacketPlayInPosition;
import com.loohp.limbo.network.protocol.packets.PacketPlayInPositionAndLook;
import com.loohp.limbo.network.protocol.packets.PacketPlayInRotation;
import com.loohp.limbo.network.protocol.packets.PacketPlayInSetCreativeSlot;
import com.loohp.limbo.network.protocol.packets.PacketPlayInTabComplete;
import com.loohp.limbo.network.protocol.packets.PacketPlayInUseItem;
import com.loohp.limbo.network.protocol.packets.PacketPlayInWindowClick;
import com.loohp.limbo.network.protocol.packets.PacketPlayOutBoss;
import com.loohp.limbo.network.protocol.packets.PacketPlayOutCloseWindow;
import com.loohp.limbo.network.protocol.packets.PacketPlayOutDeclareCommands;
import com.loohp.limbo.network.protocol.packets.PacketPlayOutDisconnect;
import com.loohp.limbo.network.protocol.packets.PacketPlayOutEntityDestroy;
import com.loohp.limbo.network.protocol.packets.PacketPlayOutEntityMetadata;
import com.loohp.limbo.network.protocol.packets.PacketPlayOutGameStateChange;
import com.loohp.limbo.network.protocol.packets.PacketPlayOutHeldItemChange;
import com.loohp.limbo.network.protocol.packets.PacketPlayOutKeepAlive;
import com.loohp.limbo.network.protocol.packets.PacketPlayOutLogin;
import com.loohp.limbo.network.protocol.packets.PacketPlayOutNamedSoundEffect;
import com.loohp.limbo.network.protocol.packets.PacketPlayOutOpenWindow;
import com.loohp.limbo.network.protocol.packets.PacketPlayOutPlayerAbilities;
import com.loohp.limbo.network.protocol.packets.PacketPlayOutPlayerInfo;
import com.loohp.limbo.network.protocol.packets.PacketPlayOutPlayerListHeaderFooter;
import com.loohp.limbo.network.protocol.packets.PacketPlayOutPluginMessaging;
import com.loohp.limbo.network.protocol.packets.PacketPlayOutPositionAndLook;
import com.loohp.limbo.network.protocol.packets.PacketPlayOutRespawn;
import com.loohp.limbo.network.protocol.packets.PacketPlayOutSetSlot;
import com.loohp.limbo.network.protocol.packets.PacketPlayOutSpawnEntity;
import com.loohp.limbo.network.protocol.packets.PacketPlayOutSpawnPosition;
import com.loohp.limbo.network.protocol.packets.PacketPlayOutStopSound;
import com.loohp.limbo.network.protocol.packets.PacketPlayOutTabComplete;
import com.loohp.limbo.network.protocol.packets.PacketPlayOutUnloadChunk;
import com.loohp.limbo.network.protocol.packets.PacketPlayOutUpdateViewPosition;
import com.loohp.limbo.network.protocol.packets.PacketPlayOutWindowData;
import com.loohp.limbo.network.protocol.packets.PacketPlayOutWindowItems;
import com.loohp.limbo.network.protocol.packets.PacketStatusInPing;
import com.loohp.limbo.network.protocol.packets.PacketStatusInRequest;
import com.loohp.limbo.network.protocol.packets.PacketStatusOutPong;
import com.loohp.limbo.network.protocol.packets.PacketStatusOutResponse;
import com.loohp.limbo.network.protocol.packets.ServerboundChatCommandPacket;
import com.loohp.limbo.network.protocol.packets.ServerboundFinishConfigurationPacket;
import com.loohp.limbo.network.protocol.packets.ServerboundLoginAcknowledgedPacket;
import com.loohp.limbo.network.protocol.packets.ServerboundResourcePackPacket;
import net.kyori.adventure.key.Key;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
@SuppressWarnings("PatternValidation")
public class PacketRegistry {
private static final Map<NetworkPhase, Map<PacketBound, BiMap<Key, Integer>>> ID_REGISTRY = new HashMap<>();
private static final BiMap<Class<? extends Packet>, PacketClassInfo> CLASS_REGISTRY = HashBiMap.create();
static {
String name = "reports/packets.json";
InputStream inputStream = Limbo.class.getClassLoader().getResourceAsStream(name);
if (inputStream == null) {
throw new RuntimeException("Failed to load " + name + " from jar!");
}
try (InputStreamReader reader = new InputStreamReader(inputStream, StandardCharsets.UTF_8)) {
JSONObject json = (JSONObject) new JSONParser().parse(reader);
for (Object objKey : json.keySet()) {
String key = (String) objKey;
NetworkPhase networkPhase = NetworkPhase.fromName(key);
Map<PacketBound, BiMap<Key, Integer>> mappings = new HashMap<>();
JSONObject jsonMappings = (JSONObject) json.get(key);
for (Object objBoundKey : jsonMappings.keySet()) {
String boundKey = (String) objBoundKey;
PacketBound packetBound = PacketBound.fromName(boundKey);
BiMap<Key, Integer> idMapping = HashBiMap.create();
JSONObject jsonIds = (JSONObject) jsonMappings.get(boundKey);
for (Object objPacketKey : jsonIds.keySet()) {
String packetKey = (String) objPacketKey;
idMapping.put(Key.key(packetKey), (int) (long) ((JSONObject) jsonIds.get(packetKey)).get("protocol_id"));
}
mappings.put(packetBound, idMapping);
}
ID_REGISTRY.put(networkPhase, mappings);
}
} catch (IOException | ParseException e) {
e.printStackTrace();
}
registerClass(PacketHandshakingIn.class, "minecraft:intention", NetworkPhase.HANDSHAKE, PacketBound.SERVERBOUND);
registerClass(PacketStatusInRequest.class, "minecraft:status_request", NetworkPhase.STATUS, PacketBound.SERVERBOUND);
registerClass(PacketStatusInPing.class, "minecraft:ping_request", NetworkPhase.STATUS, PacketBound.SERVERBOUND);
registerClass(PacketStatusOutResponse.class, "minecraft:status_response", NetworkPhase.STATUS, PacketBound.CLIENTBOUND);
registerClass(PacketStatusOutPong.class, "minecraft:pong_response", NetworkPhase.STATUS, PacketBound.CLIENTBOUND);
registerClass(PacketLoginInLoginStart.class, "minecraft:hello", NetworkPhase.LOGIN, PacketBound.SERVERBOUND);
registerClass(PacketLoginInPluginMessaging.class, "minecraft:custom_query_answer", NetworkPhase.LOGIN, PacketBound.SERVERBOUND);
registerClass(ServerboundLoginAcknowledgedPacket.class, "minecraft:login_acknowledged", NetworkPhase.LOGIN, PacketBound.SERVERBOUND);
registerClass(PacketLoginOutLoginSuccess.class, "minecraft:game_profile", NetworkPhase.LOGIN, PacketBound.CLIENTBOUND);
registerClass(PacketLoginOutDisconnect.class, "minecraft:login_disconnect", NetworkPhase.LOGIN, PacketBound.CLIENTBOUND);
registerClass(PacketLoginOutPluginMessaging.class, "minecraft:custom_query", NetworkPhase.LOGIN, PacketBound.CLIENTBOUND);
registerClass(ServerboundFinishConfigurationPacket.class, "minecraft:finish_configuration", NetworkPhase.CONFIGURATION, PacketBound.SERVERBOUND);
registerClass(ClientboundRegistryDataPacket.class, "minecraft:registry_data", NetworkPhase.CONFIGURATION, PacketBound.CLIENTBOUND);
registerClass(ClientboundFinishConfigurationPacket.class, "minecraft:finish_configuration", NetworkPhase.CONFIGURATION, PacketBound.CLIENTBOUND);
registerClass(PacketPlayInKeepAlive.class, "minecraft:keep_alive", NetworkPhase.PLAY, PacketBound.SERVERBOUND);
registerClass(ServerboundChatCommandPacket.class, "minecraft:chat_command", NetworkPhase.PLAY, PacketBound.SERVERBOUND);
registerClass(PacketPlayInChat.class, "minecraft:chat", NetworkPhase.PLAY, PacketBound.SERVERBOUND);
registerClass(PacketPlayInPosition.class, "minecraft:move_player_pos", NetworkPhase.PLAY, PacketBound.SERVERBOUND);
registerClass(PacketPlayInPositionAndLook.class, "minecraft:move_player_pos_rot", NetworkPhase.PLAY, PacketBound.SERVERBOUND);
registerClass(PacketPlayInRotation.class, "minecraft:move_player_rot", NetworkPhase.PLAY, PacketBound.SERVERBOUND);
registerClass(PacketPlayInPluginMessaging.class, "minecraft:custom_payload", NetworkPhase.PLAY, PacketBound.SERVERBOUND);
registerClass(PacketPlayInTabComplete.class, "minecraft:command_suggestion", NetworkPhase.PLAY, PacketBound.SERVERBOUND);
registerClass(PacketPlayInHeldItemChange.class, "minecraft:set_carried_item", NetworkPhase.PLAY, PacketBound.SERVERBOUND);
registerClass(ServerboundResourcePackPacket.class, "minecraft:resource_pack", NetworkPhase.PLAY, PacketBound.SERVERBOUND);
registerClass(PacketPlayInUseItem.class, "minecraft:use_item_on", NetworkPhase.PLAY, PacketBound.SERVERBOUND);
registerClass(PacketPlayInBlockPlace.class, "minecraft:use_item", NetworkPhase.PLAY, PacketBound.SERVERBOUND);
registerClass(PacketPlayInSetCreativeSlot.class, "minecraft:set_creative_mode_slot", NetworkPhase.PLAY, PacketBound.SERVERBOUND);
registerClass(PacketPlayInWindowClick.class, "minecraft:container_click", NetworkPhase.PLAY, PacketBound.SERVERBOUND);
registerClass(PacketPlayInCloseWindow.class, "minecraft:container_close", NetworkPhase.PLAY, PacketBound.SERVERBOUND);
registerClass(PacketPlayInPickItem.class, "minecraft:pick_item", NetworkPhase.PLAY, PacketBound.SERVERBOUND);
registerClass(PacketPlayInBlockDig.class, "minecraft:player_action", NetworkPhase.PLAY, PacketBound.SERVERBOUND);
registerClass(PacketPlayInItemName.class, "minecraft:rename_item", NetworkPhase.PLAY, PacketBound.SERVERBOUND);
registerClass(PacketPlayOutLogin.class, "minecraft:login", NetworkPhase.PLAY, PacketBound.CLIENTBOUND);
registerClass(PacketPlayOutPositionAndLook.class, "minecraft:player_position", NetworkPhase.PLAY, PacketBound.CLIENTBOUND);
registerClass(PacketPlayOutSpawnPosition.class, "minecraft:set_default_spawn_position", NetworkPhase.PLAY, PacketBound.CLIENTBOUND);
registerClass(ClientboundSystemChatPacket.class, "minecraft:system_chat", NetworkPhase.PLAY, PacketBound.CLIENTBOUND);
registerClass(PacketPlayOutPlayerAbilities.class, "minecraft:player_abilities", NetworkPhase.PLAY, PacketBound.CLIENTBOUND);
registerClass(ClientboundLevelChunkWithLightPacket.class, "minecraft:level_chunk_with_light", NetworkPhase.PLAY, PacketBound.CLIENTBOUND);
registerClass(PacketPlayOutUnloadChunk.class, "minecraft:forget_level_chunk", NetworkPhase.PLAY, PacketBound.CLIENTBOUND);
registerClass(PacketPlayOutKeepAlive.class, "minecraft:keep_alive", NetworkPhase.PLAY, PacketBound.CLIENTBOUND);
registerClass(PacketPlayOutGameStateChange.class, "minecraft:game_event", NetworkPhase.PLAY, PacketBound.CLIENTBOUND);
registerClass(PacketPlayOutPlayerInfo.class, "minecraft:player_info_update", NetworkPhase.PLAY, PacketBound.CLIENTBOUND);
registerClass(PacketPlayOutUpdateViewPosition.class, "minecraft:set_chunk_cache_center", NetworkPhase.PLAY, PacketBound.CLIENTBOUND);
registerClass(PacketPlayOutDisconnect.class, "minecraft:disconnect", NetworkPhase.PLAY, PacketBound.CLIENTBOUND);
registerClass(PacketPlayOutPluginMessaging.class, "minecraft:custom_payload", NetworkPhase.PLAY, PacketBound.CLIENTBOUND);
registerClass(PacketPlayOutTabComplete.class, "minecraft:command_suggestions", NetworkPhase.PLAY, PacketBound.CLIENTBOUND);
registerClass(PacketPlayOutDeclareCommands.class, "minecraft:commands", NetworkPhase.PLAY, PacketBound.CLIENTBOUND);
registerClass(PacketPlayOutRespawn.class, "minecraft:respawn", NetworkPhase.PLAY, PacketBound.CLIENTBOUND);
registerClass(PacketPlayOutEntityDestroy.class, "minecraft:remove_entities", NetworkPhase.PLAY, PacketBound.CLIENTBOUND);
registerClass(PacketPlayOutEntityMetadata.class, "minecraft:set_entity_data", NetworkPhase.PLAY, PacketBound.CLIENTBOUND);
registerClass(PacketPlayOutSpawnEntity.class, "minecraft:add_entity", NetworkPhase.PLAY, PacketBound.CLIENTBOUND);
registerClass(PacketPlayOutHeldItemChange.class, "minecraft:set_carried_item", NetworkPhase.PLAY, PacketBound.CLIENTBOUND);
registerClass(PacketPlayOutPlayerListHeaderFooter.class, "minecraft:tab_list", NetworkPhase.PLAY, PacketBound.CLIENTBOUND);
registerClass(ClientboundResourcePackPushPacket.class, "minecraft:resource_pack_push", NetworkPhase.PLAY, PacketBound.CLIENTBOUND);
registerClass(ClientboundSetTitlesAnimationPacket.class, "minecraft:set_titles_animation", NetworkPhase.PLAY, PacketBound.CLIENTBOUND);
registerClass(ClientboundSetTitleTextPacket.class, "minecraft:set_title_text", NetworkPhase.PLAY, PacketBound.CLIENTBOUND);
registerClass(ClientboundSetSubtitleTextPacket.class, "minecraft:set_subtitle_text", NetworkPhase.PLAY, PacketBound.CLIENTBOUND);
registerClass(ClientboundSetActionBarTextPacket.class, "minecraft:set_action_bar_text", NetworkPhase.PLAY, PacketBound.CLIENTBOUND);
registerClass(ClientboundClearTitlesPacket.class, "minecraft:clear_titles", NetworkPhase.PLAY, PacketBound.CLIENTBOUND);
registerClass(PacketPlayOutBoss.class, "minecraft:boss_event", NetworkPhase.PLAY, PacketBound.CLIENTBOUND);
registerClass(PacketPlayOutNamedSoundEffect.class, "minecraft:sound", NetworkPhase.PLAY, PacketBound.CLIENTBOUND);
registerClass(PacketPlayOutStopSound.class, "minecraft:stop_sound", NetworkPhase.PLAY, PacketBound.CLIENTBOUND);
registerClass(PacketPlayOutWindowItems.class, "minecraft:container_set_content", NetworkPhase.PLAY, PacketBound.CLIENTBOUND);
registerClass(PacketPlayOutSetSlot.class, "minecraft:container_set_slot", NetworkPhase.PLAY, PacketBound.CLIENTBOUND);
registerClass(PacketPlayOutOpenWindow.class, "minecraft:open_screen", NetworkPhase.PLAY, PacketBound.CLIENTBOUND);
registerClass(PacketPlayOutCloseWindow.class, "minecraft:container_close", NetworkPhase.PLAY, PacketBound.CLIENTBOUND);
registerClass(PacketPlayOutWindowData.class, "minecraft:container_set_data", NetworkPhase.PLAY, PacketBound.CLIENTBOUND);
registerClass(ClientboundChunkBatchFinishedPacket.class, "minecraft:chunk_batch_finished", NetworkPhase.PLAY, PacketBound.CLIENTBOUND);
registerClass(ClientboundChunkBatchStartPacket.class, "minecraft:chunk_batch_start", NetworkPhase.PLAY, PacketBound.CLIENTBOUND);
}
private static void registerClass(Class<? extends Packet> packetClass, String key, NetworkPhase networkPhase, PacketBound packetBound) {
CLASS_REGISTRY.put(packetClass, new PacketClassInfo(Key.key(key), networkPhase, packetBound));
}
public static PacketClassInfo getPacketInfo(Class<? extends Packet> packetClass) {
return CLASS_REGISTRY.get(packetClass);
}
public static int getPacketId(Class<? extends Packet> packetClass) {
PacketClassInfo info = getPacketInfo(packetClass);
return ID_REGISTRY.get(info.getNetworkPhase()).get(info.getPacketBound()).get(info.getKey());
}
@SuppressWarnings("unchecked")
public static <T extends Packet> Class<? extends T> getPacketClass(int packetId, NetworkPhase networkPhase, PacketBound packetBound) {
Key key = ID_REGISTRY.get(networkPhase).get(packetBound).inverse().get(packetId);
return (Class<? extends T>) CLASS_REGISTRY.inverse().get(new PacketClassInfo(key, networkPhase, packetBound));
}
public enum NetworkPhase {
HANDSHAKE("handshake", ClientConnection.ClientState.HANDSHAKE),
STATUS("status", ClientConnection.ClientState.STATUS),
CONFIGURATION("configuration", ClientConnection.ClientState.CONFIGURATION),
LOGIN("login", ClientConnection.ClientState.LOGIN),
PLAY("play", ClientConnection.ClientState.PLAY);
public static NetworkPhase fromName(String name) {
for (NetworkPhase phase : values()) {
if (phase.getName().equals(name)) {
return phase;
}
}
return null;
}
public static NetworkPhase fromClientState(ClientConnection.ClientState clientState) {
for (NetworkPhase phase : values()) {
if (phase.getClientState().equals(clientState)) {
return phase;
}
}
return null;
}
private final String name;
private final ClientConnection.ClientState clientState;
NetworkPhase(String name, ClientConnection.ClientState clientState) {
this.name = name;
this.clientState = clientState;
}
public String getName() {
return name;
}
public ClientConnection.ClientState getClientState() {
return clientState;
}
}
public enum PacketBound {
SERVERBOUND("serverbound"),
CLIENTBOUND("clientbound");
public static PacketBound fromName(String name) {
for (PacketBound bound : values()) {
if (bound.getName().equals(name)) {
return bound;
}
}
return null;
}
private final String name;
PacketBound(String name) {
this.name = name;
}
public String getName() {
return name;
}
}
public static class PacketClassInfo {
private final Key key;
private final NetworkPhase networkPhase;
private final PacketBound packetBound;
public PacketClassInfo(Key key, NetworkPhase networkPhase, PacketBound packetBound) {
this.key = key;
this.networkPhase = networkPhase;
this.packetBound = packetBound;
}
public Key getKey() {
return key;
}
public NetworkPhase getNetworkPhase() {
return networkPhase;
}
public PacketBound getPacketBound() {
return packetBound;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
PacketClassInfo that = (PacketClassInfo) o;
return Objects.equals(key, that.key) && networkPhase == that.networkPhase && packetBound == that.packetBound;
}
@Override
public int hashCode() {
return Objects.hash(key, networkPhase, packetBound);
}
}
}

View File

@ -32,25 +32,47 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.Map; import java.util.Map;
import java.util.regex.Pattern; import java.util.regex.Pattern;
public class RegistryCustom { public class RegistryCustom {
public static final RegistryCustom WORLDGEN_BIOME = new RegistryCustom("worldgen/biome"); private static final Map<Key, RegistryCustom> REGISTRIES = new HashMap<>();
public static final RegistryCustom CHAT_TYPE = new RegistryCustom("chat_type");
public static final RegistryCustom TRIM_PATTERN = new RegistryCustom("trim_pattern"); public static final RegistryCustom ADVANCEMENT = register("advancement");
public static final RegistryCustom TRIM_MATERIAL = new RegistryCustom("trim_material"); public static final RegistryCustom BANNER_PATTERN = register("banner_pattern");
public static final RegistryCustom WOLF_VARIANT = new RegistryCustom("wolf_variant"); public static final RegistryCustom CHAT_TYPE = register("chat_type");
public static final RegistryCustom DIMENSION_TYPE = new RegistryCustom("dimension_type"); public static final RegistryCustom DAMAGE_TYPE = register("damage_type");
public static final RegistryCustom DAMAGE_TYPE = new RegistryCustom("damage_type"); public static final RegistryCustom DIMENSION_TYPE = register("dimension_type");
public static final RegistryCustom BANNER_PATTERN = new RegistryCustom("banner_pattern"); public static final RegistryCustom ENCHANTMENT = register("enchantment");
public static final RegistryCustom JUKEBOX_SONG = register("jukebox_song");
public static final RegistryCustom PAINTING_VARIANT = register("painting_variant");
public static final RegistryCustom TRIM_MATERIAL = register("trim_material");
public static final RegistryCustom TRIM_PATTERN = register("trim_pattern");
public static final RegistryCustom WOLF_VARIANT = register("wolf_variant");
public static final RegistryCustom WORLDGEN_BIOME = register("worldgen/biome");
private static RegistryCustom register(String identifier) {
RegistryCustom registryCustom = new RegistryCustom(identifier);
REGISTRIES.put(registryCustom.getIdentifier(), registryCustom);
return registryCustom;
}
public static RegistryCustom getRegistry(Key identifier) {
return REGISTRIES.get(identifier);
}
public static Collection<RegistryCustom> getRegistries() {
return REGISTRIES.values();
}
private final Key identifier; private final Key identifier;
private final Map<Key, CompoundTag> entries; private final Map<Key, CompoundTag> entries;
public RegistryCustom(Key identifier, Map<Key, CompoundTag> entries) { private RegistryCustom(Key identifier, Map<Key, CompoundTag> entries) {
this.identifier = identifier; this.identifier = identifier;
this.entries = entries; this.entries = entries;
} }

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,34 @@
{
"parent": "minecraft:adventure/ol_betsy",
"criteria": {
"arbalistic": {
"conditions": {
"unique_entity_types": 5
},
"trigger": "minecraft:killed_by_crossbow"
}
},
"display": {
"description": {
"translate": "advancements.adventure.arbalistic.description"
},
"frame": "challenge",
"hidden": true,
"icon": {
"count": 1,
"id": "minecraft:crossbow"
},
"title": {
"translate": "advancements.adventure.arbalistic.title"
}
},
"requirements": [
[
"arbalistic"
]
],
"rewards": {
"experience": 85
},
"sends_telemetry_event": true
}

View File

@ -0,0 +1,26 @@
{
"parent": "minecraft:adventure/root",
"criteria": {
"avoid_vibration": {
"trigger": "minecraft:avoid_vibration"
}
},
"display": {
"description": {
"translate": "advancements.adventure.avoid_vibration.description"
},
"icon": {
"count": 1,
"id": "minecraft:sculk_sensor"
},
"title": {
"translate": "advancements.adventure.avoid_vibration.title"
}
},
"requirements": [
[
"avoid_vibration"
]
],
"sends_telemetry_event": true
}

View File

@ -0,0 +1,52 @@
{
"parent": "minecraft:adventure/minecraft_trials_edition",
"criteria": {
"blowback": {
"conditions": {
"entity": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:breeze"
}
}
],
"killing_blow": {
"direct_entity": {
"type": "minecraft:breeze_wind_charge"
},
"tags": [
{
"expected": true,
"id": "minecraft:is_projectile"
}
]
}
},
"trigger": "minecraft:player_killed_entity"
}
},
"display": {
"description": {
"translate": "advancements.adventure.blowback.description"
},
"frame": "challenge",
"icon": {
"count": 1,
"id": "minecraft:wind_charge"
},
"title": {
"translate": "advancements.adventure.blowback.title"
}
},
"requirements": [
[
"blowback"
]
],
"rewards": {
"experience": 40
},
"sends_telemetry_event": true
}

View File

@ -0,0 +1,40 @@
{
"parent": "minecraft:adventure/root",
"criteria": {
"brush_armadillo": {
"conditions": {
"entity": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:armadillo"
}
}
],
"item": {
"items": "minecraft:brush"
}
},
"trigger": "minecraft:player_interacted_with_entity"
}
},
"display": {
"description": {
"translate": "advancements.adventure.brush_armadillo.description"
},
"icon": {
"count": 1,
"id": "minecraft:armadillo_scute"
},
"title": {
"translate": "advancements.adventure.brush_armadillo.title"
}
},
"requirements": [
[
"brush_armadillo"
]
],
"sends_telemetry_event": true
}

View File

@ -0,0 +1,46 @@
{
"parent": "minecraft:adventure/shoot_arrow",
"criteria": {
"bullseye": {
"conditions": {
"projectile": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"distance": {
"horizontal": {
"min": 30.0
}
}
}
}
],
"signal_strength": 15
},
"trigger": "minecraft:target_hit"
}
},
"display": {
"description": {
"translate": "advancements.adventure.bullseye.description"
},
"frame": "challenge",
"icon": {
"count": 1,
"id": "minecraft:target"
},
"title": {
"translate": "advancements.adventure.bullseye.title"
}
},
"requirements": [
[
"bullseye"
]
],
"rewards": {
"experience": 50
},
"sends_telemetry_event": true
}

View File

@ -0,0 +1,51 @@
{
"parent": "minecraft:adventure/salvage_sherd",
"criteria": {
"pot_crafted_using_only_sherds": {
"conditions": {
"ingredients": [
{
"items": "#minecraft:decorated_pot_sherds"
},
{
"items": "#minecraft:decorated_pot_sherds"
},
{
"items": "#minecraft:decorated_pot_sherds"
},
{
"items": "#minecraft:decorated_pot_sherds"
}
],
"recipe_id": "minecraft:decorated_pot"
},
"trigger": "minecraft:recipe_crafted"
}
},
"display": {
"description": {
"translate": "advancements.adventure.craft_decorated_pot_using_only_sherds.description"
},
"icon": {
"components": {
"minecraft:pot_decorations": [
"minecraft:brick",
"minecraft:heart_pottery_sherd",
"minecraft:brick",
"minecraft:explorer_pottery_sherd"
]
},
"count": 1,
"id": "minecraft:decorated_pot"
},
"title": {
"translate": "advancements.adventure.craft_decorated_pot_using_only_sherds.title"
}
},
"requirements": [
[
"pot_crafted_using_only_sherds"
]
],
"sends_telemetry_event": true
}

View File

@ -0,0 +1,29 @@
{
"parent": "minecraft:adventure/root",
"criteria": {
"crafter_crafted_crafter": {
"conditions": {
"recipe_id": "minecraft:crafter"
},
"trigger": "minecraft:crafter_recipe_crafted"
}
},
"display": {
"description": {
"translate": "advancements.adventure.crafters_crafting_crafters.description"
},
"icon": {
"count": 1,
"id": "minecraft:crafter"
},
"title": {
"translate": "advancements.adventure.crafters_crafting_crafters.title"
}
},
"requirements": [
[
"crafter_crafted_crafter"
]
],
"sends_telemetry_event": true
}

View File

@ -0,0 +1,55 @@
{
"parent": "minecraft:adventure/root",
"criteria": {
"fall_from_world_height": {
"conditions": {
"distance": {
"y": {
"min": 379.0
}
},
"player": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"location": {
"position": {
"y": {
"max": -59.0
}
}
}
}
}
],
"start_position": {
"position": {
"y": {
"min": 319.0
}
}
}
},
"trigger": "minecraft:fall_from_height"
}
},
"display": {
"description": {
"translate": "advancements.adventure.fall_from_world_height.description"
},
"icon": {
"count": 1,
"id": "minecraft:water_bucket"
},
"title": {
"translate": "advancements.adventure.fall_from_world_height.title"
}
},
"requirements": [
[
"fall_from_world_height"
]
],
"sends_telemetry_event": true
}

View File

@ -0,0 +1,69 @@
{
"parent": "minecraft:adventure/voluntary_exile",
"criteria": {
"hero_of_the_village": {
"trigger": "minecraft:hero_of_the_village"
}
},
"display": {
"description": {
"translate": "advancements.adventure.hero_of_the_village.description"
},
"frame": "challenge",
"hidden": true,
"icon": {
"components": {
"minecraft:banner_patterns": [
{
"color": "cyan",
"pattern": "minecraft:rhombus"
},
{
"color": "light_gray",
"pattern": "minecraft:stripe_bottom"
},
{
"color": "gray",
"pattern": "minecraft:stripe_center"
},
{
"color": "light_gray",
"pattern": "minecraft:border"
},
{
"color": "black",
"pattern": "minecraft:stripe_middle"
},
{
"color": "light_gray",
"pattern": "minecraft:half_horizontal"
},
{
"color": "light_gray",
"pattern": "minecraft:circle"
},
{
"color": "black",
"pattern": "minecraft:border"
}
],
"minecraft:hide_additional_tooltip": {},
"minecraft:item_name": "{\"color\":\"gold\",\"translate\":\"block.minecraft.ominous_banner\"}"
},
"count": 1,
"id": "minecraft:white_banner"
},
"title": {
"translate": "advancements.adventure.hero_of_the_village.title"
}
},
"requirements": [
[
"hero_of_the_village"
]
],
"rewards": {
"experience": 100
},
"sends_telemetry_event": true
}

View File

@ -0,0 +1,29 @@
{
"parent": "minecraft:adventure/root",
"criteria": {
"honey_block_slide": {
"conditions": {
"block": "minecraft:honey_block"
},
"trigger": "minecraft:slide_down_block"
}
},
"display": {
"description": {
"translate": "advancements.adventure.honey_block_slide.description"
},
"icon": {
"count": 1,
"id": "minecraft:honey_block"
},
"title": {
"translate": "advancements.adventure.honey_block_slide.title"
}
},
"requirements": [
[
"honey_block_slide"
]
],
"sends_telemetry_event": true
}

View File

@ -0,0 +1,562 @@
{
"parent": "minecraft:adventure/root",
"criteria": {
"minecraft:blaze": {
"conditions": {
"entity": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:blaze"
}
}
]
},
"trigger": "minecraft:player_killed_entity"
},
"minecraft:bogged": {
"conditions": {
"entity": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:bogged"
}
}
]
},
"trigger": "minecraft:player_killed_entity"
},
"minecraft:breeze": {
"conditions": {
"entity": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:breeze"
}
}
]
},
"trigger": "minecraft:player_killed_entity"
},
"minecraft:cave_spider": {
"conditions": {
"entity": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:cave_spider"
}
}
]
},
"trigger": "minecraft:player_killed_entity"
},
"minecraft:creeper": {
"conditions": {
"entity": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:creeper"
}
}
]
},
"trigger": "minecraft:player_killed_entity"
},
"minecraft:drowned": {
"conditions": {
"entity": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:drowned"
}
}
]
},
"trigger": "minecraft:player_killed_entity"
},
"minecraft:elder_guardian": {
"conditions": {
"entity": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:elder_guardian"
}
}
]
},
"trigger": "minecraft:player_killed_entity"
},
"minecraft:ender_dragon": {
"conditions": {
"entity": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:ender_dragon"
}
}
]
},
"trigger": "minecraft:player_killed_entity"
},
"minecraft:enderman": {
"conditions": {
"entity": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:enderman"
}
}
]
},
"trigger": "minecraft:player_killed_entity"
},
"minecraft:endermite": {
"conditions": {
"entity": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:endermite"
}
}
]
},
"trigger": "minecraft:player_killed_entity"
},
"minecraft:evoker": {
"conditions": {
"entity": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:evoker"
}
}
]
},
"trigger": "minecraft:player_killed_entity"
},
"minecraft:ghast": {
"conditions": {
"entity": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:ghast"
}
}
]
},
"trigger": "minecraft:player_killed_entity"
},
"minecraft:guardian": {
"conditions": {
"entity": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:guardian"
}
}
]
},
"trigger": "minecraft:player_killed_entity"
},
"minecraft:hoglin": {
"conditions": {
"entity": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:hoglin"
}
}
]
},
"trigger": "minecraft:player_killed_entity"
},
"minecraft:husk": {
"conditions": {
"entity": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:husk"
}
}
]
},
"trigger": "minecraft:player_killed_entity"
},
"minecraft:magma_cube": {
"conditions": {
"entity": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:magma_cube"
}
}
]
},
"trigger": "minecraft:player_killed_entity"
},
"minecraft:phantom": {
"conditions": {
"entity": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:phantom"
}
}
]
},
"trigger": "minecraft:player_killed_entity"
},
"minecraft:piglin": {
"conditions": {
"entity": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:piglin"
}
}
]
},
"trigger": "minecraft:player_killed_entity"
},
"minecraft:piglin_brute": {
"conditions": {
"entity": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:piglin_brute"
}
}
]
},
"trigger": "minecraft:player_killed_entity"
},
"minecraft:pillager": {
"conditions": {
"entity": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:pillager"
}
}
]
},
"trigger": "minecraft:player_killed_entity"
},
"minecraft:ravager": {
"conditions": {
"entity": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:ravager"
}
}
]
},
"trigger": "minecraft:player_killed_entity"
},
"minecraft:shulker": {
"conditions": {
"entity": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:shulker"
}
}
]
},
"trigger": "minecraft:player_killed_entity"
},
"minecraft:silverfish": {
"conditions": {
"entity": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:silverfish"
}
}
]
},
"trigger": "minecraft:player_killed_entity"
},
"minecraft:skeleton": {
"conditions": {
"entity": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:skeleton"
}
}
]
},
"trigger": "minecraft:player_killed_entity"
},
"minecraft:slime": {
"conditions": {
"entity": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:slime"
}
}
]
},
"trigger": "minecraft:player_killed_entity"
},
"minecraft:spider": {
"conditions": {
"entity": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:spider"
}
}
]
},
"trigger": "minecraft:player_killed_entity"
},
"minecraft:stray": {
"conditions": {
"entity": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:stray"
}
}
]
},
"trigger": "minecraft:player_killed_entity"
},
"minecraft:vex": {
"conditions": {
"entity": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:vex"
}
}
]
},
"trigger": "minecraft:player_killed_entity"
},
"minecraft:vindicator": {
"conditions": {
"entity": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:vindicator"
}
}
]
},
"trigger": "minecraft:player_killed_entity"
},
"minecraft:witch": {
"conditions": {
"entity": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:witch"
}
}
]
},
"trigger": "minecraft:player_killed_entity"
},
"minecraft:wither": {
"conditions": {
"entity": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:wither"
}
}
]
},
"trigger": "minecraft:player_killed_entity"
},
"minecraft:wither_skeleton": {
"conditions": {
"entity": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:wither_skeleton"
}
}
]
},
"trigger": "minecraft:player_killed_entity"
},
"minecraft:zoglin": {
"conditions": {
"entity": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:zoglin"
}
}
]
},
"trigger": "minecraft:player_killed_entity"
},
"minecraft:zombie": {
"conditions": {
"entity": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:zombie"
}
}
]
},
"trigger": "minecraft:player_killed_entity"
},
"minecraft:zombie_villager": {
"conditions": {
"entity": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:zombie_villager"
}
}
]
},
"trigger": "minecraft:player_killed_entity"
},
"minecraft:zombified_piglin": {
"conditions": {
"entity": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:zombified_piglin"
}
}
]
},
"trigger": "minecraft:player_killed_entity"
}
},
"display": {
"description": {
"translate": "advancements.adventure.kill_a_mob.description"
},
"icon": {
"count": 1,
"id": "minecraft:iron_sword"
},
"title": {
"translate": "advancements.adventure.kill_a_mob.title"
}
},
"requirements": [
[
"minecraft:blaze",
"minecraft:bogged",
"minecraft:breeze",
"minecraft:cave_spider",
"minecraft:creeper",
"minecraft:drowned",
"minecraft:elder_guardian",
"minecraft:ender_dragon",
"minecraft:enderman",
"minecraft:endermite",
"minecraft:evoker",
"minecraft:ghast",
"minecraft:guardian",
"minecraft:hoglin",
"minecraft:husk",
"minecraft:magma_cube",
"minecraft:phantom",
"minecraft:piglin",
"minecraft:piglin_brute",
"minecraft:pillager",
"minecraft:ravager",
"minecraft:shulker",
"minecraft:silverfish",
"minecraft:skeleton",
"minecraft:slime",
"minecraft:spider",
"minecraft:stray",
"minecraft:vex",
"minecraft:vindicator",
"minecraft:witch",
"minecraft:wither_skeleton",
"minecraft:wither",
"minecraft:zoglin",
"minecraft:zombie_villager",
"minecraft:zombie",
"minecraft:zombified_piglin"
]
],
"sends_telemetry_event": true
}

View File

@ -0,0 +1,636 @@
{
"parent": "minecraft:adventure/kill_a_mob",
"criteria": {
"minecraft:blaze": {
"conditions": {
"entity": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:blaze"
}
}
]
},
"trigger": "minecraft:player_killed_entity"
},
"minecraft:bogged": {
"conditions": {
"entity": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:bogged"
}
}
]
},
"trigger": "minecraft:player_killed_entity"
},
"minecraft:breeze": {
"conditions": {
"entity": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:breeze"
}
}
]
},
"trigger": "minecraft:player_killed_entity"
},
"minecraft:cave_spider": {
"conditions": {
"entity": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:cave_spider"
}
}
]
},
"trigger": "minecraft:player_killed_entity"
},
"minecraft:creeper": {
"conditions": {
"entity": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:creeper"
}
}
]
},
"trigger": "minecraft:player_killed_entity"
},
"minecraft:drowned": {
"conditions": {
"entity": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:drowned"
}
}
]
},
"trigger": "minecraft:player_killed_entity"
},
"minecraft:elder_guardian": {
"conditions": {
"entity": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:elder_guardian"
}
}
]
},
"trigger": "minecraft:player_killed_entity"
},
"minecraft:ender_dragon": {
"conditions": {
"entity": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:ender_dragon"
}
}
]
},
"trigger": "minecraft:player_killed_entity"
},
"minecraft:enderman": {
"conditions": {
"entity": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:enderman"
}
}
]
},
"trigger": "minecraft:player_killed_entity"
},
"minecraft:endermite": {
"conditions": {
"entity": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:endermite"
}
}
]
},
"trigger": "minecraft:player_killed_entity"
},
"minecraft:evoker": {
"conditions": {
"entity": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:evoker"
}
}
]
},
"trigger": "minecraft:player_killed_entity"
},
"minecraft:ghast": {
"conditions": {
"entity": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:ghast"
}
}
]
},
"trigger": "minecraft:player_killed_entity"
},
"minecraft:guardian": {
"conditions": {
"entity": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:guardian"
}
}
]
},
"trigger": "minecraft:player_killed_entity"
},
"minecraft:hoglin": {
"conditions": {
"entity": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:hoglin"
}
}
]
},
"trigger": "minecraft:player_killed_entity"
},
"minecraft:husk": {
"conditions": {
"entity": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:husk"
}
}
]
},
"trigger": "minecraft:player_killed_entity"
},
"minecraft:magma_cube": {
"conditions": {
"entity": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:magma_cube"
}
}
]
},
"trigger": "minecraft:player_killed_entity"
},
"minecraft:phantom": {
"conditions": {
"entity": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:phantom"
}
}
]
},
"trigger": "minecraft:player_killed_entity"
},
"minecraft:piglin": {
"conditions": {
"entity": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:piglin"
}
}
]
},
"trigger": "minecraft:player_killed_entity"
},
"minecraft:piglin_brute": {
"conditions": {
"entity": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:piglin_brute"
}
}
]
},
"trigger": "minecraft:player_killed_entity"
},
"minecraft:pillager": {
"conditions": {
"entity": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:pillager"
}
}
]
},
"trigger": "minecraft:player_killed_entity"
},
"minecraft:ravager": {
"conditions": {
"entity": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:ravager"
}
}
]
},
"trigger": "minecraft:player_killed_entity"
},
"minecraft:shulker": {
"conditions": {
"entity": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:shulker"
}
}
]
},
"trigger": "minecraft:player_killed_entity"
},
"minecraft:silverfish": {
"conditions": {
"entity": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:silverfish"
}
}
]
},
"trigger": "minecraft:player_killed_entity"
},
"minecraft:skeleton": {
"conditions": {
"entity": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:skeleton"
}
}
]
},
"trigger": "minecraft:player_killed_entity"
},
"minecraft:slime": {
"conditions": {
"entity": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:slime"
}
}
]
},
"trigger": "minecraft:player_killed_entity"
},
"minecraft:spider": {
"conditions": {
"entity": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:spider"
}
}
]
},
"trigger": "minecraft:player_killed_entity"
},
"minecraft:stray": {
"conditions": {
"entity": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:stray"
}
}
]
},
"trigger": "minecraft:player_killed_entity"
},
"minecraft:vex": {
"conditions": {
"entity": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:vex"
}
}
]
},
"trigger": "minecraft:player_killed_entity"
},
"minecraft:vindicator": {
"conditions": {
"entity": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:vindicator"
}
}
]
},
"trigger": "minecraft:player_killed_entity"
},
"minecraft:witch": {
"conditions": {
"entity": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:witch"
}
}
]
},
"trigger": "minecraft:player_killed_entity"
},
"minecraft:wither": {
"conditions": {
"entity": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:wither"
}
}
]
},
"trigger": "minecraft:player_killed_entity"
},
"minecraft:wither_skeleton": {
"conditions": {
"entity": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:wither_skeleton"
}
}
]
},
"trigger": "minecraft:player_killed_entity"
},
"minecraft:zoglin": {
"conditions": {
"entity": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:zoglin"
}
}
]
},
"trigger": "minecraft:player_killed_entity"
},
"minecraft:zombie": {
"conditions": {
"entity": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:zombie"
}
}
]
},
"trigger": "minecraft:player_killed_entity"
},
"minecraft:zombie_villager": {
"conditions": {
"entity": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:zombie_villager"
}
}
]
},
"trigger": "minecraft:player_killed_entity"
},
"minecraft:zombified_piglin": {
"conditions": {
"entity": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:zombified_piglin"
}
}
]
},
"trigger": "minecraft:player_killed_entity"
}
},
"display": {
"description": {
"translate": "advancements.adventure.kill_all_mobs.description"
},
"frame": "challenge",
"icon": {
"count": 1,
"id": "minecraft:diamond_sword"
},
"title": {
"translate": "advancements.adventure.kill_all_mobs.title"
}
},
"requirements": [
[
"minecraft:blaze"
],
[
"minecraft:bogged"
],
[
"minecraft:breeze"
],
[
"minecraft:cave_spider"
],
[
"minecraft:creeper"
],
[
"minecraft:drowned"
],
[
"minecraft:elder_guardian"
],
[
"minecraft:ender_dragon"
],
[
"minecraft:enderman"
],
[
"minecraft:endermite"
],
[
"minecraft:evoker"
],
[
"minecraft:ghast"
],
[
"minecraft:guardian"
],
[
"minecraft:hoglin"
],
[
"minecraft:husk"
],
[
"minecraft:magma_cube"
],
[
"minecraft:phantom"
],
[
"minecraft:piglin"
],
[
"minecraft:piglin_brute"
],
[
"minecraft:pillager"
],
[
"minecraft:ravager"
],
[
"minecraft:shulker"
],
[
"minecraft:silverfish"
],
[
"minecraft:skeleton"
],
[
"minecraft:slime"
],
[
"minecraft:spider"
],
[
"minecraft:stray"
],
[
"minecraft:vex"
],
[
"minecraft:vindicator"
],
[
"minecraft:witch"
],
[
"minecraft:wither_skeleton"
],
[
"minecraft:wither"
],
[
"minecraft:zoglin"
],
[
"minecraft:zombie_villager"
],
[
"minecraft:zombie"
],
[
"minecraft:zombified_piglin"
]
],
"rewards": {
"experience": 100
},
"sends_telemetry_event": true
}

View File

@ -0,0 +1,27 @@
{
"parent": "minecraft:adventure/kill_a_mob",
"criteria": {
"kill_mob_near_sculk_catalyst": {
"trigger": "minecraft:kill_mob_near_sculk_catalyst"
}
},
"display": {
"description": {
"translate": "advancements.adventure.kill_mob_near_sculk_catalyst.description"
},
"frame": "challenge",
"icon": {
"count": 1,
"id": "minecraft:sculk_catalyst"
},
"title": {
"translate": "advancements.adventure.kill_mob_near_sculk_catalyst.title"
}
},
"requirements": [
[
"kill_mob_near_sculk_catalyst"
]
],
"sends_telemetry_event": true
}

View File

@ -0,0 +1,61 @@
{
"parent": "minecraft:adventure/minecraft_trials_edition",
"criteria": {
"lighten_up": {
"conditions": {
"location": [
{
"condition": "minecraft:location_check",
"predicate": {
"block": {
"blocks": [
"minecraft:oxidized_copper_bulb",
"minecraft:weathered_copper_bulb",
"minecraft:exposed_copper_bulb",
"minecraft:waxed_oxidized_copper_bulb",
"minecraft:waxed_weathered_copper_bulb",
"minecraft:waxed_exposed_copper_bulb"
],
"state": {
"lit": "true"
}
}
}
},
{
"condition": "minecraft:match_tool",
"predicate": {
"items": [
"minecraft:wooden_axe",
"minecraft:golden_axe",
"minecraft:stone_axe",
"minecraft:iron_axe",
"minecraft:diamond_axe",
"minecraft:netherite_axe"
]
}
}
]
},
"trigger": "minecraft:item_used_on_block"
}
},
"display": {
"description": {
"translate": "advancements.adventure.lighten_up.description"
},
"icon": {
"count": 1,
"id": "minecraft:copper_bulb"
},
"title": {
"translate": "advancements.adventure.lighten_up.title"
}
},
"requirements": [
[
"lighten_up"
]
],
"sends_telemetry_event": true
}

View File

@ -0,0 +1,54 @@
{
"parent": "minecraft:adventure/root",
"criteria": {
"lightning_rod_with_villager_no_fire": {
"conditions": {
"bystander": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:villager"
}
}
],
"lightning": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"distance": {
"absolute": {
"max": 30.0
}
},
"type_specific": {
"type": "minecraft:lightning",
"blocks_set_on_fire": 0
}
}
}
]
},
"trigger": "minecraft:lightning_strike"
}
},
"display": {
"description": {
"translate": "advancements.adventure.lightning_rod_with_villager_no_fire.description"
},
"icon": {
"count": 1,
"id": "minecraft:lightning_rod"
},
"title": {
"translate": "advancements.adventure.lightning_rod_with_villager_no_fire.title"
}
},
"requirements": [
[
"lightning_rod_with_villager_no_fire"
]
],
"sends_telemetry_event": true
}

View File

@ -0,0 +1,39 @@
{
"parent": "minecraft:adventure/root",
"criteria": {
"minecraft_trials_edition": {
"conditions": {
"player": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"location": {
"structures": "minecraft:trial_chambers"
}
}
}
]
},
"trigger": "minecraft:location"
}
},
"display": {
"description": {
"translate": "advancements.adventure.minecraft_trials_edition.description"
},
"icon": {
"count": 1,
"id": "minecraft:chiseled_tuff"
},
"title": {
"translate": "advancements.adventure.minecraft_trials_edition.title"
}
},
"requirements": [
[
"minecraft_trials_edition"
]
],
"sends_telemetry_event": true
}

View File

@ -0,0 +1,31 @@
{
"parent": "minecraft:adventure/root",
"criteria": {
"shot_crossbow": {
"conditions": {
"item": {
"items": "minecraft:crossbow"
}
},
"trigger": "minecraft:shot_crossbow"
}
},
"display": {
"description": {
"translate": "advancements.adventure.ol_betsy.description"
},
"icon": {
"count": 1,
"id": "minecraft:crossbow"
},
"title": {
"translate": "advancements.adventure.ol_betsy.title"
}
},
"requirements": [
[
"shot_crossbow"
]
],
"sends_telemetry_event": true
}

View File

@ -0,0 +1,53 @@
{
"parent": "minecraft:adventure/minecraft_trials_edition",
"criteria": {
"overoverkill": {
"conditions": {
"damage": {
"type": {
"direct_entity": {
"type": "minecraft:player",
"equipment": {
"mainhand": {
"items": "minecraft:mace"
}
}
},
"tags": [
{
"expected": true,
"id": "minecraft:is_player_attack"
}
]
},
"dealt": {
"min": 100.0
}
}
},
"trigger": "minecraft:player_hurt_entity"
}
},
"display": {
"description": {
"translate": "advancements.adventure.overoverkill.description"
},
"frame": "challenge",
"icon": {
"count": 1,
"id": "minecraft:mace"
},
"title": {
"translate": "advancements.adventure.overoverkill.title"
}
},
"requirements": [
[
"overoverkill"
]
],
"rewards": {
"experience": 50
},
"sends_telemetry_event": true
}

View File

@ -0,0 +1,47 @@
{
"parent": "minecraft:adventure/sleep_in_bed",
"criteria": {
"play_jukebox_in_meadows": {
"conditions": {
"location": [
{
"condition": "minecraft:location_check",
"predicate": {
"biomes": "minecraft:meadow",
"block": {
"blocks": "minecraft:jukebox"
}
}
},
{
"condition": "minecraft:match_tool",
"predicate": {
"predicates": {
"minecraft:jukebox_playable": {}
}
}
}
]
},
"trigger": "minecraft:item_used_on_block"
}
},
"display": {
"description": {
"translate": "advancements.adventure.play_jukebox_in_meadows.description"
},
"icon": {
"count": 1,
"id": "minecraft:jukebox"
},
"title": {
"translate": "advancements.adventure.play_jukebox_in_meadows.title"
}
},
"requirements": [
[
"play_jukebox_in_meadows"
]
],
"sends_telemetry_event": true
}

View File

@ -0,0 +1,184 @@
{
"parent": "minecraft:adventure/root",
"criteria": {
"chiseled_bookshelf": {
"conditions": {
"location": [
{
"block": "minecraft:chiseled_bookshelf",
"condition": "minecraft:block_state_property"
},
{
"condition": "minecraft:any_of",
"terms": [
{
"condition": "minecraft:location_check",
"offsetZ": 1,
"predicate": {
"block": {
"blocks": "minecraft:comparator",
"state": {
"facing": "north"
}
}
}
},
{
"condition": "minecraft:location_check",
"offsetZ": -1,
"predicate": {
"block": {
"blocks": "minecraft:comparator",
"state": {
"facing": "south"
}
}
}
},
{
"condition": "minecraft:location_check",
"offsetX": 1,
"predicate": {
"block": {
"blocks": "minecraft:comparator",
"state": {
"facing": "west"
}
}
}
},
{
"condition": "minecraft:location_check",
"offsetX": -1,
"predicate": {
"block": {
"blocks": "minecraft:comparator",
"state": {
"facing": "east"
}
}
}
}
]
}
]
},
"trigger": "minecraft:placed_block"
},
"comparator": {
"conditions": {
"location": [
{
"condition": "minecraft:any_of",
"terms": [
{
"condition": "minecraft:all_of",
"terms": [
{
"block": "minecraft:comparator",
"condition": "minecraft:block_state_property",
"properties": {
"facing": "north"
}
},
{
"condition": "minecraft:location_check",
"offsetZ": -1,
"predicate": {
"block": {
"blocks": "minecraft:chiseled_bookshelf"
}
}
}
]
},
{
"condition": "minecraft:all_of",
"terms": [
{
"block": "minecraft:comparator",
"condition": "minecraft:block_state_property",
"properties": {
"facing": "south"
}
},
{
"condition": "minecraft:location_check",
"offsetZ": 1,
"predicate": {
"block": {
"blocks": "minecraft:chiseled_bookshelf"
}
}
}
]
},
{
"condition": "minecraft:all_of",
"terms": [
{
"block": "minecraft:comparator",
"condition": "minecraft:block_state_property",
"properties": {
"facing": "west"
}
},
{
"condition": "minecraft:location_check",
"offsetX": -1,
"predicate": {
"block": {
"blocks": "minecraft:chiseled_bookshelf"
}
}
}
]
},
{
"condition": "minecraft:all_of",
"terms": [
{
"block": "minecraft:comparator",
"condition": "minecraft:block_state_property",
"properties": {
"facing": "east"
}
},
{
"condition": "minecraft:location_check",
"offsetX": 1,
"predicate": {
"block": {
"blocks": "minecraft:chiseled_bookshelf"
}
}
}
]
}
]
}
]
},
"trigger": "minecraft:placed_block"
}
},
"display": {
"description": {
"translate": "advancements.adventure.read_power_from_chiseled_bookshelf.description"
},
"icon": {
"count": 1,
"id": "minecraft:chiseled_bookshelf"
},
"title": {
"translate": "advancements.adventure.read_power_from_chiseled_bookshelf.title"
}
},
"requirements": [
[
"chiseled_bookshelf",
"comparator"
]
],
"sends_telemetry_event": true
}

View File

@ -0,0 +1,48 @@
{
"parent": "minecraft:adventure/under_lock_and_key",
"criteria": {
"revaulting": {
"conditions": {
"location": [
{
"condition": "minecraft:location_check",
"predicate": {
"block": {
"blocks": "minecraft:vault",
"state": {
"ominous": "true"
}
}
}
},
{
"condition": "minecraft:match_tool",
"predicate": {
"items": "minecraft:ominous_trial_key"
}
}
]
},
"trigger": "minecraft:item_used_on_block"
}
},
"display": {
"description": {
"translate": "advancements.adventure.revaulting.description"
},
"frame": "goal",
"icon": {
"count": 1,
"id": "minecraft:ominous_trial_key"
},
"title": {
"translate": "advancements.adventure.revaulting.title"
}
},
"requirements": [
[
"revaulting"
]
],
"sends_telemetry_event": true
}

View File

@ -0,0 +1,32 @@
{
"criteria": {
"killed_by_something": {
"trigger": "minecraft:entity_killed_player"
},
"killed_something": {
"trigger": "minecraft:player_killed_entity"
}
},
"display": {
"announce_to_chat": false,
"background": "minecraft:textures/gui/advancements/backgrounds/adventure.png",
"description": {
"translate": "advancements.adventure.root.description"
},
"icon": {
"count": 1,
"id": "minecraft:map"
},
"show_toast": false,
"title": {
"translate": "advancements.adventure.root.title"
}
},
"requirements": [
[
"killed_something",
"killed_by_something"
]
],
"sends_telemetry_event": true
}

View File

@ -0,0 +1,77 @@
{
"parent": "minecraft:adventure/root",
"criteria": {
"desert_pyramid": {
"conditions": {
"loot_table": "minecraft:archaeology/desert_pyramid"
},
"trigger": "minecraft:player_generates_container_loot"
},
"desert_well": {
"conditions": {
"loot_table": "minecraft:archaeology/desert_well"
},
"trigger": "minecraft:player_generates_container_loot"
},
"has_sherd": {
"conditions": {
"items": [
{
"items": "#minecraft:decorated_pot_sherds"
}
]
},
"trigger": "minecraft:inventory_changed"
},
"ocean_ruin_cold": {
"conditions": {
"loot_table": "minecraft:archaeology/ocean_ruin_cold"
},
"trigger": "minecraft:player_generates_container_loot"
},
"ocean_ruin_warm": {
"conditions": {
"loot_table": "minecraft:archaeology/ocean_ruin_warm"
},
"trigger": "minecraft:player_generates_container_loot"
},
"trail_ruins_common": {
"conditions": {
"loot_table": "minecraft:archaeology/trail_ruins_common"
},
"trigger": "minecraft:player_generates_container_loot"
},
"trail_ruins_rare": {
"conditions": {
"loot_table": "minecraft:archaeology/trail_ruins_rare"
},
"trigger": "minecraft:player_generates_container_loot"
}
},
"display": {
"description": {
"translate": "advancements.adventure.salvage_sherd.description"
},
"icon": {
"count": 1,
"id": "minecraft:brush"
},
"title": {
"translate": "advancements.adventure.salvage_sherd.title"
}
},
"requirements": [
[
"desert_pyramid",
"desert_well",
"ocean_ruin_cold",
"ocean_ruin_warm",
"trail_ruins_rare",
"trail_ruins_common"
],
[
"has_sherd"
]
],
"sends_telemetry_event": true
}

View File

@ -0,0 +1,41 @@
{
"parent": "minecraft:adventure/kill_a_mob",
"criteria": {
"shot_arrow": {
"conditions": {
"damage": {
"type": {
"direct_entity": {
"type": "#minecraft:arrows"
},
"tags": [
{
"expected": true,
"id": "minecraft:is_projectile"
}
]
}
}
},
"trigger": "minecraft:player_hurt_entity"
}
},
"display": {
"description": {
"translate": "advancements.adventure.shoot_arrow.description"
},
"icon": {
"count": 1,
"id": "minecraft:bow"
},
"title": {
"translate": "advancements.adventure.shoot_arrow.title"
}
},
"requirements": [
[
"shot_arrow"
]
],
"sends_telemetry_event": true
}

View File

@ -0,0 +1,26 @@
{
"parent": "minecraft:adventure/root",
"criteria": {
"slept_in_bed": {
"trigger": "minecraft:slept_in_bed"
}
},
"display": {
"description": {
"translate": "advancements.adventure.sleep_in_bed.description"
},
"icon": {
"count": 1,
"id": "minecraft:red_bed"
},
"title": {
"translate": "advancements.adventure.sleep_in_bed.title"
}
},
"requirements": [
[
"slept_in_bed"
]
],
"sends_telemetry_event": true
}

View File

@ -0,0 +1,54 @@
{
"parent": "minecraft:adventure/shoot_arrow",
"criteria": {
"killed_skeleton": {
"conditions": {
"entity": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:skeleton",
"distance": {
"horizontal": {
"min": 50.0
}
}
}
}
],
"killing_blow": {
"tags": [
{
"expected": true,
"id": "minecraft:is_projectile"
}
]
}
},
"trigger": "minecraft:player_killed_entity"
}
},
"display": {
"description": {
"translate": "advancements.adventure.sniper_duel.description"
},
"frame": "challenge",
"icon": {
"count": 1,
"id": "minecraft:arrow"
},
"title": {
"translate": "advancements.adventure.sniper_duel.title"
}
},
"requirements": [
[
"killed_skeleton"
]
],
"rewards": {
"experience": 50
},
"sends_telemetry_event": true
}

View File

@ -0,0 +1,45 @@
{
"parent": "minecraft:adventure/spyglass_at_ghast",
"criteria": {
"spyglass_at_dragon": {
"conditions": {
"item": {
"items": "minecraft:spyglass"
},
"player": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type_specific": {
"type": "minecraft:player",
"looking_at": {
"type": "minecraft:ender_dragon"
}
}
}
}
]
},
"trigger": "minecraft:using_item"
}
},
"display": {
"description": {
"translate": "advancements.adventure.spyglass_at_dragon.description"
},
"icon": {
"count": 1,
"id": "minecraft:spyglass"
},
"title": {
"translate": "advancements.adventure.spyglass_at_dragon.title"
}
},
"requirements": [
[
"spyglass_at_dragon"
]
],
"sends_telemetry_event": true
}

View File

@ -0,0 +1,45 @@
{
"parent": "minecraft:adventure/spyglass_at_parrot",
"criteria": {
"spyglass_at_ghast": {
"conditions": {
"item": {
"items": "minecraft:spyglass"
},
"player": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type_specific": {
"type": "minecraft:player",
"looking_at": {
"type": "minecraft:ghast"
}
}
}
}
]
},
"trigger": "minecraft:using_item"
}
},
"display": {
"description": {
"translate": "advancements.adventure.spyglass_at_ghast.description"
},
"icon": {
"count": 1,
"id": "minecraft:spyglass"
},
"title": {
"translate": "advancements.adventure.spyglass_at_ghast.title"
}
},
"requirements": [
[
"spyglass_at_ghast"
]
],
"sends_telemetry_event": true
}

View File

@ -0,0 +1,45 @@
{
"parent": "minecraft:adventure/root",
"criteria": {
"spyglass_at_parrot": {
"conditions": {
"item": {
"items": "minecraft:spyglass"
},
"player": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type_specific": {
"type": "minecraft:player",
"looking_at": {
"type": "minecraft:parrot"
}
}
}
}
]
},
"trigger": "minecraft:using_item"
}
},
"display": {
"description": {
"translate": "advancements.adventure.spyglass_at_parrot.description"
},
"icon": {
"count": 1,
"id": "minecraft:spyglass"
},
"title": {
"translate": "advancements.adventure.spyglass_at_parrot.title"
}
},
"requirements": [
[
"spyglass_at_parrot"
]
],
"sends_telemetry_event": true
}

Some files were not shown because too many files have changed in this diff Show More