Remove now unneeded exceptions

This commit is contained in:
Blue (Lukas Rieger) 2020-07-29 20:11:25 +02:00
parent a33dda0a29
commit ca4fec8c1a
8 changed files with 18 additions and 49 deletions

View File

@ -24,8 +24,6 @@
*/ */
package de.bluecolored.bluemap.common; package de.bluecolored.bluemap.common;
import java.io.IOException;
import com.flowpowered.math.vector.Vector2i; import com.flowpowered.math.vector.Vector2i;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
@ -68,7 +66,7 @@ public TileRenderer getTileRenderer() {
return tileRenderer; return tileRenderer;
} }
public void renderTile(Vector2i tile) throws IOException { public void renderTile(Vector2i tile) {
getTileRenderer().render(new WorldTile(getWorld(), tile)); getTileRenderer().render(new WorldTile(getWorld(), tile));
} }

View File

@ -161,11 +161,7 @@ private void renderThread() {
} }
if (ticket != null) { if (ticket != null) {
try { ticket.render();
ticket.render();
} catch (IOException e) {
Logger.global.logDebug("Failed to render tile " + ticket.getTile() + " of map '" + ticket.getMapType().getId() + "' after " + ticket.getRenderAttempts() + " render-attempts! (" + e.toString() + ")");
}
} else { } else {
try { try {
Thread.sleep(1000); // we don't need a super fast response time, so waiting a second is totally fine Thread.sleep(1000); // we don't need a super fast response time, so waiting a second is totally fine

View File

@ -24,7 +24,6 @@
*/ */
package de.bluecolored.bluemap.common; package de.bluecolored.bluemap.common;
import java.io.IOException;
import java.util.Objects; import java.util.Objects;
import com.flowpowered.math.vector.Vector2i; import com.flowpowered.math.vector.Vector2i;
@ -34,25 +33,13 @@ public class RenderTicket {
private final MapType map; private final MapType map;
private final Vector2i tile; private final Vector2i tile;
private int renderAttempts;
private boolean successfullyRendered;
public RenderTicket(MapType map, Vector2i tile) { public RenderTicket(MapType map, Vector2i tile) {
this.map = map; this.map = map;
this.tile = tile; this.tile = tile;
this.renderAttempts = 0;
this.successfullyRendered = false;
} }
public synchronized void render() throws IOException { public synchronized void render() {
renderAttempts++; map.renderTile(tile);
if (!successfullyRendered) {
map.renderTile(tile);
successfullyRendered = true;
}
} }
public MapType getMapType() { public MapType getMapType() {
@ -63,10 +50,6 @@ public Vector2i getTile() {
return tile; return tile;
} }
public int getRenderAttempts() {
return renderAttempts;
}
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(map.getId(), tile); return Objects.hash(map.getId(), tile);

View File

@ -350,14 +350,10 @@ public int debugCommand(CommandContext<S> context) throws CommandSyntaxException
String blockBelowIdMeta = ""; String blockBelowIdMeta = "";
if (world instanceof MCAWorld) { if (world instanceof MCAWorld) {
try { Chunk chunk = ((MCAWorld) world).getChunk(MCAWorld.blockToChunk(blockPos));
Chunk chunk = ((MCAWorld) world).getChunk(MCAWorld.blockToChunk(blockPos)); if (chunk instanceof ChunkAnvil112) {
if (chunk instanceof ChunkAnvil112) { blockIdMeta = " (" + ((ChunkAnvil112) chunk).getBlockIdMeta(blockPos) + ")";
blockIdMeta = " (" + ((ChunkAnvil112) chunk).getBlockIdMeta(blockPos) + ")"; blockBelowIdMeta = " (" + ((ChunkAnvil112) chunk).getBlockIdMeta(blockPos.add(0, -1, 0)) + ")";
blockBelowIdMeta = " (" + ((ChunkAnvil112) chunk).getBlockIdMeta(blockPos.add(0, -1, 0)) + ")";
}
} catch (IOException ex) {
Logger.global.logError("Failed to read chunk for debug!", ex);
} }
} }

View File

@ -268,7 +268,7 @@ private Chunk loadChunk(Vector2i chunkPos) throws IOException {
} }
@Override @Override
public boolean isChunkGenerated(Vector2i chunkPos) throws IOException { public boolean isChunkGenerated(Vector2i chunkPos) {
Chunk chunk = getChunk(chunkPos); Chunk chunk = getChunk(chunkPos);
return chunk.isGenerated(); return chunk.isGenerated();
} }

View File

@ -24,8 +24,6 @@
*/ */
package de.bluecolored.bluemap.core.render; package de.bluecolored.bluemap.core.render;
import java.io.IOException;
import de.bluecolored.bluemap.core.render.hires.HiresModel; import de.bluecolored.bluemap.core.render.hires.HiresModel;
import de.bluecolored.bluemap.core.render.hires.HiresModelManager; import de.bluecolored.bluemap.core.render.hires.HiresModelManager;
import de.bluecolored.bluemap.core.render.lowres.LowresModelManager; import de.bluecolored.bluemap.core.render.lowres.LowresModelManager;
@ -42,9 +40,8 @@ public TileRenderer(HiresModelManager hiresModelManager, LowresModelManager lowr
/** /**
* Renders the provided WorldTile (only) if the world is generated * Renders the provided WorldTile (only) if the world is generated
* @throws IOException If an IO-Exception occurs during the render
*/ */
public void render(WorldTile tile) throws IOException { public void render(WorldTile tile) {
//check if the region is generated before rendering, don't render if it's not generated //check if the region is generated before rendering, don't render if it's not generated
AABB area = hiresModelManager.getTileRegion(tile); AABB area = hiresModelManager.getTileRegion(tile);
if (!tile.getWorld().isAreaGenerated(area)) return; if (!tile.getWorld().isAreaGenerated(area)) return;

View File

@ -24,7 +24,6 @@
*/ */
package de.bluecolored.bluemap.core.world; package de.bluecolored.bluemap.core.world;
import java.io.IOException;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.Collection; import java.util.Collection;
import java.util.UUID; import java.util.UUID;
@ -114,24 +113,24 @@ public Collection<Vector2i> getChunkList(long modifiedSince, Predicate<Vector2i>
} }
@Override @Override
public boolean isChunkGenerated(Vector2i chunkPos) throws IOException { public boolean isChunkGenerated(Vector2i chunkPos) {
if (!isInside(chunkPos)) return false; if (!isInside(chunkPos)) return false;
return world.isChunkGenerated(chunkPos); return world.isChunkGenerated(chunkPos);
} }
@Override @Override
public boolean isAreaGenerated(AABB area) throws IOException { public boolean isAreaGenerated(AABB area) {
return isAreaGenerated(area.getMin(), area.getMax()); return isAreaGenerated(area.getMin(), area.getMax());
} }
@Override @Override
public boolean isAreaGenerated(Vector3i blockMin, Vector3i blockMax) throws IOException { public boolean isAreaGenerated(Vector3i blockMin, Vector3i blockMax) {
return isAreaGenerated(blockPosToChunkPos(blockMin), blockPosToChunkPos(blockMax)); return isAreaGenerated(blockPosToChunkPos(blockMin), blockPosToChunkPos(blockMax));
} }
@Override @Override
public boolean isAreaGenerated(Vector2i chunkMin, Vector2i chunkMax) throws IOException { public boolean isAreaGenerated(Vector2i chunkMin, Vector2i chunkMax) {
if (!isInside(chunkMin) && if (!isInside(chunkMin) &&
!isInside(chunkMax) && !isInside(chunkMax) &&
!isInside(new Vector2i(chunkMin.getX(), chunkMax.getY())) && !isInside(new Vector2i(chunkMin.getX(), chunkMax.getY())) &&

View File

@ -110,7 +110,7 @@ public default Collection<Vector2i> getChunkList(long modifiedSince){
/** /**
* Returns true if and only if that chunk is fully generated and no world-generation or lighting has yet to be done. * Returns true if and only if that chunk is fully generated and no world-generation or lighting has yet to be done.
*/ */
public boolean isChunkGenerated(Vector2i chunkPos) throws IOException; public boolean isChunkGenerated(Vector2i chunkPos);
/** /**
@ -118,7 +118,7 @@ public default Collection<Vector2i> getChunkList(long modifiedSince){
* @param area The area to check * @param area The area to check
* @throws IOException * @throws IOException
*/ */
public default boolean isAreaGenerated(AABB area) throws IOException { public default boolean isAreaGenerated(AABB area) {
return isAreaGenerated(area.getMin(), area.getMax()); return isAreaGenerated(area.getMin(), area.getMax());
} }
@ -127,7 +127,7 @@ public default boolean isAreaGenerated(AABB area) throws IOException {
* @param area The area to check * @param area The area to check
* @throws IOException * @throws IOException
*/ */
public default boolean isAreaGenerated(Vector3i blockMin, Vector3i blockMax) throws IOException { public default boolean isAreaGenerated(Vector3i blockMin, Vector3i blockMax) {
return isAreaGenerated(blockPosToChunkPos(blockMin), blockPosToChunkPos(blockMax)); return isAreaGenerated(blockPosToChunkPos(blockMin), blockPosToChunkPos(blockMax));
} }
@ -136,7 +136,7 @@ public default boolean isAreaGenerated(Vector3i blockMin, Vector3i blockMax) thr
* @param area The area to check * @param area The area to check
* @throws IOException * @throws IOException
*/ */
public default boolean isAreaGenerated(Vector2i chunkMin, Vector2i chunkMax) throws IOException { public default boolean isAreaGenerated(Vector2i chunkMin, Vector2i chunkMax) {
for (int x = chunkMin.getX(); x <= chunkMax.getX(); x++) { for (int x = chunkMin.getX(); x <= chunkMax.getX(); x++) {
for (int z = chunkMin.getY(); z <= chunkMax.getY(); z++) { for (int z = chunkMin.getY(); z <= chunkMax.getY(); z++) {
if (!isChunkGenerated(new Vector2i(x, z))) return false; if (!isChunkGenerated(new Vector2i(x, z))) return false;