Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-12-27 16:40:14 +01:00
Paintings work
Dieser Commit ist enthalten in:
Ursprung
bbf45b6a4c
Commit
193fa23146
@ -272,8 +272,9 @@ public final class EntityDefinitions {
|
|||||||
.type(EntityType.LLAMA_SPIT)
|
.type(EntityType.LLAMA_SPIT)
|
||||||
.heightAndWidth(0.25f)
|
.heightAndWidth(0.25f)
|
||||||
.build();
|
.build();
|
||||||
PAINTING = EntityDefinition.inherited(PaintingEntity::new, entityBase)
|
PAINTING = EntityDefinition.<PaintingEntity>inherited(null, entityBase)
|
||||||
.type(EntityType.PAINTING)
|
.type(EntityType.PAINTING)
|
||||||
|
.addTranslator(MetadataType.PAINTING_VARIANT, PaintingEntity::setPaintingType)
|
||||||
.build();
|
.build();
|
||||||
SHULKER_BULLET = EntityDefinition.inherited(ThrowableEntity::new, entityBase)
|
SHULKER_BULLET = EntityDefinition.inherited(ThrowableEntity::new, entityBase)
|
||||||
.type(EntityType.SHULKER_BULLET)
|
.type(EntityType.SHULKER_BULLET)
|
||||||
@ -871,7 +872,7 @@ public final class EntityDefinitions {
|
|||||||
CAT = EntityDefinition.inherited(CatEntity::new, tameableEntityBase)
|
CAT = EntityDefinition.inherited(CatEntity::new, tameableEntityBase)
|
||||||
.type(EntityType.CAT)
|
.type(EntityType.CAT)
|
||||||
.height(0.35f).width(0.3f)
|
.height(0.35f).width(0.3f)
|
||||||
.addTranslator(MetadataType.INT, CatEntity::setCatVariant)
|
.addTranslator(MetadataType.CAT_VARIANT, CatEntity::setCatVariant)
|
||||||
.addTranslator(MetadataType.BOOLEAN, CatEntity::setResting)
|
.addTranslator(MetadataType.BOOLEAN, CatEntity::setResting)
|
||||||
.addTranslator(null) // "resting state one" //TODO
|
.addTranslator(null) // "resting state one" //TODO
|
||||||
.addTranslator(MetadataType.INT, CatEntity::setCollarColor)
|
.addTranslator(MetadataType.INT, CatEntity::setCollarColor)
|
||||||
|
@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
package org.geysermc.geyser.entity.type;
|
package org.geysermc.geyser.entity.type;
|
||||||
|
|
||||||
|
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.ObjectEntityMetadata;
|
||||||
|
import com.github.steveice10.mc.protocol.data.game.entity.object.Direction;
|
||||||
import com.nukkitx.math.vector.Vector3f;
|
import com.nukkitx.math.vector.Vector3f;
|
||||||
import com.nukkitx.protocol.bedrock.packet.AddPaintingPacket;
|
import com.nukkitx.protocol.bedrock.packet.AddPaintingPacket;
|
||||||
import org.geysermc.geyser.entity.EntityDefinition;
|
import org.geysermc.geyser.entity.EntityDefinition;
|
||||||
@ -35,11 +37,11 @@ import java.util.UUID;
|
|||||||
|
|
||||||
public class PaintingEntity extends Entity {
|
public class PaintingEntity extends Entity {
|
||||||
private static final double OFFSET = -0.46875;
|
private static final double OFFSET = -0.46875;
|
||||||
private PaintingType paintingName;
|
private final Direction direction;
|
||||||
private int direction;
|
|
||||||
|
|
||||||
public PaintingEntity(GeyserSession session, int entityId, long geyserId, UUID uuid, EntityDefinition<?> definition, Vector3f position, Vector3f motion, float yaw, float pitch, float headYaw) {
|
public PaintingEntity(GeyserSession session, int entityId, long geyserId, UUID uuid, EntityDefinition<?> definition, Vector3f position, Vector3f motion, float yaw, float pitch, float headYaw, Direction direction) {
|
||||||
super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw);
|
super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw);
|
||||||
|
this.direction = direction;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -47,13 +49,21 @@ public class PaintingEntity extends Entity {
|
|||||||
// Wait until we get the metadata needed
|
// Wait until we get the metadata needed
|
||||||
}
|
}
|
||||||
|
|
||||||
public void paintingtodo() {
|
public void setPaintingType(ObjectEntityMetadata<com.github.steveice10.mc.protocol.data.game.entity.type.PaintingType> entityMetadata) {
|
||||||
|
PaintingType type = PaintingType.getByPaintingType(entityMetadata.getValue());
|
||||||
AddPaintingPacket addPaintingPacket = new AddPaintingPacket();
|
AddPaintingPacket addPaintingPacket = new AddPaintingPacket();
|
||||||
addPaintingPacket.setUniqueEntityId(geyserId);
|
addPaintingPacket.setUniqueEntityId(geyserId);
|
||||||
addPaintingPacket.setRuntimeEntityId(geyserId);
|
addPaintingPacket.setRuntimeEntityId(geyserId);
|
||||||
addPaintingPacket.setMotive(paintingName.getBedrockName());
|
addPaintingPacket.setMotive(type.getBedrockName());
|
||||||
addPaintingPacket.setPosition(fixOffset());
|
addPaintingPacket.setPosition(fixOffset(type));
|
||||||
addPaintingPacket.setDirection(direction);
|
addPaintingPacket.setDirection(switch (direction) {
|
||||||
|
//TODO this doesn't seem right. Why did it work fine before?
|
||||||
|
case SOUTH -> 0;
|
||||||
|
case WEST -> 1;
|
||||||
|
case NORTH -> 2;
|
||||||
|
case EAST -> 3;
|
||||||
|
default -> 0;
|
||||||
|
});
|
||||||
session.sendUpstreamPacket(addPaintingPacket);
|
session.sendUpstreamPacket(addPaintingPacket);
|
||||||
|
|
||||||
valid = true;
|
valid = true;
|
||||||
@ -66,17 +76,17 @@ public class PaintingEntity extends Entity {
|
|||||||
// Do nothing, as head look messes up paintings
|
// Do nothing, as head look messes up paintings
|
||||||
}
|
}
|
||||||
|
|
||||||
private Vector3f fixOffset() {
|
private Vector3f fixOffset(PaintingType paintingName) {
|
||||||
Vector3f position = super.position;
|
Vector3f position = super.position;
|
||||||
position = position.add(0.5, 0.5, 0.5);
|
position = position.add(0.5, 0.5, 0.5);
|
||||||
double widthOffset = paintingName.getWidth() > 1 ? 0.5 : 0;
|
double widthOffset = paintingName.getWidth() > 1 ? 0.5 : 0;
|
||||||
double heightOffset = paintingName.getHeight() > 1 && paintingName.getHeight() != 3 ? 0.5 : 0;
|
double heightOffset = paintingName.getHeight() > 1 && paintingName.getHeight() != 3 ? 0.5 : 0;
|
||||||
|
|
||||||
return switch (direction) {
|
return switch (direction) {
|
||||||
case 0 -> position.add(widthOffset, heightOffset, OFFSET);
|
case SOUTH -> position.add(widthOffset, heightOffset, OFFSET);
|
||||||
case 1 -> position.add(-OFFSET, heightOffset, widthOffset);
|
case WEST -> position.add(-OFFSET, heightOffset, widthOffset);
|
||||||
case 2 -> position.add(-widthOffset, heightOffset, -OFFSET);
|
case NORTH -> position.add(-widthOffset, heightOffset, -OFFSET);
|
||||||
case 3 -> position.add(OFFSET, heightOffset, -widthOffset);
|
case EAST -> position.add(OFFSET, heightOffset, -widthOffset);
|
||||||
default -> position;
|
default -> position;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -60,13 +60,9 @@ public enum PaintingType {
|
|||||||
BURNING_SKULL("BurningSkull", 4, 4);
|
BURNING_SKULL("BurningSkull", 4, 4);
|
||||||
|
|
||||||
private static final PaintingType[] VALUES = values();
|
private static final PaintingType[] VALUES = values();
|
||||||
private String bedrockName;
|
private final String bedrockName;
|
||||||
private int width;
|
private final int width;
|
||||||
private int height;
|
private final int height;
|
||||||
|
|
||||||
public com.github.steveice10.mc.protocol.data.game.entity.type.PaintingType toJavaType() {
|
|
||||||
return com.github.steveice10.mc.protocol.data.game.entity.type.PaintingType.valueOf(name());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static PaintingType getByName(String javaName) {
|
public static PaintingType getByName(String javaName) {
|
||||||
for (PaintingType paintingName : VALUES) {
|
for (PaintingType paintingName : VALUES) {
|
||||||
|
@ -69,7 +69,6 @@ public class TagCache {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void loadPacket(GeyserSession session, ClientboundUpdateTagsPacket packet) {
|
public void loadPacket(GeyserSession session, ClientboundUpdateTagsPacket packet) {
|
||||||
System.out.println(packet);
|
|
||||||
Map<String, int[]> blockTags = packet.getTags().get("minecraft:block");
|
Map<String, int[]> blockTags = packet.getTags().get("minecraft:block");
|
||||||
this.leaves = IntList.of(blockTags.get("minecraft:leaves"));
|
this.leaves = IntList.of(blockTags.get("minecraft:leaves"));
|
||||||
this.wool = IntList.of(blockTags.get("minecraft:wool"));
|
this.wool = IntList.of(blockTags.get("minecraft:wool"));
|
||||||
|
@ -106,10 +106,12 @@ public class JavaLoginTranslator extends PacketTranslator<ClientboundLoginPacket
|
|||||||
|
|
||||||
session.setGameMode(packet.getGameMode());
|
session.setGameMode(packet.getGameMode());
|
||||||
|
|
||||||
|
String newDimension = packet.getDimension();
|
||||||
|
|
||||||
boolean needsSpawnPacket = !session.isSentSpawnPacket();
|
boolean needsSpawnPacket = !session.isSentSpawnPacket();
|
||||||
if (needsSpawnPacket) {
|
if (needsSpawnPacket) {
|
||||||
// The player has yet to spawn so let's do that using some of the information in this Java packet
|
// The player has yet to spawn so let's do that using some of the information in this Java packet
|
||||||
//session.setDimension(newDimension);
|
session.setDimension(newDimension);
|
||||||
session.connect();
|
session.connect();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,7 +147,6 @@ public class JavaLoginTranslator extends PacketTranslator<ClientboundLoginPacket
|
|||||||
session.sendDownstreamPacket(new ServerboundCustomPayloadPacket("minecraft:register", PluginMessageChannels.getFloodgateRegisterData()));
|
session.sendDownstreamPacket(new ServerboundCustomPayloadPacket("minecraft:register", PluginMessageChannels.getFloodgateRegisterData()));
|
||||||
}
|
}
|
||||||
|
|
||||||
String newDimension = packet.getDimension();
|
|
||||||
if (!newDimension.equals(session.getDimension())) {
|
if (!newDimension.equals(session.getDimension())) {
|
||||||
DimensionUtils.switchDimension(session, newDimension);
|
DimensionUtils.switchDimension(session, newDimension);
|
||||||
} else if (DimensionUtils.isCustomBedrockNetherId() && newDimension.equalsIgnoreCase(DimensionUtils.NETHER)) {
|
} else if (DimensionUtils.isCustomBedrockNetherId() && newDimension.equalsIgnoreCase(DimensionUtils.NETHER)) {
|
||||||
|
@ -32,10 +32,7 @@ import com.github.steveice10.mc.protocol.data.game.entity.type.EntityType;
|
|||||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.spawn.ClientboundAddEntityPacket;
|
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.spawn.ClientboundAddEntityPacket;
|
||||||
import com.nukkitx.math.vector.Vector3f;
|
import com.nukkitx.math.vector.Vector3f;
|
||||||
import org.geysermc.geyser.entity.EntityDefinition;
|
import org.geysermc.geyser.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.entity.type.Entity;
|
import org.geysermc.geyser.entity.type.*;
|
||||||
import org.geysermc.geyser.entity.type.FallingBlockEntity;
|
|
||||||
import org.geysermc.geyser.entity.type.FishingHookEntity;
|
|
||||||
import org.geysermc.geyser.entity.type.ItemFrameEntity;
|
|
||||||
import org.geysermc.geyser.entity.type.player.PlayerEntity;
|
import org.geysermc.geyser.entity.type.player.PlayerEntity;
|
||||||
import org.geysermc.geyser.registry.Registries;
|
import org.geysermc.geyser.registry.Registries;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
@ -68,6 +65,9 @@ public class JavaAddEntityTranslator extends PacketTranslator<ClientboundAddEnti
|
|||||||
// Item frames need the hanging direction
|
// Item frames need the hanging direction
|
||||||
entity = new ItemFrameEntity(session, packet.getEntityId(), session.getEntityCache().getNextEntityId().incrementAndGet(), packet.getUuid(),
|
entity = new ItemFrameEntity(session, packet.getEntityId(), session.getEntityCache().getNextEntityId().incrementAndGet(), packet.getUuid(),
|
||||||
definition, position, motion, yaw, pitch, headYaw, (Direction) packet.getData());
|
definition, position, motion, yaw, pitch, headYaw, (Direction) packet.getData());
|
||||||
|
} else if (packet.getType() == EntityType.PAINTING) {
|
||||||
|
entity = new PaintingEntity(session, packet.getEntityId(), session.getEntityCache().getNextEntityId().incrementAndGet(), packet.getUuid(),
|
||||||
|
definition, position, motion, yaw, pitch, headYaw, (Direction) packet.getData());
|
||||||
} else if (packet.getType() == EntityType.FISHING_BOBBER) {
|
} else if (packet.getType() == EntityType.FISHING_BOBBER) {
|
||||||
// Fishing bobbers need the owner for the line
|
// Fishing bobbers need the owner for the line
|
||||||
int ownerEntityId = ((ProjectileData) packet.getData()).getOwnerId();
|
int ownerEntityId = ((ProjectileData) packet.getData()).getOwnerId();
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren