mirror of
https://github.com/Minestom/Minestom.git
synced 2024-12-31 21:48:08 +01:00
Remove ReflectASM (no more warning message)
This commit is contained in:
parent
3c0d351f15
commit
5cb31171e6
@ -26,7 +26,6 @@ dependencies {
|
|||||||
api group: 'it.unimi.dsi', name: 'fastutil', version: '8.3.0'
|
api group: 'it.unimi.dsi', name: 'fastutil', version: '8.3.0'
|
||||||
|
|
||||||
api 'com.github.Querz:NBT:4.1'
|
api 'com.github.Querz:NBT:4.1'
|
||||||
api 'com.esotericsoftware:reflectasm:1.11.9'
|
|
||||||
|
|
||||||
// https://mvnrepository.com/artifact/com.google.code.gson/gson
|
// https://mvnrepository.com/artifact/com.google.code.gson/gson
|
||||||
api group: 'com.google.code.gson', name: 'gson', version: '2.8.5'
|
api group: 'com.google.code.gson', name: 'gson', version: '2.8.5'
|
||||||
|
@ -161,7 +161,6 @@ public class InstanceContainer extends Instance {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private short executeBlockPlacementRule(short blockId, BlockPosition blockPosition) {
|
private short executeBlockPlacementRule(short blockId, BlockPosition blockPosition) {
|
||||||
|
|
||||||
BlockPlacementRule blockPlacementRule = BLOCK_MANAGER.getBlockPlacementRule(blockId);
|
BlockPlacementRule blockPlacementRule = BLOCK_MANAGER.getBlockPlacementRule(blockId);
|
||||||
if (blockPlacementRule != null) {
|
if (blockPlacementRule != null) {
|
||||||
return blockPlacementRule.blockRefresh(this, blockPosition);
|
return blockPlacementRule.blockRefresh(this, blockPosition);
|
||||||
|
@ -62,7 +62,8 @@ public abstract class CustomBlock {
|
|||||||
* Called at digging start to check for custom breaking time
|
* Called at digging start to check for custom breaking time
|
||||||
* Can be set to < 0 to be cancelled, in this case vanilla time will be used
|
* Can be set to < 0 to be cancelled, in this case vanilla time will be used
|
||||||
*
|
*
|
||||||
* @param player the player who is trying to break the block
|
* @param player the player who is trying to break the block
|
||||||
|
* @param position
|
||||||
* @return the time in ms to break it
|
* @return the time in ms to break it
|
||||||
*/
|
*/
|
||||||
public abstract int getBreakDelay(Player player, BlockPosition position);
|
public abstract int getBreakDelay(Player player, BlockPosition position);
|
||||||
@ -78,11 +79,13 @@ public abstract class CustomBlock {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines custom behaviour for entities touching this block.
|
* Defines custom behaviour for entities touching this block.
|
||||||
|
*
|
||||||
* @param instance
|
* @param instance
|
||||||
* @param position the position at which the block is
|
* @param position the position at which the block is
|
||||||
* @param touching the entity currently touching the block
|
* @param touching the entity currently touching the block
|
||||||
*/
|
*/
|
||||||
public void handleContact(Instance instance, BlockPosition position, Entity touching) {}
|
public void handleContact(Instance instance, BlockPosition position, Entity touching) {
|
||||||
|
}
|
||||||
|
|
||||||
public short getBlockId() {
|
public short getBlockId() {
|
||||||
return blockId;
|
return blockId;
|
||||||
@ -105,19 +108,21 @@ public abstract class CustomBlock {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Update this block from a neighbor. By default calls 'update' if directNeighbor is true
|
* Update this block from a neighbor. By default calls 'update' if directNeighbor is true
|
||||||
* @param instance current instance
|
*
|
||||||
* @param thisPosition this block's position
|
* @param instance current instance
|
||||||
|
* @param thisPosition this block's position
|
||||||
* @param neighborPosition the neighboring block which triggered the update
|
* @param neighborPosition the neighboring block which triggered the update
|
||||||
* @param directNeighbor is the neighbor directly connected to this block? (No diagonals)
|
* @param directNeighbor is the neighbor directly connected to this block? (No diagonals)
|
||||||
*/
|
*/
|
||||||
public void updateFromNeighbor(Instance instance, BlockPosition thisPosition, BlockPosition neighborPosition, boolean directNeighbor) {
|
public void updateFromNeighbor(Instance instance, BlockPosition thisPosition, BlockPosition neighborPosition, boolean directNeighbor) {
|
||||||
if(directNeighbor && hasUpdate()) {
|
if (directNeighbor && hasUpdate()) {
|
||||||
update(instance, thisPosition, instance.getBlockData(thisPosition));
|
update(instance, thisPosition, instance.getBlockData(thisPosition));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a scheduled update on this block happens. By default, calls 'update'
|
* Called when a scheduled update on this block happens. By default, calls 'update'
|
||||||
|
*
|
||||||
* @param instance
|
* @param instance
|
||||||
* @param position
|
* @param position
|
||||||
* @param blockData
|
* @param blockData
|
||||||
@ -128,9 +133,11 @@ public abstract class CustomBlock {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows custom block to write block entity data to a given NBT compound
|
* Allows custom block to write block entity data to a given NBT compound
|
||||||
* @param instance instance of which the block lives
|
*
|
||||||
* @param position position of the block
|
* @param instance instance of which the block lives
|
||||||
|
* @param position position of the block
|
||||||
* @param blockData equivalent to <pre>instance.getBlockData(position)</pre>
|
* @param blockData equivalent to <pre>instance.getBlockData(position)</pre>
|
||||||
*/
|
*/
|
||||||
public void writeBlockEntity(Instance instance, BlockPosition position, Data blockData, CompoundTag nbt) {}
|
public void writeBlockEntity(Instance instance, BlockPosition position, Data blockData, CompoundTag nbt) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package net.minestom.server.network.packet;
|
package net.minestom.server.network.packet;
|
||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import io.netty.buffer.Unpooled;
|
||||||
import net.minestom.server.item.ItemStack;
|
import net.minestom.server.item.ItemStack;
|
||||||
import net.minestom.server.utils.BlockPosition;
|
import net.minestom.server.utils.BlockPosition;
|
||||||
import net.minestom.server.utils.SerializerUtils;
|
import net.minestom.server.utils.SerializerUtils;
|
||||||
@ -14,6 +15,10 @@ public class PacketReader {
|
|||||||
this.buffer = buffer;
|
this.buffer = buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PacketReader(byte[] bytes) {
|
||||||
|
this(Unpooled.wrappedBuffer(bytes));
|
||||||
|
}
|
||||||
|
|
||||||
public int readVarInt() {
|
public int readVarInt() {
|
||||||
return Utils.readVarInt(buffer);
|
return Utils.readVarInt(buffer);
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ import net.minestom.server.network.packet.client.login.LoginStartPacket;
|
|||||||
public class ClientLoginPacketsHandler extends ClientPacketsHandler {
|
public class ClientLoginPacketsHandler extends ClientPacketsHandler {
|
||||||
|
|
||||||
public ClientLoginPacketsHandler() {
|
public ClientLoginPacketsHandler() {
|
||||||
register(0, LoginStartPacket.class);
|
register(0, LoginStartPacket::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,18 @@
|
|||||||
package net.minestom.server.network.packet.client.handler;
|
package net.minestom.server.network.packet.client.handler;
|
||||||
|
|
||||||
import com.esotericsoftware.reflectasm.ConstructorAccess;
|
|
||||||
import net.minestom.server.network.packet.client.ClientPacket;
|
import net.minestom.server.network.packet.client.ClientPacket;
|
||||||
|
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
public class ClientPacketsHandler {
|
public class ClientPacketsHandler {
|
||||||
|
|
||||||
// Max packet id
|
// Max packet id
|
||||||
private static final int SIZE = 0x2E;
|
private static final int SIZE = 0x2E;
|
||||||
|
|
||||||
private ConstructorAccess[] constructorAccesses = new ConstructorAccess[SIZE];
|
private Supplier<? extends ClientPacket>[] supplierAccesses = new Supplier[SIZE];
|
||||||
|
|
||||||
public void register(int id, Class<? extends ClientPacket> packet) {
|
public void register(int id, Supplier<? extends ClientPacket> packetSupplier) {
|
||||||
constructorAccesses[id] = ConstructorAccess.get(packet);
|
supplierAccesses[id] = packetSupplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClientPacket getPacketInstance(int id) {
|
public ClientPacket getPacketInstance(int id) {
|
||||||
@ -19,11 +20,11 @@ public class ClientPacketsHandler {
|
|||||||
if (id > SIZE)
|
if (id > SIZE)
|
||||||
throw new IllegalStateException("Packet ID 0x" + Integer.toHexString(id) + " has been tried to be parsed, debug needed");
|
throw new IllegalStateException("Packet ID 0x" + Integer.toHexString(id) + " has been tried to be parsed, debug needed");
|
||||||
|
|
||||||
ConstructorAccess<? extends ClientPacket> constructorAccess = constructorAccesses[id];
|
Supplier<? extends ClientPacket> supplier = supplierAccesses[id];
|
||||||
if (constructorAccess == null)
|
if (supplierAccesses == null)
|
||||||
throw new IllegalStateException("Packet id 0x" + Integer.toHexString(id) + " isn't registered!");
|
throw new IllegalStateException("Packet id 0x" + Integer.toHexString(id) + " isn't registered!");
|
||||||
|
|
||||||
ClientPacket packet = constructorAccess.newInstance();
|
ClientPacket packet = supplier.get();
|
||||||
return packet;
|
return packet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,45 +5,45 @@ import net.minestom.server.network.packet.client.play.*;
|
|||||||
public class ClientPlayPacketsHandler extends ClientPacketsHandler {
|
public class ClientPlayPacketsHandler extends ClientPacketsHandler {
|
||||||
|
|
||||||
public ClientPlayPacketsHandler() {
|
public ClientPlayPacketsHandler() {
|
||||||
register(0x00, ClientTeleportConfirmPacket.class);
|
register(0x00, ClientTeleportConfirmPacket::new);
|
||||||
register(0x03, ClientChatMessagePacket.class);
|
register(0x03, ClientChatMessagePacket::new);
|
||||||
register(0x04, ClientStatusPacket.class);
|
register(0x04, ClientStatusPacket::new);
|
||||||
register(0x05, ClientSettingsPacket.class);
|
register(0x05, ClientSettingsPacket::new);
|
||||||
register(0x06, ClientTabCompletePacket.class);
|
register(0x06, ClientTabCompletePacket::new);
|
||||||
register(0x07, ClientWindowConfirmationPacket.class);
|
register(0x07, ClientWindowConfirmationPacket::new);
|
||||||
register(0x08, ClientClickWindowButtonPacket.class); // Marked as 0x07 on wiki.vg
|
register(0x08, ClientClickWindowButtonPacket::new); // Marked as 0x07 on wiki.vg
|
||||||
register(0x09, ClientClickWindowPacket.class);
|
register(0x09, ClientClickWindowPacket::new);
|
||||||
register(0x0A, ClientCloseWindow.class);
|
register(0x0A, ClientCloseWindow::new);
|
||||||
register(0x0B, ClientPluginMessagePacket.class);
|
register(0x0B, ClientPluginMessagePacket::new);
|
||||||
register(0x0E, ClientInteractEntityPacket.class);
|
register(0x0E, ClientInteractEntityPacket::new);
|
||||||
register(0x0F, ClientKeepAlivePacket.class);
|
register(0x0F, ClientKeepAlivePacket::new);
|
||||||
|
|
||||||
// 0x10 packet not used server-side
|
// 0x10 packet not used server-side
|
||||||
register(0x11, ClientPlayerPositionPacket.class);
|
register(0x11, ClientPlayerPositionPacket::new);
|
||||||
register(0x12, ClientPlayerPositionAndLookPacket.class);
|
register(0x12, ClientPlayerPositionAndLookPacket::new);
|
||||||
register(0x13, ClientPlayerLookPacket.class);
|
register(0x13, ClientPlayerLookPacket::new);
|
||||||
register(0x14, ClientPlayerPacket.class);
|
register(0x14, ClientPlayerPacket::new);
|
||||||
register(0x15, ClientVehicleMovePacket.class);
|
register(0x15, ClientVehicleMovePacket::new);
|
||||||
register(0x16, ClientSteerBoatPacket.class);
|
register(0x16, ClientSteerBoatPacket::new);
|
||||||
register(0x17, ClientPickItemPacket.class);
|
register(0x17, ClientPickItemPacket::new);
|
||||||
register(0x18, ClientCraftRecipeRequest.class);
|
register(0x18, ClientCraftRecipeRequest::new);
|
||||||
register(0x19, ClientPlayerAbilitiesPacket.class);
|
register(0x19, ClientPlayerAbilitiesPacket::new);
|
||||||
register(0x1A, ClientPlayerDiggingPacket.class);
|
register(0x1A, ClientPlayerDiggingPacket::new);
|
||||||
register(0x1B, ClientEntityActionPacket.class);
|
register(0x1B, ClientEntityActionPacket::new);
|
||||||
register(0x1C, ClientSteerVehiclePacket.class);
|
register(0x1C, ClientSteerVehiclePacket::new);
|
||||||
register(0x1D, ClientRecipeBookData.class);
|
register(0x1D, ClientRecipeBookData::new);
|
||||||
register(0x1E, ClientNameItemPacket.class);
|
register(0x1E, ClientNameItemPacket::new);
|
||||||
register(0x1F, ClientResourcePackStatusPacket.class);
|
register(0x1F, ClientResourcePackStatusPacket::new);
|
||||||
|
|
||||||
register(0x20, ClientAdvancementTabPacket.class);
|
register(0x20, ClientAdvancementTabPacket::new);
|
||||||
register(0x21, ClientSelectTradePacket.class);
|
register(0x21, ClientSelectTradePacket::new);
|
||||||
register(0x23, ClientHeldItemChangePacket.class);
|
register(0x23, ClientHeldItemChangePacket::new);
|
||||||
register(0x24, ClientUpdateCommandBlockPacket.class);
|
register(0x24, ClientUpdateCommandBlockPacket::new);
|
||||||
register(0x25, ClientUpdateCommandBlockMinecartPacket.class);
|
register(0x25, ClientUpdateCommandBlockMinecartPacket::new);
|
||||||
register(0x26, ClientCreativeInventoryActionPacket.class);
|
register(0x26, ClientCreativeInventoryActionPacket::new);
|
||||||
register(0x29, ClientUpdateSignPacket.class);
|
register(0x29, ClientUpdateSignPacket::new);
|
||||||
register(0x2A, ClientAnimationPacket.class);
|
register(0x2A, ClientAnimationPacket::new);
|
||||||
register(0x2C, ClientPlayerBlockPlacementPacket.class);
|
register(0x2C, ClientPlayerBlockPlacementPacket::new);
|
||||||
register(0x2D, ClientUseItemPacket.class);
|
register(0x2D, ClientUseItemPacket::new);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,8 +6,8 @@ import net.minestom.server.network.packet.client.status.StatusRequestPacket;
|
|||||||
public class ClientStatusPacketsHandler extends ClientPacketsHandler {
|
public class ClientStatusPacketsHandler extends ClientPacketsHandler {
|
||||||
|
|
||||||
public ClientStatusPacketsHandler() {
|
public ClientStatusPacketsHandler() {
|
||||||
register(0x00, StatusRequestPacket.class);
|
register(0x00, StatusRequestPacket::new);
|
||||||
register(0x01, PingPacket.class);
|
register(0x01, PingPacket::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package net.minestom.server.storage;
|
package net.minestom.server.storage;
|
||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
|
||||||
import io.netty.buffer.Unpooled;
|
import io.netty.buffer.Unpooled;
|
||||||
import net.minestom.server.MinecraftServer;
|
import net.minestom.server.MinecraftServer;
|
||||||
import net.minestom.server.data.DataContainer;
|
import net.minestom.server.data.DataContainer;
|
||||||
@ -70,8 +69,7 @@ public class StorageFolder {
|
|||||||
if (data == null)
|
if (data == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
ByteBuf buffer = Unpooled.wrappedBuffer(data);
|
PacketReader packetReader = new PacketReader(data);
|
||||||
PacketReader packetReader = new PacketReader(buffer);
|
|
||||||
T value = dataType.decode(packetReader);
|
T value = dataType.decode(packetReader);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user