Merge branch 'master' into plugin

This commit is contained in:
RednedEpic 2019-12-21 10:05:21 -06:00
commit d062e36fae
18 changed files with 6111 additions and 5603 deletions

View file

@ -4,7 +4,7 @@
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE) [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
[![Build Status](https://ci.nukkitx.com/job/Geyser/job/master/badge/icon)](https://ci.nukkitx.com/job/Geyser/job/master/) [![Build Status](https://ci.nukkitx.com/job/Geyser/job/master/badge/icon)](https://ci.nukkitx.com/job/Geyser/job/master/)
[![Discord](https://img.shields.io/discord/597838753859633172.svg?color=%237289da&label=discord)](http://discord.geysermc.org/) [![Discord](https://img.shields.io/discord/613163671870242838.svg?color=%237289da&label=discord)](http://discord.geysermc.org/)
[![HitCount](http://hits.dwyl.io/Geyser/GeyserMC.svg)](http://hits.dwyl.io/Geyser/GeyserMC) [![HitCount](http://hits.dwyl.io/Geyser/GeyserMC.svg)](http://hits.dwyl.io/Geyser/GeyserMC)
Geyser is a bridge between Minecraft: Bedrock Edition and Minecraft: Java Edition, closing the gap from those wanting to play true cross-platform. Geyser is a bridge between Minecraft: Bedrock Edition and Minecraft: Java Edition, closing the gap from those wanting to play true cross-platform.

View file

@ -75,7 +75,7 @@
<dependency> <dependency>
<groupId>com.github.steveice10</groupId> <groupId>com.github.steveice10</groupId>
<artifactId>mcprotocollib</artifactId> <artifactId>mcprotocollib</artifactId>
<version>1.14.4-2-SNAPSHOT</version> <version>1.15.1-1-SNAPSHOT</version>
<scope>compile</scope> <scope>compile</scope>
<exclusions> <exclusions>
<exclusion> <exclusion>

View file

@ -63,6 +63,7 @@ import java.util.concurrent.TimeUnit;
public class GeyserConnector implements Connector { public class GeyserConnector implements Connector {
public static final BedrockPacketCodec BEDROCK_PACKET_CODEC = Bedrock_v388.V388_CODEC; public static final BedrockPacketCodec BEDROCK_PACKET_CODEC = Bedrock_v388.V388_CODEC;
public static final int BEDROCK_1_14_PROTOCOL_VERSION = 389;
public static final String NAME = "Geyser"; public static final String NAME = "Geyser";
public static final String VERSION = "1.0-SNAPSHOT"; public static final String VERSION = "1.0-SNAPSHOT";

View file

@ -27,7 +27,6 @@ package org.geysermc.connector.entity.living;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata; import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
import com.nukkitx.math.vector.Vector3f; import com.nukkitx.math.vector.Vector3f;
import com.nukkitx.protocol.bedrock.data.EntityData;
import org.geysermc.connector.entity.type.EntityType; import org.geysermc.connector.entity.type.EntityType;
import org.geysermc.connector.network.session.GeyserSession; import org.geysermc.connector.network.session.GeyserSession;
@ -39,10 +38,6 @@ public class AbstractHorseEntity extends AnimalEntity {
@Override @Override
public void updateBedrockMetadata(EntityMetadata entityMetadata, GeyserSession session) { public void updateBedrockMetadata(EntityMetadata entityMetadata, GeyserSession session) {
if (entityMetadata.getId() == 17) {
metadata.put(EntityData.VARIANT, (int) entityMetadata.getValue());
}
super.updateBedrockMetadata(entityMetadata, session); super.updateBedrockMetadata(entityMetadata, session);
} }
} }

View file

@ -26,6 +26,7 @@
package org.geysermc.connector.entity.living; package org.geysermc.connector.entity.living;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata; import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.MetadataType;
import com.nukkitx.math.vector.Vector3f; import com.nukkitx.math.vector.Vector3f;
import com.nukkitx.protocol.bedrock.data.EntityFlag; import com.nukkitx.protocol.bedrock.data.EntityFlag;
import org.geysermc.connector.entity.type.EntityType; import org.geysermc.connector.entity.type.EntityType;
@ -39,7 +40,7 @@ public class AgeableEntity extends CreatureEntity {
@Override @Override
public void updateBedrockMetadata(EntityMetadata entityMetadata, GeyserSession session) { public void updateBedrockMetadata(EntityMetadata entityMetadata, GeyserSession session) {
if (entityMetadata.getId() == 14) { if (entityMetadata.getId() == 15) {
metadata.getFlags().setFlag(EntityFlag.BABY, (boolean) entityMetadata.getValue()); metadata.getFlags().setFlag(EntityFlag.BABY, (boolean) entityMetadata.getValue());
} }

View file

@ -41,7 +41,7 @@ public class InsentientEntity extends LivingEntity {
@Override @Override
public void updateBedrockMetadata(EntityMetadata entityMetadata, GeyserSession session) { public void updateBedrockMetadata(EntityMetadata entityMetadata, GeyserSession session) {
if (entityMetadata.getId() == 13 && entityMetadata.getType() == MetadataType.BYTE) { if (entityMetadata.getId() == 14 && entityMetadata.getType() == MetadataType.BYTE) {
byte xd = (byte) entityMetadata.getValue(); byte xd = (byte) entityMetadata.getValue();
metadata.getFlags().setFlag(EntityFlag.NO_AI, (xd & 0x01) == 0x01); metadata.getFlags().setFlag(EntityFlag.NO_AI, (xd & 0x01) == 0x01);
} }

View file

@ -0,0 +1,49 @@
/*
* Copyright (c) 2019 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* @author GeyserMC
* @link https://github.com/GeyserMC/Geyser
*/
package org.geysermc.connector.entity.living.horse;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
import com.nukkitx.math.vector.Vector3f;
import com.nukkitx.protocol.bedrock.data.EntityData;
import org.geysermc.connector.entity.living.AbstractHorseEntity;
import org.geysermc.connector.entity.type.EntityType;
import org.geysermc.connector.network.session.GeyserSession;
public class HorseEntity extends AbstractHorseEntity {
public HorseEntity(long entityId, long geyserId, EntityType entityType, Vector3f position, Vector3f motion, Vector3f rotation) {
super(entityId, geyserId, entityType, position, motion, rotation);
}
@Override
public void updateBedrockMetadata(EntityMetadata entityMetadata, GeyserSession session) {
if (entityMetadata.getId() == 18) {
metadata.put(EntityData.VARIANT, (int) entityMetadata.getValue());
}
super.updateBedrockMetadata(entityMetadata, session);
}
}

View file

@ -0,0 +1,37 @@
/*
* Copyright (c) 2019 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* @author GeyserMC
* @link https://github.com/GeyserMC/Geyser
*/
package org.geysermc.connector.entity.living.horse;
import com.nukkitx.math.vector.Vector3f;
import org.geysermc.connector.entity.living.ChestedHorseEntity;
import org.geysermc.connector.entity.type.EntityType;
public class LlamaEntity extends ChestedHorseEntity {
public LlamaEntity(long entityId, long geyserId, EntityType entityType, Vector3f position, Vector3f motion, Vector3f rotation) {
super(entityId, geyserId, entityType, position, motion, rotation);
}
}

View file

@ -41,7 +41,7 @@ public class GuardianEntity extends MonsterEntity {
@Override @Override
public void updateBedrockMetadata(EntityMetadata entityMetadata, GeyserSession session) { public void updateBedrockMetadata(EntityMetadata entityMetadata, GeyserSession session) {
if (entityMetadata.getId() == 15) { if (entityMetadata.getId() == 16) {
Entity entity = session.getEntityCache().getEntityByJavaId((int) entityMetadata.getValue()); Entity entity = session.getEntityCache().getEntityByJavaId((int) entityMetadata.getValue());
if (entity != null) { if (entity != null) {
metadata.put(EntityData.TARGET_EID, entity.getGeyserId()); metadata.put(EntityData.TARGET_EID, entity.getGeyserId());

View file

@ -28,6 +28,8 @@ package org.geysermc.connector.entity.type;
import lombok.Getter; import lombok.Getter;
import org.geysermc.connector.entity.*; import org.geysermc.connector.entity.*;
import org.geysermc.connector.entity.living.*; import org.geysermc.connector.entity.living.*;
import org.geysermc.connector.entity.living.horse.HorseEntity;
import org.geysermc.connector.entity.living.horse.LlamaEntity;
import org.geysermc.connector.entity.living.monster.GuardianEntity; import org.geysermc.connector.entity.living.monster.GuardianEntity;
import org.geysermc.connector.entity.living.monster.ZombieEntity; import org.geysermc.connector.entity.living.monster.ZombieEntity;
@ -46,14 +48,15 @@ public enum EntityType {
BAT(AmbientEntity.class, 19, 0.9f, 0.5f), BAT(AmbientEntity.class, 19, 0.9f, 0.5f),
IRON_GOLEM(GolemEntity.class, 20, 2.7f, 1.4f), IRON_GOLEM(GolemEntity.class, 20, 2.7f, 1.4f),
SNOW_GOLEM(GolemEntity.class, 21, 1.9f, 0.7f), SNOW_GOLEM(GolemEntity.class, 21, 1.9f, 0.7f),
OCELOT(TameableEntity.class, 22, 0.35f, 0.3f), OCELOT(AgeableEntity.class, 22, 0.35f, 0.3f),
HORSE(AbstractHorseEntity.class, 23, 1.6f, 1.3965f), HORSE(HorseEntity.class, 23, 1.6f, 1.3965f),
DONKEY(ChestedHorseEntity.class, 24, 1.6f, 1.3965f), DONKEY(ChestedHorseEntity.class, 24, 1.6f, 1.3965f),
MULE(ChestedHorseEntity.class, 25, 1.6f, 1.3965f), MULE(ChestedHorseEntity.class, 25, 1.6f, 1.3965f),
SKELETON_HORSE(AbstractHorseEntity.class, 26, 1.6f, 1.3965f), SKELETON_HORSE(AbstractHorseEntity.class, 26, 1.6f, 1.3965f),
ZOMBIE_HORSE(AbstractHorseEntity.class, 27, 1.6f, 1.3965f), ZOMBIE_HORSE(AbstractHorseEntity.class, 27, 1.6f, 1.3965f),
POLAR_BEAR(AnimalEntity.class, 28, 1.4f, 1.3f), POLAR_BEAR(AnimalEntity.class, 28, 1.4f, 1.3f),
LLAMA(ChestedHorseEntity.class, 29, 1.87f, 0.9f), LLAMA(LlamaEntity.class, 29, 1.87f, 0.9f),
TRADER_LLAMA(LlamaEntity.class, 29, 1.187f, 0.9f),
PARROT(TameableEntity.class, 30, 0.9f, 0.5f), PARROT(TameableEntity.class, 30, 0.9f, 0.5f),
DOLPHIN(WaterEntity.class, 31, 0.6f, 0.9f), DOLPHIN(WaterEntity.class, 31, 0.6f, 0.9f),
ZOMBIE(ZombieEntity.class, 32, 1.8f, 0.6f, 0.6f, 1.62f), ZOMBIE(ZombieEntity.class, 32, 1.8f, 0.6f, 0.6f, 1.62f),
@ -101,8 +104,7 @@ public enum EntityType {
FIREWORK_ROCKET(Entity.class, 72, 0f), FIREWORK_ROCKET(Entity.class, 72, 0f),
TRIDENT(ArrowEntity.class, 73, 0f), TRIDENT(ArrowEntity.class, 73, 0f),
TURTLE(AnimalEntity.class, 74, 0.4f, 1.2f), TURTLE(AnimalEntity.class, 74, 0.4f, 1.2f),
// TODO CAT (need to figure out how to deal with baby cats) https://github.com/NukkitX/Nukkit/blob/master/src/main/java/cn/nukkit/entity/passive/EntityCat.java CAT(TameableEntity.class, 75, 0.35f, 0.3f),
SHULKER_BULLET(Entity.class, 76, 0f), SHULKER_BULLET(Entity.class, 76, 0f),
FISHING_BOBBER(Entity.class, 77, 0f), FISHING_BOBBER(Entity.class, 77, 0f),
CHALKBOARD(Entity.class, 78, 0f), CHALKBOARD(Entity.class, 78, 0f),
@ -140,7 +142,8 @@ public enum EntityType {
TROPICAL_FISH(AbstractFishEntity.class, 111, 0.6f, 0.6f), TROPICAL_FISH(AbstractFishEntity.class, 111, 0.6f, 0.6f),
COD(AbstractFishEntity.class, 112, 0.25f, 0.5f), COD(AbstractFishEntity.class, 112, 0.25f, 0.5f),
PANDA(AnimalEntity.class, 113, 1.25f, 1.125f, 1.825f), PANDA(AnimalEntity.class, 113, 1.25f, 1.125f, 1.825f),
FOX(AnimalEntity.class, 121, 0.5f, 1.25f); FOX(AnimalEntity.class, 121, 0.5f, 1.25f),
BEE(InsentientEntity.class, 122, 0.6f, 0.6f);
private Class<? extends Entity> entityClass; private Class<? extends Entity> entityClass;
private final int type; private final int type;

View file

@ -45,8 +45,7 @@ public class UpstreamPacketHandler extends LoggingPacketHandler {
@Override @Override
public boolean handle(LoginPacket loginPacket) { public boolean handle(LoginPacket loginPacket) {
if (loginPacket.getProtocolVersion() != GeyserConnector.BEDROCK_PACKET_CODEC.getProtocolVersion()) { if (loginPacket.getProtocolVersion() != GeyserConnector.BEDROCK_1_14_PROTOCOL_VERSION) {
connector.getLogger().debug("unsupported");
session.getUpstream().disconnect("Unsupported Bedrock version. Are you running an outdated version?"); session.getUpstream().disconnect("Unsupported Bedrock version. Are you running an outdated version?");
return true; return true;
} }

View file

@ -44,13 +44,7 @@ import com.nukkitx.nbt.tag.CompoundTag;
import com.nukkitx.protocol.bedrock.BedrockServerSession; import com.nukkitx.protocol.bedrock.BedrockServerSession;
import com.nukkitx.protocol.bedrock.data.GamePublishSetting; import com.nukkitx.protocol.bedrock.data.GamePublishSetting;
import com.nukkitx.protocol.bedrock.data.GameRule; import com.nukkitx.protocol.bedrock.data.GameRule;
import com.nukkitx.protocol.bedrock.packet.AvailableEntityIdentifiersPacket; import com.nukkitx.protocol.bedrock.packet.*;
import com.nukkitx.protocol.bedrock.packet.BiomeDefinitionListPacket;
import com.nukkitx.protocol.bedrock.packet.LevelChunkPacket;
import com.nukkitx.protocol.bedrock.packet.NetworkChunkPublisherUpdatePacket;
import com.nukkitx.protocol.bedrock.packet.PlayStatusPacket;
import com.nukkitx.protocol.bedrock.packet.StartGamePacket;
import com.nukkitx.protocol.bedrock.packet.TextPacket;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import org.geysermc.api.Player; import org.geysermc.api.Player;
@ -295,7 +289,7 @@ public class GeyserSession implements Player {
startGamePacket.setLevelGamemode(0); startGamePacket.setLevelGamemode(0);
startGamePacket.setDifficulty(1); startGamePacket.setDifficulty(1);
startGamePacket.setDefaultSpawn(Vector3i.ZERO); startGamePacket.setDefaultSpawn(Vector3i.ZERO);
startGamePacket.setAcheivementsDisabled(true); startGamePacket.setAchievementsDisabled(true);
startGamePacket.setTime(-1); startGamePacket.setTime(-1);
startGamePacket.setEduEditionOffers(0); startGamePacket.setEduEditionOffers(0);
startGamePacket.setEduFeaturesEnabled(false); startGamePacket.setEduFeaturesEnabled(false);

View file

@ -64,7 +64,7 @@ public class BedrockMovePlayerTranslator extends PacketTranslator<MovePlayerPack
double javaY = packet.getPosition().getY() - EntityType.PLAYER.getOffset(); double javaY = packet.getPosition().getY() - EntityType.PLAYER.getOffset();
ClientPlayerPositionRotationPacket playerPositionRotationPacket = new ClientPlayerPositionRotationPacket( ClientPlayerPositionRotationPacket playerPositionRotationPacket = new ClientPlayerPositionRotationPacket(
packet.isOnGround(), packet.getPosition().getX(), Math.ceil(javaY * 2) / 2, packet.isOnGround(), packet.getPosition().getX(), javaY,
packet.getPosition().getZ(), packet.getRotation().getY(), packet.getRotation().getX() packet.getPosition().getZ(), packet.getRotation().getY(), packet.getRotation().getX()
); );

View file

@ -165,10 +165,10 @@ public class SkinProvider {
Geyser.getLogger().debug("Downloaded " + imageUrl); Geyser.getLogger().debug("Downloaded " + imageUrl);
if (cape) { if (cape) {
image = image.getWidth() > 64 ? scale(image) : image;
BufferedImage newImage = new BufferedImage(64, 32, BufferedImage.TYPE_INT_RGB); BufferedImage newImage = new BufferedImage(64, 32, BufferedImage.TYPE_INT_RGB);
Graphics g = newImage.createGraphics(); Graphics g = newImage.createGraphics();
g.drawImage(image, 0, 0, 64, 32, null); g.drawImage(image, 0, 0, image.getWidth(), image.getHeight(), null);
g.dispose(); g.dispose();
image = newImage; image = newImage;
} }
@ -193,6 +193,15 @@ public class SkinProvider {
} }
} }
private static BufferedImage scale (BufferedImage bufferedImage) {
BufferedImage resized = new BufferedImage(bufferedImage.getWidth() / 2, bufferedImage.getHeight() / 2, BufferedImage.TYPE_INT_RGB);
Graphics2D g2 = resized.createGraphics();
g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
g2.drawImage(bufferedImage, 0, 0, bufferedImage.getWidth() / 2, bufferedImage.getHeight() / 2, null);
g2.dispose();
return resized;
}
public static <T> T getOrDefault(CompletableFuture<T> future, T defaultValue, int timeoutInSeconds) { public static <T> T getOrDefault(CompletableFuture<T> future, T defaultValue, int timeoutInSeconds) {
try { try {
return future.get(timeoutInSeconds, TimeUnit.SECONDS); return future.get(timeoutInSeconds, TimeUnit.SECONDS);

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

@ -1 +1 @@
Subproject commit 3d4147f001266d01eae6b8479428ca77bb5bf0c3 Subproject commit 0f3d65b65076b16fc7dc9226230b31291b8f2cde