Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-11-20 06:50:08 +01:00
Fix several NPE cases, apply final to relevant fields, remove unused code
The suggested changes were found with FindBugs, some of these bugs may be rare cases.
Dieser Commit ist enthalten in:
Ursprung
3027490256
Commit
744fa25349
@ -79,7 +79,8 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaPlatform {
|
|||||||
|
|
||||||
// Check if it's a spigot build with a protocol mod
|
// Check if it's a spigot build with a protocol mod
|
||||||
try {
|
try {
|
||||||
compatSpigotBuild = NMSUtil.nms("PacketEncoder").getDeclaredField("version") != null;
|
NMSUtil.nms("PacketEncoder").getDeclaredField("version");
|
||||||
|
compatSpigotBuild = true;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
compatSpigotBuild = false;
|
compatSpigotBuild = false;
|
||||||
}
|
}
|
||||||
|
@ -191,7 +191,7 @@ public abstract class Protocol {
|
|||||||
|
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@Getter
|
@Getter
|
||||||
class ProtocolPacket {
|
public static class ProtocolPacket {
|
||||||
State state;
|
State state;
|
||||||
int oldID;
|
int oldID;
|
||||||
int newID;
|
int newID;
|
||||||
|
@ -27,6 +27,6 @@ public class ShortType extends Type<Short> implements TypeConverter<Short> {
|
|||||||
if (o instanceof Boolean) {
|
if (o instanceof Boolean) {
|
||||||
return ((Boolean) o) ? (short) 1 : 0;
|
return ((Boolean) o) ? (short) 1 : 0;
|
||||||
}
|
}
|
||||||
return (short) o;
|
return (Short) o;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,6 @@ public class UnsignedByteType extends Type<Short> implements TypeConverter<Short
|
|||||||
if (o instanceof Boolean) {
|
if (o instanceof Boolean) {
|
||||||
return ((Boolean) o) ? (short) 1 : 0;
|
return ((Boolean) o) ? (short) 1 : 0;
|
||||||
}
|
}
|
||||||
return (short) o;
|
return (Short) o;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -87,12 +87,13 @@ public class Protocol1_11To1_10 extends Protocol {
|
|||||||
int type = wrapper.get(Type.VAR_INT, 1);
|
int type = wrapper.get(Type.VAR_INT, 1);
|
||||||
|
|
||||||
Entity1_11Types.EntityType entType = MetadataRewriter1_11To1_10.rewriteEntityType(type, wrapper.get(Types1_9.METADATA_LIST, 0));
|
Entity1_11Types.EntityType entType = MetadataRewriter1_11To1_10.rewriteEntityType(type, wrapper.get(Types1_9.METADATA_LIST, 0));
|
||||||
if (entType != null)
|
if (entType != null) {
|
||||||
wrapper.set(Type.VAR_INT, 1, entType.getId());
|
wrapper.set(Type.VAR_INT, 1, entType.getId());
|
||||||
|
|
||||||
// Register Type ID
|
// Register Type ID
|
||||||
wrapper.user().get(EntityTracker1_11.class).addEntity(entityId, entType);
|
wrapper.user().get(EntityTracker1_11.class).addEntity(entityId, entType);
|
||||||
get(MetadataRewriter1_11To1_10.class).handleMetadata(entityId, entType, wrapper.get(Types1_9.METADATA_LIST, 0), wrapper.user());
|
get(MetadataRewriter1_11To1_10.class).handleMetadata(entityId, entType, wrapper.get(Types1_9.METADATA_LIST, 0), wrapper.user());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -45,9 +45,9 @@ public class EntityPackets {
|
|||||||
int data = wrapper.get(Type.INT, 0);
|
int data = wrapper.get(Type.INT, 0);
|
||||||
wrapper.set(Type.INT, 0, Protocol1_13_1To1_13.getNewBlockStateId(data));
|
wrapper.set(Type.INT, 0, Protocol1_13_1To1_13.getNewBlockStateId(data));
|
||||||
}
|
}
|
||||||
|
// Register Type ID
|
||||||
|
wrapper.user().get(EntityTracker1_13.class).addEntity(entityId, entType);
|
||||||
}
|
}
|
||||||
// Register Type ID
|
|
||||||
wrapper.user().get(EntityTracker1_13.class).addEntity(entityId, entType);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -104,9 +104,9 @@ public class WorldPackets {
|
|||||||
int id = wrapper.get(Type.INT, 0);
|
int id = wrapper.get(Type.INT, 0);
|
||||||
int data = wrapper.get(Type.INT, 1);
|
int data = wrapper.get(Type.INT, 1);
|
||||||
if (id == 1010) { // Play record
|
if (id == 1010) { // Play record
|
||||||
wrapper.set(Type.INT, 1, data = InventoryPackets.getNewItemId(data));
|
wrapper.set(Type.INT, 1, InventoryPackets.getNewItemId(data));
|
||||||
} else if (id == 2001) { // Block break + block break sound
|
} else if (id == 2001) { // Block break + block break sound
|
||||||
wrapper.set(Type.INT, 1, data = Protocol1_13_1To1_13.getNewBlockStateId(data));
|
wrapper.set(Type.INT, 1, Protocol1_13_1To1_13.getNewBlockStateId(data));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -135,7 +135,9 @@ public class ChatRewriter {
|
|||||||
String oldTranslate = ((TranslatableComponent) component).getTranslate();
|
String oldTranslate = ((TranslatableComponent) component).getTranslate();
|
||||||
String newTranslate;
|
String newTranslate;
|
||||||
newTranslate = MappingData.translateMapping.get(oldTranslate);
|
newTranslate = MappingData.translateMapping.get(oldTranslate);
|
||||||
if (newTranslate == null) MappingData.mojangTranslation.get(oldTranslate);
|
if (newTranslate == null) {
|
||||||
|
newTranslate = MappingData.mojangTranslation.get(oldTranslate);
|
||||||
|
}
|
||||||
if (newTranslate != null) {
|
if (newTranslate != null) {
|
||||||
((TranslatableComponent) component).setTranslate(newTranslate);
|
((TranslatableComponent) component).setTranslate(newTranslate);
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,6 @@ import us.myles.ViaVersion.util.GsonUtil;
|
|||||||
import java.util.EnumMap;
|
import java.util.EnumMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
// Development of 1.13 support!
|
|
||||||
public class Protocol1_13To1_12_2 extends Protocol {
|
public class Protocol1_13To1_12_2 extends Protocol {
|
||||||
public static final Particle1_13Type PARTICLE_TYPE = new Particle1_13Type();
|
public static final Particle1_13Type PARTICLE_TYPE = new Particle1_13Type();
|
||||||
|
|
||||||
@ -106,8 +105,7 @@ public class Protocol1_13To1_12_2 extends Protocol {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// These are arbitrary rewrite values, it just needs an invalid color code character.
|
// These are arbitrary rewrite values, it just needs an invalid color code character.
|
||||||
protected static EnumMap<ChatColor, Character> SCOREBOARD_TEAM_NAME_REWRITE = new EnumMap<>(ChatColor.class);
|
protected final static EnumMap<ChatColor, Character> SCOREBOARD_TEAM_NAME_REWRITE = new EnumMap<>(ChatColor.class);
|
||||||
// @formatter:on
|
|
||||||
|
|
||||||
static {
|
static {
|
||||||
SCOREBOARD_TEAM_NAME_REWRITE.put(ChatColor.BLACK, 'g');
|
SCOREBOARD_TEAM_NAME_REWRITE.put(ChatColor.BLACK, 'g');
|
||||||
@ -363,11 +361,11 @@ public class Protocol1_13To1_12_2 extends Protocol {
|
|||||||
int id = wrapper.get(Type.INT, 0);
|
int id = wrapper.get(Type.INT, 0);
|
||||||
int data = wrapper.get(Type.INT, 1);
|
int data = wrapper.get(Type.INT, 1);
|
||||||
if (id == 1010) { // Play record
|
if (id == 1010) { // Play record
|
||||||
wrapper.set(Type.INT, 1, data = MappingData.oldToNewItems.get(data << 4));
|
wrapper.set(Type.INT, 1, MappingData.oldToNewItems.get(data << 4));
|
||||||
} else if (id == 2001) { // Block break + block break sound
|
} else if (id == 2001) { // Block break + block break sound
|
||||||
int blockId = data & 0xFFF;
|
int blockId = data & 0xFFF;
|
||||||
int blockData = data >> 12;
|
int blockData = data >> 12;
|
||||||
wrapper.set(Type.INT, 1, data = WorldPackets.toNewId(blockId << 4 | blockData));
|
wrapper.set(Type.INT, 1, WorldPackets.toNewId(blockId << 4 | blockData));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -35,7 +35,7 @@ public class RedstoneConnectionHandler extends ConnectionHandler {
|
|||||||
b |= getState(data.getValue("north")) << 2;
|
b |= getState(data.getValue("north")) << 2;
|
||||||
b |= getState(data.getValue("south")) << 4;
|
b |= getState(data.getValue("south")) << 4;
|
||||||
b |= getState(data.getValue("west")) << 6;
|
b |= getState(data.getValue("west")) << 6;
|
||||||
b |= Integer.valueOf(data.getValue("power")) << 8;
|
b |= Integer.parseInt(data.getValue("power")) << 8;
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,13 +21,13 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class MappingData {
|
public class MappingData {
|
||||||
public static BiMap<Integer, Integer> oldToNewItems = HashBiMap.create();
|
public static final BiMap<Integer, Integer> oldToNewItems = HashBiMap.create();
|
||||||
public static Map<String, Integer[]> blockTags = new HashMap<>();
|
public static final Map<String, Integer[]> blockTags = new HashMap<>();
|
||||||
public static Map<String, Integer[]> itemTags = new HashMap<>();
|
public static final Map<String, Integer[]> itemTags = new HashMap<>();
|
||||||
public static Map<String, Integer[]> fluidTags = new HashMap<>();
|
public static final Map<String, Integer[]> fluidTags = new HashMap<>();
|
||||||
public static BiMap<Short, String> oldEnchantmentsIds = HashBiMap.create();
|
public static final BiMap<Short, String> oldEnchantmentsIds = HashBiMap.create();
|
||||||
public static Map<String, String> translateMapping = new HashMap<>();
|
public static final Map<String, String> translateMapping = new HashMap<>();
|
||||||
public static Map<String, String> mojangTranslation = new HashMap<>();
|
public static final Map<String, String> mojangTranslation = new HashMap<>();
|
||||||
public static Mappings enchantmentMappings;
|
public static Mappings enchantmentMappings;
|
||||||
public static Mappings soundMappings;
|
public static Mappings soundMappings;
|
||||||
public static Mappings blockMappings;
|
public static Mappings blockMappings;
|
||||||
@ -50,7 +50,6 @@ public class MappingData {
|
|||||||
Via.getPlatform().getLogger().info("Loading 1.12.2 -> 1.13 sound mapping...");
|
Via.getPlatform().getLogger().info("Loading 1.12.2 -> 1.13 sound mapping...");
|
||||||
soundMappings = new SoundMappingShortArray(mapping1_12.getAsJsonArray("sounds"), mapping1_13.getAsJsonArray("sounds"));
|
soundMappings = new SoundMappingShortArray(mapping1_12.getAsJsonArray("sounds"), mapping1_13.getAsJsonArray("sounds"));
|
||||||
Via.getPlatform().getLogger().info("Loading translation mappping");
|
Via.getPlatform().getLogger().info("Loading translation mappping");
|
||||||
translateMapping = new HashMap<>();
|
|
||||||
Map<String, String> translateData = GsonUtil.getGson().fromJson(
|
Map<String, String> translateData = GsonUtil.getGson().fromJson(
|
||||||
new InputStreamReader(
|
new InputStreamReader(
|
||||||
MappingData.class.getClassLoader()
|
MappingData.class.getClassLoader()
|
||||||
|
@ -10,8 +10,8 @@ import us.myles.ViaVersion.api.type.Type;
|
|||||||
import us.myles.ViaVersion.api.type.types.version.Types1_12;
|
import us.myles.ViaVersion.api.type.types.version.Types1_12;
|
||||||
import us.myles.ViaVersion.api.type.types.version.Types1_13;
|
import us.myles.ViaVersion.api.type.types.version.Types1_13;
|
||||||
import us.myles.ViaVersion.packets.State;
|
import us.myles.ViaVersion.packets.State;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.metadata.MetadataRewriter1_13To1_12_2;
|
|
||||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.EntityTypeRewriter;
|
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.EntityTypeRewriter;
|
||||||
|
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.metadata.MetadataRewriter1_13To1_12_2;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.storage.EntityTracker1_13;
|
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.storage.EntityTracker1_13;
|
||||||
|
|
||||||
public class EntityPackets {
|
public class EntityPackets {
|
||||||
@ -68,11 +68,11 @@ public class EntityPackets {
|
|||||||
}
|
}
|
||||||
|
|
||||||
wrapper.set(Type.INT, 0, data);
|
wrapper.set(Type.INT, 0, data);
|
||||||
}
|
|
||||||
|
|
||||||
|
// Register Type ID
|
||||||
|
wrapper.user().get(EntityTracker1_13.class).addEntity(entityId, entType);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Register Type ID
|
|
||||||
wrapper.user().get(EntityTracker1_13.class).addEntity(entityId, entType);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -624,14 +624,16 @@ public class InventoryPackets {
|
|||||||
if (oldId == null && newId.startsWith("viaversion:legacy/")) {
|
if (oldId == null && newId.startsWith("viaversion:legacy/")) {
|
||||||
oldId = Short.valueOf(newId.substring(18));
|
oldId = Short.valueOf(newId.substring(18));
|
||||||
}
|
}
|
||||||
enchEntry.put(
|
if (oldId != null) {
|
||||||
new ShortTag(
|
enchEntry.put(
|
||||||
"id",
|
new ShortTag(
|
||||||
oldId
|
"id",
|
||||||
)
|
oldId
|
||||||
);
|
)
|
||||||
enchEntry.put(new ShortTag("lvl", (Short) ((CompoundTag) enchantmentEntry).get("lvl").getValue()));
|
);
|
||||||
ench.add(enchEntry);
|
enchEntry.put(new ShortTag("lvl", (Short) ((CompoundTag) enchantmentEntry).get("lvl").getValue()));
|
||||||
|
ench.add(enchEntry);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tag.remove("Enchantments");
|
tag.remove("Enchantments");
|
||||||
@ -648,14 +650,16 @@ public class InventoryPackets {
|
|||||||
if (oldId == null && newId.startsWith("viaversion:legacy/")) {
|
if (oldId == null && newId.startsWith("viaversion:legacy/")) {
|
||||||
oldId = Short.valueOf(newId.substring(18));
|
oldId = Short.valueOf(newId.substring(18));
|
||||||
}
|
}
|
||||||
enchEntry.put(
|
if (oldId != null) {
|
||||||
new ShortTag(
|
enchEntry.put(
|
||||||
"id",
|
new ShortTag(
|
||||||
oldId
|
"id",
|
||||||
)
|
oldId
|
||||||
);
|
)
|
||||||
enchEntry.put(new ShortTag("lvl", (Short) ((CompoundTag) enchantmentEntry).get("lvl").getValue()));
|
);
|
||||||
newStoredEnch.add(enchEntry);
|
enchEntry.put(new ShortTag("lvl", (Short) ((CompoundTag) enchantmentEntry).get("lvl").getValue()));
|
||||||
|
newStoredEnch.add(enchEntry);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tag.remove("StoredEnchantments");
|
tag.remove("StoredEnchantments");
|
||||||
|
@ -9,11 +9,11 @@ import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.providers.BlockEntityP
|
|||||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.storage.BlockStorage;
|
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.storage.BlockStorage;
|
||||||
|
|
||||||
public class BannerHandler implements BlockEntityProvider.BlockEntityHandler {
|
public class BannerHandler implements BlockEntityProvider.BlockEntityHandler {
|
||||||
private final int WALL_BANNER_START = 7110; // 4 each
|
private static final int WALL_BANNER_START = 7110; // 4 each
|
||||||
private final int WALL_BANNER_STOP = 7173;
|
private static final int WALL_BANNER_STOP = 7173;
|
||||||
|
|
||||||
private final int BANNER_START = 6854; // 16 each
|
private static final int BANNER_START = 6854; // 16 each
|
||||||
private final int BANNER_STOP = 7109;
|
private static final int BANNER_STOP = 7109;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int transform(UserConnection user, CompoundTag tag) {
|
public int transform(UserConnection user, CompoundTag tag) {
|
||||||
|
@ -9,8 +9,8 @@ import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.providers.BlockEntityP
|
|||||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.storage.BlockStorage;
|
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.storage.BlockStorage;
|
||||||
|
|
||||||
public class SkullHandler implements BlockEntityProvider.BlockEntityHandler {
|
public class SkullHandler implements BlockEntityProvider.BlockEntityHandler {
|
||||||
private final int SKULL_WALL_START = 5447;
|
private static final int SKULL_WALL_START = 5447;
|
||||||
private final int SKULL_END = 5566;
|
private static final int SKULL_END = 5566;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int transform(UserConnection user, CompoundTag tag) {
|
public int transform(UserConnection user, CompoundTag tag) {
|
||||||
|
@ -72,7 +72,7 @@ public class BlockStorage extends StoredObject {
|
|||||||
|
|
||||||
@Data
|
@Data
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class ReplacementData {
|
public static class ReplacementData {
|
||||||
private int original;
|
private int original;
|
||||||
private int replacement;
|
private int replacement;
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ import us.myles.ViaVersion.api.data.Mappings;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class MappingData {
|
public class MappingData {
|
||||||
public static BiMap<Integer, Integer> oldToNewItems = HashBiMap.create();
|
public final static BiMap<Integer, Integer> oldToNewItems = HashBiMap.create();
|
||||||
public static Mappings blockStateMappings;
|
public static Mappings blockStateMappings;
|
||||||
public static Mappings blockMappings;
|
public static Mappings blockMappings;
|
||||||
public static Mappings soundMappings;
|
public static Mappings soundMappings;
|
||||||
|
@ -49,7 +49,6 @@ public class EntityPackets {
|
|||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
int entityId = wrapper.get(Type.VAR_INT, 0);
|
int entityId = wrapper.get(Type.VAR_INT, 0);
|
||||||
UUID uuid = wrapper.get(Type.UUID, 0);
|
|
||||||
int typeId = wrapper.get(Type.VAR_INT, 1);
|
int typeId = wrapper.get(Type.VAR_INT, 1);
|
||||||
|
|
||||||
Entity1_13Types.EntityType type1_13 = Entity1_13Types.getTypeFromId(typeId, true);
|
Entity1_13Types.EntityType type1_13 = Entity1_13Types.getTypeFromId(typeId, true);
|
||||||
@ -95,11 +94,12 @@ public class EntityPackets {
|
|||||||
velocity.write(Type.SHORT, wrapper.get(Type.SHORT, 2));
|
velocity.write(Type.SHORT, wrapper.get(Type.SHORT, 2));
|
||||||
velocity.send(Protocol1_14To1_13_2.class);
|
velocity.send(Protocol1_14To1_13_2.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Register Type ID
|
||||||
|
wrapper.user().get(EntityTracker1_14.class).addEntity(entityId, type1_14);
|
||||||
}
|
}
|
||||||
|
|
||||||
wrapper.set(Type.VAR_INT, 1, typeId);
|
wrapper.set(Type.VAR_INT, 1, typeId);
|
||||||
// Register Type ID
|
|
||||||
wrapper.user().get(EntityTracker1_14.class).addEntity(entityId, type1_14);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -128,14 +128,11 @@ public class EntityPackets {
|
|||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
int entityId = wrapper.get(Type.VAR_INT, 0);
|
int entityId = wrapper.get(Type.VAR_INT, 0);
|
||||||
int type = wrapper.get(Type.VAR_INT, 1);
|
int type = wrapper.get(Type.VAR_INT, 1);
|
||||||
UUID uuid = wrapper.get(Type.UUID, 0);
|
|
||||||
|
|
||||||
type = EntityTypeRewriter.getNewId(type).or(type);
|
type = EntityTypeRewriter.getNewId(type).or(type);
|
||||||
|
|
||||||
Entity1_14Types.EntityType entType = Entity1_14Types.getTypeFromId(type);
|
|
||||||
|
|
||||||
wrapper.set(Type.VAR_INT, 1, type);
|
wrapper.set(Type.VAR_INT, 1, type);
|
||||||
|
|
||||||
|
Entity1_14Types.EntityType entType = Entity1_14Types.getTypeFromId(type);
|
||||||
// Register Type ID
|
// Register Type ID
|
||||||
wrapper.user().get(EntityTracker1_14.class).addEntity(entityId, entType);
|
wrapper.user().get(EntityTracker1_14.class).addEntity(entityId, entType);
|
||||||
|
|
||||||
@ -173,7 +170,6 @@ public class EntityPackets {
|
|||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
UUID uuid = wrapper.get(Type.UUID, 0);
|
|
||||||
int entityId = wrapper.get(Type.VAR_INT, 0);
|
int entityId = wrapper.get(Type.VAR_INT, 0);
|
||||||
|
|
||||||
Entity1_14Types.EntityType entType = Entity1_14Types.EntityType.PLAYER;
|
Entity1_14Types.EntityType entType = Entity1_14Types.EntityType.PLAYER;
|
||||||
|
@ -228,9 +228,9 @@ public class WorldPackets {
|
|||||||
int id = wrapper.get(Type.INT, 0);
|
int id = wrapper.get(Type.INT, 0);
|
||||||
int data = wrapper.get(Type.INT, 1);
|
int data = wrapper.get(Type.INT, 1);
|
||||||
if (id == 1010) { // Play record
|
if (id == 1010) { // Play record
|
||||||
wrapper.set(Type.INT, 1, data = InventoryPackets.getNewItemId(data));
|
wrapper.set(Type.INT, 1, InventoryPackets.getNewItemId(data));
|
||||||
} else if (id == 2001) { // Block break + block break sound
|
} else if (id == 2001) { // Block break + block break sound
|
||||||
wrapper.set(Type.INT, 1, data = Protocol1_14To1_13_2.getNewBlockStateId(data));
|
wrapper.set(Type.INT, 1, Protocol1_14To1_13_2.getNewBlockStateId(data));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -34,7 +34,8 @@ public class Chunk1_9_1_2Type extends PartialType<Chunk, ClientWorld> {
|
|||||||
|
|
||||||
boolean groundUp = input.readBoolean();
|
boolean groundUp = input.readBoolean();
|
||||||
int primaryBitmask = Type.VAR_INT.read(input);
|
int primaryBitmask = Type.VAR_INT.read(input);
|
||||||
int size = Type.VAR_INT.read(input);
|
// Size (unused)
|
||||||
|
Type.VAR_INT.read(input);
|
||||||
|
|
||||||
BitSet usedSections = new BitSet(16);
|
BitSet usedSections = new BitSet(16);
|
||||||
ChunkSection[] sections = new ChunkSection[16];
|
ChunkSection[] sections = new ChunkSection[16];
|
||||||
|
@ -329,7 +329,7 @@ public class WorldPackets {
|
|||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void registerMap() {
|
||||||
map(Type.POSITION); // 0 - Position
|
map(Type.POSITION); // 0 - Position
|
||||||
map(Type.VAR_INT, Type.BYTE); // 1 - Block Face
|
map(Type.VAR_INT, Type.UNSIGNED_BYTE); // 1 - Block Face
|
||||||
map(Type.VAR_INT, Type.NOTHING); // 2 - Hand
|
map(Type.VAR_INT, Type.NOTHING); // 2 - Hand
|
||||||
create(new ValueCreator() {
|
create(new ValueCreator() {
|
||||||
@Override
|
@Override
|
||||||
@ -359,7 +359,7 @@ public class WorldPackets {
|
|||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
int face = wrapper.get(Type.BYTE, 0);
|
int face = wrapper.get(Type.UNSIGNED_BYTE, 0);
|
||||||
if (face == 255)
|
if (face == 255)
|
||||||
return;
|
return;
|
||||||
Position p = wrapper.get(Type.POSITION, 0);
|
Position p = wrapper.get(Type.POSITION, 0);
|
||||||
|
@ -100,14 +100,14 @@ public class UpdateUtil {
|
|||||||
connection.setDoOutput(true);
|
connection.setDoOutput(true);
|
||||||
BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
||||||
String input;
|
String input;
|
||||||
String content = "";
|
StringBuilder builder = new StringBuilder();
|
||||||
while ((input = br.readLine()) != null) {
|
while ((input = br.readLine()) != null) {
|
||||||
content = content + input;
|
builder.append(input);
|
||||||
}
|
}
|
||||||
br.close();
|
br.close();
|
||||||
JsonObject statistics;
|
JsonObject statistics;
|
||||||
try {
|
try {
|
||||||
statistics = GsonUtil.getGson().fromJson(content, JsonObject.class);
|
statistics = GsonUtil.getGson().fromJson(builder.toString(), JsonObject.class);
|
||||||
} catch (JsonParseException e) {
|
} catch (JsonParseException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return null;
|
return null;
|
||||||
|
@ -76,10 +76,10 @@ public abstract class Config implements ConfigurationProvider {
|
|||||||
defaults.remove(option);
|
defaults.remove(option);
|
||||||
}
|
}
|
||||||
// Merge with defaultLoader
|
// Merge with defaultLoader
|
||||||
for (Object key : config.keySet()) {
|
for (Map.Entry<String, Object> entry : config.entrySet()) {
|
||||||
// Set option in new conf if exists
|
// Set option in new conf if exists
|
||||||
if (defaults.containsKey(key) && !unsupported.contains(key.toString())) {
|
if (defaults.containsKey(entry.getKey()) && !unsupported.contains(entry.getKey())) {
|
||||||
defaults.put((String) key, config.get(key));
|
defaults.put(entry.getKey(), entry.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
@ -70,18 +70,22 @@ public class HandItemCache implements Runnable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
int id = 0;
|
int id = 0;
|
||||||
try {
|
if (GET_ID != null) {
|
||||||
id = (int) GET_ID.invoke(null, itemInHand.getItem());
|
try {
|
||||||
} catch (IllegalAccessException e) {
|
id = (int) GET_ID.invoke(null, itemInHand.getItem());
|
||||||
e.printStackTrace();
|
} catch (IllegalAccessException e) {
|
||||||
} catch (InvocationTargetException e) {
|
e.printStackTrace();
|
||||||
e.printStackTrace();
|
} catch (InvocationTargetException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
int damage = 0;
|
int damage = 0;
|
||||||
try {
|
if (GET_DAMAGE != null) {
|
||||||
damage = (int) GET_DAMAGE.get(itemInHand);
|
try {
|
||||||
} catch (IllegalAccessException e) {
|
damage = (int) GET_DAMAGE.get(itemInHand);
|
||||||
e.printStackTrace();
|
} catch (IllegalAccessException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return new Item((short) id, (byte) itemInHand.getQuantity(), (short) damage, null);
|
return new Item((short) id, (byte) itemInHand.getQuantity(), (short) damage, null);
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren