mirror of
https://github.com/GTNewHorizons/NotEnoughItems.git
synced 2026-11-18 11:29:35 +00:00
Compare commits
9
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2fa641c2aa | ||
|
|
255dac4db0 | ||
|
|
9bbdd7b174 | ||
|
|
af0f71e7ca | ||
|
|
de4e2c1632 | ||
|
|
f1518102bc | ||
|
|
29fe442671 | ||
|
|
c75420b31d | ||
|
|
98b6e552c4 |
No files matched your search
@@ -43,9 +43,3 @@ jobs:
|
||||
prerelease: false
|
||||
title: "${{ env.RELEASE_VERSION }}"
|
||||
files: build/libs/*.jar
|
||||
|
||||
- name: Publish to Maven
|
||||
run: ./gradlew publish
|
||||
env:
|
||||
MAVEN_USER: ${{ secrets.MAVEN_USER }}
|
||||
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
|
||||
@@ -1,3 +0,0 @@
|
||||
# Any Github changes require admin approval
|
||||
/.github/** @GTNewHorizons/admin
|
||||
|
||||
+24
-89
@@ -1,9 +1,9 @@
|
||||
//version: 1642872913
|
||||
//version: 8fa7883b6196c1765266f4e6ddf3118d5043aafb
|
||||
/*
|
||||
DO NOT CHANGE THIS FILE!
|
||||
|
||||
Also, you may replace this file at any time if there is an update available.
|
||||
Please check https://github.com/GTNewHorizons/ExampleMod1.7.10/blob/main/build.gradle for updates.
|
||||
Please check https://github.com/SinTh0r4s/ExampleMod1.7.10/blob/main/build.gradle for updates.
|
||||
*/
|
||||
|
||||
|
||||
@@ -32,18 +32,16 @@ buildscript {
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.github.GTNewHorizons:ForgeGradle:1.2.5'
|
||||
classpath 'com.github.GTNewHorizons:ForgeGradle:1.2.4'
|
||||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
id 'idea'
|
||||
id 'eclipse'
|
||||
id 'scala'
|
||||
id("org.ajoberstar.grgit") version("3.1.1")
|
||||
id("com.github.johnrengelman.shadow") version("4.0.4")
|
||||
id("com.palantir.git-version") version("0.12.3")
|
||||
id('de.undercouch.download') version('4.1.2')
|
||||
id("maven-publish")
|
||||
}
|
||||
|
||||
@@ -90,7 +88,6 @@ checkPropertyExists("containsMixinsAndOrCoreModOnly")
|
||||
checkPropertyExists("usesShadowedDependencies")
|
||||
checkPropertyExists("developmentEnvironmentUserName")
|
||||
|
||||
boolean noPublishedSources = project.findProperty("noPublishedSources") ? project.noPublishedSources.toBoolean() : false
|
||||
|
||||
String javaSourceDir = "src/main/java/"
|
||||
String scalaSourceDir = "src/main/scala/"
|
||||
@@ -154,16 +151,12 @@ configurations.all {
|
||||
|
||||
// Fix Jenkins' Git: chmod a file should not be detected as a change and append a '.dirty' to the version
|
||||
'git config core.fileMode false'.execute()
|
||||
|
||||
// Pulls version first from the VERSION env and then git tag
|
||||
String identifiedVersion
|
||||
// Pulls version from git tag
|
||||
try {
|
||||
String versionOverride = System.getenv("VERSION") ?: null
|
||||
identifiedVersion = versionOverride == null ? gitVersion() : versionOverride
|
||||
version = minecraftVersion + "-" + identifiedVersion
|
||||
version = minecraftVersion + "-" + gitVersion()
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new IllegalStateException("This mod must be version controlled by Git AND the repository must provide at least one tag, or the VERSION override must be set!");
|
||||
throw new IllegalStateException("This mod must be version controlled by Git AND the repository must provide at least one tag!");
|
||||
}
|
||||
|
||||
group = modGroup
|
||||
@@ -230,7 +223,7 @@ dependencies {
|
||||
annotationProcessor("com.google.code.gson:gson:2.8.6")
|
||||
annotationProcessor("org.spongepowered:mixin:0.8-SNAPSHOT")
|
||||
// using 0.8 to workaround a issue in 0.7 which fails mixin application
|
||||
compile("com.github.GTNewHorizons:SpongePoweredMixin:0.7.12-GTNH") {
|
||||
compile("org.spongepowered:mixin:0.7.11-SNAPSHOT") {
|
||||
// Mixin includes a lot of dependencies that are too up-to-date
|
||||
exclude module: "launchwrapper"
|
||||
exclude module: "guava"
|
||||
@@ -238,7 +231,7 @@ dependencies {
|
||||
exclude module: "commons-io"
|
||||
exclude module: "log4j-core"
|
||||
}
|
||||
compile("com.github.GTNewHorizons:SpongeMixins:1.5.0")
|
||||
compile("com.github.GTNewHorizons:SpongeMixins:1.3.3:dev")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -487,63 +480,40 @@ task apiJar(type: Jar) {
|
||||
}
|
||||
|
||||
artifacts {
|
||||
if(!noPublishedSources) {
|
||||
archives sourcesJar
|
||||
}
|
||||
archives sourcesJar
|
||||
archives devJar
|
||||
if(apiPackage) {
|
||||
archives apiJar
|
||||
}
|
||||
}
|
||||
|
||||
// The gradle metadata includes all of the additional deps that we disabled from POM generation (including forgeBin with no groupID),
|
||||
// and isn't strictly needed with the POM so just disable it.
|
||||
tasks.withType(GenerateModuleMetadata) {
|
||||
enabled = false
|
||||
}
|
||||
|
||||
|
||||
// publishing
|
||||
publishing {
|
||||
publications {
|
||||
maven(MavenPublication) {
|
||||
from components.java
|
||||
if(usesShadowedDependencies.toBoolean()) {
|
||||
artifact source: shadowJar, classifier: ""
|
||||
}
|
||||
if(!noPublishedSources) {
|
||||
artifact source: sourcesJar, classifier: "src"
|
||||
}
|
||||
artifact source: usesShadowedDependencies.toBoolean() ? shadowDevJar : devJar, classifier: "dev"
|
||||
artifact source: jar
|
||||
artifact source: sourcesJar, classifier: "src"
|
||||
artifact source: devJar, classifier: "dev"
|
||||
if (apiPackage) {
|
||||
artifact source: apiJar, classifier: "api"
|
||||
}
|
||||
|
||||
groupId = System.getenv("ARTIFACT_GROUP_ID") ?: "com.github.GTNewHorizons"
|
||||
groupId = System.getenv("ARTIFACT_GROUP_ID") ?: group
|
||||
artifactId = System.getenv("ARTIFACT_ID") ?: project.name
|
||||
// Using the identified version, not project.version as it has the prepended 1.7.10
|
||||
version = System.getenv("RELEASE_VERSION") ?: identifiedVersion
|
||||
|
||||
// Remove all non GTNH deps here.
|
||||
// Original intention was to remove an invalid forgeBin being generated without a groupId (mandatory), but
|
||||
// it also removes all of the MC deps
|
||||
pom.withXml {
|
||||
Node pomNode = asNode()
|
||||
pomNode.dependencies.'*'.findAll() {
|
||||
it.groupId.text() != 'com.github.GTNewHorizons'
|
||||
}.each() {
|
||||
it.parent().remove(it)
|
||||
}
|
||||
}
|
||||
version = System.getenv("ARTIFACT_VERSION") ?: project.version
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
url = "http://jenkins.usrv.eu:8081/nexus/content/repositories/releases"
|
||||
String owner = System.getenv("REPOSITORY_OWNER") ?: "Unknown"
|
||||
String repositoryName = System.getenv("REPOSITORY_NAME") ?: "Unknown"
|
||||
String githubRepositoryUrl = "https://maven.pkg.github.com/$owner/$repositoryName"
|
||||
name = "GitHubPackages"
|
||||
url = githubRepositoryUrl
|
||||
credentials {
|
||||
username = System.getenv("MAVEN_USER") ?: "NONE"
|
||||
password = System.getenv("MAVEN_PASSWORD") ?: "NONE"
|
||||
username = System.getenv("GITHUB_ACTOR") ?: "NONE"
|
||||
password = System.getenv("GITHUB_TOKEN") ?: "NONE"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -567,7 +537,7 @@ if (isNewBuildScriptVersionAvailable(projectDir.toString())) {
|
||||
}
|
||||
|
||||
static URL availableBuildScriptUrl() {
|
||||
new URL("https://raw.githubusercontent.com/GTNewHorizons/ExampleMod1.7.10/main/build.gradle")
|
||||
new URL("https://raw.githubusercontent.com/SinTh0r4s/ExampleMod1.7.10/main/build.gradle")
|
||||
}
|
||||
|
||||
boolean performBuildScriptUpdate(String projectDir) {
|
||||
@@ -605,46 +575,11 @@ configure(updateBuildScript) {
|
||||
description = 'Updates the build script to the latest version'
|
||||
}
|
||||
|
||||
// Deobfuscation
|
||||
|
||||
def deobf(String sourceURL, String fileName) {
|
||||
def bon2File = "$projectDir/deobf/BON2-2.5.0.jar"
|
||||
def cacheFile = "$projectDir/deobf/out/" + fileName + ".jar"
|
||||
def deobfFile = "$projectDir/deobf/out/" + fileName + "-deobf.jar"
|
||||
|
||||
if(file(deobfFile).exists()) {
|
||||
return files(deobfFile)
|
||||
}
|
||||
|
||||
download {
|
||||
src 'https://github.com/GTNewHorizons/BON2/releases/download/2.5.0/BON2-2.5.0.CUSTOM-all.jar'
|
||||
dest bon2File
|
||||
quiet true
|
||||
overwrite false
|
||||
}
|
||||
|
||||
download {
|
||||
src sourceURL
|
||||
dest cacheFile
|
||||
quiet true
|
||||
overwrite false
|
||||
}
|
||||
|
||||
exec {
|
||||
commandLine 'java', '-jar', bon2File, '--inputJar', cacheFile, '--outputJar', deobfFile, '--mcVer', '1.7.10', '--mappingsVer', 'stable_12', '--notch'
|
||||
workingDir "$projectDir/deobf"
|
||||
standardOutput = new ByteArrayOutputStream()
|
||||
}
|
||||
|
||||
delete(cacheFile)
|
||||
return files(deobfFile)
|
||||
}
|
||||
|
||||
// Helper methods
|
||||
|
||||
def checkPropertyExists(String propertyName) {
|
||||
if (project.hasProperty(propertyName) == false) {
|
||||
throw new GradleException("This project requires a property \"" + propertyName + "\"! Please add it your \"gradle.properties\". You can find all properties and their description here: https://github.com/GTNewHorizons/ExampleMod1.7.10/blob/main/gradle.properties")
|
||||
throw new GradleException("This project requires a property \"" + propertyName + "\"! Please add it your \"gradle.properties\". You can find all properties and their description here: https://github.com/SinTh0r4s/ExampleMod1.7.10/blob/main/gradle.properties")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
// Add your dependencies here
|
||||
|
||||
dependencies {
|
||||
compile("com.github.GTNewHorizons:CodeChickenLib:1.1.5.1:dev")
|
||||
compile("com.github.GTNewHorizons:CodeChickenCore:1.1.3:dev")
|
||||
compile("com.github.GTNewHorizons:CodeChickenLib:master-SNAPSHOT:dev")
|
||||
compile("com.github.GTNewHorizons:CodeChickenCore:master-SNAPSHOT:dev")
|
||||
shadowImplementation("org.apache.commons:commons-csv:1.5")
|
||||
}
|
||||
@@ -2,10 +2,6 @@
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven {
|
||||
name = "GTNH Maven"
|
||||
url = "http://jenkins.usrv.eu:8081/nexus/content/groups/public/"
|
||||
}
|
||||
maven {
|
||||
url = "https://jitpack.io"
|
||||
}
|
||||
|
||||
@@ -185,13 +185,13 @@ public class ItemList
|
||||
@SuppressWarnings("unchecked")
|
||||
public void execute() {
|
||||
// System.out.println("Executing NEI Item Loading");
|
||||
ThreadOperationTimer timer = getTimer(NEIClientConfig.getItemLoadingTimeout());
|
||||
ThreadOperationTimer timer = getTimer(500);
|
||||
|
||||
LinkedList<ItemStack> items = new LinkedList<>();
|
||||
LinkedList<ItemStack> permutations = new LinkedList<>();
|
||||
ListMultimap<Item, ItemStack> itemMap = ArrayListMultimap.create();
|
||||
|
||||
timer.setLimit(NEIClientConfig.getItemLoadingTimeout());
|
||||
timer.setLimit(500);
|
||||
for (Item item : (Iterable<Item>) Item.itemRegistry) {
|
||||
if (interrupted()) return;
|
||||
|
||||
|
||||
@@ -168,8 +168,6 @@ public class NEIClientConfig {
|
||||
return isMouseScrollTransferEnabled();
|
||||
}
|
||||
});
|
||||
|
||||
tag.getTag("itemLoadingTimeout").getIntValue(500);
|
||||
|
||||
tag.getTag("command.creative").setDefaultValue("/gamemode {0} {1}");
|
||||
API.addOption(new OptionTextField("command.creative"));
|
||||
@@ -453,10 +451,6 @@ public class NEIClientConfig {
|
||||
int i = getIntSetting("inventory.itemIDs");
|
||||
return i == 2 || (i == 1 && isEnabled() && !isHidden());
|
||||
}
|
||||
|
||||
public static int getItemLoadingTimeout() {
|
||||
return getIntSetting("itemLoadingTimeout");
|
||||
}
|
||||
|
||||
public static void toggleBooleanSetting(String setting) {
|
||||
ConfigTag tag = getSetting(setting);
|
||||
|
||||
@@ -300,7 +300,7 @@ public class API
|
||||
* @param stack the ingredient that can craft recipes (like a furnace or crafting table)
|
||||
* @param handler the recipe category handled by the ingredient
|
||||
*/
|
||||
public static void addRecipeCatalyst(ItemStack stack, IRecipeHandler handler) {
|
||||
public static void addRecipeCatalyst(ItemStack stack, Class<? extends IRecipeHandler> handler) {
|
||||
addRecipeCatalyst(Collections.singletonList(stack), handler);
|
||||
}
|
||||
|
||||
@@ -310,42 +310,8 @@ public class API
|
||||
* @param stacks the ingredients that can craft recipes (like a furnace or crafting table)
|
||||
* @param handler the recipe category handled by the ingredient
|
||||
*/
|
||||
public static void addRecipeCatalyst(List<ItemStack> stacks, IRecipeHandler handler) {
|
||||
String handlerID = handler.getOverlayIdentifier();
|
||||
if (handlerID != null) {
|
||||
addRecipeCatalyst(stacks, handler.getOverlayIdentifier());
|
||||
}
|
||||
else {
|
||||
NEIClientConfig.logger.warn(String.format("failed to add recipe catalyst, implement IRecipeHandler#getOverlayIdentifier for your handler %s", handler.getClass().getName()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an association between an ingredient and what it can craft. (i.e. Furnace ItemStack -> Smelting and Fuel Recipes)
|
||||
* Allows players to see what ingredient they need to craft in order to make recipes from a recipe category.
|
||||
* @param stack the ingredient that can craft recipes (like a furnace or crafting table)
|
||||
* @param handlerID recipe category identifier (see {@link IRecipeHandler#getOverlayIdentifier()})
|
||||
*/
|
||||
public static void addRecipeCatalyst(ItemStack stack, String handlerID) {
|
||||
addRecipeCatalyst(Collections.singletonList(stack), handlerID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an association between an ingredient and what it can craft. (i.e. Furnace ItemStack -> Smelting and Fuel Recipes)
|
||||
* Allows players to see what ingredient they need to craft in order to make recipes from a recipe category.
|
||||
* @param stacks the ingredients that can craft recipes (like a furnace or crafting table)
|
||||
* @param handlerID recipe category identifier (see {@link IRecipeHandler#getOverlayIdentifier()})
|
||||
*/
|
||||
public static void addRecipeCatalyst(List<ItemStack> stacks, String handlerID) {
|
||||
RecipeCatalysts.addRecipeCatalyst(stacks, handlerID);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void addRecipeCatalyst(ItemStack stack, Class<? extends IRecipeHandler> handler) {
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void addRecipeCatalyst(List<ItemStack> stacks, Class<? extends IRecipeHandler> handler) {
|
||||
RecipeCatalysts.addRecipeCatalyst(stacks, handler);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
package codechicken.nei.asm;
|
||||
|
||||
import codechicken.lib.asm.ASMHelper;
|
||||
import org.objectweb.asm.ClassVisitor;
|
||||
import org.objectweb.asm.MethodVisitor;
|
||||
|
||||
import static org.objectweb.asm.Opcodes.POP;
|
||||
import static org.objectweb.asm.Opcodes.PUTSTATIC;
|
||||
|
||||
public class GuiContainerManagerAPITransformer extends ClassVisitor {
|
||||
private final String tname;
|
||||
private boolean changed = false;
|
||||
|
||||
public GuiContainerManagerAPITransformer(int api, ClassVisitor cv, String tname) {
|
||||
super(api, cv);
|
||||
this.tname = tname;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MethodVisitor visitMethod(int access, String mname, String mdesc, String signature, String[] exceptions) {
|
||||
return new MethodVisitor(api, super.visitMethod(access, mname, mdesc, signature, exceptions)) {
|
||||
@Override
|
||||
public void visitFieldInsn(int opcode, String owner, String name, String desc) {
|
||||
if (opcode == PUTSTATIC && "codechicken/nei/guihook/GuiContainerManager".equals(owner) && name.endsWith("Handlers") && desc.equals("Ljava/util/LinkedList;")) {
|
||||
ASMHelper.logger.warn("Found suspicious PUTSTATIC {} in {}#{}{}, replacing with POP!", name, tname, mname, mdesc);
|
||||
changed = true;
|
||||
super.visitInsn(POP);
|
||||
} else {
|
||||
super.visitFieldInsn(opcode, owner, name, desc);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public boolean isChanged() {
|
||||
return changed;
|
||||
}
|
||||
}
|
||||
@@ -41,7 +41,6 @@ public class NEITransformer implements IClassTransformer
|
||||
ASMInit.init();
|
||||
}
|
||||
|
||||
private final boolean paranoidMode = Boolean.getBoolean("nei.paranoid");
|
||||
private final ModularASMTransformer transformer = new ModularASMTransformer();
|
||||
private final Map<String, ASMBlock> asmblocks = ASMReader.loadResource("/assets/nei/asm/blocks.asm");
|
||||
|
||||
@@ -265,14 +264,6 @@ public class NEITransformer implements IClassTransformer
|
||||
}
|
||||
bytes = transformSubclasses(name, bytes);
|
||||
}
|
||||
if (paranoidMode && !tname.startsWith("codechicken.nei")) {
|
||||
ClassReader cr = new ClassReader(bytes);
|
||||
ClassWriter cw = new ClassWriter(0);
|
||||
GuiContainerManagerAPITransformer cv = new GuiContainerManagerAPITransformer(ASM5, cw, tname);
|
||||
cr.accept(cv, ClassReader.SKIP_DEBUG);
|
||||
if (cv.isChanged())
|
||||
bytes = cw.toByteArray();
|
||||
}
|
||||
|
||||
bytes = transformer.transform(name, bytes);
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -23,7 +23,6 @@ import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static codechicken.lib.gui.GuiDraw.drawMultilineTip;
|
||||
@@ -36,11 +35,11 @@ public class GuiContainerManager
|
||||
public GuiContainer window;
|
||||
|
||||
public static RenderItem drawItems = new RenderItem();
|
||||
public static final LinkedList<IContainerTooltipHandler> tooltipHandlers = new HideousLinkedList<>(new CopyOnWriteArrayList<>());
|
||||
public static final LinkedList<IContainerInputHandler> inputHandlers = new HideousLinkedList<>(new CopyOnWriteArrayList<>());
|
||||
public static final LinkedList<IContainerDrawHandler> drawHandlers = new HideousLinkedList<>(new CopyOnWriteArrayList<>());
|
||||
public static final LinkedList<IContainerObjectHandler> objectHandlers = new HideousLinkedList<>(new CopyOnWriteArrayList<>());
|
||||
public static final LinkedList<IContainerSlotClickHandler> slotClickHandlers = new HideousLinkedList<>(new CopyOnWriteArrayList<>());
|
||||
public static LinkedList<IContainerTooltipHandler> tooltipHandlers = new LinkedList<>();
|
||||
public static LinkedList<IContainerInputHandler> inputHandlers = new LinkedList<>();
|
||||
public static LinkedList<IContainerDrawHandler> drawHandlers = new LinkedList<>();
|
||||
public static LinkedList<IContainerObjectHandler> objectHandlers = new LinkedList<>();
|
||||
public static LinkedList<IContainerSlotClickHandler> slotClickHandlers = new LinkedList<>();
|
||||
|
||||
static {
|
||||
addSlotClickHandler(new DefaultSlotClickHandler());
|
||||
|
||||
@@ -1,271 +0,0 @@
|
||||
package codechicken.nei.guihook;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.function.UnaryOperator;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* A hideous LinkedList that is backed by an arbitrary list, for alternative characteristics while preserving
|
||||
* binary compatibility...
|
||||
* @param <E>
|
||||
*/
|
||||
final class HideousLinkedList<E> extends LinkedList<E> {
|
||||
private final List<E> backing;
|
||||
|
||||
HideousLinkedList(List<E> backing) {
|
||||
this.backing = backing;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return backing.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return backing.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Object o) {
|
||||
return backing.contains(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<E> iterator() {
|
||||
return backing.iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] toArray() {
|
||||
return backing.toArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T[] toArray(T[] a) {
|
||||
return backing.toArray(a);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean add(E e) {
|
||||
return backing.add(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addFirst(E e) {
|
||||
backing.add(0, e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public E getFirst() {
|
||||
if (backing.size() == 0) throw new NoSuchElementException();
|
||||
return(backing.get(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public E removeFirst() {
|
||||
E item = getFirst();
|
||||
backing.remove(0);
|
||||
return item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addLast(E e) {
|
||||
backing.add(backing.size(), e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public E getLast() {
|
||||
if (backing.size() == 0) throw new NoSuchElementException();
|
||||
return backing.get(backing.size() - 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public E removeLast() {
|
||||
E item = getLast();
|
||||
backing.remove(backing.size() - 1);
|
||||
return item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public E peek() {
|
||||
return backing.size() > 0 ? backing.get(0) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public E peekFirst() {
|
||||
return backing.size() > 0 ? getFirst() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public E peekLast() {
|
||||
return backing.size() > 0 ? getLast() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public E poll() {
|
||||
return backing.size() > 0 ? removeFirst() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public E pollFirst() {
|
||||
return poll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public E pollLast() {
|
||||
return backing.size() > 0 ? removeLast() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void push(E e) {
|
||||
addFirst(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public E pop() {
|
||||
return removeFirst();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeFirstOccurrence(Object e) {
|
||||
return remove(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeLastOccurrence(Object e) {
|
||||
int idx = this.backing.lastIndexOf(e);
|
||||
if (idx != -1) {
|
||||
this.backing.remove(idx);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove(Object o) {
|
||||
return backing.remove(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsAll(Collection<?> c) {
|
||||
return backing.containsAll(c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addAll(Collection<? extends E> c) {
|
||||
return backing.addAll(c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addAll(int index, Collection<? extends E> c) {
|
||||
return backing.addAll(index, c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeAll(Collection<?> c) {
|
||||
return backing.removeAll(c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean retainAll(Collection<?> c) {
|
||||
return backing.retainAll(c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void replaceAll(UnaryOperator<E> operator) {
|
||||
backing.replaceAll(operator);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sort(Comparator<? super E> c) {
|
||||
backing.sort(c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
backing.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return backing.equals(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return backing.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public E get(int index) {
|
||||
return backing.get(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public E set(int index, E element) {
|
||||
return backing.set(index, element);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(int index, E element) {
|
||||
backing.add(index, element);
|
||||
}
|
||||
|
||||
@Override
|
||||
public E remove(int index) {
|
||||
return backing.remove(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int indexOf(Object o) {
|
||||
return backing.indexOf(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int lastIndexOf(Object o) {
|
||||
return backing.lastIndexOf(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListIterator<E> listIterator() {
|
||||
return backing.listIterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListIterator<E> listIterator(int index) {
|
||||
return backing.listIterator(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<E> subList(int fromIndex, int toIndex) {
|
||||
return backing.subList(fromIndex, toIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Spliterator<E> spliterator() {
|
||||
return backing.spliterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeIf(Predicate<? super E> filter) {
|
||||
return backing.removeIf(filter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<E> stream() {
|
||||
return backing.stream();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<E> parallelStream() {
|
||||
return backing.parallelStream();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forEach(Consumer<? super E> action) {
|
||||
backing.forEach(action);
|
||||
}
|
||||
}
|
||||
@@ -507,7 +507,7 @@ public abstract class GuiRecipe extends GuiContainer implements IGuiContainerOve
|
||||
if (result != null)
|
||||
slotcontainer.addSlot(result, p.x, p.y);
|
||||
|
||||
List<PositionedStack> catalysts = RecipeCatalysts.getRecipeCatalysts(handler);
|
||||
List<PositionedStack> catalysts = RecipeCatalysts.getRecipeCatalysts(handler.getClass());
|
||||
for (PositionedStack catalyst : catalysts) {
|
||||
int xOffset = -GuiRecipeCatalyst.ingredientSize + 1;
|
||||
int yOffset = BG_TOP_Y + GuiRecipeCatalyst.fullBorder;
|
||||
|
||||
@@ -24,7 +24,7 @@ public class GuiRecipeCatalyst extends INEIGuiAdapter {
|
||||
|
||||
public void draw() {
|
||||
if (guiRecipe == null) return;
|
||||
int catalystsSize = RecipeCatalysts.getRecipeCatalysts(guiRecipe.getHandler()).size();
|
||||
int catalystsSize = RecipeCatalysts.getRecipeCatalysts(guiRecipe.getHandler().getClass()).size();
|
||||
if (catalystsSize == 0) return;
|
||||
|
||||
int availableHeight = RecipeCatalysts.getHeight();
|
||||
@@ -49,7 +49,7 @@ public class GuiRecipeCatalyst extends INEIGuiAdapter {
|
||||
public boolean hideItemPanelSlot(GuiContainer gui, int x, int y, int w, int h) {
|
||||
if (!(gui instanceof GuiRecipe)) return false;
|
||||
guiRecipe = (GuiRecipe) gui;
|
||||
int catalystsSize = RecipeCatalysts.getRecipeCatalysts(guiRecipe.getHandler()).size();
|
||||
int catalystsSize = RecipeCatalysts.getRecipeCatalysts(guiRecipe.getHandler().getClass()).size();
|
||||
if (catalystsSize == 0) return false;
|
||||
|
||||
int availableHeight = RecipeCatalysts.getHeight();
|
||||
|
||||
@@ -89,15 +89,6 @@ public interface IRecipeHandler
|
||||
* @return An instance of {@link IOverlayHandler} to be used for rendering the overlay of this specific recipe.
|
||||
*/
|
||||
public IOverlayHandler getOverlayHandler(GuiContainer gui, int recipe);
|
||||
/**
|
||||
* Simply works with the {@link codechicken.nei.api.DefaultOverlayRenderer}
|
||||
* If the current container has been registered with this identifier, the question mark appears and an overlay guide can be drawn.
|
||||
*
|
||||
* @return The overlay identifier of this recipe type.
|
||||
*/
|
||||
public default String getOverlayIdentifier() {
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @return The number of recipes that can fit on a page in the viewer (1 or 2)
|
||||
|
||||
@@ -12,49 +12,39 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class RecipeCatalysts {
|
||||
private static final Map<String, List<ItemStack>> recipeCatalystMap = new HashMap<>();
|
||||
private static Map<String, List<PositionedStack>> positionedRecipeCatalystMap = new HashMap<>();
|
||||
private static final Map<Class<? extends IRecipeHandler>, List<ItemStack>> recipeCatalystMap = new HashMap<>();
|
||||
private static Map<Class<? extends IRecipeHandler>, List<PositionedStack>> positionedRecipeCatalystMap = new HashMap<>();
|
||||
private static int heightCache;
|
||||
|
||||
public static void addRecipeCatalyst(List<ItemStack> stacks, String handlerID) {
|
||||
if (handlerID == null) return;
|
||||
if (recipeCatalystMap.containsKey(handlerID)) {
|
||||
recipeCatalystMap.get(handlerID).addAll(stacks);
|
||||
public static void addRecipeCatalyst(List<ItemStack> stacks, Class<? extends IRecipeHandler> handler) {
|
||||
if (recipeCatalystMap.containsKey(handler)) {
|
||||
recipeCatalystMap.get(handler).addAll(stacks);
|
||||
} else {
|
||||
// use ArrayList initializer to prevent UOE
|
||||
recipeCatalystMap.put(handlerID, new ArrayList<>(stacks));
|
||||
recipeCatalystMap.put(handler, new ArrayList<>(stacks));
|
||||
}
|
||||
}
|
||||
|
||||
public static Map<String, List<PositionedStack>> getPositionedRecipeCatalystMap() {
|
||||
public static Map<Class<? extends IRecipeHandler>, List<PositionedStack>> getPositionedRecipeCatalystMap() {
|
||||
return positionedRecipeCatalystMap;
|
||||
}
|
||||
|
||||
public static List<PositionedStack> getRecipeCatalysts(IRecipeHandler handler) {
|
||||
return getRecipeCatalysts(handler.getOverlayIdentifier());
|
||||
}
|
||||
|
||||
public static List<PositionedStack> getRecipeCatalysts(String handlerID) {
|
||||
public static List<PositionedStack> getRecipeCatalysts(Class<? extends IRecipeHandler> handler) {
|
||||
if (!NEIClientConfig.areJEIStyleTabsVisible() || !NEIClientConfig.areJEIStyleRecipeCatalystsVisible()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return positionedRecipeCatalystMap.getOrDefault(handlerID, Collections.emptyList());
|
||||
return positionedRecipeCatalystMap.getOrDefault(handler, Collections.emptyList());
|
||||
}
|
||||
|
||||
public static boolean containsCatalyst(IRecipeHandler handler, ItemStack candidate) {
|
||||
return containsCatalyst(handler.getOverlayIdentifier(), candidate);
|
||||
}
|
||||
|
||||
public static boolean containsCatalyst(String handlerID, ItemStack candidate) {
|
||||
return recipeCatalystMap.getOrDefault(handlerID, Collections.emptyList()).stream()
|
||||
public static boolean containsCatalyst(Class<? extends IRecipeHandler> handler, ItemStack candidate) {
|
||||
return recipeCatalystMap.getOrDefault(handler, Collections.emptyList()).stream()
|
||||
.anyMatch(s -> NEIServerUtils.areStacksSameType(s, candidate));
|
||||
}
|
||||
|
||||
public static void updatePosition(int availableHeight) {
|
||||
if (availableHeight == heightCache) return;
|
||||
|
||||
Map<String, List<PositionedStack>> newMap = new HashMap<>();
|
||||
for (Map.Entry<String, List<ItemStack>> entry : recipeCatalystMap.entrySet()) {
|
||||
Map<Class<? extends IRecipeHandler>, List<PositionedStack>> newMap = new HashMap<>();
|
||||
for (Map.Entry<Class<? extends IRecipeHandler>, List<ItemStack>> entry : recipeCatalystMap.entrySet()) {
|
||||
List<ItemStack> catalysts = entry.getValue();
|
||||
List<PositionedStack> newStacks = new ArrayList<>();
|
||||
int rowCount = getRowCount(availableHeight, catalysts.size());
|
||||
@@ -85,18 +75,4 @@ public class RecipeCatalysts {
|
||||
return NEIServerUtils.divideCeil(catalystsSize, columnCount);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void addRecipeCatalyst(List<ItemStack> stacks, Class<? extends IRecipeHandler> handler) {
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static List<PositionedStack> getRecipeCatalysts(Class<? extends IRecipeHandler> handler) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static boolean containsCatalyst(Class<? extends IRecipeHandler> handler, ItemStack candidate) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -123,10 +123,12 @@ public class RecipeInfo
|
||||
API.registerRecipeHandler(new ProfilerRecipeHandler(true));
|
||||
API.registerUsageHandler(new ProfilerRecipeHandler(false));
|
||||
|
||||
API.addRecipeCatalyst(new ItemStack(Blocks.crafting_table), "crafting");
|
||||
API.addRecipeCatalyst(new ItemStack(Blocks.furnace), new FurnaceRecipeHandler());
|
||||
API.addRecipeCatalyst(new ItemStack(Items.brewing_stand), new BrewingRecipeHandler());
|
||||
API.addRecipeCatalyst(new ItemStack(Blocks.furnace), new FuelRecipeHandler());
|
||||
API.addRecipeCatalyst(new ItemStack(Blocks.crafting_table), ShapedRecipeHandler.class);
|
||||
API.addRecipeCatalyst(new ItemStack(Blocks.crafting_table), ShapelessRecipeHandler.class);
|
||||
API.addRecipeCatalyst(new ItemStack(Blocks.crafting_table), FireworkRecipeHandler.class);
|
||||
API.addRecipeCatalyst(new ItemStack(Blocks.furnace), FurnaceRecipeHandler.class);
|
||||
API.addRecipeCatalyst(new ItemStack(Items.brewing_stand), BrewingRecipeHandler.class);
|
||||
API.addRecipeCatalyst(new ItemStack(Blocks.furnace), FuelRecipeHandler.class);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -442,7 +442,6 @@ public abstract class TemplateRecipeHandler implements ICraftingHandler, IUsageH
|
||||
*
|
||||
* @return The overlay identifier of this recipe type.
|
||||
*/
|
||||
@Override
|
||||
public String getOverlayIdentifier() {
|
||||
return null;
|
||||
}
|
||||
@@ -560,7 +559,7 @@ public abstract class TemplateRecipeHandler implements ICraftingHandler, IUsageH
|
||||
TemplateRecipeHandler handler = newInstance();
|
||||
if (inputId.equals("item")) {
|
||||
ItemStack candidate = (ItemStack) ingredients[0];
|
||||
if (RecipeCatalysts.containsCatalyst(handler, candidate)) {
|
||||
if (RecipeCatalysts.containsCatalyst(handler.getClass(), candidate)) {
|
||||
for (RecipeTransferRect rect : transferRects) {
|
||||
if (specifyTransferRect() == null || Objects.equals(rect.outputId, specifyTransferRect())) {
|
||||
handler.loadCraftingRecipes(rect.outputId, rect.results);
|
||||
|
||||
Reference in new issue
Block a user