mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-12 08:58:02 -04:00
some fixes, store sign data as nbt internally
This commit is contained in:
parent
a37b3ed181
commit
60f0d5dc89
@ -23,12 +23,12 @@ public class Team {
|
||||
final String name;
|
||||
final List<String> players;
|
||||
TextComponent displayName;
|
||||
String prefix;
|
||||
String suffix;
|
||||
TextComponent prefix;
|
||||
TextComponent suffix;
|
||||
boolean friendlyFire;
|
||||
boolean seeFriendlyInvisibles;
|
||||
|
||||
public Team(String name, TextComponent displayName, String prefix, String suffix, boolean friendlyFire, boolean seeFriendlyInvisibles, String[] players) {
|
||||
public Team(String name, TextComponent displayName, TextComponent prefix, TextComponent suffix, boolean friendlyFire, boolean seeFriendlyInvisibles, String[] players) {
|
||||
this.name = name;
|
||||
this.displayName = displayName;
|
||||
this.prefix = prefix;
|
||||
@ -38,7 +38,7 @@ public class Team {
|
||||
this.players = new ArrayList<>(Arrays.asList(players));
|
||||
}
|
||||
|
||||
public void updateInformation(TextComponent displayName, String prefix, String suffix, boolean friendlyFire, boolean seeFriendlyInvisibles) {
|
||||
public void updateInformation(TextComponent displayName, TextComponent prefix, TextComponent suffix, boolean friendlyFire, boolean seeFriendlyInvisibles) {
|
||||
this.displayName = displayName;
|
||||
this.prefix = prefix;
|
||||
this.suffix = suffix;
|
||||
@ -54,11 +54,11 @@ public class Team {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
public String getPrefix() {
|
||||
public TextComponent getPrefix() {
|
||||
return prefix;
|
||||
}
|
||||
|
||||
public String getSuffix() {
|
||||
public TextComponent getSuffix() {
|
||||
return suffix;
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,6 @@
|
||||
package de.bixilon.minosoft.game.datatypes.world;
|
||||
|
||||
import de.bixilon.minosoft.game.datatypes.Dimension;
|
||||
import de.bixilon.minosoft.game.datatypes.TextComponent;
|
||||
import de.bixilon.minosoft.game.datatypes.blocks.Block;
|
||||
import de.bixilon.minosoft.game.datatypes.blocks.Blocks;
|
||||
import de.bixilon.minosoft.game.datatypes.entities.Entity;
|
||||
@ -30,7 +29,6 @@ public class World {
|
||||
final HashMap<ChunkLocation, Chunk> chunks;
|
||||
final HashMap<Integer, Entity> entities;
|
||||
final String name;
|
||||
final HashMap<BlockPosition, TextComponent[]> signs;
|
||||
final HashMap<BlockPosition, CompoundTag> blockEntityMeta;
|
||||
boolean hardcore;
|
||||
boolean raining;
|
||||
@ -40,7 +38,6 @@ public class World {
|
||||
this.name = name;
|
||||
chunks = new HashMap<>();
|
||||
entities = new HashMap<>();
|
||||
signs = new HashMap<>();
|
||||
blockEntityMeta = new HashMap<>();
|
||||
}
|
||||
|
||||
@ -125,15 +122,6 @@ public class World {
|
||||
this.dimension = dimension;
|
||||
}
|
||||
|
||||
public void updateSign(BlockPosition position, TextComponent[] lines) {
|
||||
// ToDo check if block is really a sign
|
||||
signs.put(position, lines);
|
||||
}
|
||||
|
||||
public TextComponent[] getSignText(BlockPosition position) {
|
||||
return signs.get(position);
|
||||
}
|
||||
|
||||
public void setBlockEntityData(BlockPosition position, CompoundTag nbt) {
|
||||
// ToDo check if block is really a block entity (command block, spawner, skull, flower pot)
|
||||
blockEntityMeta.put(position, nbt);
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
package de.bixilon.minosoft.nbt.tag;
|
||||
|
||||
import de.bixilon.minosoft.game.datatypes.world.BlockPosition;
|
||||
import de.bixilon.minosoft.protocol.protocol.InByteBuffer;
|
||||
import de.bixilon.minosoft.protocol.protocol.OutByteBuffer;
|
||||
|
||||
@ -182,6 +183,18 @@ public class CompoundTag implements NBTTag {
|
||||
return (CompoundTag) data.get(key);
|
||||
}
|
||||
|
||||
public void writeTag(String name, NBTTag tag) {
|
||||
data.put(name, tag);
|
||||
}
|
||||
|
||||
// abstract functions
|
||||
|
||||
public void writeBlockPosition(BlockPosition position) {
|
||||
data.put("x", new IntTag(position.getX()));
|
||||
data.put("y", new IntTag(position.getY()));
|
||||
data.put("z", new IntTag(position.getZ()));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
@ -76,7 +76,7 @@ public class PacketDeclareRecipes implements ClientboundPacket {
|
||||
|
||||
@Override
|
||||
public void log() {
|
||||
Log.protocol(String.format("Received unlock crafting recipe packet (recipeLength=%d)", recipes.length));
|
||||
Log.protocol(String.format("Received declare recipe packet (recipeLength=%d)", recipes.length));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -25,8 +25,8 @@ public class PacketTeams implements ClientboundPacket {
|
||||
String name;
|
||||
TeamActions action;
|
||||
TextComponent displayName;
|
||||
String prefix;
|
||||
String suffix;
|
||||
TextComponent prefix;
|
||||
TextComponent suffix;
|
||||
boolean friendlyFire;
|
||||
boolean seeFriendlyInvisibles;
|
||||
TeamCollisionRules collisionRule = TeamCollisionRules.NEVER;
|
||||
@ -43,8 +43,8 @@ public class PacketTeams implements ClientboundPacket {
|
||||
action = TeamActions.byId(buffer.readByte());
|
||||
if (action == TeamActions.CREATE || action == TeamActions.INFORMATION_UPDATE) {
|
||||
displayName = buffer.readTextComponent();
|
||||
prefix = buffer.readString();
|
||||
suffix = buffer.readString();
|
||||
prefix = buffer.readTextComponent();
|
||||
suffix = buffer.readTextComponent();
|
||||
setFriendlyFireByLegacy(buffer.readByte());
|
||||
}
|
||||
if (action == TeamActions.CREATE || action == TeamActions.PLAYER_ADD || action == TeamActions.PLAYER_REMOVE) {
|
||||
@ -60,8 +60,8 @@ public class PacketTeams implements ClientboundPacket {
|
||||
action = TeamActions.byId(buffer.readByte());
|
||||
if (action == TeamActions.CREATE || action == TeamActions.INFORMATION_UPDATE) {
|
||||
displayName = buffer.readTextComponent();
|
||||
prefix = buffer.readString();
|
||||
suffix = buffer.readString();
|
||||
prefix = buffer.readTextComponent();
|
||||
suffix = buffer.readTextComponent();
|
||||
setFriendlyFireByLegacy(buffer.readByte());
|
||||
nameTagVisibility = TeamNameTagVisibilities.byName(buffer.readString());
|
||||
color = TextComponent.ChatAttributes.byColor(ChatColor.byId(buffer.readByte()));
|
||||
@ -82,8 +82,8 @@ public class PacketTeams implements ClientboundPacket {
|
||||
action = TeamActions.byId(buffer.readByte());
|
||||
if (action == TeamActions.CREATE || action == TeamActions.INFORMATION_UPDATE) {
|
||||
displayName = buffer.readTextComponent();
|
||||
prefix = buffer.readString();
|
||||
suffix = buffer.readString();
|
||||
prefix = buffer.readTextComponent();
|
||||
suffix = buffer.readTextComponent();
|
||||
byte friendlyFireRaw = buffer.readByte();
|
||||
friendlyFire = BitByte.isBitMask(friendlyFireRaw, 0x01);
|
||||
seeFriendlyInvisibles = BitByte.isBitMask(friendlyFireRaw, 0x02);
|
||||
@ -110,8 +110,8 @@ public class PacketTeams implements ClientboundPacket {
|
||||
nameTagVisibility = TeamNameTagVisibilities.byName(buffer.readString());
|
||||
collisionRule = TeamCollisionRules.byName(buffer.readString());
|
||||
color = TextComponent.ChatAttributes.byColor(ChatColor.byId(buffer.readByte()));
|
||||
prefix = buffer.readString();
|
||||
suffix = buffer.readString();
|
||||
prefix = buffer.readTextComponent();
|
||||
suffix = buffer.readTextComponent();
|
||||
}
|
||||
if (action == TeamActions.CREATE || action == TeamActions.PLAYER_ADD || action == TeamActions.PLAYER_REMOVE) {
|
||||
int playerCount = buffer.readVarInt();
|
||||
@ -148,11 +148,11 @@ public class PacketTeams implements ClientboundPacket {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
public String getPrefix() {
|
||||
public TextComponent getPrefix() {
|
||||
return prefix;
|
||||
}
|
||||
|
||||
public String getSuffix() {
|
||||
public TextComponent getSuffix() {
|
||||
return suffix;
|
||||
}
|
||||
|
||||
|
@ -27,6 +27,8 @@ import de.bixilon.minosoft.game.datatypes.scoreboard.ScoreboardScore;
|
||||
import de.bixilon.minosoft.game.datatypes.scoreboard.Team;
|
||||
import de.bixilon.minosoft.game.datatypes.world.BlockPosition;
|
||||
import de.bixilon.minosoft.logging.Log;
|
||||
import de.bixilon.minosoft.nbt.tag.CompoundTag;
|
||||
import de.bixilon.minosoft.nbt.tag.StringTag;
|
||||
import de.bixilon.minosoft.protocol.network.Connection;
|
||||
import de.bixilon.minosoft.protocol.packets.clientbound.login.PacketEncryptionRequest;
|
||||
import de.bixilon.minosoft.protocol.packets.clientbound.login.PacketLoginDisconnect;
|
||||
@ -339,7 +341,12 @@ public class PacketHandler {
|
||||
}
|
||||
|
||||
public void handle(PacketUpdateSignReceiving pkg) {
|
||||
connection.getPlayer().getWorld().updateSign(pkg.getPosition(), pkg.getLines());
|
||||
CompoundTag nbt = new CompoundTag();
|
||||
nbt.writeBlockPosition(pkg.getPosition());
|
||||
nbt.writeTag("id", new StringTag("minecraft:sign"));
|
||||
for (int i = 0; i < 4; i++) {
|
||||
nbt.writeTag(String.format("Text%d", (i + 1)), new StringTag(pkg.getLines()[i].getRaw().toString()));
|
||||
}
|
||||
}
|
||||
|
||||
public void handle(PacketEntityAnimation pkg) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user