Upstream, generics, formatting

This commit is contained in:
MattBDev
2019-06-11 16:07:43 -04:00
parent e2c2205dac
commit cd88e513a8
126 changed files with 2488 additions and 3091 deletions

View File

@ -830,16 +830,15 @@ public final class BlockTypes {
}
}
{ // Register new blocks
int internalId = 1;
for (Map.Entry<String, String> entry : blockMap.entrySet()) {
String id = entry.getKey();
String defaultState = entry.getValue();
// Skip already registered ids
for (; values[internalId] != null; internalId++);
BlockType type = register(defaultState, internalId, stateList);
values[internalId] = type;
}
// Register new blocks
int internalId = 1;
for (Map.Entry<String, String> entry : blockMap.entrySet()) {
String id = entry.getKey();
String defaultState = entry.getValue();
// Skip already registered ids
for (; values[internalId] != null; internalId++);
BlockType type = register(defaultState, internalId, stateList);
values[internalId] = type;
}
// Add to $Registry
@ -866,9 +865,7 @@ public final class BlockTypes {
try {
Field field = BlockTypes.class.getDeclaredField(enumName);
ReflectionUtils.setFailsafeFieldValue(field, null, existing);
} catch (NoSuchFieldException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
} catch (NoSuchFieldException | IllegalAccessException e) {
e.printStackTrace();
}
@ -898,12 +895,12 @@ public final class BlockTypes {
try {
BlockStateHolder block = LegacyMapper.getInstance().getBlockFromLegacy(input);
if (block != null) return block.getBlockType();
} catch (NumberFormatException | IndexOutOfBoundsException e) {
} catch (NumberFormatException | IndexOutOfBoundsException ignored) {
}
throw new SuggestInputParseException("Does not match a valid block type: " + inputLower, inputLower, () -> Stream.of(BlockTypes.values)
.filter(b -> StringMan.blockStateMatches(inputLower, b.getId()))
.map(e1 -> e1.getId())
.map(BlockType::getId)
.sorted(StringMan.blockStateComparator(inputLower))
.collect(Collectors.toList())
);
@ -913,31 +910,31 @@ public final class BlockTypes {
return $NAMESPACES;
}
public static final @Nullable BlockType get(final String id) {
public static @Nullable BlockType get(final String id) {
return $REGISTRY.get(id);
}
public static final @Nullable BlockType get(final CharSequence id) {
public static @Nullable BlockType get(final CharSequence id) {
return $REGISTRY.get(id);
}
@Deprecated
public static final BlockType get(final int ordinal) {
public static BlockType get(final int ordinal) {
return values[ordinal];
}
@Deprecated
public static final BlockType getFromStateId(final int internalStateId) {
public static BlockType getFromStateId(final int internalStateId) {
return values[internalStateId & BIT_MASK];
}
@Deprecated
public static final BlockType getFromStateOrdinal(final int internalStateOrdinal) {
public static BlockType getFromStateOrdinal(final int internalStateOrdinal) {
return states[internalStateOrdinal].getBlockType();
}
public static int size() {
return values.length;
}
}