Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-09-08 20:43:04 +02:00
Implement glow item frames
Dieser Commit ist enthalten in:
Ursprung
5b7aa57472
Commit
1fe179c6d2
@ -122,7 +122,7 @@
|
||||
<dependency>
|
||||
<groupId>com.github.GeyserMC</groupId>
|
||||
<artifactId>MCProtocolLib</artifactId>
|
||||
<version>5f523d3</version>
|
||||
<version>eb02688</version>
|
||||
<!-- <groupId>com.github.steveice10</groupId>-->
|
||||
<!-- <artifactId>mcprotocollib</artifactId>-->
|
||||
<!-- <version>1.17-pre5-SNAPSHOT</version>-->
|
||||
|
@ -84,7 +84,7 @@ public class ItemFrameEntity extends Entity {
|
||||
@Override
|
||||
public void spawnEntity(GeyserSession session) {
|
||||
NbtMapBuilder blockBuilder = NbtMap.builder()
|
||||
.putString("name", "minecraft:frame")
|
||||
.putString("name", this.entityType == EntityType.GLOW_ITEM_FRAME ? "minecraft:glow_frame" : "minecraft:frame")
|
||||
.putInt("version", session.getBlockTranslator().getBlockStateVersion());
|
||||
blockBuilder.put("states", NbtMap.builder()
|
||||
.putInt("facing_direction", direction.ordinal())
|
||||
@ -167,7 +167,7 @@ public class ItemFrameEntity extends Entity {
|
||||
builder.putInt("y", bedrockPosition.getY());
|
||||
builder.putInt("z", bedrockPosition.getZ());
|
||||
builder.putByte("isMovable", (byte) 1);
|
||||
builder.putString("id", "ItemFrame");
|
||||
builder.putString("id", this.entityType == EntityType.GLOW_ITEM_FRAME ? "GlowItemFrame" : "ItemFrame");
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
|
@ -161,7 +161,6 @@ public enum EntityType {
|
||||
ZOGLIN(ZoglinEntity.class, 126, 1.4f, 1.3965f, 1.3965f, 0f, "minecraft:zoglin"),
|
||||
PIGLIN(PiglinEntity.class, 123, 1.95f, 0.6f, 0.6f, 0f, "minecraft:piglin"),
|
||||
PIGLIN_BRUTE(BasePiglinEntity.class, 127, 1.95f, 0.6f, 0.6f, 0f, "minecraft:piglin_brute"),
|
||||
//TODO: AXOLOTL GLOW_ITEM_FRAME
|
||||
AXOLOTL(AxolotlEntity.class, 0, 0.42f, 0.7f, 0.7f, 0f, "minecraft:axolotl"),
|
||||
GLOW_SQUID(GlowSquidEntity.class, 0, 0.8f, 0.8f, 0.8f, 0f, "minecraft:glow_squid"),
|
||||
GOAT(GoatEntity.class, 0, 1.3f, 0.9f, 0.9f, 0f, "minecraft:goat"),
|
||||
@ -171,6 +170,7 @@ public enum EntityType {
|
||||
* Item frames are handled differently since they are a block in Bedrock.
|
||||
*/
|
||||
ITEM_FRAME(ItemFrameEntity.class, 0, 0, 0),
|
||||
GLOW_ITEM_FRAME(ItemFrameEntity.class, 0, 0, 0),
|
||||
|
||||
/**
|
||||
* Not an entity in Bedrock, so we replace it with an evoker
|
||||
|
@ -28,6 +28,7 @@ package org.geysermc.connector.network.translators.bedrock;
|
||||
import com.nukkitx.math.vector.Vector3i;
|
||||
import com.nukkitx.protocol.bedrock.packet.BlockPickRequestPacket;
|
||||
import org.geysermc.connector.entity.ItemFrameEntity;
|
||||
import org.geysermc.connector.entity.type.EntityType;
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
import org.geysermc.connector.network.translators.PacketTranslator;
|
||||
import org.geysermc.connector.network.translators.Translator;
|
||||
@ -53,7 +54,7 @@ public class BedrockBlockPickRequestTranslator extends PacketTranslator<BlockPic
|
||||
InventoryUtils.findOrCreateItem(session, entity.getHeldItem());
|
||||
} else {
|
||||
// Grab the frame as the item
|
||||
InventoryUtils.findOrCreateItem(session, "minecraft:item_frame");
|
||||
InventoryUtils.findOrCreateItem(session, entity.getEntityType() == EntityType.GLOW_ITEM_FRAME ? "minecraft:glow_item_frame" : "minecraft:item_frame");
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
@ -95,6 +95,7 @@ public class BedrockEntityPickRequestTranslator extends PacketTranslator<EntityP
|
||||
case ARMOR_STAND:
|
||||
case END_CRYSTAL:
|
||||
//case ITEM_FRAME: Not an entity in Bedrock Edition
|
||||
//case GLOW_ITEM_FRAME:
|
||||
case MINECART:
|
||||
case PAINTING:
|
||||
// No spawn egg, just an item
|
||||
|
@ -64,7 +64,7 @@ public class JavaSpawnEntityTranslator extends PacketTranslator<ServerSpawnEntit
|
||||
if (packet.getType() == EntityType.FALLING_BLOCK) {
|
||||
entity = new FallingBlockEntity(packet.getEntityId(), session.getEntityCache().getNextEntityId().incrementAndGet(),
|
||||
type, position, motion, rotation, ((FallingBlockData) packet.getData()).getId());
|
||||
} else if (packet.getType() == EntityType.ITEM_FRAME) {
|
||||
} else if (packet.getType() == EntityType.ITEM_FRAME || packet.getType() == EntityType.GLOW_ITEM_FRAME) {
|
||||
// Item frames need the hanging direction
|
||||
entity = new ItemFrameEntity(packet.getEntityId(), session.getEntityCache().getNextEntityId().incrementAndGet(),
|
||||
type, position, motion, rotation, (HangingDirection) packet.getData());
|
||||
|
@ -322,7 +322,8 @@ public abstract class BlockTranslator {
|
||||
|
||||
// Loop around again to find all item frame runtime IDs
|
||||
for (Object2IntMap.Entry<NbtMap> entry : blockStateOrderedMap.object2IntEntrySet()) {
|
||||
if (entry.getKey().getString("name").equals("minecraft:frame")) {
|
||||
String name = entry.getKey().getString("name");
|
||||
if (name.equals("minecraft:frame") || name.equals("minecraft:glow_frame")) {
|
||||
itemFrames.put(entry.getKey(), entry.getIntValue());
|
||||
}
|
||||
}
|
||||
|
@ -290,6 +290,8 @@ public class ChunkUtils {
|
||||
if (itemFrameEntity != null) {
|
||||
if (blockState == JAVA_AIR_ID) { // Item frame is still present and no block overrides that; refresh it
|
||||
itemFrameEntity.updateBlock(session);
|
||||
// Still update the chunk cache with the new block
|
||||
session.getChunkCache().updateBlock(position.getX(), position.getY(), position.getZ(), blockState);
|
||||
return;
|
||||
}
|
||||
// Otherwise, let's still store our reference to the item frame, but let the new block take precedence for now
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren