Skip to content

Commit d1f0618

Browse files
committed
Merge branch '2.0' into feat/1.21.4-support
2 parents 6e2da40 + da71044 commit d1f0618

File tree

9 files changed

+124
-21
lines changed

9 files changed

+124
-21
lines changed

.github/workflows/gradle-publish.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,9 @@ jobs:
6262
with:
6363
name: fabric-build
6464
path: fabric/build/libs
65+
66+
- name: Upload build artifacts sponge
67+
uses: actions/upload-artifact@v4
68+
with:
69+
name: sponge-build
70+
path: sponge/build/libs

api/build.gradle.kts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,11 @@ mappingCompression {
113113
}
114114

115115
tasks {
116+
assemble {
117+
setDependsOn(dependsOn.filterNot { it == "shadowNoAdventure" })
118+
}
119+
116120
javadoc {
117-
setDestinationDir(file("${project.layout.buildDirectory.asFile.get()}/docs/javadoc"))
118-
options {
119-
(this as CoreJavadocOptions).addBooleanOption("Xdoclint:none", true)
120-
}
121121
mustRunAfter(generateVersionsFile)
122122
}
123123

api/src/main/java/com/github/retrooper/packetevents/protocol/component/builtin/item/ItemPotionContents.java

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
package com.github.retrooper.packetevents.protocol.component.builtin.item;
2020

21+
import com.github.retrooper.packetevents.manager.server.ServerVersion;
2122
import com.github.retrooper.packetevents.protocol.potion.Potion;
2223
import com.github.retrooper.packetevents.protocol.potion.PotionEffect;
2324
import com.github.retrooper.packetevents.protocol.potion.Potions;
@@ -32,28 +33,44 @@ public class ItemPotionContents {
3233
private @Nullable Potion potion;
3334
private @Nullable Integer customColor;
3435
private List<PotionEffect> customEffects;
36+
private @Nullable String customName;
3537

3638
public ItemPotionContents(
3739
@Nullable Potion potion,
3840
@Nullable Integer customColor,
3941
List<PotionEffect> customEffects
42+
) {
43+
this(potion, customColor, customEffects, null);
44+
}
45+
46+
public ItemPotionContents(
47+
@Nullable Potion potion,
48+
@Nullable Integer customColor,
49+
List<PotionEffect> customEffects,
50+
@Nullable String customName
4051
) {
4152
this.potion = potion;
4253
this.customColor = customColor;
4354
this.customEffects = customEffects;
55+
this.customName = customName;
4456
}
4557

4658
public static ItemPotionContents read(PacketWrapper<?> wrapper) {
4759
Potion potionId = wrapper.readOptional(ew -> ew.readMappedEntity(Potions::getById));
4860
Integer customColor = wrapper.readOptional(PacketWrapper::readInt);
4961
List<PotionEffect> customEffects = wrapper.readList(PotionEffect::read);
50-
return new ItemPotionContents(potionId, customColor, customEffects);
62+
String customName = wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_1_21_2)
63+
? wrapper.readOptional(PacketWrapper::readString) : null;
64+
return new ItemPotionContents(potionId, customColor, customEffects, customName);
5165
}
5266

5367
public static void write(PacketWrapper<?> wrapper, ItemPotionContents contents) {
5468
wrapper.writeOptional(contents.potion, PacketWrapper::writeMappedEntity);
5569
wrapper.writeOptional(contents.customColor, PacketWrapper::writeInt);
5670
wrapper.writeList(contents.customEffects, PotionEffect::write);
71+
if (wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_1_21_2)) {
72+
wrapper.writeOptional(contents.customName, PacketWrapper::writeString);
73+
}
5774
}
5875

5976
public @Nullable Potion getPotion() {
@@ -84,18 +101,27 @@ public void setCustomEffects(List<PotionEffect> customEffects) {
84101
this.customEffects = customEffects;
85102
}
86103

104+
public @Nullable String getCustomName() {
105+
return this.customName;
106+
}
107+
108+
public void setCustomName(@Nullable String customName) {
109+
this.customName = customName;
110+
}
111+
87112
@Override
88113
public boolean equals(Object obj) {
89114
if (this == obj) return true;
90115
if (!(obj instanceof ItemPotionContents)) return false;
91116
ItemPotionContents that = (ItemPotionContents) obj;
92117
if (!Objects.equals(this.potion, that.potion)) return false;
93118
if (!Objects.equals(this.customColor, that.customColor)) return false;
94-
return this.customEffects.equals(that.customEffects);
119+
if (!this.customEffects.equals(that.customEffects)) return false;
120+
return Objects.equals(this.customName, that.customName);
95121
}
96122

97123
@Override
98124
public int hashCode() {
99-
return Objects.hash(this.potion, this.customColor, this.customEffects);
125+
return Objects.hash(this.potion, this.customColor, this.customEffects, this.customName);
100126
}
101127
}

api/src/main/java/com/github/retrooper/packetevents/protocol/world/BlockFace.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,33 @@ public BlockFace getCW() {
153153
}
154154
}
155155

156+
/**
157+
* Returns an integer representing cardinal directions with south as the starting index at 0. UP and DOWN return -1
158+
* <p>
159+
* Used by Mojang for calculations involving mob AI, decorations, paintings, item frames, maps,
160+
* structure generation, campfires, stairs, connecting blocks, and flowerbeds.
161+
* Also used for getting directions and block faces as rotations.
162+
*
163+
* @return integer horizontal id
164+
*/
165+
public int getHorizontalId() {
166+
switch (this) {
167+
case DOWN:
168+
case UP:
169+
return -1;
170+
case NORTH:
171+
return 2;
172+
case SOUTH:
173+
return 0;
174+
case WEST:
175+
return 1;
176+
case EAST:
177+
return 3;
178+
default:
179+
throw new IllegalArgumentException("Invalid block face input for getHorizontalId");
180+
}
181+
}
182+
156183
public short getFaceValue() {
157184
return faceValue;
158185
}

build.gradle.kts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import java.io.ByteArrayOutputStream
22

33
// TODO UPDATE
4-
val fullVersion = "2.6.0"
4+
val fullVersion = "2.6.1"
55
val snapshot = true
66

77
group = "com.github.retrooper"
@@ -70,11 +70,5 @@ allprojects {
7070
withType<Jar> {
7171
archiveVersion = rootProject.ext["versionNoHash"] as String
7272
}
73-
74-
withType<Javadoc> {
75-
title = "packetevents-${project.name} v${rootProject.version}"
76-
options.encoding = Charsets.UTF_8.name()
77-
options.overview = rootProject.file("buildSrc/src/main/resources/javadoc-overview.html").toString()
78-
}
7973
}
8074
}

buildSrc/src/main/kotlin/packetevents.library-conventions.gradle.kts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,16 @@ tasks {
3535
options.release = 8
3636
}
3737

38+
javadoc {
39+
title = "packetevents-${project.name} v${rootProject.version}"
40+
options.encoding = Charsets.UTF_8.name()
41+
options.overview = rootProject.file("buildSrc/src/main/resources/javadoc-overview.html").toString()
42+
setDestinationDir(file("${project.layout.buildDirectory.asFile.get()}/docs/javadoc"))
43+
options {
44+
(this as CoreJavadocOptions).addBooleanOption("Xdoclint:none", true)
45+
}
46+
}
47+
3848
processResources {
3949
inputs.property("version", project.version)
4050
filesMatching(listOf("plugin.yml", "bungee.yml", "velocity-plugin.json", "fabric.mod.json")) {

buildSrc/src/main/kotlin/packetevents.shadow-conventions.gradle.kts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,46 @@ tasks {
2828
mergeServiceFiles()
2929
}
3030

31+
create<ShadowJar>("shadowNoAdventure") {
32+
group = rootProject.name
33+
description = "Create a combined JAR of project and runtime dependencies without Adventure dependencies."
34+
archiveFileName = "packetevents-${project.name}-no-adv-${rootProject.ext["versionNoHash"]}.jar"
35+
archiveClassifier = null
36+
37+
val shadowJar = shadowJar.get()
38+
val sourceSets = project.extensions.getByType<SourceSetContainer>()
39+
40+
manifest.inheritFrom(shadowJar.manifest)
41+
42+
from(sourceSets.main.get().output)
43+
configurations = shadowJar.configurations
44+
45+
relocate("net.kyori.adventure.text.serializer", "io.github.retrooper.packetevents.adventure.serializer")
46+
relocate("net.kyori.option", "io.github.retrooper.packetevents.adventure.option")
47+
relocate("org.bstats", "io.github.retrooper.packetevents.bstats")
48+
49+
dependencies {
50+
exclude(dependency("net.kyori:adventure-api:.*"))
51+
exclude(dependency("net.kyori:adventure-key:.*"))
52+
exclude(dependency("net.kyori:adventure-nbt:.*"))
53+
exclude(dependency("net.kyori:examination-api:.*"))
54+
exclude(dependency("net.kyori:examination-string:.*"))
55+
exclude(dependency("com.google.code.gson:gson:.*"))
56+
exclude("META-INF/INDEX.LIST", "META-INF/*.SF", "META-INF/*.DSA", "META-INF/*.RSA", "module-info.class")
57+
}
58+
59+
mergeServiceFiles()
60+
}
61+
3162
assemble {
3263
dependsOn(shadowJar)
3364
}
65+
66+
if (project.properties.contains("no-adv")) {
67+
assemble {
68+
dependsOn("shadowNoAdventure")
69+
}
70+
}
3471
}
3572

3673
configurations.implementation.get().extendsFrom(configurations.shadow.get())
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<body>
22
<p>
3-
PacketEvents is a fast and efficient multi-platform packet processing library for Minecraft.
4-
Our packet wrappers are easy to use with multi-version support.
3+
Precision meets performance—a powerful tool for mastering Minecraft packet manipulation with speed and finesse.
54
</p>
65

76
<p>Javadoc links:</p>
@@ -10,6 +9,8 @@
109
<li><a href="https://javadocs.packetevents.com/spigot/">packetevents-spigot</a></li>
1110
<li><a href="https://javadocs.packetevents.com/velocity/">packetevents-velocity</a></li>
1211
<li><a href="https://javadocs.packetevents.com/bungeecord/">packetevents-bungeecord</a></li>
12+
<li><a href="https://javadocs.packetevents.com/fabric/">packetevents-fabric</a></li>
13+
<li><a href="https://javadocs.packetevents.com/sponge/">packetevents-sponge</a></li>
1314
<li><a href="https://javadocs.packetevents.com/netty-common/">packetevents-netty-common</a></li>
1415
</ul>
1516
</body>

fabric/build.gradle.kts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,13 @@ tasks {
4343
}
4444
}
4545

46-
sequenceOf(remapJar, remapSourcesJar).forEach {
47-
it {
48-
archiveBaseName = "${rootProject.name}-fabric"
49-
archiveVersion = rootProject.ext["versionNoHash"] as String
50-
}
46+
remapJar {
47+
archiveBaseName = "${rootProject.name}-fabric"
48+
archiveVersion = rootProject.ext["versionNoHash"] as String
49+
}
50+
51+
remapSourcesJar {
52+
archiveVersion = rootProject.ext["versionNoHash"] as String
5153
}
5254
}
5355

0 commit comments

Comments
 (0)