mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-27 10:59:16 +00:00
Updated Upstream (Leaves)
Upstream has released updates that appear to apply and compile correctly Leaves Changes: LeavesMC/Leaves@88819fe8 Add mc-old hopper suck-in behavior (#395) LeavesMC/Leaves@7394e8dd Fix papermc repo LeavesMC/Leaves@85c7bf11 Remove cache-world-generator-sea-level (#392) LeavesMC/Leaves@00798036 init 1.21.4, and boom! LeavesMC/Leaves@91fc24da build change, but weight not work LeavesMC/Leaves@4ccdf459 just work LeavesMC/Leaves@05ee2e36 Build changes, and delete timings LeavesMC/Leaves@fcc859dc Fix API patches (#406) LeavesMC/Leaves@6a1259df 0006/0129 LeavesMC/Leaves@3e3b05df 0009/0129 LeavesMC/Leaves@c3255c4f 0011/0129 LeavesMC/Leaves@6284c7b6 0018/0129 LeavesMC/Leaves@7abdc88c 0030/0129 LeavesMC/Leaves@4d119ff9 0035/0129 LeavesMC/Leaves@60baed99 0043/0129 LeavesMC/Leaves@dc319d5b 0048/0129 LeavesMC/Leaves@73a505d5 0049/0129 LeavesMC/Leaves@016b29dd 0057/0129 LeavesMC/Leaves@c9cf5af8 0065/0129 LeavesMC/Leaves@330b79ff 0086/0129 (#408) LeavesMC/Leaves@06c1d946 0087/0129 LeavesMC/Leaves@bf4bc284 0091/0129 LeavesMC/Leaves@102a3b70 0097/0129 LeavesMC/Leaves@53b43fed 0101/0129 LeavesMC/Leaves@892f3925 102/129 LeavesMC/Leaves@08c3043a 0107/0129 LeavesMC/Leaves@48764d8e 0112/0129 LeavesMC/Leaves@8380feff 0118/0129 LeavesMC/Leaves@e51603db 0129/0129, 100% patched LeavesMC/Leaves@ef851152 fix some LeavesMC/Leaves@9b7c6e88 server work LeavesMC/Leaves@272b7dcb Protocol... (#409) LeavesMC/Leaves@7be1bc97 Make jade better LeavesMC/Leaves@5350f6ea Make action work LeavesMC/Leaves@f07c26c8 fix action jar
This commit is contained in:
@@ -1,22 +0,0 @@
|
||||
package org.dreeam.leaf.config.modules.gameplay;
|
||||
|
||||
import org.dreeam.leaf.config.ConfigModules;
|
||||
import org.dreeam.leaf.config.EnumConfigCategory;
|
||||
|
||||
public class DisableMovedWronglyThreshold extends ConfigModules {
|
||||
|
||||
public String getBasePath() {
|
||||
return EnumConfigCategory.GAMEPLAY.getBaseKeyName() + ".player";
|
||||
}
|
||||
|
||||
public static boolean enabled = false;
|
||||
|
||||
@Override
|
||||
public void onLoaded() {
|
||||
enabled = config.getBoolean(getBasePath() + ".disable-moved-wrongly-threshold", enabled,
|
||||
config.pickStringRegionBased(
|
||||
"Disable moved quickly/wrongly checks.",
|
||||
"关闭 moved wrongly/too quickly! 警告."
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.stats.ServerStatsCounter;
|
||||
import net.minecraft.stats.Stat;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@@ -18,21 +19,18 @@ public class BotStatsCounter extends ServerStatsCounter {
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, Stat<?> stat, int value) {
|
||||
|
||||
public void setValue(@NotNull Player player, @NotNull Stat<?> stat, int value) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parseLocal(DataFixer dataFixer, String json) {
|
||||
|
||||
public void parseLocal(@NotNull DataFixer dataFixer, @NotNull String json) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getValue(Stat<?> stat) {
|
||||
public int getValue(@NotNull Stat<?> stat) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,8 +38,8 @@ public class AppleSkinProtocol {
|
||||
}
|
||||
|
||||
@Contract("_ -> new")
|
||||
public static @NotNull ResourceLocation id(String path) {
|
||||
return new ResourceLocation(PROTOCOL_ID, path);
|
||||
public static ResourceLocation id(String path) {
|
||||
return ResourceLocation.tryBuild(PROTOCOL_ID, path);
|
||||
}
|
||||
|
||||
@ProtocolHandler.PlayerJoin
|
||||
|
||||
@@ -21,13 +21,13 @@ public class XaeroMapProtocol {
|
||||
}
|
||||
|
||||
@Contract("_ -> new")
|
||||
public static @NotNull ResourceLocation idMini(String path) {
|
||||
return new ResourceLocation(PROTOCOL_ID_MINI, path);
|
||||
public static ResourceLocation idMini(String path) {
|
||||
return ResourceLocation.tryBuild(PROTOCOL_ID_MINI, path);
|
||||
}
|
||||
|
||||
@Contract("_ -> new")
|
||||
public static @NotNull ResourceLocation idWorld(String path) {
|
||||
return new ResourceLocation(PROTOCOL_ID_WORLD, path);
|
||||
public static ResourceLocation idWorld(String path) {
|
||||
return ResourceLocation.tryBuild(PROTOCOL_ID_WORLD, path);
|
||||
}
|
||||
|
||||
public static void onSendWorldInfo(@NotNull ServerPlayer player) {
|
||||
|
||||
@@ -173,7 +173,7 @@ public class LeavesProtocolManager {
|
||||
if (receiver.sendFabricRegister() && !receiver.ignoreId()) {
|
||||
for (String payloadId : receiver.payloadId()) {
|
||||
for (String namespace : protocol.namespace()) {
|
||||
ALL_KNOWN_ID.add(new ResourceLocation(namespace, payloadId));
|
||||
ALL_KNOWN_ID.add(ResourceLocation.tryBuild(namespace, payloadId));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -323,7 +323,6 @@ public class LeavesProtocolManager {
|
||||
}
|
||||
|
||||
public record EmptyPayload(ResourceLocation id) implements LeavesCustomPayload<EmptyPayload> {
|
||||
|
||||
@New
|
||||
public EmptyPayload(ResourceLocation location, FriendlyByteBuf buf) {
|
||||
this(location);
|
||||
@@ -336,7 +335,6 @@ public class LeavesProtocolManager {
|
||||
|
||||
public record LeavesPayload(FriendlyByteBuf data,
|
||||
ResourceLocation id) implements LeavesCustomPayload<LeavesPayload> {
|
||||
|
||||
@New
|
||||
public LeavesPayload(ResourceLocation location, FriendlyByteBuf buf) {
|
||||
this(new FriendlyByteBuf(buf.readBytes(buf.readableBytes())), location);
|
||||
|
||||
@@ -4,6 +4,7 @@ import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
@@ -11,6 +12,7 @@ import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.entity.AgeableMob;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.Mob;
|
||||
import net.minecraft.world.entity.animal.Animal;
|
||||
import net.minecraft.world.entity.animal.Chicken;
|
||||
import net.minecraft.world.entity.animal.allay.Allay;
|
||||
@@ -41,10 +43,11 @@ import org.leavesmc.leaves.protocol.core.ProtocolHandler;
|
||||
import org.leavesmc.leaves.protocol.core.ProtocolUtils;
|
||||
import org.leavesmc.leaves.protocol.jade.accessor.BlockAccessor;
|
||||
import org.leavesmc.leaves.protocol.jade.accessor.EntityAccessor;
|
||||
import org.leavesmc.leaves.protocol.jade.payload.ClientHandshakePayload;
|
||||
import org.leavesmc.leaves.protocol.jade.payload.ReceiveDataPayload;
|
||||
import org.leavesmc.leaves.protocol.jade.payload.RequestBlockPayload;
|
||||
import org.leavesmc.leaves.protocol.jade.payload.RequestEntityPayload;
|
||||
import org.leavesmc.leaves.protocol.jade.payload.ServerPingPayload;
|
||||
import org.leavesmc.leaves.protocol.jade.payload.ServerHandshakePayload;
|
||||
import org.leavesmc.leaves.protocol.jade.provider.IJadeProvider;
|
||||
import org.leavesmc.leaves.protocol.jade.provider.IServerDataProvider;
|
||||
import org.leavesmc.leaves.protocol.jade.provider.IServerExtensionProvider;
|
||||
@@ -66,6 +69,7 @@ import org.leavesmc.leaves.protocol.jade.provider.entity.AnimalOwnerProvider;
|
||||
import org.leavesmc.leaves.protocol.jade.provider.entity.MobBreedingProvider;
|
||||
import org.leavesmc.leaves.protocol.jade.provider.entity.MobGrowthProvider;
|
||||
import org.leavesmc.leaves.protocol.jade.provider.entity.NextEntityDropProvider;
|
||||
import org.leavesmc.leaves.protocol.jade.provider.entity.PetArmorProvider;
|
||||
import org.leavesmc.leaves.protocol.jade.provider.entity.StatusEffectsProvider;
|
||||
import org.leavesmc.leaves.protocol.jade.provider.entity.ZombieVillagerProvider;
|
||||
import org.leavesmc.leaves.protocol.jade.util.HierarchyLookup;
|
||||
@@ -75,7 +79,9 @@ import org.leavesmc.leaves.protocol.jade.util.PriorityStore;
|
||||
import org.leavesmc.leaves.protocol.jade.util.WrappedHierarchyLookup;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@LeavesProtocol(namespace = "jade")
|
||||
public class JadeProtocol {
|
||||
@@ -84,18 +90,20 @@ public class JadeProtocol {
|
||||
private static List<Block> shearableBlocks = null;
|
||||
|
||||
public static final String PROTOCOL_ID = "jade";
|
||||
public static final String PROTOCOL_VERSION = "7";
|
||||
|
||||
public static final HierarchyLookup<IServerDataProvider<EntityAccessor>> entityDataProviders = new HierarchyLookup<>(Entity.class);
|
||||
public static final PairHierarchyLookup<IServerDataProvider<BlockAccessor>> blockDataProviders = new PairHierarchyLookup<>(new HierarchyLookup<>(Block.class), new HierarchyLookup<>(BlockEntity.class));
|
||||
public static final WrappedHierarchyLookup<IServerExtensionProvider<ItemStack>> itemStorageProviders = WrappedHierarchyLookup.forAccessor();
|
||||
private static final Set<ServerPlayer> enabledPlayers = new HashSet<>();
|
||||
|
||||
public static boolean shouldEnable() {
|
||||
return org.dreeam.leaf.config.modules.network.ProtocolSupport.jadeProtocol;
|
||||
}
|
||||
|
||||
@Contract("_ -> new")
|
||||
public static @NotNull ResourceLocation id(String path) {
|
||||
return new ResourceLocation(PROTOCOL_ID, path);
|
||||
public static ResourceLocation id(String path) {
|
||||
return ResourceLocation.tryBuild(PROTOCOL_ID, path);
|
||||
}
|
||||
|
||||
@Contract("_ -> new")
|
||||
@@ -124,6 +132,7 @@ public class JadeProtocol {
|
||||
entityDataProviders.register(Tadpole.class, MobGrowthProvider.INSTANCE);
|
||||
entityDataProviders.register(Animal.class, MobBreedingProvider.INSTANCE);
|
||||
entityDataProviders.register(Allay.class, MobBreedingProvider.INSTANCE);
|
||||
entityDataProviders.register(Mob.class, PetArmorProvider.INSTANCE);
|
||||
|
||||
entityDataProviders.register(Chicken.class, NextEntityDropProvider.INSTANCE);
|
||||
entityDataProviders.register(Armadillo.class, NextEntityDropProvider.INSTANCE);
|
||||
@@ -152,20 +161,22 @@ public class JadeProtocol {
|
||||
entityDataProviders.loadComplete(priorities);
|
||||
itemStorageProviders.loadComplete(priorities);
|
||||
|
||||
try {
|
||||
shearableBlocks = Collections.unmodifiableList(LootTableMineableCollector.execute(
|
||||
MinecraftServer.getServer().reloadableRegistries().lookup().lookupOrThrow(Registries.LOOT_TABLE),
|
||||
Items.SHEARS.getDefaultInstance()
|
||||
));
|
||||
} catch (Throwable ignore) {
|
||||
shearableBlocks = List.of();
|
||||
LeavesLogger.LOGGER.severe("Failed to collect shearable blocks");
|
||||
}
|
||||
rebuildShearableBlocks();
|
||||
}
|
||||
|
||||
@ProtocolHandler.PlayerJoin
|
||||
public static void onPlayerJoin(ServerPlayer player) {
|
||||
sendPingPacket(player);
|
||||
@ProtocolHandler.PayloadReceiver(payload = ClientHandshakePayload.class, payloadId = "client_handshake")
|
||||
public static void clientHandshake(ServerPlayer player, ClientHandshakePayload payload) {
|
||||
if (!payload.protocolVersion().equals(PROTOCOL_VERSION)) {
|
||||
player.sendSystemMessage(Component.literal("You are using a different version of Jade than the server. Please update Jade or report to the server operator").withColor(0xff0000));
|
||||
return;
|
||||
}
|
||||
ProtocolUtils.sendPayloadPacket(player, new ServerHandshakePayload(Collections.emptyMap(), shearableBlocks, blockDataProviders.mappedIds(), entityDataProviders.mappedIds()));
|
||||
enabledPlayers.add(player);
|
||||
}
|
||||
|
||||
@ProtocolHandler.PlayerLeave
|
||||
public static void onPlayerLeave(ServerPlayer player) {
|
||||
enabledPlayers.remove(player);
|
||||
}
|
||||
|
||||
@ProtocolHandler.PayloadReceiver(payload = RequestEntityPayload.class, payloadId = "request_entity")
|
||||
@@ -255,17 +266,22 @@ public class JadeProtocol {
|
||||
@ProtocolHandler.ReloadServer
|
||||
public static void onServerReload() {
|
||||
if (org.dreeam.leaf.config.modules.network.ProtocolSupport.jadeProtocol) {
|
||||
enableAllPlayer();
|
||||
rebuildShearableBlocks();
|
||||
for (ServerPlayer player : enabledPlayers) {
|
||||
ProtocolUtils.sendPayloadPacket(player, new ServerHandshakePayload(Collections.emptyMap(), shearableBlocks, blockDataProviders.mappedIds(), entityDataProviders.mappedIds()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void enableAllPlayer() {
|
||||
for (ServerPlayer player : MinecraftServer.getServer().getPlayerList().players) {
|
||||
sendPingPacket(player);
|
||||
private static void rebuildShearableBlocks() {
|
||||
try {
|
||||
shearableBlocks = Collections.unmodifiableList(LootTableMineableCollector.execute(
|
||||
MinecraftServer.getServer().reloadableRegistries().lookup().lookupOrThrow(Registries.LOOT_TABLE),
|
||||
Items.SHEARS.getDefaultInstance()
|
||||
));
|
||||
} catch (Throwable ignore) {
|
||||
shearableBlocks = List.of();
|
||||
LeavesLogger.LOGGER.severe("Failed to collect shearable blocks");
|
||||
}
|
||||
}
|
||||
|
||||
public static void sendPingPacket(ServerPlayer player) {
|
||||
ProtocolUtils.sendPayloadPacket(player, new ServerPingPayload(Collections.emptyMap(), shearableBlocks, blockDataProviders.mappedIds(), entityDataProviders.mappedIds()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
package org.leavesmc.leaves.protocol.jade.accessor;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
|
||||
import io.netty.buffer.Unpooled;
|
||||
import net.minecraft.nbt.ByteArrayTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
@@ -12,6 +8,9 @@ import net.minecraft.network.codec.StreamEncoder;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.phys.HitResult;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public abstract class AccessorImpl<T extends HitResult> implements Accessor<T> {
|
||||
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package org.leavesmc.leaves.protocol.jade.payload;
|
||||
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||
import net.minecraft.network.codec.ByteBufCodecs;
|
||||
import net.minecraft.network.codec.StreamCodec;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import org.leavesmc.leaves.protocol.core.LeavesCustomPayload;
|
||||
import org.leavesmc.leaves.protocol.core.ProtocolUtils;
|
||||
import org.leavesmc.leaves.protocol.jade.JadeProtocol;
|
||||
|
||||
public record ClientHandshakePayload(String protocolVersion) implements LeavesCustomPayload<ClientHandshakePayload> {
|
||||
|
||||
private static final ResourceLocation PACKET_CLIENT_HANDSHAKE = JadeProtocol.id("client_handshake");
|
||||
|
||||
private static final StreamCodec<RegistryFriendlyByteBuf, ClientHandshakePayload> CODEC = StreamCodec.composite(
|
||||
ByteBufCodecs.STRING_UTF8,
|
||||
ClientHandshakePayload::protocolVersion,
|
||||
ClientHandshakePayload::new);
|
||||
|
||||
@Override
|
||||
public void write(FriendlyByteBuf buf) {
|
||||
CODEC.encode(ProtocolUtils.decorate(buf), this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation id() {
|
||||
return PACKET_CLIENT_HANDSHAKE;
|
||||
}
|
||||
|
||||
@New
|
||||
public static ClientHandshakePayload create(ResourceLocation location, FriendlyByteBuf buf) {
|
||||
return CODEC.decode(ProtocolUtils.decorate(buf));
|
||||
}
|
||||
}
|
||||
@@ -6,10 +6,10 @@ import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||
import net.minecraft.network.codec.ByteBufCodecs;
|
||||
import net.minecraft.network.codec.StreamCodec;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.leavesmc.leaves.protocol.core.LeavesCustomPayload;
|
||||
import org.leavesmc.leaves.protocol.core.ProtocolUtils;
|
||||
import org.leavesmc.leaves.protocol.jade.JadeProtocol;
|
||||
import org.leavesmc.leaves.protocol.jade.accessor.BlockAccessor;
|
||||
import org.leavesmc.leaves.protocol.jade.accessor.BlockAccessorImpl;
|
||||
@@ -35,12 +35,12 @@ public record RequestBlockPayload(BlockAccessorImpl.SyncData data, List<@Nullabl
|
||||
|
||||
@Override
|
||||
public void write(FriendlyByteBuf buf) {
|
||||
CODEC.encode(new RegistryFriendlyByteBuf(buf, MinecraftServer.getServer().registryAccess()), this);
|
||||
CODEC.encode(ProtocolUtils.decorate(buf), this);
|
||||
}
|
||||
|
||||
@New
|
||||
public static RequestBlockPayload create(ResourceLocation location, FriendlyByteBuf buf) {
|
||||
return CODEC.decode(new RegistryFriendlyByteBuf(buf, MinecraftServer.getServer().registryAccess()));
|
||||
return CODEC.decode(ProtocolUtils.decorate(buf));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -6,10 +6,10 @@ import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||
import net.minecraft.network.codec.ByteBufCodecs;
|
||||
import net.minecraft.network.codec.StreamCodec;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.leavesmc.leaves.protocol.core.LeavesCustomPayload;
|
||||
import org.leavesmc.leaves.protocol.core.ProtocolUtils;
|
||||
import org.leavesmc.leaves.protocol.jade.JadeProtocol;
|
||||
import org.leavesmc.leaves.protocol.jade.accessor.EntityAccessor;
|
||||
import org.leavesmc.leaves.protocol.jade.accessor.EntityAccessorImpl;
|
||||
@@ -38,12 +38,12 @@ public record RequestEntityPayload(EntityAccessorImpl.SyncData data,
|
||||
|
||||
@Override
|
||||
public void write(FriendlyByteBuf buf) {
|
||||
CODEC.encode(new RegistryFriendlyByteBuf(buf, MinecraftServer.getServer().registryAccess()), this);
|
||||
CODEC.encode(ProtocolUtils.decorate(buf), this);
|
||||
}
|
||||
|
||||
@New
|
||||
public static RequestEntityPayload create(ResourceLocation location, FriendlyByteBuf buf) {
|
||||
return CODEC.decode(new RegistryFriendlyByteBuf(buf, MinecraftServer.getServer().registryAccess()));
|
||||
return CODEC.decode(ProtocolUtils.decorate(buf));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -8,9 +8,9 @@ import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||
import net.minecraft.network.codec.ByteBufCodecs;
|
||||
import net.minecraft.network.codec.StreamCodec;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import org.leavesmc.leaves.protocol.core.LeavesCustomPayload;
|
||||
import org.leavesmc.leaves.protocol.core.ProtocolUtils;
|
||||
import org.leavesmc.leaves.protocol.jade.JadeProtocol;
|
||||
|
||||
import java.util.List;
|
||||
@@ -18,28 +18,25 @@ import java.util.Map;
|
||||
|
||||
import static org.leavesmc.leaves.protocol.jade.util.JadeCodec.PRIMITIVE_STREAM_CODEC;
|
||||
|
||||
public record ServerPingPayload(
|
||||
public record ServerHandshakePayload(Map<ResourceLocation, Object> serverConfig, List<Block> shearableBlocks,
|
||||
List<ResourceLocation> blockProviderIds,
|
||||
List<ResourceLocation> entityProviderIds) implements LeavesCustomPayload<ServerHandshakePayload> {
|
||||
|
||||
Map<ResourceLocation, Object> serverConfig,
|
||||
List<Block> shearableBlocks,
|
||||
List<ResourceLocation> blockProviderIds,
|
||||
List<ResourceLocation> entityProviderIds) implements LeavesCustomPayload<ServerPingPayload> {
|
||||
|
||||
private static final ResourceLocation PACKET_SERVER_HANDSHAKE = JadeProtocol.id("server_ping_v1");
|
||||
private static final StreamCodec<RegistryFriendlyByteBuf, ServerPingPayload> CODEC = StreamCodec.composite(
|
||||
private static final ResourceLocation PACKET_SERVER_HANDSHAKE = JadeProtocol.id("server_handshake");
|
||||
private static final StreamCodec<RegistryFriendlyByteBuf, ServerHandshakePayload> CODEC = StreamCodec.composite(
|
||||
ByteBufCodecs.map(Maps::newHashMapWithExpectedSize, ResourceLocation.STREAM_CODEC, PRIMITIVE_STREAM_CODEC),
|
||||
ServerPingPayload::serverConfig,
|
||||
ServerHandshakePayload::serverConfig,
|
||||
ByteBufCodecs.registry(Registries.BLOCK).apply(ByteBufCodecs.list()),
|
||||
ServerPingPayload::shearableBlocks,
|
||||
ServerHandshakePayload::shearableBlocks,
|
||||
ByteBufCodecs.<ByteBuf, ResourceLocation>list().apply(ResourceLocation.STREAM_CODEC),
|
||||
ServerPingPayload::blockProviderIds,
|
||||
ServerHandshakePayload::blockProviderIds,
|
||||
ByteBufCodecs.<ByteBuf, ResourceLocation>list().apply(ResourceLocation.STREAM_CODEC),
|
||||
ServerPingPayload::entityProviderIds,
|
||||
ServerPingPayload::new);
|
||||
ServerHandshakePayload::entityProviderIds,
|
||||
ServerHandshakePayload::new);
|
||||
|
||||
@Override
|
||||
public void write(FriendlyByteBuf buf) {
|
||||
CODEC.encode(new RegistryFriendlyByteBuf(buf, MinecraftServer.getServer().registryAccess()), this);
|
||||
CODEC.encode(ProtocolUtils.decorate(buf), this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -0,0 +1,35 @@
|
||||
package org.leavesmc.leaves.protocol.jade.provider.entity;
|
||||
|
||||
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||
import net.minecraft.network.codec.StreamCodec;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.Mob;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.leavesmc.leaves.protocol.jade.JadeProtocol;
|
||||
import org.leavesmc.leaves.protocol.jade.accessor.EntityAccessor;
|
||||
import org.leavesmc.leaves.protocol.jade.provider.StreamServerDataProvider;
|
||||
|
||||
public enum PetArmorProvider implements StreamServerDataProvider<EntityAccessor, ItemStack> {
|
||||
INSTANCE;
|
||||
|
||||
private static final ResourceLocation MC_PET_ARMOR = JadeProtocol.mc_id("pet_armor");
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ItemStack streamData(@NotNull EntityAccessor accessor) {
|
||||
ItemStack armor = ((Mob) accessor.getEntity()).getBodyArmorItem();
|
||||
return armor.isEmpty() ? null : armor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StreamCodec<RegistryFriendlyByteBuf, ItemStack> streamCodec() {
|
||||
return ItemStack.OPTIONAL_STREAM_CODEC;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getUid() {
|
||||
return MC_PET_ARMOR;
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,6 @@ public enum PacketType {
|
||||
public final ResourceLocation identifier;
|
||||
|
||||
PacketType(final String id) {
|
||||
identifier = new ResourceLocation(SyncmaticaProtocol.PROTOCOL_ID, id);
|
||||
identifier = ResourceLocation.tryBuild(SyncmaticaProtocol.PROTOCOL_ID, id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import org.leavesmc.leaves.protocol.core.LeavesCustomPayload;
|
||||
public record SyncmaticaPayload(ResourceLocation packetType,
|
||||
FriendlyByteBuf data) implements LeavesCustomPayload<SyncmaticaPayload> {
|
||||
|
||||
private static final ResourceLocation NETWORK_ID = new ResourceLocation(SyncmaticaProtocol.PROTOCOL_ID, "main");
|
||||
private static final ResourceLocation NETWORK_ID = ResourceLocation.tryBuild(SyncmaticaProtocol.PROTOCOL_ID, "main");
|
||||
|
||||
@New
|
||||
public static SyncmaticaPayload decode(ResourceLocation location, FriendlyByteBuf buf) {
|
||||
|
||||
@@ -60,7 +60,7 @@ public class ServerPhotographer extends ServerPlayer {
|
||||
photographer.createState = state;
|
||||
|
||||
photographer.recorder.start();
|
||||
MinecraftServer.getServer().getPlayerList().placeNewPhotographer(photographer.recorder, photographer, world, state.loc);
|
||||
MinecraftServer.getServer().getPlayerList().placeNewPhotographer(photographer.recorder, photographer, world);
|
||||
photographer.serverLevel().chunkSource.move(photographer);
|
||||
photographer.setInvisible(true);
|
||||
photographers.add(photographer);
|
||||
|
||||
Reference in New Issue
Block a user