Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-12-26 16:12:46 +01:00
Implement chest boat
Dieser Commit ist enthalten in:
Ursprung
66a7efaa96
Commit
9183897d52
@ -63,6 +63,7 @@ public final class EntityDefinitions {
|
||||
public static final EntityDefinition<SpiderEntity> CAVE_SPIDER;
|
||||
public static final EntityDefinition<MinecartEntity> CHEST_MINECART;
|
||||
public static final EntityDefinition<ChickenEntity> CHICKEN;
|
||||
public static final EntityDefinition<BoatEntity> CHEST_BOAT;
|
||||
public static final EntityDefinition<AbstractFishEntity> COD;
|
||||
public static final EntityDefinition<CommandBlockMinecartEntity> COMMAND_BLOCK_MINECART;
|
||||
public static final EntityDefinition<CowEntity> COW;
|
||||
@ -209,6 +210,9 @@ public final class EntityDefinitions {
|
||||
.addTranslator(MetadataType.BOOLEAN, BoatEntity::setPaddlingRight)
|
||||
.addTranslator(MetadataType.INT, (boatEntity, entityMetadata) -> boatEntity.getDirtyMetadata().put(EntityData.BOAT_BUBBLE_TIME, entityMetadata.getValue())) // May not actually do anything
|
||||
.build();
|
||||
CHEST_BOAT = EntityDefinition.inherited(BOAT.factory(), BOAT)
|
||||
.type(EntityType.CHEST_BOAT)
|
||||
.build();
|
||||
DRAGON_FIREBALL = EntityDefinition.inherited(FireballEntity::new, entityBase)
|
||||
.type(EntityType.DRAGON_FIREBALL)
|
||||
.heightAndWidth(1.0f)
|
||||
|
@ -52,7 +52,7 @@ public class BedrockEntityPickRequestTranslator extends PacketTranslator<EntityP
|
||||
// Get the corresponding item
|
||||
String itemName;
|
||||
switch (entity.getDefinition().entityType()) {
|
||||
case BOAT -> {
|
||||
case BOAT, CHEST_BOAT -> {
|
||||
// Include type of boat in the name
|
||||
int variant = ((BoatEntity) entity).getVariant();
|
||||
String typeOfBoat = switch (variant) {
|
||||
@ -61,9 +61,10 @@ public class BedrockEntityPickRequestTranslator extends PacketTranslator<EntityP
|
||||
case 3 -> "jungle";
|
||||
case 4 -> "acacia";
|
||||
case 5 -> "dark_oak";
|
||||
case 6 -> "mangrove";
|
||||
default -> "oak";
|
||||
};
|
||||
itemName = typeOfBoat + "_boat";
|
||||
itemName = typeOfBoat + "_" + entity.getDefinition().entityType().name().toLowerCase(Locale.ROOT);
|
||||
}
|
||||
case LEASH_KNOT -> itemName = "lead";
|
||||
case CHEST_MINECART, COMMAND_BLOCK_MINECART, FURNACE_MINECART, HOPPER_MINECART, TNT_MINECART ->
|
||||
|
@ -28,10 +28,10 @@ package org.geysermc.geyser.translator.protocol.bedrock.entity.player;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.InteractAction;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.PlayerState;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.type.EntityType;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.player.ServerboundInteractPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.player.ServerboundPlayerCommandPacket;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
||||
import com.nukkitx.protocol.bedrock.data.inventory.ContainerType;
|
||||
import com.nukkitx.protocol.bedrock.packet.ContainerOpenPacket;
|
||||
import com.nukkitx.protocol.bedrock.packet.InteractPacket;
|
||||
@ -96,12 +96,10 @@ public class BedrockInteractTranslator extends PacketTranslator<InteractPacket>
|
||||
case OPEN_INVENTORY:
|
||||
if (session.getOpenInventory() == null) {
|
||||
Entity ridingEntity = session.getPlayerEntity().getVehicle();
|
||||
if (ridingEntity instanceof AbstractHorseEntity) {
|
||||
if (ridingEntity.getFlag(EntityFlag.TAMED)) {
|
||||
// We should request to open the horse inventory instead
|
||||
ServerboundPlayerCommandPacket openHorseWindowPacket = new ServerboundPlayerCommandPacket(session.getPlayerEntity().getEntityId(), PlayerState.OPEN_HORSE_INVENTORY);
|
||||
session.sendDownstreamPacket(openHorseWindowPacket);
|
||||
}
|
||||
if (ridingEntity instanceof AbstractHorseEntity || (ridingEntity != null && ridingEntity.getDefinition().entityType() == EntityType.CHEST_BOAT)) {
|
||||
// This mob has an inventory of its own that we should open instead.
|
||||
ServerboundPlayerCommandPacket openVehicleWindowPacket = new ServerboundPlayerCommandPacket(session.getPlayerEntity().getEntityId(), PlayerState.OPEN_VEHICLE_INVENTORY);
|
||||
session.sendDownstreamPacket(openVehicleWindowPacket);
|
||||
} else {
|
||||
session.setOpenInventory(session.getPlayerInventory());
|
||||
|
||||
|
@ -31,7 +31,7 @@ import org.geysermc.geyser.translator.protocol.PacketTranslator;
|
||||
import org.geysermc.geyser.translator.protocol.Translator;
|
||||
|
||||
@Translator(packet = ClientboundBlockChangedAckPacket.class)
|
||||
public class JavaBlockBreakAckTranslator extends PacketTranslator<ClientboundBlockChangedAckPacket> {
|
||||
public class JavaBlockChangedAckTranslator extends PacketTranslator<ClientboundBlockChangedAckPacket> {
|
||||
|
||||
@Override
|
||||
public void translate(GeyserSession session, ClientboundBlockChangedAckPacket packet) {
|
@ -27,14 +27,13 @@ package org.geysermc.geyser.translator.protocol.java.level;
|
||||
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.level.ClientboundBlockDestructionPacket;
|
||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.LevelEventType;
|
||||
import com.nukkitx.protocol.bedrock.packet.LevelEventPacket;
|
||||
import org.geysermc.geyser.registry.BlockRegistries;
|
||||
import org.geysermc.geyser.registry.type.ItemMapping;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
import org.geysermc.geyser.translator.protocol.PacketTranslator;
|
||||
import org.geysermc.geyser.translator.protocol.Translator;
|
||||
import org.geysermc.geyser.registry.BlockRegistries;
|
||||
import org.geysermc.geyser.registry.type.ItemMapping;
|
||||
import org.geysermc.geyser.util.BlockUtils;
|
||||
|
||||
@Translator(packet = ClientboundBlockDestructionPacket.class)
|
||||
@ -45,11 +44,7 @@ public class JavaBlockDestructionTranslator extends PacketTranslator<Clientbound
|
||||
int state = session.getGeyser().getWorldManager().getBlockAt(session, packet.getPosition().getX(), packet.getPosition().getY(), packet.getPosition().getZ());
|
||||
int breakTime = (int) (65535 / Math.ceil(BlockUtils.getBreakTime(session, BlockRegistries.JAVA_BLOCKS.get(state), ItemMapping.AIR, new CompoundTag(""), false) * 20));
|
||||
LevelEventPacket levelEventPacket = new LevelEventPacket();
|
||||
levelEventPacket.setPosition(Vector3f.from(
|
||||
packet.getPosition().getX(),
|
||||
packet.getPosition().getY(),
|
||||
packet.getPosition().getZ()
|
||||
));
|
||||
levelEventPacket.setPosition(packet.getPosition().toFloat());
|
||||
levelEventPacket.setType(LevelEventType.BLOCK_START_BREAK);
|
||||
|
||||
switch (packet.getStage()) {
|
||||
|
@ -54,7 +54,8 @@ public class JavaLevelEventTranslator extends PacketTranslator<ClientboundLevelE
|
||||
if (packet.getEvent() == com.github.steveice10.mc.protocol.data.game.level.event.SoundEvent.RECORD) {
|
||||
RecordEventData recordEventData = (RecordEventData) packet.getData();
|
||||
SoundEvent soundEvent = Registries.RECORDS.getOrDefault(recordEventData.getRecordId(), SoundEvent.STOP_RECORD);
|
||||
Vector3f pos = Vector3f.from(packet.getPosition().getX(), packet.getPosition().getY(), packet.getPosition().getZ()).add(0.5f, 0.5f, 0.5f);
|
||||
Vector3i origin = packet.getPosition();
|
||||
Vector3f pos = Vector3f.from(origin.getX() + 0.5f, origin.getY() + 0.5f, origin.getZ() + 0.5f);
|
||||
|
||||
LevelSoundEventPacket levelSoundEvent = new LevelSoundEventPacket();
|
||||
levelSoundEvent.setIdentifier("");
|
||||
|
@ -32,6 +32,7 @@ import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
||||
import org.geysermc.geyser.entity.EntityDefinitions;
|
||||
import org.geysermc.geyser.entity.type.BoatEntity;
|
||||
import org.geysermc.geyser.entity.type.Entity;
|
||||
import org.geysermc.geyser.entity.type.living.ArmorStandEntity;
|
||||
import org.geysermc.geyser.entity.type.living.animal.AnimalEntity;
|
||||
@ -85,7 +86,7 @@ public final class EntityUtils {
|
||||
case TRADER_LLAMA, LLAMA -> mountedHeightOffset = height * 0.6f;
|
||||
case MINECART, HOPPER_MINECART, TNT_MINECART, CHEST_MINECART, FURNACE_MINECART, SPAWNER_MINECART,
|
||||
COMMAND_BLOCK_MINECART -> mountedHeightOffset = 0;
|
||||
case BOAT -> mountedHeightOffset = -0.1f;
|
||||
case BOAT, CHEST_BOAT -> mountedHeightOffset = -0.1f;
|
||||
case HOGLIN, ZOGLIN -> {
|
||||
boolean isBaby = mount.getFlag(EntityFlag.BABY);
|
||||
mountedHeightOffset = height - (isBaby ? 0.2f : 0.15f);
|
||||
@ -160,13 +161,14 @@ public final class EntityUtils {
|
||||
xOffset = -0.6f;
|
||||
}
|
||||
}
|
||||
case CHEST_BOAT -> xOffset = 0.15F;
|
||||
case CHICKEN -> zOffset = -0.1f;
|
||||
case TRADER_LLAMA, LLAMA -> zOffset = -0.3f;
|
||||
}
|
||||
if (passenger.getDefinition().entityType() == EntityType.SHULKER) {
|
||||
switch (mount.getDefinition().entityType()) {
|
||||
case MINECART, HOPPER_MINECART, TNT_MINECART, CHEST_MINECART, FURNACE_MINECART, SPAWNER_MINECART,
|
||||
COMMAND_BLOCK_MINECART, BOAT -> yOffset = 0.1875f;
|
||||
COMMAND_BLOCK_MINECART, BOAT, CHEST_BOAT -> yOffset = 0.1875f;
|
||||
}
|
||||
}
|
||||
/*
|
||||
@ -182,7 +184,7 @@ public final class EntityUtils {
|
||||
}
|
||||
switch (mount.getDefinition().entityType()) {
|
||||
case MINECART, HOPPER_MINECART, TNT_MINECART, CHEST_MINECART, FURNACE_MINECART, SPAWNER_MINECART,
|
||||
COMMAND_BLOCK_MINECART, BOAT -> yOffset -= mount.getDefinition().height() * 0.5f;
|
||||
COMMAND_BLOCK_MINECART, BOAT, CHEST_BOAT -> yOffset -= mount.getDefinition().height() * 0.5f;
|
||||
}
|
||||
Vector3f offset = Vector3f.from(xOffset, yOffset, zOffset);
|
||||
passenger.setRiderSeatPosition(offset);
|
||||
@ -190,7 +192,7 @@ public final class EntityUtils {
|
||||
}
|
||||
|
||||
public static void updateRiderRotationLock(Entity passenger, Entity mount, boolean isRiding) {
|
||||
if (isRiding && mount.getDefinition() == EntityDefinitions.BOAT) {
|
||||
if (isRiding && mount instanceof BoatEntity) {
|
||||
// Head rotation is locked while riding in a boat
|
||||
passenger.getDirtyMetadata().put(EntityData.RIDER_ROTATION_LOCKED, (byte) 1);
|
||||
passenger.getDirtyMetadata().put(EntityData.RIDER_MAX_ROTATION, 90f);
|
||||
|
Binäre Datei nicht angezeigt.
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren