Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -279,5 +279,10 @@
"/>
<message key="matchxpath.match" value="Inject local capture is not allowed, use @Local instead"/>
</module>

<module name="MatchXpath">
<property name="query" value="//LITERAL_ASSERT"/>
<message key="matchxpath.match" value="Avoid using 'assert'."/>
</module>
</module>
</module>
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,9 @@ public RegistryEntry<Biome> pick(int x, int y, int z, MultiNoiseUtil.MultiNoiseS

return pick(highlandsReplacement, vanillaBiome, map, x, z, noise);
} else {
assert END_BIOMES_MAP.containsKey(vanillaBiome.getKey().orElseThrow());
if (!END_BIOMES_MAP.containsKey(vanillaBiome.getKey().orElseThrow())) {
throw new IllegalStateException("Biome is not an End biome: " + vanillaBiome);
}

return pick(vanillaBiome, vanillaBiome, endBiomesMap, x, z, noise);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,10 @@ public static ClientPlayNetworkAddon getClientPlayAddon() {
}

public static void setClientPlayAddon(ClientPlayNetworkAddon addon) {
assert addon == null || currentConfigurationAddon == null;
if (!(addon == null || currentConfigurationAddon == null)) {
throw new IllegalStateException();
}

currentPlayAddon = addon;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,10 @@ public Set<Identifier> getSendableChannels() {

@Override
public void onCommonVersionPacket(int negotiatedVersion) {
assert negotiatedVersion == 1; // We only support version 1 for now
// We only support version 1 for now
if (negotiatedVersion != 1) {
throw new UnsupportedOperationException("Unsupported common packet version: " + negotiatedVersion);
}

commonVersion = negotiatedVersion;
this.logger.debug("Negotiated common packet version {}", commonVersion);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,13 @@ public GlobalReceiverRegistry(NetworkSide side, NetworkPhase phase, @Nullable Pa
this.payloadTypeRegistry = payloadTypeRegistry;

if (payloadTypeRegistry != null) {
assert phase == payloadTypeRegistry.getPhase();
assert side == payloadTypeRegistry.getSide();
if (phase != payloadTypeRegistry.getPhase()) {
throw new IllegalStateException();
}

if (side != payloadTypeRegistry.getSide()) {
throw new IllegalStateException();
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,10 @@ public boolean startConfiguration() {
}

// We should have received a response
assert registerState == RegisterState.RECEIVED || registerState == RegisterState.NOT_RECEIVED;
if (!(registerState == RegisterState.RECEIVED || registerState == RegisterState.NOT_RECEIVED)) {
throw new IllegalStateException();
}

return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@ private void initAddon(CallbackInfo ci) {
private void onClientReady(CallbackInfo ci) {
// Send the initial channel registration packet
if (this.addon.startConfiguration()) {
assert currentTask == null;
if (currentTask != null) {
throw new IllegalStateException("A task is already running: " + currentTask.getKey().id());
}

ci.cancel();
return;
}
Expand All @@ -113,8 +116,9 @@ private void onClientReady(CallbackInfo ci) {
}

// All early tasks should have been completed
assert currentTask == null;
assert tasks.isEmpty();
if (currentTask != null || !tasks.isEmpty()) {
throw new IllegalStateException("All early tasks should have been completed, current: " + currentTask + ", queued: " + tasks.size());
}

// Run the vanilla tasks.
this.addon.configuration();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ public void onInitialize() {
ranTests = true;

TestState.getOrCreate(world).setValue("Hello!");
assert Objects.equals(TestState.getOrCreate(world).getValue(), "Hello!");

if (!Objects.equals(TestState.getOrCreate(world).getValue(), "Hello!")) {
throw new IllegalStateException();
}
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,11 @@ public void remap(Object2IntMap<Identifier> remoteIndexedEntries, RemapMode mode

// Add the new object
rawIdToEntry.size(Math.max(this.rawIdToEntry.size(), id + 1));
assert rawIdToEntry.get(id) == null;

if (rawIdToEntry.get(id) != null) {
throw new IllegalStateException("Raw ID already populated");
}

rawIdToEntry.set(id, object);
entryToRawId.put(object.value(), id);
}
Expand All @@ -359,7 +363,10 @@ public void unmap() throws RemapException {
// Emit AddObject events for previously culled objects.
for (Identifier id : fabric_prevEntries.keySet()) {
if (!idToEntry.containsKey(id)) {
assert fabric_prevIndexedEntries.containsKey(id);
if (!fabric_prevIndexedEntries.containsKey(id)) {
throw new IllegalStateException("id missing from previous indexed entries");
}

addedIds.add(id);
}
}
Expand Down