Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix inconsistencies with movement and position #699

Merged
merged 129 commits into from
Nov 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
129 commits
Select commit Hold shift + click to select a range
14f8f52
Move fixes v2
Heath123 May 30, 2020
6cc9b68
Don't ignore correction packets
Heath123 May 30, 2020
aac2ee8
Merge branch 'master' of https://github.com/GeyserMC/Geyser into move…
Heath123 Jun 1, 2020
775c238
Merge branch 'master' of https://github.com/GeyserMC/Geyser into move…
Heath123 Jun 2, 2020
1bef628
Fix teleport confirmations
Heath123 Jun 6, 2020
0db937f
Work on move fixes more
Heath123 Jun 7, 2020
7ed2832
Fix teleports
Heath123 Jun 7, 2020
20abd77
Merge branch 'master' of https://github.com/GeyserMC/Geyser into move…
Heath123 Jun 9, 2020
0b5caf4
Rework it a bit and start on solid collision checking
Heath123 Jun 12, 2020
461716e
Start working on -40 barrier
Heath123 Jun 14, 2020
949604b
Merge branch 'master' of https://github.com/GeyserMC/Geyser into move…
Heath123 Jul 9, 2020
3bc5f71
Try to fix NCP or something
Heath123 Jul 25, 2020
1fab01a
Fix pom.xml
Heath123 Jul 25, 2020
48cf90c
Improve NoCheatPlus slightly
Heath123 Jul 26, 2020
b8e4326
Respond to review
Heath123 Jul 26, 2020
a9b874d
Finally fix NCP Passable! (I hope)
Heath123 Jul 26, 2020
36048bb
Check if entity is main player when updating bounding box
Heath123 Jul 26, 2020
87ea4a3
Merge branch 'master' of https://github.com/GeyserMC/Geyser into move…
Heath123 Jul 27, 2020
52be34b
Undo changing item frame code
Heath123 Jul 27, 2020
a739219
Merge branch 'master' of https://github.com/GeyserMC/Geyser into move…
Heath123 Aug 17, 2020
aedc993
Update submodules
Heath123 Aug 18, 2020
b849745
Merge branch 'master' of https://github.com/GeyserMC/Geyser into move…
Heath123 Aug 20, 2020
5bf8b28
Merge branch 'master' of https://github.com/GeyserMC/Geyser into move…
Heath123 Aug 28, 2020
caad532
Fix it
Heath123 Aug 28, 2020
700d239
Merge branch 'master' of https://github.com/GeyserMC/Geyser into move…
Heath123 Sep 3, 2020
70f5fe3
Push temporary fix with duplicated code
Heath123 Sep 3, 2020
a52a188
Merge branch 'master' into move-fixes
Redned235 Sep 5, 2020
3f1e870
Remove files that should not be here
Redned235 Sep 5, 2020
bd7513f
Cleanups
Redned235 Sep 5, 2020
ac4ec3e
Flower pot collision and other minor tweaks
Redned235 Sep 5, 2020
abbb95e
Implement skull collision
Redned235 Sep 5, 2020
ba34261
Implement enchanting table collision
Redned235 Sep 5, 2020
823da5c
Merge branch 'master' of https://github.com/GeyserMC/Geyser into move…
Heath123 Sep 10, 2020
a333030
Fix .gitignore
Heath123 Sep 10, 2020
5daa321
Fix bed collision
Heath123 Sep 10, 2020
6683acf
Merge branch 'master' of https://github.com/GeyserMC/Geyser into move…
Heath123 Sep 19, 2020
06801f3
Merge branch 'master' of https://github.com/GeyserMC/Geyser into move…
Heath123 Sep 22, 2020
be2ab85
Merge branch 'master' of https://github.com/GeyserMC/Geyser into move…
Heath123 Sep 23, 2020
685edea
Move some code to GeyserSession and fix a bug
Heath123 Sep 24, 2020
79e4461
Merge branch 'master' of https://github.com/GeyserMC/Geyser into move…
Heath123 Sep 24, 2020
e605cc8
Use files for collison and cleanup
Heath123 Sep 26, 2020
63fbaa6
Small cleanup
Heath123 Sep 26, 2020
4aef471
Merge branch 'master' of https://github.com/GeyserMC/Geyser into move…
Heath123 Sep 26, 2020
d919021
Remove debug code and hopefully fix submodules
Heath123 Sep 27, 2020
9795edc
Remove some things that shouldn't be there
Heath123 Sep 27, 2020
63ec800
Use file collison for beds
Heath123 Sep 27, 2020
4c5039d
Passable fix cleanup
Heath123 Sep 27, 2020
07e42ba
More cleanups etc.
Heath123 Sep 27, 2020
03d4094
Delete file that shouldn't be there'
Heath123 Sep 27, 2020
65aaa24
Remove gradle folder
Heath123 Sep 27, 2020
76e8dbc
More cleanups
Heath123 Sep 27, 2020
213f1aa
Cleanup used Passable fix code
Heath123 Sep 27, 2020
d5190a1
Move static variable to top
Heath123 Sep 27, 2020
0af5e66
Remove some usused imports
Heath123 Sep 27, 2020
7f45fcc
Put some imports back or something
Heath123 Sep 27, 2020
bf06df9
Fix spacing
Heath123 Sep 27, 2020
ae50d5b
Remove debug code
Heath123 Sep 27, 2020
9af34ad
Declare BlockCollision variables on their own line
Heath123 Sep 27, 2020
4b99653
Checnge comments to JavDoc
Heath123 Sep 27, 2020
175874e
Enable chunk caching by default
Heath123 Sep 27, 2020
18825cc
Delete Gradle files
Heath123 Sep 27, 2020
b49b98a
Remove duplicate config option
Heath123 Sep 27, 2020
d4fa420
Delete more Gradle files
Heath123 Sep 27, 2020
5c81d6d
Reorganise code
Heath123 Sep 27, 2020
616d512
Delete more Gradle files
Heath123 Sep 27, 2020
42993cc
Merge branch 'master' of https://github.com/GeyserMC/Geyser into move…
Heath123 Oct 24, 2020
66a8194
Merge branch 'master' of https://github.com/GeyserMC/Geyser into move…
Heath123 Oct 24, 2020
f52e88d
Remove some useless/debug code
Heath123 Oct 24, 2020
1c8da02
Update to use pre-processed coordinates
Heath123 Oct 24, 2020
587f293
Allow look-only move packets to confirm teleports by changing code or…
Heath123 Oct 25, 2020
9cf5398
Don't send invalid snow movement
Heath123 Oct 25, 2020
49a2506
Fix potential bug/memory leak with changing worlds
Heath123 Oct 25, 2020
2bbaea4
Mostly fix door collision
Heath123 Oct 28, 2020
f453805
Merge branch 'master' of https://github.com/GeyserMC/Geyser into move…
Heath123 Oct 28, 2020
748c866
Merge branch 'master' of https://github.com/GeyserMC/Geyser into move…
Heath123 Oct 30, 2020
acedec7
Update mappings
Heath123 Oct 30, 2020
351156e
Merge branch 'master' of https://github.com/GeyserMC/Geyser into move…
Heath123 Nov 6, 2020
4ee1a41
Update mappings
Heath123 Nov 6, 2020
d800136
Fix incorrect collision
Heath123 Nov 6, 2020
502f71f
Fix JavaDoc formatting
Heath123 Nov 6, 2020
38120a9
Remove unused import
Heath123 Nov 6, 2020
6cd5223
Resolve merge conflict
Camotoy Nov 6, 2020
d67330c
Merge branch 'master' of https://github.com/GeyserMC/Geyser into move…
Camotoy Nov 6, 2020
a772b5c
Refactor and remove whitespace inconsistencies
Camotoy Nov 6, 2020
6805347
Remove .gitignore difference
Camotoy Nov 6, 2020
35aebda
Fix mappings up
Camotoy Nov 6, 2020
27a3e63
Create SessionPlayerEntity for GeyserSession-specific tasks
Camotoy Nov 7, 2020
d16bb79
Refactor BedrockMovePlayerTranslator to fix position change
Camotoy Nov 7, 2020
fb98a15
Fix inconsistencies
Camotoy Nov 7, 2020
990d9c8
Clean up methods
Camotoy Nov 7, 2020
c0d3cb3
Fix newline
Camotoy Nov 7, 2020
5ec6d32
Fix diff
Camotoy Nov 7, 2020
ddbd8d6
More general cleanup
Camotoy Nov 7, 2020
a816e14
Document CollsionRemapper more
Heath123 Nov 7, 2020
76be063
Update languages submodule
Heath123 Nov 7, 2020
b3dacb2
Remove unused, commented out method
Heath123 Nov 7, 2020
a03042a
Fix scaffolding
Heath123 Nov 7, 2020
c697c12
Fix Y rotation on move correction
Heath123 Nov 7, 2020
1c2a351
Remove deprecated methods; clean up
Camotoy Nov 7, 2020
f09bdac
Send exact teleport position on confirm
Camotoy Nov 7, 2020
c7c9c56
File clean up
Camotoy Nov 8, 2020
90ea192
Fix scaffolding bugs.
Heath123 Nov 8, 2020
e0eb475
Clean up scaffolding flag usage
Camotoy Nov 8, 2020
4435e20
Move GeyserSession to the beginning of CollisionTranslator.getCollisi…
Camotoy Nov 8, 2020
eaad17e
Fix shulker boxes
Heath123 Nov 9, 2020
43004da
Fix trapdoors
Heath123 Nov 9, 2020
d36c406
Merge branch 'master' of https://github.com/GeyserMC/Geyser into move…
Camotoy Nov 9, 2020
1b34075
Fix coloured shulker boxes
Heath123 Nov 9, 2020
585db6d
Merge branch 'move-fixes' of https://github.com/Heath123/Geyser into …
Heath123 Nov 9, 2020
5a2d31f
Fix grass paths (mostly)
Heath123 Nov 9, 2020
e4b712c
Clean up trapdoor code
Camotoy Nov 9, 2020
232a823
Merge branch 'master' of https://github.com/GeyserMC/Geyser into move…
Camotoy Nov 10, 2020
89cdf68
Fix imports
Camotoy Nov 10, 2020
49736b7
Merge branch 'master' of https://github.com/GeyserMC/Geyser into move…
Heath123 Nov 13, 2020
a7b6b79
Merge branch 'move-fixes' of https://github.com/Heath123/Geyser into …
Heath123 Nov 13, 2020
426329c
Merge branch 'master' of https://github.com/GeyserMC/Geyser into move…
Camotoy Nov 17, 2020
c9b6b71
First go at implementing Adapter support
Camotoy Nov 17, 2020
2497c63
Object-orient all the things
Camotoy Nov 17, 2020
6920b53
Work more on legacy support
Camotoy Nov 17, 2020
e2a2539
Merge branch 'master' of https://github.com/GeyserMC/Geyser into move…
Camotoy Nov 18, 2020
991b8c9
Add config option, fully update to 1.16.100
Camotoy Nov 18, 2020
9cce7de
Remove 0 air to JAVA_AIR_ID
Camotoy Nov 18, 2020
7268694
Remove unneeded override
Camotoy Nov 18, 2020
360db28
Updated to latest adapters commit and fixes the double getWorld call
Tim203 Nov 19, 2020
1ba0915
Merge pull request #14 from Tim203/move-fixes
Camotoy Nov 19, 2020
f422c3b
Merge branch 'move-fixes' of https://github.com/Heath123/Geyser into …
Camotoy Nov 20, 2020
b649f2e
Update mappings and cache protocol path
Camotoy Nov 20, 2020
817a991
Cache protocol info for 1.12 -> 1.13 as it will always be the same
Camotoy Nov 20, 2020
d05c064
Javadoc changes
Camotoy Nov 20, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions bootstrap/spigot/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@
<version>3.2.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.geysermc.adapters</groupId>
<artifactId>spigot-all</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<finalName>${outputName}-Spigot</finalName>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@

package org.geysermc.platform.spigot;

import com.github.steveice10.mc.protocol.MinecraftConstants;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
import org.geysermc.adapters.spigot.SpigotAdapters;
import org.geysermc.common.PlatformType;
import org.geysermc.connector.GeyserConnector;
import org.geysermc.connector.bootstrap.GeyserBootstrap;
Expand All @@ -42,18 +44,23 @@
import org.geysermc.platform.spigot.command.GeyserSpigotCommandManager;
import org.geysermc.platform.spigot.command.SpigotCommandSender;
import org.geysermc.platform.spigot.world.GeyserSpigotBlockPlaceListener;
import org.geysermc.platform.spigot.world.GeyserSpigotWorldManager;
import org.geysermc.platform.spigot.world.manager.*;
import us.myles.ViaVersion.api.Pair;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.data.MappingData;
import us.myles.ViaVersion.api.protocol.Protocol;
import us.myles.ViaVersion.api.protocol.ProtocolRegistry;
import us.myles.ViaVersion.api.protocol.ProtocolVersion;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
import java.util.UUID;
import java.util.logging.Level;

public class GeyserSpigotPlugin extends JavaPlugin implements GeyserBootstrap {

private GeyserSpigotCommandManager geyserCommandManager;
private GeyserSpigotConfiguration geyserConfig;
private GeyserSpigotLogger geyserLogger;
Expand Down Expand Up @@ -142,8 +149,48 @@ public void onEnable() {
// Set if we need to use a different method for getting a player's locale
SpigotCommandSender.setUseLegacyLocaleMethod(!isCompatible(Bukkit.getServer().getVersion(), "1.12.0"));

this.geyserWorldManager = new GeyserSpigotWorldManager(isLegacy, use3dBiomes, isViaVersion);
GeyserSpigotBlockPlaceListener blockPlaceListener = new GeyserSpigotBlockPlaceListener(connector, isLegacy, isViaVersion);
if (connector.getConfig().isUseAdapters()) {
try {
String name = Bukkit.getServer().getClass().getPackage().getName();
String nmsVersion = name.substring(name.lastIndexOf('.') + 1);
SpigotAdapters.registerWorldAdapter(nmsVersion);
if (isViaVersion && isViaVersionNeeded()) {
if (isLegacy) {
// Pre-1.13
this.geyserWorldManager = new GeyserSpigot1_12NativeWorldManager();
} else {
// Post-1.13
this.geyserWorldManager = new GeyserSpigotLegacyNativeWorldManager(this, use3dBiomes);
}
} else {
// No ViaVersion
this.geyserWorldManager = new GeyserSpigotNativeWorldManager(use3dBiomes);
}
geyserLogger.debug("Using NMS adapter: " + this.geyserWorldManager.getClass() + ", " + nmsVersion);
} catch (Exception e) {
if (geyserConfig.isDebugMode()) {
geyserLogger.debug("Error while attempting to find NMS adapter. Most likely, this can be safely ignored. :)");
e.printStackTrace();
}
}
} else {
geyserLogger.debug("Not using NMS adapter as it is disabled in the config.");
}
if (this.geyserWorldManager == null) {
// No NMS adapter
if (isLegacy && isViaVersion) {
// Use ViaVersion for converting pre-1.13 block states
this.geyserWorldManager = new GeyserSpigot1_12WorldManager();
} else if (isLegacy) {
// Not sure how this happens - without ViaVersion, we don't know any block states, so just assume everything is air
this.geyserWorldManager = new GeyserSpigotFallbackWorldManager();
} else {
// Post-1.13
this.geyserWorldManager = new GeyserSpigotWorldManager(use3dBiomes);
}
geyserLogger.debug("Using default world manager: " + this.geyserWorldManager.getClass());
}
GeyserSpigotBlockPlaceListener blockPlaceListener = new GeyserSpigotBlockPlaceListener(connector, this.geyserWorldManager);

Bukkit.getServer().getPluginManager().registerEvents(blockPlaceListener, this);

Expand All @@ -152,8 +199,9 @@ public void onEnable() {

@Override
public void onDisable() {
if (connector != null)
if (connector != null) {
connector.shutdown();
}
}

@Override
Expand Down Expand Up @@ -186,6 +234,11 @@ public Path getConfigFolder() {
return getDataFolder().toPath();
}

@Override
public BootstrapDumpInfo getDumpInfo() {
return new GeyserSpigotDumpInfo();
}

public boolean isCompatible(String version, String whichVersion) {
int[] currentVersion = parseVersion(version);
int[] otherVersion = parseVersion(whichVersion);
Expand Down Expand Up @@ -213,15 +266,43 @@ private int[] parseVersion(String versionParam) {
String t = stringArray[index].replaceAll("\\D", "");
try {
temp[index] = Integer.parseInt(t);
} catch(NumberFormatException ex) {
} catch (NumberFormatException ex) {
temp[index] = 0;
}
}
return temp;
}

@Override
public BootstrapDumpInfo getDumpInfo() {
return new GeyserSpigotDumpInfo();
/**
* @return the server version before ViaVersion finishes initializing
*/
public ProtocolVersion getServerProtocolVersion() {
String bukkitVersion = Bukkit.getServer().getVersion();
// Turn "(MC: 1.16.4)" into 1.16.4.
String version = bukkitVersion.split("\\(MC: ")[1].split("\\)")[0];
return ProtocolVersion.getClosest(version);
}

/**
* This function should not run unless ViaVersion is installed on the server.
*
* @return true if there is any block mappings difference between the server and client.
*/
private boolean isViaVersionNeeded() {
ProtocolVersion serverVersion = getServerProtocolVersion();
List<Pair<Integer, Protocol>> protocolList = ProtocolRegistry.getProtocolPath(MinecraftConstants.PROTOCOL_VERSION,
serverVersion.getVersion());
if (protocolList == null) {
// No translation needed!
return false;
}
for (int i = protocolList.size() - 1; i >= 0; i--) {
MappingData mappingData = protocolList.get(i).getValue().getMappingData();
if (mappingData != null) {
return true;
}
}
// All mapping data is null, which means client and server block states are the same
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@
import org.geysermc.connector.GeyserConnector;
import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.network.translators.world.block.BlockTranslator;
import org.geysermc.platform.spigot.world.manager.GeyserSpigotWorldManager;

@AllArgsConstructor
public class GeyserSpigotBlockPlaceListener implements Listener {

private final GeyserConnector connector;
private final boolean isLegacy;
private final boolean isViaVersion;
private final GeyserSpigotWorldManager worldManager;

@EventHandler
public void place(final BlockPlaceEvent event) {
Expand All @@ -52,14 +52,13 @@ public void place(final BlockPlaceEvent event) {
placeBlockSoundPacket.setSound(SoundEvent.PLACE);
placeBlockSoundPacket.setPosition(Vector3f.from(event.getBlockPlaced().getX(), event.getBlockPlaced().getY(), event.getBlockPlaced().getZ()));
placeBlockSoundPacket.setBabySound(false);
String javaBlockId;
if (isLegacy) {
javaBlockId = BlockTranslator.getJavaIdBlockMap().inverse().get(GeyserSpigotWorldManager.getLegacyBlock(session,
event.getBlockPlaced().getX(), event.getBlockPlaced().getY(), event.getBlockPlaced().getZ(), isViaVersion));
if (worldManager.isLegacy()) {
placeBlockSoundPacket.setExtraData(BlockTranslator.getBedrockBlockId(worldManager.getBlockAt(session,
event.getBlockPlaced().getX(), event.getBlockPlaced().getY(), event.getBlockPlaced().getZ())));
} else {
javaBlockId = event.getBlockPlaced().getBlockData().getAsString();
String javaBlockId = event.getBlockPlaced().getBlockData().getAsString();
placeBlockSoundPacket.setExtraData(BlockTranslator.getBedrockBlockId(BlockTranslator.getJavaIdBlockMap().getOrDefault(javaBlockId, BlockTranslator.JAVA_AIR_ID)));
}
placeBlockSoundPacket.setExtraData(BlockTranslator.getBedrockBlockId(BlockTranslator.getJavaIdBlockMap().getOrDefault(javaBlockId, 0)));
placeBlockSoundPacket.setIdentifier(":");
session.sendUpstreamPacket(placeBlockSoundPacket);
session.setLastBlockPlacePosition(null);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* Copyright (c) 2019-2020 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.platform.spigot.world.manager;

import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.geysermc.adapters.spigot.SpigotAdapters;
import org.geysermc.adapters.spigot.SpigotWorldAdapter;
import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.network.translators.world.block.BlockTranslator;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.storage.BlockStorage;

/**
* Used with ViaVersion and pre-1.13.
*/
public class GeyserSpigot1_12NativeWorldManager extends GeyserSpigot1_12WorldManager {
private final SpigotWorldAdapter adapter;

public GeyserSpigot1_12NativeWorldManager() {
this.adapter = SpigotAdapters.getWorldAdapter();
// Unlike post-1.13, we can't build up a cache of block states, because block entities need some special conversion
}

@Override
public int getBlockAt(GeyserSession session, int x, int y, int z) {
Player player = Bukkit.getPlayer(session.getPlayerEntity().getUsername());
if (player == null) {
return BlockTranslator.JAVA_AIR_ID;
}
// Get block entity storage
BlockStorage storage = Via.getManager().getConnection(player.getUniqueId()).get(BlockStorage.class);
int blockId = adapter.getBlockAt(player.getWorld(), x, y, z);
return getLegacyBlock(storage, blockId, x, y, z);
}
}
Loading