Skip alpha channel for custom model data component (#12205)
This commit is contained in:
@ -40,7 +40,7 @@ public record PaperCustomModelData(
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Color> colors() {
|
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 {
|
static final class BuilderImpl implements CustomModelData.Builder {
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
package org.bukkit.craftbukkit.inventory.components;
|
package org.bukkit.craftbukkit.inventory.components;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -57,7 +56,7 @@ public final class CraftCustomModelDataComponent implements CustomModelDataCompo
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setFloats(List<Float> floats) {
|
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
|
@Override
|
||||||
@ -67,7 +66,7 @@ public final class CraftCustomModelDataComponent implements CustomModelDataCompo
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setFlags(List<Boolean> flags) {
|
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
|
@Override
|
||||||
@ -77,17 +76,17 @@ public final class CraftCustomModelDataComponent implements CustomModelDataCompo
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setStrings(List<String> strings) {
|
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
|
@Override
|
||||||
public List<Color> getColors() {
|
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
|
@Override
|
||||||
public void setColors(List<Color> colors) {
|
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
|
@Override
|
||||||
@ -95,14 +94,11 @@ public final class CraftCustomModelDataComponent implements CustomModelDataCompo
|
|||||||
if (this == obj) {
|
if (this == obj) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (obj == null) {
|
if (obj == null || this.getClass() != obj.getClass()) {
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (this.getClass() != obj.getClass()) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final CraftCustomModelDataComponent other = (CraftCustomModelDataComponent) obj;
|
final CraftCustomModelDataComponent other = (CraftCustomModelDataComponent) obj;
|
||||||
return Objects.equals(this.handle, other.handle);
|
return this.handle.equals(other.handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -114,6 +110,6 @@ public final class CraftCustomModelDataComponent implements CustomModelDataCompo
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "CraftCustomModelDataComponent{" + "handle=" + this.handle + '}';
|
return "CraftCustomModelDataComponent{component=" + this.handle + '}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user