Skip to content

Commit

Permalink
Fixed cache keys
Browse files Browse the repository at this point in the history
  • Loading branch information
LatvianModder committed Aug 21, 2024
1 parent b561e36 commit 5f14877
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.biome.Biomes;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.level.block.state.properties.IntegerProperty;
Expand Down Expand Up @@ -194,9 +193,11 @@ private static HTTPResponse renderCanvas(KJSHTTPRequest req, int canvasSize, Str
Files.write(cachePath, bytes);
} catch (Exception ignore) {
}

return HTTPResponse.ok().content(bytes, "image/png").header("X-KubeJS-Cache-Key", cacheUUIDStr);
}

return HTTPResponse.ok().content(bytes, "image/png").header("X-KubeJS-Cache-Key", cacheUUIDStr);
return HTTPResponse.ok().content(bytes, "image/png");
}

private static HTTPResponse renderAnimated(KJSHTTPRequest req, String dir, @Nullable ByteBuf cacheBuf, List<HTTPResponse> responses) throws Exception {
Expand Down Expand Up @@ -252,6 +253,8 @@ private static HTTPResponse renderAnimated(KJSHTTPRequest req, String dir, @Null
Files.write(cachePath, bytes);
} catch (Exception ignore) {
}

return HTTPResponse.ok().content(bytes, "image/gif").header("X-KubeJS-Cache-Key", cacheUUIDStr);
}

return HTTPResponse.ok().content(bytes, "image/gif");
Expand Down Expand Up @@ -455,13 +458,4 @@ public void setBody(ResponseContent body) {
}
}
}

public static HTTPResponse testGIF(KJSHTTPRequest req) throws Exception {
return renderAnimated(req, "test", null, List.of(
renderItem(req, Items.RED_STAINED_GLASS.getDefaultInstance(), true),
renderItem(req, Items.CARROT.getDefaultInstance(), true),
renderBlock(req, Blocks.NETHER_PORTAL.defaultBlockState(), true),
renderFluid(req, new FluidStack(Fluids.WATER, FluidType.BUCKET_VOLUME), true)
));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ public static void register(LocalWebServerRegistry registry) {
registry.get("/img/{size}/item-tag/{namespace}/{path}", ImageGenerator::itemTag);
registry.get("/img/{size}/block-tag/{namespace}/{path}", ImageGenerator::blockTag);
registry.get("/img/{size}/fluid-tag/{namespace}/{path}", ImageGenerator::fluidTag);
registry.get("/img/{size}/test-gif", ImageGenerator::testGIF);
}

private static HTTPResponse getScreenshot(KJSHTTPRequest req) {
Expand Down

0 comments on commit 5f14877

Please sign in to comment.