mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Signs placed ingame work
This commit is contained in:
parent
50b71a1050
commit
4cba8b05a5
4 changed files with 23 additions and 17 deletions
|
|
@ -26,6 +26,7 @@
|
||||||
package org.geysermc.connector.network.translators.bedrock;
|
package org.geysermc.connector.network.translators.bedrock;
|
||||||
|
|
||||||
import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerPositionRotationPacket;
|
import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerPositionRotationPacket;
|
||||||
|
import static com.nukkitx.math.vector.Vector2f.from;
|
||||||
import com.nukkitx.math.vector.Vector3f;
|
import com.nukkitx.math.vector.Vector3f;
|
||||||
import com.nukkitx.protocol.bedrock.packet.MoveEntityAbsolutePacket;
|
import com.nukkitx.protocol.bedrock.packet.MoveEntityAbsolutePacket;
|
||||||
import com.nukkitx.protocol.bedrock.packet.MovePlayerPacket;
|
import com.nukkitx.protocol.bedrock.packet.MovePlayerPacket;
|
||||||
|
|
@ -37,6 +38,8 @@ import org.geysermc.connector.entity.type.EntityType;
|
||||||
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 static java.lang.Math.abs;
|
||||||
|
|
||||||
public class BedrockMovePlayerTranslator extends PacketTranslator<MovePlayerPacket> {
|
public class BedrockMovePlayerTranslator extends PacketTranslator<MovePlayerPacket> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -91,18 +94,9 @@ public class BedrockMovePlayerTranslator extends PacketTranslator<MovePlayerPack
|
||||||
if (mode != MovePlayerPacket.Mode.NORMAL)
|
if (mode != MovePlayerPacket.Mode.NORMAL)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
double xRange = newPosition.getX() - currentPosition.getX();
|
double yRange = abs(newPosition.getY() - currentPosition.getY());
|
||||||
double yRange = newPosition.getY() - currentPosition.getY();
|
|
||||||
double zRange = newPosition.getZ() - currentPosition.getZ();
|
|
||||||
|
|
||||||
if (xRange < 0)
|
if (yRange > 30 || dist(newPosition, currentPosition) > 10) {
|
||||||
xRange = -xRange;
|
|
||||||
if (yRange < 0)
|
|
||||||
yRange = -yRange;
|
|
||||||
if (zRange < 0)
|
|
||||||
zRange = -zRange;
|
|
||||||
|
|
||||||
if ((xRange + yRange + zRange) > 100) {
|
|
||||||
session.getConnector().getLogger().debug(ChatColor.RED + session.getName() + " moved too quickly." +
|
session.getConnector().getLogger().debug(ChatColor.RED + session.getName() + " moved too quickly." +
|
||||||
" current position: " + currentPosition + ", new position: " + newPosition);
|
" current position: " + currentPosition + ", new position: " + newPosition);
|
||||||
|
|
||||||
|
|
@ -112,6 +106,10 @@ public class BedrockMovePlayerTranslator extends PacketTranslator<MovePlayerPack
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private double dist(Vector3f a, Vector3f b) {
|
||||||
|
return from(a.getX(), a.getZ()).distance(from(b.getX(), b.getZ()));
|
||||||
|
}
|
||||||
|
|
||||||
public void recalculatePosition(GeyserSession session, Entity entity, Vector3f currentPosition) {
|
public void recalculatePosition(GeyserSession session, Entity entity, Vector3f currentPosition) {
|
||||||
// Gravity might need to be reset...
|
// Gravity might need to be reset...
|
||||||
SetEntityDataPacket entityDataPacket = new SetEntityDataPacket();
|
SetEntityDataPacket entityDataPacket = new SetEntityDataPacket();
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ public class SignDataMapper extends BlockEntityUtils.ExtraDataMapper {
|
||||||
.intTag("x", x)
|
.intTag("x", x)
|
||||||
.intTag("y", y)
|
.intTag("y", y)
|
||||||
.intTag("z", z)
|
.intTag("z", z)
|
||||||
|
.byteTag("isMovable", (byte) 0)
|
||||||
.build("");
|
.build("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ public class ChunkUtils {
|
||||||
int chunkSectionCount = chunks.length;
|
int chunkSectionCount = chunks.length;
|
||||||
chunkData.sections = new ChunkSection[chunkSectionCount];
|
chunkData.sections = new ChunkSection[chunkSectionCount];
|
||||||
|
|
||||||
|
//Will be useful later
|
||||||
List<CompoundTag> tiles = new ArrayList<>(Arrays.asList(column.getTileEntities()));
|
List<CompoundTag> tiles = new ArrayList<>(Arrays.asList(column.getTileEntities()));
|
||||||
|
|
||||||
for (int chunkY = 0; chunkY < chunkSectionCount; chunkY++) {
|
for (int chunkY = 0; chunkY < chunkSectionCount; chunkY++) {
|
||||||
|
|
@ -46,12 +47,17 @@ public class ChunkUtils {
|
||||||
BlockState blockState = chunk.get(x, y, z);
|
BlockState blockState = chunk.get(x, y, z);
|
||||||
BlockEntry block = TranslatorsInit.getBlockTranslator().getBedrockBlock(blockState);
|
BlockEntry block = TranslatorsInit.getBlockTranslator().getBedrockBlock(blockState);
|
||||||
|
|
||||||
section.getBlockStorageArray()[0].setFullBlock(ChunkSection.blockPosition(x, y, z),
|
if(!block.getJavaIdentifier().contains("sign")) {
|
||||||
block.getBedrockId() << 4 | block.getBedrockData());
|
section.getBlockStorageArray()[0].setFullBlock(ChunkSection.blockPosition(x, y, z),
|
||||||
|
block.getBedrockId() << 4 | block.getBedrockData());
|
||||||
|
|
||||||
if (block.getJavaIdentifier().contains("waterlogged=true")) {
|
if (block.getJavaIdentifier().contains("waterlogged=true")) {
|
||||||
|
section.getBlockStorageArray()[1].setFullBlock(ChunkSection.blockPosition(x, y, z),
|
||||||
|
9 << 4); // water id
|
||||||
|
}
|
||||||
|
} else {
|
||||||
section.getBlockStorageArray()[1].setFullBlock(ChunkSection.blockPosition(x, y, z),
|
section.getBlockStorageArray()[1].setFullBlock(ChunkSection.blockPosition(x, y, z),
|
||||||
9 << 4); // water id
|
0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -64,6 +70,7 @@ public class ChunkUtils {
|
||||||
NBTOutputStream nbtStream = NbtUtils.createNetworkWriter(stream);
|
NBTOutputStream nbtStream = NbtUtils.createNetworkWriter(stream);
|
||||||
|
|
||||||
for (CompoundTag tag : tiles) {
|
for (CompoundTag tag : tiles) {
|
||||||
|
if(tag.get("id").getValue().toString().contains("sign")) continue;
|
||||||
try {
|
try {
|
||||||
nbtStream.write(BlockEntityUtils.getExtraTags(tag));
|
nbtStream.write(BlockEntityUtils.getExtraTags(tag));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
|
||||||
|
|
@ -104,6 +104,7 @@ public class MessageUtils {
|
||||||
ret+=getFormat(FORMATS.get(string));
|
ret+=getFormat(FORMATS.get(string));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ret+=object.get("text").getAsString();
|
||||||
|
|
||||||
if(object.has("extra")) {
|
if(object.has("extra")) {
|
||||||
for(JsonElement element : object.get("extra").getAsJsonArray()) {
|
for(JsonElement element : object.get("extra").getAsJsonArray()) {
|
||||||
|
|
@ -116,14 +117,13 @@ public class MessageUtils {
|
||||||
ret+=getFormat(FORMATS.get(string));
|
ret+=getFormat(FORMATS.get(string));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ret+=element.getAsJsonObject().get("text").getAsString();
|
||||||
} else {
|
} else {
|
||||||
ret+=element.getAsString();
|
ret+=element.getAsString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ret+=object.get("text").getAsString();
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue