Skip alpha channel for custom model data component (#12205)

This commit is contained in:
Lulu13022002
2025-03-08 05:27:05 +01:00
committed by GitHub
parent a6ce734fd0
commit ce30016218
2 changed files with 9 additions and 13 deletions

View File

@ -40,7 +40,7 @@ public record PaperCustomModelData(
@Override
public List<Color> colors() {
return MCUtil.transformUnmodifiable(this.impl.colors(), Color::fromRGB);
return MCUtil.transformUnmodifiable(this.impl.colors(), color -> Color.fromRGB(color & 0x00FFFFFF)); // skip alpha channel
}
static final class BuilderImpl implements CustomModelData.Builder {

View File

@ -1,6 +1,5 @@
package org.bukkit.craftbukkit.inventory.components;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
@ -57,7 +56,7 @@ public final class CraftCustomModelDataComponent implements CustomModelDataCompo
@Override
public void setFloats(List<Float> floats) {
this.handle = new CustomModelData(new ArrayList<>(floats), this.handle.flags(), this.handle.strings(), this.handle.colors());
this.handle = new CustomModelData(List.copyOf(floats), this.handle.flags(), this.handle.strings(), this.handle.colors());
}
@Override
@ -67,7 +66,7 @@ public final class CraftCustomModelDataComponent implements CustomModelDataCompo
@Override
public void setFlags(List<Boolean> flags) {
this.handle = new CustomModelData(this.handle.floats(), List.copyOf(flags), this.handle.strings(), this.handle.colors()); // Paper
this.handle = new CustomModelData(this.handle.floats(), List.copyOf(flags), this.handle.strings(), this.handle.colors());
}
@Override
@ -77,17 +76,17 @@ public final class CraftCustomModelDataComponent implements CustomModelDataCompo
@Override
public void setStrings(List<String> strings) {
this.handle = new CustomModelData(this.handle.floats(), this.handle.flags(), List.copyOf(strings), this.handle.colors()); // Paper
this.handle = new CustomModelData(this.handle.floats(), this.handle.flags(), List.copyOf(strings), this.handle.colors());
}
@Override
public List<Color> getColors() {
return this.getHandle().colors().stream().map(Color::fromRGB).toList();
return this.getHandle().colors().stream().map(color -> Color.fromRGB(color & 0x00FFFFFF)).toList(); // skip alpha channel
}
@Override
public void setColors(List<Color> colors) {
this.handle = new CustomModelData(this.handle.floats(), this.handle.flags(), this.handle.strings(), colors.stream().map(Color::asRGB).toList()); // Paper
this.handle = new CustomModelData(this.handle.floats(), this.handle.flags(), this.handle.strings(), colors.stream().map(Color::asRGB).toList());
}
@Override
@ -95,14 +94,11 @@ public final class CraftCustomModelDataComponent implements CustomModelDataCompo
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (this.getClass() != obj.getClass()) {
if (obj == null || this.getClass() != obj.getClass()) {
return false;
}
final CraftCustomModelDataComponent other = (CraftCustomModelDataComponent) obj;
return Objects.equals(this.handle, other.handle);
return this.handle.equals(other.handle);
}
@Override
@ -114,6 +110,6 @@ public final class CraftCustomModelDataComponent implements CustomModelDataCompo
@Override
public String toString() {
return "CraftCustomModelDataComponent{" + "handle=" + this.handle + '}';
return "CraftCustomModelDataComponent{component=" + this.handle + '}';
}
}