Compare commits

...
8 Commits
Author SHA1 Message Date
bombcar db6e3d33ca clean up repos 2022-02-11 08:12:11 -08:00
bombcar 991a6dc772 update buildscript, fix mcmod info not displaying 2022-02-11 08:12:11 -08:00
Serghei Borovetchi 5f1ed67a8b create presets module 2022-02-10 08:43:16 -08:00
miozune 49b22e0683 Add more util function 2022-02-10 08:38:02 -08:00
Kiwiand[Kiwi233] 00dacef241 Update zh_CN.lang (#213)
* Update zh_CN.lang

* Update zh_CN.lang

* Update zh_CN.lang

* Update zh_CN.lang

Co-authored-by: [Kiwi233] <[[email protected]]>
2022-02-07 21:42:39 +01:00
miozune c4da6706a5 Move fuel info from tooltip to foreground 2022-02-07 12:39:24 -08:00
Oleg Ivanov f588543b64 Add new chunk overlay mode for gregtech ore regions (#211)
* Add new chunk overlay mode for gregtech ore regions
* Change GregTech existence check to GregTech 5 only
* Add GT-like region shift on negative coords
2022-02-07 12:18:02 -08:00
Socolio f006a93dd5 Add mob overlay cache, optimize mob overlay spawn check 2022-02-07 12:14:26 -08:00
25 changed files with 1671 additions and 194 deletions

No files matched your search

+54 -46
View File
@@ -1,11 +1,14 @@
//version: 1644194279
//version: 1644510936
/*
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.
*/
*/
import org.gradle.internal.logging.text.StyledTextOutput
import org.gradle.internal.logging.text.StyledTextOutputFactory
import org.gradle.internal.logging.text.StyledTextOutput.Style
import com.github.jengelman.gradle.plugins.shadow.tasks.ConfigureShadowRelocation
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
@@ -15,20 +18,20 @@ import java.util.concurrent.TimeUnit
buildscript {
repositories {
maven {
name = "forge"
url = "https://maven.minecraftforge.net"
name 'forge'
url 'https://maven.minecraftforge.net'
}
maven {
name = "sonatype"
url = "https://oss.sonatype.org/content/repositories/snapshots/"
name 'sonatype'
url 'https://oss.sonatype.org/content/repositories/snapshots/'
}
maven {
name = "Scala CI dependencies"
url = "https://repo1.maven.org/maven2/"
name 'Scala CI dependencies'
url 'https://repo1.maven.org/maven2/'
}
maven {
name = "jitpack"
url = "https://jitpack.io"
name 'jitpack'
url 'https://jitpack.io'
}
}
dependencies {
@@ -37,21 +40,24 @@ buildscript {
}
plugins {
id 'java-library'
id 'idea'
id 'eclipse'
id 'scala'
id 'maven-publish'
id('org.jetbrains.kotlin.jvm') version ('1.6.10') apply false
id('org.ajoberstar.grgit') version('4.1.1')
id('com.github.johnrengelman.shadow') version('4.0.4')
id('com.palantir.git-version') version('0.13.0') apply false
id('de.undercouch.download') version('5.0.1')
id('maven-publish')
}
if (project.file('.git/HEAD').isFile()) {
apply plugin: 'com.palantir.git-version'
}
def out = services.get(StyledTextOutputFactory).create("an-output")
apply plugin: 'forge'
def projectJavaVersion = JavaLanguageVersion.of(8)
@@ -168,7 +174,7 @@ try {
'git config core.fileMode false'.execute()
}
catch (Exception e) {
logger.error("\u001B[31mgit isn't installed at all\u001B[0m")
out.style(Style.Failure).println("git isn't installed at all")
}
// Pulls version first from the VERSION env and then git tag
@@ -178,9 +184,11 @@ try {
identifiedVersion = versionOverride == null ? gitVersion() : versionOverride
}
catch (Exception e) {
logger.error("\n\u001B[1;31mThis mod must be version controlled by Git AND the repository must provide at least one tag,\n" +
"or the VERSION override must be set! \u001B[32m(Don't download from GitHub using the ZIP option, instead\n" +
"clone the repository, see\u001B[33m https://gtnh.miraheze.org/wiki/Development \u001B[32mfor details.)\u001B[0m\n");
out.style(Style.Failure).text(
'This mod must be version controlled by Git AND the repository must provide at least one tag,\n' +
'or the VERSION override must be set! ').style(Style.SuccessHeader).text('(Do NOT download from GitHub using the ZIP option, instead\n' +
'clone the repository, see ').style(Style.Info).text('https://gtnh.miraheze.org/wiki/Development').style(Style.SuccessHeader).println(' for details.)'
)
versionOverride = 'NO-GIT-TAG-SET'
identifiedVersion = versionOverride
}
@@ -188,8 +196,7 @@ version = minecraftVersion + '-' + identifiedVersion
String modVersion = identifiedVersion
if( identifiedVersion.equals(versionOverride) ) {
logger.error('\u001B[31m\u001B[7mWe hope you know what you\'re doing using\u001B[0m\u001B[1;34m ' + modVersion + '\u001B[0m\n');
logger.error('\7\u001B[31mGoing to blindly try to use\u001B[1;34m ' + modVersion + '\u001B[0m\u001B[31m, this probably won\'t work the way you expect!!\u001B[0m\n');
out.style(Style.Failure).text('Override version to ').style(Style.Identifier).text(modVersion).style(Style.Failure).println('!\7')
}
group = modGroup
@@ -262,36 +269,36 @@ configurations {
repositories {
maven {
name = "Overmind forge repo mirror"
url = "https://gregtech.overminddl1.com/"
name 'Overmind forge repo mirror'
url 'https://gregtech.overminddl1.com/'
}
if(usesMixins.toBoolean()) {
maven {
name = "sponge"
url = "https://repo.spongepowered.org/repository/maven-public"
name 'sponge'
url 'https://repo.spongepowered.org/repository/maven-public'
}
maven {
url = "https://jitpack.io"
url 'https://jitpack.io'
}
}
}
dependencies {
if(usesMixins.toBoolean()) {
annotationProcessor("org.ow2.asm:asm-debug-all:5.0.3")
annotationProcessor("com.google.guava:guava:24.1.1-jre")
annotationProcessor("com.google.code.gson:gson:2.8.6")
annotationProcessor("org.spongepowered:mixin:0.8-SNAPSHOT")
annotationProcessor('org.ow2.asm:asm-debug-all:5.0.3')
annotationProcessor('com.google.guava:guava:24.1.1-jre')
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('com.github.GTNewHorizons:SpongePoweredMixin:0.7.12-GTNH') {
// Mixin includes a lot of dependencies that are too up-to-date
exclude module: "launchwrapper"
exclude module: "guava"
exclude module: "gson"
exclude module: "commons-io"
exclude module: "log4j-core"
exclude module: 'launchwrapper'
exclude module: 'guava'
exclude module: 'gson'
exclude module: 'commons-io'
exclude module: 'log4j-core'
}
compile("com.github.GTNewHorizons:SpongeMixins:1.5.0")
compile('com.github.GTNewHorizons:SpongeMixins:1.5.0')
}
}
@@ -411,7 +418,7 @@ processResources
from(sourceSets.main.resources.srcDirs) {
include 'mcmod.info'
// replace version and mcversion
// replace modVersion and minecraftVersion
expand "minecraftVersion": project.minecraft.version,
"modVersion": modVersion,
"modId": modId,
@@ -422,7 +429,7 @@ processResources
from refMap
}
// copy everything else, thats not the mcmod.info
// copy everything else that's not the mcmod.info
from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'
}
@@ -539,8 +546,6 @@ tasks.withType(GenerateModuleMetadata) {
enabled = false
}
// publishing
publishing {
publications {
maven(MavenPublication) {
@@ -561,13 +566,16 @@ publishing {
// 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
// remove extra garbage from who knows where
pom.withXml {
def badPomGroup = ['net.minecraft', 'com.google.code.findbugs', 'org.ow2.asm', 'com.typesafe.akka', 'com.typesafe', 'org.scala-lang',
'org.scala-lang.plugins', 'net.sf.jopt-simple', 'lzma', 'com.mojang', 'org.apache.commons', 'org.apache.httpcomponents',
'commons-logging', 'java3d', 'net.sf.trove4j', 'com.ibm.icu', 'com.paulscode', 'io.netty', 'com.google.guava',
'commons-io', 'commons-codec', 'net.java.jinput', 'net.java.jutils', 'com.google.code.gson', 'org.apache.logging.log4j',
'org.lwjgl.lwjgl', 'tv.twitch', '']
Node pomNode = asNode()
pomNode.dependencies.'*'.findAll() {
it.groupId.text() != 'com.github.GTNewHorizons'
badPomGroup.contains(it.groupId.text())
}.each() {
it.parent().remove(it)
}
@@ -599,7 +607,7 @@ if (isNewBuildScriptVersionAvailable(projectDir.toString())) {
if (autoUpdateBuildScript.toBoolean()) {
performBuildScriptUpdate(projectDir.toString())
} else {
println("Build script update available! Run 'gradle updateBuildScript'")
out.style(Style.SuccessHeader).println("Build script update available! Run 'gradle updateBuildScript'")
}
}
@@ -611,7 +619,7 @@ boolean performBuildScriptUpdate(String projectDir) {
if (isNewBuildScriptVersionAvailable(projectDir)) {
def buildscriptFile = getFile("build.gradle")
availableBuildScriptUrl().withInputStream { i -> buildscriptFile.withOutputStream { it << i } }
print("Build script updated. Please REIMPORT the project or RESTART your IDE!")
out.style(Style.Success).print("Build script updated. Please REIMPORT the project or RESTART your IDE!")
return true
}
return false
@@ -673,7 +681,7 @@ def deobf(String sourceURL) {
}
}
// The method above is to be prefered. Use this method if the filename is not at the end of the URL.
// The method above is to be preferred. Use this method if the filename is not at the end of the URL.
def deobf(String sourceURL, String fileName) {
String cacheDir = System.getProperty("user.home") + "/.gradle/caches/"
String bon2Dir = cacheDir + "forge_gradle/deobf"
@@ -685,14 +693,14 @@ def deobf(String sourceURL, String fileName) {
return files(deobfFile)
}
download {
download.run {
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 {
download.run {
src sourceURL
dest obfFile
quiet true
+3 -3
View File
@@ -1,7 +1,7 @@
// Add your dependencies here
dependencies {
compile("com.github.GTNewHorizons:CodeChickenLib:1.1.5.3:dev")
compile("com.github.GTNewHorizons:CodeChickenCore:1.1.3:dev")
shadowImplementation("org.apache.commons:commons-csv:1.5")
compile('com.github.GTNewHorizons:CodeChickenLib:1.1.5.3:dev')
compile('com.github.GTNewHorizons:CodeChickenCore:1.1.3:dev')
shadowImplementation('org.apache.commons:commons-csv:1.8')
}
+6 -6
View File
@@ -15,15 +15,15 @@ autoUpdateBuildScript = false
minecraftVersion = 1.7.10
forgeVersion = 10.13.4.1614
# Select a username for testing your mod with breakpoints. You may leave this empty for a random user name each time you
# Select a username for testing your mod with breakpoints. You may leave this empty for a random username each time you
# restart Minecraft in development. Choose this dependent on your mod:
# Do you need consistent player progressing (for example Thaumcraft)? -> Select a name
# Do you need to test how your custom blocks interacts with a player that is not the owner? -> leave name empty
developmentEnvironmentUserName = "Developer"
developmentEnvironmentUserName = Developer
# Define a source file of your project with:
# public static final String VERSION = "GRADLETOKEN_VERSION";
# The string's content will be replaced with your mods version when compiled. You should use this to specify your mod's
# The string's content will be replaced with your mod's version when compiled. You should use this to specify your mod's
# version in @Mod([...], version = VERSION, [...])
# Leave these properties empty to skip individual token replacements
replaceGradleTokenInFile = NEIModContainer.java
@@ -32,12 +32,12 @@ gradleTokenModName = GRADLETOKEN_MODNAME
gradleTokenVersion = GRADLETOKEN_VERSION
gradleTokenGroupName =
# In case your mod provides an API for other mods to implement you may declare its package here. Otherwise you can
# In case your mod provides an API for other mods to implement you may declare its package here. Otherwise, you can
# leave this property empty.
# Example value: apiPackage = api + modGroup = com.myname.mymodid -> com.myname.mymodid.api
apiPackage =
# Specify the configuration file for Forge's access transformers here. I must be placed into /src/main/resources/META-INF/
# Specify the configuration file for Forge's access transformers here. It must be placed into /src/main/resources/META-INF/
# Example value: mymodid_at.cfg
accessTransformersFile = nei_at.cfg
@@ -48,7 +48,7 @@ mixinPlugin =
# Specify the package that contains all of your Mixins. You may only place Mixins in this package or the build will fail!
mixinsPackage =
# Specify the core mod entry class if you use a core mod. This class must implement IFMLLoadingPlugin!
# This parameter is for legacy compatability only
# This parameter is for legacy compatibility only
# Example value: coreModClass = asm.FMLPlugin + modGroup = com.myname.mymodid -> com.myname.mymodid.asm.FMLPlugin
coreModClass = asm.NEICorePlugin
# If your project is only a consolidation of mixins or a core mod and does NOT contain a 'normal' mod ( = some class
+9 -3
View File
@@ -3,10 +3,16 @@
repositories {
mavenCentral()
maven {
name = "GTNH Maven"
url = "http://jenkins.usrv.eu:8081/nexus/content/groups/public/"
name 'GTNH Maven'
url 'http://jenkins.usrv.eu:8081/nexus/content/groups/public/'
}
maven {
url = "https://jitpack.io"
url 'https://cursemaven.com'
content {
includeGroup 'curse.maven'
}
}
maven {
url 'https://jitpack.io'
}
}
@@ -21,7 +21,6 @@ import static codechicken.lib.gui.GuiDraw.drawRect;
import java.awt.Point;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.FileInputStream;
@@ -450,6 +449,10 @@ public class BookmarkPanel extends ItemPanel
public void saveBookmarks()
{
if (bookmarkFile == null) {
return;
}
ArrayList<String> strings = new ArrayList<>();
for (int grpIdx = 0; grpIdx < namespaces.size() - 1; grpIdx++) {
@@ -487,12 +490,10 @@ public class BookmarkPanel extends ItemPanel
}
if (bookmarkFile != null) {
try(FileWriter writer = new FileWriter(bookmarkFile)) {
IOUtils.writeLines(strings, "\n", writer);
} catch (IOException e) {
NEIClientConfig.logger.error("Filed to save bookmarks list to file {}", bookmarkFile, e);
}
try (FileOutputStream output = new FileOutputStream(bookmarkFile)) {
IOUtils.writeLines(strings, "\n", output, "UTF-8");
} catch (IOException e) {
NEIClientConfig.logger.error("Filed to save bookmarks list to file {}", bookmarkFile, e);
}
}
@@ -748,6 +749,7 @@ public class BookmarkPanel extends ItemPanel
public void mouseUp(int mousex, int mousey, int button)
{
if (sortedStackIndex != -1) {
draggedStack = null;
sortedNamespaceIndex = -1;
sortedStackIndex = -1;
mouseDownSlot = -1;
@@ -6,6 +6,8 @@ import codechicken.lib.packet.PacketCustom;
import codechicken.nei.api.API;
import codechicken.nei.api.ItemInfo;
import codechicken.nei.recipe.GuiRecipeTab;
import codechicken.nei.recipe.StackInfo;
import com.google.common.collect.Lists;
import cpw.mods.fml.client.CustomModLoadingErrorDisplayException;
import cpw.mods.fml.common.FMLCommonHandler;
@@ -160,6 +162,7 @@ public class ClientHandler
loadSerialHandlers();
loadHeightHackHandlers();
ItemInfo.preInit();
StackInfo.loadGuidFilters();
}
public static void loadSerialHandlers() {
@@ -252,6 +252,7 @@ public class ItemList
try {
filtered = ItemList.forkJoinPool.submit(() -> items.parallelStream()
.filter(PresetsWidget::matches)
.filter(filter::matches)
.collect(Collectors.toCollection(ArrayList::new))).get();
} catch (InterruptedException | ExecutionException e) {
+15 -1
View File
@@ -1,5 +1,6 @@
package codechicken.nei;
import codechicken.lib.vec.Rectangle4i;
import codechicken.nei.api.GuiInfo;
import codechicken.nei.api.INEIGuiHandler;
import codechicken.nei.guihook.GuiContainerManager;
@@ -14,6 +15,7 @@ import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidContainerItem;
import static codechicken.lib.gui.GuiDraw.drawRect;
import static codechicken.nei.LayoutManager.searchField;
import java.util.ArrayList;
@@ -82,6 +84,18 @@ public class ItemPanel extends Widget
super.refresh(gui);
}
@Override
protected void drawItem(Rectangle4i rect, int idx, ItemPanelSlot focus)
{
if (PresetsWidget.inEditMode() && !PresetsWidget.isHidden(getItem(idx))) {
drawRect(rect.x, rect.y, rect.w, rect.h, 0xee555555);
}
super.drawItem(rect, idx, PresetsWidget.inEditMode()? null: focus);
}
}
protected ItemsGrid grid = new ItemPanelGrid();
@@ -236,6 +250,7 @@ public class ItemPanel extends Widget
if (mouseOverSlot == null || mouseOverSlot.slotIndex != mouseDownSlot || heldTime > 500) {
draggedStack = getDraggedStackWithQuantity(mouseDownSlot);
mouseDownSlot = -1;
}
}
@@ -482,7 +497,6 @@ public class ItemPanel extends Widget
else if (button == 1)
GuiUsageRecipe.openRecipeGui("item", item);
draggedStack = null;
mouseDownSlot = -1;
return;
}
+1 -1
View File
@@ -14,7 +14,7 @@ import static codechicken.lib.gui.GuiDraw.drawRect;
public class ItemsGrid
{
protected static final int SLOT_SIZE = 18;
public static final int SLOT_SIZE = 18;
protected int width;
protected int height;
@@ -86,6 +86,7 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH
public static ItemPanel itemPanel;
public static BookmarkPanel bookmarkPanel;
public static SubsetWidget dropDown;
public static PresetsWidget presetsPanel;
public static TextField searchField;
public static ButtonCycled options;
@@ -177,7 +178,7 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH
@Override
public boolean objectUnderMouse(GuiContainer gui, int mousex, int mousey) {
if (!isHidden() && isEnabled())
for (Widget widget : controlWidgets)
for (Widget widget : drawWidgets)
if (widget.contains(mousex, mousey))
return true;
@@ -238,7 +239,7 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH
@Override
public ItemStack getStackUnderMouse(GuiContainer gui, int mousex, int mousey) {
if (!isHidden() && isEnabled()) {
for (Widget widget : controlWidgets) {
for (Widget widget : drawWidgets) {
ItemStack stack = widget.getStackMouseOver(mousex, mousey);
if (stack != null)
return stack;
@@ -275,7 +276,7 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH
@Override
public List<String> handleTooltip(GuiContainer gui, int mousex, int mousey, List<String> currenttip) {
if (!isHidden() && isEnabled() && GuiContainerManager.shouldShowTooltip(gui)) {
for (Widget widget : controlWidgets)
for (Widget widget : drawWidgets)
currenttip = widget.handleTooltip(mousex, mousey, currenttip);
}
return currenttip;
@@ -339,6 +340,7 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH
bookmarkPanel.init();
dropDown = new SubsetWidget();
presetsPanel = new PresetsWidget();
searchField = new SearchField("search");
options = new ButtonCycled(3)
@@ -671,7 +673,13 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH
addWidget(options);
addWidget(bookmarksButton);
if (visiblity.showItemPanel) {
addWidget(itemPanel);
if (PresetsWidget.inEditMode()) {
drawWidgets.add(itemPanel);
} else {
addWidget(itemPanel);
}
itemPanel.setVisible();
addWidget(more);
@@ -682,6 +690,8 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH
if (visiblity.showBookmarkPanel) {
addWidget(bookmarkPanel);
bookmarkPanel.setVisible();
addWidget(presetsPanel);
}
if (visiblity.showSearchSection) {
@@ -738,7 +748,7 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH
if (!isEnabled())
return;
for (Widget widget : controlWidgets)
for (Widget widget : drawWidgets)
widget.update();
}
@@ -747,7 +757,7 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH
if (isHidden() || !isEnabled())
return false;
for (Widget widget : controlWidgets)
for (Widget widget : drawWidgets)
if (widget.onMouseWheel(scrolled, mousex, mousey))
return true;
@@ -190,6 +190,17 @@ public class NEIClientConfig {
return true;
}
});
tag.getTag("inventory.worldSpecificPresets").setComment("Global or world specific presets").getBooleanValue(false);
API.addOption(new OptionToggleButton("inventory.worldSpecificPresets", true) {
@Override
public boolean onClick(int button) {
super.onClick(button);
initPresetsFile(worldPath);
return true;
}
});
tag.getTag("inventory.bookmarksEnabled").setComment("Enable/disable bookmarks").getBooleanValue(true);
API.addOption(new OptionToggleButton("inventory.bookmarksEnabled", true));
tag.getTag("inventory.saveCurrentRecipeInBookmarksEnabled").setComment("Save Current Recipe in Bookmarks").getBooleanValue(true);
@@ -303,6 +314,7 @@ public class NEIClientConfig {
}
initBookmarkFile(worldPath);
initPresetsFile(worldPath);
world = new ConfigSet(new File(specificDir, "NEI.dat"), new ConfigFile(new File(specificDir, "NEI.cfg")));
onWorldLoad(newWorld);
}
@@ -386,6 +398,16 @@ public class NEIClientConfig {
ItemPanels.bookmarkPanel.setBookmarkFile(worldPath);
}
private static void initPresetsFile(String worldPath)
{
if (!global.config.getTag("inventory.worldSpecificPresets").getBooleanValue()) {
worldPath = "global";
}
PresetsWidget.loadPresets(worldPath);
}
public static boolean isWorldSpecific(String setting) {
if(world == null) return false;
ConfigTag tag = world.config.getTag(setting, false);
@@ -13,6 +13,7 @@ import cpw.mods.fml.client.FMLFileResourcePack;
import cpw.mods.fml.client.FMLFolderResourcePack;
import cpw.mods.fml.common.DummyModContainer;
import cpw.mods.fml.common.LoadController;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.ModMetadata;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLInterModComms;
@@ -24,15 +25,14 @@ import cpw.mods.fml.common.versioning.VersionRange;
import net.minecraft.util.EnumChatFormatting;
import java.io.File;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import java.util.*;
public class NEIModContainer extends DummyModContainer
{
public static LinkedList<IConfigureNEI> plugins = new LinkedList<>();
private static boolean gregTech5Loaded;
public NEIModContainer() {
super(getModMetadata());
loadMetadata();
@@ -43,9 +43,16 @@ public class NEIModContainer extends DummyModContainer
modMetadata.name = "GRADLETOKEN_MODNAME";
modMetadata.modId = "GRADLETOKEN_MODID";
modMetadata.version = "GRADLETOKEN_VERSION";
modMetadata.authorList = Arrays.asList( "ChickenBones", "mitchej123" );
modMetadata.url = "https://github.com/GTNewHorizons/NotEnoughItems";
modMetadata.description = "Recipe Viewer, Inventory Manager, Item Spawner, Cheats and more; GTNH Version includes many enhancements.";
return modMetadata;
}
public static boolean isGT5Loaded() {
return gregTech5Loaded;
}
@Override
public Set<ArtifactVersion> getRequirements() {
Set<ArtifactVersion> deps = new HashSet<>();
@@ -92,6 +99,7 @@ public class NEIModContainer extends DummyModContainer
@Subscribe
public void preInit(FMLPreInitializationEvent event) {
gregTech5Loaded = Loader.isModLoaded("gregtech") && !Loader.isModLoaded("gregapi_post");
if (CommonUtils.isClient())
ClientHandler.preInit();
}
@@ -98,6 +98,9 @@ public class PositionedStack
return false;
}
/**
* NBT-friendly version of {@link #contains(ItemStack)}
*/
public boolean containsWithNBT(ItemStack ingredient) {
for(ItemStack item : items)
if(NEIServerUtils.areStacksSameTypeCraftingWithNBT(item, ingredient))
File diff suppressed because it is too large. Load diff
@@ -15,11 +15,14 @@ import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.chunk.Chunk;
import org.lwjgl.opengl.GL11;
public class WorldOverlayRenderer implements IKeyStateTracker
{
public static int mobOverlay = 0;
public class WorldOverlayRenderer implements IKeyStateTracker {
public static int chunkOverlay = 0;
public static int mobOverlay = 0;
private static byte[] mobSpawnCache;
private static long mobOverlayUpdateTime;
public static void reset() {
mobOverlay = 0;
chunkOverlay = 0;
@@ -33,7 +36,7 @@ public class WorldOverlayRenderer implements IKeyStateTracker
if (KeyManager.keyStates.get("world.moboverlay").down)
mobOverlay = (mobOverlay + 1) % 2;
if (KeyManager.keyStates.get("world.chunkoverlay").down)
chunkOverlay = (chunkOverlay + 1) % 3;
chunkOverlay = (chunkOverlay + 1) % (NEIModContainer.isGT5Loaded() ? 4 : 3);
}
public static void render(float frame) {
@@ -46,9 +49,56 @@ public class WorldOverlayRenderer implements IKeyStateTracker
GL11.glPopMatrix();
}
private static void buildMobSpawnOverlay(Entity entity) {
if (mobSpawnCache == null) {
mobSpawnCache = new byte[33 * 33 * 33]; // 35kB
}
World world = entity.worldObj;
int x1 = (int) entity.posX;
int z1 = (int) entity.posZ;
int y1 = (int) MathHelper.clip(entity.posY, 16, world.getHeight() - 16);
for (int i = 0; i <= 32; i++) {
int x = x1 - 16 + i;
for (int j = 0; j <= 32; j++) {
int z = z1 - 16 + j;
int bufIndex = (i * 33 + j) * 33;
Chunk chunk = world.getChunkFromBlockCoords(x, z);
BiomeGenBase biome = world.getBiomeGenForCoords(x, z);
if (biome.getSpawnableList(EnumCreatureType.monster).isEmpty() || biome.getSpawningChance() <= 0) {
mobSpawnCache[bufIndex] = -1;
continue;
}
int maxHeight = chunk.worldObj.getHeightValue(x, z);
for (int k = 0; k <= 32; k++) {
int y = y1 - 16 + k;
if (y > maxHeight) {
mobSpawnCache[bufIndex + k] = -1;
break;
}
mobSpawnCache[bufIndex + k] = getSpawnMode(chunk, x, y, z);
}
}
}
}
private static void renderMobSpawnOverlay(Entity entity) {
if (mobOverlay == 0)
if (mobOverlay == 0) {
if (mobSpawnCache != null) {
mobSpawnCache = null;
}
return;
}
long worldTime = entity.worldObj.getTotalWorldTime();
if (mobSpawnCache == null || mobOverlayUpdateTime != worldTime) {
mobOverlayUpdateTime = worldTime;
buildMobSpawnOverlay(entity);
}
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glEnable(GL11.GL_BLEND);
@@ -65,32 +115,37 @@ public class WorldOverlayRenderer implements IKeyStateTracker
int z1 = (int) entity.posZ;
int y1 = (int) MathHelper.clip(entity.posY, 16, world.getHeight() - 16);
for (int x = x1 - 16; x <= x1 + 16; x++)
for (int z = z1 - 16; z <= z1 + 16; z++) {
Chunk chunk = world.getChunkFromBlockCoords(x, z);
BiomeGenBase biome = world.getBiomeGenForCoords(x, z);
if (biome.getSpawnableList(EnumCreatureType.monster).isEmpty() || biome.getSpawningChance() <= 0)
continue;
for (int i = 0; i <= 32; i++) {
int x = x1 - 16 + i;
for (int j = 0; j <= 32; j++) {
int z = z1 - 16 + j;
int cacheIndex = (i * 33 + j) * 33;
for (int y = y1 - 16; y < y1 + 16; y++) {
int spawnMode = getSpawnMode(chunk, x, y, z);
if (spawnMode == 0)
for (int k = 0; k <= 32; k++) {
int y = y1 - 16 + k;
int spawnMode = mobSpawnCache[cacheIndex + k];
if (spawnMode == 0) {
continue;
} else if (spawnMode == -1) {
break;
}
if (spawnMode != curSpawnMode) {
if (spawnMode == 1)
if (spawnMode == 1) {
GL11.glColor4f(1, 1, 0, 1);
else
} else {
GL11.glColor4f(1, 0, 0, 1);
}
curSpawnMode = spawnMode;
}
GL11.glVertex3d(x, y + 0.004, z);
GL11.glVertex3d(x + 1, y + 0.004, z + 1);
GL11.glVertex3d(x + 1, y + 0.004, z);
GL11.glVertex3d(x, y + 0.004, z + 1);
GL11.glVertex3d(x, y + 0.02, z);
GL11.glVertex3d(x + 1, y + 0.02, z + 1);
GL11.glVertex3d(x + 1, y + 0.02, z);
GL11.glVertex3d(x, y + 0.02, z + 1);
}
}
}
GL11.glEnd();
GL11.glEnable(GL11.GL_LIGHTING);
@@ -100,10 +155,12 @@ public class WorldOverlayRenderer implements IKeyStateTracker
private static final Entity dummyEntity = new EntityPig(null);
private static final AxisAlignedBB aabb = AxisAlignedBB.getBoundingBox(0, 0, 0, 0, 0, 0);
private static int getSpawnMode(Chunk chunk, int x, int y, int z) {
private static byte getSpawnMode(Chunk chunk, int x, int y, int z) {
if (!SpawnerAnimals.canCreatureTypeSpawnAtLocation(EnumCreatureType.monster, chunk.worldObj, x, y, z) ||
chunk.getSavedLightValue(EnumSkyBlock.Block, x & 15, y, z & 15) >= 8)
chunk.getSavedLightValue(EnumSkyBlock.Block, x & 15, y, z & 15) >= 8) {
return 0;
}
aabb.minX = x + 0.2;
aabb.maxX = x + 0.8;
@@ -111,14 +168,11 @@ public class WorldOverlayRenderer implements IKeyStateTracker
aabb.maxY = y + 1.8;
aabb.minZ = z + 0.2;
aabb.maxZ = z + 0.8;
if (!chunk.worldObj.checkNoEntityCollision(aabb) ||
!chunk.worldObj.getCollidingBoundingBoxes(dummyEntity, aabb).isEmpty() ||
chunk.worldObj.isAnyLiquid(aabb))
if (!chunk.worldObj.getCollidingBoundingBoxes(dummyEntity, aabb).isEmpty() || chunk.worldObj.isAnyLiquid(aabb)) {
return 0;
}
if (chunk.getSavedLightValue(EnumSkyBlock.Sky, x & 15, y, z & 15) >= 8)
return 1;
return 2;
return (byte) (chunk.getSavedLightValue(EnumSkyBlock.Sky, x & 15, y, z & 15) >= 8 ? 1 : 2);
}
private static void renderChunkBounds(Entity entity) {
@@ -172,40 +226,93 @@ public class WorldOverlayRenderer implements IKeyStateTracker
GL11.glVertex3d(x1, y2, z1);
}
if (chunkOverlay == 2 && cx == 0 && cz == 0) {
dy = 32;
y1 = Math.floor(entity.posY - dy / 2);
y2 = y1 + dy;
if (y1 < 0) {
y1 = 0;
y2 = dy;
}
if (cx == 0 && cz == 0) {
if (chunkOverlay == 2) {
dy = 32;
y1 = Math.floor(entity.posY - dy / 2);
y2 = y1 + dy;
if (y1 < 0) {
y1 = 0;
y2 = dy;
}
if (y1 > entity.worldObj.getHeight()) {
y2 = entity.worldObj.getHeight();
y1 = y2 - dy;
}
if (y1 > entity.worldObj.getHeight()) {
y2 = entity.worldObj.getHeight();
y1 = y2 - dy;
}
GL11.glColor4d(0, 0.9, 0, 0.4);
for (double y = (int) y1; y <= y2; y++) {
GL11.glVertex3d(x2, y, z1);
GL11.glVertex3d(x2, y, z2);
GL11.glVertex3d(x1, y, z1);
GL11.glVertex3d(x1, y, z2);
GL11.glVertex3d(x1, y, z2);
GL11.glVertex3d(x2, y, z2);
GL11.glVertex3d(x1, y, z1);
GL11.glVertex3d(x2, y, z1);
}
for (double h = 1; h <= 15; h++) {
GL11.glVertex3d(x1 + h, y1, z1);
GL11.glVertex3d(x1 + h, y2, z1);
GL11.glVertex3d(x1 + h, y1, z2);
GL11.glVertex3d(x1 + h, y2, z2);
GL11.glVertex3d(x1, y1, z1 + h);
GL11.glVertex3d(x1, y2, z1 + h);
GL11.glVertex3d(x2, y1, z1 + h);
GL11.glVertex3d(x2, y2, z1 + h);
GL11.glColor4d(0, 0.9, 0, 0.4);
for (double y = (int) y1; y <= y2; y++) {
GL11.glVertex3d(x2, y, z1);
GL11.glVertex3d(x2, y, z2);
GL11.glVertex3d(x1, y, z1);
GL11.glVertex3d(x1, y, z2);
GL11.glVertex3d(x1, y, z2);
GL11.glVertex3d(x2, y, z2);
GL11.glVertex3d(x1, y, z1);
GL11.glVertex3d(x2, y, z1);
}
for (double h = 1; h <= 15; h++) {
GL11.glVertex3d(x1 + h, y1, z1);
GL11.glVertex3d(x1 + h, y2, z1);
GL11.glVertex3d(x1 + h, y1, z2);
GL11.glVertex3d(x1 + h, y2, z2);
GL11.glVertex3d(x1, y1, z1 + h);
GL11.glVertex3d(x1, y2, z1 + h);
GL11.glVertex3d(x2, y1, z1 + h);
GL11.glVertex3d(x2, y2, z1 + h);
}
} else if (chunkOverlay == 3) {
int gx1 = ((entity.chunkCoordX < 0 ? entity.chunkCoordX - 3 : entity.chunkCoordX) / 3 * 3) << 4;
int gz1 = ((entity.chunkCoordZ < 0 ? entity.chunkCoordZ - 3 : entity.chunkCoordZ) / 3 * 3) << 4;
if (entity.chunkCoordX < 0) {
gx1 += 16;
}
if (entity.chunkCoordZ < 0) {
gz1 += 16;
}
int gx2 = gx1 + 48;
int gz2 = gz1 + 48;
GL11.glColor4d(0, 0.9, 0, 0.4);
for (double y = (int) y1; y <= y2; y++) {
GL11.glVertex3d(gx2, y, gz1);
GL11.glVertex3d(gx2, y, gz2);
GL11.glVertex3d(gx1, y, gz1);
GL11.glVertex3d(gx1, y, gz2);
GL11.glVertex3d(gx1, y, gz2);
GL11.glVertex3d(gx2, y, gz2);
GL11.glVertex3d(gx1, y, gz1);
GL11.glVertex3d(gx2, y, gz1);
}
for (double h = 4; h <= 44; h += 4) {
if (h % 16 == 0) {
continue;
}
GL11.glVertex3d(gx1 + h, y1, gz1);
GL11.glVertex3d(gx1 + h, y2, gz1);
GL11.glVertex3d(gx1 + h, y1, gz2);
GL11.glVertex3d(gx1 + h, y2, gz2);
GL11.glVertex3d(gx1, y1, gz1 + h);
GL11.glVertex3d(gx1, y2, gz1 + h);
GL11.glVertex3d(gx2, y1, gz1 + h);
GL11.glVertex3d(gx2, y2, gz1 + h);
}
GL11.glColor4d(0, 0, 0.9, 0.4);
gx1 += 23;
gz1 += 23;
gx2 = gx1 + 1;
gz2 = gz1 + 1;
GL11.glVertex3d(gx1, y1, gz1);
GL11.glVertex3d(gx1, y2, gz1);
GL11.glVertex3d(gx2, y1, gz1);
GL11.glVertex3d(gx2, y2, gz1);
GL11.glVertex3d(gx1, y1, gz2);
GL11.glVertex3d(gx1, y2, gz2);
GL11.glVertex3d(gx2, y1, gz2);
GL11.glVertex3d(gx2, y2, gz2);
}
}
}
@@ -4,12 +4,14 @@ import codechicken.core.launch.CodeChickenCorePlugin;
import codechicken.lib.asm.ASMInit;
import cpw.mods.fml.relauncher.IFMLCallHook;
import cpw.mods.fml.relauncher.IFMLLoadingPlugin;
import cpw.mods.fml.relauncher.IFMLLoadingPlugin.MCVersion;
import cpw.mods.fml.relauncher.IFMLLoadingPlugin.TransformerExclusions;
import java.io.File;
import java.util.Map;
@TransformerExclusions(value = {"codechicken.nei.asm"})
@MCVersion( "1.7.10" )
public class NEICorePlugin implements IFMLLoadingPlugin, IFMLCallHook
{
public static File location;
@@ -2,9 +2,11 @@ package codechicken.nei.recipe;
import codechicken.nei.NEIClientUtils;
import codechicken.nei.PositionedStack;
import net.minecraft.client.Minecraft;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.FurnaceRecipes;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -87,26 +89,13 @@ public class FuelRecipeHandler extends FurnaceRecipeHandler
}
@Override
public List<String> handleItemTooltip(GuiRecipe gui, ItemStack stack, List<String> currenttip, int recipe) {
public void drawExtras(int recipe) {
super.drawExtras(recipe);
CachedFuelRecipe crecipe = (CachedFuelRecipe) arecipes.get(recipe);
FuelPair fuel = crecipe.fuel;
float burnTime = fuel.burnTime / 200F;
if (gui.isMouseOver(fuel.stack, recipe) && burnTime < 1) {
burnTime = 1F / burnTime;
String s_time = Float.toString(burnTime);
if (burnTime == Math.round(burnTime))
s_time = Integer.toString((int) burnTime);
currenttip.add(translate("recipe.fuel.required", s_time));
} else if ((gui.isMouseOver(crecipe.getResult(), recipe) || gui.isMouseOver(crecipe.getIngredient(), recipe)) && burnTime > 1) {
String s_time = Float.toString(burnTime);
if (burnTime == Math.round(burnTime))
s_time = Integer.toString((int) burnTime);
currenttip.add(translate("recipe.fuel." + (gui.isMouseOver(crecipe.getResult(), recipe) ? "produced" : "processed"), s_time));
}
return currenttip;
NumberFormat numberInstance = NumberFormat.getNumberInstance();
numberInstance.setMaximumFractionDigits(2);
String smeltCount = numberInstance.format(fuel.burnTime / 200f);
Minecraft.getMinecraft().fontRenderer.drawString(translate("recipe.fuel.smeltCount", smeltCount), 73, 51, 0xFF000000);
}
}
@@ -1,19 +1,35 @@
package codechicken.nei.recipe;
import codechicken.nei.NEIClientConfig;
import codechicken.nei.api.IStackStringifyHandler;
import codechicken.nei.recipe.stackinfo.DefaultStackStringifyHandler;
import codechicken.nei.recipe.stackinfo.GTFluidStackStringifyHandler;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraftforge.fluids.FluidStack;
import org.apache.commons.io.IOUtils;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.WeakHashMap;
public class StackInfo
{
public static final ArrayList<IStackStringifyHandler> stackStringifyHandlers = new ArrayList<>();
public static final ArrayList<IStackStringifyHandler> stackStringifyHandlers = new ArrayList<>();
private static final HashMap<String, HashMap<String, String[]>> guidfilters = new HashMap<>();
private static final WeakHashMap<ItemStack, String> guidcache = new WeakHashMap<>();
static {
stackStringifyHandlers.add(new DefaultStackStringifyHandler());
stackStringifyHandlers.add(new GTFluidStackStringifyHandler());
@@ -39,7 +55,7 @@ public class StackInfo
{
ItemStack stack = null;
for (int i = stackStringifyHandlers.size() - 1; i >= 0 && stack == null; i--) {
for (int i = stackStringifyHandlers.size() - 1; i >= 0 && nbtTag != null && stack == null; i--) {
stack = stackStringifyHandlers.get(i).convertNBTToItemStack(nbtTag);
}
@@ -73,4 +89,119 @@ public class StackInfo
return fluid;
}
public static String getItemStackGUID(ItemStack stack)
{
if (!guidcache.containsKey(stack)) {
final NBTTagCompound nbTag = itemStackToNBT(stack, false);
if (nbTag == null) {
return null;
}
nbTag.removeTag("Count");
if (nbTag.getShort("Damage") == 0) {
nbTag.removeTag("Damage");
}
if (nbTag.hasKey("tag") && nbTag.getCompoundTag("tag").hasNoTags()) {
nbTag.removeTag("tag");
}
if (nbTag.hasKey("strId") && guidfilters.containsKey(nbTag.getString("strId"))) {
final ArrayList<String> keys = new ArrayList<>();
final String strId = nbTag.getString("strId");
keys.add(strId);
guidfilters.get(strId).forEach((key, rule) -> {
Object local = nbTag;
for (int i = 0; i < rule.length; i++) {
try {
if (local instanceof NBTTagCompound) {
local = ((NBTTagCompound) local).getTag(rule[i]);
} else if (local instanceof NBTTagList) {
local = ((NBTTagList) local).tagList.get(Integer.parseInt(rule[i]));
} else {
break;
}
} catch (Throwable e) {
break;
}
}
if (local instanceof NBTBase) {
keys.add(((NBTBase)local).toString());
} else if (local != null) {
keys.add(String.valueOf(local));
}
});
synchronized (guidcache) {
guidcache.put(stack, keys.toString());
}
} else {
synchronized (guidcache) {
guidcache.put(stack, nbTag.toString());
}
}
}
return guidcache.get(stack);
}
public static void loadGuidFilters()
{
guidfilters.clear();
final File guidFlitersFile = new File(NEIClientConfig.configDir, "guidfilters.cfg");
List<String> itemStrings = new ArrayList<>();
if (guidFlitersFile.exists()) {
try (FileReader reader = new FileReader(guidFlitersFile)) {
NEIClientConfig.logger.info("Loading guid filters from file {}", guidFlitersFile);
itemStrings = IOUtils.readLines(reader);
} catch (IOException e) {
NEIClientConfig.logger.error("Failed to load bookmarks from file {}", guidFlitersFile, e);
e.printStackTrace();
}
} else {
final URL filterUrl = Thread.currentThread().getContextClassLoader().getResource("assets/nei/guidfilters.cfg");
try (BufferedReader reader = new BufferedReader(new InputStreamReader(filterUrl.openStream()))) {
itemStrings = IOUtils.readLines(reader);
} catch (IOException e) {
NEIClientConfig.logger.info("Error parsing guid filters");
e.printStackTrace();
} catch (Exception e) {
NEIClientConfig.logger.info("Error parsing guid filters");
e.printStackTrace();
}
}
for (String guidStr: itemStrings) {
final String[] parts = guidStr.split(",");
final HashMap<String, String[]> rules = new HashMap<>();
for (int j = 1; j < parts.length; j++) {
rules.put(parts[j], parts[j].split("\\."));
}
guidfilters.put(parts[0], rules);
}
}
}
@@ -219,6 +219,17 @@ public abstract class TemplateRecipeHandler implements ICraftingHandler, IUsageH
return false;
}
/**
* NBT-friendly version of {@link #contains(Collection, ItemStack)}
*/
public boolean containsWithNBT(Collection<PositionedStack> ingredients, ItemStack ingredient) {
for (PositionedStack stack : ingredients)
if (stack.containsWithNBT(ingredient))
return true;
return false;
}
/**
* @param ingred
* @return true if any of the permutations of any of the ingredients contain this stack
+81 -31
View File
@@ -1,11 +1,8 @@
package codechicken.nei.util;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.google.gson.JsonPrimitive;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagByte;
@@ -20,26 +17,21 @@ import net.minecraft.nbt.NBTTagLong;
import net.minecraft.nbt.NBTTagShort;
import net.minecraft.nbt.NBTTagString;
import java.io.ByteArrayOutputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.IntStream;
public class NBTJson {
private static final Pattern numberPattern = Pattern.compile("^([-+]?[\\d]+\\.?[0-9]*)([bBsSlLfFdD]?)$");
private static final JsonParser parser = new JsonParser();
private static final Gson gson = new GsonBuilder().create();
private static final Pattern numberPattern = Pattern.compile("^([-+]?\\d+\\.?\\d*E*\\d*)([bBsSlLfFdD]?)$");
public static String toJson(NBTTagCompound tag) {
return toJson(toJsonObject(tag));
}
public static String toJson(JsonElement json) {
final String jsonString = json.toString();
return gson.toJson(parser.parse(jsonString));
return json.toString();
}
@SuppressWarnings("unchecked")
@@ -50,9 +42,11 @@ public class NBTJson {
final Map<String, NBTBase> tagMap = (Map<String, NBTBase>)nbtTagCompound.tagMap;
JsonObject root = new JsonObject();
for (Map.Entry<String, NBTBase> nbtEntry : tagMap.entrySet() ) {
for (Map.Entry<String, NBTBase> nbtEntry : tagMap.entrySet()) {
root.add(nbtEntry.getKey(), toJsonObject(nbtEntry.getValue()));
}
return root;
} else if (nbt instanceof NBTTagByte) {
// Number (byte)
@@ -80,23 +74,48 @@ public class NBTJson {
return new JsonPrimitive(((NBTTagString) nbt).func_150285_a_());
} else if (nbt instanceof NBTTagList) {
// Tag List
JsonArray arr = new JsonArray();
((NBTTagList) nbt).tagList.forEach(c -> arr.add(toJsonObject((NBTBase) c)));
return arr;
final NBTTagList list = (NBTTagList) nbt;
if (list.tagList.isEmpty()) {
return createEmptyList(list);
} else {
JsonArray arr = new JsonArray();
list.tagList.forEach(c -> arr.add(toJsonObject((NBTBase) c)));
return arr;
}
} else if (nbt instanceof NBTTagIntArray) {
// Int Array
JsonArray arr = new JsonArray();
for(int i : ((NBTTagIntArray) nbt).func_150302_c()) {
arr.add(new JsonPrimitive(i));
final NBTTagIntArray list = (NBTTagIntArray) nbt;
if (list.func_150302_c().length == 0) {
return createEmptyList(list);
} else {
JsonArray arr = new JsonArray();
for (int i : list.func_150302_c()) {
arr.add(new JsonPrimitive(i));
}
return arr;
}
return arr;
} else if (nbt instanceof NBTTagByteArray) {
// Byte Array
JsonArray arr = new JsonArray();
for(int i : ((NBTTagByteArray) nbt).func_150292_c()) {
arr.add(new JsonPrimitive(i));
final NBTTagByteArray list = (NBTTagByteArray) nbt;
if (list.func_150292_c().length == 0) {
return createEmptyList(list);
} else {
JsonArray arr = new JsonArray();
for (byte i : list.func_150292_c()) {
arr.add(new JsonPrimitive(Byte.toString(i) + 'B'));
}
return arr;
}
return arr;
} else {
throw new IllegalArgumentException("Unsupported NBT Tag: " + NBTBase.NBTTypes[nbt.getId()] + " - " + nbt);
}
@@ -108,7 +127,7 @@ public class NBTJson {
final JsonPrimitive jsonPrimitive = (JsonPrimitive) jsonElement;
final String jsonString = jsonPrimitive.getAsString();
final Matcher m = numberPattern.matcher(jsonString);
if(m.find()) {
if (m.find()) {
// Number
final String numberString = m.group(1);
if (m.groupCount() == 2 && m.group(2).length() > 0) {
@@ -152,7 +171,13 @@ public class NBTJson {
if (nbtList.stream().allMatch(n -> n instanceof NBTTagInt)) {
return new NBTTagIntArray(nbtList.stream().mapToInt(i -> ((NBTTagInt)i).func_150287_d() ).toArray());
} else if (nbtList.stream().allMatch(n -> n instanceof NBTTagByte)) {
return new NBTTagByteArray(toByteArray(nbtList.stream().mapToInt(i -> ((NBTTagInt)i).func_150287_d() )));
final byte[] abyte = new byte[nbtList.size()];
for (int i = 0; i < nbtList.size(); i++) {
abyte[i] = ((NBTTagByte) nbtList.get(i)).func_150290_f();
}
return new NBTTagByteArray(abyte);
} else {
NBTTagList nbtTagList = new NBTTagList();
nbtList.forEach(nbtTagList::appendTag);
@@ -163,18 +188,43 @@ public class NBTJson {
} else if (jsonElement instanceof JsonObject) {
// NBTTagCompound
final JsonObject jsonObject = (JsonObject) jsonElement;
NBTTagCompound nbtTagCompound = new NBTTagCompound();
for (Map.Entry<String, JsonElement> jsonEntry : jsonObject.entrySet()) {
nbtTagCompound.setTag(jsonEntry.getKey(), toNbt(jsonEntry.getValue()));
final NBTBase custom = restoreEmptyList(jsonObject);
if (custom == null) {
NBTTagCompound nbtTagCompound = new NBTTagCompound();
for (Map.Entry<String, JsonElement> jsonEntry : jsonObject.entrySet()) {
nbtTagCompound.setTag(jsonEntry.getKey(), toNbt(jsonEntry.getValue()));
}
return nbtTagCompound;
} else {
return custom;
}
return nbtTagCompound;
}
throw new IllegalArgumentException("Unhandled element " + jsonElement);
}
public static byte[] toByteArray(IntStream stream) {
return stream.collect(ByteArrayOutputStream::new, (baos, i) -> baos.write((byte) i), (baos1, baos2) -> baos1.write(baos2.toByteArray(), 0, baos2.size()))
.toByteArray();
protected static JsonObject createEmptyList(Object obj)
{
JsonObject empty = new JsonObject();
empty.add("__custom_type", new JsonPrimitive(obj.getClass().getName()));
return empty;
}
protected static NBTBase restoreEmptyList(JsonObject obj)
{
if (obj.has("__custom_type")) {
try {
final String className = obj.get("__custom_type").getAsString();
return (NBTBase)Class.forName(className).newInstance();
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException th) {}
}
return null;
}
}
@@ -0,0 +1,56 @@
AdvancedSolarPanel:hybrid_solar_helmet,Damage
BuildCraft|Transport:pipeFacade
DraconicEvolution:draconicAxe,tag.Energy
DraconicEvolution:draconicPickaxe,tag.Energy
DraconicEvolution:wyvernPickaxe,tag.Energy
ExtraUtilities:microblocks,Damage
Forestry:beePrincessGE,tag.Genome.Chromosomes
ForgeMicroblock:microblock,Damage
Genetics:serumArray,tag.genes
GraviSuite:itemPlasmaCell,tag.Fluid.FluidName
IC2:itemCropSeed,tag.name
IC2:itemFluidCell,tag.Fluid.FluidName
NodalMechanics:item.nodalmechanics.matrix,tag.Aspects.0.key
TConstruct:ArrowAmmo,tag.InfiTool
TConstruct:BoltAmmo,tag.InfiTool
TConstruct:Crossbow,tag.InfiTool
TConstruct:Javelin,tag.InfiTool
TConstruct:LongBow,tag.InfiTool
TConstruct:ShortBow,tag.InfiTool
TConstruct:Shuriken,tag.InfiTool
TConstruct:ThrowingKnife,tag.InfiTool
TConstruct:battleaxe,tag.InfiTool
TConstruct:battlesign,tag.InfiTool
TConstruct:broadsword,tag.InfiTool
TConstruct:chisel,tag.InfiTool
TConstruct:cleaver,tag.InfiTool
TConstruct:cutlass,tag.InfiTool
TConstruct:dagger,tag.InfiTool
TConstruct:excavator,tag.InfiTool
TConstruct:frypan,tag.InfiTool
TConstruct:hammer,tag.InfiTool
TConstruct:hatchet,tag.InfiTool
TConstruct:longsword,tag.InfiTool
TConstruct:lumberaxe,tag.InfiTool
TConstruct:mattock,tag.InfiTool
TConstruct:pickaxe,tag.InfiTool
TConstruct:potionLauncher
TConstruct:rapier,tag.InfiTool
TConstruct:scythe,tag.InfiTool
TConstruct:shovel,tag.InfiTool
Thaumcraft:ItemEssence,tag.Aspects.0.key
Thaumcraft:ItemWispEssence,tag.Aspects.0.key
WitchingGadgets:item.WG_InfusedGem,tag.Aspect
adventurebackpack:adventureBackpack,Damage
appliedenergistics2:item.ItemFacade
bartworks:BioLabParts,Damage,tag.Name
battlegear2:knights_armour.boots
battlegear2:knights_armour.helmet
battlegear2:knights_armour.legs
battlegear2:knights_armour.plate
miscutils:itemBlueprint
miscutils:particleIon,Damage
miscutils:personalHealingDevice
tectech:item.em.debugContainer,tag.symbols
tinkersdefense:Heater Shield,tag.InfiTool
tinkersdefense:Round Shield,tag.InfiTool
+17 -1
View File
@@ -111,6 +111,9 @@ nei.options.inventory=Inventory
nei.options.inventory.worldSpecificBookmarks=World Specific Bookmarks
nei.options.inventory.worldSpecificBookmarks.true=Yes
nei.options.inventory.worldSpecificBookmarks.false=No
nei.options.inventory.worldSpecificPresets=World Specific Presets
nei.options.inventory.worldSpecificPresets.true=Yes
nei.options.inventory.worldSpecificPresets.false=No
nei.options.inventory.bookmarksEnabled=Bookmarks Panel Visibility
nei.options.inventory.bookmarksEnabled.true=Visible
nei.options.inventory.bookmarksEnabled.false=Hidden
@@ -231,8 +234,12 @@ nei.recipe.shaped=Shaped Crafting
nei.recipe.shapeless=Shapeless Crafting
nei.recipe.furnace=Smelting
nei.recipe.fuel=Fuel
nei.recipe.fuel.smeltCount=Smelts %s items
# Deprecated
nei.recipe.fuel.required=%s required
# Deprecated
nei.recipe.fuel.processed=%s processed
# Deprecated
nei.recipe.fuel.produced=%s produced
nei.recipe.firework=Fireworks
nei.recipe.firework.tooltip0=Dyes add colours to the charges
@@ -277,4 +284,13 @@ nei.subsets.Items.Tools.Shovels=Shovels
nei.subsets.Items.Weapons=Weapons
nei.subsets.Items.Weapons.Ranged=Ranged
nei.subsets.Items.Weapons.Swords=Swords
nei.subsets.Mod=Mod
nei.subsets.Mod=Mod
nei.presets.blacklist.label=B
nei.presets.blacklist.tooltip=Blacklist
nei.presets.whitelist.label=W
nei.presets.whitelist.tooltip=Whitelist
nei.presets.textfield.tooltip.1=Enter - save
nei.presets.textfield.tooltip.2=Escape - cancel
nei.presets.label.tooltip=Double click to edit
nei.presets.label.selected=%s Presets
@@ -108,6 +108,9 @@ nei.options.keys.world.creative=游戏模式
nei.options.keys.world.creative.tip=循环游戏模式
nei.options.inventory=物品栏
nei.options.inventory.worldSpecificBookmarks=书签存储位置
nei.options.inventory.worldSpecificBookmarks.true=存档内
nei.options.inventory.worldSpecificBookmarks.false=全局
nei.options.inventory.bookmarksEnabled=显示/隐藏书签页
nei.options.inventory.bookmarksEnabled.true=显示
nei.options.inventory.bookmarksEnabled.false=隐藏
@@ -117,6 +120,9 @@ nei.options.inventory.jei_style_tabs.false=否 [不会吧]
nei.options.inventory.jei_style_item_presence_overlay=JEI风格物品覆盖?-悬停
nei.options.inventory.jei_style_item_presence_overlay.true=是
nei.options.inventory.jei_style_item_presence_overlay.false=否
nei.options.inventory.jei_style_recipe_catalyst=JEI风格可执行合成表机器显示[测试中]
nei.options.inventory.jei_style_recipe_catalyst.true=是
nei.options.inventory.jei_style_recipe_catalyst.false=否
nei.options.inventory.saveCurrentRecipeInBookmarksEnabled=保存书签中的当前合成表
nei.options.inventory.saveCurrentRecipeInBookmarksEnabled.true=启用
nei.options.inventory.saveCurrentRecipeInBookmarksEnabled.false=禁用
+3 -3
View File
@@ -1,7 +1,7 @@
{
"repo": "https://github.com/GTNewHorizons/CodeChickenLib/releases/download/1.1.4.1/",
"file": "CodeChickenLib-1.7.10-1.1.4.1.jar",
"dev": "CodeChickenLib-1.7.10-1.1.4.1-dev.jar",
"repo": "https://github.com/GTNewHorizons/CodeChickenLib/releases/download/1.1.5.3/",
"file": "CodeChickenLib-1.7.10-1.1.5.3.jar",
"dev": "CodeChickenLib-1.7.10-1.1.5.3-dev.jar",
"class": "codechicken.lib.asm.ASMHelper",
"coreLib": true
}
+1 -1
View File
@@ -4,7 +4,7 @@
"name": "${modName}",
"version": "${modVersion}",
"mcversion": "${minecraftVersion}",
"description": "Recipe Viewer, Inventory Manager, Item Spawner, Cheats and more; GTNH Version includes many ehancements.",
"description": "Recipe Viewer, Inventory Manager, Item Spawner, Cheats and more; GTNH Version includes many enhancements.",
"url": "https://github.com/GTNewHorizons/NotEnoughItems",
"credits": "Alexandria - original idea",
"license": "LGPL-3.0",