mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Banners on shields support
This commit is contained in:
parent
3162f1e4fd
commit
822568ecaa
1 changed files with 27 additions and 0 deletions
|
@ -25,13 +25,40 @@
|
||||||
|
|
||||||
package org.geysermc.geyser.item.type;
|
package org.geysermc.geyser.item.type;
|
||||||
|
|
||||||
|
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||||
|
import com.github.steveice10.opennbt.tag.builtin.IntTag;
|
||||||
|
import com.github.steveice10.opennbt.tag.builtin.ListTag;
|
||||||
|
import com.github.steveice10.opennbt.tag.builtin.Tag;
|
||||||
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.geysermc.geyser.item.components.ToolTier;
|
import org.geysermc.geyser.item.components.ToolTier;
|
||||||
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
|
|
||||||
public class ShieldItem extends Item {
|
public class ShieldItem extends Item {
|
||||||
public ShieldItem(String javaIdentifier, Builder builder) {
|
public ShieldItem(String javaIdentifier, Builder builder) {
|
||||||
super(javaIdentifier, builder);
|
super(javaIdentifier, builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void translateNbtToBedrock(@NonNull GeyserSession session, @NonNull CompoundTag tag) {
|
||||||
|
super.translateNbtToBedrock(session, tag);
|
||||||
|
|
||||||
|
if (tag.remove("BlockEntityTag") instanceof CompoundTag blockEntityTag) {
|
||||||
|
if (blockEntityTag.get("Patterns") instanceof ListTag patterns) {
|
||||||
|
for (Tag pattern : patterns) {
|
||||||
|
if (((CompoundTag) pattern).get("Color") instanceof IntTag color) {
|
||||||
|
color.setValue(15 - color.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Bedrock looks for patterns at the root
|
||||||
|
tag.put(patterns);
|
||||||
|
}
|
||||||
|
if (blockEntityTag.get("Base") instanceof IntTag base) {
|
||||||
|
base.setValue(15 - base.getValue());
|
||||||
|
tag.put(base);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isValidRepairItem(Item other) {
|
public boolean isValidRepairItem(Item other) {
|
||||||
// Java Edition 1.19.3 checks the tag, but TODO check to see if we want it or are simulating what Bedrock is doing
|
// Java Edition 1.19.3 checks the tag, but TODO check to see if we want it or are simulating what Bedrock is doing
|
||||||
|
|
Loading…
Reference in a new issue