mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-13 17:37:58 -04:00
BlockAction and BlockEntity, remove some more exceptions
This commit is contained in:
parent
f0c2c4ff4c
commit
9b0e9b6bd6
@ -210,7 +210,7 @@ public class Connection {
|
||||
serverVersion = buffer.readString();
|
||||
toSend.writeString(clientVersion);
|
||||
}
|
||||
Log.info(String.format("Server is running %s, connected with %s", serverVersion, getVersion().getName()));
|
||||
Log.info(String.format("Server is running \"%s\", connected with %s", serverVersion, getVersion().getName()));
|
||||
|
||||
getPluginChannelHandler().sendRawData(DefaultPluginChannels.MC_BRAND.getName(), toSend);
|
||||
});
|
||||
|
@ -35,7 +35,13 @@ public class PacketBlockAction implements ClientboundPacket {
|
||||
public void read(InPacketBuffer buffer, ProtocolVersion v) {
|
||||
switch (v) {
|
||||
case VERSION_1_7_10:
|
||||
position = buffer.readBlockPositionShort();
|
||||
case VERSION_1_8:
|
||||
// that's the only difference here
|
||||
if (v.getVersion() >= ProtocolVersion.VERSION_1_8.getVersion()) {
|
||||
position = buffer.readPosition();
|
||||
} else {
|
||||
position = buffer.readBlockPositionShort();
|
||||
}
|
||||
byte byte1 = buffer.readByte();
|
||||
byte byte2 = buffer.readByte();
|
||||
Class<? extends BlockAction> clazz;
|
||||
@ -65,8 +71,6 @@ public class PacketBlockAction implements ClientboundPacket {
|
||||
}
|
||||
|
||||
break;
|
||||
case VERSION_1_8:
|
||||
//ToDO
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,8 @@ import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
|
||||
|
||||
public class PacketBlockEntityMetadata implements ClientboundPacket {
|
||||
BlockPosition position;
|
||||
Action action;
|
||||
Action_1_7_10 action_1_7_10;
|
||||
Action_1_8 action_1_8;
|
||||
CompoundTag nbt;
|
||||
|
||||
|
||||
@ -32,12 +33,12 @@ public class PacketBlockEntityMetadata implements ClientboundPacket {
|
||||
switch (v) {
|
||||
case VERSION_1_7_10:
|
||||
position = buffer.readBlockPositionShort();
|
||||
action = Action.byId(buffer.readByte());
|
||||
action_1_7_10 = Action_1_7_10.byId(buffer.readByte());
|
||||
nbt = buffer.readNBT(true);
|
||||
break;
|
||||
case VERSION_1_8:
|
||||
position = buffer.readPosition();
|
||||
action = Action.byId(buffer.readByte());
|
||||
action_1_8 = Action_1_8.byId(buffer.readByte());
|
||||
nbt = buffer.readNBT();
|
||||
break;
|
||||
}
|
||||
@ -45,7 +46,7 @@ public class PacketBlockEntityMetadata implements ClientboundPacket {
|
||||
|
||||
@Override
|
||||
public void log() {
|
||||
Log.protocol(String.format("Receiving blockEntityMeta (position=%s, action=%s)", position.toString(), action.name()));
|
||||
Log.protocol(String.format("Receiving blockEntityMeta (position=%s, action=%s)", position.toString(), ((action_1_7_10 == null) ? action_1_8.name() : action_1_7_10.name())));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -57,15 +58,19 @@ public class PacketBlockEntityMetadata implements ClientboundPacket {
|
||||
return position;
|
||||
}
|
||||
|
||||
public Action getAction() {
|
||||
return action;
|
||||
public Action_1_7_10 getAction1_7_10() {
|
||||
return action_1_7_10;
|
||||
}
|
||||
|
||||
public Action_1_8 getAction1_8() {
|
||||
return action_1_8;
|
||||
}
|
||||
|
||||
public CompoundTag getNbt() {
|
||||
return nbt;
|
||||
}
|
||||
|
||||
public enum Action {
|
||||
public enum Action_1_7_10 {
|
||||
SPAWNER(1),
|
||||
COMMAND_BLOCK(2),
|
||||
SKULL(3),
|
||||
@ -73,14 +78,42 @@ public class PacketBlockEntityMetadata implements ClientboundPacket {
|
||||
|
||||
final int id;
|
||||
|
||||
Action(int id) {
|
||||
Action_1_7_10(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public static Action byId(int id) {
|
||||
for (Action g : values()) {
|
||||
if (g.getId() == id) {
|
||||
return g;
|
||||
public static Action_1_7_10 byId(int id) {
|
||||
for (Action_1_7_10 a : values()) {
|
||||
if (a.getId() == id) {
|
||||
return a;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
||||
public enum Action_1_8 {
|
||||
SPAWNER(1),
|
||||
COMMAND_BLOCK(2),
|
||||
BEACON(3),
|
||||
SKULL(4),
|
||||
FLOWER_POT(5),
|
||||
BANNER(6);
|
||||
|
||||
final int id;
|
||||
|
||||
Action_1_8(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public static Action_1_8 byId(int id) {
|
||||
for (Action_1_8 a : values()) {
|
||||
if (a.getId() == id) {
|
||||
return a;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
@ -444,7 +444,13 @@ public class PacketHandler {
|
||||
connection.getPlayer().getScoreboardManager().getObjective(pkg.getScoreName()).addScore(new ScoreboardScore(pkg.getItemName(), pkg.getScoreName(), pkg.getScoreValue()));
|
||||
break;
|
||||
case REMOVE:
|
||||
connection.getPlayer().getScoreboardManager().getObjective(pkg.getScoreName()).removeScore(pkg.getScoreName());
|
||||
ScoreboardObjective objective = connection.getPlayer().getScoreboardManager().getObjective(pkg.getScoreName());
|
||||
//ToDo handle correctly
|
||||
if (objective == null) {
|
||||
Log.warn(String.format("Server tried to remove score with was not created before (itemName=\"%s\", scoreName=\"%s\")!", pkg.getItemName(), pkg.getScoreName()));
|
||||
} else {
|
||||
objective.removeScore(pkg.getItemName());
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user