Merge remote-tracking branch 'origin/master' into feature/math-2.0

This commit is contained in:
Camotoy 2023-04-06 12:18:52 -04:00
commit 8b5631f785
18 changed files with 128 additions and 97 deletions

28
.github/workflows/deploy.yml vendored Normal file
View 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 }}

View file

@ -14,4 +14,4 @@ jobs:
with: with:
java-version: 1.8 java-version: 1.8
- name: Build with Maven - name: Build with Maven
run: mvn package --file pom.xml run: mvn package -B

56
Jenkinsfile vendored
View file

@ -12,67 +12,17 @@ pipeline {
steps { steps {
sh 'mvn clean package' sh 'mvn clean package'
} }
post {
success {
archiveArtifacts artifacts: 'target/*.jar', excludes: 'target/*-sources.jar', fingerprint: true
}
}
} }
stage ('Deploy') { stage ('Javadocs') {
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') {
when { when {
branch "master" branch "master"
} }
steps { steps {
rtMavenDeployer( sh 'mvn javadoc:javadoc'
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"
)
step([$class: 'JavadocArchiver', javadocDir: 'target/site/apidocs', keepAll: false]) step([$class: 'JavadocArchiver', javadocDir: 'target/site/apidocs', keepAll: false])
} }
} }
} }
} }

19
pom.xml
View file

@ -247,4 +247,23 @@
</plugin> </plugin>
</plugins> </plugins>
</build> </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> </project>

View file

@ -199,9 +199,9 @@ public class MinecraftCodec {
} }
public static final PacketCodec CODEC = PacketCodec.builder() public static final PacketCodec CODEC = PacketCodec.builder()
.protocolVersion((1 << 30) | 120) .protocolVersion(762)
.helper(() -> new MinecraftCodecHelper(LEVEL_EVENTS, SOUND_NAMES)) .helper(() -> new MinecraftCodecHelper(LEVEL_EVENTS, SOUND_NAMES))
.minecraftVersion("1.19.4 Pre-release 1") .minecraftVersion("1.19.4")
.state(ProtocolState.HANDSHAKE, PacketStateCodec.builder() .state(ProtocolState.HANDSHAKE, PacketStateCodec.builder()
.registerServerboundPacket(0x00, ClientIntentionPacket.class, ClientIntentionPacket::new) .registerServerboundPacket(0x00, ClientIntentionPacket.class, ClientIntentionPacket::new)
) )

View file

@ -347,7 +347,7 @@ public class MinecraftCodecHelper extends BasePacketCodecHelper {
} }
public Component readComponent(ByteBuf buf) { 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) { public void writeComponent(ByteBuf buf, Component component) {

View file

@ -5,6 +5,8 @@ import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NonNull; import lombok.NonNull;
import java.util.OptionalInt;
@Data @Data
@AllArgsConstructor @AllArgsConstructor
public class CommandNode { public class CommandNode {
@ -24,9 +26,9 @@ public class CommandNode {
private final @NonNull int[] childIndices; 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. * Name of the node, if type is LITERAL or ARGUMENT.

View file

@ -16,4 +16,5 @@ public class ShapedRecipeData implements RecipeData {
private final @NonNull CraftingBookCategory category; private final @NonNull CraftingBookCategory category;
private final @NonNull Ingredient[] ingredients; private final @NonNull Ingredient[] ingredients;
private final ItemStack result; private final ItemStack result;
private final boolean showNotification;
} }

View file

@ -27,7 +27,7 @@ public enum NameTagVisibility {
static { static {
for (NameTagVisibility option : values()) { for (NameTagVisibility option : values()) {
VALUES.put(option.name(), option); VALUES.put(option.getName(), option);
} }
} }
} }

View file

@ -12,6 +12,8 @@ import lombok.Data;
import lombok.NonNull; import lombok.NonNull;
import lombok.With; import lombok.With;
import java.util.OptionalInt;
@Data @Data
@With @With
@AllArgsConstructor @AllArgsConstructor
@ -42,9 +44,11 @@ public class ClientboundCommandsPacket implements MinecraftPacket {
children[j] = helper.readVarInt(in); children[j] = helper.readVarInt(in);
} }
int redirectIndex = 0; OptionalInt redirectIndex;
if ((flags & FLAG_REDIRECT) != 0) { if ((flags & FLAG_REDIRECT) != 0) {
redirectIndex = helper.readVarInt(in); redirectIndex = OptionalInt.of(helper.readVarInt(in));
} else {
redirectIndex = OptionalInt.empty();
} }
String name = null; String name = null;
@ -163,7 +167,7 @@ public class ClientboundCommandsPacket implements MinecraftPacket {
flags |= FLAG_EXECUTABLE; flags |= FLAG_EXECUTABLE;
} }
if (node.getRedirectIndex() != 0) { if (node.getRedirectIndex().isPresent()) {
flags |= FLAG_REDIRECT; flags |= FLAG_REDIRECT;
} }
@ -178,8 +182,8 @@ public class ClientboundCommandsPacket implements MinecraftPacket {
helper.writeVarInt(out, childIndex); helper.writeVarInt(out, childIndex);
} }
if (node.getRedirectIndex() != 0) { if (node.getRedirectIndex().isPresent()) {
helper.writeVarInt(out, node.getRedirectIndex()); helper.writeVarInt(out, node.getRedirectIndex().getAsInt());
} }
if (node.getType() == CommandType.LITERAL || node.getType() == CommandType.ARGUMENT) { if (node.getType() == CommandType.LITERAL || node.getType() == CommandType.ARGUMENT) {

View file

@ -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.MinecraftCodecHelper;
import com.github.steveice10.mc.protocol.codec.MinecraftPacket; 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.entity.metadata.ItemStack;
import com.github.steveice10.mc.protocol.data.game.recipe.CraftingBookCategory; import com.github.steveice10.mc.protocol.data.game.recipe.CraftingBookCategory;
import com.github.steveice10.mc.protocol.data.game.recipe.Ingredient; import com.github.steveice10.mc.protocol.data.game.recipe.Ingredient;
@ -54,8 +53,9 @@ public class ClientboundUpdateRecipesPacket implements MinecraftPacket {
} }
ItemStack result = helper.readItemStack(in); 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; break;
} }
case SMELTING: case SMELTING:
@ -152,6 +152,7 @@ public class ClientboundUpdateRecipesPacket implements MinecraftPacket {
} }
helper.writeItemStack(out, data.getResult()); helper.writeItemStack(out, data.getResult());
out.writeBoolean(data.isShowNotification());
break; break;
} }
case SMELTING: case SMELTING:

View file

@ -19,14 +19,14 @@ import java.util.Map;
public class ClientboundUpdateTagsPacket implements MinecraftPacket { public class ClientboundUpdateTagsPacket implements MinecraftPacket {
private final @NonNull Map<String, Map<String, int[]>> tags = new HashMap<>(); 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); int totalTagCount = helper.readVarInt(in);
for (int i = 0; i < totalTagCount; i++) { for (int i = 0; i < totalTagCount; i++) {
Map<String, int[]> tag = new HashMap<>(); Map<String, int[]> tag = new HashMap<>();
String tagName = Identifier.formalize(helper.readString(in)); String tagName = helper.readResourceLocation(in);
int tagsCount = helper.readVarInt(in); int tagsCount = helper.readVarInt(in);
for (int j = 0; j < tagsCount; j++) { for (int j = 0; j < tagsCount; j++) {
String name = helper.readString(in); String name = helper.readResourceLocation(in);
int entriesCount = helper.readVarInt(in); int entriesCount = helper.readVarInt(in);
int[] entries = new int[entriesCount]; int[] entries = new int[entriesCount];
for (int index = 0; index < entriesCount; index++) { for (int index = 0; index < entriesCount; index++) {
@ -40,13 +40,13 @@ public class ClientboundUpdateTagsPacket implements MinecraftPacket {
} }
@Override @Override
public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { public void serialize(ByteBuf out, MinecraftCodecHelper helper) {
helper.writeVarInt(out, tags.size()); helper.writeVarInt(out, tags.size());
for (Map.Entry<String, Map<String, int[]>> tagSet : tags.entrySet()) { 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()); helper.writeVarInt(out, tagSet.getValue().size());
for (Map.Entry<String, int[]> tag : tagSet.getValue().entrySet()) { 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); helper.writeVarInt(out, tag.getValue().length);
for (int id : tag.getValue()) { for (int id : tag.getValue()) {
helper.writeVarInt(out, id); helper.writeVarInt(out, id);

View file

@ -16,17 +16,17 @@ import org.cloudburstmc.math.vector.Vector3i;
@AllArgsConstructor @AllArgsConstructor
public class ClientboundBlockEventPacket implements MinecraftPacket { public class ClientboundBlockEventPacket implements MinecraftPacket {
// Do we really want these hardcoded values? // Do we really want these hardcoded values?
private static final int NOTE_BLOCK = 93; private static final int NOTE_BLOCK = 101;
private static final int STICKY_PISTON = 112; private static final int STICKY_PISTON = 120;
private static final int PISTON = 119; private static final int PISTON = 127;
private static final int MOB_SPAWNER = 165; private static final int MOB_SPAWNER = 174;
private static final int CHEST = 167; private static final int CHEST = 176;
private static final int ENDER_CHEST = 328; private static final int ENDER_CHEST = 343;
private static final int TRAPPED_CHEST = 392; private static final int TRAPPED_CHEST = 410;
private static final int END_GATEWAY = 576; private static final int END_GATEWAY = 600;
private static final int SHULKER_BOX_LOWER = 586; private static final int SHULKER_BOX_LOWER = 610;
private static final int SHULKER_BOX_HIGHER = 602; private static final int SHULKER_BOX_HIGHER = 626;
private static final int BELL = 755; private static final int BELL = 779;
private final @NonNull Vector3i position; private final @NonNull Vector3i position;
private final @NonNull BlockValueType type; private final @NonNull BlockValueType type;

View file

@ -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.MinecraftCodecHelper;
import com.github.steveice10.mc.protocol.codec.MinecraftPacket; 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.CollisionRule;
import com.github.steveice10.mc.protocol.data.game.scoreboard.NameTagVisibility; import com.github.steveice10.mc.protocol.data.game.scoreboard.NameTagVisibility;
import com.github.steveice10.mc.protocol.data.game.scoreboard.TeamAction; import com.github.steveice10.mc.protocol.data.game.scoreboard.TeamAction;
@ -11,6 +10,7 @@ import io.netty.buffer.ByteBuf;
import lombok.*; import lombok.*;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import javax.annotation.Nullable;
import java.io.IOException; import java.io.IOException;
import java.util.Arrays; import java.util.Arrays;
@ -26,8 +26,8 @@ public class ClientboundSetPlayerTeamPacket implements MinecraftPacket {
private final Component suffix; private final Component suffix;
private final boolean friendlyFire; private final boolean friendlyFire;
private final boolean seeFriendlyInvisibles; private final boolean seeFriendlyInvisibles;
private final NameTagVisibility nameTagVisibility; private final @Nullable NameTagVisibility nameTagVisibility;
private final CollisionRule collisionRule; private final @Nullable CollisionRule collisionRule;
private final TeamColor color; private final TeamColor color;
private final String[] players; private final String[] players;
@ -147,8 +147,8 @@ public class ClientboundSetPlayerTeamPacket implements MinecraftPacket {
if (this.action == TeamAction.CREATE || this.action == TeamAction.UPDATE) { if (this.action == TeamAction.CREATE || this.action == TeamAction.UPDATE) {
helper.writeComponent(out, this.displayName); helper.writeComponent(out, this.displayName);
out.writeByte((this.friendlyFire ? 0x1 : 0x0) | (this.seeFriendlyInvisibles ? 0x2 : 0x0)); out.writeByte((this.friendlyFire ? 0x1 : 0x0) | (this.seeFriendlyInvisibles ? 0x2 : 0x0));
helper.writeString(out, this.nameTagVisibility.getName()); helper.writeString(out, this.nameTagVisibility == null ? "" : this.nameTagVisibility.getName());
helper.writeString(out, this.collisionRule.getName()); helper.writeString(out, this.collisionRule == null ? "" : this.collisionRule.getName());
helper.writeVarInt(out, this.color.ordinal()); helper.writeVarInt(out, this.color.ordinal());
helper.writeComponent(out, this.prefix); helper.writeComponent(out, this.prefix);
helper.writeComponent(out, this.suffix); helper.writeComponent(out, this.suffix);

View file

@ -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() { public String getTabId() {
if (this.action != AdvancementTabAction.OPENED_TAB) { if (this.action != AdvancementTabAction.OPENED_TAB) {

View file

@ -9,6 +9,8 @@ import com.github.steveice10.mc.protocol.data.game.command.properties.StringProp
import com.github.steveice10.mc.protocol.packet.PacketTest; import com.github.steveice10.mc.protocol.packet.PacketTest;
import org.junit.Before; import org.junit.Before;
import java.util.OptionalInt;
public class ClientboundCommandsPacketTest extends PacketTest { public class ClientboundCommandsPacketTest extends PacketTest {
@Before @Before
public void setup() { public void setup() {
@ -18,7 +20,7 @@ public class ClientboundCommandsPacketTest extends PacketTest {
CommandType.ROOT, CommandType.ROOT,
true, true,
new int[]{1, 2}, new int[]{1, 2},
0, OptionalInt.empty(),
null, null,
null, null,
null, null,
@ -28,7 +30,7 @@ public class ClientboundCommandsPacketTest extends PacketTest {
CommandType.LITERAL, CommandType.LITERAL,
false, false,
new int[]{3, 4}, new int[]{3, 4},
0, OptionalInt.empty(),
"Literal", "Literal",
null, null,
null, null,
@ -38,7 +40,7 @@ public class ClientboundCommandsPacketTest extends PacketTest {
CommandType.ARGUMENT, CommandType.ARGUMENT,
false, false,
new int[0], new int[0],
3, OptionalInt.of(3),
"Argument1", "Argument1",
CommandParser.DOUBLE, CommandParser.DOUBLE,
new DoubleProperties(), new DoubleProperties(),
@ -48,7 +50,7 @@ public class ClientboundCommandsPacketTest extends PacketTest {
CommandType.ARGUMENT, CommandType.ARGUMENT,
false, false,
new int[0], new int[0],
0, OptionalInt.empty(),
"Argument2", "Argument2",
CommandParser.DOUBLE, CommandParser.DOUBLE,
new DoubleProperties(0, 100), new DoubleProperties(0, 100),
@ -58,7 +60,7 @@ public class ClientboundCommandsPacketTest extends PacketTest {
CommandType.ARGUMENT, CommandType.ARGUMENT,
false, false,
new int[0], new int[0],
0, OptionalInt.empty(),
"Argument3", "Argument3",
CommandParser.STRING, CommandParser.STRING,
StringProperties.SINGLE_WORD, StringProperties.SINGLE_WORD,
@ -68,7 +70,7 @@ public class ClientboundCommandsPacketTest extends PacketTest {
CommandType.ARGUMENT, CommandType.ARGUMENT,
false, false,
new int[0], new int[0],
0, OptionalInt.empty(),
"Argument4", "Argument4",
CommandParser.STRING, CommandParser.STRING,
StringProperties.SINGLE_WORD, StringProperties.SINGLE_WORD,

View file

@ -62,7 +62,8 @@ public class ServerDeclareRecipesTest extends PacketTest {
new ItemStack(6) new ItemStack(6)
}) })
}, },
new ItemStack(20) new ItemStack(20),
true
) )
), ),
new Recipe( new Recipe(

View file

@ -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)
);
}
}