Skip to content

Nekos.life source by idk and 1.20.4 #20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
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
53 changes: 18 additions & 35 deletions .github/workflows/dev_build.yml
Original file line number Diff line number Diff line change
@@ -1,42 +1,25 @@
# This workflow will build a Java project with Gradle
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle

name: Java CI with Gradle

concurrency:
group: "build-1.19"
cancel-in-progress: true

on:
push:
branches: [ master ]
paths-ignore:
- '*.md'

name: Publish Development Build
on: push

jobs:
build:

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: 17
distribution: 'zulu'
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew build
- name: Remove *-dev.jar
run: rm ./build/libs/*-dev.jar || true
- uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "latest-1.19"
prerelease: false
title: "1.19 Build"
- uses: actions/checkout@v2
- uses: actions/setup-java@v2
with:
java-version: 17
distribution: adopt
- name: Change wrapper permissions
run: chmod +x ./gradlew
- name: Build
run: ./gradlew build
- name: Release
uses: marvinpinto/action-automatic-releases@latest
with:
repo_token: '${{ secrets.GITHUB_TOKEN }}'
automatic_release_tag: latest
prerelease: true
title: Dev Build
files: |
./build/libs/*.jar

38 changes: 38 additions & 0 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle

name: Java CI with Gradle

on:
workflow_dispatch:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

permissions:
contents: read

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Change wrapper permissions
run: chmod +x ./gradlew

- name: Build with Gradle
uses: gradle/gradle-build-action@bd5760595778326ba7f1441bcf7e88b49de61a25 # v2.6.0
with:
arguments: build
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# E621 hud element
<div align="center">
<img src="src/main/resources/assets/e621/logo.png" alt="logo" width="200"/>
</div>

# E621 hud element with nekoslife, e926, danbooru and safebooru updated for 1.20.4
Why did I update this?
We all know how many people rely on this every day.
Thanks RewardedIvan for nekoslife source
<div align="center">
<a href="https://discord.gg/9mrRPGKYU3"><img src="https://invidget.switchblade.xyz/9mrRPGKYU3"></a>
</div>
Expand All @@ -10,7 +16,7 @@

<hr />

<a href="https://github.com/AntiCope/meteor-e621-integration/releases/tag/latest-1.18">
<a href="https://github.com/veronoicc/meteor-e621-integration/releases/tag/latest">
<img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcS2Csaj7qL5xw4PUQVUL8ig8adN8wUtHIyyPNO3jHq4ZPQrInpoNfK3-5bpCc6y4Qk0tw&usqp=CAU" />
<img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRhF3jjLg6ZcMHViwfPKRj_BfMFkDCP59YrcpzZBM5XbGuZ2Q7RyDJfoMoC5S_ckBRX1g&usqp=CAU" />
<img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcS_GlNQ2QzowFoex_SuVlqpKPyYsXwN1oldZg&usqp=CAU" />
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '0.12-SNAPSHOT'
id 'fabric-loom' version '1.5-SNAPSHOT'
}

sourceCompatibility = targetCompatibility = JavaVersion.VERSION_17
Expand Down
13 changes: 5 additions & 8 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
org.gradle.jvmargs=-Xmx2G

# Fabric (https://fabricmc.net/versions.html)
minecraft_version=1.19.2
yarn_mappings=1.19.2+build.4
loader_version=0.14.9
minecraft_version=1.20.4
yarn_mappings=1.20.4+build.2
loader_version=0.15.1

# Mod Properties
mod_version=0.1
mod_version=1.4.5
maven_group=anticope
archives_base_name=e621-addon

# Dependency Versions.

# Meteor (https://maven.meteordev.org/)
meteor_version=0.5.1-SNAPSHOT
meteor_version=0.5.6-SNAPSHOT
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
19 changes: 15 additions & 4 deletions src/main/java/anticope/esixtwoone/ImageHUD.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@
import anticope.esixtwoone.sources.Source.Size;
import anticope.esixtwoone.sources.Source.SourceType;

import static baritone.api.utils.Helper.mc;
import javax.imageio.ImageIO;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;

import static meteordevelopment.meteorclient.MeteorClient.mc;
import static meteordevelopment.meteorclient.utils.Utils.WHITE;

public class ImageHUD extends HudElement {
Expand Down Expand Up @@ -56,7 +61,11 @@ public class ImageHUD extends HudElement {
.defaultValue(100)
.min(10)
.sliderRange(70, 1000)
.onChanged(o -> updateSize())
.onChanged(o -> {
if (o != 0) {
updateSize();
}
})
.build()
);

Expand Down Expand Up @@ -154,8 +163,10 @@ private void loadImage() {
return;
}
E621Hud.LOG.info(url);
var img = NativeImage.read(Http.get(url).sendInputStream());
mc.getTextureManager().registerTexture(TEXID, new NativeImageBackedTexture(img));
var img = ImageIO.read(Http.get(url).sendInputStream());
var baos = new ByteArrayOutputStream();
ImageIO.write(img, "png", baos);
mc.getTextureManager().registerTexture(TEXID, new NativeImageBackedTexture(NativeImage.read(new ByteArrayInputStream(baos.toByteArray()))));
empty = false;
} catch (Exception ex) {
E621Hud.LOG.error("Failed to render the image.", ex);
Expand Down
39 changes: 39 additions & 0 deletions src/main/java/anticope/esixtwoone/sources/DanBooru.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package anticope.esixtwoone.sources;

import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;

import meteordevelopment.meteorclient.utils.network.Http;

public class DanBooru extends Source {

private final String domain;
private final int lastPage;

public DanBooru(String domain, int lastPage) {
this.domain = domain;
this.lastPage = lastPage;
}

@Override
public void reset() {}

@Override
public String randomImage(String filter, Size size) {
String query = String.format("%s/posts.json?tags=%s&page=%d&format=json&limit=10", domain, filter, random.nextInt(0, lastPage));
JsonElement result = Http.get(query).sendJson(JsonElement.class);
if (result == null) return null;

if (result instanceof JsonArray array) {
if (array.get(random.nextInt(0, Math.min(11, array.size()))) instanceof JsonObject post) {
return switch (size) {
case preview -> post.get("preview_file_url").getAsString();
case sample -> post.get("large_file_url").getAsString();
case file -> post.get("file_url").getAsString();
};
}
}
return null;
}
}
11 changes: 8 additions & 3 deletions src/main/java/anticope/esixtwoone/sources/ESixTwoOne.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@

public class ESixTwoOne extends Source {

private final String domain;

public ESixTwoOne(String domain) {
this.domain = domain;
}

private int maxPage = 30;

@Override
Expand All @@ -17,15 +23,14 @@ public void reset() {
@Override
public String randomImage(String filter, Size size) {
int pageNum = random.nextInt(1, maxPage);
JsonObject result = Http.get("https://e621.net/posts.json?limit=320&tags="+filter+"&page="+ pageNum).sendJson(JsonObject.class);
JsonObject result = Http.get(domain + "/posts.json?limit=320&tags="+filter+"&page="+ pageNum).sendJson(JsonObject.class);
if (result.get("posts") instanceof JsonArray array) {
if(array.size() <= 0) {
maxPage = pageNum - 1;
return null;
}
if (array.get(random.nextInt(array.size())) instanceof JsonObject post) {
var url = post.get(size.toString()).getAsJsonObject().get("url").getAsString();
return url;
return post.get(size.toString()).getAsJsonObject().get("url").getAsString();
}
}
return null;
Expand Down
33 changes: 33 additions & 0 deletions src/main/java/anticope/esixtwoone/sources/NekosLife.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package anticope.esixtwoone.sources;

import com.google.gson.JsonElement;
import com.google.gson.JsonObject;

import meteordevelopment.meteorclient.utils.network.Http;

public class NekosLife extends Source {

private final String domain;

public NekosLife(String domain) {
this.domain = domain;
}

@Override
public void reset() {}

@Override
public String randomImage(String filter, Size size) {
String query = String.format("%s/api/v2/img/%s", domain, filter);
JsonElement result = Http.get(query).sendJson(JsonElement.class);
if (result == null) return null;

if (result instanceof JsonObject object) {
if (object.get("url") != null) {
return object.get("url").getAsString();
}
}

return null;
}
}
18 changes: 13 additions & 5 deletions src/main/java/anticope/esixtwoone/sources/Source.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,13 @@ public enum Size {

public enum SourceType {
e621,
e926,

gelbooru,
rule34
danbooru,
safebooru,
rule34,
nekoslife
}

protected final Random random = new Random();
Expand All @@ -36,10 +41,13 @@ public String getRandomImage(String filter, Size size) {

public static Source getSource(SourceType type) {
return switch (type) {
case e621 -> new ESixTwoOne();
case gelbooru -> new GelBooru("https://gelbooru.com/", 700);
case rule34 -> new GelBooru("https://api.rule34.xxx/", 700);
default -> null;
case e621 -> new ESixTwoOne("https://e621.net");
case e926 -> new ESixTwoOne("https://e926.net");
case gelbooru -> new GelBooru("https://gelbooru.com", 700);
case danbooru -> new DanBooru("https://danbooru.donmai.us", 700);
case safebooru -> new GelBooru("https://safebooru.org", 700);
case rule34 -> new GelBooru("https://api.rule34.xxx", 700);
case nekoslife -> new NekosLife("https://nekos.life");
};
}
}
Binary file modified src/main/resources/assets/e621/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/resources/assets/e621/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 6 additions & 3 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@
"id": "e621-hud",
"version": "${version}",
"name": "E621 hud",
"description": "An addon template for the Meteor addons.",
"description": "E621 hud element for meteor client.",
"authors": [
"AntiCope"
"AntiCope",
"veronoicc"
],
"contact": {
"repo": "https://github.com/MeteorDevelopment/meteor-addon-template"
"homepage": "https://github.com/veronoicc/meteor-e621-integration",
"issues": "https://github.com/veronoicc/meteor-e621-integration/issues",
"repo": "https://github.com/veronoicc/meteor-e621-integration"
},
"icon": "assets/e621/icon.png",
"environment": "client",
Expand Down