Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-11-19 14:30:17 +01:00
translate trial spawners, cleanup
Dieser Commit ist enthalten in:
Ursprung
22009054ab
Commit
21a2c2332f
@ -29,6 +29,8 @@ import com.github.steveice10.mc.protocol.data.game.level.block.BlockEntityType;
|
|||||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.StringTag;
|
import com.github.steveice10.opennbt.tag.builtin.StringTag;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.Tag;
|
import com.github.steveice10.opennbt.tag.builtin.Tag;
|
||||||
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
import org.cloudburstmc.math.vector.Vector3i;
|
import org.cloudburstmc.math.vector.Vector3i;
|
||||||
import org.cloudburstmc.nbt.NbtMap;
|
import org.cloudburstmc.nbt.NbtMap;
|
||||||
import org.cloudburstmc.nbt.NbtMapBuilder;
|
import org.cloudburstmc.nbt.NbtMapBuilder;
|
||||||
@ -99,24 +101,28 @@ public class SpawnerBlockEntityTranslator extends BlockEntityTranslator {
|
|||||||
builder.put("MinSpawnDelay", current.getValue());
|
builder.put("MinSpawnDelay", current.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
CompoundTag spawnData = tag.get("SpawnData");
|
translateSpawnData(builder, tag.get("SpawnData"));
|
||||||
if (spawnData != null) {
|
|
||||||
CompoundTag entityTag = spawnData.get("entity");
|
|
||||||
if (entityTag.get("id") instanceof StringTag idTag) {
|
|
||||||
// As of 1.19.3, spawners can be empty
|
|
||||||
String entityId = idTag.getValue();
|
|
||||||
builder.put("EntityIdentifier", entityId);
|
|
||||||
|
|
||||||
EntityDefinition<?> definition = Registries.JAVA_ENTITY_IDENTIFIERS.get(entityId);
|
|
||||||
if (definition != null) {
|
|
||||||
builder.put("DisplayEntityWidth", definition.width());
|
|
||||||
builder.put("DisplayEntityHeight", definition.height());
|
|
||||||
builder.put("DisplayEntityScale", 1.0f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
builder.put("id", "MobSpawner");
|
|
||||||
builder.put("isMovable", (byte) 1);
|
builder.put("isMovable", (byte) 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void translateSpawnData(@NonNull NbtMapBuilder builder, @Nullable CompoundTag spawnData) {
|
||||||
|
if (spawnData == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
CompoundTag entityTag = spawnData.get("entity");
|
||||||
|
if (entityTag.get("id") instanceof StringTag idTag) {
|
||||||
|
// As of 1.19.3, spawners can be empty
|
||||||
|
String entityId = idTag.getValue();
|
||||||
|
builder.put("EntityIdentifier", entityId);
|
||||||
|
|
||||||
|
EntityDefinition<?> definition = Registries.JAVA_ENTITY_IDENTIFIERS.get(entityId);
|
||||||
|
if (definition != null) {
|
||||||
|
builder.put("DisplayEntityWidth", definition.width());
|
||||||
|
builder.put("DisplayEntityHeight", definition.height());
|
||||||
|
builder.put("DisplayEntityScale", 1.0f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,13 +30,18 @@ import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
|||||||
import org.cloudburstmc.nbt.NbtMapBuilder;
|
import org.cloudburstmc.nbt.NbtMapBuilder;
|
||||||
|
|
||||||
@BlockEntity(type = BlockEntityType.TRIAL_SPAWNER)
|
@BlockEntity(type = BlockEntityType.TRIAL_SPAWNER)
|
||||||
public class TrialSpawnerBlockEntityTranslator extends SpawnerBlockEntityTranslator {
|
public class TrialSpawnerBlockEntityTranslator extends BlockEntityTranslator {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void translateTag(NbtMapBuilder builder, CompoundTag tag, int blockState) {
|
public void translateTag(NbtMapBuilder builder, CompoundTag tag, int blockState) {
|
||||||
if (tag != null) {
|
if (tag == null) {
|
||||||
// todo 1.20.3 doesn't seem to work
|
return;
|
||||||
super.translateTag(builder, tag, blockState);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// trial spawners have "spawn_data" instead of "SpawnData"
|
||||||
|
SpawnerBlockEntityTranslator.translateSpawnData(builder, tag.get("spawn_data"));
|
||||||
|
|
||||||
|
// Because trial spawners don't exist on bedrock yet
|
||||||
|
builder.put("id", "MobSpawner");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,6 @@ import org.cloudburstmc.nbt.NbtMapBuilder;
|
|||||||
import org.cloudburstmc.protocol.bedrock.packet.BlockEntityDataPacket;
|
import org.cloudburstmc.protocol.bedrock.packet.BlockEntityDataPacket;
|
||||||
import org.cloudburstmc.protocol.bedrock.packet.BlockEventPacket;
|
import org.cloudburstmc.protocol.bedrock.packet.BlockEventPacket;
|
||||||
import it.unimi.dsi.fastutil.objects.Object2IntMaps;
|
import it.unimi.dsi.fastutil.objects.Object2IntMaps;
|
||||||
import org.geysermc.geyser.GeyserImpl;
|
|
||||||
import org.geysermc.geyser.api.util.PlatformType;
|
import org.geysermc.geyser.api.util.PlatformType;
|
||||||
import org.geysermc.geyser.level.block.BlockStateValues;
|
import org.geysermc.geyser.level.block.BlockStateValues;
|
||||||
import org.geysermc.geyser.level.physics.Direction;
|
import org.geysermc.geyser.level.physics.Direction;
|
||||||
@ -128,14 +127,6 @@ public class JavaBlockEventTranslator extends PacketTranslator<ClientboundBlockE
|
|||||||
|
|
||||||
blockEntityPacket.setData(builder.build());
|
blockEntityPacket.setData(builder.build());
|
||||||
session.sendUpstreamPacket(blockEntityPacket);
|
session.sendUpstreamPacket(blockEntityPacket);
|
||||||
} else if (value instanceof DecoratedPotValue) {
|
|
||||||
// todo 1.20.3
|
|
||||||
} else if (value instanceof GenericBlockValue genericValue) {
|
|
||||||
if (genericValue.getValue() != 0) {
|
|
||||||
GeyserImpl.getInstance().getLogger().warning("Nonzero generic block value: " + packet);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
GeyserImpl.getInstance().getLogger().warning("Unhandled non-generic block event: " + packet);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -142,7 +142,8 @@ public class JavaGameEventTranslator extends PacketTranslator<ClientboundGameEve
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case AFFECTED_BY_ELDER_GUARDIAN:
|
case AFFECTED_BY_ELDER_GUARDIAN:
|
||||||
// todo 1.20.3 does this play a sound? this game event has a value for audible or not
|
// note: There is a ElderGuardianEffectValue that determines if a sound should be made or not,
|
||||||
|
// but that doesn't seem to be controllable on Bedrock Edition
|
||||||
EntityEventPacket eventPacket = new EntityEventPacket();
|
EntityEventPacket eventPacket = new EntityEventPacket();
|
||||||
eventPacket.setType(EntityEventType.ELDER_GUARDIAN_CURSE);
|
eventPacket.setType(EntityEventType.ELDER_GUARDIAN_CURSE);
|
||||||
eventPacket.setData(0);
|
eventPacket.setData(0);
|
||||||
@ -168,9 +169,10 @@ public class JavaGameEventTranslator extends PacketTranslator<ClientboundGameEve
|
|||||||
arrowSoundPacket.setPosition(entity.getPosition());
|
arrowSoundPacket.setPosition(entity.getPosition());
|
||||||
session.sendUpstreamPacket(arrowSoundPacket);
|
session.sendUpstreamPacket(arrowSoundPacket);
|
||||||
break;
|
break;
|
||||||
case PUFFERFISH_STING_SOUND:
|
|
||||||
// todo 1.20.3 was this accidentally not implemented?
|
|
||||||
default:
|
default:
|
||||||
|
// DEMO_MESSAGE - for JE game demo
|
||||||
|
// LEVEL_CHUNKS_LOAD_START - ???
|
||||||
|
// PUFFERFISH_STING_SOUND - doesn't exist on bedrock
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ protocol-connection = "3.0.0.Beta1-20231107.190703-112"
|
|||||||
raknet = "1.0.0.CR1-20230703.195238-9"
|
raknet = "1.0.0.CR1-20230703.195238-9"
|
||||||
blockstateupdater="1.20.50-20231106.161340-1"
|
blockstateupdater="1.20.50-20231106.161340-1"
|
||||||
mcauthlib = "d9d773e"
|
mcauthlib = "d9d773e"
|
||||||
mcprotocollib = "11105ca"
|
mcprotocollib = "7123bf9"
|
||||||
adventure = "4.14.0"
|
adventure = "4.14.0"
|
||||||
adventure-platform = "4.3.0"
|
adventure-platform = "4.3.0"
|
||||||
junit = "5.9.2"
|
junit = "5.9.2"
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren