forked from GeyserMC/Geyser
Merge remote-tracking branch 'origin/master' into block-entities
This commit is contained in:
commit
e1ba1fa3e8
28 changed files with 6236 additions and 5793 deletions
42
README.md
42
README.md
|
@ -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.
|
||||||
|
@ -13,39 +13,31 @@ Geyser is a bridge between Minecraft: Bedrock Edition and Minecraft: Java Editio
|
||||||
Geyser is a proxy, bridging the gap between Minecraft: Bedrock Edition and Minecraft: Java Edition servers.
|
Geyser is a proxy, bridging the gap between Minecraft: Bedrock Edition and Minecraft: Java Edition servers.
|
||||||
The ultimate goal of this project is to allow Minecraft: Bedrock Edition users to join Minecraft: Java Edition servers as seamlessly as possible.
|
The ultimate goal of this project is to allow Minecraft: Bedrock Edition users to join Minecraft: Java Edition servers as seamlessly as possible.
|
||||||
|
|
||||||
### Please note, this project is still a work in progress and should not be used on production.
|
### Please note, this project is still a work in progress and should not be used on production. Expect bugs!
|
||||||
|
|
||||||
## Setting Up
|
## Setting Up
|
||||||
Please note, Geyser is **not** a plugin. Watch the video below or take a look [here](https://github.com/GeyserMC/Geyser/wiki#Setup) for how to set it up.
|
Please note, Geyser is **not** (currently) a plugin. Watch the video below or take a look [here](https://github.com/GeyserMC/Geyser/wiki#Setup) for how to set it up.
|
||||||
|
|
||||||
[![YouTube Video](https://img.youtube.com/vi/OmLxwl7_UzQ/0.jpg)](https://www.youtube.com/watch?v=OmLxwl7_UzQ)
|
[![YouTube Video](https://img.youtube.com/vi/U7dZZ8w7Gi4/0.jpg)](https://www.youtube.com/watch?v=U7dZZ8w7Gi4)
|
||||||
|
|
||||||
Links:
|
## Links:
|
||||||
- Website: https://geysermc.org
|
- Website: https://geysermc.org
|
||||||
- Docs: https://github.com/GeyserMC/Geyser/wiki
|
- Docs: https://github.com/GeyserMC/Geyser/wiki
|
||||||
- Download: http://ci.geysermc.org
|
- Download: http://ci.geysermc.org
|
||||||
- Discord: http://discord.geysermc.org/
|
- Discord: http://discord.geysermc.org/
|
||||||
|
- Donate: https://patreon.com/GeyserMC
|
||||||
|
|
||||||
## What's Completed
|
## What's Left to be Added/Fixed
|
||||||
- [x] Server recognized in server list
|
- Inventories ([#67](https://github.com/GeyserMC/Geyser/pull/67))
|
||||||
- [x] Join detection from remote
|
- Crafting ([#67](https://github.com/GeyserMC/Geyser/pull/67))
|
||||||
- [x] Online mode/auth support
|
- Creative Mode ([#67](https://github.com/GeyserMC/Geyser/pull/67))
|
||||||
- [x] Chat/command support
|
- Sounds
|
||||||
- [x] Scoreboard
|
- Block Particles
|
||||||
- [ ] Inventory support
|
- Block Entities ([`block-entities`](https://github.com/GeyserMC/Geyser/tree/block-entities))
|
||||||
- [x] Inventory viewing
|
- Biome Colors
|
||||||
- [x] NBT data
|
- Some Entity Flags
|
||||||
- [ ] Inventory movement (transactions)
|
- Proper Movement
|
||||||
- [x] Player movement support
|
- Support to be Ran as a Plugin ([`plugin`](https://github.com/GeyserMC/Geyser/tree/plugin))
|
||||||
- [x] Entity support
|
|
||||||
- [x] Player support
|
|
||||||
- [ ] Chunks
|
|
||||||
- [x] Block translation (may be missing mappings)
|
|
||||||
- [x] Block updates
|
|
||||||
- [ ] Block entities
|
|
||||||
- [x] Extra data
|
|
||||||
- [ ] Biome colors
|
|
||||||
- [x] Block break/place support
|
|
||||||
|
|
||||||
## Compiling
|
## Compiling
|
||||||
1. Clone the repo to your computer
|
1. Clone the repo to your computer
|
||||||
|
|
|
@ -59,12 +59,6 @@
|
||||||
<version>1.6.4</version>
|
<version>1.6.4</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.projectlombok</groupId>
|
|
||||||
<artifactId>lombok</artifactId>
|
|
||||||
<version>1.18.4</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.fusesource.jansi</groupId>
|
<groupId>org.fusesource.jansi</groupId>
|
||||||
<artifactId>jansi</artifactId>
|
<artifactId>jansi</artifactId>
|
||||||
|
@ -73,8 +67,8 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.nukkitx.protocol</groupId>
|
<groupId>com.nukkitx.protocol</groupId>
|
||||||
<artifactId>bedrock-v388</artifactId>
|
<artifactId>bedrock-v389</artifactId>
|
||||||
<version>2.4.0</version>
|
<version>2.4.4</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -110,7 +104,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>
|
||||||
|
@ -129,7 +123,7 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<build>
|
<build>
|
||||||
<finalName>${outputName}-noshade</finalName>
|
<finalName>${project.parent.name}-noshade</finalName>
|
||||||
<directory>../target</directory>
|
<directory>../target</directory>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
|
@ -147,7 +141,7 @@
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-javadoc-plugin</artifactId>
|
<artifactId>maven-javadoc-plugin</artifactId>
|
||||||
<configuration>
|
<configuration>
|
||||||
<finalName>${outputName}</finalName>
|
<finalName>${project.parent.name}</finalName>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
|
@ -162,7 +156,7 @@
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
<configuration>
|
<configuration>
|
||||||
<finalName>${outputName}</finalName>
|
<finalName>${project.parent.name}</finalName>
|
||||||
<shadedArtifactAttached>true</shadedArtifactAttached>
|
<shadedArtifactAttached>true</shadedArtifactAttached>
|
||||||
<minimizeJar>true</minimizeJar>
|
<minimizeJar>true</minimizeJar>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|
|
@ -27,7 +27,7 @@ package org.geysermc.connector;
|
||||||
|
|
||||||
import com.nukkitx.protocol.bedrock.BedrockPacketCodec;
|
import com.nukkitx.protocol.bedrock.BedrockPacketCodec;
|
||||||
import com.nukkitx.protocol.bedrock.BedrockServer;
|
import com.nukkitx.protocol.bedrock.BedrockServer;
|
||||||
import com.nukkitx.protocol.bedrock.v388.Bedrock_v388;
|
import com.nukkitx.protocol.bedrock.v389.Bedrock_v389;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.fusesource.jansi.AnsiConsole;
|
import org.fusesource.jansi.AnsiConsole;
|
||||||
|
@ -67,7 +67,7 @@ import java.util.concurrent.TimeUnit;
|
||||||
@Getter
|
@Getter
|
||||||
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_v389.V389_CODEC;
|
||||||
|
|
||||||
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";
|
||||||
|
|
|
@ -39,10 +39,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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,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());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
|
@ -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());
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -46,7 +46,6 @@ 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_PACKET_CODEC.getProtocolVersion()) {
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
@ -73,7 +72,7 @@ public class UpstreamPacketHandler extends LoggingPacketHandler {
|
||||||
ResourcePackStackPacket stack = new ResourcePackStackPacket();
|
ResourcePackStackPacket stack = new ResourcePackStackPacket();
|
||||||
stack.setExperimental(false);
|
stack.setExperimental(false);
|
||||||
stack.setForcedToAccept(false);
|
stack.setForcedToAccept(false);
|
||||||
stack.setGameVersion(GeyserConnector.BEDROCK_PACKET_CODEC.getMinecraftVersion());
|
stack.setGameVersion("*");
|
||||||
session.getUpstream().sendPacket(stack);
|
session.getUpstream().sendPacket(stack);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -132,4 +131,4 @@ public class UpstreamPacketHandler extends LoggingPacketHandler {
|
||||||
public boolean handle(InventoryTransactionPacket packet) {
|
public boolean handle(InventoryTransactionPacket packet) {
|
||||||
return translateAndDefault(packet);
|
return translateAndDefault(packet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -295,7 +295,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);
|
||||||
|
@ -328,7 +328,7 @@ public class GeyserSession implements Player {
|
||||||
startGamePacket.setMultiplayerCorrelationId("");
|
startGamePacket.setMultiplayerCorrelationId("");
|
||||||
startGamePacket.setBlockPalette(Toolbox.BLOCKS);
|
startGamePacket.setBlockPalette(Toolbox.BLOCKS);
|
||||||
startGamePacket.setItemEntries(Toolbox.ITEMS);
|
startGamePacket.setItemEntries(Toolbox.ITEMS);
|
||||||
startGamePacket.setVanillaVersion(GeyserConnector.BEDROCK_PACKET_CODEC.getMinecraftVersion());
|
startGamePacket.setVanillaVersion("*");
|
||||||
// startGamePacket.setMovementServerAuthoritative(true);
|
// startGamePacket.setMovementServerAuthoritative(true);
|
||||||
upstream.sendPacket(startGamePacket);
|
upstream.sendPacket(startGamePacket);
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,7 +79,7 @@ public class ChunkCache {
|
||||||
Position blockPosition = chunkPosition.getChunkBlock(position.getX(), position.getY(), position.getZ());
|
Position blockPosition = chunkPosition.getChunkBlock(position.getX(), position.getY(), position.getZ());
|
||||||
if (chunk != null) {
|
if (chunk != null) {
|
||||||
BlockState blockState = chunk.get(blockPosition.getX(), blockPosition.getY(), blockPosition.getZ());
|
BlockState blockState = chunk.get(blockPosition.getX(), blockPosition.getY(), blockPosition.getZ());
|
||||||
return TranslatorsInit.getBlockTranslator().getBedrockBlock(blockState);
|
return TranslatorsInit.getBlockTranslator().getBlockEntry(blockState);
|
||||||
}
|
}
|
||||||
|
|
||||||
return BlockEntry.AIR;
|
return BlockEntry.AIR;
|
||||||
|
|
|
@ -25,23 +25,30 @@
|
||||||
|
|
||||||
package org.geysermc.connector.network.translators.block;
|
package org.geysermc.connector.network.translators.block;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@AllArgsConstructor
|
|
||||||
public class BlockEntry {
|
public class BlockEntry {
|
||||||
|
|
||||||
public static BlockEntry AIR = new BlockEntry("minecraft:air", 0, 0, 0);
|
public static BlockEntry AIR = new BlockEntry("minecraft:air", 0, 0);
|
||||||
|
|
||||||
private String javaIdentifier;
|
private final String javaIdentifier;
|
||||||
private int javaId;
|
private final int javaId;
|
||||||
|
private final int bedrockRuntimeId;
|
||||||
|
private final boolean waterlogged;
|
||||||
|
|
||||||
private int bedrockId;
|
public BlockEntry(String javaIdentifier, int javaId, int bedrockRuntimeId) {
|
||||||
private int bedrockData;
|
this.javaIdentifier = javaIdentifier;
|
||||||
|
this.javaId = javaId;
|
||||||
|
this.bedrockRuntimeId = bedrockRuntimeId;
|
||||||
|
this.waterlogged = (javaIdentifier.contains("waterlogged=true")
|
||||||
|
|| javaIdentifier.startsWith("minecraft:kelp")
|
||||||
|
|| javaIdentifier.contains("seagrass")
|
||||||
|
|| javaIdentifier.startsWith("minecraft:bubble_column"));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
return obj == this || (obj instanceof BlockEntry && ((BlockEntry) obj).getBedrockId() == this.getBedrockId() && ((BlockEntry) obj).getJavaIdentifier().equals(this.getJavaIdentifier()));
|
return obj == this || (obj instanceof BlockEntry && ((BlockEntry) obj).getBedrockRuntimeId() == this.getBedrockRuntimeId() && ((BlockEntry) obj).getJavaIdentifier().equals(this.getJavaIdentifier()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,18 @@ package org.geysermc.connector.network.translators.block;
|
||||||
import com.github.steveice10.mc.protocol.data.game.world.block.BlockState;
|
import com.github.steveice10.mc.protocol.data.game.world.block.BlockState;
|
||||||
import org.geysermc.connector.utils.Toolbox;
|
import org.geysermc.connector.utils.Toolbox;
|
||||||
|
|
||||||
public class BlockTranslator {
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public BlockEntry getBedrockBlock(BlockState state) {
|
public class BlockTranslator {
|
||||||
|
private final Map<String, BlockEntry> javaIdentifierMap = new HashMap<>();
|
||||||
|
|
||||||
|
public BlockEntry getBlockEntry(BlockState state) {
|
||||||
return Toolbox.BLOCK_ENTRIES.get(state.getId());
|
return Toolbox.BLOCK_ENTRIES.get(state.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BlockEntry getBlockEntry(String javaIdentifier) {
|
||||||
|
return javaIdentifierMap.computeIfAbsent(javaIdentifier, key -> Toolbox.BLOCK_ENTRIES.values()
|
||||||
|
.stream().filter(blockEntry -> blockEntry.getJavaIdentifier().equals(key)).findFirst().orElse(null));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,13 +26,9 @@
|
||||||
package org.geysermc.connector.network.translators.java.entity.player;
|
package org.geysermc.connector.network.translators.java.entity.player;
|
||||||
|
|
||||||
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.player.ServerPlayerActionAckPacket;
|
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.player.ServerPlayerActionAckPacket;
|
||||||
import com.nukkitx.math.vector.Vector3i;
|
|
||||||
import com.nukkitx.protocol.bedrock.packet.UpdateBlockPacket;
|
|
||||||
import org.geysermc.connector.network.session.GeyserSession;
|
import org.geysermc.connector.network.session.GeyserSession;
|
||||||
import org.geysermc.connector.network.translators.PacketTranslator;
|
import org.geysermc.connector.network.translators.PacketTranslator;
|
||||||
import org.geysermc.connector.network.translators.TranslatorsInit;
|
import org.geysermc.connector.utils.ChunkUtils;
|
||||||
import org.geysermc.connector.network.translators.block.BlockEntry;
|
|
||||||
import org.geysermc.connector.world.GlobalBlockPalette;
|
|
||||||
|
|
||||||
public class JavaPlayerActionAckTranslator extends PacketTranslator<ServerPlayerActionAckPacket> {
|
public class JavaPlayerActionAckTranslator extends PacketTranslator<ServerPlayerActionAckPacket> {
|
||||||
|
|
||||||
|
@ -40,18 +36,7 @@ public class JavaPlayerActionAckTranslator extends PacketTranslator<ServerPlayer
|
||||||
public void translate(ServerPlayerActionAckPacket packet, GeyserSession session) {
|
public void translate(ServerPlayerActionAckPacket packet, GeyserSession session) {
|
||||||
switch (packet.getAction()) {
|
switch (packet.getAction()) {
|
||||||
case FINISH_DIGGING:
|
case FINISH_DIGGING:
|
||||||
UpdateBlockPacket updateBlockPacket = new UpdateBlockPacket();
|
ChunkUtils.updateBlock(session, packet.getNewState(), packet.getPosition());
|
||||||
updateBlockPacket.setDataLayer(0);
|
|
||||||
updateBlockPacket.setBlockPosition(Vector3i.from(
|
|
||||||
packet.getPosition().getX(),
|
|
||||||
packet.getPosition().getY(),
|
|
||||||
packet.getPosition().getZ()));
|
|
||||||
|
|
||||||
BlockEntry itemEntry = TranslatorsInit.getBlockTranslator().getBedrockBlock(packet.getNewState());
|
|
||||||
updateBlockPacket.setRuntimeId(GlobalBlockPalette.getOrCreateRuntimeId(itemEntry.getBedrockId() << 4 | itemEntry.getBedrockData()));
|
|
||||||
updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.NEIGHBORS);
|
|
||||||
|
|
||||||
session.getUpstream().sendPacket(updateBlockPacket);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,31 +1,14 @@
|
||||||
package org.geysermc.connector.network.translators.java.world;
|
package org.geysermc.connector.network.translators.java.world;
|
||||||
|
|
||||||
import com.github.steveice10.mc.protocol.data.game.world.block.BlockChangeRecord;
|
|
||||||
import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerBlockChangePacket;
|
import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerBlockChangePacket;
|
||||||
import com.nukkitx.math.vector.Vector3i;
|
|
||||||
import com.nukkitx.protocol.bedrock.packet.UpdateBlockPacket;
|
|
||||||
import org.geysermc.connector.network.session.GeyserSession;
|
import org.geysermc.connector.network.session.GeyserSession;
|
||||||
import org.geysermc.connector.network.translators.PacketTranslator;
|
import org.geysermc.connector.network.translators.PacketTranslator;
|
||||||
import org.geysermc.connector.network.translators.TranslatorsInit;
|
import org.geysermc.connector.utils.ChunkUtils;
|
||||||
import org.geysermc.connector.network.translators.block.BlockEntry;
|
|
||||||
import org.geysermc.connector.world.GlobalBlockPalette;
|
|
||||||
|
|
||||||
public class JavaBlockChangeTranslator extends PacketTranslator<ServerBlockChangePacket> {
|
public class JavaBlockChangeTranslator extends PacketTranslator<ServerBlockChangePacket> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void translate(ServerBlockChangePacket packet, GeyserSession session) {
|
public void translate(ServerBlockChangePacket packet, GeyserSession session) {
|
||||||
UpdateBlockPacket updateBlockPacket = new UpdateBlockPacket();
|
ChunkUtils.updateBlock(session, packet.getRecord().getBlock(), packet.getRecord().getPosition());
|
||||||
BlockChangeRecord record = packet.getRecord();
|
|
||||||
updateBlockPacket.setDataLayer(0);
|
|
||||||
updateBlockPacket.setBlockPosition(Vector3i.from(
|
|
||||||
record.getPosition().getX(),
|
|
||||||
record.getPosition().getY(),
|
|
||||||
record.getPosition().getZ()
|
|
||||||
));
|
|
||||||
|
|
||||||
BlockEntry itemEntry = TranslatorsInit.getBlockTranslator().getBedrockBlock(record.getBlock());
|
|
||||||
updateBlockPacket.setRuntimeId(GlobalBlockPalette.getOrCreateRuntimeId(itemEntry.getBedrockId() << 4 | itemEntry.getBedrockData()));
|
|
||||||
updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.NEIGHBORS);
|
|
||||||
|
|
||||||
session.getUpstream().sendPacket(updateBlockPacket);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,32 +27,16 @@ package org.geysermc.connector.network.translators.java.world;
|
||||||
|
|
||||||
import com.github.steveice10.mc.protocol.data.game.world.block.BlockChangeRecord;
|
import com.github.steveice10.mc.protocol.data.game.world.block.BlockChangeRecord;
|
||||||
import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerMultiBlockChangePacket;
|
import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerMultiBlockChangePacket;
|
||||||
import com.nukkitx.math.vector.Vector3i;
|
|
||||||
import com.nukkitx.protocol.bedrock.packet.UpdateBlockPacket;
|
|
||||||
import org.geysermc.connector.network.session.GeyserSession;
|
import org.geysermc.connector.network.session.GeyserSession;
|
||||||
import org.geysermc.connector.network.translators.PacketTranslator;
|
import org.geysermc.connector.network.translators.PacketTranslator;
|
||||||
import org.geysermc.connector.network.translators.TranslatorsInit;
|
import org.geysermc.connector.utils.ChunkUtils;
|
||||||
import org.geysermc.connector.network.translators.block.BlockEntry;
|
|
||||||
import org.geysermc.connector.world.GlobalBlockPalette;
|
|
||||||
|
|
||||||
public class JavaMultiBlockChangeTranslator extends PacketTranslator<ServerMultiBlockChangePacket> {
|
public class JavaMultiBlockChangeTranslator extends PacketTranslator<ServerMultiBlockChangePacket> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void translate(ServerMultiBlockChangePacket packet, GeyserSession session) {
|
public void translate(ServerMultiBlockChangePacket packet, GeyserSession session) {
|
||||||
for (BlockChangeRecord record : packet.getRecords()) {
|
for (BlockChangeRecord record : packet.getRecords()) {
|
||||||
UpdateBlockPacket updateBlockPacket = new UpdateBlockPacket();
|
ChunkUtils.updateBlock(session, record.getBlock(), record.getPosition());
|
||||||
updateBlockPacket.setDataLayer(0);
|
|
||||||
updateBlockPacket.setBlockPosition(Vector3i.from(
|
|
||||||
record.getPosition().getX(),
|
|
||||||
record.getPosition().getY(),
|
|
||||||
record.getPosition().getZ()
|
|
||||||
));
|
|
||||||
|
|
||||||
BlockEntry blockEntry = TranslatorsInit.getBlockTranslator().getBedrockBlock(record.getBlock());
|
|
||||||
updateBlockPacket.setRuntimeId(GlobalBlockPalette.getOrCreateRuntimeId(blockEntry.getBedrockId() << 4 | blockEntry.getBedrockData()));
|
|
||||||
updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.NEIGHBORS);
|
|
||||||
|
|
||||||
session.getUpstream().sendPacket(updateBlockPacket);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,10 +2,15 @@ package org.geysermc.connector.utils;
|
||||||
|
|
||||||
import com.github.steveice10.mc.protocol.data.game.chunk.Chunk;
|
import com.github.steveice10.mc.protocol.data.game.chunk.Chunk;
|
||||||
import com.github.steveice10.mc.protocol.data.game.chunk.Column;
|
import com.github.steveice10.mc.protocol.data.game.chunk.Column;
|
||||||
|
import com.github.steveice10.mc.protocol.data.game.entity.metadata.Position;
|
||||||
|
import com.github.steveice10.mc.protocol.data.game.world.block.BlockChangeRecord;
|
||||||
import com.github.steveice10.mc.protocol.data.game.world.block.BlockState;
|
import com.github.steveice10.mc.protocol.data.game.world.block.BlockState;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.Tag;
|
import com.github.steveice10.opennbt.tag.builtin.Tag;
|
||||||
import org.geysermc.connector.console.GeyserLogger;
|
import org.geysermc.connector.console.GeyserLogger;
|
||||||
|
import com.nukkitx.math.vector.Vector3i;
|
||||||
|
import com.nukkitx.protocol.bedrock.packet.UpdateBlockPacket;
|
||||||
|
import org.geysermc.connector.network.session.GeyserSession;
|
||||||
import org.geysermc.connector.network.translators.TranslatorsInit;
|
import org.geysermc.connector.network.translators.TranslatorsInit;
|
||||||
import org.geysermc.connector.network.translators.block.BlockEntry;
|
import org.geysermc.connector.network.translators.block.BlockEntry;
|
||||||
import org.geysermc.connector.network.translators.block.entity.BlockEntityTranslator;
|
import org.geysermc.connector.network.translators.block.entity.BlockEntityTranslator;
|
||||||
|
@ -39,24 +44,14 @@ public class ChunkUtils {
|
||||||
for (int y = 0; y < 16; y++) {
|
for (int y = 0; y < 16; y++) {
|
||||||
for (int z = 0; z < 16; z++) {
|
for (int z = 0; z < 16; z++) {
|
||||||
BlockState blockState = chunk.get(x, y, z);
|
BlockState blockState = chunk.get(x, y, z);
|
||||||
BlockEntry block = TranslatorsInit.getBlockTranslator().getBedrockBlock(blockState);
|
BlockEntry block = TranslatorsInit.getBlockTranslator().getBlockEntry(blockState);
|
||||||
|
|
||||||
// Block entity data for signs is not sent in this packet, which is needed
|
|
||||||
// for bedrock, so we need to check the block itself
|
|
||||||
// if (block.getJavaIdentifier().contains("sign")) {
|
|
||||||
//// SignBlockEntityTranslator sign = (SignBlockEntityTranslator) BlockEntityUtils.getBlockEntityTranslator("Sign");
|
|
||||||
//// blockEntities.add(sign.getDefaultJavaTag(x, y, z));
|
|
||||||
// section.getBlockStorageArray()[0].setFullBlock(ChunkSection.blockPosition(x, y, z), 0);
|
|
||||||
//// System.out.println("Found sign at " + x + " " + y + " " + z);
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
|
|
||||||
section.getBlockStorageArray()[0].setFullBlock(ChunkSection.blockPosition(x, y, z),
|
section.getBlockStorageArray()[0].setFullBlock(ChunkSection.blockPosition(x, y, z),
|
||||||
block.getBedrockId() << 4 | block.getBedrockData());
|
block.getBedrockRuntimeId());
|
||||||
|
|
||||||
if (block.getJavaIdentifier().contains("waterlogged=true")) {
|
if (block.isWaterlogged()) {
|
||||||
section.getBlockStorageArray()[1].setFullBlock(ChunkSection.blockPosition(x, y, z),
|
BlockEntry water = TranslatorsInit.getBlockTranslator().getBlockEntry("minecraft:water[level=0]");
|
||||||
9 << 4); // water id
|
section.getBlockStorageArray()[1].setFullBlock(ChunkSection.blockPosition(x, y, z), water.getBedrockRuntimeId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -80,6 +75,29 @@ public class ChunkUtils {
|
||||||
return chunkData;
|
return chunkData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void updateBlock(GeyserSession session, BlockState blockState, Position position) {
|
||||||
|
BlockEntry blockEntry = TranslatorsInit.getBlockTranslator().getBlockEntry(blockState);
|
||||||
|
Vector3i pos = Vector3i.from(position.getX(), position.getY(), position.getZ());
|
||||||
|
|
||||||
|
UpdateBlockPacket updateBlockPacket = new UpdateBlockPacket();
|
||||||
|
updateBlockPacket.setDataLayer(0);
|
||||||
|
updateBlockPacket.setBlockPosition(pos);
|
||||||
|
updateBlockPacket.setRuntimeId(blockEntry.getBedrockRuntimeId());
|
||||||
|
updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.NEIGHBORS);
|
||||||
|
session.getUpstream().sendPacket(updateBlockPacket);
|
||||||
|
|
||||||
|
UpdateBlockPacket waterPacket = new UpdateBlockPacket();
|
||||||
|
waterPacket.setDataLayer(1);
|
||||||
|
waterPacket.setBlockPosition(pos);
|
||||||
|
if (blockEntry.isWaterlogged()) {
|
||||||
|
BlockEntry water = TranslatorsInit.getBlockTranslator().getBlockEntry("minecraft:water[level=0]");
|
||||||
|
waterPacket.setRuntimeId(water.getBedrockRuntimeId());
|
||||||
|
} else {
|
||||||
|
waterPacket.setRuntimeId(0);
|
||||||
|
}
|
||||||
|
session.getUpstream().sendPacket(waterPacket);
|
||||||
|
}
|
||||||
|
|
||||||
public static final class ChunkData {
|
public static final class ChunkData {
|
||||||
public ChunkSection[] sections;
|
public ChunkSection[] sections;
|
||||||
|
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -5,6 +5,7 @@ import com.nukkitx.nbt.NbtUtils;
|
||||||
import com.nukkitx.nbt.stream.NBTInputStream;
|
import com.nukkitx.nbt.stream.NBTInputStream;
|
||||||
import com.nukkitx.nbt.tag.CompoundTag;
|
import com.nukkitx.nbt.tag.CompoundTag;
|
||||||
import com.nukkitx.nbt.tag.ListTag;
|
import com.nukkitx.nbt.tag.ListTag;
|
||||||
|
import com.nukkitx.nbt.tag.Tag;
|
||||||
import com.nukkitx.protocol.bedrock.packet.StartGamePacket;
|
import com.nukkitx.protocol.bedrock.packet.StartGamePacket;
|
||||||
|
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||||
|
@ -13,7 +14,6 @@ import org.geysermc.connector.GeyserConnector;
|
||||||
import org.geysermc.connector.console.GeyserLogger;
|
import org.geysermc.connector.console.GeyserLogger;
|
||||||
import org.geysermc.connector.network.translators.block.BlockEntry;
|
import org.geysermc.connector.network.translators.block.BlockEntry;
|
||||||
import org.geysermc.connector.network.translators.item.ItemEntry;
|
import org.geysermc.connector.network.translators.item.ItemEntry;
|
||||||
import org.geysermc.connector.world.GlobalBlockPalette;
|
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
@ -32,7 +32,6 @@ public class Toolbox {
|
||||||
throw new AssertionError("Unable to find bedrock/runtime_block_states.dat");
|
throw new AssertionError("Unable to find bedrock/runtime_block_states.dat");
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, Integer> blockIdToIdentifier = new HashMap<>();
|
|
||||||
ListTag<CompoundTag> blocksTag;
|
ListTag<CompoundTag> blocksTag;
|
||||||
|
|
||||||
NBTInputStream nbtInputStream = NbtUtils.createNetworkReader(stream);
|
NBTInputStream nbtInputStream = NbtUtils.createNetworkReader(stream);
|
||||||
|
@ -44,15 +43,6 @@ public class Toolbox {
|
||||||
throw new AssertionError(ex);
|
throw new AssertionError(ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (CompoundTag entry : blocksTag.getValue()) {
|
|
||||||
String name = entry.getAsCompound("block").getAsString("name");
|
|
||||||
int id = entry.getAsShort("id");
|
|
||||||
int data = entry.getAsShort("meta");
|
|
||||||
|
|
||||||
blockIdToIdentifier.put(name, id);
|
|
||||||
GlobalBlockPalette.registerMapping(id << 4 | data);
|
|
||||||
}
|
|
||||||
|
|
||||||
BLOCKS = blocksTag;
|
BLOCKS = blocksTag;
|
||||||
InputStream stream2 = Toolbox.class.getClassLoader().getResourceAsStream("bedrock/items.json");
|
InputStream stream2 = Toolbox.class.getClassLoader().getResourceAsStream("bedrock/items.json");
|
||||||
if (stream2 == null) {
|
if (stream2 == null) {
|
||||||
|
@ -97,16 +87,38 @@ public class Toolbox {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
int blockIndex = 0;
|
int javaIndex = -1;
|
||||||
for (Map.Entry<String, Map<String, Object>> itemEntry : blocks.entrySet()) {
|
javaLoop:
|
||||||
if (!blockIdToIdentifier.containsKey(itemEntry.getValue().get("bedrock_identifier"))) {
|
for (Map.Entry<String, Map<String, Object>> javaEntry : blocks.entrySet()) {
|
||||||
GeyserLogger.DEFAULT.debug("Mapping " + itemEntry.getValue().get("bedrock_identifier") + " was not found for bedrock edition!");
|
javaIndex++;
|
||||||
BLOCK_ENTRIES.put(blockIndex, new BlockEntry(itemEntry.getKey(), blockIndex, 248, 0)); // update block
|
String wantedIdentifier = (String) javaEntry.getValue().get("bedrock_identifier");
|
||||||
} else {
|
Map<String, Object> wantedStates = (Map<String, Object>) javaEntry.getValue().get("bedrock_states");
|
||||||
BLOCK_ENTRIES.put(blockIndex, new BlockEntry(itemEntry.getKey(), blockIndex, blockIdToIdentifier.get(itemEntry.getValue().get("bedrock_identifier")), (int) itemEntry.getValue().get("bedrock_data")));
|
|
||||||
}
|
|
||||||
|
|
||||||
blockIndex++;
|
int bedrockIndex = -1;
|
||||||
|
bedrockLoop:
|
||||||
|
for (CompoundTag bedrockEntry : BLOCKS.getValue()) {
|
||||||
|
bedrockIndex++;
|
||||||
|
CompoundTag blockTag = bedrockEntry.getAsCompound("block");
|
||||||
|
if (blockTag.getAsString("name").equals(wantedIdentifier)) {
|
||||||
|
if (wantedStates != null) {
|
||||||
|
Map<String, Tag<?>> bedrockStates = blockTag.getAsCompound("states").getValue();
|
||||||
|
for (Map.Entry<String, Object> stateEntry : wantedStates.entrySet()) {
|
||||||
|
Tag<?> bedrockStateTag = bedrockStates.get(stateEntry.getKey());
|
||||||
|
if (bedrockStateTag == null)
|
||||||
|
continue bedrockLoop;
|
||||||
|
Object bedrockStateValue = bedrockStateTag.getValue();
|
||||||
|
if (bedrockStateValue instanceof Byte)
|
||||||
|
bedrockStateValue = ((Byte) bedrockStateValue).intValue();
|
||||||
|
if (!stateEntry.getValue().equals(bedrockStateValue))
|
||||||
|
continue bedrockLoop;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
BlockEntry blockEntry = new BlockEntry(javaEntry.getKey(), javaIndex, bedrockIndex);
|
||||||
|
BLOCK_ENTRIES.put(javaIndex, blockEntry);
|
||||||
|
continue javaLoop;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
GeyserLogger.DEFAULT.debug("Mapping " + javaEntry.getKey() + " was not found for bedrock edition!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,47 +0,0 @@
|
||||||
package org.geysermc.connector.world;
|
|
||||||
|
|
||||||
import it.unimi.dsi.fastutil.ints.Int2IntMap;
|
|
||||||
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
|
|
||||||
|
|
||||||
import java.util.NoSuchElementException;
|
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adapted from NukkitX: https://github.com/NukkitX/Nukkit
|
|
||||||
*/
|
|
||||||
public class GlobalBlockPalette {
|
|
||||||
|
|
||||||
private static final Int2IntMap legacyToRuntimeId = new Int2IntOpenHashMap();
|
|
||||||
private static final Int2IntMap runtimeIdToLegacy = new Int2IntOpenHashMap();
|
|
||||||
private static final AtomicInteger runtimeIdAllocator = new AtomicInteger(0);
|
|
||||||
|
|
||||||
static {
|
|
||||||
legacyToRuntimeId.defaultReturnValue(-1);
|
|
||||||
runtimeIdToLegacy.defaultReturnValue(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getOrCreateRuntimeId(int id, int meta) {
|
|
||||||
return getOrCreateRuntimeId((id << 4) | meta);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getOrCreateRuntimeId(int legacyId) throws NoSuchElementException {
|
|
||||||
int runtimeId = legacyToRuntimeId.get(legacyId);
|
|
||||||
if (!legacyToRuntimeId.containsKey(legacyId) || runtimeId == -1) {
|
|
||||||
//runtimeId = registerMapping(runtimeIdAllocator.incrementAndGet(), legacyId);
|
|
||||||
// throw new NoSuchElementException("Unmapped block registered id:" + (legacyId >>> 4) + " meta:" + (legacyId & 0xf));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return runtimeId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int registerMapping(int legacyId) {
|
|
||||||
int runtimeId = runtimeIdAllocator.getAndIncrement();
|
|
||||||
runtimeIdToLegacy.put(runtimeId, legacyId);
|
|
||||||
legacyToRuntimeId.put(legacyId, runtimeId);
|
|
||||||
return runtimeId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getLegacyId(int runtimeId) {
|
|
||||||
return runtimeIdToLegacy.get(runtimeId);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -4,7 +4,6 @@ import com.nukkitx.network.VarInts;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||||
import it.unimi.dsi.fastutil.ints.IntList;
|
import it.unimi.dsi.fastutil.ints.IntList;
|
||||||
import org.geysermc.connector.world.GlobalBlockPalette;
|
|
||||||
import org.geysermc.connector.world.chunk.bitarray.BitArray;
|
import org.geysermc.connector.world.chunk.bitarray.BitArray;
|
||||||
import org.geysermc.connector.world.chunk.bitarray.BitArrayVersion;
|
import org.geysermc.connector.world.chunk.bitarray.BitArrayVersion;
|
||||||
|
|
||||||
|
@ -44,11 +43,11 @@ public class BlockStorage {
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized int getFullBlock(int index) {
|
public synchronized int getFullBlock(int index) {
|
||||||
return this.legacyIdFor(this.bitArray.get(index));
|
return this.palette.getInt(this.bitArray.get(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void setFullBlock(int index, int legacyId) {
|
public synchronized void setFullBlock(int index, int runtimeId) {
|
||||||
int idx = this.idFor(legacyId);
|
int idx = this.idFor(runtimeId);
|
||||||
this.bitArray.set(index, idx);
|
this.bitArray.set(index, idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,8 +71,7 @@ public class BlockStorage {
|
||||||
this.bitArray = newBitArray;
|
this.bitArray = newBitArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int idFor(int legacyId) {
|
private int idFor(int runtimeId) {
|
||||||
int runtimeId = GlobalBlockPalette.getOrCreateRuntimeId(legacyId);
|
|
||||||
int index = this.palette.indexOf(runtimeId);
|
int index = this.palette.indexOf(runtimeId);
|
||||||
if (index != -1) {
|
if (index != -1) {
|
||||||
return index;
|
return index;
|
||||||
|
@ -91,11 +89,6 @@ public class BlockStorage {
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int legacyIdFor(int index) {
|
|
||||||
int runtimeId = this.palette.get(index);
|
|
||||||
return GlobalBlockPalette.getLegacyId(runtimeId);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isEmpty() {
|
public boolean isEmpty() {
|
||||||
if (this.palette.size() == 1) {
|
if (this.palette.size() == 1) {
|
||||||
return true;
|
return true;
|
||||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
Binary file not shown.
|
@ -1 +1 @@
|
||||||
Subproject commit 5ec6f1f339506129514de59d0e09e9b2c612e8be
|
Subproject commit b9308a64699fabb7510a05d3b270ccd6dd52b635
|
2
pom.xml
2
pom.xml
|
@ -7,7 +7,7 @@
|
||||||
<artifactId>geyser-parent</artifactId>
|
<artifactId>geyser-parent</artifactId>
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<name>GeyserMC</name>
|
<name>Geyser</name>
|
||||||
<description>Allows for players from Minecraft Bedrock Edition to join Minecraft Java Edition servers.</description>
|
<description>Allows for players from Minecraft Bedrock Edition to join Minecraft Java Edition servers.</description>
|
||||||
<url>https://geysermc.org</url>
|
<url>https://geysermc.org</url>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue