mirror of
https://github.com/GeyserMC/MCProtocolLib.git
synced 2024-11-14 19:34:58 -05:00
Merge remote-tracking branch 'origin/master' into feature/math-2.0
This commit is contained in:
commit
8b5631f785
18 changed files with 128 additions and 97 deletions
28
.github/workflows/deploy.yml
vendored
Normal file
28
.github/workflows/deploy.yml
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
name: Deploy
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Set up JDK 1.8
|
||||
uses: actions/setup-java@v1
|
||||
with:
|
||||
java-version: 8
|
||||
distribution: temurin
|
||||
overwrite-settings: true
|
||||
server-id: opencollab-snapshot-repo
|
||||
server-username: MAVEN_USERNAME
|
||||
server-password: MAVEN_PASSWORD
|
||||
- name: Deploy with Maven
|
||||
run: mvn deploy -B -P deploy
|
||||
env:
|
||||
MAVEN_USERNAME: ${{ vars.DEPLOY_USER }}
|
||||
MAVEN_PASSWORD: ${{ secrets.DEPLOY_PASS }}
|
2
.github/workflows/maven.yml
vendored
2
.github/workflows/maven.yml
vendored
|
@ -14,4 +14,4 @@ jobs:
|
|||
with:
|
||||
java-version: 1.8
|
||||
- name: Build with Maven
|
||||
run: mvn package --file pom.xml
|
||||
run: mvn package -B
|
||||
|
|
56
Jenkinsfile
vendored
56
Jenkinsfile
vendored
|
@ -12,67 +12,17 @@ pipeline {
|
|||
steps {
|
||||
sh 'mvn clean package'
|
||||
}
|
||||
post {
|
||||
success {
|
||||
archiveArtifacts artifacts: 'target/*.jar', excludes: 'target/*-sources.jar', fingerprint: true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage ('Deploy') {
|
||||
when {
|
||||
branch "master"
|
||||
}
|
||||
pipeline {
|
||||
agent any
|
||||
tools {
|
||||
maven 'Maven 3'
|
||||
jdk 'Java 8'
|
||||
}
|
||||
options {
|
||||
buildDiscarder(logRotator(artifactNumToKeepStr: '20'))
|
||||
}
|
||||
stages {
|
||||
stage ('Build') {
|
||||
steps {
|
||||
sh 'mvn clean package'
|
||||
}
|
||||
post {
|
||||
success {
|
||||
archiveArtifacts artifacts: 'target/*.jar', excludes: 'target/*-sources.jar', fingerprint: true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage ('Deploy') {
|
||||
stage ('Javadocs') {
|
||||
when {
|
||||
branch "master"
|
||||
}
|
||||
|
||||
steps {
|
||||
rtMavenDeployer(
|
||||
id: "maven-deployer",
|
||||
serverId: "opencollab-artifactory",
|
||||
releaseRepo: "maven-releases",
|
||||
snapshotRepo: "maven-snapshots"
|
||||
)
|
||||
rtMavenResolver(
|
||||
id: "maven-resolver",
|
||||
serverId: "opencollab-artifactory",
|
||||
releaseRepo: "maven-deploy-release",
|
||||
snapshotRepo: "maven-deploy-snapshot"
|
||||
)
|
||||
rtMavenRun(
|
||||
pom: 'pom.xml',
|
||||
goals: 'javadoc:javadoc javadoc:jar source:jar install -DskipTests',
|
||||
deployerId: "maven-deployer",
|
||||
resolverId: "maven-resolver"
|
||||
)
|
||||
rtPublishBuildInfo(
|
||||
serverId: "opencollab-artifactory"
|
||||
)
|
||||
sh 'mvn javadoc:javadoc'
|
||||
step([$class: 'JavadocArchiver', javadocDir: 'target/site/apidocs', keepAll: false])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
19
pom.xml
19
pom.xml
|
@ -247,4 +247,23 @@
|
|||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>deploy</id>
|
||||
<activation>
|
||||
<activeByDefault>true</activeByDefault>
|
||||
</activation>
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>opencollab-release-repo</id>
|
||||
<url>https://repo.opencollab.dev/maven-releases/</url>
|
||||
</repository>
|
||||
<snapshotRepository>
|
||||
<id>opencollab-snapshot-repo</id>
|
||||
<url>https://repo.opencollab.dev/maven-snapshots/</url>
|
||||
</snapshotRepository>
|
||||
</distributionManagement>
|
||||
</profile>
|
||||
</profiles>
|
||||
</project>
|
||||
|
|
|
@ -199,9 +199,9 @@ public class MinecraftCodec {
|
|||
}
|
||||
|
||||
public static final PacketCodec CODEC = PacketCodec.builder()
|
||||
.protocolVersion((1 << 30) | 120)
|
||||
.protocolVersion(762)
|
||||
.helper(() -> new MinecraftCodecHelper(LEVEL_EVENTS, SOUND_NAMES))
|
||||
.minecraftVersion("1.19.4 Pre-release 1")
|
||||
.minecraftVersion("1.19.4")
|
||||
.state(ProtocolState.HANDSHAKE, PacketStateCodec.builder()
|
||||
.registerServerboundPacket(0x00, ClientIntentionPacket.class, ClientIntentionPacket::new)
|
||||
)
|
||||
|
|
|
@ -347,7 +347,7 @@ public class MinecraftCodecHelper extends BasePacketCodecHelper {
|
|||
}
|
||||
|
||||
public Component readComponent(ByteBuf buf) {
|
||||
return DefaultComponentSerializer.get().deserialize(this.readString(buf));
|
||||
return DefaultComponentSerializer.get().deserialize(this.readString(buf, 262144));
|
||||
}
|
||||
|
||||
public void writeComponent(ByteBuf buf, Component component) {
|
||||
|
|
|
@ -5,6 +5,8 @@ import lombok.AllArgsConstructor;
|
|||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
|
||||
import java.util.OptionalInt;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class CommandNode {
|
||||
|
@ -24,9 +26,9 @@ public class CommandNode {
|
|||
private final @NonNull int[] childIndices;
|
||||
|
||||
/**
|
||||
* Redirect index, or -1 if none is set.
|
||||
* Redirect index, or empty if none is set.
|
||||
*/
|
||||
private final int redirectIndex;
|
||||
private final OptionalInt redirectIndex;
|
||||
|
||||
/**
|
||||
* Name of the node, if type is LITERAL or ARGUMENT.
|
||||
|
|
|
@ -16,4 +16,5 @@ public class ShapedRecipeData implements RecipeData {
|
|||
private final @NonNull CraftingBookCategory category;
|
||||
private final @NonNull Ingredient[] ingredients;
|
||||
private final ItemStack result;
|
||||
private final boolean showNotification;
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ public enum NameTagVisibility {
|
|||
|
||||
static {
|
||||
for (NameTagVisibility option : values()) {
|
||||
VALUES.put(option.name(), option);
|
||||
VALUES.put(option.getName(), option);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,8 @@ import lombok.Data;
|
|||
import lombok.NonNull;
|
||||
import lombok.With;
|
||||
|
||||
import java.util.OptionalInt;
|
||||
|
||||
@Data
|
||||
@With
|
||||
@AllArgsConstructor
|
||||
|
@ -42,9 +44,11 @@ public class ClientboundCommandsPacket implements MinecraftPacket {
|
|||
children[j] = helper.readVarInt(in);
|
||||
}
|
||||
|
||||
int redirectIndex = 0;
|
||||
OptionalInt redirectIndex;
|
||||
if ((flags & FLAG_REDIRECT) != 0) {
|
||||
redirectIndex = helper.readVarInt(in);
|
||||
redirectIndex = OptionalInt.of(helper.readVarInt(in));
|
||||
} else {
|
||||
redirectIndex = OptionalInt.empty();
|
||||
}
|
||||
|
||||
String name = null;
|
||||
|
@ -163,7 +167,7 @@ public class ClientboundCommandsPacket implements MinecraftPacket {
|
|||
flags |= FLAG_EXECUTABLE;
|
||||
}
|
||||
|
||||
if (node.getRedirectIndex() != 0) {
|
||||
if (node.getRedirectIndex().isPresent()) {
|
||||
flags |= FLAG_REDIRECT;
|
||||
}
|
||||
|
||||
|
@ -178,8 +182,8 @@ public class ClientboundCommandsPacket implements MinecraftPacket {
|
|||
helper.writeVarInt(out, childIndex);
|
||||
}
|
||||
|
||||
if (node.getRedirectIndex() != 0) {
|
||||
helper.writeVarInt(out, node.getRedirectIndex());
|
||||
if (node.getRedirectIndex().isPresent()) {
|
||||
helper.writeVarInt(out, node.getRedirectIndex().getAsInt());
|
||||
}
|
||||
|
||||
if (node.getType() == CommandType.LITERAL || node.getType() == CommandType.ARGUMENT) {
|
||||
|
|
|
@ -2,7 +2,6 @@ package com.github.steveice10.mc.protocol.packet.ingame.clientbound;
|
|||
|
||||
import com.github.steveice10.mc.protocol.codec.MinecraftCodecHelper;
|
||||
import com.github.steveice10.mc.protocol.codec.MinecraftPacket;
|
||||
import com.github.steveice10.mc.protocol.data.game.Identifier;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack;
|
||||
import com.github.steveice10.mc.protocol.data.game.recipe.CraftingBookCategory;
|
||||
import com.github.steveice10.mc.protocol.data.game.recipe.Ingredient;
|
||||
|
@ -54,8 +53,9 @@ public class ClientboundUpdateRecipesPacket implements MinecraftPacket {
|
|||
}
|
||||
|
||||
ItemStack result = helper.readItemStack(in);
|
||||
boolean showNotification = in.readBoolean();
|
||||
|
||||
data = new ShapedRecipeData(width, height, group, category, ingredients, result);
|
||||
data = new ShapedRecipeData(width, height, group, category, ingredients, result, showNotification);
|
||||
break;
|
||||
}
|
||||
case SMELTING:
|
||||
|
@ -152,6 +152,7 @@ public class ClientboundUpdateRecipesPacket implements MinecraftPacket {
|
|||
}
|
||||
|
||||
helper.writeItemStack(out, data.getResult());
|
||||
out.writeBoolean(data.isShowNotification());
|
||||
break;
|
||||
}
|
||||
case SMELTING:
|
||||
|
|
|
@ -19,14 +19,14 @@ import java.util.Map;
|
|||
public class ClientboundUpdateTagsPacket implements MinecraftPacket {
|
||||
private final @NonNull Map<String, Map<String, int[]>> tags = new HashMap<>();
|
||||
|
||||
public ClientboundUpdateTagsPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException {
|
||||
public ClientboundUpdateTagsPacket(ByteBuf in, MinecraftCodecHelper helper) {
|
||||
int totalTagCount = helper.readVarInt(in);
|
||||
for (int i = 0; i < totalTagCount; i++) {
|
||||
Map<String, int[]> tag = new HashMap<>();
|
||||
String tagName = Identifier.formalize(helper.readString(in));
|
||||
String tagName = helper.readResourceLocation(in);
|
||||
int tagsCount = helper.readVarInt(in);
|
||||
for (int j = 0; j < tagsCount; j++) {
|
||||
String name = helper.readString(in);
|
||||
String name = helper.readResourceLocation(in);
|
||||
int entriesCount = helper.readVarInt(in);
|
||||
int[] entries = new int[entriesCount];
|
||||
for (int index = 0; index < entriesCount; index++) {
|
||||
|
@ -40,13 +40,13 @@ public class ClientboundUpdateTagsPacket implements MinecraftPacket {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException {
|
||||
public void serialize(ByteBuf out, MinecraftCodecHelper helper) {
|
||||
helper.writeVarInt(out, tags.size());
|
||||
for (Map.Entry<String, Map<String, int[]>> tagSet : tags.entrySet()) {
|
||||
helper.writeString(out, tagSet.getKey());
|
||||
helper.writeResourceLocation(out, tagSet.getKey());
|
||||
helper.writeVarInt(out, tagSet.getValue().size());
|
||||
for (Map.Entry<String, int[]> tag : tagSet.getValue().entrySet()) {
|
||||
helper.writeString(out, tag.getKey());
|
||||
helper.writeResourceLocation(out, tag.getKey());
|
||||
helper.writeVarInt(out, tag.getValue().length);
|
||||
for (int id : tag.getValue()) {
|
||||
helper.writeVarInt(out, id);
|
||||
|
|
|
@ -16,17 +16,17 @@ import org.cloudburstmc.math.vector.Vector3i;
|
|||
@AllArgsConstructor
|
||||
public class ClientboundBlockEventPacket implements MinecraftPacket {
|
||||
// Do we really want these hardcoded values?
|
||||
private static final int NOTE_BLOCK = 93;
|
||||
private static final int STICKY_PISTON = 112;
|
||||
private static final int PISTON = 119;
|
||||
private static final int MOB_SPAWNER = 165;
|
||||
private static final int CHEST = 167;
|
||||
private static final int ENDER_CHEST = 328;
|
||||
private static final int TRAPPED_CHEST = 392;
|
||||
private static final int END_GATEWAY = 576;
|
||||
private static final int SHULKER_BOX_LOWER = 586;
|
||||
private static final int SHULKER_BOX_HIGHER = 602;
|
||||
private static final int BELL = 755;
|
||||
private static final int NOTE_BLOCK = 101;
|
||||
private static final int STICKY_PISTON = 120;
|
||||
private static final int PISTON = 127;
|
||||
private static final int MOB_SPAWNER = 174;
|
||||
private static final int CHEST = 176;
|
||||
private static final int ENDER_CHEST = 343;
|
||||
private static final int TRAPPED_CHEST = 410;
|
||||
private static final int END_GATEWAY = 600;
|
||||
private static final int SHULKER_BOX_LOWER = 610;
|
||||
private static final int SHULKER_BOX_HIGHER = 626;
|
||||
private static final int BELL = 779;
|
||||
|
||||
private final @NonNull Vector3i position;
|
||||
private final @NonNull BlockValueType type;
|
||||
|
|
|
@ -2,7 +2,6 @@ package com.github.steveice10.mc.protocol.packet.ingame.clientbound.scoreboard;
|
|||
|
||||
import com.github.steveice10.mc.protocol.codec.MinecraftCodecHelper;
|
||||
import com.github.steveice10.mc.protocol.codec.MinecraftPacket;
|
||||
import com.github.steveice10.mc.protocol.data.DefaultComponentSerializer;
|
||||
import com.github.steveice10.mc.protocol.data.game.scoreboard.CollisionRule;
|
||||
import com.github.steveice10.mc.protocol.data.game.scoreboard.NameTagVisibility;
|
||||
import com.github.steveice10.mc.protocol.data.game.scoreboard.TeamAction;
|
||||
|
@ -11,6 +10,7 @@ import io.netty.buffer.ByteBuf;
|
|||
import lombok.*;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
|
||||
|
@ -26,8 +26,8 @@ public class ClientboundSetPlayerTeamPacket implements MinecraftPacket {
|
|||
private final Component suffix;
|
||||
private final boolean friendlyFire;
|
||||
private final boolean seeFriendlyInvisibles;
|
||||
private final NameTagVisibility nameTagVisibility;
|
||||
private final CollisionRule collisionRule;
|
||||
private final @Nullable NameTagVisibility nameTagVisibility;
|
||||
private final @Nullable CollisionRule collisionRule;
|
||||
private final TeamColor color;
|
||||
|
||||
private final String[] players;
|
||||
|
@ -147,8 +147,8 @@ public class ClientboundSetPlayerTeamPacket implements MinecraftPacket {
|
|||
if (this.action == TeamAction.CREATE || this.action == TeamAction.UPDATE) {
|
||||
helper.writeComponent(out, this.displayName);
|
||||
out.writeByte((this.friendlyFire ? 0x1 : 0x0) | (this.seeFriendlyInvisibles ? 0x2 : 0x0));
|
||||
helper.writeString(out, this.nameTagVisibility.getName());
|
||||
helper.writeString(out, this.collisionRule.getName());
|
||||
helper.writeString(out, this.nameTagVisibility == null ? "" : this.nameTagVisibility.getName());
|
||||
helper.writeString(out, this.collisionRule == null ? "" : this.collisionRule.getName());
|
||||
helper.writeVarInt(out, this.color.ordinal());
|
||||
helper.writeComponent(out, this.prefix);
|
||||
helper.writeComponent(out, this.suffix);
|
||||
|
|
|
@ -29,7 +29,7 @@ public class ServerboundSeenAdvancementsPacket implements MinecraftPacket {
|
|||
}
|
||||
|
||||
/**
|
||||
* @throws IllegalStateException if {@link #getAction()} is not {@link AdvancementTabAction#OPENED_TAB}.
|
||||
* @throws IllegalStateException if #getAction() is not {@link AdvancementTabAction#OPENED_TAB}.
|
||||
*/
|
||||
public String getTabId() {
|
||||
if (this.action != AdvancementTabAction.OPENED_TAB) {
|
||||
|
|
|
@ -9,6 +9,8 @@ import com.github.steveice10.mc.protocol.data.game.command.properties.StringProp
|
|||
import com.github.steveice10.mc.protocol.packet.PacketTest;
|
||||
import org.junit.Before;
|
||||
|
||||
import java.util.OptionalInt;
|
||||
|
||||
public class ClientboundCommandsPacketTest extends PacketTest {
|
||||
@Before
|
||||
public void setup() {
|
||||
|
@ -18,7 +20,7 @@ public class ClientboundCommandsPacketTest extends PacketTest {
|
|||
CommandType.ROOT,
|
||||
true,
|
||||
new int[]{1, 2},
|
||||
0,
|
||||
OptionalInt.empty(),
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
|
@ -28,7 +30,7 @@ public class ClientboundCommandsPacketTest extends PacketTest {
|
|||
CommandType.LITERAL,
|
||||
false,
|
||||
new int[]{3, 4},
|
||||
0,
|
||||
OptionalInt.empty(),
|
||||
"Literal",
|
||||
null,
|
||||
null,
|
||||
|
@ -38,7 +40,7 @@ public class ClientboundCommandsPacketTest extends PacketTest {
|
|||
CommandType.ARGUMENT,
|
||||
false,
|
||||
new int[0],
|
||||
3,
|
||||
OptionalInt.of(3),
|
||||
"Argument1",
|
||||
CommandParser.DOUBLE,
|
||||
new DoubleProperties(),
|
||||
|
@ -48,7 +50,7 @@ public class ClientboundCommandsPacketTest extends PacketTest {
|
|||
CommandType.ARGUMENT,
|
||||
false,
|
||||
new int[0],
|
||||
0,
|
||||
OptionalInt.empty(),
|
||||
"Argument2",
|
||||
CommandParser.DOUBLE,
|
||||
new DoubleProperties(0, 100),
|
||||
|
@ -58,7 +60,7 @@ public class ClientboundCommandsPacketTest extends PacketTest {
|
|||
CommandType.ARGUMENT,
|
||||
false,
|
||||
new int[0],
|
||||
0,
|
||||
OptionalInt.empty(),
|
||||
"Argument3",
|
||||
CommandParser.STRING,
|
||||
StringProperties.SINGLE_WORD,
|
||||
|
@ -68,7 +70,7 @@ public class ClientboundCommandsPacketTest extends PacketTest {
|
|||
CommandType.ARGUMENT,
|
||||
false,
|
||||
new int[0],
|
||||
0,
|
||||
OptionalInt.empty(),
|
||||
"Argument4",
|
||||
CommandParser.STRING,
|
||||
StringProperties.SINGLE_WORD,
|
||||
|
|
|
@ -62,7 +62,8 @@ public class ServerDeclareRecipesTest extends PacketTest {
|
|||
new ItemStack(6)
|
||||
})
|
||||
},
|
||||
new ItemStack(20)
|
||||
new ItemStack(20),
|
||||
true
|
||||
)
|
||||
),
|
||||
new Recipe(
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
package com.github.steveice10.mc.protocol.packet.ingame.clientbound.level;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.scoreboard.CollisionRule;
|
||||
import com.github.steveice10.mc.protocol.data.game.scoreboard.NameTagVisibility;
|
||||
import com.github.steveice10.mc.protocol.data.game.scoreboard.TeamColor;
|
||||
import com.github.steveice10.mc.protocol.packet.PacketTest;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.scoreboard.ClientboundSetPlayerTeamPacket;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.junit.Before;
|
||||
|
||||
public class ClientboundSetPlayerTeamPacketTest extends PacketTest {
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
// Test nameTagVisibility and collisionRule encoding/decoding
|
||||
this.setPackets(
|
||||
new ClientboundSetPlayerTeamPacket("dummy", Component.empty(), Component.empty(), Component.empty(),
|
||||
true, false, NameTagVisibility.NEVER, CollisionRule.PUSH_OWN_TEAM, TeamColor.RESET),
|
||||
new ClientboundSetPlayerTeamPacket("dummy", Component.empty(), Component.empty(), Component.empty(),
|
||||
false, true, NameTagVisibility.HIDE_FOR_OTHER_TEAMS, CollisionRule.PUSH_OTHER_TEAMS, TeamColor.RED)
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue