fix: DustColorTransition packet reading/writing (#2236)

* fix: DustColorTransition packet reading/writing

* chore: fix tests
This commit is contained in:
DeidaraMC 2024-07-01 16:02:04 -04:00 committed by GitHub
parent 77af815afe
commit efeb2229ea
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 11 additions and 11 deletions

View File

@ -146,26 +146,26 @@ public sealed interface Particle extends StaticProtocolObject, Particles permits
}
}
record DustColorTransition(@NotNull NamespaceID namespace, int id, @NotNull RGBLike color, float scale, @NotNull RGBLike transitionColor) implements Particle {
record DustColorTransition(@NotNull NamespaceID namespace, int id, @NotNull RGBLike color, @NotNull RGBLike transitionColor, float scale) implements Particle {
@Contract (pure = true)
public @NotNull DustColorTransition withProperties(@NotNull RGBLike color, float scale, @NotNull RGBLike transitionColor) {
return new DustColorTransition(namespace, id, color, scale, transitionColor);
public @NotNull DustColorTransition withProperties(@NotNull RGBLike color, @NotNull RGBLike transitionColor, float scale) {
return new DustColorTransition(namespace, id, color, transitionColor, scale);
}
@Contract(pure = true)
public @NotNull DustColorTransition withColor(@NotNull RGBLike color) {
return this.withProperties(color, scale, transitionColor);
return this.withProperties(color, transitionColor, scale);
}
@Contract(pure = true)
public @NotNull DustColorTransition withScale(float scale) {
return this.withProperties(color, scale, transitionColor);
return this.withProperties(color, transitionColor, scale);
}
@Contract(pure = true)
public @NotNull DustColorTransition withTransitionColor(@NotNull RGBLike transitionColor) {
return this.withProperties(color, scale, transitionColor);
return this.withProperties(color, transitionColor, scale);
}
@Override
@ -174,11 +174,11 @@ public sealed interface Particle extends StaticProtocolObject, Particles permits
(int) (reader.read(NetworkBuffer.FLOAT) * 255),
(int) (reader.read(NetworkBuffer.FLOAT) * 255),
(int) (reader.read(NetworkBuffer.FLOAT) * 255)
), reader.read(NetworkBuffer.FLOAT), new Color(
), new Color(
(int) (reader.read(NetworkBuffer.FLOAT) * 255),
(int) (reader.read(NetworkBuffer.FLOAT) * 255),
(int) (reader.read(NetworkBuffer.FLOAT) * 255)
));
), reader.read(NetworkBuffer.FLOAT));
}
@Override
@ -186,10 +186,10 @@ public sealed interface Particle extends StaticProtocolObject, Particles permits
writer.write(NetworkBuffer.FLOAT, color.red() / 255f);
writer.write(NetworkBuffer.FLOAT, color.green() / 255f);
writer.write(NetworkBuffer.FLOAT, color.blue() / 255f);
writer.write(NetworkBuffer.FLOAT, scale);
writer.write(NetworkBuffer.FLOAT, transitionColor.red() / 255f);
writer.write(NetworkBuffer.FLOAT, transitionColor.green() / 255f);
writer.write(NetworkBuffer.FLOAT, transitionColor.blue() / 255f);
writer.write(NetworkBuffer.FLOAT, scale);
}
}

View File

@ -38,7 +38,7 @@ final class ParticleImpl {
case "minecraft:dust_pillar" -> new Particle.DustPillar(namespace, id, Block.STONE);
case "minecraft:dust" -> new Particle.Dust(namespace, id, new Color(255, 255, 255), 1);
case "minecraft:dust_color_transition" -> new Particle.DustColorTransition(namespace, id, new Color(255, 255, 255),
1, new Color(255, 255, 255));
new Color(255, 255, 255), 1);
case "minecraft:sculk_charge" -> new Particle.SculkCharge(namespace, id, 0);
case "minecraft:item" -> new Particle.Item(namespace, id, ItemStack.AIR);
case "minecraft:vibration" -> new Particle.Vibration(namespace, id, Particle.Vibration.SourceType.BLOCK, Vec.ZERO, 0, 0, 0);

View File

@ -53,7 +53,7 @@ public class AreaEffectCloudTest {
float size = 0.1f;
Particle particle = Particle.DUST_COLOR_TRANSITION.withProperties(new Color(r, g, b), size, new Color(r2, g2, b2));
Particle particle = Particle.DUST_COLOR_TRANSITION.withProperties(new Color(r, g, b), new Color(r2, g2, b2), size);
Entity entity = new Entity(EntityTypes.AREA_EFFECT_CLOUD);
AreaEffectCloudMeta meta = (AreaEffectCloudMeta) entity.getEntityMeta();