3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-11-08 17:20:24 +01:00

Remove some more unncessary/doubled map check

Dieser Commit ist enthalten in:
KennyTV 2018-09-30 21:19:18 +02:00
Ursprung 449ec15309
Commit 033d3bcd4d
7 geänderte Dateien mit 11 neuen und 25 gelöschten Zeilen

Datei anzeigen

@ -33,9 +33,7 @@ public class EntityTracker extends StoredObject {
} }
public Optional<Entity1_11Types.EntityType> get(int id) { public Optional<Entity1_11Types.EntityType> get(int id) {
if (!has(id)) return Optional.fromNullable(clientEntityTypes.get(id));
return Optional.absent();
return Optional.of(clientEntityTypes.get(id));
} }
public void addHologram(int entId) { public void addHologram(int entId) {

Datei anzeigen

@ -28,9 +28,7 @@ public class EntityTracker extends StoredObject {
} }
public Optional<Entity1_12Types.EntityType> get(int id) { public Optional<Entity1_12Types.EntityType> get(int id) {
if (!has(id)) return Optional.fromNullable(clientEntityTypes.get(id));
return Optional.absent();
return Optional.of(clientEntityTypes.get(id));
} }
} }

Datei anzeigen

@ -46,12 +46,6 @@ public class PaintingProvider implements Provider {
// Handle older versions // Handle older versions
if (!motive.startsWith("minecraft:")) if (!motive.startsWith("minecraft:"))
motive = "minecraft:" + motive.toLowerCase(); motive = "minecraft:" + motive.toLowerCase();
return Optional.fromNullable(paintings.get(motive));
Integer index = paintings.get(motive);
if (index != null) {
return Optional.of(index);
}
return Optional.absent();
} }
} }

Datei anzeigen

@ -28,9 +28,7 @@ public class EntityTracker extends StoredObject {
} }
public Optional<Entity1_13Types.EntityType> get(int id) { public Optional<Entity1_13Types.EntityType> get(int id) {
if (!has(id)) return Optional.fromNullable(clientEntityTypes.get(id));
return Optional.absent();
return Optional.of(clientEntityTypes.get(id));
} }
} }

Datei anzeigen

@ -173,12 +173,7 @@ public enum MetaIndex {
private static Optional<MetaIndex> getIndex(Entity1_10Types.EntityType type, int index) { private static Optional<MetaIndex> getIndex(Entity1_10Types.EntityType type, int index) {
Pair pair = new Pair<>(type, index); Pair pair = new Pair<>(type, index);
MetaIndex metaIndex = metadataRewrites.get(pair); return Optional.fromNullable(metadataRewrites.get(pair));
if (metaIndex != null) {
return Optional.of(metaIndex);
}
return Optional.absent();
} }
public static MetaIndex searchIndex(Entity1_10Types.EntityType type, int index) { public static MetaIndex searchIndex(Entity1_10Types.EntityType type, int index) {

Datei anzeigen

@ -57,11 +57,14 @@ public class CommandBlockStorage extends StoredObject {
if (blocks == null) if (blocks == null)
return Optional.absent(); return Optional.absent();
CompoundTag tag = blocks.get(position).clone(); CompoundTag tag = blocks.get(position);
if (tag == null)
return Optional.absent();
tag = tag.clone();
tag.put(new ByteTag("powered", (byte) 0)); tag.put(new ByteTag("powered", (byte) 0));
tag.put(new ByteTag("auto", (byte) 0)); tag.put(new ByteTag("auto", (byte) 0));
tag.put(new ByteTag("conditionMet", (byte) 0)); tag.put(new ByteTag("conditionMet", (byte) 0));
return Optional.of(tag); return Optional.of(tag);
} }

Datei anzeigen

@ -183,7 +183,7 @@ public abstract class Config implements ConfigurationProvider {
public List<Integer> getIntegerList(String key) { public List<Integer> getIntegerList(String key) {
Object o = this.config.get(key); Object o = this.config.get(key);
if (o != null) { if (o != null) {
return (List<Integer>) this.config.get(key); return (List<Integer>) o;
} else { } else {
return new ArrayList<>(); return new ArrayList<>();
} }