mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-12-01 04:31:54 +01:00
Add custom minecart metadata (#713)
Adds display item, offset, and enable values.
This commit is contained in:
parent
b8615874f9
commit
215e5a7e21
1 changed files with 17 additions and 0 deletions
|
@ -30,6 +30,7 @@ import com.nukkitx.math.vector.Vector3f;
|
|||
import com.nukkitx.protocol.bedrock.data.EntityData;
|
||||
import org.geysermc.connector.entity.type.EntityType;
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
import org.geysermc.connector.network.translators.world.block.BlockTranslator;
|
||||
|
||||
public class MinecartEntity extends Entity {
|
||||
|
||||
|
@ -54,6 +55,22 @@ public class MinecartEntity extends Entity {
|
|||
metadata.put(EntityData.HURT_TIME, Math.min((int) (float) entityMetadata.getValue(), 15));
|
||||
}
|
||||
|
||||
// Custom block
|
||||
if (entityMetadata.getId() == 10) {
|
||||
metadata.put(EntityData.DISPLAY_ITEM, BlockTranslator.getBedrockBlockId((int) entityMetadata.getValue()));
|
||||
}
|
||||
|
||||
// Custom block offset
|
||||
if (entityMetadata.getId() == 11) {
|
||||
metadata.put(EntityData.DISPLAY_OFFSET, entityMetadata.getValue());
|
||||
}
|
||||
|
||||
// If the custom block should be enabled
|
||||
if (entityMetadata.getId() == 12) {
|
||||
// Needs a byte based off of Java's boolean
|
||||
metadata.put(EntityData.HAS_DISPLAY, (byte) ((boolean) entityMetadata.getValue() ? 1 : 0));
|
||||
}
|
||||
|
||||
super.updateBedrockMetadata(entityMetadata, session);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue