mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2024-11-23 02:25:19 +01:00
Set default return values
This commit is contained in:
parent
8188ae09f5
commit
6167c3b526
@ -137,12 +137,7 @@ public class ProtocolRegistry {
|
||||
protocols.put(protocol.getClass(), protocol);
|
||||
|
||||
for (int version : supported) {
|
||||
Int2ObjectMap<Protocol> protocolMap = registryMap.get(version);
|
||||
if (protocolMap == null) {
|
||||
protocolMap = new Int2ObjectOpenHashMap<>(1);
|
||||
registryMap.put(version, protocolMap);
|
||||
}
|
||||
|
||||
Int2ObjectMap<Protocol> protocolMap = registryMap.computeIfAbsent(version, s -> new Int2ObjectOpenHashMap<>(1));
|
||||
protocolMap.put(output, protocol);
|
||||
}
|
||||
|
||||
|
@ -184,7 +184,10 @@ public abstract class MetadataRewriter {
|
||||
}
|
||||
|
||||
public <T extends Enum<T> & EntityType> void mapTypes(EntityType[] oldTypes, Class<T> newTypeClass) {
|
||||
if (typeMapping == null) typeMapping = new Int2IntOpenHashMap(oldTypes.length);
|
||||
if (typeMapping == null) {
|
||||
typeMapping = new Int2IntOpenHashMap(oldTypes.length);
|
||||
typeMapping.defaultReturnValue(-1);
|
||||
}
|
||||
for (EntityType oldType : oldTypes) {
|
||||
try {
|
||||
T newType = Enum.valueOf(newTypeClass, oldType.name());
|
||||
@ -199,7 +202,10 @@ public abstract class MetadataRewriter {
|
||||
}
|
||||
|
||||
public void mapType(EntityType oldType, EntityType newType) {
|
||||
if (typeMapping == null) typeMapping = new Int2IntOpenHashMap();
|
||||
if (typeMapping == null) {
|
||||
typeMapping = new Int2IntOpenHashMap();
|
||||
typeMapping.defaultReturnValue(-1);
|
||||
}
|
||||
typeMapping.put(oldType.getId(), newType.getId());
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package us.myles.ViaVersion.protocols.protocol1_13to1_12_2.blockconnections;
|
||||
|
||||
import it.unimi.dsi.fastutil.ints.Int2IntMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
@ -11,7 +12,7 @@ import java.util.Set;
|
||||
|
||||
|
||||
public class FlowerConnectionHandler extends ConnectionHandler {
|
||||
private static final Int2IntOpenHashMap flowers = new Int2IntOpenHashMap();
|
||||
private static final Int2IntMap flowers = new Int2IntOpenHashMap();
|
||||
|
||||
static ConnectionData.ConnectorInitAction init() {
|
||||
final Set<String> baseFlower = new HashSet<>();
|
||||
@ -38,7 +39,7 @@ public class FlowerConnectionHandler extends ConnectionHandler {
|
||||
public int connect(UserConnection user, Position position, int blockState) {
|
||||
int blockBelowId = getBlockData(user, position.getRelative(BlockFace.BOTTOM));
|
||||
int connectBelow = flowers.get(blockBelowId);
|
||||
if (connectBelow != -1) {
|
||||
if (connectBelow != 0) {
|
||||
int blockAboveId = getBlockData(user, position.getRelative(BlockFace.TOP));
|
||||
if (Via.getConfig().isStemWhenBlockAbove()) {
|
||||
if (blockAboveId == 0) {
|
||||
|
@ -1,5 +1,6 @@
|
||||
package us.myles.ViaVersion.protocols.protocol1_13to1_12_2.blockconnections;
|
||||
|
||||
import it.unimi.dsi.fastutil.ints.Int2IntMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.api.minecraft.BlockFace;
|
||||
@ -10,8 +11,8 @@ import java.util.Set;
|
||||
|
||||
public class RedstoneConnectionHandler extends ConnectionHandler {
|
||||
private static final Set<Integer> redstone = new HashSet<>();
|
||||
private static final Int2IntOpenHashMap connectedBlockStates = new Int2IntOpenHashMap(1296);
|
||||
private static final Int2IntOpenHashMap powerMappings = new Int2IntOpenHashMap(1296);
|
||||
private static final Int2IntMap connectedBlockStates = new Int2IntOpenHashMap(1296);
|
||||
private static final Int2IntMap powerMappings = new Int2IntOpenHashMap(1296);
|
||||
|
||||
static ConnectionData.ConnectorInitAction init() {
|
||||
final RedstoneConnectionHandler connectionHandler = new RedstoneConnectionHandler();
|
||||
|
@ -1,11 +1,13 @@
|
||||
package us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data;
|
||||
|
||||
import it.unimi.dsi.fastutil.ints.Int2IntMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
|
||||
|
||||
public class EntityTypeRewriter {
|
||||
private static final Int2IntOpenHashMap ENTITY_TYPES = new Int2IntOpenHashMap(93);
|
||||
private static final Int2IntMap ENTITY_TYPES = new Int2IntOpenHashMap(93);
|
||||
|
||||
static {
|
||||
ENTITY_TYPES.defaultReturnValue(-1);
|
||||
registerEntity(1, 32); // item - ajl
|
||||
registerEntity(2, 22); // xp_orb - abx
|
||||
registerEntity(3, 0); // area_effect_cloud - abp
|
||||
|
@ -47,7 +47,7 @@ public class MappingData {
|
||||
if (id == null) {
|
||||
Via.getPlatform().getLogger().warning("Unknown blockstate " + key + " :(");
|
||||
} else {
|
||||
MappingData.motionBlocking.add(id);
|
||||
MappingData.motionBlocking.add(id.intValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user