mirror of
https://github.com/GTNewHorizons/CraftTweaker.git
synced 2026-11-26 23:03:12 +00:00
Compare commits
28
Commits
3.2.7
...
translator
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8fcb36d394 | ||
|
|
f9db90268e | ||
|
|
e7cd5e602d | ||
|
|
65e1f469ae | ||
|
|
7fe4150afc | ||
|
|
03ca9b2055 | ||
|
|
dff620805a | ||
|
|
bd80583381 | ||
|
|
1bb66c6402 | ||
|
|
4b21e3e833 | ||
|
|
ea3b258225 | ||
|
|
a28945f5f1 | ||
|
|
4e3c2c1b79 | ||
|
|
69b28b3bd4 | ||
|
|
60c3c9056d | ||
|
|
bebd499076 | ||
|
|
6376aff61f | ||
|
|
a309488cdf | ||
|
|
6b208b98bc | ||
|
|
e9a6a085b5 | ||
|
|
1afc652dc4 | ||
|
|
356fbdbdcc | ||
|
|
1d76f7db78 | ||
|
|
8abb3efbfb | ||
|
|
b86eeb4cc6 | ||
|
|
a7f9afb6c4 | ||
|
|
236744c74e | ||
|
|
eb2b529dea |
No files matched your search
@@ -0,0 +1,2 @@
|
|||||||
|
# Ignore spotlessApply reformat
|
||||||
|
a309488cdf7837ae1a27fab25305405ca7fe34e9
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
* text eol=lf
|
||||||
|
|
||||||
|
*.[jJ][aA][rR] binary
|
||||||
|
|
||||||
|
*.[pP][nN][gG] binary
|
||||||
|
*.[jJ][pP][gG] binary
|
||||||
|
*.[jJ][pP][eE][gG] binary
|
||||||
|
*.[gG][iI][fF] binary
|
||||||
|
*.[tT][iI][fF] binary
|
||||||
|
*.[tT][iI][fF][fF] binary
|
||||||
|
*.[iI][cC][oO] binary
|
||||||
|
*.[sS][vV][gG] text
|
||||||
|
*.[eE][pP][sS] binary
|
||||||
|
*.[xX][cC][fF] binary
|
||||||
|
|
||||||
|
*.[kK][aA][rR] binary
|
||||||
|
*.[mM]4[aA] binary
|
||||||
|
*.[mM][iI][dD] binary
|
||||||
|
*.[mM][iI][dD][iI] binary
|
||||||
|
*.[mM][pP]3 binary
|
||||||
|
*.[oO][gG][gG] binary
|
||||||
|
*.[rR][aA] binary
|
||||||
|
|
||||||
|
*.7[zZ] binary
|
||||||
|
*.[gG][zZ] binary
|
||||||
|
*.[tT][aA][rR] binary
|
||||||
|
*.[tT][gG][zZ] binary
|
||||||
|
*.[zZ][iI][pP] binary
|
||||||
|
|
||||||
|
*.[tT][cC][nN] binary
|
||||||
|
*.[sS][oO] binary
|
||||||
|
*.[dD][lL][lL] binary
|
||||||
|
*.[dD][yY][lL][iI][bB] binary
|
||||||
|
*.[pP][sS][dD] binary
|
||||||
|
*.[tT][tT][fF] binary
|
||||||
|
*.[oO][tT][fF] binary
|
||||||
|
|
||||||
|
*.[pP][aA][tT][cC][hH] -text
|
||||||
|
|
||||||
|
*.[bB][aA][tT] text eol=crlf
|
||||||
|
*.[cC][mM][dD] text eol=crlf
|
||||||
|
*.[pP][sS]1 text eol=crlf
|
||||||
|
|
||||||
|
*[aA][uU][tT][oO][gG][eE][nN][eE][rR][aA][tT][eE][dD]* binary
|
||||||
@@ -1,5 +1,3 @@
|
|||||||
# 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://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
|
|
||||||
|
|
||||||
name: Build and test
|
name: Build and test
|
||||||
|
|
||||||
@@ -11,35 +9,5 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-and-test:
|
build-and-test:
|
||||||
runs-on: ubuntu-latest
|
uses: GTNewHorizons/GTNH-Actions-Workflows/.github/workflows/build-and-test.yml@master
|
||||||
steps:
|
secrets: inherit
|
||||||
- uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: Set up JDK 8
|
|
||||||
uses: actions/setup-java@v2
|
|
||||||
with:
|
|
||||||
java-version: '8'
|
|
||||||
distribution: 'adopt'
|
|
||||||
cache: gradle
|
|
||||||
|
|
||||||
- name: Grant execute permission for gradlew
|
|
||||||
run: chmod +x gradlew
|
|
||||||
|
|
||||||
- name: Setup the workspace
|
|
||||||
run: ./gradlew setupCIWorkspace
|
|
||||||
|
|
||||||
- name: Build the mod
|
|
||||||
run: ./gradlew build
|
|
||||||
|
|
||||||
- name: Run server for 1.5 minutes
|
|
||||||
run: |
|
|
||||||
mkdir run
|
|
||||||
echo "eula=true" > run/eula.txt
|
|
||||||
timeout 90 ./gradlew runServer 2>&1 | tee -a server.log || true
|
|
||||||
|
|
||||||
- name: Test no errors reported during server run
|
|
||||||
run: |
|
|
||||||
chmod +x .github/scripts/test_no_error_reports
|
|
||||||
.github/scripts/test_no_error_reports
|
|
||||||
@@ -1,51 +1,14 @@
|
|||||||
# 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://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
|
|
||||||
|
|
||||||
name: Release tagged build
|
name: Release tagged build
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
tags:
|
tags: [ '*' ]
|
||||||
- '*'
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
release-tags:
|
||||||
runs-on: ubuntu-latest
|
uses: GTNewHorizons/GTNH-Actions-Workflows/.github/workflows/release-tags.yml@master
|
||||||
steps:
|
secrets: inherit
|
||||||
- uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: Set release version
|
|
||||||
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
- name: Set up JDK 8
|
|
||||||
uses: actions/setup-java@v2
|
|
||||||
with:
|
|
||||||
java-version: '8'
|
|
||||||
distribution: 'adopt'
|
|
||||||
cache: gradle
|
|
||||||
|
|
||||||
- name: Grant execute permission for gradlew
|
|
||||||
run: chmod +x gradlew
|
|
||||||
|
|
||||||
- name: Setup the workspace
|
|
||||||
run: ./gradlew setupCIWorkspace
|
|
||||||
|
|
||||||
- name: Build the mod
|
|
||||||
run: ./gradlew build
|
|
||||||
|
|
||||||
- name: Release under current tag
|
|
||||||
uses: "marvinpinto/action-automatic-releases@latest"
|
|
||||||
with:
|
|
||||||
repo_token: "${{ secrets.GITHUB_TOKEN }}"
|
|
||||||
automatic_release_tag: "${{ env.RELEASE_VERSION }}"
|
|
||||||
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 }}
|
|
||||||
+8
-5
@@ -1,9 +1,12 @@
|
|||||||
import minetweaker.tasks.RegisterZenClassesTask
|
import minetweaker.tasks.RegisterZenClassesTask
|
||||||
|
|
||||||
task makeRegistry(type: RegisterZenClassesTask) {
|
def makeRegistryTask = tasks.register('makeRegistry', RegisterZenClassesTask) {
|
||||||
inputDir = file("build/classes/java/main/")
|
dependsOn("compileJava")
|
||||||
outputDir = file("build/classes/java/main/")
|
inputDir.set(file("build/classes/java/main/"))
|
||||||
className = "minetweaker.mc1710.MineTweakerRegistry"
|
outputDir.set(file("build/classes/java/main/"))
|
||||||
|
className.set("minetweaker.mc1710.MineTweakerRegistry")
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.classes.dependsOn(makeRegistry)
|
tasks.named("classes").configure {
|
||||||
|
dependsOn(makeRegistryTask)
|
||||||
|
}
|
||||||
+1069
-339
File diff suppressed because it is too large.
Load diff
+18
-6
@@ -1,9 +1,21 @@
|
|||||||
import javax.tools.ToolProvider
|
import java.io.File
|
||||||
|
|
||||||
apply plugin: 'java'
|
plugins {
|
||||||
|
id("java")
|
||||||
|
}
|
||||||
|
|
||||||
|
java {
|
||||||
|
toolchain {
|
||||||
|
languageVersion.set(JavaLanguageVersion.of(8))
|
||||||
|
vendor.set(JvmVendorSpec.ADOPTIUM)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//Make sure JAVA_HOME is set as an environment variable
|
//Make sure JAVA_HOME is set as an environment variable
|
||||||
ext.javaToolsJar = ((URLClassLoader) ToolProvider.getSystemToolClassLoader()).getURLs()
|
ext.javaToolsJar = files(
|
||||||
|
javaToolchains.compilerFor(java.toolchain).map { tc ->
|
||||||
|
new File(tc.executablePath.asFile.parentFile.parentFile, "lib/tools.jar")
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
@@ -11,7 +23,7 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile gradleApi()
|
gradleApi()
|
||||||
compile 'org.ow2.asm:asm-debug-all:5.0.3'
|
implementation 'org.ow2.asm:asm-debug-all:5.0.3'
|
||||||
compile files(javaToolsJar)
|
implementation files(javaToolsJar)
|
||||||
}
|
}
|
||||||
@@ -11,8 +11,11 @@ import java.util.List;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import org.gradle.api.DefaultTask;
|
import org.gradle.api.DefaultTask;
|
||||||
|
import org.gradle.api.file.DirectoryProperty;
|
||||||
|
import org.gradle.api.provider.Property;
|
||||||
import org.gradle.api.tasks.Input;
|
import org.gradle.api.tasks.Input;
|
||||||
import org.gradle.api.tasks.InputDirectory;
|
import org.gradle.api.tasks.InputDirectory;
|
||||||
|
import org.gradle.api.tasks.Optional;
|
||||||
import org.gradle.api.tasks.OutputDirectory;
|
import org.gradle.api.tasks.OutputDirectory;
|
||||||
import org.gradle.api.tasks.TaskAction;
|
import org.gradle.api.tasks.TaskAction;
|
||||||
import org.objectweb.asm.AnnotationVisitor;
|
import org.objectweb.asm.AnnotationVisitor;
|
||||||
@@ -31,30 +34,29 @@ import org.objectweb.asm.Type;
|
|||||||
*
|
*
|
||||||
* @author Stan Hebben
|
* @author Stan Hebben
|
||||||
*/
|
*/
|
||||||
public class RegisterZenClassesTask extends DefaultTask {
|
public abstract class RegisterZenClassesTask extends DefaultTask {
|
||||||
@InputDirectory
|
@InputDirectory
|
||||||
public File inputDir;
|
public abstract DirectoryProperty getInputDir();
|
||||||
|
|
||||||
@OutputDirectory
|
@OutputDirectory
|
||||||
public File outputDir = null;
|
@Optional
|
||||||
|
public abstract DirectoryProperty getOutputDir();
|
||||||
public void setInputDir(File inputDir) {
|
|
||||||
this.inputDir = inputDir;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOutputDir(File inputDir) {
|
|
||||||
this.outputDir = inputDir;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Input
|
@Input
|
||||||
public String className;
|
public abstract Property<String> getClassName();
|
||||||
|
|
||||||
|
public RegisterZenClassesTask() {
|
||||||
|
getOutputDir().convention(getInputDir());
|
||||||
|
}
|
||||||
|
|
||||||
@TaskAction
|
@TaskAction
|
||||||
public void doTask() {
|
public void doTask() {
|
||||||
if (outputDir == null) outputDir = inputDir;
|
final File inputDir = getInputDir().get().getAsFile();
|
||||||
|
final File outputDir = getOutputDir().get().getAsFile();
|
||||||
|
final String className = getClassName().get();
|
||||||
|
|
||||||
List<String> classNames = new ArrayList<String>();
|
List<String> classNames = new ArrayList<>();
|
||||||
List<OnRegisterMethod> onRegisterMethods = new ArrayList<OnRegisterMethod>();
|
List<OnRegisterMethod> onRegisterMethods = new ArrayList<>();
|
||||||
iterate(inputDir, null, classNames, onRegisterMethods);
|
iterate(inputDir, null, classNames, onRegisterMethods);
|
||||||
|
|
||||||
String fullClassName = className.replace('.', '/');
|
String fullClassName = className.replace('.', '/');
|
||||||
@@ -69,11 +71,11 @@ public class RegisterZenClassesTask extends DefaultTask {
|
|||||||
for (String clsName : classNames) {
|
for (String clsName : classNames) {
|
||||||
method.visitVarInsn(Opcodes.ALOAD, 0);
|
method.visitVarInsn(Opcodes.ALOAD, 0);
|
||||||
method.visitLdcInsn(Type.getType("L" + clsName + ";"));
|
method.visitLdcInsn(Type.getType("L" + clsName + ";"));
|
||||||
method.visitMethodInsn(Opcodes.INVOKEINTERFACE, "java/util/List", "add", "(Ljava/lang/Object;)Z");
|
method.visitMethodInsn(Opcodes.INVOKEINTERFACE, "java/util/List", "add", "(Ljava/lang/Object;)Z", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (OnRegisterMethod onRegisterMethod : onRegisterMethods) {
|
for (OnRegisterMethod onRegisterMethod : onRegisterMethods) {
|
||||||
method.visitMethodInsn(Opcodes.INVOKESTATIC, onRegisterMethod.className, onRegisterMethod.methodName, "()V");
|
method.visitMethodInsn(Opcodes.INVOKESTATIC, onRegisterMethod.className, onRegisterMethod.methodName, "()V", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
method.visitInsn(Opcodes.RETURN);
|
method.visitInsn(Opcodes.RETURN);
|
||||||
@@ -93,10 +95,8 @@ public class RegisterZenClassesTask extends DefaultTask {
|
|||||||
outputFile.delete();
|
outputFile.delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try(FileOutputStream outputStream = new FileOutputStream(outputFile)) {
|
||||||
FileOutputStream outputStream = new FileOutputStream(outputFile);
|
|
||||||
outputStream.write(output.toByteArray());
|
outputStream.write(output.toByteArray());
|
||||||
outputStream.close();
|
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
Logger.getLogger(RegisterZenClassesTask.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(RegisterZenClassesTask.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
@@ -119,8 +119,7 @@ public class RegisterZenClassesTask extends DefaultTask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void processJavaClass(File cls, String pkg, List<String> classNames, List<OnRegisterMethod> onRegisterMethods) {
|
private void processJavaClass(File cls, String pkg, List<String> classNames, List<OnRegisterMethod> onRegisterMethods) {
|
||||||
try {
|
try(InputStream input = new BufferedInputStream(new FileInputStream(cls))) {
|
||||||
InputStream input = new BufferedInputStream(new FileInputStream(cls));
|
|
||||||
ClassReader reader = new ClassReader(input);
|
ClassReader reader = new ClassReader(input);
|
||||||
|
|
||||||
AnnotationDetector detector = new AnnotationDetector();
|
AnnotationDetector detector = new AnnotationDetector();
|
||||||
@@ -142,10 +141,10 @@ public class RegisterZenClassesTask extends DefaultTask {
|
|||||||
|
|
||||||
private static class AnnotationDetector extends ClassVisitor {
|
private static class AnnotationDetector extends ClassVisitor {
|
||||||
private boolean isAnnotated = false;
|
private boolean isAnnotated = false;
|
||||||
private List<MethodAnnotationDetector> onRegister = new ArrayList<MethodAnnotationDetector>();
|
private List<MethodAnnotationDetector> onRegister = new ArrayList<>();
|
||||||
|
|
||||||
public AnnotationDetector() {
|
public AnnotationDetector() {
|
||||||
super(Opcodes.ASM4);
|
super(Opcodes.ASM5);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+3
-3
@@ -1,5 +1,5 @@
|
|||||||
dependencies {
|
dependencies {
|
||||||
shadeCompile("com.github.GTNewHorizons:ZenScript:1.0.0-GTNH")
|
shadowImplementation("com.github.GTNewHorizons:ZenScript:1.0.0-GTNH")
|
||||||
compile("net.industrial-craft:industrialcraft-2:2.2.828-experimental:dev")
|
implementation("net.industrial-craft:industrialcraft-2:2.2.828-experimental:dev")
|
||||||
compile("com.github.GTNewHorizons:NotEnoughItems:2.2.9-GTNH:dev")
|
implementation("com.github.GTNewHorizons:NotEnoughItems:2.3.45-GTNH:dev")
|
||||||
}
|
}
|
||||||
+17
-6
@@ -21,16 +21,19 @@ forgeVersion = 10.13.4.1614
|
|||||||
# Do you need to test how your custom blocks interacts with a player that is not the owner? -> leave name empty
|
# 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:
|
# Generate a class with String fields for the mod id, name, version and group name named with the fields below
|
||||||
|
generateGradleTokenClass = minetweaker.mc1710.Tags
|
||||||
|
gradleTokenModId =
|
||||||
|
gradleTokenModName =
|
||||||
|
gradleTokenVersion = MOD_VERSION
|
||||||
|
gradleTokenGroupName =
|
||||||
|
# [DEPRECATED]
|
||||||
|
# Multiple source files can be defined here by providing a comma-seperated list: Class1.java,Class2.java,Class3.java
|
||||||
# public static final String VERSION = "GRADLETOKEN_VERSION";
|
# public static final String VERSION = "GRADLETOKEN_VERSION";
|
||||||
# The string's content will be replaced with your mod's 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, [...])
|
# version in @Mod([...], version = VERSION, [...])
|
||||||
# Leave these properties empty to skip individual token replacements
|
# Leave these properties empty to skip individual token replacements
|
||||||
replaceGradleTokenInFile = MineTweakerMod.java
|
replaceGradleTokenInFile =
|
||||||
gradleTokenModId =
|
|
||||||
gradleTokenModName =
|
|
||||||
gradleTokenVersion =
|
|
||||||
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.
|
# leave this property empty.
|
||||||
@@ -60,6 +63,14 @@ containsMixinsAndOrCoreModOnly = false
|
|||||||
# If enabled, you may use 'shadowCompile' for dependencies. They will be integrated in your jar. It is your
|
# If enabled, you may use 'shadowCompile' for dependencies. They will be integrated in your jar. It is your
|
||||||
# responsibility check the licence and request permission for distribution, if required.
|
# responsibility check the licence and request permission for distribution, if required.
|
||||||
usesShadowedDependencies = true
|
usesShadowedDependencies = true
|
||||||
|
# If disabled, won't remove unused classes from shaded dependencies. Some libraries use reflection to access
|
||||||
|
# their own classes, making the minimization unreliable.
|
||||||
|
minimizeShadowedDependencies = false
|
||||||
|
# If disabled, won't rename the shadowed classes.
|
||||||
|
relocateShadowedDependencies = false
|
||||||
|
|
||||||
|
# Adds the GTNH maven, CurseMaven, IC2/Player maven, and some more well-known 1.7.10 repositories
|
||||||
|
includeWellKnownRepositories = true
|
||||||
|
|
||||||
# Optional parameter to customize the produced artifacts. Use this to preserver artifact naming when migrating older
|
# Optional parameter to customize the produced artifacts. Use this to preserver artifact naming when migrating older
|
||||||
# projects. New projects should not use this parameter.
|
# projects. New projects should not use this parameter.
|
||||||
|
|||||||
Vendored
BIN
Binary file not shown.
+2
-1
@@ -1,5 +1,6 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
|
||||||
|
networkTimeout=10000
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.1-bin.zip
|
|
||||||
@@ -1,78 +1,129 @@
|
|||||||
#!/usr/bin/env bash
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright © 2015-2021 the original authors.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
##
|
#
|
||||||
## Gradle start up script for UN*X
|
# Gradle start up script for POSIX generated by Gradle.
|
||||||
##
|
#
|
||||||
|
# Important for running:
|
||||||
|
#
|
||||||
|
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||||
|
# noncompliant, but you have some other compliant shell such as ksh or
|
||||||
|
# bash, then to run this script, type that shell name before the whole
|
||||||
|
# command line, like:
|
||||||
|
#
|
||||||
|
# ksh Gradle
|
||||||
|
#
|
||||||
|
# Busybox and similar reduced shells will NOT work, because this script
|
||||||
|
# requires all of these POSIX shell features:
|
||||||
|
# * functions;
|
||||||
|
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||||
|
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||||
|
# * compound commands having a testable exit status, especially «case»;
|
||||||
|
# * various built-in commands including «command», «set», and «ulimit».
|
||||||
|
#
|
||||||
|
# Important for patching:
|
||||||
|
#
|
||||||
|
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||||
|
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||||
|
#
|
||||||
|
# The "traditional" practice of packing multiple parameters into a
|
||||||
|
# space-separated string is a well documented source of bugs and security
|
||||||
|
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||||
|
# options in "$@", and eventually passing that to Java.
|
||||||
|
#
|
||||||
|
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||||
|
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||||
|
# see the in-line comments for details.
|
||||||
|
#
|
||||||
|
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||||
|
# Darwin, MinGW, and NonStop.
|
||||||
|
#
|
||||||
|
# (3) This script is generated from the Groovy template
|
||||||
|
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||||
|
# within the Gradle project.
|
||||||
|
#
|
||||||
|
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||||
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
# Attempt to set APP_HOME
|
# Attempt to set APP_HOME
|
||||||
# Resolve links: $0 may be a link
|
|
||||||
PRG="$0"
|
|
||||||
# Need this for relative symlinks.
|
|
||||||
while [ -h "$PRG" ] ; do
|
|
||||||
ls=`ls -ld "$PRG"`
|
|
||||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
|
||||||
if expr "$link" : '/.*' > /dev/null; then
|
|
||||||
PRG="$link"
|
|
||||||
else
|
|
||||||
PRG=`dirname "$PRG"`"/$link"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
SAVED="`pwd`"
|
|
||||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
|
||||||
APP_HOME="`pwd -P`"
|
|
||||||
cd "$SAVED" >/dev/null
|
|
||||||
|
|
||||||
APP_NAME="Gradle"
|
# Resolve links: $0 may be a link
|
||||||
APP_BASE_NAME=`basename "$0"`
|
app_path=$0
|
||||||
|
|
||||||
|
# Need this for daisy-chained symlinks.
|
||||||
|
while
|
||||||
|
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||||
|
[ -h "$app_path" ]
|
||||||
|
do
|
||||||
|
ls=$( ls -ld "$app_path" )
|
||||||
|
link=${ls#*' -> '}
|
||||||
|
case $link in #(
|
||||||
|
/*) app_path=$link ;; #(
|
||||||
|
*) app_path=$APP_HOME$link ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
# This is normally unused
|
||||||
|
# shellcheck disable=SC2034
|
||||||
|
APP_BASE_NAME=${0##*/}
|
||||||
|
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||||
|
|
||||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
DEFAULT_JVM_OPTS=""
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
MAX_FD="maximum"
|
MAX_FD=maximum
|
||||||
|
|
||||||
warn () {
|
warn () {
|
||||||
echo "$*"
|
echo "$*"
|
||||||
}
|
} >&2
|
||||||
|
|
||||||
die () {
|
die () {
|
||||||
echo
|
echo
|
||||||
echo "$*"
|
echo "$*"
|
||||||
echo
|
echo
|
||||||
exit 1
|
exit 1
|
||||||
}
|
} >&2
|
||||||
|
|
||||||
# OS specific support (must be 'true' or 'false').
|
# OS specific support (must be 'true' or 'false').
|
||||||
cygwin=false
|
cygwin=false
|
||||||
msys=false
|
msys=false
|
||||||
darwin=false
|
darwin=false
|
||||||
nonstop=false
|
nonstop=false
|
||||||
case "`uname`" in
|
case "$( uname )" in #(
|
||||||
CYGWIN* )
|
CYGWIN* ) cygwin=true ;; #(
|
||||||
cygwin=true
|
Darwin* ) darwin=true ;; #(
|
||||||
;;
|
MSYS* | MINGW* ) msys=true ;; #(
|
||||||
Darwin* )
|
NONSTOP* ) nonstop=true ;;
|
||||||
darwin=true
|
|
||||||
;;
|
|
||||||
MINGW* )
|
|
||||||
msys=true
|
|
||||||
;;
|
|
||||||
NONSTOP* )
|
|
||||||
nonstop=true
|
|
||||||
;;
|
|
||||||
esac
|
esac
|
||||||
|
|
||||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||||
|
|
||||||
|
|
||||||
# Determine the Java command to use to start the JVM.
|
# Determine the Java command to use to start the JVM.
|
||||||
if [ -n "$JAVA_HOME" ] ; then
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
# IBM's JDK on AIX uses strange locations for the executables
|
# IBM's JDK on AIX uses strange locations for the executables
|
||||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||||
else
|
else
|
||||||
JAVACMD="$JAVA_HOME/bin/java"
|
JAVACMD=$JAVA_HOME/bin/java
|
||||||
fi
|
fi
|
||||||
if [ ! -x "$JAVACMD" ] ; then
|
if [ ! -x "$JAVACMD" ] ; then
|
||||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||||
@@ -81,7 +132,7 @@ Please set the JAVA_HOME variable in your environment to match the
|
|||||||
location of your Java installation."
|
location of your Java installation."
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
JAVACMD="java"
|
JAVACMD=java
|
||||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
|
||||||
Please set the JAVA_HOME variable in your environment to match the
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
@@ -89,76 +140,105 @@ location of your Java installation."
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Increase the maximum file descriptors if we can.
|
# Increase the maximum file descriptors if we can.
|
||||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||||
MAX_FD_LIMIT=`ulimit -H -n`
|
case $MAX_FD in #(
|
||||||
if [ $? -eq 0 ] ; then
|
max*)
|
||||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||||
MAX_FD="$MAX_FD_LIMIT"
|
# shellcheck disable=SC3045
|
||||||
fi
|
MAX_FD=$( ulimit -H -n ) ||
|
||||||
ulimit -n $MAX_FD
|
warn "Could not query maximum file descriptor limit"
|
||||||
if [ $? -ne 0 ] ; then
|
esac
|
||||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
case $MAX_FD in #(
|
||||||
fi
|
'' | soft) :;; #(
|
||||||
else
|
*)
|
||||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||||
fi
|
# shellcheck disable=SC3045
|
||||||
fi
|
ulimit -n "$MAX_FD" ||
|
||||||
|
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||||
# For Darwin, add options to specify how the application appears in the dock
|
|
||||||
if $darwin; then
|
|
||||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
|
||||||
fi
|
|
||||||
|
|
||||||
# For Cygwin, switch paths to Windows format before running java
|
|
||||||
if $cygwin ; then
|
|
||||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
|
||||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
|
||||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
|
||||||
|
|
||||||
# We build the pattern for arguments to be converted via cygpath
|
|
||||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
|
||||||
SEP=""
|
|
||||||
for dir in $ROOTDIRSRAW ; do
|
|
||||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
|
||||||
SEP="|"
|
|
||||||
done
|
|
||||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
|
||||||
# Add a user-defined pattern to the cygpath arguments
|
|
||||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
|
||||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
|
||||||
fi
|
|
||||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
|
||||||
i=0
|
|
||||||
for arg in "$@" ; do
|
|
||||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
|
||||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
|
||||||
|
|
||||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
|
||||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
|
||||||
else
|
|
||||||
eval `echo args$i`="\"$arg\""
|
|
||||||
fi
|
|
||||||
i=$((i+1))
|
|
||||||
done
|
|
||||||
case $i in
|
|
||||||
(0) set -- ;;
|
|
||||||
(1) set -- "$args0" ;;
|
|
||||||
(2) set -- "$args0" "$args1" ;;
|
|
||||||
(3) set -- "$args0" "$args1" "$args2" ;;
|
|
||||||
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
|
||||||
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
|
||||||
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
|
||||||
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
|
||||||
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
|
||||||
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
|
# Collect all arguments for the java command, stacking in reverse order:
|
||||||
function splitJvmOpts() {
|
# * args from the command line
|
||||||
JVM_OPTS=("$@")
|
# * the main class name
|
||||||
}
|
# * -classpath
|
||||||
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
|
# * -D...appname settings
|
||||||
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
|
# * --module-path (only if needed)
|
||||||
|
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||||
|
|
||||||
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
|
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||||
|
if "$cygwin" || "$msys" ; then
|
||||||
|
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||||
|
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||||
|
|
||||||
|
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||||
|
|
||||||
|
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||||
|
for arg do
|
||||||
|
if
|
||||||
|
case $arg in #(
|
||||||
|
-*) false ;; # don't mess with options #(
|
||||||
|
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||||
|
[ -e "$t" ] ;; #(
|
||||||
|
*) false ;;
|
||||||
|
esac
|
||||||
|
then
|
||||||
|
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||||
|
fi
|
||||||
|
# Roll the args list around exactly as many times as the number of
|
||||||
|
# args, so each arg winds up back in the position where it started, but
|
||||||
|
# possibly modified.
|
||||||
|
#
|
||||||
|
# NB: a `for` loop captures its iteration list before it begins, so
|
||||||
|
# changing the positional parameters here affects neither the number of
|
||||||
|
# iterations, nor the values presented in `arg`.
|
||||||
|
shift # remove old arg
|
||||||
|
set -- "$@" "$arg" # push replacement arg
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Collect all arguments for the java command;
|
||||||
|
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||||
|
# shell script including quotes and variable substitutions, so put them in
|
||||||
|
# double quotes to make sure that they get re-expanded; and
|
||||||
|
# * put everything else in single quotes, so that it's not re-expanded.
|
||||||
|
|
||||||
|
set -- \
|
||||||
|
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||||
|
-classpath "$CLASSPATH" \
|
||||||
|
org.gradle.wrapper.GradleWrapperMain \
|
||||||
|
"$@"
|
||||||
|
|
||||||
|
# Stop when "xargs" is not available.
|
||||||
|
if ! command -v xargs >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
die "xargs is not available"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Use "xargs" to parse quoted args.
|
||||||
|
#
|
||||||
|
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||||
|
#
|
||||||
|
# In Bash we could simply go:
|
||||||
|
#
|
||||||
|
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||||
|
# set -- "${ARGS[@]}" "$@"
|
||||||
|
#
|
||||||
|
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||||
|
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||||
|
# character that might be a shell metacharacter, then use eval to reverse
|
||||||
|
# that process (while maintaining the separation between arguments), and wrap
|
||||||
|
# the whole thing up as a single "set" statement.
|
||||||
|
#
|
||||||
|
# This will of course break if any of these variables contains a newline or
|
||||||
|
# an unmatched quote.
|
||||||
|
#
|
||||||
|
|
||||||
|
eval "set -- $(
|
||||||
|
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||||
|
xargs -n1 |
|
||||||
|
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||||
|
tr '\n' ' '
|
||||||
|
)" '"$@"'
|
||||||
|
|
||||||
|
exec "$JAVACMD" "$@"
|
||||||
Vendored
+30
-28
@@ -1,3 +1,19 @@
|
|||||||
|
@rem
|
||||||
|
@rem Copyright 2015 the original author or authors.
|
||||||
|
@rem
|
||||||
|
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
@rem you may not use this file except in compliance with the License.
|
||||||
|
@rem You may obtain a copy of the License at
|
||||||
|
@rem
|
||||||
|
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
@rem
|
||||||
|
@rem Unless required by applicable law or agreed to in writing, software
|
||||||
|
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
@rem See the License for the specific language governing permissions and
|
||||||
|
@rem limitations under the License.
|
||||||
|
@rem
|
||||||
|
|
||||||
@if "%DEBUG%"=="" @echo off
|
@if "%DEBUG%"=="" @echo off
|
||||||
@rem ##########################################################################
|
@rem ##########################################################################
|
||||||
@rem
|
@rem
|
||||||
@@ -10,18 +26,22 @@ if "%OS%"=="Windows_NT" setlocal
|
|||||||
|
|
||||||
set DIRNAME=%~dp0
|
set DIRNAME=%~dp0
|
||||||
if "%DIRNAME%"=="" set DIRNAME=.
|
if "%DIRNAME%"=="" set DIRNAME=.
|
||||||
|
@rem This is normally unused
|
||||||
set APP_BASE_NAME=%~n0
|
set APP_BASE_NAME=%~n0
|
||||||
set APP_HOME=%DIRNAME%
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
|
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||||
|
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||||
|
|
||||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
set DEFAULT_JVM_OPTS=
|
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||||
|
|
||||||
@rem Find java.exe
|
@rem Find java.exe
|
||||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||||
|
|
||||||
set JAVA_EXE=java.exe
|
set JAVA_EXE=java.exe
|
||||||
%JAVA_EXE% -version >NUL 2>&1
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
if "%ERRORLEVEL%" == "0" goto init
|
if %ERRORLEVEL% equ 0 goto execute
|
||||||
|
|
||||||
echo.
|
echo.
|
||||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
@@ -35,7 +55,7 @@ goto fail
|
|||||||
set JAVA_HOME=%JAVA_HOME:"=%
|
set JAVA_HOME=%JAVA_HOME:"=%
|
||||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||||
|
|
||||||
if exist "%JAVA_EXE%" goto init
|
if exist "%JAVA_EXE%" goto execute
|
||||||
|
|
||||||
echo.
|
echo.
|
||||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||||
@@ -45,44 +65,26 @@ echo location of your Java installation.
|
|||||||
|
|
||||||
goto fail
|
goto fail
|
||||||
|
|
||||||
:init
|
|
||||||
@rem Get command-line arguments, handling Windows variants
|
|
||||||
|
|
||||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
|
||||||
if "%@eval[2+2]" == "4" goto 4NT_args
|
|
||||||
|
|
||||||
:win9xME_args
|
|
||||||
@rem Slurp the command line arguments.
|
|
||||||
set CMD_LINE_ARGS=
|
|
||||||
set _SKIP=2
|
|
||||||
|
|
||||||
:win9xME_args_slurp
|
|
||||||
if "x%~1" == "x" goto execute
|
|
||||||
|
|
||||||
set CMD_LINE_ARGS=%*
|
|
||||||
goto execute
|
|
||||||
|
|
||||||
:4NT_args
|
|
||||||
@rem Get arguments from the 4NT Shell from JP Software
|
|
||||||
set CMD_LINE_ARGS=%$
|
|
||||||
|
|
||||||
:execute
|
:execute
|
||||||
@rem Setup the command line
|
@rem Setup the command line
|
||||||
|
|
||||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||||
|
|
||||||
|
|
||||||
@rem Execute Gradle
|
@rem Execute Gradle
|
||||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||||
|
|
||||||
:end
|
:end
|
||||||
@rem End local scope for the variables with windows NT shell
|
@rem End local scope for the variables with windows NT shell
|
||||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||||
|
|
||||||
:fail
|
:fail
|
||||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||||
rem the _cmd.exe /c_ return code!
|
rem the _cmd.exe /c_ return code!
|
||||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
set EXIT_CODE=%ERRORLEVEL%
|
||||||
exit /b 1
|
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||||
|
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||||
|
exit /b %EXIT_CODE%
|
||||||
|
|
||||||
:mainEnd
|
:mainEnd
|
||||||
if "%OS%"=="Windows_NT" endlocal
|
if "%OS%"=="Windows_NT" endlocal
|
||||||
|
|||||||
+2
-11
@@ -2,19 +2,10 @@
|
|||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
maven {
|
maven {
|
||||||
name = "GTNH"
|
name = "GTNH Maven"
|
||||||
url = "http://jenkins.usrv.eu:8081/nexus/content/groups/public/"
|
url = "http://jenkins.usrv.eu:8081/nexus/content/groups/public/"
|
||||||
}
|
}
|
||||||
maven {
|
maven {
|
||||||
name = "ic2"
|
url "https://cursemaven.com"
|
||||||
url = "https://maven.ic2.player.to/"
|
|
||||||
metadataSources {
|
|
||||||
mavenPom()
|
|
||||||
artifact()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
maven {
|
|
||||||
name = "jitpack.io"
|
|
||||||
url = "https://jitpack.io"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
|
||||||
|
pluginManagement {
|
||||||
|
repositories {
|
||||||
|
maven {
|
||||||
|
// RetroFuturaGradle
|
||||||
|
name "GTNH Maven"
|
||||||
|
url "http://jenkins.usrv.eu:8081/nexus/content/groups/public/"
|
||||||
|
allowInsecureProtocol = true
|
||||||
|
mavenContent {
|
||||||
|
includeGroup("com.gtnewhorizons.retrofuturagradle")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
gradlePluginPortal()
|
||||||
|
mavenCentral()
|
||||||
|
mavenLocal()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
id 'com.diffplug.blowdryerSetup' version '1.6.0'
|
||||||
|
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.4.0' // Provides java toolchains
|
||||||
|
}
|
||||||
|
|
||||||
|
blowdryerSetup {
|
||||||
|
repoSubfolder 'gtnhShared'
|
||||||
|
github('GTNewHorizons/ExampleMod1.7.10', 'tag', '0.2.0')
|
||||||
|
//devLocal '.' // Use this when testing config updates locally
|
||||||
|
}
|
||||||
@@ -3,12 +3,12 @@ package minetweaker;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The class registry provides the list of annotated classes to the scripting
|
* The class registry provides the list of annotated classes to the scripting system.
|
||||||
* system.
|
|
||||||
*
|
*
|
||||||
* @author Stan Hebben
|
* @author Stan Hebben
|
||||||
*/
|
*/
|
||||||
public class ClassRegistry {
|
public class ClassRegistry {
|
||||||
|
|
||||||
public static void getClasses(List<Class> output) {
|
public static void getClasses(List<Class> output) {
|
||||||
// no longer needed. kept to not break anyone who reference this
|
// no longer needed. kept to not break anyone who reference this
|
||||||
// seriously though, why would anyone want to look at this registry anyway
|
// seriously though, why would anyone want to look at this registry anyway
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package minetweaker;
|
package minetweaker;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import stanhebben.zenscript.compiler.IEnvironmentGlobal;
|
import stanhebben.zenscript.compiler.IEnvironmentGlobal;
|
||||||
import stanhebben.zenscript.parser.Token;
|
import stanhebben.zenscript.parser.Token;
|
||||||
import stanhebben.zenscript.symbols.IZenSymbol;
|
import stanhebben.zenscript.symbols.IZenSymbol;
|
||||||
@@ -8,17 +9,17 @@ import stanhebben.zenscript.symbols.IZenSymbol;
|
|||||||
/**
|
/**
|
||||||
* Bracket handlers enable processing of the bracket syntax.
|
* Bracket handlers enable processing of the bracket syntax.
|
||||||
*
|
*
|
||||||
* Inside brackets, any kind of token is acceptable except the closing bracket.
|
* Inside brackets, any kind of token is acceptable except the closing bracket. (>) Bracket handlers (multiple
|
||||||
* (>) Bracket handlers (multiple handlers can be registered) will resolve
|
* handlers can be registered) will resolve these tokens into actual values. Values have to be ZenScript symbols and
|
||||||
* these tokens into actual values. Values have to be ZenScript symbols and will
|
* will resolve at compile-time.
|
||||||
* resolve at compile-time.
|
|
||||||
*
|
*
|
||||||
* These may of course return an expression that are executed on run-time, but
|
* These may of course return an expression that are executed on run-time, but the type of the resulting value must be
|
||||||
* the type of the resulting value must be known compile-time.
|
* known compile-time.
|
||||||
*
|
*
|
||||||
* @author Stan Hebben
|
* @author Stan Hebben
|
||||||
*/
|
*/
|
||||||
public interface IBracketHandler {
|
public interface IBracketHandler {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resolves a set of tokens.
|
* Resolves a set of tokens.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -4,12 +4,13 @@ import minetweaker.api.chat.IChatMessage;
|
|||||||
import minetweaker.api.item.IItemDefinition;
|
import minetweaker.api.item.IItemDefinition;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Platform functions are a set of internal functions implemented by the
|
* Platform functions are a set of internal functions implemented by the platform intended to communicate between API
|
||||||
* platform intended to communicate between API and implementation.
|
* and implementation.
|
||||||
*
|
*
|
||||||
* @author Stan Hebben
|
* @author Stan Hebben
|
||||||
*/
|
*/
|
||||||
public interface IPlatformFunctions {
|
public interface IPlatformFunctions {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a string into a chat message.
|
* Converts a string into a chat message.
|
||||||
*
|
*
|
||||||
@@ -19,8 +20,7 @@ public interface IPlatformFunctions {
|
|||||||
public IChatMessage getMessage(String message);
|
public IChatMessage getMessage(String message);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Distributes the given script data to all connected clients. Automatically
|
* Distributes the given script data to all connected clients. Automatically reloads the scripts from this data.
|
||||||
* reloads the scripts from this data.
|
|
||||||
*
|
*
|
||||||
* @param data data to be distributed
|
* @param data data to be distributed
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -3,12 +3,13 @@ package minetweaker;
|
|||||||
import minetweaker.api.item.IIngredient;
|
import minetweaker.api.item.IIngredient;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to register removable mod recipes for mod machines. Once registered, it
|
* Used to register removable mod recipes for mod machines. Once registered, it will be called when minetweaker.remove()
|
||||||
* will be called when minetweaker.remove() is called.
|
* is called.
|
||||||
*
|
*
|
||||||
* @author Stan Hebben
|
* @author Stan Hebben
|
||||||
*/
|
*/
|
||||||
public interface IRecipeRemover {
|
public interface IRecipeRemover {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes all the items matching the given ingredient.
|
* Removes all the items matching the given ingredient.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -3,82 +3,70 @@ package minetweaker;
|
|||||||
/**
|
/**
|
||||||
* Defines a (possibly) undoable action.
|
* Defines a (possibly) undoable action.
|
||||||
*
|
*
|
||||||
* Every modification made by a command must be registered to the Tweaker with
|
* Every modification made by a command must be registered to the Tweaker with the Tweaker.apply method. This enables
|
||||||
* the Tweaker.apply method. This enables MineTweaker to keep track of actions
|
* MineTweaker to keep track of actions that have been performed, and enables them to be rolled back later on.
|
||||||
* that have been performed, and enables them to be rolled back later on.
|
|
||||||
*
|
*
|
||||||
* Actions exist in two flavors: undoable and permanent. If an action returns
|
* Actions exist in two flavors: undoable and permanent. If an action returns canUndo(), the action is undoable,
|
||||||
* canUndo(), the action is undoable, otherwise it is permanent. Permanent
|
* otherwise it is permanent. Permanent actions cannot be used in server scripts.
|
||||||
* actions cannot be used in server scripts.
|
|
||||||
*
|
*
|
||||||
* There also exist semi-permanent actions. Those actions can return an override
|
* There also exist semi-permanent actions. Those actions can return an override key; if a newer action has the same
|
||||||
* key; if a newer action has the same override key as an old action, the new
|
* override key as an old action, the new action is considered to override the old one.
|
||||||
* action is considered to override the old one.
|
|
||||||
*
|
*
|
||||||
* Likewise, actions can implement hashCode and equals methods to indicate that
|
* Likewise, actions can implement hashCode and equals methods to indicate that they are equal. If an action is equal to
|
||||||
* they are equal. If an action is equal to a non-undoable stuck action, it will
|
* a non-undoable stuck action, it will be omitted from execution.
|
||||||
* be omitted from execution.
|
|
||||||
*
|
*
|
||||||
* @author Stan Hebben
|
* @author Stan Hebben
|
||||||
*/
|
*/
|
||||||
public interface IUndoableAction {
|
public interface IUndoableAction {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes what the action is supposed to do. This method can be called
|
* Executes what the action is supposed to do. This method can be called again if undo() has been called in between.
|
||||||
* again if undo() has been called in between.
|
|
||||||
*/
|
*/
|
||||||
public void apply();
|
public void apply();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if this action can be undone. If this method returns true, it must
|
* Checks if this action can be undone. If this method returns true, it must implement undo() properly. If this
|
||||||
* implement undo() properly. If this method returns false, the action is
|
* method returns false, the action is considered permanent, undo() will never be called, and the action cannot be
|
||||||
* considered permanent, undo() will never be called, and the action cannot
|
* executed as part of a server script. Additionally, the minetweaker.clear() function will not work and
|
||||||
* be executed as part of a server script. Additionally, the
|
* minetweaker.canClear will return false.
|
||||||
* minetweaker.clear() function will not work and minetweaker.canClear will
|
|
||||||
* return false.
|
|
||||||
*
|
*
|
||||||
* @return undoable status
|
* @return undoable status
|
||||||
*/
|
*/
|
||||||
public boolean canUndo();
|
public boolean canUndo();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Undoes the action. Will only be called after apply() has been executed.
|
* Undoes the action. Will only be called after apply() has been executed. After an undo, apply may be called again.
|
||||||
* After an undo, apply may be called again. They could be done multiple
|
* They could be done multiple times in certain scenarios.
|
||||||
* times in certain scenarios.
|
|
||||||
*/
|
*/
|
||||||
public void undo();
|
public void undo();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Describes, in a single human-readable sentence, what this specific action
|
* Describes, in a single human-readable sentence, what this specific action is doing. Used in logging messages,
|
||||||
* is doing. Used in logging messages, lists, ...
|
* lists, ...
|
||||||
*
|
*
|
||||||
* Try to be as descriptive as possible without being too verbose.
|
* Try to be as descriptive as possible without being too verbose.
|
||||||
*
|
*
|
||||||
* Examples: - Adding Peach planks to the woodPlanks ore dictionary entry -
|
* Examples: - Adding Peach planks to the woodPlanks ore dictionary entry - Removing a recipe for Iron Ore
|
||||||
* Removing a recipe for Iron Ore
|
|
||||||
*
|
*
|
||||||
* @return the description of this action
|
* @return the description of this action
|
||||||
*/
|
*/
|
||||||
public String describe();
|
public String describe();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Describes what this action does if it is undone. Similar to the
|
* Describes what this action does if it is undone. Similar to the describe() method. No implementation is needed if
|
||||||
* describe() method. No implementation is needed if the action cannot be
|
* the action cannot be undone.
|
||||||
* undone.
|
|
||||||
*
|
*
|
||||||
* @return the description of this action, when undone
|
* @return the description of this action, when undone
|
||||||
*/
|
*/
|
||||||
public String describeUndo();
|
public String describeUndo();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the override key. Two actions are considered to override each
|
* Returns the override key. Two actions are considered to override each other if their override key is equal. You
|
||||||
* other if their override key is equal. You can return null to indicate
|
* can return null to indicate that an action can never be overridden.
|
||||||
* that an action can never be overridden.
|
|
||||||
*
|
*
|
||||||
* This value only makes sense for recipes that are not undoable. For
|
* This value only makes sense for recipes that are not undoable. For undoable recipes, you should return null.
|
||||||
* undoable recipes, you should return null.
|
|
||||||
*
|
*
|
||||||
* @return override key (null for actions that are undoable or which can
|
* @return override key (null for actions that are undoable or which can never be overridden by another action)
|
||||||
* never be overridden by another action)
|
|
||||||
*/
|
*/
|
||||||
public Object getOverrideKey();
|
public Object getOverrideKey();
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,25 @@
|
|||||||
package minetweaker;
|
package minetweaker;
|
||||||
|
|
||||||
|
import java.lang.annotation.Annotation;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.lang.reflect.Modifier;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
|
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
|
||||||
|
import cpw.mods.fml.common.registry.GameRegistry;
|
||||||
import minetweaker.annotations.BracketHandler;
|
import minetweaker.annotations.BracketHandler;
|
||||||
import minetweaker.annotations.ModOnly;
|
import minetweaker.annotations.ModOnly;
|
||||||
import minetweaker.api.client.IClient;
|
import minetweaker.api.client.IClient;
|
||||||
@@ -7,8 +27,13 @@ import minetweaker.api.compat.*;
|
|||||||
import minetweaker.api.event.IEventManager;
|
import minetweaker.api.event.IEventManager;
|
||||||
import minetweaker.api.formatting.IFormatter;
|
import minetweaker.api.formatting.IFormatter;
|
||||||
import minetweaker.api.game.IGame;
|
import minetweaker.api.game.IGame;
|
||||||
|
import minetweaker.api.item.IIngredient;
|
||||||
|
import minetweaker.api.item.IItemStack;
|
||||||
|
import minetweaker.api.item.IngredientItem;
|
||||||
import minetweaker.api.mods.ILoadedMods;
|
import minetweaker.api.mods.ILoadedMods;
|
||||||
import minetweaker.api.oredict.IOreDict;
|
import minetweaker.api.oredict.IOreDict;
|
||||||
|
import minetweaker.api.oredict.IOreDictEntry;
|
||||||
|
import minetweaker.api.oredict.IngredientOreDict;
|
||||||
import minetweaker.api.recipes.IFurnaceManager;
|
import minetweaker.api.recipes.IFurnaceManager;
|
||||||
import minetweaker.api.recipes.IRecipeManager;
|
import minetweaker.api.recipes.IRecipeManager;
|
||||||
import minetweaker.api.server.IServer;
|
import minetweaker.api.server.IServer;
|
||||||
@@ -26,49 +51,182 @@ import stanhebben.zenscript.symbols.SymbolJavaStaticMethod;
|
|||||||
import stanhebben.zenscript.type.natives.IJavaMethod;
|
import stanhebben.zenscript.type.natives.IJavaMethod;
|
||||||
import stanhebben.zenscript.type.natives.JavaMethod;
|
import stanhebben.zenscript.type.natives.JavaMethod;
|
||||||
|
|
||||||
import java.lang.annotation.Annotation;
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.lang.reflect.Modifier;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides access to the MineTweaker API.
|
* Provides access to the MineTweaker API.
|
||||||
*
|
*
|
||||||
* An implementing platform needs to do the following: - Set a logger - Set the
|
* An implementing platform needs to do the following: - Set a logger - Set the ore dictionary - Set the recipe manager
|
||||||
* ore dictionary - Set the recipe manager - Set the furnace manager - Set event
|
* - Set the furnace manager - Set event manager - Set resource manager
|
||||||
* manager - Set resource manager
|
|
||||||
*
|
*
|
||||||
* - Register additional global symbols to the GlobalRegistry (recipes,
|
* - Register additional global symbols to the GlobalRegistry (recipes, minetweaker, oreDict, logger, as well as the
|
||||||
* minetweaker, oreDict, logger, as well as the official set of functions) -
|
* official set of functions) - Register native classes using the GlobalRegistry - Register bracket handlers to resolve
|
||||||
* Register native classes using the GlobalRegistry - Register bracket handlers
|
* block/item/... references using the bracket syntax
|
||||||
* to resolve block/item/... references using the bracket syntax
|
|
||||||
*
|
*
|
||||||
* @author Stan Hebben
|
* @author Stan Hebben
|
||||||
*/
|
*/
|
||||||
public class MineTweakerAPI {
|
public class MineTweakerAPI {
|
||||||
public static final String[] COLOR_NAMES = {
|
|
||||||
"White",
|
private static final org.apache.logging.log4j.Logger TRANSLATORLOGGER = LogManager
|
||||||
"Orange",
|
.getLogger("[SCRIPTS TO CODE TRANSLATOR]");
|
||||||
"Magenta",
|
|
||||||
"Light Blue",
|
public static void info(String log) {
|
||||||
"Yellow",
|
TRANSLATORLOGGER.info(log);
|
||||||
"Lime",
|
}
|
||||||
"Pink",
|
|
||||||
"Gray",
|
public static String convertStack(ItemStack stack) {
|
||||||
"Light Gray",
|
if (stack == null) return "null";
|
||||||
"Cyan",
|
GameRegistry.UniqueIdentifier itemIdentifier = GameRegistry.findUniqueIdentifierFor(stack.getItem());
|
||||||
"Purple",
|
int meta = stack.getItemDamage();
|
||||||
"Blue",
|
int size = stack.stackSize;
|
||||||
"Brown",
|
NBTTagCompound tagCompound = stack.stackTagCompound;
|
||||||
"Green",
|
if (tagCompound == null || tagCompound.hasNoTags()) {
|
||||||
"Red",
|
return "getModItem(\"" + itemIdentifier.modId
|
||||||
"Black"
|
+ "\", \""
|
||||||
|
+ itemIdentifier.name
|
||||||
|
+ "\", "
|
||||||
|
+ size
|
||||||
|
+ ", "
|
||||||
|
+ meta
|
||||||
|
+ ", missing)";
|
||||||
|
} else {
|
||||||
|
return "createItemStack(\"" + itemIdentifier.modId
|
||||||
|
+ "\", \""
|
||||||
|
+ itemIdentifier.name
|
||||||
|
+ "\", "
|
||||||
|
+ size
|
||||||
|
+ ", "
|
||||||
|
+ meta
|
||||||
|
+ ", "
|
||||||
|
+ "\""
|
||||||
|
+ tagCompound.toString().replace("\"", "\\\"")
|
||||||
|
+ "\""
|
||||||
|
+ ", missing)";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String convertStack(IIngredient ingredient) {
|
||||||
|
Object internal = ingredient.getInternal();
|
||||||
|
if (internal instanceof ItemStack) return convertStack((ItemStack) internal);
|
||||||
|
else return "ERRORSTACK";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String convertStackOrOre(IIngredient ingredient) {
|
||||||
|
Object internal = ingredient.getInternal();
|
||||||
|
if (internal instanceof ItemStack) return convertStack((ItemStack) internal);
|
||||||
|
else if (internal instanceof String) return "\"" + (String) internal + "\"";
|
||||||
|
else return "ERRORSTACK";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String convertArrayInLine(Object[] arr) {
|
||||||
|
StringBuilder arrayString = new StringBuilder();
|
||||||
|
for (int i = 0, arrLength = arr.length; i < arrLength; i++) {
|
||||||
|
Object o = arr[i];
|
||||||
|
if (o instanceof String) arrayString.append("\"").append((String) o).append("\"");
|
||||||
|
else if (o instanceof Character) arrayString.append("'").append((char) o).append("'");
|
||||||
|
else if (o instanceof ItemStack) arrayString.append(convertStack((ItemStack) o));
|
||||||
|
else if (o instanceof IItemStack || o instanceof IngredientItem)
|
||||||
|
arrayString.append(convertStack((IIngredient) o));
|
||||||
|
else if (o instanceof IOreDictEntry)
|
||||||
|
arrayString.append("\"").append((String) ((IOreDictEntry) o).getInternal()).append("\"");
|
||||||
|
else if (o instanceof IngredientOreDict)
|
||||||
|
arrayString.append("\"").append((String) ((IngredientOreDict) o).getInternal()).append("\"");
|
||||||
|
else if (o == null) arrayString.append("null");
|
||||||
|
else arrayString.append(o);
|
||||||
|
if (i + 1 < arrLength) arrayString.append(", ");
|
||||||
|
}
|
||||||
|
return arrayString.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String convert2DArrayInLine(Object[][] arr) {
|
||||||
|
StringBuilder arrayString = new StringBuilder();
|
||||||
|
for (int i = 0, arrLength = arr.length; i < arrLength; i++) {
|
||||||
|
for (int j = 0, jarrLength = arr[i].length; j < jarrLength; j++) {
|
||||||
|
Object o = arr[i][j];
|
||||||
|
if (o instanceof String) arrayString.append("\"").append((String) o).append("\"");
|
||||||
|
else if (o instanceof Character) arrayString.append("'").append((char) o).append("'");
|
||||||
|
else if (o instanceof ItemStack) arrayString.append(convertStack((ItemStack) o));
|
||||||
|
else if (o instanceof IItemStack || o instanceof IngredientItem)
|
||||||
|
arrayString.append(convertStack((IIngredient) o));
|
||||||
|
else if (o instanceof IOreDictEntry)
|
||||||
|
arrayString.append("\"").append((String) ((IOreDictEntry) o).getInternal()).append("\"");
|
||||||
|
else if (o instanceof IngredientOreDict)
|
||||||
|
arrayString.append("\"").append((String) ((IngredientOreDict) o).getInternal()).append("\"");
|
||||||
|
else if (o == null) arrayString.append("null");
|
||||||
|
else arrayString.append(o);
|
||||||
|
if (i + 1 < arrLength || j + 1 < jarrLength) arrayString.append(", ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return arrayString.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void logGTRecipe(ItemStack[] itemInputs, ItemStack[] itemOutputs, int[] chances,
|
||||||
|
FluidStack[] fluidInputs, FluidStack[] fluidOutputs, int duration, int eut, Integer specialValue,
|
||||||
|
String recipeMapVariable) {
|
||||||
|
StringBuilder builder = new StringBuilder("GT_Values.RA.stdBuilder()");
|
||||||
|
Function<ItemStack[], ItemStack[]> isAllObjectsNullItemStack = arr -> {
|
||||||
|
if (arr == null || arr.length == 0 || Arrays.stream(arr).allMatch(Objects::isNull)) return null;
|
||||||
|
return Arrays.stream(arr).filter(Objects::nonNull).toArray(ItemStack[]::new);
|
||||||
};
|
};
|
||||||
|
Function<FluidStack[], FluidStack[]> isAllObjectsNullFluidStack = arr -> {
|
||||||
|
if (arr == null || arr.length == 0 || Arrays.stream(arr).allMatch(Objects::isNull)) return null;
|
||||||
|
return Arrays.stream(arr).filter(Objects::nonNull).toArray(FluidStack[]::new);
|
||||||
|
};
|
||||||
|
itemInputs = isAllObjectsNullItemStack.apply(itemInputs);
|
||||||
|
itemOutputs = isAllObjectsNullItemStack.apply(itemOutputs);
|
||||||
|
fluidInputs = isAllObjectsNullFluidStack.apply(fluidInputs);
|
||||||
|
fluidOutputs = isAllObjectsNullFluidStack.apply(fluidOutputs);
|
||||||
|
if (itemInputs == null || itemInputs.length == 0) builder.append(".noItemInputs()");
|
||||||
|
else builder.append(".itemInputs(").append(convertArrayInLine(itemInputs)).append(")");
|
||||||
|
if (itemOutputs == null || itemOutputs.length == 0) builder.append(".noItemOutputs()");
|
||||||
|
else builder.append(".itemOutputs(").append(convertArrayInLine(itemOutputs)).append(")");
|
||||||
|
if (chances != null && chances.length > 0) builder.append(".outputChances(")
|
||||||
|
.append(convertArrayInLine(Arrays.stream(chances).boxed().toArray(Integer[]::new))).append(")");
|
||||||
|
if (fluidInputs == null || fluidInputs.length == 0) builder.append(".noFluidInputs()");
|
||||||
|
else builder.append(".fluidInputs(").append(convertArrayInLine(fluidInputs)).append(")");
|
||||||
|
if (fluidOutputs == null || fluidOutputs.length == 0) builder.append(".noFluidOutputs()");
|
||||||
|
else builder.append(".fluidOutputs(").append(convertArrayInLine(fluidOutputs)).append(")");
|
||||||
|
builder.append(".duration(").append(duration).append(")");
|
||||||
|
builder.append(".eut(").append(eut).append(")");
|
||||||
|
if (specialValue != null) builder.append(".specialValue(").append(specialValue.intValue()).append(")");
|
||||||
|
builder.append(".addTo(").append(recipeMapVariable).append(");");
|
||||||
|
|
||||||
|
info(builder.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void logGTRecipe(ItemStack[] itemInputs, ItemStack[] itemOutputs, FluidStack[] fluidInputs,
|
||||||
|
FluidStack[] fluidOutputs, int duration, int eut, String recipeMapVariable) {
|
||||||
|
logGTRecipe(itemInputs, itemOutputs, null, fluidInputs, fluidOutputs, duration, eut, null, recipeMapVariable);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void logGTRecipe(ItemStack[] itemInputs, ItemStack[] itemOutputs, int[] chances,
|
||||||
|
FluidStack[] fluidInputs, FluidStack[] fluidOutputs, int duration, int eut, String recipeMapVariable) {
|
||||||
|
logGTRecipe(
|
||||||
|
itemInputs,
|
||||||
|
itemOutputs,
|
||||||
|
chances,
|
||||||
|
fluidInputs,
|
||||||
|
fluidOutputs,
|
||||||
|
duration,
|
||||||
|
eut,
|
||||||
|
null,
|
||||||
|
recipeMapVariable);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void logGTRecipe(ItemStack[] itemInputs, ItemStack[] itemOutputs, FluidStack[] fluidInputs,
|
||||||
|
FluidStack[] fluidOutputs, int duration, int eut, int specialValue, String recipeMapVariable) {
|
||||||
|
logGTRecipe(
|
||||||
|
itemInputs,
|
||||||
|
itemOutputs,
|
||||||
|
null,
|
||||||
|
fluidInputs,
|
||||||
|
fluidOutputs,
|
||||||
|
duration,
|
||||||
|
eut,
|
||||||
|
specialValue,
|
||||||
|
recipeMapVariable);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final String[] COLOR_NAMES = { "White", "Orange", "Magenta", "Light Blue", "Yellow", "Lime", "Pink",
|
||||||
|
"Gray", "Light Gray", "Cyan", "Purple", "Blue", "Brown", "Green", "Red", "Black" };
|
||||||
private static IJEIRecipeRegistry ijeiRecipeRegistry = new DummyJEIRecipeRegistry();
|
private static IJEIRecipeRegistry ijeiRecipeRegistry = new DummyJEIRecipeRegistry();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
@@ -93,15 +251,15 @@ public class MineTweakerAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Tweaker is where you apply undoable actions. Any kind of action that
|
* The Tweaker is where you apply undoable actions. Any kind of action that reloads with the scripts should always
|
||||||
* reloads with the scripts should always be submitted to the tweaker.
|
* be submitted to the tweaker.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static final ITweaker tweaker = new MTTweaker();
|
public static final ITweaker tweaker = new MTTweaker();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The logger can be used to write logging messages to the client. Error and
|
* The logger can be used to write logging messages to the client. Error and warning messages should be relayed to
|
||||||
* warning messages should be relayed to admins for further handling.
|
* admins for further handling.
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@@ -174,8 +332,7 @@ public class MineTweakerAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logs a command message. Commands messages are those generated as output
|
* Logs a command message. Commands messages are those generated as output in response to a command.
|
||||||
* in response to a command.
|
|
||||||
*
|
*
|
||||||
* @param message command message
|
* @param message command message
|
||||||
*/
|
*/
|
||||||
@@ -184,8 +341,8 @@ public class MineTweakerAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logs an info message. Info messages have low priority and will only be
|
* Logs an info message. Info messages have low priority and will only be displayed in the log files, but not
|
||||||
* displayed in the log files, but not directly to players in-game.
|
* directly to players in-game.
|
||||||
*
|
*
|
||||||
* @param message info message
|
* @param message info message
|
||||||
*/
|
*/
|
||||||
@@ -194,10 +351,9 @@ public class MineTweakerAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logs a warning message. Warning messages are displayed to admins and
|
* Logs a warning message. Warning messages are displayed to admins and indicate that there is an issue. However,
|
||||||
* indicate that there is an issue. However, the issue is not a large
|
* the issue is not a large problem, and everything should run fine - besides perhaps a few things not entirely
|
||||||
* problem, and everything should run fine - besides perhaps a few things
|
* working as expected.
|
||||||
* not entirely working as expected.
|
|
||||||
*
|
*
|
||||||
* @param message warning message
|
* @param message warning message
|
||||||
*/
|
*/
|
||||||
@@ -206,10 +362,9 @@ public class MineTweakerAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logs an error message. Error messages indicate a real problem and
|
* Logs an error message. Error messages indicate a real problem and indicate that things won't run properly. The
|
||||||
* indicate that things won't run properly. The scripting system will still
|
* scripting system will still make a best-effort attempt at executing the rest of the scripts, but that might cause
|
||||||
* make a best-effort attempt at executing the rest of the scripts, but that
|
* additional errors and issues.
|
||||||
* might cause additional errors and issues.
|
|
||||||
*
|
*
|
||||||
* @param message error message
|
* @param message error message
|
||||||
*/
|
*/
|
||||||
@@ -218,10 +373,9 @@ public class MineTweakerAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logs an error message. Error messages indicate a real problem and
|
* Logs an error message. Error messages indicate a real problem and indicate that things won't run properly. The
|
||||||
* indicate that things won't run properly. The scripting system will still
|
* scripting system will still make a best-effort attempt at executing the rest of the scripts, but that might cause
|
||||||
* make a best-effort attempt at executing the rest of the scripts, but that
|
* additional errors and issues.
|
||||||
* might cause additional errors and issues.
|
|
||||||
*
|
*
|
||||||
* @param message error message
|
* @param message error message
|
||||||
* @param exception exception that was caught related to the error
|
* @param exception exception that was caught related to the error
|
||||||
@@ -235,9 +389,8 @@ public class MineTweakerAPI {
|
|||||||
// ###################################
|
// ###################################
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a class registry class. Such class must have (at least) a public
|
* Register a class registry class. Such class must have (at least) a public static method called "getClasses" with
|
||||||
* static method called "getClasses" with accepts a List of classes and
|
* accepts a List of classes and which stores its classes into that list.
|
||||||
* which stores its classes into that list.
|
|
||||||
*
|
*
|
||||||
* @param registryClass
|
* @param registryClass
|
||||||
*/
|
*/
|
||||||
@@ -246,9 +399,8 @@ public class MineTweakerAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a class registry class. Such class must have (at least) a public
|
* Register a class registry class. Such class must have (at least) a public static method called "getClasses" with
|
||||||
* static method called "getClasses" with accepts a List of classes and
|
* accepts a List of classes and which stores its classes into that list.
|
||||||
* which stores its classes into that list.
|
|
||||||
*
|
*
|
||||||
* @param registryClass
|
* @param registryClass
|
||||||
* @param description
|
* @param description
|
||||||
@@ -269,11 +421,9 @@ public class MineTweakerAPI {
|
|||||||
String version = ((ModOnly) annotation).version();
|
String version = ((ModOnly) annotation).version();
|
||||||
|
|
||||||
for (String mod : value) {
|
for (String mod : value) {
|
||||||
if (!loadedMods.contains(mod))
|
if (!loadedMods.contains(mod)) continue outer;
|
||||||
continue outer;
|
|
||||||
|
|
||||||
if (!loadedMods.get(mod).getVersion().startsWith(version))
|
if (!loadedMods.get(mod).getVersion().startsWith(version)) continue outer;
|
||||||
continue outer;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -281,8 +431,7 @@ public class MineTweakerAPI {
|
|||||||
MineTweakerAPI.registerClass(cls);
|
MineTweakerAPI.registerClass(cls);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (description != null)
|
if (description != null) logInfo("Loaded class registry: " + description);
|
||||||
logInfo("Loaded class registry: " + description);
|
|
||||||
}
|
}
|
||||||
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
|
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
|
||||||
if (ex.getCause() instanceof NoClassDefFoundError) {
|
if (ex.getCause() instanceof NoClassDefFoundError) {
|
||||||
@@ -294,8 +443,8 @@ public class MineTweakerAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers a class registry. Will attempt to resolve the given class name.
|
* Registers a class registry. Will attempt to resolve the given class name. Does nothing if the class could not be
|
||||||
* Does nothing if the class could not be loaded.
|
* loaded.
|
||||||
*
|
*
|
||||||
* @param className class name to be loaded
|
* @param className class name to be loaded
|
||||||
* @return true if registration was successful
|
* @return true if registration was successful
|
||||||
@@ -305,8 +454,8 @@ public class MineTweakerAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers a class registry. Will attempt to resolve the given class name.
|
* Registers a class registry. Will attempt to resolve the given class name. Does nothing if the class could not be
|
||||||
* Does nothing if the class could not be loaded.
|
* loaded.
|
||||||
*
|
*
|
||||||
* @param className class name to be loaded
|
* @param className class name to be loaded
|
||||||
* @param description
|
* @param description
|
||||||
@@ -322,9 +471,8 @@ public class MineTweakerAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers an annotated class. A class is annotated with either @ZenClass
|
* Registers an annotated class. A class is annotated with either @ZenClass or @ZenExpansion. Classes not annotated
|
||||||
* or @ZenExpansion. Classes not annotated with either of these will be
|
* with either of these will be ignored.
|
||||||
* ignored.
|
|
||||||
*
|
*
|
||||||
* @param annotatedClass
|
* @param annotatedClass
|
||||||
*/
|
*/
|
||||||
@@ -353,8 +501,7 @@ public class MineTweakerAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers a global symbol. Global symbols are immediately accessible from
|
* Registers a global symbol. Global symbols are immediately accessible from anywhere in the scripts.
|
||||||
* anywhere in the scripts.
|
|
||||||
*
|
*
|
||||||
* @param name symbol name
|
* @param name symbol name
|
||||||
* @param symbol symbol
|
* @param symbol symbol
|
||||||
@@ -364,8 +511,7 @@ public class MineTweakerAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers a recipe remover. Removers are called when the global
|
* Registers a recipe remover. Removers are called when the global minetweaker.remove() function is called.
|
||||||
* minetweaker.remove() function is called.
|
|
||||||
*
|
*
|
||||||
* @param remover recipe remover
|
* @param remover recipe remover
|
||||||
*/
|
*/
|
||||||
@@ -374,9 +520,8 @@ public class MineTweakerAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers a bracket handler. Is capable of converting the bracket syntax
|
* Registers a bracket handler. Is capable of converting the bracket syntax to an actual value. This new handler
|
||||||
* to an actual value. This new handler will be added last - it can thus not
|
* will be added last - it can thus not intercept values that are already handled by the system.
|
||||||
* intercept values that are already handled by the system.
|
|
||||||
*
|
*
|
||||||
* @param handler bracket handler to be added
|
* @param handler bracket handler to be added
|
||||||
*/
|
*/
|
||||||
@@ -398,9 +543,8 @@ public class MineTweakerAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a symbol that refers to a java getter. The getter must be a
|
* Creates a symbol that refers to a java getter. The getter must be a method with no arguments. The given symbol
|
||||||
* method with no arguments. The given symbol will act as a variable of
|
* will act as a variable of which the value can be retrieved but not set.
|
||||||
* which the value can be retrieved but not set.
|
|
||||||
*
|
*
|
||||||
* @param cls class that contains the getter method
|
* @param cls class that contains the getter method
|
||||||
* @param name name of the method
|
* @param name name of the method
|
||||||
@@ -412,9 +556,8 @@ public class MineTweakerAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a symbol that refers to a static field. The field must be an
|
* Creates a symbol that refers to a static field. The field must be an existing public field in the given class.
|
||||||
* existing public field in the given class. The field will act as a
|
* The field will act as a variable that can be retrieved but not set.
|
||||||
* variable that can be retrieved but not set.
|
|
||||||
*
|
*
|
||||||
* @param cls class that contains the field
|
* @param cls class that contains the field
|
||||||
* @param name field name (must be public)
|
* @param name field name (must be public)
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
* To change this license header, choose License Headers in Project Properties. To change this template file, choose
|
||||||
* To change this template file, choose Tools | Templates
|
* Tools | Templates and open the template in the editor.
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package minetweaker;
|
package minetweaker;
|
||||||
|
|||||||
@@ -1,5 +1,14 @@
|
|||||||
package minetweaker;
|
package minetweaker;
|
||||||
|
|
||||||
|
import static minetweaker.MineTweakerAPI.furnace;
|
||||||
|
import static minetweaker.MineTweakerAPI.server;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.datatransfer.Clipboard;
|
||||||
|
import java.awt.datatransfer.StringSelection;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import minetweaker.api.block.IBlock;
|
import minetweaker.api.block.IBlock;
|
||||||
import minetweaker.api.block.IBlockDefinition;
|
import minetweaker.api.block.IBlockDefinition;
|
||||||
import minetweaker.api.data.IData;
|
import minetweaker.api.data.IData;
|
||||||
@@ -28,22 +37,13 @@ import minetweaker.runtime.IScriptProvider;
|
|||||||
import minetweaker.util.EventList;
|
import minetweaker.util.EventList;
|
||||||
import minetweaker.util.IEventHandler;
|
import minetweaker.util.IEventHandler;
|
||||||
|
|
||||||
import java.awt.*;
|
|
||||||
import java.awt.datatransfer.Clipboard;
|
|
||||||
import java.awt.datatransfer.StringSelection;
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import static minetweaker.MineTweakerAPI.furnace;
|
|
||||||
import static minetweaker.MineTweakerAPI.server;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The implementation API is used by API implementations for internal
|
* The implementation API is used by API implementations for internal communication and initialization.
|
||||||
* communication and initialization.
|
|
||||||
*
|
*
|
||||||
* @author Stan Hebben
|
* @author Stan Hebben
|
||||||
*/
|
*/
|
||||||
public class MineTweakerImplementationAPI {
|
public class MineTweakerImplementationAPI {
|
||||||
|
|
||||||
private static Set<IPlayer> blockInfoPlayers = new HashSet<IPlayer>();
|
private static Set<IPlayer> blockInfoPlayers = new HashSet<IPlayer>();
|
||||||
private static IEventHandle blockEventHandler = null;
|
private static IEventHandle blockEventHandler = null;
|
||||||
|
|
||||||
@@ -64,12 +64,13 @@ public class MineTweakerImplementationAPI {
|
|||||||
static {
|
static {
|
||||||
minetweakerCommands = new HashMap<String, MineTweakerCommand>();
|
minetweakerCommands = new HashMap<String, MineTweakerCommand>();
|
||||||
|
|
||||||
minetweakerCommands.put("reload", new MineTweakerCommand(
|
minetweakerCommands.put(
|
||||||
"reload",
|
"reload",
|
||||||
new String[]{
|
new MineTweakerCommand(
|
||||||
"/minetweaker reload",
|
"reload",
|
||||||
" Reloads all scripts"
|
new String[] { "/minetweaker reload", " Reloads all scripts" },
|
||||||
}, new ICommandFunction() {
|
new ICommandFunction() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(String[] arguments, IPlayer player) {
|
public void execute(String[] arguments, IPlayer player) {
|
||||||
reload();
|
reload();
|
||||||
@@ -77,12 +78,14 @@ public class MineTweakerImplementationAPI {
|
|||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
minetweakerCommands.put("names", new MineTweakerCommand(
|
minetweakerCommands.put(
|
||||||
"names",
|
"names",
|
||||||
new String[]{
|
new MineTweakerCommand(
|
||||||
"/minetweaker names",
|
"names",
|
||||||
" Outputs a list of all item names in the game to the minetweaker log"
|
new String[] { "/minetweaker names",
|
||||||
}, new ICommandFunction() {
|
" Outputs a list of all item names in the game to the minetweaker log" },
|
||||||
|
new ICommandFunction() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(String[] arguments, IPlayer player) {
|
public void execute(String[] arguments, IPlayer player) {
|
||||||
List<IItemDefinition> items = MineTweakerAPI.game.getItems();
|
List<IItemDefinition> items = MineTweakerAPI.game.getItems();
|
||||||
@@ -111,12 +114,14 @@ public class MineTweakerImplementationAPI {
|
|||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
minetweakerCommands.put("liquids", new MineTweakerCommand(
|
minetweakerCommands.put(
|
||||||
"liquids",
|
"liquids",
|
||||||
new String[]{
|
new MineTweakerCommand(
|
||||||
"/minetweaker liquids",
|
"liquids",
|
||||||
" Outputs a list of all liquid names in the game to the minetweaker log"
|
new String[] { "/minetweaker liquids",
|
||||||
}, new ICommandFunction() {
|
" Outputs a list of all liquid names in the game to the minetweaker log" },
|
||||||
|
new ICommandFunction() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(String[] arguments, IPlayer player) {
|
public void execute(String[] arguments, IPlayer player) {
|
||||||
List<ILiquidDefinition> liquids = MineTweakerAPI.game.getLiquids();
|
List<ILiquidDefinition> liquids = MineTweakerAPI.game.getLiquids();
|
||||||
@@ -124,7 +129,8 @@ public class MineTweakerImplementationAPI {
|
|||||||
|
|
||||||
MineTweakerAPI.logCommand("Liquids:");
|
MineTweakerAPI.logCommand("Liquids:");
|
||||||
for (ILiquidDefinition liquid : liquids) {
|
for (ILiquidDefinition liquid : liquids) {
|
||||||
MineTweakerAPI.logCommand("<liquid:" + liquid.getName() + ">, " + liquid.getDisplayName());
|
MineTweakerAPI.logCommand(
|
||||||
|
"<liquid:" + liquid.getName() + ">, " + liquid.getDisplayName());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
@@ -133,12 +139,14 @@ public class MineTweakerImplementationAPI {
|
|||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
minetweakerCommands.put("blocks", new MineTweakerCommand(
|
minetweakerCommands.put(
|
||||||
"blocks",
|
"blocks",
|
||||||
new String[]{
|
new MineTweakerCommand(
|
||||||
"/minetweaker blocks",
|
"blocks",
|
||||||
" Outputs a list of all blocks in the game to the minetweaker log"
|
new String[] { "/minetweaker blocks",
|
||||||
}, new ICommandFunction() {
|
" Outputs a list of all blocks in the game to the minetweaker log" },
|
||||||
|
new ICommandFunction() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(String[] arguments, IPlayer player) {
|
public void execute(String[] arguments, IPlayer player) {
|
||||||
List<IBlockDefinition> blocks = MineTweakerAPI.game.getBlocks();
|
List<IBlockDefinition> blocks = MineTweakerAPI.game.getBlocks();
|
||||||
@@ -146,7 +154,8 @@ public class MineTweakerImplementationAPI {
|
|||||||
|
|
||||||
MineTweakerAPI.logCommand("Blocks:");
|
MineTweakerAPI.logCommand("Blocks:");
|
||||||
for (IBlockDefinition block : blocks) {
|
for (IBlockDefinition block : blocks) {
|
||||||
MineTweakerAPI.logCommand("<block:" + block.getId() + ">, " + block.getDisplayName());
|
MineTweakerAPI
|
||||||
|
.logCommand("<block:" + block.getId() + ">, " + block.getDisplayName());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
@@ -155,12 +164,14 @@ public class MineTweakerImplementationAPI {
|
|||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
minetweakerCommands.put("entities", new MineTweakerCommand(
|
minetweakerCommands.put(
|
||||||
"entities",
|
"entities",
|
||||||
new String[]{
|
new MineTweakerCommand(
|
||||||
"/minetweaker entities",
|
"entities",
|
||||||
" Outputs a list of all entity definitions in the game to the minetweaker log"
|
new String[] { "/minetweaker entities",
|
||||||
}, new ICommandFunction() {
|
" Outputs a list of all entity definitions in the game to the minetweaker log" },
|
||||||
|
new ICommandFunction() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(String[] arguments, IPlayer player) {
|
public void execute(String[] arguments, IPlayer player) {
|
||||||
List<IEntityDefinition> entities = MineTweakerAPI.game.getEntities();
|
List<IEntityDefinition> entities = MineTweakerAPI.game.getEntities();
|
||||||
@@ -177,17 +188,16 @@ public class MineTweakerImplementationAPI {
|
|||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
minetweakerCommands.put("recipes", new MineTweakerCommand(
|
minetweakerCommands.put(
|
||||||
"recipes",
|
"recipes",
|
||||||
new String[]{
|
new MineTweakerCommand(
|
||||||
"/minetweaker recipes",
|
"recipes",
|
||||||
" Lists all crafting recipes in the game",
|
new String[] { "/minetweaker recipes", " Lists all crafting recipes in the game",
|
||||||
"/minetweaker recipes hand",
|
"/minetweaker recipes hand", " Lists all crafting recipes for the item in your hand",
|
||||||
" Lists all crafting recipes for the item in your hand",
|
" Also copies the recipes to clipboard", "/minetweaker recipes furnace",
|
||||||
" Also copies the recipes to clipboard",
|
" lists all furnace recipes in the game" },
|
||||||
"/minetweaker recipes furnace",
|
new ICommandFunction() {
|
||||||
" lists all furnace recipes in the game"
|
|
||||||
}, new ICommandFunction() {
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(String[] arguments, IPlayer player) {
|
public void execute(String[] arguments, IPlayer player) {
|
||||||
if (arguments.length == 0) {
|
if (arguments.length == 0) {
|
||||||
@@ -216,12 +226,14 @@ public class MineTweakerImplementationAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
player.sendChat("Recipe list generated; see minetweaker.log in your minecraft dir");
|
player.sendChat(
|
||||||
|
"Recipe list generated; see minetweaker.log in your minecraft dir");
|
||||||
}
|
}
|
||||||
} else if (arguments[0].equals("hand") && player != null) {
|
} else if (arguments[0].equals("hand") && player != null) {
|
||||||
IItemStack item = player.getCurrentItem();
|
IItemStack item = player.getCurrentItem();
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
List<ICraftingRecipe> recipes = MineTweakerAPI.recipes.getRecipesFor(item.anyAmount());
|
List<ICraftingRecipe> recipes = MineTweakerAPI.recipes
|
||||||
|
.getRecipesFor(item.anyAmount());
|
||||||
if (recipes.isEmpty()) {
|
if (recipes.isEmpty()) {
|
||||||
player.sendChat("No crafting recipes found for that item");
|
player.sendChat("No crafting recipes found for that item");
|
||||||
} else {
|
} else {
|
||||||
@@ -253,7 +265,8 @@ public class MineTweakerImplementationAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
player.sendChat("Furnace Recipe list generated; see minetweaker.log in your minecraft dir");
|
player.sendChat(
|
||||||
|
"Furnace Recipe list generated; see minetweaker.log in your minecraft dir");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
@@ -263,12 +276,13 @@ public class MineTweakerImplementationAPI {
|
|||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
minetweakerCommands.put("inventory", new MineTweakerCommand(
|
minetweakerCommands.put(
|
||||||
"inventory",
|
"inventory",
|
||||||
new String[]{
|
new MineTweakerCommand(
|
||||||
"/minetweaker inventory",
|
"inventory",
|
||||||
" Lists all items in your inventory"
|
new String[] { "/minetweaker inventory", " Lists all items in your inventory" },
|
||||||
}, new ICommandFunction() {
|
new ICommandFunction() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(String[] arguments, IPlayer player) {
|
public void execute(String[] arguments, IPlayer player) {
|
||||||
for (int i = 0; i < player.getInventorySize(); i++) {
|
for (int i = 0; i < player.getInventorySize(); i++) {
|
||||||
@@ -280,14 +294,14 @@ public class MineTweakerImplementationAPI {
|
|||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
minetweakerCommands.put("hand", new MineTweakerCommand(
|
minetweakerCommands.put(
|
||||||
"hand",
|
"hand",
|
||||||
new String[]{
|
new MineTweakerCommand(
|
||||||
"/minetweaker hand",
|
"hand",
|
||||||
" Outputs the name of the item in your hand",
|
new String[] { "/minetweaker hand", " Outputs the name of the item in your hand",
|
||||||
" Also copies the name to clipboard and prints",
|
" Also copies the name to clipboard and prints", " oredict entries" },
|
||||||
" oredict entries"
|
new ICommandFunction() {
|
||||||
}, new ICommandFunction() {
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(String[] arguments, IPlayer player) {
|
public void execute(String[] arguments, IPlayer player) {
|
||||||
IItemStack hand = player.getCurrentItem();
|
IItemStack hand = player.getCurrentItem();
|
||||||
@@ -304,14 +318,16 @@ public class MineTweakerImplementationAPI {
|
|||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
minetweakerCommands.put("oredict", new MineTweakerCommand(
|
minetweakerCommands.put(
|
||||||
"oredict",
|
"oredict",
|
||||||
new String[]{
|
new MineTweakerCommand(
|
||||||
"/minetweaker oredict",
|
"oredict",
|
||||||
|
new String[] { "/minetweaker oredict",
|
||||||
" Outputs all ore dictionary entries in the game to the minetweaker log",
|
" Outputs all ore dictionary entries in the game to the minetweaker log",
|
||||||
"/minetweaker oredict <name>",
|
"/minetweaker oredict <name>",
|
||||||
" Outputs all items in the given ore dictionary entry to the minetweaker log"
|
" Outputs all items in the given ore dictionary entry to the minetweaker log" },
|
||||||
}, new ICommandFunction() {
|
new ICommandFunction() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(String[] arguments, IPlayer player) {
|
public void execute(String[] arguments, IPlayer player) {
|
||||||
if (arguments.length > 0) {
|
if (arguments.length > 0) {
|
||||||
@@ -329,7 +345,8 @@ public class MineTweakerImplementationAPI {
|
|||||||
} else {
|
} else {
|
||||||
for (IOreDictEntry entry : MineTweakerAPI.oreDict.getEntries()) {
|
for (IOreDictEntry entry : MineTweakerAPI.oreDict.getEntries()) {
|
||||||
if (!entry.isEmpty()) {
|
if (!entry.isEmpty()) {
|
||||||
MineTweakerAPI.logCommand("Ore entries for <ore:" + entry.getName() + "> :");
|
MineTweakerAPI
|
||||||
|
.logCommand("Ore entries for <ore:" + entry.getName() + "> :");
|
||||||
for (IItemStack ore : entry.getItems()) {
|
for (IItemStack ore : entry.getItems()) {
|
||||||
MineTweakerAPI.logCommand(" " + ore);
|
MineTweakerAPI.logCommand(" " + ore);
|
||||||
}
|
}
|
||||||
@@ -340,12 +357,13 @@ public class MineTweakerImplementationAPI {
|
|||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
minetweakerCommands.put("mods", new MineTweakerCommand(
|
minetweakerCommands.put(
|
||||||
"mods",
|
"mods",
|
||||||
new String[]{
|
new MineTweakerCommand(
|
||||||
"/minetweaker mods",
|
"mods",
|
||||||
" Outputs all active mod IDs and versions in the game"
|
new String[] { "/minetweaker mods", " Outputs all active mod IDs and versions in the game" },
|
||||||
}, new ICommandFunction() {
|
new ICommandFunction() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(String[] arguments, IPlayer player) {
|
public void execute(String[] arguments, IPlayer player) {
|
||||||
MineTweakerAPI.logCommand("Mods list:");
|
MineTweakerAPI.logCommand("Mods list:");
|
||||||
@@ -357,13 +375,13 @@ public class MineTweakerImplementationAPI {
|
|||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
minetweakerCommands.put("name", new MineTweakerCommand(
|
minetweakerCommands.put(
|
||||||
"name",
|
"name",
|
||||||
new String[]{
|
new MineTweakerCommand(
|
||||||
"/minetweaker name <id>",
|
"name",
|
||||||
" Outputs the name for the given item ID",
|
new String[] { "/minetweaker name <id>", " Outputs the name for the given item ID", },
|
||||||
},
|
|
||||||
new ICommandFunction() {
|
new ICommandFunction() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(String[] arguments, IPlayer player) {
|
public void execute(String[] arguments, IPlayer player) {
|
||||||
if (arguments.length < 1) {
|
if (arguments.length < 1) {
|
||||||
@@ -388,13 +406,13 @@ public class MineTweakerImplementationAPI {
|
|||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
minetweakerCommands.put("seeds", new MineTweakerCommand(
|
minetweakerCommands.put(
|
||||||
"seeds",
|
"seeds",
|
||||||
new String[]{
|
new MineTweakerCommand(
|
||||||
"/minetweaker seeds",
|
"seeds",
|
||||||
" Prints all seeds registered",
|
new String[] { "/minetweaker seeds", " Prints all seeds registered", " for tall grass" },
|
||||||
" for tall grass"
|
new ICommandFunction() {
|
||||||
}, new ICommandFunction() {
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(String[] arguments, IPlayer player) {
|
public void execute(String[] arguments, IPlayer player) {
|
||||||
MineTweakerAPI.logCommand("Seeds:");
|
MineTweakerAPI.logCommand("Seeds:");
|
||||||
@@ -406,13 +424,13 @@ public class MineTweakerImplementationAPI {
|
|||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
minetweakerCommands.put("loot", new MineTweakerCommand(
|
minetweakerCommands.put(
|
||||||
|
"loot",
|
||||||
|
new MineTweakerCommand(
|
||||||
"seeds",
|
"seeds",
|
||||||
new String[]{
|
new String[] { "/minetweaker seeds", " Prints all seeds registered", " for tall grass" },
|
||||||
"/minetweaker seeds",
|
new ICommandFunction() {
|
||||||
" Prints all seeds registered",
|
|
||||||
" for tall grass"
|
|
||||||
}, new ICommandFunction() {
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(String[] arguments, IPlayer player) {
|
public void execute(String[] arguments, IPlayer player) {
|
||||||
if (arguments.length == 0) {
|
if (arguments.length == 0) {
|
||||||
@@ -442,48 +460,52 @@ public class MineTweakerImplementationAPI {
|
|||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
minetweakerCommands.put("wiki", new MineTweakerCommand(
|
minetweakerCommands.put(
|
||||||
"wiki",
|
"wiki",
|
||||||
new String[]{
|
new MineTweakerCommand(
|
||||||
"/minetweaker wiki",
|
"wiki",
|
||||||
" Opens your browser with the wiki"
|
new String[] { "/minetweaker wiki", " Opens your browser with the wiki" },
|
||||||
}, new ICommandFunction() {
|
new ICommandFunction() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(String[] arguments, IPlayer player) {
|
public void execute(String[] arguments, IPlayer player) {
|
||||||
player.openBrowser("http://minetweaker3.powerofbytes.com/wiki/");
|
player.openBrowser("http://minetweaker3.powerofbytes.com/wiki/");
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
minetweakerCommands.put("bugs", new MineTweakerCommand(
|
minetweakerCommands.put(
|
||||||
"bugs",
|
"bugs",
|
||||||
new String[]{
|
new MineTweakerCommand(
|
||||||
"/minetweaker bugs",
|
"bugs",
|
||||||
" Opens your browser with the GitHub bug tracker"
|
new String[] { "/minetweaker bugs", " Opens your browser with the GitHub bug tracker" },
|
||||||
}, new ICommandFunction() {
|
new ICommandFunction() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(String[] arguments, IPlayer player) {
|
public void execute(String[] arguments, IPlayer player) {
|
||||||
player.openBrowser("https://github.com/stanhebben/MineTweaker3/issues");
|
player.openBrowser("https://github.com/stanhebben/MineTweaker3/issues");
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
minetweakerCommands.put("forum", new MineTweakerCommand(
|
minetweakerCommands.put(
|
||||||
"forum",
|
"forum",
|
||||||
new String[]{
|
new MineTweakerCommand(
|
||||||
"/minetweaker forum",
|
"forum",
|
||||||
" Opens your browser with the forum"
|
new String[] { "/minetweaker forum", " Opens your browser with the forum" },
|
||||||
}, new ICommandFunction() {
|
new ICommandFunction() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(String[] arguments, IPlayer player) {
|
public void execute(String[] arguments, IPlayer player) {
|
||||||
player.openBrowser("http://minetweaker3.powerofbytes.com/forum");
|
player.openBrowser("http://minetweaker3.powerofbytes.com/forum");
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
minetweakerCommands.put("biomes", new MineTweakerCommand(
|
minetweakerCommands.put(
|
||||||
"biomes",
|
"biomes",
|
||||||
new String[]{
|
new MineTweakerCommand(
|
||||||
"/minetweaker biomes",
|
"biomes",
|
||||||
" Lists all the biomes in the game"
|
new String[] { "/minetweaker biomes", " Lists all the biomes in the game" },
|
||||||
}, new ICommandFunction() {
|
new ICommandFunction() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(String[] arguments, IPlayer player) {
|
public void execute(String[] arguments, IPlayer player) {
|
||||||
MineTweakerAPI.logCommand("Biomes:");
|
MineTweakerAPI.logCommand("Biomes:");
|
||||||
@@ -496,13 +518,15 @@ public class MineTweakerImplementationAPI {
|
|||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
minetweakerCommands.put("blockinfo", new MineTweakerCommand(
|
minetweakerCommands.put(
|
||||||
"blockinfo",
|
"blockinfo",
|
||||||
new String[]{
|
new MineTweakerCommand(
|
||||||
"/minetweaker blockinfo",
|
"blockinfo",
|
||||||
|
new String[] { "/minetweaker blockinfo",
|
||||||
" Activates or deactivates block reader. In block info mode,",
|
" Activates or deactivates block reader. In block info mode,",
|
||||||
" right-click a block to see ID, meta and tile entity data"
|
" right-click a block to see ID, meta and tile entity data" },
|
||||||
}, new ICommandFunction() {
|
new ICommandFunction() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(String[] arguments, IPlayer player) {
|
public void execute(String[] arguments, IPlayer player) {
|
||||||
if (blockInfoPlayers.isEmpty()) {
|
if (blockInfoPlayers.isEmpty()) {
|
||||||
@@ -550,14 +574,8 @@ public class MineTweakerImplementationAPI {
|
|||||||
* @param formatter formatter interface
|
* @param formatter formatter interface
|
||||||
* @param vanilla vanilla interface
|
* @param vanilla vanilla interface
|
||||||
*/
|
*/
|
||||||
public static void init(
|
public static void init(IOreDict oreDict, IRecipeManager recipes, IFurnaceManager furnace, IGame game,
|
||||||
IOreDict oreDict,
|
ILoadedMods mods, IFormatter formatter, IVanilla vanilla) {
|
||||||
IRecipeManager recipes,
|
|
||||||
IFurnaceManager furnace,
|
|
||||||
IGame game,
|
|
||||||
ILoadedMods mods,
|
|
||||||
IFormatter formatter,
|
|
||||||
IVanilla vanilla) {
|
|
||||||
MineTweakerAPI.oreDict = oreDict;
|
MineTweakerAPI.oreDict = oreDict;
|
||||||
MineTweakerAPI.recipes = recipes;
|
MineTweakerAPI.recipes = recipes;
|
||||||
MineTweakerAPI.furnace = furnace;
|
MineTweakerAPI.furnace = furnace;
|
||||||
@@ -576,6 +594,7 @@ public class MineTweakerImplementationAPI {
|
|||||||
public static IEventHandle onRollbackEvent(IEventHandler<ReloadEvent> handler) {
|
public static IEventHandle onRollbackEvent(IEventHandler<ReloadEvent> handler) {
|
||||||
return ONROLLBACK.add(handler);
|
return ONROLLBACK.add(handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IEventHandle onReloadEvent(IEventHandler<ReloadEvent> handler) {
|
public static IEventHandle onReloadEvent(IEventHandler<ReloadEvent> handler) {
|
||||||
return ONRELOAD.add(handler);
|
return ONRELOAD.add(handler);
|
||||||
}
|
}
|
||||||
@@ -611,8 +630,7 @@ public class MineTweakerImplementationAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called to reload scripts. Must be called after setting a new script
|
* Called to reload scripts. Must be called after setting a new script provider in order to reload scripts.
|
||||||
* provider in order to reload scripts.
|
|
||||||
*/
|
*/
|
||||||
public static void reload() {
|
public static void reload() {
|
||||||
blockInfoPlayers.clear();
|
blockInfoPlayers.clear();
|
||||||
@@ -630,13 +648,19 @@ public class MineTweakerImplementationAPI {
|
|||||||
|
|
||||||
if (MineTweakerAPI.server != null) {
|
if (MineTweakerAPI.server != null) {
|
||||||
if (!MineTweakerAPI.server.isCommandAdded("minetweaker")) {
|
if (!MineTweakerAPI.server.isCommandAdded("minetweaker")) {
|
||||||
server.addCommand("minetweaker", "", new String[]{"mt", "crafttweaker", "ct"}, new ICommandFunction() {
|
server.addCommand(
|
||||||
|
"minetweaker",
|
||||||
|
"",
|
||||||
|
new String[] { "mt", "crafttweaker", "ct" },
|
||||||
|
new ICommandFunction() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(String[] arguments, IPlayer player) {
|
public void execute(String[] arguments, IPlayer player) {
|
||||||
if (arguments.length == 0) {
|
if (arguments.length == 0) {
|
||||||
player.sendChat("Please provide a command. Use /mt help for more info.");
|
player.sendChat("Please provide a command. Use /mt help for more info.");
|
||||||
} else if (arguments[0].equals("help")) {
|
} else if (arguments[0].equals("help")) {
|
||||||
String[] keys = minetweakerCommands.keySet().toArray(new String[minetweakerCommands.size()]);
|
String[] keys = minetweakerCommands.keySet()
|
||||||
|
.toArray(new String[minetweakerCommands.size()]);
|
||||||
Arrays.sort(keys);
|
Arrays.sort(keys);
|
||||||
for (String key : keys) {
|
for (String key : keys) {
|
||||||
for (String helpMessage : minetweakerCommands.get(key).description) {
|
for (String helpMessage : minetweakerCommands.get(key).description) {
|
||||||
@@ -648,16 +672,20 @@ public class MineTweakerImplementationAPI {
|
|||||||
if (command == null) {
|
if (command == null) {
|
||||||
player.sendChat("No such minetweaker command available");
|
player.sendChat("No such minetweaker command available");
|
||||||
} else {
|
} else {
|
||||||
command.function.execute(Arrays.copyOfRange(arguments, 1, arguments.length), player);
|
command.function
|
||||||
|
.execute(Arrays.copyOfRange(arguments, 1, arguments.length), player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, new ICommandValidator() {
|
},
|
||||||
|
new ICommandValidator() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canExecute(IPlayer player) {
|
public boolean canExecute(IPlayer player) {
|
||||||
return server.isOp(player);
|
return server.isOp(player);
|
||||||
}
|
}
|
||||||
}, null);
|
},
|
||||||
|
null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -674,8 +702,7 @@ public class MineTweakerImplementationAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a new minetweaker command. Can be called with /mt <command&;gt;
|
* Adds a new minetweaker command. Can be called with /mt <command&;gt; <arguments>.
|
||||||
* <arguments>.
|
|
||||||
*
|
*
|
||||||
* @param name command name
|
* @param name command name
|
||||||
* @param description description strings
|
* @param description description strings
|
||||||
@@ -705,12 +732,12 @@ public class MineTweakerImplementationAPI {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ######################
|
// ######################
|
||||||
// ### Action classes ###
|
// ### Action classes ###
|
||||||
// ######################
|
// ######################
|
||||||
|
|
||||||
private static class AddMineTweakerCommandAction implements IUndoableAction {
|
private static class AddMineTweakerCommandAction implements IUndoableAction {
|
||||||
|
|
||||||
private final MineTweakerCommand command;
|
private final MineTweakerCommand command;
|
||||||
|
|
||||||
public AddMineTweakerCommandAction(MineTweakerCommand command) {
|
public AddMineTweakerCommandAction(MineTweakerCommand command) {
|
||||||
@@ -721,8 +748,7 @@ public class MineTweakerImplementationAPI {
|
|||||||
public void apply() {
|
public void apply() {
|
||||||
if (!minetweakerCommands.containsKey(command.name)) {
|
if (!minetweakerCommands.containsKey(command.name)) {
|
||||||
minetweakerCommands.put(command.name, command);
|
minetweakerCommands.put(command.name, command);
|
||||||
} else {
|
} else {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -731,8 +757,7 @@ public class MineTweakerImplementationAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void undo() {
|
public void undo() {}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String describe() {
|
public String describe() {
|
||||||
@@ -758,6 +783,7 @@ public class MineTweakerImplementationAPI {
|
|||||||
// #############################
|
// #############################
|
||||||
|
|
||||||
private static class MineTweakerCommand {
|
private static class MineTweakerCommand {
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
private final String[] description;
|
private final String[] description;
|
||||||
private final ICommandFunction function;
|
private final ICommandFunction function;
|
||||||
@@ -770,6 +796,7 @@ public class MineTweakerImplementationAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static class ItemComparator implements Comparator<IItemDefinition> {
|
private static class ItemComparator implements Comparator<IItemDefinition> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compare(IItemDefinition o1, IItemDefinition o2) {
|
public int compare(IItemDefinition o1, IItemDefinition o2) {
|
||||||
return o1.getId().compareTo(o2.getId());
|
return o1.getId().compareTo(o2.getId());
|
||||||
@@ -777,6 +804,7 @@ public class MineTweakerImplementationAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static class LiquidComparator implements Comparator<ILiquidDefinition> {
|
private static class LiquidComparator implements Comparator<ILiquidDefinition> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compare(ILiquidDefinition o1, ILiquidDefinition o2) {
|
public int compare(ILiquidDefinition o1, ILiquidDefinition o2) {
|
||||||
return o1.getName().compareTo(o2.getName());
|
return o1.getName().compareTo(o2.getName());
|
||||||
@@ -784,6 +812,7 @@ public class MineTweakerImplementationAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static class BlockComparator implements Comparator<IBlockDefinition> {
|
private static class BlockComparator implements Comparator<IBlockDefinition> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compare(IBlockDefinition o1, IBlockDefinition o2) {
|
public int compare(IBlockDefinition o1, IBlockDefinition o2) {
|
||||||
return o1.getId().compareTo(o2.getId());
|
return o1.getId().compareTo(o2.getId());
|
||||||
@@ -791,6 +820,7 @@ public class MineTweakerImplementationAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static class EntityComparator implements Comparator<IEntityDefinition> {
|
private static class EntityComparator implements Comparator<IEntityDefinition> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compare(IEntityDefinition o1, IEntityDefinition o2) {
|
public int compare(IEntityDefinition o1, IEntityDefinition o2) {
|
||||||
return o1.getId().compareTo(o2.getId());
|
return o1.getId().compareTo(o2.getId());
|
||||||
@@ -798,6 +828,7 @@ public class MineTweakerImplementationAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static class ListenPlayerLoggedIn implements IEventHandler<PlayerLoggedInEvent> {
|
private static class ListenPlayerLoggedIn implements IEventHandler<PlayerLoggedInEvent> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle(PlayerLoggedInEvent event) {
|
public void handle(PlayerLoggedInEvent event) {
|
||||||
if (MineTweakerAPI.server != null && MineTweakerAPI.server.isOp(event.getPlayer())) {
|
if (MineTweakerAPI.server != null && MineTweakerAPI.server.isOp(event.getPlayer())) {
|
||||||
@@ -807,6 +838,7 @@ public class MineTweakerImplementationAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static class ListenPlayerLoggedOut implements IEventHandler<PlayerLoggedOutEvent> {
|
private static class ListenPlayerLoggedOut implements IEventHandler<PlayerLoggedOutEvent> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle(PlayerLoggedOutEvent event) {
|
public void handle(PlayerLoggedOutEvent event) {
|
||||||
logger.removePlayer(event.getPlayer());
|
logger.removePlayer(event.getPlayer());
|
||||||
@@ -814,6 +846,7 @@ public class MineTweakerImplementationAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static class ListenBlockInfo implements IEventHandler<PlayerInteractEvent> {
|
private static class ListenBlockInfo implements IEventHandler<PlayerInteractEvent> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle(PlayerInteractEvent event) {
|
public void handle(PlayerInteractEvent event) {
|
||||||
if (blockInfoPlayers.contains(event.getPlayer())) {
|
if (blockInfoPlayers.contains(event.getPlayer())) {
|
||||||
|
|||||||
@@ -6,14 +6,14 @@ package minetweaker;
|
|||||||
* @author Stan Hebben
|
* @author Stan Hebben
|
||||||
*/
|
*/
|
||||||
public abstract class OneWayAction implements IUndoableAction {
|
public abstract class OneWayAction implements IUndoableAction {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canUndo() {
|
public boolean canUndo() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void undo() {
|
public void undo() {}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String describeUndo() {
|
public String describeUndo() {
|
||||||
|
|||||||
@@ -6,18 +6,18 @@ import java.lang.annotation.RetentionPolicy;
|
|||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Marks a bracket handler. Bracket handlers are automatically registered. The
|
* Marks a bracket handler. Bracket handlers are automatically registered. The marked class should have an empty
|
||||||
* marked class should have an empty constructor.
|
* constructor.
|
||||||
*
|
*
|
||||||
* @author Stan Hebben
|
* @author Stan Hebben
|
||||||
*/
|
*/
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Target({ ElementType.TYPE })
|
@Target({ ElementType.TYPE })
|
||||||
public @interface BracketHandler {
|
public @interface BracketHandler {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates priority. A lower value means a higher priority. Only change if
|
* Indicates priority. A lower value means a higher priority. Only change if you have issues, default value is 10.
|
||||||
* you have issues, default value is 10. Internal minetweaker handlers have
|
* Internal minetweaker handlers have priorities up to 100.
|
||||||
* priorities up to 100.
|
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -6,14 +6,14 @@ import java.lang.annotation.RetentionPolicy;
|
|||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates that a certain class is only available when a specific mod is
|
* Indicates that a certain class is only available when a specific mod is available. Multiple mods can be specified.
|
||||||
* available. Multiple mods can be specified.
|
|
||||||
*
|
*
|
||||||
* @author Stan Hebben
|
* @author Stan Hebben
|
||||||
*/
|
*/
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Target({ ElementType.TYPE, ElementType.METHOD })
|
@Target({ ElementType.TYPE, ElementType.METHOD })
|
||||||
public @interface ModOnly {
|
public @interface ModOnly {
|
||||||
|
|
||||||
public String[] value();
|
public String[] value();
|
||||||
|
|
||||||
public String version() default "";
|
public String version() default "";
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
* To change this license header, choose License Headers in Project Properties. To change this template file, choose
|
||||||
* To change this template file, choose Tools | Templates
|
* Tools | Templates and open the template in the editor.
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package minetweaker.annotations;
|
package minetweaker.annotations;
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package minetweaker.api.block;
|
package minetweaker.api.block;
|
||||||
|
|
||||||
import minetweaker.util.ArrayUtil;
|
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
import minetweaker.util.ArrayUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Stan
|
* @author Stan
|
||||||
*/
|
*/
|
||||||
@@ -31,8 +31,7 @@ public class BlockPatternOr implements IBlockPattern {
|
|||||||
@Override
|
@Override
|
||||||
public boolean matches(IBlock block) {
|
public boolean matches(IBlock block) {
|
||||||
for (IBlockPattern pattern : elements) {
|
for (IBlockPattern pattern : elements) {
|
||||||
if(pattern.matches(block))
|
if (pattern.matches(block)) return true;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package minetweaker.api.block;
|
package minetweaker.api.block;
|
||||||
|
|
||||||
import stanhebben.zenscript.annotations.*;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import stanhebben.zenscript.annotations.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Stan
|
* @author Stan
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ package minetweaker.api.chat;
|
|||||||
import stanhebben.zenscript.annotations.*;
|
import stanhebben.zenscript.annotations.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a chat message. Strings can be converted into chat messages, and
|
* Represents a chat message. Strings can be converted into chat messages, and chat messages can be colored and
|
||||||
* chat messages can be colored and concatenated.
|
* concatenated.
|
||||||
*
|
*
|
||||||
* @author Stan Hebben
|
* @author Stan Hebben
|
||||||
*/
|
*/
|
||||||
@@ -22,8 +22,7 @@ public interface IChatMessage {
|
|||||||
IChatMessage add(IChatMessage other);
|
IChatMessage add(IChatMessage other);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the internal object backing this object. Must be generated by
|
* Retrieves the internal object backing this object. Must be generated by the implementing platform.
|
||||||
* the implementing platform.
|
|
||||||
*
|
*
|
||||||
* @return internal object
|
* @return internal object
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,14 +1,13 @@
|
|||||||
package minetweaker.api.compat;
|
package minetweaker.api.compat;
|
||||||
|
|
||||||
import minetweaker.api.item.IIngredient;
|
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
import minetweaker.api.item.IIngredient;
|
||||||
|
|
||||||
public class DummyJEIRecipeRegistry implements IJEIRecipeRegistry {
|
public class DummyJEIRecipeRegistry implements IJEIRecipeRegistry {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addRecipe(Object object) {
|
public void addRecipe(Object object) {}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addRecipe(Object object, String category) {
|
public void addRecipe(Object object, String category) {
|
||||||
@@ -16,8 +15,7 @@ public class DummyJEIRecipeRegistry implements IJEIRecipeRegistry {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeRecipe(Object object) {
|
public void removeRecipe(Object object) {}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeRecipe(Object output, String category) {
|
public void removeRecipe(Object output, String category) {
|
||||||
@@ -25,12 +23,10 @@ public class DummyJEIRecipeRegistry implements IJEIRecipeRegistry {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addFurnace(List<Object> inputs, Object output) {
|
public void addFurnace(List<Object> inputs, Object output) {}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeFurnace(Object object) {
|
public void removeFurnace(Object object) {}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addFuel(Collection<Object> input, int burnTime) {
|
public void addFuel(Collection<Object> input, int burnTime) {
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package minetweaker.api.compat;
|
package minetweaker.api.compat;
|
||||||
|
|
||||||
import minetweaker.api.item.IIngredient;
|
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
import minetweaker.api.item.IIngredient;
|
||||||
|
|
||||||
public interface IJEIRecipeRegistry {
|
public interface IJEIRecipeRegistry {
|
||||||
|
|
||||||
void addRecipe(Object object);
|
void addRecipe(Object object);
|
||||||
@@ -14,7 +14,6 @@ public interface IJEIRecipeRegistry {
|
|||||||
|
|
||||||
void removeRecipe(Object output, String category);
|
void removeRecipe(Object output, String category);
|
||||||
|
|
||||||
|
|
||||||
void addFurnace(List<Object> inputs, Object output);
|
void addFurnace(List<Object> inputs, Object output);
|
||||||
|
|
||||||
void removeFurnace(Object output);
|
void removeFurnace(Object output);
|
||||||
|
|||||||
@@ -20,8 +20,7 @@ public interface IContainer extends Iterable<IItemStack> {
|
|||||||
int getContainerSize();
|
int getContainerSize();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the item stack at the given position. Returns null if there is no
|
* Gets the item stack at the given position. Returns null if there is no stack at that position.
|
||||||
* stack at that position.
|
|
||||||
*
|
*
|
||||||
* @param i stack position
|
* @param i stack position
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -111,10 +111,8 @@ public class DataByteArray implements IData {
|
|||||||
result.append("[");
|
result.append("[");
|
||||||
boolean first = true;
|
boolean first = true;
|
||||||
for (byte value : data) {
|
for (byte value : data) {
|
||||||
if(first)
|
if (first) first = false;
|
||||||
first = false;
|
else result.append(", ");
|
||||||
else
|
|
||||||
result.append(", ");
|
|
||||||
|
|
||||||
result.append(value);
|
result.append(value);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -141,23 +141,19 @@ public class DataList implements IData {
|
|||||||
@Override
|
@Override
|
||||||
public boolean contains(IData data) {
|
public boolean contains(IData data) {
|
||||||
List<IData> dataValues = data.asList();
|
List<IData> dataValues = data.asList();
|
||||||
if(dataValues != null && containsList(dataValues))
|
if (dataValues != null && containsList(dataValues)) return true;
|
||||||
return true;
|
|
||||||
|
|
||||||
for (IData value : values) {
|
for (IData value : values) {
|
||||||
if(value.contains(data))
|
if (value.contains(data)) return true;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean containsList(List<IData> dataValues) {
|
private boolean containsList(List<IData> dataValues) {
|
||||||
outer:
|
outer: for (IData dataValue : dataValues) {
|
||||||
for(IData dataValue : dataValues) {
|
|
||||||
for (IData value : values) {
|
for (IData value : values) {
|
||||||
if(value.contains(dataValue))
|
if (value.contains(dataValue)) continue outer;
|
||||||
continue outer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -169,12 +165,10 @@ public class DataList implements IData {
|
|||||||
@Override
|
@Override
|
||||||
public boolean equals(IData data) {
|
public boolean equals(IData data) {
|
||||||
List<IData> otherValues = data.asList();
|
List<IData> otherValues = data.asList();
|
||||||
if(otherValues.size() != values.size())
|
if (otherValues.size() != values.size()) return false;
|
||||||
return false;
|
|
||||||
|
|
||||||
for (int i = 0; i < values.size(); i++) {
|
for (int i = 0; i < values.size(); i++) {
|
||||||
if(!values.get(i).equals(otherValues.get(i)))
|
if (!values.get(i).equals(otherValues.get(i))) return false;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -200,8 +194,7 @@ public class DataList implements IData {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IData update(IData data) {
|
public IData update(IData data) {
|
||||||
if(immutable)
|
if (immutable) data = data.immutable();
|
||||||
data = data.immutable();
|
|
||||||
|
|
||||||
List<IData> result = new ArrayList<>();
|
List<IData> result = new ArrayList<>();
|
||||||
result.addAll(values);
|
result.addAll(values);
|
||||||
|
|||||||
@@ -209,8 +209,7 @@ public class DataMap implements IData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Map<String, IData> dataMap = data.asMap();
|
Map<String, IData> dataMap = data.asMap();
|
||||||
if(dataMap == null)
|
if (dataMap == null) return false;
|
||||||
return false;
|
|
||||||
|
|
||||||
for (Map.Entry<String, IData> dataEntry : dataMap.entrySet()) {
|
for (Map.Entry<String, IData> dataEntry : dataMap.entrySet()) {
|
||||||
if (!this.data.containsKey(dataEntry.getKey())) {
|
if (!this.data.containsKey(dataEntry.getKey())) {
|
||||||
@@ -230,12 +229,10 @@ public class DataMap implements IData {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(IData data) {
|
public boolean equals(IData data) {
|
||||||
if(this == data)
|
if (this == data) return true;
|
||||||
return true;
|
|
||||||
|
|
||||||
Map<String, IData> dataMap = data.asMap();
|
Map<String, IData> dataMap = data.asMap();
|
||||||
if(dataMap.size() != this.data.size())
|
if (dataMap.size() != this.data.size()) return false;
|
||||||
return false;
|
|
||||||
|
|
||||||
for (Map.Entry<String, IData> dataEntry : this.data.entrySet()) {
|
for (Map.Entry<String, IData> dataEntry : this.data.entrySet()) {
|
||||||
if (!dataMap.containsKey(dataEntry.getKey())) {
|
if (!dataMap.containsKey(dataEntry.getKey())) {
|
||||||
@@ -263,8 +260,7 @@ public class DataMap implements IData {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IData update(IData data) {
|
public IData update(IData data) {
|
||||||
if(immutable)
|
if (immutable) data = data.immutable();
|
||||||
data = data.immutable();
|
|
||||||
|
|
||||||
Map<String, IData> result = new HashMap<>();
|
Map<String, IData> result = new HashMap<>();
|
||||||
for (Map.Entry<String, IData> entry : this.data.entrySet()) {
|
for (Map.Entry<String, IData> entry : this.data.entrySet()) {
|
||||||
@@ -287,12 +283,10 @@ public class DataMap implements IData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean isValidIdentifier(String str) {
|
private boolean isValidIdentifier(String str) {
|
||||||
if(!Character.isJavaIdentifierStart(str.charAt(0)))
|
if (!Character.isJavaIdentifierStart(str.charAt(0))) return false;
|
||||||
return false;
|
|
||||||
|
|
||||||
for (int i = 1; i < str.length(); i++) {
|
for (int i = 1; i < str.length(); i++) {
|
||||||
if(!Character.isJavaIdentifierPart(str.charAt(i)))
|
if (!Character.isJavaIdentifierPart(str.charAt(i))) return false;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
package minetweaker.api.data;
|
package minetweaker.api.data;
|
||||||
|
|
||||||
import stanhebben.zenscript.annotations.*;
|
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
import stanhebben.zenscript.annotations.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generic data interface. A data element may contain any kind of basic data
|
* Generic data interface. A data element may contain any kind of basic data element (bool, byte, short, int, long,
|
||||||
* element (bool, byte, short, int, long, float, double, string, list, map, int
|
* float, double, string, list, map, int array or byte array). Used to store data with stacks, blocks, world, ...
|
||||||
* array or byte array). Used to store data with stacks, blocks, world, ...
|
|
||||||
*
|
*
|
||||||
* @author Stan Hebben
|
* @author Stan Hebben
|
||||||
*/
|
*/
|
||||||
@@ -69,8 +68,7 @@ public interface IData {
|
|||||||
String asString();
|
String asString();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempts to convert this value to a List. Returns null if this value
|
* Attempts to convert this value to a List. Returns null if this value cannot be converted to a list.
|
||||||
* cannot be converted to a list.
|
|
||||||
*
|
*
|
||||||
* @return list data of this value, if any
|
* @return list data of this value, if any
|
||||||
*/
|
*/
|
||||||
@@ -78,8 +76,7 @@ public interface IData {
|
|||||||
List<IData> asList();
|
List<IData> asList();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempts to convert this value to a Map. Returns null if this value
|
* Attempts to convert this value to a Map. Returns null if this value cannot be converted to a map.
|
||||||
* cannot be converted to a map.
|
|
||||||
*
|
*
|
||||||
* @return map data of this value, if any
|
* @return map data of this value, if any
|
||||||
*/
|
*/
|
||||||
@@ -87,8 +84,7 @@ public interface IData {
|
|||||||
Map<String, IData> asMap();
|
Map<String, IData> asMap();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempts to convert this value to a byte array. Returns null if this
|
* Attempts to convert this value to a byte array. Returns null if this value cannot be converted to a byte array.
|
||||||
* value cannot be converted to a byte array.
|
|
||||||
*
|
*
|
||||||
* @return byte array data of this value, if any
|
* @return byte array data of this value, if any
|
||||||
*/
|
*/
|
||||||
@@ -96,8 +92,7 @@ public interface IData {
|
|||||||
byte[] asByteArray();
|
byte[] asByteArray();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempts to convert this value to an int array. Returns null if this
|
* Attempts to convert this value to an int array. Returns null if this value cannot be converted to an int array.
|
||||||
* value cannot be converted to an int array.
|
|
||||||
*
|
*
|
||||||
* @return int array data of this value, if any
|
* @return int array data of this value, if any
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* This file is part of MineTweaker API, licensed under the MIT License (MIT).
|
* This file is part of MineTweaker API, licensed under the MIT License (MIT). Copyright (c) 2014 MineTweaker
|
||||||
*
|
* <http://minetweaker3.powerofbytes.com>
|
||||||
* Copyright (c) 2014 MineTweaker <http://minetweaker3.powerofbytes.com>
|
|
||||||
*/
|
*/
|
||||||
package minetweaker.api.data;
|
package minetweaker.api.data;
|
||||||
|
|
||||||
|
|||||||
@@ -5,9 +5,8 @@ import minetweaker.api.world.IDimension;
|
|||||||
import stanhebben.zenscript.annotations.*;
|
import stanhebben.zenscript.annotations.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Entity interface. Used to obtain information about entities, and modify their
|
* Entity interface. Used to obtain information about entities, and modify their data. Entities are any item that is
|
||||||
* data. Entities are any item that is freely movable in the world, such as
|
* freely movable in the world, such as players, monsters, items on the ground, ...
|
||||||
* players, monsters, items on the ground, ...
|
|
||||||
*
|
*
|
||||||
* @author Stan Hebben
|
* @author Stan Hebben
|
||||||
*/
|
*/
|
||||||
@@ -55,8 +54,7 @@ public interface IEntity {
|
|||||||
Position3f getPosition();
|
Position3f getPosition();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the position of this entity. Instantly moves (teleports) the entity
|
* Sets the position of this entity. Instantly moves (teleports) the entity to that position.
|
||||||
* to that position.
|
|
||||||
*
|
*
|
||||||
* @param position entity position
|
* @param position entity position
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
package minetweaker.api.entity;
|
package minetweaker.api.entity;
|
||||||
|
|
||||||
import minetweaker.api.item.IItemStack;
|
|
||||||
import stanhebben.zenscript.annotations.Optional;
|
|
||||||
import stanhebben.zenscript.annotations.*;
|
|
||||||
import stanhebben.zenscript.value.*;
|
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
import minetweaker.api.item.IItemStack;
|
||||||
|
import stanhebben.zenscript.annotations.*;
|
||||||
|
import stanhebben.zenscript.annotations.Optional;
|
||||||
|
import stanhebben.zenscript.value.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Stan Hebben
|
* @author Stan Hebben
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ import minetweaker.api.item.IItemStack;
|
|||||||
import stanhebben.zenscript.annotations.ZenGetter;
|
import stanhebben.zenscript.annotations.ZenGetter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents an item entity. Item entities are entities representing an item
|
* Represents an item entity. Item entities are entities representing an item stack on the ground (or flying through the
|
||||||
* stack on the ground (or flying through the air).
|
* air).
|
||||||
*
|
*
|
||||||
* @author Stan Hebben
|
* @author Stan Hebben
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package minetweaker.api.event;
|
package minetweaker.api.event;
|
||||||
|
|
||||||
import stanhebben.zenscript.annotations.*;
|
|
||||||
|
|
||||||
import java.io.Closeable;
|
import java.io.Closeable;
|
||||||
|
|
||||||
|
import stanhebben.zenscript.annotations.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents an event handle. Event handles are used to cancel event listeners.
|
* Represents an event handle. Event handles are used to cancel event listeners.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -50,48 +50,18 @@ public interface IEventManager {
|
|||||||
IEventHandle onPlayerUseItemTick(IEventHandler<PlayerUseItemTickEvent> ev);
|
IEventHandle onPlayerUseItemTick(IEventHandler<PlayerUseItemTickEvent> ev);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* IEventHandle
|
* IEventHandle onPlayerUseItemStop(IEventHandler<PlayerUseItemStopEvent> ev); IEventHandle
|
||||||
* onPlayerUseItemStop(IEventHandler<PlayerUseItemStopEvent> ev);
|
* onPlayerUseItemFinish(IPlayerUserItemFinishEventHandler ev); IEventHandle onPlayerChat(IPlayerChatEventHandler
|
||||||
*
|
* ev); IEventHandle onTimerSingle(int millis, ITimerEventHandler ev); IEventHandle onTimerRepeat(int millis,
|
||||||
* IEventHandle
|
* ITimerEventHandler ev); IEventHandle onEntityJoinWorld(IEntityJoinWorldEventHandler ev); IEventHandle
|
||||||
* onPlayerUseItemFinish(IPlayerUserItemFinishEventHandler ev);
|
* onEntityStruckByLightning(IEntityStruckByLightningEventHandler ev); IEventHandle
|
||||||
*
|
* onLivingEnderTeleport(ILivingEnderTeleportEventHandler ev); IEventHandle
|
||||||
* IEventHandle onPlayerChat(IPlayerChatEventHandler ev);
|
* onLivingAttackEvent(ILivingAttackEventHandler ev); IEventHandle onLivingDeathEvent(ILivingDeathEventHandler ev);
|
||||||
*
|
* IEventHandle onLivingJumpEvent(ILivingJumpEventHandler ev); IEventHandle
|
||||||
* IEventHandle onTimerSingle(int millis, ITimerEventHandler ev);
|
* onLivingFallEvent(ILivingFallEventHandler ev); IEventHandle onLivingHurtEvent(ILivingHurtEventHandler ev);
|
||||||
*
|
* IEventHandle onLivingDeathDropsEvent(ILivingDeathDropsEventHandler ev); IEventHandle
|
||||||
* IEventHandle onTimerRepeat(int millis, ITimerEventHandler ev);
|
* onItemTossed(IItemTossedEventHandler ev); IEventHandle onItemExpired(IItemExpiredEventHandler ev); IEventHandle
|
||||||
*
|
* onMinecartCollision(IMinecartCollisionEventHandler ev); IEventHandle
|
||||||
* IEventHandle onEntityJoinWorld(IEntityJoinWorldEventHandler ev);
|
* onMinecartInteract(IMinecartInteractEventHandler ev); IEventHandle onCommand(ICommandEventHandler ev);
|
||||||
*
|
|
||||||
* IEventHandle
|
|
||||||
* onEntityStruckByLightning(IEntityStruckByLightningEventHandler ev);
|
|
||||||
*
|
|
||||||
* IEventHandle
|
|
||||||
* onLivingEnderTeleport(ILivingEnderTeleportEventHandler ev);
|
|
||||||
*
|
|
||||||
* IEventHandle onLivingAttackEvent(ILivingAttackEventHandler ev);
|
|
||||||
*
|
|
||||||
* IEventHandle onLivingDeathEvent(ILivingDeathEventHandler ev);
|
|
||||||
*
|
|
||||||
* IEventHandle onLivingJumpEvent(ILivingJumpEventHandler ev);
|
|
||||||
*
|
|
||||||
* IEventHandle onLivingFallEvent(ILivingFallEventHandler ev);
|
|
||||||
*
|
|
||||||
* IEventHandle onLivingHurtEvent(ILivingHurtEventHandler ev);
|
|
||||||
*
|
|
||||||
* IEventHandle onLivingDeathDropsEvent(ILivingDeathDropsEventHandler
|
|
||||||
* ev);
|
|
||||||
*
|
|
||||||
* IEventHandle onItemTossed(IItemTossedEventHandler ev);
|
|
||||||
*
|
|
||||||
* IEventHandle onItemExpired(IItemExpiredEventHandler ev);
|
|
||||||
*
|
|
||||||
* IEventHandle onMinecartCollision(IMinecartCollisionEventHandler
|
|
||||||
* ev);
|
|
||||||
*
|
|
||||||
* IEventHandle onMinecartInteract(IMinecartInteractEventHandler ev);
|
|
||||||
*
|
|
||||||
* IEventHandle onCommand(ICommandEventHandler ev);
|
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
@@ -1,12 +1,12 @@
|
|||||||
package minetweaker.api.event;
|
package minetweaker.api.event;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import minetweaker.api.damage.IDamageSource;
|
import minetweaker.api.damage.IDamageSource;
|
||||||
import minetweaker.api.entity.IEntityItem;
|
import minetweaker.api.entity.IEntityItem;
|
||||||
import minetweaker.api.player.IPlayer;
|
import minetweaker.api.player.IPlayer;
|
||||||
import stanhebben.zenscript.annotations.*;
|
import stanhebben.zenscript.annotations.*;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Stan
|
* @author Stan
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package minetweaker.api.game;
|
package minetweaker.api.game;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import minetweaker.api.block.IBlockDefinition;
|
import minetweaker.api.block.IBlockDefinition;
|
||||||
import minetweaker.api.entity.IEntityDefinition;
|
import minetweaker.api.entity.IEntityDefinition;
|
||||||
import minetweaker.api.item.IItemDefinition;
|
import minetweaker.api.item.IItemDefinition;
|
||||||
@@ -7,8 +9,6 @@ import minetweaker.api.liquid.ILiquidDefinition;
|
|||||||
import minetweaker.api.world.IBiome;
|
import minetweaker.api.world.IBiome;
|
||||||
import stanhebben.zenscript.annotations.*;
|
import stanhebben.zenscript.annotations.*;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Game interface. Used to obtain general game information.
|
* Game interface. Used to obtain general game information.
|
||||||
*
|
*
|
||||||
@@ -103,8 +103,7 @@ public interface IGame {
|
|||||||
/**
|
/**
|
||||||
* Lock the game and disable reload. Recommended for distributed versions.
|
* Lock the game and disable reload. Recommended for distributed versions.
|
||||||
* <p>
|
* <p>
|
||||||
* Once locked, reload cannot be unlocked - a game restart is required to
|
* Once locked, reload cannot be unlocked - a game restart is required to alter the scripts.
|
||||||
* alter the scripts.
|
|
||||||
*/
|
*/
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
void lock();
|
void lock();
|
||||||
|
|||||||
@@ -1,18 +1,17 @@
|
|||||||
package minetweaker.api.item;
|
package minetweaker.api.item;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import minetweaker.api.liquid.ILiquidStack;
|
import minetweaker.api.liquid.ILiquidStack;
|
||||||
import minetweaker.api.player.IPlayer;
|
import minetweaker.api.player.IPlayer;
|
||||||
import stanhebben.zenscript.annotations.*;
|
import stanhebben.zenscript.annotations.*;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a recipe ingredient. An ingredient can be an item, an ore
|
* Represents a recipe ingredient. An ingredient can be an item, an ore dictionary entry, an item stack, an ore
|
||||||
* dictionary entry, an item stack, an ore dictionary entry multiplied with an
|
* dictionary entry multiplied with an amount, or other kinds of ingredients as offered by the API.
|
||||||
* amount, or other kinds of ingredients as offered by the API.
|
|
||||||
* <p>
|
* <p>
|
||||||
* There is no guarantee that every mod will respect the conditions or
|
* There is no guarantee that every mod will respect the conditions or transformations, or that every mod will support
|
||||||
* transformations, or that every mod will support every kind of ingredient.
|
* every kind of ingredient.
|
||||||
*
|
*
|
||||||
* @author Stan Hebben
|
* @author Stan Hebben
|
||||||
*/
|
*/
|
||||||
@@ -20,8 +19,7 @@ import java.util.List;
|
|||||||
public interface IIngredient {
|
public interface IIngredient {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the mark of the ingredient. Ingredients can be marked so they can be
|
* Gets the mark of the ingredient. Ingredients can be marked so they can be used in crafting functions.
|
||||||
* used in crafting functions.
|
|
||||||
*
|
*
|
||||||
* @return ingredient mark
|
* @return ingredient mark
|
||||||
*/
|
*/
|
||||||
@@ -31,8 +29,7 @@ public interface IIngredient {
|
|||||||
/**
|
/**
|
||||||
* Gets the amount.
|
* Gets the amount.
|
||||||
* <p>
|
* <p>
|
||||||
* Should return -1 if no amount is available and 1 for a single item.
|
* Should return -1 if no amount is available and 1 for a single item. Stacks return the stack size.
|
||||||
* Stacks return the stack size.
|
|
||||||
*
|
*
|
||||||
* @return stack size
|
* @return stack size
|
||||||
*/
|
*/
|
||||||
@@ -42,8 +39,7 @@ public interface IIngredient {
|
|||||||
/**
|
/**
|
||||||
* Gets all possible items for this ingredient.
|
* Gets all possible items for this ingredient.
|
||||||
* <p>
|
* <p>
|
||||||
* If there is no item list (for example, it is the <*> wildcard item)
|
* If there is no item list (for example, it is the <*> wildcard item) null should be returned.
|
||||||
* null should be returned.
|
|
||||||
*
|
*
|
||||||
* @return the items for this ingredient, or null
|
* @return the items for this ingredient, or null
|
||||||
*/
|
*/
|
||||||
@@ -53,8 +49,7 @@ public interface IIngredient {
|
|||||||
/**
|
/**
|
||||||
* Gets all possible liquids for this ingredient.
|
* Gets all possible liquids for this ingredient.
|
||||||
* <p>
|
* <p>
|
||||||
* If there is no liquid list (for example, it is the <*&ft; wildcard
|
* If there is no liquid list (for example, it is the <*&ft; wildcard item) null should be returned.
|
||||||
* item) null should be returned.
|
|
||||||
*
|
*
|
||||||
* @return the liquids for this ingredient, or null
|
* @return the liquids for this ingredient, or null
|
||||||
*/
|
*/
|
||||||
@@ -73,8 +68,7 @@ public interface IIngredient {
|
|||||||
IIngredient amount(int amount);
|
IIngredient amount(int amount);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Combines multiple ingredients into a single one. Note that ore dictionary
|
* Combines multiple ingredients into a single one. Note that ore dictionary entries are preferred to or statements.
|
||||||
* entries are preferred to or statements.
|
|
||||||
*
|
*
|
||||||
* @param ingredient ingredient to combine with
|
* @param ingredient ingredient to combine with
|
||||||
*
|
*
|
||||||
@@ -115,8 +109,7 @@ public interface IIngredient {
|
|||||||
IIngredient marked(String mark);
|
IIngredient marked(String mark);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if this ingredient matches the given item. For liquids, will match
|
* Checks if this ingredient matches the given item. For liquids, will match the item if it is a valid container.
|
||||||
* the item if it is a valid container.
|
|
||||||
*
|
*
|
||||||
* @param item item to check
|
* @param item item to check
|
||||||
*
|
*
|
||||||
@@ -126,8 +119,7 @@ public interface IIngredient {
|
|||||||
boolean matches(IItemStack item);
|
boolean matches(IItemStack item);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if this ingredient matches the given item. For liquids, will match
|
* Checks if this ingredient matches the given item. For liquids, will match the item if it is a valid container.
|
||||||
* the item if it is a valid container.
|
|
||||||
*
|
*
|
||||||
* @param item item to check
|
* @param item item to check
|
||||||
*
|
*
|
||||||
@@ -136,7 +128,6 @@ public interface IIngredient {
|
|||||||
@ZenMethod
|
@ZenMethod
|
||||||
boolean matchesExact(IItemStack item);
|
boolean matchesExact(IItemStack item);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if this ingredient matches the given liquid.
|
* Checks if this ingredient matches the given liquid.
|
||||||
*
|
*
|
||||||
@@ -148,8 +139,7 @@ public interface IIngredient {
|
|||||||
boolean matches(ILiquidStack liquid);
|
boolean matches(ILiquidStack liquid);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if this ingredient contains all possible values for the given
|
* Check if this ingredient contains all possible values for the given ingredient.
|
||||||
* ingredient.
|
|
||||||
*
|
*
|
||||||
* @param ingredient ingredient to check
|
* @param ingredient ingredient to check
|
||||||
*
|
*
|
||||||
@@ -172,8 +162,7 @@ public interface IIngredient {
|
|||||||
/**
|
/**
|
||||||
* Checks if this ingredient has (or could have) any transformatiosns.
|
* Checks if this ingredient has (or could have) any transformatiosns.
|
||||||
*
|
*
|
||||||
* @return true if there are (or could be) any transformations false
|
* @return true if there are (or could be) any transformations false otherwise.
|
||||||
* otherwise.
|
|
||||||
*/
|
*/
|
||||||
@ZenGetter("hasTransformations")
|
@ZenGetter("hasTransformations")
|
||||||
boolean hasTransformers();
|
boolean hasTransformers();
|
||||||
@@ -181,9 +170,8 @@ public interface IIngredient {
|
|||||||
/**
|
/**
|
||||||
* Gets the internal item backing this ingredient.
|
* Gets the internal item backing this ingredient.
|
||||||
* <p>
|
* <p>
|
||||||
* The value is implementation-dependent and should only be handled by the
|
* The value is implementation-dependent and should only be handled by the internal code. Don't use this value -
|
||||||
* internal code. Don't use this value - instead, use the version-specific
|
* instead, use the version-specific helper methods.
|
||||||
* helper methods.
|
|
||||||
*
|
*
|
||||||
* @return internal item
|
* @return internal item
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -5,9 +5,8 @@ import stanhebben.zenscript.annotations.ZenClass;
|
|||||||
/**
|
/**
|
||||||
* Item conditions apply additional conditions on item stacks.
|
* Item conditions apply additional conditions on item stacks.
|
||||||
* <p>
|
* <p>
|
||||||
* They may, for instance, require specific damage ranges or NBT tags. Custom
|
* They may, for instance, require specific damage ranges or NBT tags. Custom implementations of this functional
|
||||||
* implementations of this functional interface may contain any kind of
|
* interface may contain any kind of condition.
|
||||||
* condition.
|
|
||||||
*
|
*
|
||||||
* @author Stan Hebben
|
* @author Stan Hebben
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,16 +1,15 @@
|
|||||||
package minetweaker.api.item;
|
package minetweaker.api.item;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import minetweaker.api.oredict.IOreDictEntry;
|
import minetweaker.api.oredict.IOreDictEntry;
|
||||||
import stanhebben.zenscript.annotations.*;
|
import stanhebben.zenscript.annotations.*;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Contains an item definition. Item definitions provide general information
|
* Contains an item definition. Item definitions provide general information about an item, such as its name and ID.
|
||||||
* about an item, such as its name and ID.
|
|
||||||
* <p>
|
* <p>
|
||||||
* Item definitions themselves have no localized name, as it could be different
|
* Item definitions themselves have no localized name, as it could be different for each subitem or even depend on NBT
|
||||||
* for each subitem or even depend on NBT tags.
|
* tags.
|
||||||
*
|
*
|
||||||
* @author Stan Hebben
|
* @author Stan Hebben
|
||||||
*/
|
*/
|
||||||
@@ -44,8 +43,7 @@ public interface IItemDefinition {
|
|||||||
IItemStack makeStack(@Optional int meta);
|
IItemStack makeStack(@Optional int meta);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns all ore entries containing this item. Also contains ore entries
|
* Returns all ore entries containing this item. Also contains ore entries that refer to a specific sub-item.
|
||||||
* that refer to a specific sub-item.
|
|
||||||
*
|
*
|
||||||
* @return all the ore entries containing this item.
|
* @return all the ore entries containing this item.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,25 +1,22 @@
|
|||||||
package minetweaker.api.item;
|
package minetweaker.api.item;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import minetweaker.api.block.IBlock;
|
import minetweaker.api.block.IBlock;
|
||||||
import minetweaker.api.data.IData;
|
import minetweaker.api.data.IData;
|
||||||
import minetweaker.api.liquid.ILiquidStack;
|
import minetweaker.api.liquid.ILiquidStack;
|
||||||
import minetweaker.api.oredict.IOreDictEntry;
|
import minetweaker.api.oredict.IOreDictEntry;
|
||||||
import stanhebben.zenscript.annotations.*;
|
import stanhebben.zenscript.annotations.*;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Contains an item stack. An item stack consists of an item definition, a meta
|
* Contains an item stack. An item stack consists of an item definition, a meta or damage value and NBT data.
|
||||||
* or damage value and NBT data.
|
|
||||||
* <p>
|
* <p>
|
||||||
* Item stacks can be retrieved using its name (or ID, in 1.6.4) with the
|
* Item stacks can be retrieved using its name (or ID, in 1.6.4) with the bracket syntax. When using the bracket syntax,
|
||||||
* bracket syntax. When using the bracket syntax, by default, the item stack
|
* by default, the item stack will match any size when used as ingredient. Item stacks can be multiplied with an integer
|
||||||
* will match any size when used as ingredient. Item stacks can be multiplied
|
* to create a stack of different size.
|
||||||
* with an integer to create a stack of different size.
|
|
||||||
* <p>
|
* <p>
|
||||||
* Item stacks are immutable. You can, however, easily create modified stacks
|
* Item stacks are immutable. You can, however, easily create modified stacks using the helper methods. Adding
|
||||||
* using the helper methods. Adding conditions and transformations will turn the
|
* conditions and transformations will turn the item stack into an ingredients.
|
||||||
* item stack into an ingredients.
|
|
||||||
*
|
*
|
||||||
* @author Stan Hebben
|
* @author Stan Hebben
|
||||||
*/
|
*/
|
||||||
@@ -43,9 +40,8 @@ public interface IItemStack extends IIngredient {
|
|||||||
String getName();
|
String getName();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the display name. By default, it is the localized item name, but
|
* Gets the display name. By default, it is the localized item name, but could also be the display name from NBT
|
||||||
* could also be the display name from NBT data, or another item-specific
|
* data, or another item-specific name.
|
||||||
* name.
|
|
||||||
*
|
*
|
||||||
* @return item display name
|
* @return item display name
|
||||||
*/
|
*/
|
||||||
@@ -53,8 +49,8 @@ public interface IItemStack extends IIngredient {
|
|||||||
String getDisplayName();
|
String getDisplayName();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the display name. Only works if the name is translatable. Does not
|
* Sets the display name. Only works if the name is translatable. Does not override names set by NBT data or using
|
||||||
* override names set by NBT data or using item-specific logic.
|
* item-specific logic.
|
||||||
*
|
*
|
||||||
* @param name item display name
|
* @param name item display name
|
||||||
*/
|
*/
|
||||||
@@ -116,9 +112,8 @@ public interface IItemStack extends IIngredient {
|
|||||||
void setMaxDamage(int damage);
|
void setMaxDamage(int damage);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the item tag. (NBT data) The resulting data is immutable and can
|
* Gets the item tag. (NBT data) The resulting data is immutable and can only be changed with updateTag. Returns
|
||||||
* only be changed with updateTag. Returns empty data if there is no data.
|
* empty data if there is no data. Never returns null.
|
||||||
* Never returns null.
|
|
||||||
*
|
*
|
||||||
* @return item tag
|
* @return item tag
|
||||||
*/
|
*/
|
||||||
@@ -126,9 +121,8 @@ public interface IItemStack extends IIngredient {
|
|||||||
IData getTag();
|
IData getTag();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the liquid contained in this item, if any. If this item stack is not
|
* Gets the liquid contained in this item, if any. If this item stack is not an item container, it returns null.
|
||||||
* an item container, it returns null. Only returns the amount of liquid in
|
* Only returns the amount of liquid in a single item and doesn't into account stack size.
|
||||||
* a single item and doesn't into account stack size.
|
|
||||||
*
|
*
|
||||||
* @return liquid data
|
* @return liquid data
|
||||||
*/
|
*/
|
||||||
@@ -146,8 +140,7 @@ public interface IItemStack extends IIngredient {
|
|||||||
IItemStack amount(int amount);
|
IItemStack amount(int amount);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a weighted item stack with the given percentage chance. Does the
|
* Creates a weighted item stack with the given percentage chance. Does the same as item.weight(p * 0.01).
|
||||||
* same as item.weight(p * 0.01).
|
|
||||||
*
|
*
|
||||||
* @param p probability, with percent
|
* @param p probability, with percent
|
||||||
*
|
*
|
||||||
@@ -167,8 +160,8 @@ public interface IItemStack extends IIngredient {
|
|||||||
WeightedItemStack weight(float p);
|
WeightedItemStack weight(float p);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an item stack with the same item and stack size, but accepting
|
* Creates an item stack with the same item and stack size, but accepting any damage value. Only useful for items
|
||||||
* any damage value. Only useful for items used as ingredients.
|
* used as ingredients.
|
||||||
*
|
*
|
||||||
* @return item stack with wildcard damage
|
* @return item stack with wildcard damage
|
||||||
*/
|
*/
|
||||||
@@ -252,8 +245,7 @@ public interface IItemStack extends IIngredient {
|
|||||||
IBlock asBlock();
|
IBlock asBlock();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves all the ores referring to this item. Includes wildcard ore
|
* Retrieves all the ores referring to this item. Includes wildcard ore entries.
|
||||||
* entries.
|
|
||||||
*
|
*
|
||||||
* @return ore entries containing this item stack
|
* @return ore entries containing this item stack
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -4,9 +4,8 @@ import minetweaker.api.player.IPlayer;
|
|||||||
import stanhebben.zenscript.annotations.*;
|
import stanhebben.zenscript.annotations.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An item transformer modifies an item stack after crafting. Used to apply
|
* An item transformer modifies an item stack after crafting. Used to apply damage, grab multiple items, change NBT
|
||||||
* damage, grab multiple items, change NBT tags, replace the item with something
|
* tags, replace the item with something else - or whatever else you'd want to happen to the input stack.
|
||||||
* else - or whatever else you'd want to happen to the input stack.
|
|
||||||
*
|
*
|
||||||
* @author Stan Hebben
|
* @author Stan Hebben
|
||||||
*/
|
*/
|
||||||
@@ -14,8 +13,7 @@ import stanhebben.zenscript.annotations.*;
|
|||||||
public interface IItemTransformer {
|
public interface IItemTransformer {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transforms the specified item. May modify this item (and return it) or
|
* Transforms the specified item. May modify this item (and return it) or return an entirely new one.
|
||||||
* return an entirely new one.
|
|
||||||
*
|
*
|
||||||
* @param item input item
|
* @param item input item
|
||||||
* @param byPlayer player that performs the crafting
|
* @param byPlayer player that performs the crafting
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
package minetweaker.api.item;
|
package minetweaker.api.item;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import minetweaker.api.liquid.ILiquidStack;
|
import minetweaker.api.liquid.ILiquidStack;
|
||||||
import minetweaker.api.player.IPlayer;
|
import minetweaker.api.player.IPlayer;
|
||||||
import minetweaker.util.ArrayUtil;
|
import minetweaker.util.ArrayUtil;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the wildcard ingredient (<*>).
|
* Represents the wildcard ingredient (<*>).
|
||||||
*
|
*
|
||||||
@@ -18,8 +18,7 @@ public class IngredientAny implements IIngredient {
|
|||||||
public static Object INTERNAL_ANY = null; // platforms supporting an "any"
|
public static Object INTERNAL_ANY = null; // platforms supporting an "any"
|
||||||
// item should fill it here
|
// item should fill it here
|
||||||
|
|
||||||
private IngredientAny() {
|
private IngredientAny() {}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getMark() {
|
public String getMark() {
|
||||||
@@ -76,7 +75,6 @@ public class IngredientAny implements IIngredient {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(ILiquidStack liquid) {
|
public boolean matches(ILiquidStack liquid) {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -1,14 +1,13 @@
|
|||||||
package minetweaker.api.item;
|
package minetweaker.api.item;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import minetweaker.api.liquid.ILiquidStack;
|
import minetweaker.api.liquid.ILiquidStack;
|
||||||
import minetweaker.api.player.IPlayer;
|
import minetweaker.api.player.IPlayer;
|
||||||
import minetweaker.util.ArrayUtil;
|
import minetweaker.util.ArrayUtil;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the wildcard ingredient, with conditions and/or transformers
|
* Represents the wildcard ingredient, with conditions and/or transformers applied to it.
|
||||||
* applied to it.
|
|
||||||
*
|
*
|
||||||
* @author Stan Hebben
|
* @author Stan Hebben
|
||||||
*/
|
*/
|
||||||
@@ -72,8 +71,7 @@ public class IngredientAnyAdvanced implements IIngredient {
|
|||||||
@Override
|
@Override
|
||||||
public boolean matches(IItemStack item) {
|
public boolean matches(IItemStack item) {
|
||||||
for (IItemCondition condition : conditions) {
|
for (IItemCondition condition : conditions) {
|
||||||
if(!condition.matches(item))
|
if (!condition.matches(item)) return false;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -82,8 +80,7 @@ public class IngredientAnyAdvanced implements IIngredient {
|
|||||||
@Override
|
@Override
|
||||||
public boolean matchesExact(IItemStack item) {
|
public boolean matchesExact(IItemStack item) {
|
||||||
for (IItemCondition condition : conditions) {
|
for (IItemCondition condition : conditions) {
|
||||||
if(!condition.matches(item))
|
if (!condition.matches(item)) return false;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -99,8 +96,7 @@ public class IngredientAnyAdvanced implements IIngredient {
|
|||||||
public boolean contains(IIngredient ingredient) {
|
public boolean contains(IIngredient ingredient) {
|
||||||
List<IItemStack> iitems = ingredient.getItems();
|
List<IItemStack> iitems = ingredient.getItems();
|
||||||
for (IItemStack iitem : iitems) {
|
for (IItemStack iitem : iitems) {
|
||||||
if(!matches(iitem))
|
if (!matches(iitem)) return false;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -4,9 +4,8 @@ import minetweaker.api.data.IData;
|
|||||||
import stanhebben.zenscript.annotations.*;
|
import stanhebben.zenscript.annotations.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Conditions can be used to set requirements for matching items. They can be
|
* Conditions can be used to set requirements for matching items. They can be used to require specific NBT tags or
|
||||||
* used to require specific NBT tags or damage values, requiring changed items
|
* damage values, requiring changed items or as complement to damage-consuming or stack-consuming recipes.
|
||||||
* or as complement to damage-consuming or stack-consuming recipes.
|
|
||||||
*
|
*
|
||||||
* @author Stan Hebben
|
* @author Stan Hebben
|
||||||
*/
|
*/
|
||||||
@@ -23,6 +22,7 @@ public class IngredientCondition {
|
|||||||
@ZenMethod
|
@ZenMethod
|
||||||
public static IIngredient onlyDamaged(IIngredient ingredient) {
|
public static IIngredient onlyDamaged(IIngredient ingredient) {
|
||||||
return ingredient.only(new IItemCondition() {
|
return ingredient.only(new IItemCondition() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(IItemStack stack) {
|
public boolean matches(IItemStack stack) {
|
||||||
return stack.getDamage() > 0;
|
return stack.getDamage() > 0;
|
||||||
@@ -41,6 +41,7 @@ public class IngredientCondition {
|
|||||||
@ZenMethod
|
@ZenMethod
|
||||||
public static IIngredient onlyDamageAtLeast(IIngredient ingredient, final int minDamage) {
|
public static IIngredient onlyDamageAtLeast(IIngredient ingredient, final int minDamage) {
|
||||||
return ingredient.only(new IItemCondition() {
|
return ingredient.only(new IItemCondition() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(IItemStack stack) {
|
public boolean matches(IItemStack stack) {
|
||||||
return stack.getDamage() >= minDamage;
|
return stack.getDamage() >= minDamage;
|
||||||
@@ -49,8 +50,7 @@ public class IngredientCondition {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Requires the item to be damaged with at most a specified amount. An
|
* Requires the item to be damaged with at most a specified amount. An undamaged item is accepted.
|
||||||
* undamaged item is accepted.
|
|
||||||
*
|
*
|
||||||
* @param ingredient target value
|
* @param ingredient target value
|
||||||
* @param maxDamage maximum damage
|
* @param maxDamage maximum damage
|
||||||
@@ -60,6 +60,7 @@ public class IngredientCondition {
|
|||||||
@ZenMethod
|
@ZenMethod
|
||||||
public static IIngredient onlyDamageAtMost(IIngredient ingredient, final int maxDamage) {
|
public static IIngredient onlyDamageAtMost(IIngredient ingredient, final int maxDamage) {
|
||||||
return ingredient.only(new IItemCondition() {
|
return ingredient.only(new IItemCondition() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(IItemStack stack) {
|
public boolean matches(IItemStack stack) {
|
||||||
return stack.getDamage() <= maxDamage;
|
return stack.getDamage() <= maxDamage;
|
||||||
@@ -79,6 +80,7 @@ public class IngredientCondition {
|
|||||||
@ZenMethod
|
@ZenMethod
|
||||||
public static IIngredient onlyDamageBetween(IIngredient ingredient, final int minDamage, final int maxDamage) {
|
public static IIngredient onlyDamageBetween(IIngredient ingredient, final int minDamage, final int maxDamage) {
|
||||||
return ingredient.only(new IItemCondition() {
|
return ingredient.only(new IItemCondition() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(IItemStack stack) {
|
public boolean matches(IItemStack stack) {
|
||||||
return stack.getDamage() >= minDamage && stack.getDamage() <= maxDamage;
|
return stack.getDamage() >= minDamage && stack.getDamage() <= maxDamage;
|
||||||
@@ -87,8 +89,8 @@ public class IngredientCondition {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Requires the item to contain at least the given tags. It is OK for the
|
* Requires the item to contain at least the given tags. It is OK for the item to contain more data, as remaining
|
||||||
* item to contain more data, as remaining data is ignored.
|
* data is ignored.
|
||||||
*
|
*
|
||||||
* @param ingredient target value
|
* @param ingredient target value
|
||||||
* @param data required data
|
* @param data required data
|
||||||
@@ -98,6 +100,7 @@ public class IngredientCondition {
|
|||||||
@ZenMethod
|
@ZenMethod
|
||||||
public static IIngredient onlyWithTag(IIngredient ingredient, final IData data) {
|
public static IIngredient onlyWithTag(IIngredient ingredient, final IData data) {
|
||||||
return ingredient.only(new IItemCondition() {
|
return ingredient.only(new IItemCondition() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(IItemStack stack) {
|
public boolean matches(IItemStack stack) {
|
||||||
return stack.getTag() != null && stack.getTag().contains(data);
|
return stack.getTag() != null && stack.getTag().contains(data);
|
||||||
@@ -106,8 +109,8 @@ public class IngredientCondition {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Requires the input stack to contain at least the given number of items.
|
* Requires the input stack to contain at least the given number of items. Used in combination with stack consuming
|
||||||
* Used in combination with stack consuming recipes.
|
* recipes.
|
||||||
*
|
*
|
||||||
* @param ingredient target value
|
* @param ingredient target value
|
||||||
* @param amount required stack size
|
* @param amount required stack size
|
||||||
@@ -117,6 +120,7 @@ public class IngredientCondition {
|
|||||||
@ZenMethod
|
@ZenMethod
|
||||||
public static IIngredient onlyStack(IIngredient ingredient, final int amount) {
|
public static IIngredient onlyStack(IIngredient ingredient, final int amount) {
|
||||||
return ingredient.only(new IItemCondition() {
|
return ingredient.only(new IItemCondition() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(IItemStack stack) {
|
public boolean matches(IItemStack stack) {
|
||||||
return stack.getAmount() >= amount;
|
return stack.getAmount() >= amount;
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
package minetweaker.api.item;
|
package minetweaker.api.item;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
import minetweaker.api.liquid.ILiquidStack;
|
import minetweaker.api.liquid.ILiquidStack;
|
||||||
import minetweaker.api.player.IPlayer;
|
import minetweaker.api.player.IPlayer;
|
||||||
import minetweaker.util.ArrayUtil;
|
import minetweaker.util.ArrayUtil;
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Contains an item stack with modifiers applied to it.
|
* Contains an item stack with modifiers applied to it.
|
||||||
*
|
*
|
||||||
@@ -75,12 +75,10 @@ public class IngredientItem implements IIngredient {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(IItemStack item) {
|
public boolean matches(IItemStack item) {
|
||||||
if(!this.item.matches(item))
|
if (!this.item.matches(item)) return false;
|
||||||
return false;
|
|
||||||
|
|
||||||
for (IItemCondition condition : conditions) {
|
for (IItemCondition condition : conditions) {
|
||||||
if(!condition.matches(item))
|
if (!condition.matches(item)) return false;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -88,12 +86,10 @@ public class IngredientItem implements IIngredient {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matchesExact(IItemStack item) {
|
public boolean matchesExact(IItemStack item) {
|
||||||
if(!this.item.matchesExact(item))
|
if (!this.item.matchesExact(item)) return false;
|
||||||
return false;
|
|
||||||
|
|
||||||
for (IItemCondition condition : conditions) {
|
for (IItemCondition condition : conditions) {
|
||||||
if(!condition.matches(item))
|
if (!condition.matches(item)) return false;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -108,8 +104,7 @@ public class IngredientItem implements IIngredient {
|
|||||||
public boolean contains(IIngredient ingredient) {
|
public boolean contains(IIngredient ingredient) {
|
||||||
List<IItemStack> iitems = ingredient.getItems();
|
List<IItemStack> iitems = ingredient.getItems();
|
||||||
for (IItemStack iitem : iitems) {
|
for (IItemStack iitem : iitems) {
|
||||||
if(!matches(iitem))
|
if (!matches(iitem)) return false;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
package minetweaker.api.item;
|
package minetweaker.api.item;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
import minetweaker.api.liquid.ILiquidStack;
|
import minetweaker.api.liquid.ILiquidStack;
|
||||||
import minetweaker.api.player.IPlayer;
|
import minetweaker.api.player.IPlayer;
|
||||||
import minetweaker.util.ArrayUtil;
|
import minetweaker.util.ArrayUtil;
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Stan
|
* @author Stan
|
||||||
*/
|
*/
|
||||||
@@ -27,7 +27,8 @@ public class IngredientOr implements IIngredient {
|
|||||||
this(new IIngredient[] { a, b });
|
this(new IIngredient[] { a, b });
|
||||||
}
|
}
|
||||||
|
|
||||||
private IngredientOr(IIngredient[] elements, String mark, IItemCondition[] conditions, IItemTransformer[] transformers) {
|
private IngredientOr(IIngredient[] elements, String mark, IItemCondition[] conditions,
|
||||||
|
IItemTransformer[] transformers) {
|
||||||
this.elements = elements;
|
this.elements = elements;
|
||||||
this.mark = mark;
|
this.mark = mark;
|
||||||
this.conditions = conditions;
|
this.conditions = conditions;
|
||||||
@@ -94,8 +95,7 @@ public class IngredientOr implements IIngredient {
|
|||||||
@Override
|
@Override
|
||||||
public boolean matches(IItemStack item) {
|
public boolean matches(IItemStack item) {
|
||||||
for (IIngredient ingredient : elements) {
|
for (IIngredient ingredient : elements) {
|
||||||
if(ingredient.matches(item))
|
if (ingredient.matches(item)) return true;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -104,8 +104,7 @@ public class IngredientOr implements IIngredient {
|
|||||||
@Override
|
@Override
|
||||||
public boolean matchesExact(IItemStack item) {
|
public boolean matchesExact(IItemStack item) {
|
||||||
for (IIngredient ingredient : elements) {
|
for (IIngredient ingredient : elements) {
|
||||||
if(ingredient.matchesExact(item))
|
if (ingredient.matchesExact(item)) return true;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -114,8 +113,7 @@ public class IngredientOr implements IIngredient {
|
|||||||
@Override
|
@Override
|
||||||
public boolean matches(ILiquidStack liquid) {
|
public boolean matches(ILiquidStack liquid) {
|
||||||
for (IIngredient ingredient : elements) {
|
for (IIngredient ingredient : elements) {
|
||||||
if(ingredient.matches(liquid))
|
if (ingredient.matches(liquid)) return true;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -125,8 +123,7 @@ public class IngredientOr implements IIngredient {
|
|||||||
public boolean contains(IIngredient ingredient) {
|
public boolean contains(IIngredient ingredient) {
|
||||||
List<IItemStack> items = ingredient.getItems();
|
List<IItemStack> items = ingredient.getItems();
|
||||||
for (IItemStack item : items) {
|
for (IItemStack item : items) {
|
||||||
if(!matches(item))
|
if (!matches(item)) return false;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
package minetweaker.api.item;
|
package minetweaker.api.item;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
import minetweaker.api.liquid.ILiquidStack;
|
import minetweaker.api.liquid.ILiquidStack;
|
||||||
import minetweaker.api.player.IPlayer;
|
import minetweaker.api.player.IPlayer;
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Contains an ingredient stack. Is an ingredient with a specific stack size
|
* Contains an ingredient stack. Is an ingredient with a specific stack size assigned to it.
|
||||||
* assigned to it.
|
|
||||||
*
|
*
|
||||||
* @author Stan Hebben
|
* @author Stan Hebben
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -3,9 +3,8 @@ package minetweaker.api.item;
|
|||||||
import stanhebben.zenscript.annotations.*;
|
import stanhebben.zenscript.annotations.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transformations can be used to modify an ingredient after it is used in a
|
* Transformations can be used to modify an ingredient after it is used in a crafting recipe. It could reuse the item,
|
||||||
* crafting recipe. It could reuse the item, damage it or consume multiple
|
* damage it or consume multiple items.
|
||||||
* items.
|
|
||||||
*
|
*
|
||||||
* @author Stan Hebben
|
* @author Stan Hebben
|
||||||
*/
|
*/
|
||||||
@@ -25,8 +24,8 @@ public class IngredientTransform {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Damages the item. Also makes the item reusable. Will damage the item for
|
* Damages the item. Also makes the item reusable. Will damage the item for 1 point upon crafting and consume it
|
||||||
* 1 point upon crafting and consume it when broken.
|
* when broken.
|
||||||
*
|
*
|
||||||
* @param ingredient target value
|
* @param ingredient target value
|
||||||
*
|
*
|
||||||
@@ -45,10 +44,8 @@ public class IngredientTransform {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Damages the item for a specific amount. Also makes the item reusable.
|
* Damages the item for a specific amount. Also makes the item reusable. Upon reaching maximum damage, the item will
|
||||||
* Upon reaching maximum damage, the item will be consumed. Take care to set
|
* be consumed. Take care to set the proper condition such that an almost-broken item becomes invalid for crafting.
|
||||||
* the proper condition such that an almost-broken item becomes invalid for
|
|
||||||
* crafting.
|
|
||||||
*
|
*
|
||||||
* @param ingredient target value
|
* @param ingredient target value
|
||||||
* @param damage damage to be applied
|
* @param damage damage to be applied
|
||||||
@@ -68,8 +65,7 @@ public class IngredientTransform {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Causes the item to be replaced upon crafting. Can be used, for instance,
|
* Causes the item to be replaced upon crafting. Can be used, for instance, to return empty bottles or buckets.
|
||||||
* to return empty bottles or buckets.
|
|
||||||
*
|
*
|
||||||
* @param ingredient target value
|
* @param ingredient target value
|
||||||
* @param withItem replacement item
|
* @param withItem replacement item
|
||||||
@@ -89,9 +85,8 @@ public class IngredientTransform {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Causes multiple items to be consumed. Take care to set a condition for a
|
* Causes multiple items to be consumed. Take care to set a condition for a minimum stack size too, as otherwise
|
||||||
* minimum stack size too, as otherwise smaller stacks would still be
|
* smaller stacks would still be accepted for input.
|
||||||
* accepted for input.
|
|
||||||
*
|
*
|
||||||
* @param ingredient target value
|
* @param ingredient target value
|
||||||
* @param amount consumption amount
|
* @param amount consumption amount
|
||||||
@@ -116,8 +111,7 @@ public class IngredientTransform {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gives an item back to the player. Also clears the inventory slot at that
|
* Gives an item back to the player. Also clears the inventory slot at that position.
|
||||||
* position.
|
|
||||||
*
|
*
|
||||||
* @param ingredient
|
* @param ingredient
|
||||||
* @param givenItem
|
* @param givenItem
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
package minetweaker.api.item;
|
package minetweaker.api.item;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
import minetweaker.api.liquid.ILiquidStack;
|
import minetweaker.api.liquid.ILiquidStack;
|
||||||
import minetweaker.api.player.IPlayer;
|
import minetweaker.api.player.IPlayer;
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Stan
|
* @author Stan
|
||||||
*/
|
*/
|
||||||
@@ -73,7 +73,6 @@ public class IngredientUnknown implements IIngredient {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(ILiquidStack liquid) {
|
public boolean matches(ILiquidStack liquid) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
package minetweaker.api.item;
|
package minetweaker.api.item;
|
||||||
|
|
||||||
import stanhebben.zenscript.annotations.*;
|
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
import stanhebben.zenscript.annotations.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Contains a weighted item stack. Weighted item stacks simply contain a stack
|
* Contains a weighted item stack. Weighted item stacks simply contain a stack and a weight.
|
||||||
* and a weight.
|
|
||||||
*
|
*
|
||||||
* @author Stan Hebben
|
* @author Stan Hebben
|
||||||
*/
|
*/
|
||||||
@@ -15,6 +14,7 @@ public final class WeightedItemStack {
|
|||||||
|
|
||||||
private final IItemStack stack;
|
private final IItemStack stack;
|
||||||
private final float p;
|
private final float p;
|
||||||
|
|
||||||
public WeightedItemStack(IItemStack stack, float p) {
|
public WeightedItemStack(IItemStack stack, float p) {
|
||||||
this.stack = stack;
|
this.stack = stack;
|
||||||
this.p = p;
|
this.p = p;
|
||||||
@@ -68,6 +68,7 @@ public final class WeightedItemStack {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final WeightedItemStack other = (WeightedItemStack) obj;
|
final WeightedItemStack other = (WeightedItemStack) obj;
|
||||||
return !(this.stack != other.stack && (this.stack == null || !this.stack.equals(other.stack))) && Float.floatToIntBits(this.p) == Float.floatToIntBits(other.p);
|
return !(this.stack != other.stack && (this.stack == null || !this.stack.equals(other.stack)))
|
||||||
|
&& Float.floatToIntBits(this.p) == Float.floatToIntBits(other.p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,13 +1,12 @@
|
|||||||
package minetweaker.api.liquid;
|
package minetweaker.api.liquid;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import minetweaker.api.item.IItemStack;
|
import minetweaker.api.item.IItemStack;
|
||||||
import stanhebben.zenscript.annotations.*;
|
import stanhebben.zenscript.annotations.*;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Contains a liquid definition. Liquid definitions provide additional
|
* Contains a liquid definition. Liquid definitions provide additional information about liquids.
|
||||||
* information about liquids.
|
|
||||||
*
|
*
|
||||||
* @author Stan Hebben
|
* @author Stan Hebben
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
package minetweaker.api.liquid;
|
package minetweaker.api.liquid;
|
||||||
|
|
||||||
import stanhebben.zenscript.annotations.*;
|
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
import stanhebben.zenscript.annotations.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Contains a weighted item stack. Weighted item stacks simply contain a stack
|
* Contains a weighted item stack. Weighted item stacks simply contain a stack and a weight.
|
||||||
* and a weight.
|
|
||||||
*
|
*
|
||||||
* @author Stan Hebben
|
* @author Stan Hebben
|
||||||
*/
|
*/
|
||||||
@@ -15,6 +14,7 @@ public final class WeightedLiquidStack {
|
|||||||
|
|
||||||
private final ILiquidStack stack;
|
private final ILiquidStack stack;
|
||||||
private final float p;
|
private final float p;
|
||||||
|
|
||||||
public WeightedLiquidStack(ILiquidStack stack, float p) {
|
public WeightedLiquidStack(ILiquidStack stack, float p) {
|
||||||
this.stack = stack;
|
this.stack = stack;
|
||||||
this.p = p;
|
this.p = p;
|
||||||
@@ -68,6 +68,7 @@ public final class WeightedLiquidStack {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final WeightedLiquidStack other = (WeightedLiquidStack) obj;
|
final WeightedLiquidStack other = (WeightedLiquidStack) obj;
|
||||||
return !(this.stack != other.stack && (this.stack == null || !this.stack.equals(other.stack))) && Float.floatToIntBits(this.p) == Float.floatToIntBits(other.p);
|
return !(this.stack != other.stack && (this.stack == null || !this.stack.equals(other.stack)))
|
||||||
|
&& Float.floatToIntBits(this.p) == Float.floatToIntBits(other.p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,17 +1,17 @@
|
|||||||
package minetweaker.api.logger;
|
package minetweaker.api.logger;
|
||||||
|
|
||||||
import minetweaker.runtime.ILogger;
|
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import minetweaker.runtime.ILogger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Stan Hebben
|
* @author Stan Hebben
|
||||||
*/
|
*/
|
||||||
public class FileLogger implements ILogger {
|
public class FileLogger implements ILogger {
|
||||||
|
|
||||||
private static final Pattern FORMATTING_CODE_PATTERN = Pattern.compile("(?i)" + String.valueOf('\u00a7') + "[0-9A-FK-OR]");
|
private static final Pattern FORMATTING_CODE_PATTERN = Pattern
|
||||||
|
.compile("(?i)" + String.valueOf('\u00a7') + "[0-9A-FK-OR]");
|
||||||
private final Writer writer;
|
private final Writer writer;
|
||||||
private final PrintWriter printWriter;
|
private final PrintWriter printWriter;
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
package minetweaker.api.logger;
|
package minetweaker.api.logger;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
import minetweaker.api.player.IPlayer;
|
import minetweaker.api.player.IPlayer;
|
||||||
import minetweaker.runtime.ILogger;
|
import minetweaker.runtime.ILogger;
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Stan
|
* @author Stan
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -3,6 +3,19 @@ package minetweaker.api.minecraft;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.nbt.NBTBase;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.world.IBlockAccess;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraft.world.biome.BiomeGenBase;
|
||||||
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
|
import net.minecraftforge.oredict.OreDictionary;
|
||||||
|
|
||||||
import minetweaker.MineTweakerAPI;
|
import minetweaker.MineTweakerAPI;
|
||||||
import minetweaker.api.block.IBlock;
|
import minetweaker.api.block.IBlock;
|
||||||
import minetweaker.api.block.IBlockDefinition;
|
import minetweaker.api.block.IBlockDefinition;
|
||||||
@@ -17,25 +30,14 @@ import minetweaker.api.world.IBiome;
|
|||||||
import minetweaker.api.world.IDimension;
|
import minetweaker.api.world.IDimension;
|
||||||
import minetweaker.mc1710.block.MCBlockDefinition;
|
import minetweaker.mc1710.block.MCBlockDefinition;
|
||||||
import minetweaker.mc1710.block.MCSpecificBlock;
|
import minetweaker.mc1710.block.MCSpecificBlock;
|
||||||
|
import minetweaker.mc1710.block.MCWorldBlock;
|
||||||
import minetweaker.mc1710.data.NBTConverter;
|
import minetweaker.mc1710.data.NBTConverter;
|
||||||
import minetweaker.mc1710.item.MCItemStack;
|
import minetweaker.mc1710.item.MCItemStack;
|
||||||
|
import minetweaker.mc1710.liquid.MCLiquidStack;
|
||||||
import minetweaker.mc1710.oredict.MCOreDictEntry;
|
import minetweaker.mc1710.oredict.MCOreDictEntry;
|
||||||
import minetweaker.mc1710.player.MCPlayer;
|
import minetweaker.mc1710.player.MCPlayer;
|
||||||
import minetweaker.mc1710.world.MCDimension;
|
|
||||||
import minetweaker.mc1710.block.MCWorldBlock;
|
|
||||||
import minetweaker.mc1710.liquid.MCLiquidStack;
|
|
||||||
import minetweaker.mc1710.world.MCBiome;
|
import minetweaker.mc1710.world.MCBiome;
|
||||||
import net.minecraft.block.Block;
|
import minetweaker.mc1710.world.MCDimension;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.item.Item;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.nbt.NBTBase;
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
|
||||||
import net.minecraft.world.IBlockAccess;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import net.minecraft.world.biome.BiomeGenBase;
|
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
|
||||||
import net.minecraftforge.oredict.OreDictionary;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MineTweaker - MineCraft API bridge.
|
* MineTweaker - MineCraft API bridge.
|
||||||
@@ -43,19 +45,18 @@ import net.minecraftforge.oredict.OreDictionary;
|
|||||||
* @author Stan Hebben
|
* @author Stan Hebben
|
||||||
*/
|
*/
|
||||||
public class MineTweakerMC {
|
public class MineTweakerMC {
|
||||||
|
|
||||||
private static final Map<Block, MCBlockDefinition> blockDefinitions = new HashMap<Block, MCBlockDefinition>();
|
private static final Map<Block, MCBlockDefinition> blockDefinitions = new HashMap<Block, MCBlockDefinition>();
|
||||||
public static final IBiome[] biomes;
|
public static final IBiome[] biomes;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
biomes = new IBiome[BiomeGenBase.getBiomeGenArray().length];
|
biomes = new IBiome[BiomeGenBase.getBiomeGenArray().length];
|
||||||
for (int i = 0; i < BiomeGenBase.getBiomeGenArray().length; i++) {
|
for (int i = 0; i < BiomeGenBase.getBiomeGenArray().length; i++) {
|
||||||
if (BiomeGenBase.getBiomeGenArray()[i] != null)
|
if (BiomeGenBase.getBiomeGenArray()[i] != null) biomes[i] = new MCBiome(BiomeGenBase.getBiomeGenArray()[i]);
|
||||||
biomes[i] = new MCBiome(BiomeGenBase.getBiomeGenArray()[i]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private MineTweakerMC() {
|
private MineTweakerMC() {}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the Minecraft item for this MineTweaker item.
|
* Returns the Minecraft item for this MineTweaker item.
|
||||||
@@ -64,8 +65,7 @@ public class MineTweakerMC {
|
|||||||
* @return minecraft item stack
|
* @return minecraft item stack
|
||||||
*/
|
*/
|
||||||
public static ItemStack getItemStack(IItemStack item) {
|
public static ItemStack getItemStack(IItemStack item) {
|
||||||
if (item == null)
|
if (item == null) return null;
|
||||||
return null;
|
|
||||||
|
|
||||||
Object internal = item.getInternal();
|
Object internal = item.getInternal();
|
||||||
if (internal == null || !(internal instanceof ItemStack)) {
|
if (internal == null || !(internal instanceof ItemStack)) {
|
||||||
@@ -75,15 +75,14 @@ public class MineTweakerMC {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the Minecraft ingredient for this ingredient. This method is only
|
* Returns the Minecraft ingredient for this ingredient. This method is only useful for ingredients that represent a
|
||||||
* useful for ingredients that represent a single item stack.
|
* single item stack.
|
||||||
*
|
*
|
||||||
* @param ingredient item ingredient
|
* @param ingredient item ingredient
|
||||||
* @return minecraft item stack
|
* @return minecraft item stack
|
||||||
*/
|
*/
|
||||||
public static ItemStack getItemStack(IIngredient ingredient) {
|
public static ItemStack getItemStack(IIngredient ingredient) {
|
||||||
if (ingredient == null)
|
if (ingredient == null) return null;
|
||||||
return null;
|
|
||||||
|
|
||||||
List<IItemStack> items = ingredient.getItems();
|
List<IItemStack> items = ingredient.getItems();
|
||||||
if (items.size() != 1) {
|
if (items.size() != 1) {
|
||||||
@@ -99,8 +98,7 @@ public class MineTweakerMC {
|
|||||||
* @return minetweaker item stack
|
* @return minetweaker item stack
|
||||||
*/
|
*/
|
||||||
public static IItemStack getIItemStack(ItemStack item) {
|
public static IItemStack getIItemStack(ItemStack item) {
|
||||||
if (item == null)
|
if (item == null) return null;
|
||||||
return null;
|
|
||||||
|
|
||||||
return new MCItemStack(item);
|
return new MCItemStack(item);
|
||||||
}
|
}
|
||||||
@@ -112,8 +110,7 @@ public class MineTweakerMC {
|
|||||||
* @return minetweaker stack
|
* @return minetweaker stack
|
||||||
*/
|
*/
|
||||||
public static IItemStack getIItemStackWildcardSize(ItemStack item) {
|
public static IItemStack getIItemStackWildcardSize(ItemStack item) {
|
||||||
if (item == null)
|
if (item == null) return null;
|
||||||
return null;
|
|
||||||
|
|
||||||
return new MCItemStack(item, true);
|
return new MCItemStack(item, true);
|
||||||
}
|
}
|
||||||
@@ -126,8 +123,7 @@ public class MineTweakerMC {
|
|||||||
* @return minetweaker stack
|
* @return minetweaker stack
|
||||||
*/
|
*/
|
||||||
public static IItemStack getIItemStackWildcardSize(Item item, int meta) {
|
public static IItemStack getIItemStackWildcardSize(Item item, int meta) {
|
||||||
if (item == null)
|
if (item == null) return null;
|
||||||
return null;
|
|
||||||
|
|
||||||
return new MCItemStack(new ItemStack(item, 1, meta), true);
|
return new MCItemStack(new ItemStack(item, 1, meta), true);
|
||||||
}
|
}
|
||||||
@@ -140,8 +136,7 @@ public class MineTweakerMC {
|
|||||||
* @return minetweaker item stack
|
* @return minetweaker item stack
|
||||||
*/
|
*/
|
||||||
public static IItemStack getIItemStackWildcard(Item item, int amount) {
|
public static IItemStack getIItemStackWildcard(Item item, int amount) {
|
||||||
if (item == null)
|
if (item == null) return null;
|
||||||
return null;
|
|
||||||
|
|
||||||
return new MCItemStack(new ItemStack(item, 1, OreDictionary.WILDCARD_VALUE));
|
return new MCItemStack(new ItemStack(item, 1, OreDictionary.WILDCARD_VALUE));
|
||||||
}
|
}
|
||||||
@@ -164,22 +159,19 @@ public class MineTweakerMC {
|
|||||||
* @return minetweaker item stack
|
* @return minetweaker item stack
|
||||||
*/
|
*/
|
||||||
public static IItemStack getItemStack(Item item, int amount, int damage) {
|
public static IItemStack getItemStack(Item item, int amount, int damage) {
|
||||||
if (item == null)
|
if (item == null) return null;
|
||||||
return null;
|
|
||||||
|
|
||||||
return new MCItemStack(new ItemStack(item, amount, damage));
|
return new MCItemStack(new ItemStack(item, amount, damage));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts an array of minetweaker item stacks into an array of minecraft
|
* Converts an array of minetweaker item stacks into an array of minecraft item stacks.
|
||||||
* item stacks.
|
|
||||||
*
|
*
|
||||||
* @param items minetweker item stacks
|
* @param items minetweker item stacks
|
||||||
* @return minecraft item stacks
|
* @return minecraft item stacks
|
||||||
*/
|
*/
|
||||||
public static ItemStack[] getItemStacks(IItemStack... items) {
|
public static ItemStack[] getItemStacks(IItemStack... items) {
|
||||||
if (items == null)
|
if (items == null) return null;
|
||||||
return null;
|
|
||||||
|
|
||||||
ItemStack[] output = new ItemStack[items.length];
|
ItemStack[] output = new ItemStack[items.length];
|
||||||
for (int i = 0; i < items.length; i++) {
|
for (int i = 0; i < items.length; i++) {
|
||||||
@@ -192,15 +184,13 @@ public class MineTweakerMC {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a list of minetweaker item stacks into an array of minecraft
|
* Converts a list of minetweaker item stacks into an array of minecraft item stacks.
|
||||||
* item stacks.
|
|
||||||
*
|
*
|
||||||
* @param items minetweaker items
|
* @param items minetweaker items
|
||||||
* @return minecraft items
|
* @return minecraft items
|
||||||
*/
|
*/
|
||||||
public static ItemStack[] getItemStacks(List<IItemStack> items) {
|
public static ItemStack[] getItemStacks(List<IItemStack> items) {
|
||||||
if (items == null)
|
if (items == null) return null;
|
||||||
return null;
|
|
||||||
|
|
||||||
ItemStack[] output = new ItemStack[items.size()];
|
ItemStack[] output = new ItemStack[items.size()];
|
||||||
for (int i = 0; i < items.size(); i++) {
|
for (int i = 0; i < items.size(); i++) {
|
||||||
@@ -215,15 +205,13 @@ public class MineTweakerMC {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts an array of minecraft item stacks into an array of minetweaker
|
* Converts an array of minecraft item stacks into an array of minetweaker item stacks.
|
||||||
* item stacks.
|
|
||||||
*
|
*
|
||||||
* @param items minecraft item stacks
|
* @param items minecraft item stacks
|
||||||
* @return minetweaker item stacks
|
* @return minetweaker item stacks
|
||||||
*/
|
*/
|
||||||
public static IItemStack[] getIItemStacks(ItemStack... items) {
|
public static IItemStack[] getIItemStacks(ItemStack... items) {
|
||||||
if (items == null)
|
if (items == null) return null;
|
||||||
return null;
|
|
||||||
|
|
||||||
IItemStack[] result = new IItemStack[items.length];
|
IItemStack[] result = new IItemStack[items.length];
|
||||||
for (int i = 0; i < items.length; i++) {
|
for (int i = 0; i < items.length; i++) {
|
||||||
@@ -233,15 +221,13 @@ public class MineTweakerMC {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a list of minecraft item stacks into an array of minetweaker
|
* Converts a list of minecraft item stacks into an array of minetweaker item stacks.
|
||||||
* item stacks.
|
|
||||||
*
|
*
|
||||||
* @param items minecraft item stacks
|
* @param items minecraft item stacks
|
||||||
* @return minetweaker item stacks
|
* @return minetweaker item stacks
|
||||||
*/
|
*/
|
||||||
public static IItemStack[] getIItemStacks(List<ItemStack> items) {
|
public static IItemStack[] getIItemStacks(List<ItemStack> items) {
|
||||||
if (items == null)
|
if (items == null) return null;
|
||||||
return null;
|
|
||||||
|
|
||||||
IItemStack[] result = new IItemStack[items.size()];
|
IItemStack[] result = new IItemStack[items.size()];
|
||||||
for (int i = 0; i < result.length; i++) {
|
for (int i = 0; i < result.length; i++) {
|
||||||
@@ -251,8 +237,8 @@ public class MineTweakerMC {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the ore dictionary entry with the given name. If the entry didn't
|
* Gets the ore dictionary entry with the given name. If the entry didn't exist yet, it will create it and return an
|
||||||
* exist yet, it will create it and return an empty entry.
|
* empty entry.
|
||||||
*
|
*
|
||||||
* @param name ore entry name
|
* @param name ore entry name
|
||||||
* @return ore dictionary entry
|
* @return ore dictionary entry
|
||||||
@@ -268,8 +254,7 @@ public class MineTweakerMC {
|
|||||||
* @return minetweaker player
|
* @return minetweaker player
|
||||||
*/
|
*/
|
||||||
public static IPlayer getIPlayer(EntityPlayer player) {
|
public static IPlayer getIPlayer(EntityPlayer player) {
|
||||||
if (player == null)
|
if (player == null) return null;
|
||||||
return null;
|
|
||||||
|
|
||||||
return new MCPlayer(player);
|
return new MCPlayer(player);
|
||||||
}
|
}
|
||||||
@@ -281,8 +266,7 @@ public class MineTweakerMC {
|
|||||||
* @return minecraft player
|
* @return minecraft player
|
||||||
*/
|
*/
|
||||||
public static EntityPlayer getPlayer(IPlayer player) {
|
public static EntityPlayer getPlayer(IPlayer player) {
|
||||||
if (player == null)
|
if (player == null) return null;
|
||||||
return null;
|
|
||||||
|
|
||||||
if (!(player instanceof MCPlayer)) {
|
if (!(player instanceof MCPlayer)) {
|
||||||
MineTweakerAPI.logError("Invalid player: " + player);
|
MineTweakerAPI.logError("Invalid player: " + player);
|
||||||
@@ -292,15 +276,13 @@ public class MineTweakerMC {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a Minecraft NBT to an IData instance. The IData instance is
|
* Converts a Minecraft NBT to an IData instance. The IData instance is immutable (not modifyiable).
|
||||||
* immutable (not modifyiable).
|
|
||||||
*
|
*
|
||||||
* @param nbt nbt data
|
* @param nbt nbt data
|
||||||
* @return IData value
|
* @return IData value
|
||||||
*/
|
*/
|
||||||
public static IData getIData(NBTBase nbt) {
|
public static IData getIData(NBTBase nbt) {
|
||||||
if (nbt == null)
|
if (nbt == null) return null;
|
||||||
return null;
|
|
||||||
|
|
||||||
return NBTConverter.from(nbt, true);
|
return NBTConverter.from(nbt, true);
|
||||||
}
|
}
|
||||||
@@ -312,8 +294,7 @@ public class MineTweakerMC {
|
|||||||
* @return mutable IData value
|
* @return mutable IData value
|
||||||
*/
|
*/
|
||||||
public static IData getIDataModifyable(NBTBase nbt) {
|
public static IData getIDataModifyable(NBTBase nbt) {
|
||||||
if (nbt == null)
|
if (nbt == null) return null;
|
||||||
return null;
|
|
||||||
|
|
||||||
return NBTConverter.from(nbt, false);
|
return NBTConverter.from(nbt, false);
|
||||||
}
|
}
|
||||||
@@ -325,8 +306,7 @@ public class MineTweakerMC {
|
|||||||
* @return nbt data
|
* @return nbt data
|
||||||
*/
|
*/
|
||||||
public static NBTBase getNBT(IData data) {
|
public static NBTBase getNBT(IData data) {
|
||||||
if (data == null)
|
if (data == null) return null;
|
||||||
return null;
|
|
||||||
|
|
||||||
return NBTConverter.from(data);
|
return NBTConverter.from(data);
|
||||||
}
|
}
|
||||||
@@ -338,8 +318,7 @@ public class MineTweakerMC {
|
|||||||
* @return nbt compound data
|
* @return nbt compound data
|
||||||
*/
|
*/
|
||||||
public static NBTTagCompound getNBTCompound(IData data) {
|
public static NBTTagCompound getNBTCompound(IData data) {
|
||||||
if (data == null)
|
if (data == null) return null;
|
||||||
return null;
|
|
||||||
|
|
||||||
return (NBTTagCompound) NBTConverter.from(data);
|
return (NBTTagCompound) NBTConverter.from(data);
|
||||||
}
|
}
|
||||||
@@ -377,8 +356,7 @@ public class MineTweakerMC {
|
|||||||
* @return dimension
|
* @return dimension
|
||||||
*/
|
*/
|
||||||
public static IDimension getDimension(World world) {
|
public static IDimension getDimension(World world) {
|
||||||
if (world == null)
|
if (world == null) return null;
|
||||||
return null;
|
|
||||||
|
|
||||||
return new MCDimension(world);
|
return new MCDimension(world);
|
||||||
}
|
}
|
||||||
@@ -425,8 +403,7 @@ public class MineTweakerMC {
|
|||||||
* @return MCF fluid stack
|
* @return MCF fluid stack
|
||||||
*/
|
*/
|
||||||
public static FluidStack getLiquidStack(ILiquidStack stack) {
|
public static FluidStack getLiquidStack(ILiquidStack stack) {
|
||||||
if (stack == null)
|
if (stack == null) return null;
|
||||||
return null;
|
|
||||||
|
|
||||||
return (FluidStack) stack.getInternal();
|
return (FluidStack) stack.getInternal();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package minetweaker.api.oredict;
|
package minetweaker.api.oredict;
|
||||||
|
|
||||||
import stanhebben.zenscript.annotations.*;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import stanhebben.zenscript.annotations.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Stan
|
* @author Stan
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ public interface IOreDictEntry extends IIngredient {
|
|||||||
@ZenMethod
|
@ZenMethod
|
||||||
void removeItems(IItemStack[] items);
|
void removeItems(IItemStack[] items);
|
||||||
|
|
||||||
|
|
||||||
@ZenOperator(OperatorType.CONTAINS)
|
@ZenOperator(OperatorType.CONTAINS)
|
||||||
boolean contains(IItemStack item);
|
boolean contains(IItemStack item);
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
package minetweaker.api.oredict;
|
package minetweaker.api.oredict;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
import minetweaker.api.item.*;
|
import minetweaker.api.item.*;
|
||||||
import minetweaker.api.liquid.ILiquidStack;
|
import minetweaker.api.liquid.ILiquidStack;
|
||||||
import minetweaker.api.player.IPlayer;
|
import minetweaker.api.player.IPlayer;
|
||||||
import minetweaker.util.ArrayUtil;
|
import minetweaker.util.ArrayUtil;
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Stan Hebben
|
* @author Stan Hebben
|
||||||
*/
|
*/
|
||||||
@@ -17,7 +17,8 @@ public class IngredientOreDict implements IIngredient {
|
|||||||
private final IItemCondition[] conditions;
|
private final IItemCondition[] conditions;
|
||||||
private final IItemTransformer[] transformers;
|
private final IItemTransformer[] transformers;
|
||||||
|
|
||||||
public IngredientOreDict(IOreDictEntry entry, String mark, IItemCondition[] conditions, IItemTransformer[] transformers) {
|
public IngredientOreDict(IOreDictEntry entry, String mark, IItemCondition[] conditions,
|
||||||
|
IItemTransformer[] transformers) {
|
||||||
this.entry = entry;
|
this.entry = entry;
|
||||||
this.mark = mark;
|
this.mark = mark;
|
||||||
this.conditions = conditions;
|
this.conditions = conditions;
|
||||||
@@ -71,12 +72,10 @@ public class IngredientOreDict implements IIngredient {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(IItemStack item) {
|
public boolean matches(IItemStack item) {
|
||||||
if(!entry.matches(item))
|
if (!entry.matches(item)) return false;
|
||||||
return false;
|
|
||||||
|
|
||||||
for (IItemCondition condition : conditions) {
|
for (IItemCondition condition : conditions) {
|
||||||
if(!condition.matches(item))
|
if (!condition.matches(item)) return false;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -84,12 +83,10 @@ public class IngredientOreDict implements IIngredient {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matchesExact(IItemStack item) {
|
public boolean matchesExact(IItemStack item) {
|
||||||
if(!entry.matchesExact(item))
|
if (!entry.matchesExact(item)) return false;
|
||||||
return false;
|
|
||||||
|
|
||||||
for (IItemCondition condition : conditions) {
|
for (IItemCondition condition : conditions) {
|
||||||
if(!condition.matches(item))
|
if (!condition.matches(item)) return false;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -35,6 +35,8 @@ public interface IPlayer {
|
|||||||
@ZenMethod
|
@ZenMethod
|
||||||
void sendChat(IChatMessage message);
|
void sendChat(IChatMessage message);
|
||||||
|
|
||||||
|
int MAX_CHAT_MESSAGE_LENGTH = 512;
|
||||||
|
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
void sendChat(String message);
|
void sendChat(String message);
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
package minetweaker.api.recipes;
|
package minetweaker.api.recipes;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import minetweaker.api.item.IItemStack;
|
import minetweaker.api.item.IItemStack;
|
||||||
import stanhebben.zenscript.annotations.*;
|
import stanhebben.zenscript.annotations.*;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The BrewingManager adds and removes brewing recipes. The IBrewingManager
|
* The BrewingManager adds and removes brewing recipes. The IBrewingManager instance is available through the recipes
|
||||||
* instance is available through the recipes global variable.
|
* global variable.
|
||||||
*
|
*
|
||||||
* @author Jared
|
* @author Jared
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ import minetweaker.api.player.IPlayer;
|
|||||||
import stanhebben.zenscript.annotations.*;
|
import stanhebben.zenscript.annotations.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Crafting inventory interface. The crafting inventory is the 2x2 grid in the
|
* Crafting inventory interface. The crafting inventory is the 2x2 grid in the player inventory or the 3x3 grid in the
|
||||||
* player inventory or the 3x3 grid in the crafting bench.
|
* crafting bench.
|
||||||
*
|
*
|
||||||
* @author Stan Hebben
|
* @author Stan Hebben
|
||||||
*/
|
*/
|
||||||
@@ -64,8 +64,7 @@ public interface ICraftingInventory {
|
|||||||
IItemStack getStack(int i);
|
IItemStack getStack(int i);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the stack at the given position. The top left stack is position (0,
|
* Gets the stack at the given position. The top left stack is position (0, 0).
|
||||||
* 0).
|
|
||||||
*
|
*
|
||||||
* @param x stack x position
|
* @param x stack x position
|
||||||
* @param y stack y position
|
* @param y stack y position
|
||||||
@@ -76,13 +75,11 @@ public interface ICraftingInventory {
|
|||||||
IItemStack getStack(int x, int y);
|
IItemStack getStack(int x, int y);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the stack at the given position. The top left stack is position (0,
|
* Sets the stack at the given position. The top left stack is position (0, 0).
|
||||||
* 0).
|
|
||||||
*
|
*
|
||||||
* @param x stack x position
|
* @param x stack x position
|
||||||
* @param y stack y position
|
* @param y stack y position
|
||||||
* @param stack item stack to be set, or null to clear the stack at that
|
* @param stack item stack to be set, or null to clear the stack at that position
|
||||||
* position
|
|
||||||
*/
|
*/
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
void setStack(int x, int y, IItemStack stack);
|
void setStack(int x, int y, IItemStack stack);
|
||||||
@@ -91,8 +88,7 @@ public interface ICraftingInventory {
|
|||||||
* Sets the stack at the given index.
|
* Sets the stack at the given index.
|
||||||
*
|
*
|
||||||
* @param i stack index
|
* @param i stack index
|
||||||
* @param stack item stack to be set, or null to clear the stack at that
|
* @param stack item stack to be set, or null to clear the stack at that index
|
||||||
* index
|
|
||||||
*/
|
*/
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
void setStack(int i, IItemStack stack);
|
void setStack(int i, IItemStack stack);
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
package minetweaker.api.recipes;
|
package minetweaker.api.recipes;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import minetweaker.api.item.*;
|
import minetweaker.api.item.*;
|
||||||
import stanhebben.zenscript.annotations.*;
|
import stanhebben.zenscript.annotations.*;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Stan
|
* @author Stan
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -5,6 +5,5 @@ package minetweaker.api.recipes;
|
|||||||
*/
|
*/
|
||||||
public interface IFurnaceRecipe {
|
public interface IFurnaceRecipe {
|
||||||
|
|
||||||
|
|
||||||
String toCommandString();
|
String toCommandString();
|
||||||
}
|
}
|
||||||
@@ -2,6 +2,5 @@ package minetweaker.api.recipes;
|
|||||||
|
|
||||||
public interface IMTRecipe {
|
public interface IMTRecipe {
|
||||||
|
|
||||||
|
|
||||||
ICraftingRecipe getRecipe();
|
ICraftingRecipe getRecipe();
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
package minetweaker.api.recipes;
|
package minetweaker.api.recipes;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import minetweaker.api.item.IItemStack;
|
import minetweaker.api.item.IItemStack;
|
||||||
import stanhebben.zenscript.annotations.ZenClass;
|
import stanhebben.zenscript.annotations.ZenClass;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Stan
|
* @author Stan
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
package minetweaker.api.recipes;
|
package minetweaker.api.recipes;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import minetweaker.api.item.*;
|
import minetweaker.api.item.*;
|
||||||
import stanhebben.zenscript.annotations.*;
|
import stanhebben.zenscript.annotations.*;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The RecipeManager adds and removes crafting recipes. The IRecipeManager
|
* The RecipeManager adds and removes crafting recipes. The IRecipeManager instance is available through the recipes
|
||||||
* instance is available through the recipes global variable.
|
* global variable.
|
||||||
*
|
*
|
||||||
* @author Stan Hebben
|
* @author Stan Hebben
|
||||||
*/
|
*/
|
||||||
@@ -52,13 +52,15 @@ public interface IRecipeManager {
|
|||||||
* @param function recipe function (optional)
|
* @param function recipe function (optional)
|
||||||
*/
|
*/
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
void addShaped(IItemStack output, IIngredient[][] ingredients, @Optional IRecipeFunction function, @Optional IRecipeAction action);
|
void addShaped(IItemStack output, IIngredient[][] ingredients, @Optional IRecipeFunction function,
|
||||||
|
@Optional IRecipeAction action);
|
||||||
|
|
||||||
void addShaped(IItemStack output, IIngredient[][] ingredients, IRecipeFunction function);
|
void addShaped(IItemStack output, IIngredient[][] ingredients, IRecipeFunction function);
|
||||||
|
|
||||||
void addShaped(IItemStack output, IIngredient[][] ingredients, IRecipeAction action);
|
void addShaped(IItemStack output, IIngredient[][] ingredients, IRecipeAction action);
|
||||||
|
|
||||||
void addShaped(IItemStack output, IIngredient[][] ingredients);
|
void addShaped(IItemStack output, IIngredient[][] ingredients);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a mirrored shaped recipe.
|
* Adds a mirrored shaped recipe.
|
||||||
*
|
*
|
||||||
@@ -67,13 +69,15 @@ public interface IRecipeManager {
|
|||||||
* @param function recipe function (optional)
|
* @param function recipe function (optional)
|
||||||
*/
|
*/
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
void addShapedMirrored(IItemStack output, IIngredient[][] ingredients, @Optional IRecipeFunction function, @Optional IRecipeAction action);
|
void addShapedMirrored(IItemStack output, IIngredient[][] ingredients, @Optional IRecipeFunction function,
|
||||||
|
@Optional IRecipeAction action);
|
||||||
|
|
||||||
void addShapedMirrored(IItemStack output, IIngredient[][] ingredients, IRecipeFunction function);
|
void addShapedMirrored(IItemStack output, IIngredient[][] ingredients, IRecipeFunction function);
|
||||||
|
|
||||||
void addShapedMirrored(IItemStack output, IIngredient[][] ingredients, IRecipeAction action);
|
void addShapedMirrored(IItemStack output, IIngredient[][] ingredients, IRecipeAction action);
|
||||||
|
|
||||||
void addShapedMirrored(IItemStack output, IIngredient[][] ingredients);
|
void addShapedMirrored(IItemStack output, IIngredient[][] ingredients);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a shapeless recipe.
|
* Adds a shapeless recipe.
|
||||||
*
|
*
|
||||||
@@ -82,7 +86,8 @@ public interface IRecipeManager {
|
|||||||
* @param function recipe function (optional)
|
* @param function recipe function (optional)
|
||||||
*/
|
*/
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
void addShapeless(IItemStack output, IIngredient[] ingredients, @Optional IRecipeFunction function, @Optional IRecipeAction action);
|
void addShapeless(IItemStack output, IIngredient[] ingredients, @Optional IRecipeFunction function,
|
||||||
|
@Optional IRecipeAction action);
|
||||||
|
|
||||||
void addShapeless(IItemStack output, IIngredient[] ingredients, IRecipeFunction function);
|
void addShapeless(IItemStack output, IIngredient[] ingredients, IRecipeFunction function);
|
||||||
|
|
||||||
@@ -102,13 +107,13 @@ public interface IRecipeManager {
|
|||||||
int removeShaped(IIngredient output, @Optional IIngredient[][] ingredients);
|
int removeShaped(IIngredient output, @Optional IIngredient[][] ingredients);
|
||||||
|
|
||||||
int removeShaped(IIngredient output);
|
int removeShaped(IIngredient output);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes shapeless recipes.
|
* Removes shapeless recipes.
|
||||||
*
|
*
|
||||||
* @param output recipe output
|
* @param output recipe output
|
||||||
* @param ingredients recipe ingredients
|
* @param ingredients recipe ingredients
|
||||||
* @param wildcard if the recipe may contain other ingredients too, besides
|
* @param wildcard if the recipe may contain other ingredients too, besides the ones specified
|
||||||
* the ones specified
|
|
||||||
*
|
*
|
||||||
* @return number of removed recipes
|
* @return number of removed recipes
|
||||||
*/
|
*/
|
||||||
@@ -122,8 +127,7 @@ public interface IRecipeManager {
|
|||||||
int removeShapeless(IIngredient output);
|
int removeShapeless(IIngredient output);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Performs a crafting with the specified ingredients. Returns null if no
|
* Performs a crafting with the specified ingredients. Returns null if no crafting recipe exists.
|
||||||
* crafting recipe exists.
|
|
||||||
*
|
*
|
||||||
* @param contents crafting inventory contents
|
* @param contents crafting inventory contents
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
package minetweaker.api.recipes;
|
package minetweaker.api.recipes;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
import minetweaker.api.item.*;
|
import minetweaker.api.item.*;
|
||||||
import minetweaker.api.player.IPlayer;
|
import minetweaker.api.player.IPlayer;
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Stan
|
* @author Stan
|
||||||
*/
|
*/
|
||||||
@@ -18,7 +18,6 @@ public class ShapedRecipe implements ICraftingRecipe {
|
|||||||
private final IRecipeFunction function;
|
private final IRecipeFunction function;
|
||||||
private final IRecipeAction action;
|
private final IRecipeAction action;
|
||||||
|
|
||||||
|
|
||||||
private final IItemStack output;
|
private final IItemStack output;
|
||||||
private final IIngredient[] ingredients;
|
private final IIngredient[] ingredients;
|
||||||
|
|
||||||
@@ -26,7 +25,8 @@ public class ShapedRecipe implements ICraftingRecipe {
|
|||||||
this(output, ingredients, function, null, mirrored);
|
this(output, ingredients, function, null, mirrored);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ShapedRecipe(IItemStack output, IIngredient[][] ingredients, IRecipeFunction function, IRecipeAction action, boolean mirrored) {
|
public ShapedRecipe(IItemStack output, IIngredient[][] ingredients, IRecipeFunction function, IRecipeAction action,
|
||||||
|
boolean mirrored) {
|
||||||
int numIngredients = 0;
|
int numIngredients = 0;
|
||||||
for (IIngredient[] ingredient : ingredients) {
|
for (IIngredient[] ingredient : ingredients) {
|
||||||
for (IIngredient iIngredient : ingredient) {
|
for (IIngredient iIngredient : ingredient) {
|
||||||
@@ -100,15 +100,12 @@ public class ShapedRecipe implements ICraftingRecipe {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for (int i = 0; i <= inventory.getWidth() - width; i++) {
|
for (int i = 0; i <= inventory.getWidth() - width; i++) {
|
||||||
out:
|
out: for (int j = 0; j <= inventory.getHeight() - height; j++) {
|
||||||
for(int j = 0; j <= inventory.getHeight() - height; j++) {
|
|
||||||
for (int k = 0; k < ingredients.length; k++) {
|
for (int k = 0; k < ingredients.length; k++) {
|
||||||
IItemStack item = inventory.getStack(posx[k] + i, posy[k] + j);
|
IItemStack item = inventory.getStack(posx[k] + i, posy[k] + j);
|
||||||
if(item == null)
|
if (item == null) continue out;
|
||||||
continue out;
|
|
||||||
|
|
||||||
if(!ingredients[k].matches(item))
|
if (!ingredients[k].matches(item)) continue out;
|
||||||
continue out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -117,15 +114,12 @@ public class ShapedRecipe implements ICraftingRecipe {
|
|||||||
|
|
||||||
if (mirrored) {
|
if (mirrored) {
|
||||||
for (int i = 0; i <= inventory.getWidth() - width; i++) {
|
for (int i = 0; i <= inventory.getWidth() - width; i++) {
|
||||||
out:
|
out: for (int j = 0; j <= inventory.getHeight() - height; j++) {
|
||||||
for(int j = 0; j <= inventory.getHeight() - height; j++) {
|
|
||||||
for (int k = 0; k < ingredients.length; k++) {
|
for (int k = 0; k < ingredients.length; k++) {
|
||||||
IItemStack item = inventory.getStack(inventory.getWidth() - (posx[k] + i) - 1, posy[k] + j);
|
IItemStack item = inventory.getStack(inventory.getWidth() - (posx[k] + i) - 1, posy[k] + j);
|
||||||
if(item == null)
|
if (item == null) continue out;
|
||||||
continue out;
|
|
||||||
|
|
||||||
if(!ingredients[k].matches(item))
|
if (!ingredients[k].matches(item)) continue out;
|
||||||
continue out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -141,15 +135,12 @@ public class ShapedRecipe implements ICraftingRecipe {
|
|||||||
IItemStack[] stacks = new IItemStack[ingredients.length];
|
IItemStack[] stacks = new IItemStack[ingredients.length];
|
||||||
|
|
||||||
for (int i = 0; i <= inventory.getWidth() - width; i++) {
|
for (int i = 0; i <= inventory.getWidth() - width; i++) {
|
||||||
out:
|
out: for (int j = 0; j <= inventory.getHeight() - height; j++) {
|
||||||
for(int j = 0; j <= inventory.getHeight() - height; j++) {
|
|
||||||
for (int k = 0; k < ingredients.length; k++) {
|
for (int k = 0; k < ingredients.length; k++) {
|
||||||
IItemStack item = inventory.getStack(posx[k] + i, posy[k] + j);
|
IItemStack item = inventory.getStack(posx[k] + i, posy[k] + j);
|
||||||
if(item == null)
|
if (item == null) continue out;
|
||||||
continue out;
|
|
||||||
|
|
||||||
if(!ingredients[k].matches(item))
|
if (!ingredients[k].matches(item)) continue out;
|
||||||
continue out;
|
|
||||||
stacks[k] = item;
|
stacks[k] = item;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,15 +150,12 @@ public class ShapedRecipe implements ICraftingRecipe {
|
|||||||
|
|
||||||
if (mirrored) {
|
if (mirrored) {
|
||||||
for (int i = 0; i <= inventory.getWidth() - width; i++) {
|
for (int i = 0; i <= inventory.getWidth() - width; i++) {
|
||||||
out:
|
out: for (int j = 0; j <= inventory.getHeight() - height; j++) {
|
||||||
for(int j = 0; j <= inventory.getHeight() - height; j++) {
|
|
||||||
for (int k = 0; k < ingredients.length; k++) {
|
for (int k = 0; k < ingredients.length; k++) {
|
||||||
IItemStack item = inventory.getStack(inventory.getWidth() - (posx[k] + i) - 1, posy[k] + j);
|
IItemStack item = inventory.getStack(inventory.getWidth() - (posx[k] + i) - 1, posy[k] + j);
|
||||||
if(item == null)
|
if (item == null) continue out;
|
||||||
continue out;
|
|
||||||
|
|
||||||
if(!ingredients[k].matches(item))
|
if (!ingredients[k].matches(item)) continue out;
|
||||||
continue out;
|
|
||||||
stacks[k] = item;
|
stacks[k] = item;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -195,15 +183,12 @@ public class ShapedRecipe implements ICraftingRecipe {
|
|||||||
IItemStack[] stacks = new IItemStack[ingredients.length];
|
IItemStack[] stacks = new IItemStack[ingredients.length];
|
||||||
|
|
||||||
for (int i = 0; i <= inventory.getWidth() - width; i++) {
|
for (int i = 0; i <= inventory.getWidth() - width; i++) {
|
||||||
out:
|
out: for (int j = 0; j <= inventory.getHeight() - height; j++) {
|
||||||
for(int j = 0; j <= inventory.getHeight() - height; j++) {
|
|
||||||
for (int k = 0; k < ingredients.length; k++) {
|
for (int k = 0; k < ingredients.length; k++) {
|
||||||
IItemStack item = inventory.getStack(posx[k] + i, posy[k] + j);
|
IItemStack item = inventory.getStack(posx[k] + i, posy[k] + j);
|
||||||
if(item == null)
|
if (item == null) continue out;
|
||||||
continue out;
|
|
||||||
|
|
||||||
if(!ingredients[k].matches(item))
|
if (!ingredients[k].matches(item)) continue out;
|
||||||
continue out;
|
|
||||||
stacks[k] = item;
|
stacks[k] = item;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -214,15 +199,12 @@ public class ShapedRecipe implements ICraftingRecipe {
|
|||||||
|
|
||||||
if (mirrored) {
|
if (mirrored) {
|
||||||
for (int i = 0; i <= inventory.getWidth() - width; i++) {
|
for (int i = 0; i <= inventory.getWidth() - width; i++) {
|
||||||
out:
|
out: for (int j = 0; j <= inventory.getHeight() - height; j++) {
|
||||||
for(int j = 0; j <= inventory.getHeight() - height; j++) {
|
|
||||||
for (int k = 0; k < ingredients.length; k++) {
|
for (int k = 0; k < ingredients.length; k++) {
|
||||||
IItemStack item = inventory.getStack(inventory.getWidth() - (posx[k] + i) - 1, posy[k] + j);
|
IItemStack item = inventory.getStack(inventory.getWidth() - (posx[k] + i) - 1, posy[k] + j);
|
||||||
if(item == null)
|
if (item == null) continue out;
|
||||||
continue out;
|
|
||||||
|
|
||||||
if(!ingredients[k].matches(item))
|
if (!ingredients[k].matches(item)) continue out;
|
||||||
continue out;
|
|
||||||
stacks[k] = item;
|
stacks[k] = item;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -257,8 +239,7 @@ public class ShapedRecipe implements ICraftingRecipe {
|
|||||||
result.append("[");
|
result.append("[");
|
||||||
|
|
||||||
for (int j = 0; j < ingredientsArray[i].length; j++) {
|
for (int j = 0; j < ingredientsArray[i].length; j++) {
|
||||||
if(j > 0)
|
if (j > 0) result.append(", ");
|
||||||
result.append(", ");
|
|
||||||
|
|
||||||
result.append(ingredientsArray[i][j]);
|
result.append(ingredientsArray[i][j]);
|
||||||
}
|
}
|
||||||
@@ -270,7 +251,8 @@ public class ShapedRecipe implements ICraftingRecipe {
|
|||||||
return result.toString();
|
return result.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private IItemStack doRecipe(ICraftingInventory inventory, IItemStack[] stacks, int offx, int offy, IItemStack output, boolean mirrored) {
|
private IItemStack doRecipe(ICraftingInventory inventory, IItemStack[] stacks, int offx, int offy,
|
||||||
|
IItemStack output, boolean mirrored) {
|
||||||
// determine output and apply transformations
|
// determine output and apply transformations
|
||||||
|
|
||||||
if (function != null) {
|
if (function != null) {
|
||||||
@@ -291,18 +273,17 @@ public class ShapedRecipe implements ICraftingRecipe {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* for (int i = 0; i < ingredients.length; i++) { IItemStack transformed
|
* for (int i = 0; i < ingredients.length; i++) { IItemStack transformed =
|
||||||
* = ingredients[i].applyTransform(stacks[i]); if (transformed !=
|
* ingredients[i].applyTransform(stacks[i]); if (transformed != stacks[i]) { if (mirrored) { inventory.setStack(
|
||||||
* stacks[i]) { if (mirrored) { inventory.setStack( inventory.getWidth()
|
* inventory.getWidth() - (offx + posx[i]) - 1, offy + posy[i], transformed); } else { inventory.setStack( offx
|
||||||
* - (offx + posx[i]) - 1, offy + posy[i], transformed); } else {
|
* + posx[i], offy + posy[i], transformed); } } }
|
||||||
* inventory.setStack( offx + posx[i], offy + posy[i], transformed); } }
|
|
||||||
* }
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doRecipeTransformers(ICraftingInventory inventory, IItemStack[] stacks, int offx, int offy, boolean mirrored, IPlayer byPlayer) {
|
private void doRecipeTransformers(ICraftingInventory inventory, IItemStack[] stacks, int offx, int offy,
|
||||||
|
boolean mirrored, IPlayer byPlayer) {
|
||||||
for (int i = 0; i < ingredients.length; i++) {
|
for (int i = 0; i < ingredients.length; i++) {
|
||||||
IItemStack transformed = ingredients[i].applyTransform(stacks[i], byPlayer);
|
IItemStack transformed = ingredients[i].applyTransform(stacks[i], byPlayer);
|
||||||
if (transformed != stacks[i]) {
|
if (transformed != stacks[i]) {
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
package minetweaker.api.recipes;
|
package minetweaker.api.recipes;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
import minetweaker.api.item.*;
|
import minetweaker.api.item.*;
|
||||||
import minetweaker.api.player.IPlayer;
|
import minetweaker.api.player.IPlayer;
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Stan
|
* @author Stan
|
||||||
*/
|
*/
|
||||||
@@ -15,7 +15,8 @@ public class ShapelessRecipe implements ICraftingRecipe {
|
|||||||
private final IRecipeAction action;
|
private final IRecipeAction action;
|
||||||
private final IIngredient[] ingredients;
|
private final IIngredient[] ingredients;
|
||||||
|
|
||||||
public ShapelessRecipe(IItemStack output, IIngredient[] ingredients, IRecipeFunction function, IRecipeAction action) {
|
public ShapelessRecipe(IItemStack output, IIngredient[] ingredients, IRecipeFunction function,
|
||||||
|
IRecipeAction action) {
|
||||||
this.output = output;
|
this.output = output;
|
||||||
this.function = function;
|
this.function = function;
|
||||||
this.ingredients = ingredients;
|
this.ingredients = ingredients;
|
||||||
@@ -45,15 +46,12 @@ public class ShapelessRecipe implements ICraftingRecipe {
|
|||||||
IItemStack[] matched = new IItemStack[recipe.length];
|
IItemStack[] matched = new IItemStack[recipe.length];
|
||||||
int[] indices = new int[recipe.length];
|
int[] indices = new int[recipe.length];
|
||||||
|
|
||||||
outer:
|
outer: for (int i = 0; i < ingredients.getSize(); i++) {
|
||||||
for(int i = 0; i < ingredients.getSize(); i++) {
|
|
||||||
IItemStack ingredient = ingredients.getStack(i);
|
IItemStack ingredient = ingredients.getStack(i);
|
||||||
if(ingredient == null)
|
if (ingredient == null) continue;
|
||||||
continue;
|
|
||||||
|
|
||||||
for (int j = 0; j < recipe.length; j++) {
|
for (int j = 0; j < recipe.length; j++) {
|
||||||
if(matched[j] != null)
|
if (matched[j] != null) continue;
|
||||||
continue;
|
|
||||||
if (recipe[j].matches(ingredient)) {
|
if (recipe[j].matches(ingredient)) {
|
||||||
matched[j] = ingredient;
|
matched[j] = ingredient;
|
||||||
indices[j] = i;
|
indices[j] = i;
|
||||||
@@ -133,8 +131,7 @@ public class ShapelessRecipe implements ICraftingRecipe {
|
|||||||
result.append(", [");
|
result.append(", [");
|
||||||
|
|
||||||
for (int i = 0; i < ingredients.length; i++) {
|
for (int i = 0; i < ingredients.length; i++) {
|
||||||
if(i > 0)
|
if (i > 0) result.append(", ");
|
||||||
result.append(", ");
|
|
||||||
|
|
||||||
result.append(ingredients[i]);
|
result.append(ingredients[i]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,8 +5,7 @@ import minetweaker.api.event.*;
|
|||||||
import minetweaker.util.IEventHandler;
|
import minetweaker.util.IEventHandler;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract server implementation. Implements call of which the implementation
|
* Abstract server implementation. Implements call of which the implementation is already fixed by the API.
|
||||||
* is already fixed by the API.
|
|
||||||
*
|
*
|
||||||
* @author Stan Hebben
|
* @author Stan Hebben
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -12,7 +12,8 @@ import stanhebben.zenscript.annotations.*;
|
|||||||
public interface IServer {
|
public interface IServer {
|
||||||
|
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
void addCommand(String name, String usage, String[] aliases, ICommandFunction function, @Optional ICommandValidator validator, @Optional ICommandTabCompletion completion);
|
void addCommand(String name, String usage, String[] aliases, ICommandFunction function,
|
||||||
|
@Optional ICommandValidator validator, @Optional ICommandTabCompletion completion);
|
||||||
|
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
void addMineTweakerCommand(String name, String[] usage, ICommandFunction function);
|
void addMineTweakerCommand(String name, String[] usage, ICommandFunction function);
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package minetweaker.api.tooltip;
|
package minetweaker.api.tooltip;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import minetweaker.*;
|
import minetweaker.*;
|
||||||
import minetweaker.api.formatting.IFormattedText;
|
import minetweaker.api.formatting.IFormattedText;
|
||||||
import minetweaker.api.item.*;
|
import minetweaker.api.item.*;
|
||||||
@@ -7,8 +9,6 @@ import minetweaker.api.util.IngredientMap;
|
|||||||
import minetweaker.api.util.IngredientMap.IngredientMapEntry;
|
import minetweaker.api.util.IngredientMap.IngredientMapEntry;
|
||||||
import stanhebben.zenscript.annotations.*;
|
import stanhebben.zenscript.annotations.*;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Stan
|
* @author Stan
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
package minetweaker.api.util;
|
package minetweaker.api.util;
|
||||||
|
|
||||||
import minetweaker.api.item.*;
|
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import minetweaker.api.item.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Stan
|
* @author Stan
|
||||||
*/
|
*/
|
||||||
@@ -17,7 +17,8 @@ public class IngredientMap<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public IngredientMapEntry<T> register(IIngredient ingredient, T entry) {
|
public IngredientMapEntry<T> register(IIngredient ingredient, T entry) {
|
||||||
Set<IItemDefinition> items = ingredient.getItems().stream().map(IItemStack::getDefinition).collect(Collectors.toSet());
|
Set<IItemDefinition> items = ingredient.getItems().stream().map(IItemStack::getDefinition)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
IngredientMapEntry<T> actualEntry = new IngredientMapEntry<>(ingredient, entry);
|
IngredientMapEntry<T> actualEntry = new IngredientMapEntry<>(ingredient, entry);
|
||||||
|
|
||||||
@@ -33,7 +34,8 @@ public class IngredientMap<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void unregister(IngredientMapEntry<T> entry) {
|
public void unregister(IngredientMapEntry<T> entry) {
|
||||||
Set<IItemDefinition> items = entry.ingredient.getItems().stream().map(IItemStack::getDefinition).collect(Collectors.toSet());
|
Set<IItemDefinition> items = entry.ingredient.getItems().stream().map(IItemStack::getDefinition)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
for (IItemDefinition item : items) {
|
for (IItemDefinition item : items) {
|
||||||
if (entries.containsKey(item)) {
|
if (entries.containsKey(item)) {
|
||||||
@@ -58,7 +60,8 @@ public class IngredientMap<T> {
|
|||||||
}
|
}
|
||||||
List<IngredientMapEntry<T>> entries = this.entries.get(item.getDefinition());
|
List<IngredientMapEntry<T>> entries = this.entries.get(item.getDefinition());
|
||||||
if (entries != null) {
|
if (entries != null) {
|
||||||
return entries.stream().filter(entry -> entry.ingredient.matches(item)).map(entry -> entry.entry).collect(Collectors.toCollection(ArrayList::new));
|
return entries.stream().filter(entry -> entry.ingredient.matches(item)).map(entry -> entry.entry)
|
||||||
|
.collect(Collectors.toCollection(ArrayList::new));
|
||||||
} else {
|
} else {
|
||||||
return Collections.EMPTY_LIST;
|
return Collections.EMPTY_LIST;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,5 @@ public interface ILootFunction {
|
|||||||
String getName();
|
String getName();
|
||||||
|
|
||||||
@ZenSetter
|
@ZenSetter
|
||||||
void setName();
|
void setName(String name);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
package minetweaker.api.vanilla;
|
package minetweaker.api.vanilla;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import minetweaker.api.item.*;
|
import minetweaker.api.item.*;
|
||||||
import stanhebben.zenscript.annotations.*;
|
import stanhebben.zenscript.annotations.*;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Stan
|
* @author Stan
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
package minetweaker.api.vanilla;
|
package minetweaker.api.vanilla;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import minetweaker.api.item.*;
|
import minetweaker.api.item.*;
|
||||||
import stanhebben.zenscript.annotations.*;
|
import stanhebben.zenscript.annotations.*;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Stan
|
* @author Stan
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
package minetweaker.api.vanilla;
|
package minetweaker.api.vanilla;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import minetweaker.api.item.*;
|
import minetweaker.api.item.*;
|
||||||
import stanhebben.zenscript.annotations.*;
|
import stanhebben.zenscript.annotations.*;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Jared on 5/9/2016.
|
* Created by Jared on 5/9/2016.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package minetweaker.expand;
|
package minetweaker.expand;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
import minetweaker.api.data.DataList;
|
import minetweaker.api.data.DataList;
|
||||||
import minetweaker.api.data.IData;
|
import minetweaker.api.data.IData;
|
||||||
import stanhebben.zenscript.annotations.ZenCaster;
|
import stanhebben.zenscript.annotations.ZenCaster;
|
||||||
@@ -13,6 +14,7 @@ import stanhebben.zenscript.annotations.ZenExpansion;
|
|||||||
*/
|
*/
|
||||||
@ZenExpansion("any[]")
|
@ZenExpansion("any[]")
|
||||||
public class ExpandAnyArray {
|
public class ExpandAnyArray {
|
||||||
|
|
||||||
@ZenCaster
|
@ZenCaster
|
||||||
public static IData asData(IData[] values) {
|
public static IData asData(IData[] values) {
|
||||||
return new DataList(Arrays.asList(values), true);
|
return new DataList(Arrays.asList(values), true);
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
/*
|
/*
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
* To change this license header, choose License Headers in Project Properties. To change this template file, choose
|
||||||
* To change this template file, choose Tools | Templates
|
* Tools | Templates and open the template in the editor.
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package minetweaker.expand;
|
package minetweaker.expand;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import minetweaker.api.data.DataMap;
|
import minetweaker.api.data.DataMap;
|
||||||
import minetweaker.api.data.IData;
|
import minetweaker.api.data.IData;
|
||||||
import stanhebben.zenscript.annotations.ZenCaster;
|
import stanhebben.zenscript.annotations.ZenCaster;
|
||||||
@@ -18,6 +18,7 @@ import stanhebben.zenscript.annotations.ZenExpansion;
|
|||||||
*/
|
*/
|
||||||
@ZenExpansion("any[any]")
|
@ZenExpansion("any[any]")
|
||||||
public class ExpandAnyDict {
|
public class ExpandAnyDict {
|
||||||
|
|
||||||
@ZenCaster
|
@ZenCaster
|
||||||
public static IData asData(Map<String, IData> values) {
|
public static IData asData(Map<String, IData> values) {
|
||||||
return new DataMap(values, true);
|
return new DataMap(values, true);
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
* To change this license header, choose License Headers in Project Properties. To change this template file, choose
|
||||||
* To change this template file, choose Tools | Templates
|
* Tools | Templates and open the template in the editor.
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package minetweaker.expand;
|
package minetweaker.expand;
|
||||||
@@ -17,6 +16,7 @@ import stanhebben.zenscript.annotations.ZenExpansion;
|
|||||||
*/
|
*/
|
||||||
@ZenExpansion("bool")
|
@ZenExpansion("bool")
|
||||||
public class ExpandBool {
|
public class ExpandBool {
|
||||||
|
|
||||||
@ZenCaster
|
@ZenCaster
|
||||||
public static IData asData(boolean value) {
|
public static IData asData(boolean value) {
|
||||||
return new DataBool(value);
|
return new DataBool(value);
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
* To change this license header, choose License Headers in Project Properties. To change this template file, choose
|
||||||
* To change this template file, choose Tools | Templates
|
* Tools | Templates and open the template in the editor.
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package minetweaker.expand;
|
package minetweaker.expand;
|
||||||
@@ -17,6 +16,7 @@ import stanhebben.zenscript.annotations.ZenExpansion;
|
|||||||
*/
|
*/
|
||||||
@ZenExpansion("byte")
|
@ZenExpansion("byte")
|
||||||
public class ExpandByte {
|
public class ExpandByte {
|
||||||
|
|
||||||
@ZenCaster
|
@ZenCaster
|
||||||
public static IData asData(byte value) {
|
public static IData asData(byte value) {
|
||||||
return new DataByte(value);
|
return new DataByte(value);
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
* To change this license header, choose License Headers in Project Properties. To change this template file, choose
|
||||||
* To change this template file, choose Tools | Templates
|
* Tools | Templates and open the template in the editor.
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package minetweaker.expand;
|
package minetweaker.expand;
|
||||||
@@ -17,6 +16,7 @@ import stanhebben.zenscript.annotations.ZenExpansion;
|
|||||||
*/
|
*/
|
||||||
@ZenExpansion("double")
|
@ZenExpansion("double")
|
||||||
public class ExpandDouble {
|
public class ExpandDouble {
|
||||||
|
|
||||||
@ZenCaster
|
@ZenCaster
|
||||||
public static IData asData(double value) {
|
public static IData asData(double value) {
|
||||||
return new DataDouble(value);
|
return new DataDouble(value);
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
* To change this license header, choose License Headers in Project Properties. To change this template file, choose
|
||||||
* To change this template file, choose Tools | Templates
|
* Tools | Templates and open the template in the editor.
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package minetweaker.expand;
|
package minetweaker.expand;
|
||||||
@@ -17,6 +16,7 @@ import stanhebben.zenscript.annotations.ZenExpansion;
|
|||||||
*/
|
*/
|
||||||
@ZenExpansion("float")
|
@ZenExpansion("float")
|
||||||
public class ExpandFloat {
|
public class ExpandFloat {
|
||||||
|
|
||||||
@ZenCaster
|
@ZenCaster
|
||||||
public static IData asData(float value) {
|
public static IData asData(float value) {
|
||||||
return new DataFloat(value);
|
return new DataFloat(value);
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
* To change this license header, choose License Headers in Project Properties. To change this template file, choose
|
||||||
* To change this template file, choose Tools | Templates
|
* Tools | Templates and open the template in the editor.
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package minetweaker.expand;
|
package minetweaker.expand;
|
||||||
@@ -17,6 +16,7 @@ import stanhebben.zenscript.annotations.ZenExpansion;
|
|||||||
*/
|
*/
|
||||||
@ZenExpansion("int")
|
@ZenExpansion("int")
|
||||||
public class ExpandInt {
|
public class ExpandInt {
|
||||||
|
|
||||||
@ZenCaster
|
@ZenCaster
|
||||||
public static IData toData(int value) {
|
public static IData toData(int value) {
|
||||||
return new DataInt(value);
|
return new DataInt(value);
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
* To change this license header, choose License Headers in Project Properties. To change this template file, choose
|
||||||
* To change this template file, choose Tools | Templates
|
* Tools | Templates and open the template in the editor.
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package minetweaker.expand;
|
package minetweaker.expand;
|
||||||
@@ -17,6 +16,7 @@ import stanhebben.zenscript.annotations.ZenExpansion;
|
|||||||
*/
|
*/
|
||||||
@ZenExpansion("minetweaker.item.IItemStack")
|
@ZenExpansion("minetweaker.item.IItemStack")
|
||||||
public class ExpandItemStack {
|
public class ExpandItemStack {
|
||||||
|
|
||||||
@ZenCaster
|
@ZenCaster
|
||||||
public static WeightedItemStack asWeightedItemStack(IItemStack value) {
|
public static WeightedItemStack asWeightedItemStack(IItemStack value) {
|
||||||
return new WeightedItemStack(value, 1.0f);
|
return new WeightedItemStack(value, 1.0f);
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
* To change this license header, choose License Headers in Project Properties. To change this template file, choose
|
||||||
* To change this template file, choose Tools | Templates
|
* Tools | Templates and open the template in the editor.
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package minetweaker.expand;
|
package minetweaker.expand;
|
||||||
@@ -17,6 +16,7 @@ import stanhebben.zenscript.annotations.ZenExpansion;
|
|||||||
*/
|
*/
|
||||||
@ZenExpansion("long")
|
@ZenExpansion("long")
|
||||||
public class ExpandLong {
|
public class ExpandLong {
|
||||||
|
|
||||||
@ZenCaster
|
@ZenCaster
|
||||||
public static IData asData(long value) {
|
public static IData asData(long value) {
|
||||||
return new DataLong(value);
|
return new DataLong(value);
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
* To change this license header, choose License Headers in Project Properties. To change this template file, choose
|
||||||
* To change this template file, choose Tools | Templates
|
* Tools | Templates and open the template in the editor.
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package minetweaker.expand;
|
package minetweaker.expand;
|
||||||
@@ -17,6 +16,7 @@ import stanhebben.zenscript.annotations.ZenExpansion;
|
|||||||
*/
|
*/
|
||||||
@ZenExpansion("short")
|
@ZenExpansion("short")
|
||||||
public class ExpandShort {
|
public class ExpandShort {
|
||||||
|
|
||||||
@ZenCaster
|
@ZenCaster
|
||||||
public static IData asNBT(short value) {
|
public static IData asNBT(short value) {
|
||||||
return new DataShort(value);
|
return new DataShort(value);
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
/*
|
/*
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
* To change this license header, choose License Headers in Project Properties. To change this template file, choose
|
||||||
* To change this template file, choose Tools | Templates
|
* Tools | Templates and open the template in the editor.
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package minetweaker.expand;
|
package minetweaker.expand;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import minetweaker.MineTweakerAPI;
|
import minetweaker.MineTweakerAPI;
|
||||||
import minetweaker.MineTweakerImplementationAPI;
|
import minetweaker.MineTweakerImplementationAPI;
|
||||||
import minetweaker.api.chat.IChatMessage;
|
import minetweaker.api.chat.IChatMessage;
|
||||||
@@ -27,6 +27,7 @@ import stanhebben.zenscript.annotations.ZenOperator;
|
|||||||
*/
|
*/
|
||||||
@ZenExpansion("string")
|
@ZenExpansion("string")
|
||||||
public class ExpandString {
|
public class ExpandString {
|
||||||
|
|
||||||
@ZenOperator(OperatorType.ADD)
|
@ZenOperator(OperatorType.ADD)
|
||||||
public static IFormattedText add(String str, IFormattedText formattedText) {
|
public static IFormattedText add(String str, IFormattedText formattedText) {
|
||||||
return MineTweakerAPI.format.string(str).add(formattedText);
|
return MineTweakerAPI.format.string(str).add(formattedText);
|
||||||
@@ -60,14 +61,12 @@ public class ExpandString {
|
|||||||
|
|
||||||
while (minIndex + separator.length() <= value.length()) {
|
while (minIndex + separator.length() <= value.length()) {
|
||||||
int index = value.indexOf(separator, minIndex);
|
int index = value.indexOf(separator, minIndex);
|
||||||
if (index < 0)
|
if (index < 0) break;
|
||||||
break;
|
|
||||||
result.add(value.substring(minIndex, index));
|
result.add(value.substring(minIndex, index));
|
||||||
minIndex = index + separator.length();
|
minIndex = index + separator.length();
|
||||||
|
|
||||||
numSplits++;
|
numSplits++;
|
||||||
if (maximum > 0 && numSplits >= maximum)
|
if (maximum > 0 && numSplits >= maximum) break;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
result.add(value.substring(minIndex));
|
result.add(value.substring(minIndex));
|
||||||
|
|||||||
@@ -1,5 +1,12 @@
|
|||||||
package minetweaker.mc1710;
|
package minetweaker.mc1710;
|
||||||
|
|
||||||
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
|
|
||||||
|
import org.lwjgl.input.Keyboard;
|
||||||
|
|
||||||
|
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||||
|
import cpw.mods.fml.common.gameevent.PlayerEvent;
|
||||||
|
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||||
import minetweaker.MineTweakerAPI;
|
import minetweaker.MineTweakerAPI;
|
||||||
import minetweaker.MineTweakerImplementationAPI;
|
import minetweaker.MineTweakerImplementationAPI;
|
||||||
import minetweaker.api.event.PlayerCraftedEvent;
|
import minetweaker.api.event.PlayerCraftedEvent;
|
||||||
@@ -11,23 +18,36 @@ import minetweaker.api.player.IPlayer;
|
|||||||
import minetweaker.mc1710.network.MineTweakerLoadScriptsPacket;
|
import minetweaker.mc1710.network.MineTweakerLoadScriptsPacket;
|
||||||
import minetweaker.mc1710.recipes.MCCraftingInventory;
|
import minetweaker.mc1710.recipes.MCCraftingInventory;
|
||||||
import minetweaker.mc1710.recipes.MCRecipeManager;
|
import minetweaker.mc1710.recipes.MCRecipeManager;
|
||||||
import net.minecraft.entity.player.EntityPlayerMP;
|
|
||||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
|
||||||
import cpw.mods.fml.common.gameevent.PlayerEvent;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Stan
|
* @author Stan
|
||||||
*/
|
*/
|
||||||
public class FMLEventHandler {
|
public class FMLEventHandler {
|
||||||
|
|
||||||
|
private static boolean shiftDown = false;
|
||||||
|
|
||||||
|
public static boolean isShiftDown() {
|
||||||
|
return shiftDown;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void onClientTick(TickEvent.ClientTickEvent ev) {
|
||||||
|
if (ev.phase == TickEvent.Phase.START) {
|
||||||
|
shiftDown = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onPlayerLoggedIn(PlayerEvent.PlayerLoggedInEvent ev) {
|
public void onPlayerLoggedIn(PlayerEvent.PlayerLoggedInEvent ev) {
|
||||||
if (ev.player instanceof EntityPlayerMP && MineTweakerConfig.sendLoadScripts) {
|
if (ev.player instanceof EntityPlayerMP && MineTweakerConfig.sendLoadScripts) {
|
||||||
EntityPlayerMP player = (EntityPlayerMP) ev.player;
|
EntityPlayerMP player = (EntityPlayerMP) ev.player;
|
||||||
MineTweakerMod.NETWORK.sendTo(new MineTweakerLoadScriptsPacket(MineTweakerAPI.tweaker.getScriptData()), player);
|
MineTweakerMod.NETWORK
|
||||||
|
.sendTo(new MineTweakerLoadScriptsPacket(MineTweakerAPI.tweaker.getScriptData()), player);
|
||||||
}
|
}
|
||||||
|
|
||||||
MineTweakerImplementationAPI.events.publishPlayerLoggedIn(new PlayerLoggedInEvent(MineTweakerMC.getIPlayer(ev.player)));
|
MineTweakerImplementationAPI.events
|
||||||
|
.publishPlayerLoggedIn(new PlayerLoggedInEvent(MineTweakerMC.getIPlayer(ev.player)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
@@ -38,20 +58,28 @@ public class FMLEventHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (MineTweakerImplementationAPI.events.hasPlayerCrafted()) {
|
if (MineTweakerImplementationAPI.events.hasPlayerCrafted()) {
|
||||||
MineTweakerImplementationAPI.events.publishPlayerCrafted(new PlayerCraftedEvent(iPlayer, MineTweakerMC.getIItemStack(ev.crafting), MCCraftingInventory.get(ev.craftMatrix, ev.player)));
|
MineTweakerImplementationAPI.events.publishPlayerCrafted(
|
||||||
|
new PlayerCraftedEvent(
|
||||||
|
iPlayer,
|
||||||
|
MineTweakerMC.getIItemStack(ev.crafting),
|
||||||
|
MCCraftingInventory.get(ev.craftMatrix, ev.player)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onPlayerItemSmelted(PlayerEvent.ItemSmeltedEvent ev) {
|
public void onPlayerItemSmelted(PlayerEvent.ItemSmeltedEvent ev) {
|
||||||
if (MineTweakerImplementationAPI.events.hasPlayerSmelted()) {
|
if (MineTweakerImplementationAPI.events.hasPlayerSmelted()) {
|
||||||
MineTweakerImplementationAPI.events.publishPlayerSmelted(new PlayerSmeltedEvent(MineTweakerMC.getIPlayer(ev.player), MineTweakerMC.getIItemStack(ev.smelting)));
|
MineTweakerImplementationAPI.events.publishPlayerSmelted(
|
||||||
|
new PlayerSmeltedEvent(
|
||||||
|
MineTweakerMC.getIPlayer(ev.player),
|
||||||
|
MineTweakerMC.getIItemStack(ev.smelting)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onPlayerLoggedOut(PlayerEvent.PlayerLoggedOutEvent ev) {
|
public void onPlayerLoggedOut(PlayerEvent.PlayerLoggedOutEvent ev) {
|
||||||
MineTweakerImplementationAPI.events.publishPlayerLoggedOut(new PlayerLoggedOutEvent(MineTweakerMC.getIPlayer(ev.player)));
|
MineTweakerImplementationAPI.events
|
||||||
|
.publishPlayerLoggedOut(new PlayerLoggedOutEvent(MineTweakerMC.getIPlayer(ev.player)));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,11 +1,22 @@
|
|||||||
/*
|
/*
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
* To change this license header, choose License Headers in Project Properties. To change this template file, choose
|
||||||
* To change this template file, choose Tools | Templates
|
* Tools | Templates and open the template in the editor.
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package minetweaker.mc1710;
|
package minetweaker.mc1710;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
import net.minecraft.client.multiplayer.GuiConnecting;
|
||||||
|
import net.minecraft.entity.*;
|
||||||
|
import net.minecraft.entity.item.*;
|
||||||
|
import net.minecraft.entity.player.*;
|
||||||
|
import net.minecraft.item.*;
|
||||||
|
import net.minecraftforge.client.event.GuiOpenEvent;
|
||||||
|
import net.minecraftforge.event.entity.living.*;
|
||||||
|
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
|
||||||
|
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||||
|
|
||||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
@@ -17,31 +28,21 @@ import minetweaker.api.minecraft.MineTweakerMC;
|
|||||||
import minetweaker.api.tooltip.IngredientTooltips;
|
import minetweaker.api.tooltip.IngredientTooltips;
|
||||||
import minetweaker.mc1710.formatting.IMCFormattedString;
|
import minetweaker.mc1710.formatting.IMCFormattedString;
|
||||||
import minetweaker.mc1710.item.*;
|
import minetweaker.mc1710.item.*;
|
||||||
import net.minecraft.client.multiplayer.GuiConnecting;
|
|
||||||
import net.minecraft.entity.*;
|
|
||||||
import net.minecraft.entity.item.*;
|
|
||||||
import net.minecraft.entity.player.*;
|
|
||||||
import net.minecraft.item.*;
|
|
||||||
import net.minecraftforge.client.event.GuiOpenEvent;
|
|
||||||
import net.minecraftforge.event.entity.living.*;
|
|
||||||
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
|
|
||||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
|
||||||
import org.lwjgl.input.Keyboard;
|
|
||||||
import stanhebben.zenscript.value.*;
|
import stanhebben.zenscript.value.*;
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Stan
|
* @author Stan
|
||||||
*/
|
*/
|
||||||
public class ForgeEventHandler {
|
public class ForgeEventHandler {
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onPlayerInteract(PlayerInteractEvent ev) {
|
public void onPlayerInteract(PlayerInteractEvent ev) {
|
||||||
minetweaker.api.event.PlayerInteractEvent event = new minetweaker.api.event.PlayerInteractEvent(
|
minetweaker.api.event.PlayerInteractEvent event = new minetweaker.api.event.PlayerInteractEvent(
|
||||||
MineTweakerMC.getIPlayer(ev.entityPlayer),
|
MineTweakerMC.getIPlayer(ev.entityPlayer),
|
||||||
MineTweakerMC.getDimension(ev.world),
|
MineTweakerMC.getDimension(ev.world),
|
||||||
ev.x, ev.y, ev.z
|
ev.x,
|
||||||
);
|
ev.y,
|
||||||
|
ev.z);
|
||||||
|
|
||||||
MineTweakerImplementationAPI.events.publishPlayerInteract(event);
|
MineTweakerImplementationAPI.events.publishPlayerInteract(event);
|
||||||
}
|
}
|
||||||
@@ -60,7 +61,7 @@ public class ForgeEventHandler {
|
|||||||
ev.toolTip.add(((IMCFormattedString) tooltip).getTooltipString());
|
ev.toolTip.add(((IMCFormattedString) tooltip).getTooltipString());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) {
|
if (FMLEventHandler.isShiftDown()) {
|
||||||
for (IFormattedText tooltip : IngredientTooltips.getShiftTooltips(itemStack)) {
|
for (IFormattedText tooltip : IngredientTooltips.getShiftTooltips(itemStack)) {
|
||||||
ev.toolTip.add(((IMCFormattedString) tooltip).getTooltipString());
|
ev.toolTip.add(((IMCFormattedString) tooltip).getTooltipString());
|
||||||
}
|
}
|
||||||
@@ -68,7 +69,6 @@ public class ForgeEventHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onLivingDeathDrops(LivingDropsEvent ev) {
|
public void onLivingDeathDrops(LivingDropsEvent ev) {
|
||||||
final EntityLivingBase entity = ev.entityLiving;
|
final EntityLivingBase entity = ev.entityLiving;
|
||||||
@@ -84,9 +84,19 @@ public class ForgeEventHandler {
|
|||||||
|
|
||||||
final EntityItem item;
|
final EntityItem item;
|
||||||
if (val.getMin() == 0 && val.getMax() == 0) {
|
if (val.getMin() == 0 && val.getMax() == 0) {
|
||||||
item = new EntityItem(entity.worldObj, entity.posX + 0.5, entity.posY + 0.5, entity.posZ + 0.5, ((ItemStack) key.getInternal()).copy());
|
item = new EntityItem(
|
||||||
|
entity.worldObj,
|
||||||
|
entity.posX + 0.5,
|
||||||
|
entity.posY + 0.5,
|
||||||
|
entity.posZ + 0.5,
|
||||||
|
((ItemStack) key.getInternal()).copy());
|
||||||
} else {
|
} else {
|
||||||
item = new EntityItem(entity.worldObj, entity.posX + 0.5, entity.posY + 0.5, entity.posZ + 0.5, ((ItemStack) key.withAmount(val.getRandom()).getInternal()).copy());
|
item = new EntityItem(
|
||||||
|
entity.worldObj,
|
||||||
|
entity.posX + 0.5,
|
||||||
|
entity.posY + 0.5,
|
||||||
|
entity.posZ + 0.5,
|
||||||
|
((ItemStack) key.withAmount(val.getRandom()).getInternal()).copy());
|
||||||
}
|
}
|
||||||
ev.drops.add(item);
|
ev.drops.add(item);
|
||||||
}
|
}
|
||||||
@@ -99,9 +109,19 @@ public class ForgeEventHandler {
|
|||||||
|
|
||||||
final EntityItem item;
|
final EntityItem item;
|
||||||
if (val.getMin() == 0 && val.getMax() == 0) {
|
if (val.getMin() == 0 && val.getMax() == 0) {
|
||||||
item = new EntityItem(entity.worldObj, entity.posX + 0.5, entity.posY + 0.5, entity.posZ + 0.5, ((ItemStack) key.getInternal()).copy());
|
item = new EntityItem(
|
||||||
|
entity.worldObj,
|
||||||
|
entity.posX + 0.5,
|
||||||
|
entity.posY + 0.5,
|
||||||
|
entity.posZ + 0.5,
|
||||||
|
((ItemStack) key.getInternal()).copy());
|
||||||
} else {
|
} else {
|
||||||
item = new EntityItem(entity.worldObj, entity.posX + 0.5, entity.posY + 0.5, entity.posZ + 0.5, ((ItemStack) key.withAmount(val.getRandom()).getInternal()).copy());
|
item = new EntityItem(
|
||||||
|
entity.worldObj,
|
||||||
|
entity.posX + 0.5,
|
||||||
|
entity.posY + 0.5,
|
||||||
|
entity.posZ + 0.5,
|
||||||
|
((ItemStack) key.withAmount(val.getRandom()).getInternal()).copy());
|
||||||
}
|
}
|
||||||
ev.drops.add(item);
|
ev.drops.add(item);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,13 +4,13 @@ import net.minecraft.client.gui.GuiButton;
|
|||||||
import net.minecraft.client.gui.GuiScreen;
|
import net.minecraft.client.gui.GuiScreen;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This screen is shown when a client has been modified with a permanent
|
* This screen is shown when a client has been modified with a permanent modification and the player logs into a game
|
||||||
* modification and the player logs into a game with a different script. It asks
|
* with a different script. It asks the player to restart the game.
|
||||||
* the player to restart the game.
|
|
||||||
*
|
*
|
||||||
* @author Stan Hebben
|
* @author Stan Hebben
|
||||||
*/
|
*/
|
||||||
public class GuiCannotRemodify extends GuiScreen {
|
public class GuiCannotRemodify extends GuiScreen {
|
||||||
|
|
||||||
private final String message1;
|
private final String message1;
|
||||||
private final String message2;
|
private final String message2;
|
||||||
private final String message3;
|
private final String message3;
|
||||||
@@ -24,29 +24,15 @@ public class GuiCannotRemodify extends GuiScreen {
|
|||||||
@Override
|
@Override
|
||||||
public void initGui() {
|
public void initGui() {
|
||||||
this.buttonList.clear();
|
this.buttonList.clear();
|
||||||
this.buttonList.add(
|
this.buttonList.add(new GuiButton(0, this.width / 2 - 100, this.height / 4 + 120 + 12, "Close"));
|
||||||
new GuiButton(0, this.width / 2 - 100, this.height / 4 + 120 + 12, "Close")
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drawScreen(int par1, int par2, float par3) {
|
public void drawScreen(int par1, int par2, float par3) {
|
||||||
this.drawDefaultBackground();
|
this.drawDefaultBackground();
|
||||||
this.drawCenteredString(
|
this.drawCenteredString(this.fontRendererObj, message1, this.width / 2, this.height / 2 - 40, 11184810);
|
||||||
this.fontRendererObj,
|
this.drawCenteredString(this.fontRendererObj, message2, this.width / 2, this.height / 2 - 20, 11184810);
|
||||||
message1,
|
this.drawCenteredString(this.fontRendererObj, message3, this.width / 2, this.height / 2 - 0, 11184810);
|
||||||
this.width / 2, this.height / 2 - 40,
|
|
||||||
11184810);
|
|
||||||
this.drawCenteredString(
|
|
||||||
this.fontRendererObj,
|
|
||||||
message2,
|
|
||||||
this.width / 2, this.height / 2 - 20,
|
|
||||||
11184810);
|
|
||||||
this.drawCenteredString(
|
|
||||||
this.fontRendererObj,
|
|
||||||
message3,
|
|
||||||
this.width / 2, this.height / 2 - 0,
|
|
||||||
11184810);
|
|
||||||
|
|
||||||
super.drawScreen(par1, par2, par3);
|
super.drawScreen(par1, par2, par3);
|
||||||
}
|
}
|
||||||
|
|||||||
Loaded 100 of 211 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user