mirror of
https://github.com/GTNewHorizons/CraftTweaker.git
synced 2026-11-24 22:04:23 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ea3b258225 | ||
|
|
a28945f5f1 | ||
|
|
4e3c2c1b79 | ||
|
|
69b28b3bd4 | ||
|
|
60c3c9056d | ||
|
|
bebd499076 | ||
|
|
6376aff61f | ||
|
|
a309488cdf | ||
|
|
6b208b98bc | ||
|
|
e9a6a085b5 | ||
|
|
1afc652dc4 | ||
|
|
356fbdbdcc | ||
|
|
1d76f7db78 | ||
|
|
8abb3efbfb | ||
|
|
b86eeb4cc6 | ||
|
|
a7f9afb6c4 | ||
|
|
236744c74e | ||
|
|
eb2b529dea | ||
|
|
bf291dee77 | ||
|
|
a02cb3eec6 | ||
|
|
38c46d61d9 | ||
|
|
7c4b38e853 | ||
|
|
67ef22c4cc | ||
|
|
5044de32dd | ||
|
|
7b75ffb679 | ||
|
|
4787672b6e | ||
|
|
22502ff016 | ||
|
|
7c060cb624 | ||
|
|
b6a27cb150 | ||
|
|
6ffcca483f | ||
|
|
dc78b2b39e | ||
|
|
436ad039ca | ||
|
|
a348865dda | ||
|
|
86b4108e4f | ||
|
|
4d4fed2482 | ||
|
|
1796484e7c | ||
|
|
af79e56481 |
No files matched your search
@@ -0,0 +1,19 @@
|
|||||||
|
# This is the universal Text Editor Configuration
|
||||||
|
# for all GTNewHorizons projects
|
||||||
|
# See: https://editorconfig.org/
|
||||||
|
|
||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
charset = utf-8
|
||||||
|
end_of_line = lf
|
||||||
|
indent_size = 4
|
||||||
|
indent_style = space
|
||||||
|
insert_final_newline = true
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
|
||||||
|
[*.{bat,ini}]
|
||||||
|
end_of_line = crlf
|
||||||
|
|
||||||
|
[*.{dtd,json,info,mcmeta,md,sh,svg,xml,xsd,xsl,yaml,yml}]
|
||||||
|
indent_size = 2
|
||||||
@@ -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
|
||||||
Executable
+51
@@ -0,0 +1,51 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# bashsupport disable=BP5006 # Global environment variables
|
||||||
|
RUNDIR="run" \
|
||||||
|
CRASH="crash-reports" \
|
||||||
|
SERVERLOG="server.log"
|
||||||
|
|
||||||
|
# enable nullglob to get 0 results when no match rather than the pattern
|
||||||
|
shopt -s nullglob
|
||||||
|
|
||||||
|
# store matches in array
|
||||||
|
crash_reports=("$RUNDIR/$CRASH/crash"*.txt)
|
||||||
|
|
||||||
|
# if array not empty there are crash_reports
|
||||||
|
if [ "${#crash_reports[@]}" -gt 0 ]; then
|
||||||
|
# get the latest crash_report from array
|
||||||
|
latest_crash_report="${crash_reports[-1]}"
|
||||||
|
{
|
||||||
|
printf 'Latest crash report detected %s:\n' "${latest_crash_report##*/}"
|
||||||
|
cat "$latest_crash_report"
|
||||||
|
} >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if grep --quiet --fixed-strings 'Fatal errors were detected' "$SERVERLOG"; then
|
||||||
|
{
|
||||||
|
printf 'Fatal errors detected:\n'
|
||||||
|
cat server.log
|
||||||
|
} >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if grep --quiet --fixed-strings 'The state engine was in incorrect state ERRORED and forced into state SERVER_STOPPED' \
|
||||||
|
"$SERVERLOG"; then
|
||||||
|
{
|
||||||
|
printf 'Server force stopped:'
|
||||||
|
cat server.log
|
||||||
|
} >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! grep --quiet --perl-regexp --only-matching '.+Done \(.+\)\! For help, type "help" or "\?"' "$SERVERLOG"; then
|
||||||
|
{
|
||||||
|
printf 'Server did not finish startup:'
|
||||||
|
cat server.log
|
||||||
|
} >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
printf 'No crash reports detected'
|
||||||
|
exit 0
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
|
||||||
|
name: Build and test
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
branches: [ master, main ]
|
||||||
|
push:
|
||||||
|
branches: [ master, main ]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-and-test:
|
||||||
|
uses: GTNewHorizons/GTNH-Actions-Workflows/.github/workflows/build-and-test.yml@master
|
||||||
|
secrets: inherit
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
|
||||||
|
name: Release tagged build
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags: [ '*' ]
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
release-tags:
|
||||||
|
uses: GTNewHorizons/GTNH-Actions-Workflows/.github/workflows/release-tags.yml@master
|
||||||
|
secrets: inherit
|
||||||
+34
-139
@@ -1,140 +1,35 @@
|
|||||||
# Ignore All
|
.gradle
|
||||||
/*
|
.settings
|
||||||
|
/.idea/
|
||||||
# Except:
|
.shelf
|
||||||
|
/run/
|
||||||
# Source files & libraries
|
/build/
|
||||||
!/buildSrc
|
/eclipse/
|
||||||
/buildSrc/*
|
.vscode
|
||||||
!/buildSrc/src/
|
.classpath
|
||||||
|
.project
|
||||||
!/MineTweaker3-API
|
/bin/
|
||||||
/MineTweaker3-API/*
|
/config/
|
||||||
!/MineTweaker3-API/src
|
/crash-reports/
|
||||||
|
/logs/
|
||||||
!/MineTweaker3-MC1112-Main
|
options.txt
|
||||||
/MineTweaker3-MC1112-Main/*
|
/saves/
|
||||||
!/MineTweaker3-MC1112-Main/src
|
usernamecache.json
|
||||||
!/MineTweaker3-MC1112-Main/build.gradle
|
banned-ips.json
|
||||||
/MineTweaker3-MC1112-Main/bin
|
banned-players.json
|
||||||
|
eula.txt
|
||||||
!/MineTweaker3-MC1112-Mod-JEI
|
ops.json
|
||||||
/MineTweaker3-MC1112-Mod-JEI/*
|
server.properties
|
||||||
!/MineTweaker3-MC1112-Mod-JEI/src
|
servers.dat
|
||||||
!/MineTweaker3-MC1112-Mod-JEI/libs
|
usercache.json
|
||||||
!/MineTweaker3-MC1112-Mod-JEI/build.gradle
|
whitelist.json
|
||||||
|
/out/
|
||||||
!/MineTweaker3-MC1102-Main
|
*.iml
|
||||||
/MineTweaker3-MC1102-Main/*
|
*.ipr
|
||||||
!/MineTweaker3-MC1102-Main/src
|
*.iws
|
||||||
!/MineTweaker3-MC1102-Main/build.gradle
|
src/main/resources/mixins.*.json
|
||||||
/MineTweaker3-MC1102-Main/bin
|
*.bat
|
||||||
|
/src/main/generated/
|
||||||
!/MineTweaker3-MC1102-Mod-JEI
|
/src/test/generated/
|
||||||
/MineTweaker3-MC1102-Mod-JEI/*
|
|
||||||
!/MineTweaker3-MC1102-Mod-JEI/src
|
|
||||||
!/MineTweaker3-MC1102-Mod-JEI/libs
|
|
||||||
!/MineTweaker3-MC1102-Mod-JEI/build.gradle
|
|
||||||
|
|
||||||
!/MineTweaker3-MC19-Main
|
|
||||||
/MineTweaker3-MC19-Main/*
|
|
||||||
!/MineTweaker3-MC19-Main/src
|
|
||||||
!/MineTweaker3-MC19-Main/build.gradle
|
|
||||||
/MineTweaker3-MC19-Main/bin
|
|
||||||
|
|
||||||
!/MineTweaker3-MC19-Mod-JEI
|
|
||||||
/MineTweaker3-MC19-Mod-JEI/*
|
|
||||||
!/MineTweaker3-MC19-Mod-JEI/src
|
|
||||||
!/MineTweaker3-MC19-Mod-JEI/libs
|
|
||||||
!/MineTweaker3-MC19-Mod-JEI/build.gradle
|
|
||||||
|
|
||||||
!/MineTweaker3-MC18-Main
|
|
||||||
/MineTweaker3-MC18-Main/*
|
|
||||||
!/MineTweaker3-MC18-Main/src
|
|
||||||
!/MineTweaker3-MC18-Main/build.gradle
|
|
||||||
/MineTweaker3-MC18-Main/bin
|
|
||||||
|
|
||||||
!/MineTweaker3-MC18-Mod-JEI
|
|
||||||
/MineTweaker3-MC18-Mod-JEI/*
|
|
||||||
!/MineTweaker3-MC18-Mod-JEI/src
|
|
||||||
!/MineTweaker3-MC18-Mod-JEI/libs
|
|
||||||
!/MineTweaker3-MC18-Mod-JEI/build.gradle
|
|
||||||
|
|
||||||
|
|
||||||
!/MineTweaker3-MC1710-Main
|
|
||||||
/MineTweaker3-MC1710-Main/*
|
|
||||||
!/MineTweaker3-MC1710-Main/src
|
|
||||||
/MineTweaker3-MC1710-Main/bin
|
|
||||||
!/MineTweaker3-MC1710-Main/build.gradle
|
|
||||||
|
|
||||||
|
|
||||||
!/MineTweaker3-MC1710-Mod-Buildcraft
|
|
||||||
/MineTweaker3-MC1710-Mod-Buildcraft/*
|
|
||||||
!/MineTweaker3-MC1710-Mod-Buildcraft/src
|
|
||||||
!/MineTweaker3-MC1710-Mod-Buildcraft/libs
|
|
||||||
!/MineTweaker3-MC1710-Mod-Buildcraft/build.gradle
|
|
||||||
|
|
||||||
|
|
||||||
!/MineTweaker3-MC1710-Mod-Buildcraft61
|
|
||||||
/MineTweaker3-MC1710-Mod-Buildcraft61/*
|
|
||||||
!/MineTweaker3-MC1710-Mod-Buildcraft61/src
|
|
||||||
!/MineTweaker3-MC1710-Mod-Buildcraft61/libs
|
|
||||||
!/MineTweaker3-MC1710-Mod-Buildcraft61/build.gradle
|
|
||||||
|
|
||||||
!/MineTweaker3-MC1710-Mod-IC2
|
|
||||||
/MineTweaker3-MC1710-Mod-IC2/*
|
|
||||||
!/MineTweaker3-MC1710-Mod-IC2/src
|
|
||||||
!/MineTweaker3-MC1710-Mod-IC2/libs
|
|
||||||
!/MineTweaker3-MC1710-Mod-IC2/build.gradle
|
|
||||||
|
|
||||||
!/MineTweaker3-MC1102-Mod-IC2
|
|
||||||
/MineTweaker3-MC1102-Mod-IC2/*
|
|
||||||
!/MineTweaker3-MC1102-Mod-IC2/src
|
|
||||||
!/MineTweaker3-MC1102-Mod-IC2/libs
|
|
||||||
!/MineTweaker3-MC1102-Mod-IC2/build.gradle
|
|
||||||
|
|
||||||
!/MineTweaker3-MC1710-Mod-MFR
|
|
||||||
/MineTweaker3-MC1710-Mod-MFR/*
|
|
||||||
!/MineTweaker3-MC1710-Mod-MFR/src
|
|
||||||
!/MineTweaker3-MC1710-Mod-MFR/libs
|
|
||||||
!/MineTweaker3-MC1710-Mod-MFR/build.gradle
|
|
||||||
|
|
||||||
|
|
||||||
!/MineTweaker3-MC1710-Mod-NEI
|
|
||||||
/MineTweaker3-MC1710-Mod-NEI/*
|
|
||||||
!/MineTweaker3-MC1710-Mod-NEI/src
|
|
||||||
!/MineTweaker3-MC1710-Mod-NEI/libs
|
|
||||||
!/MineTweaker3-MC1710-Mod-NEI/build.gradle
|
|
||||||
|
|
||||||
|
|
||||||
!/ZenScript
|
|
||||||
/ZenScript/*
|
|
||||||
!/ZenScript/src
|
|
||||||
|
|
||||||
!/MineTweaker3-Web
|
|
||||||
|
|
||||||
# gradle
|
|
||||||
!/build.gradle
|
|
||||||
!/build.properties
|
|
||||||
!/settings.gradle
|
|
||||||
!/common.gradle
|
|
||||||
!/gradle.properties
|
|
||||||
!/gradlew*
|
|
||||||
!/gradle
|
|
||||||
|
|
||||||
MineTweaker3-Web/doc
|
|
||||||
|
|
||||||
# github
|
|
||||||
!/.gitignore
|
|
||||||
!/README.md
|
|
||||||
|
|
||||||
# unwanted os-generated files
|
|
||||||
nbproject/
|
|
||||||
.DS_Store
|
.DS_Store
|
||||||
.DS_Store?
|
classes
|
||||||
._*
|
|
||||||
.Spotlight-V100
|
|
||||||
.Trashes
|
|
||||||
ehthumbs.db
|
|
||||||
Thumbs.db
|
|
||||||
*~
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
[submodule "ZenScript"]
|
|
||||||
path = ZenScript
|
|
||||||
url = https://github.com/CraftTweaker/ZenScript.git
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
||||||
<gradle-project-properties>
|
|
||||||
<!--DO NOT EDIT THIS FILE! - Used by the Gradle plugin of NetBeans.-->
|
|
||||||
<built-in-tasks>
|
|
||||||
<task>
|
|
||||||
<display-name>debug</display-name>
|
|
||||||
<non-blocking>no</non-blocking>
|
|
||||||
<task-names>
|
|
||||||
<name must-exist="no">runClient</name>
|
|
||||||
</task-names>
|
|
||||||
<task-args/>
|
|
||||||
<task-jvm-args>
|
|
||||||
<arg>-Xdebug</arg>
|
|
||||||
</task-jvm-args>
|
|
||||||
</task>
|
|
||||||
<task>
|
|
||||||
<display-name>run</display-name>
|
|
||||||
<non-blocking>no</non-blocking>
|
|
||||||
<task-names>
|
|
||||||
<name must-exist="no">runClient</name>
|
|
||||||
</task-names>
|
|
||||||
<task-args/>
|
|
||||||
<task-jvm-args>
|
|
||||||
<arg>-Dfml.coreMods.load=minetweaker.mc172.transformer.MineTweakerTransformer</arg>
|
|
||||||
</task-jvm-args>
|
|
||||||
</task>
|
|
||||||
<task>
|
|
||||||
<display-name>run.single</display-name>
|
|
||||||
<non-blocking>no</non-blocking>
|
|
||||||
<task-names>
|
|
||||||
<name must-exist="no">${project}:runClient</name>
|
|
||||||
</task-names>
|
|
||||||
<task-args/>
|
|
||||||
<task-jvm-args/>
|
|
||||||
</task>
|
|
||||||
</built-in-tasks>
|
|
||||||
</gradle-project-properties>
|
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
|
||||||
|
# CraftTweaker
|
||||||
|
|
||||||
|
Changelog of CraftTweaker.
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
# Any Github changes require admin approval
|
||||||
|
/.github/** @GTNewHorizons/admin
|
||||||
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
import minetweaker.tasks.RegisterZenClassesTask;
|
|
||||||
|
|
||||||
apply plugin: 'java'
|
|
||||||
apply plugin: 'maven'
|
|
||||||
|
|
||||||
version = ext.mineTweakerVersion
|
|
||||||
|
|
||||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
|
||||||
targetCompatibility = JavaVersion.VERSION_1_8
|
|
||||||
sourceCompatibility = 1.8
|
|
||||||
targetCompatibility = 1.8
|
|
||||||
|
|
||||||
task makeRegistry(type: RegisterZenClassesTask) {
|
|
||||||
inputDir = file('build/classes/main')
|
|
||||||
outputDir = file('build/classes/main')
|
|
||||||
className = 'minetweaker.ClassRegistry'
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.jar.dependsOn(makeRegistry)
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
dependencies {
|
|
||||||
compile project(':ZenScript')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
package minetweaker;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The class registry provides the list of annotated classes to the scripting
|
|
||||||
* system.
|
|
||||||
*
|
|
||||||
* @author Stan Hebben
|
|
||||||
*/
|
|
||||||
public class ClassRegistry {
|
|
||||||
public static void getClasses(List<Class> output) {
|
|
||||||
// method stub; contents generated by RegisterZenClassesTask
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
package minetweaker;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import stanhebben.zenscript.compiler.IEnvironmentGlobal;
|
|
||||||
import stanhebben.zenscript.parser.Token;
|
|
||||||
import stanhebben.zenscript.symbols.IZenSymbol;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Bracket handlers enable processing of the bracket syntax.
|
|
||||||
*
|
|
||||||
* Inside brackets, any kind of token is acceptable except the closing bracket.
|
|
||||||
* (>) Bracket handlers (multiple handlers can be registered) will resolve
|
|
||||||
* these tokens into actual values. Values have to be ZenScript symbols and will
|
|
||||||
* resolve at compile-time.
|
|
||||||
*
|
|
||||||
* These may of course return an expression that are executed on run-time, but
|
|
||||||
* the type of the resulting value must be known compile-time.
|
|
||||||
*
|
|
||||||
* @author Stan Hebben
|
|
||||||
*/
|
|
||||||
public interface IBracketHandler {
|
|
||||||
/**
|
|
||||||
* Resolves a set of tokens.
|
|
||||||
*
|
|
||||||
* If the series of tokens is unrecognized, this method should return null.
|
|
||||||
*
|
|
||||||
* @param environment global compilation environment
|
|
||||||
* @param tokens token stream to be detected
|
|
||||||
* @return the resolved symbol, or null
|
|
||||||
*/
|
|
||||||
public IZenSymbol resolve(IEnvironmentGlobal environment, List<Token> tokens);
|
|
||||||
}
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
package minetweaker;
|
|
||||||
|
|
||||||
import minetweaker.api.chat.IChatMessage;
|
|
||||||
import minetweaker.api.item.IItemDefinition;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Platform functions are a set of internal functions implemented by the
|
|
||||||
* platform intended to communicate between API and implementation.
|
|
||||||
*
|
|
||||||
* @author Stan Hebben
|
|
||||||
*/
|
|
||||||
public interface IPlatformFunctions {
|
|
||||||
/**
|
|
||||||
* Converts a string into a chat message.
|
|
||||||
*
|
|
||||||
* @param message message string
|
|
||||||
* @return chat message
|
|
||||||
*/
|
|
||||||
public IChatMessage getMessage(String message);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Distributes the given script data to all connected clients. Automatically
|
|
||||||
* reloads the scripts from this data.
|
|
||||||
*
|
|
||||||
* @param data data to be distributed
|
|
||||||
*/
|
|
||||||
public void distributeScripts(byte[] data);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Finds the item definition with the given ID.
|
|
||||||
*
|
|
||||||
* @param id item ID
|
|
||||||
* @return resulting item definition
|
|
||||||
*/
|
|
||||||
public IItemDefinition getItemDefinition(int id);
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
package minetweaker;
|
|
||||||
|
|
||||||
import minetweaker.api.item.IIngredient;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Used to register removable mod recipes for mod machines. Once registered, it
|
|
||||||
* will be called when minetweaker.remove() is called.
|
|
||||||
*
|
|
||||||
* @author Stan Hebben
|
|
||||||
*/
|
|
||||||
public interface IRecipeRemover {
|
|
||||||
/**
|
|
||||||
* Removes all the items matching the given ingredient.
|
|
||||||
*
|
|
||||||
* @param ingredient ingredient
|
|
||||||
*/
|
|
||||||
public void remove(IIngredient ingredient);
|
|
||||||
}
|
|
||||||
@@ -1,84 +0,0 @@
|
|||||||
package minetweaker;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Defines a (possibly) undoable action.
|
|
||||||
*
|
|
||||||
* Every modification made by a command must be registered to the Tweaker with
|
|
||||||
* the Tweaker.apply method. This enables MineTweaker to keep track of actions
|
|
||||||
* 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
|
|
||||||
* canUndo(), the action is undoable, otherwise it is permanent. Permanent
|
|
||||||
* actions cannot be used in server scripts.
|
|
||||||
*
|
|
||||||
* There also exist semi-permanent actions. Those actions can return an override
|
|
||||||
* key; if a newer action has the same override key as an old action, the new
|
|
||||||
* action is considered to override the old one.
|
|
||||||
*
|
|
||||||
* Likewise, actions can implement hashCode and equals methods to indicate that
|
|
||||||
* they are equal. If an action is equal to a non-undoable stuck action, it will
|
|
||||||
* be omitted from execution.
|
|
||||||
*
|
|
||||||
* @author Stan Hebben
|
|
||||||
*/
|
|
||||||
public interface IUndoableAction {
|
|
||||||
/**
|
|
||||||
* Executes what the action is supposed to do. This method can be called
|
|
||||||
* again if undo() has been called in between.
|
|
||||||
*/
|
|
||||||
public void apply();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks if this action can be undone. If this method returns true, it must
|
|
||||||
* implement undo() properly. If this method returns false, the action is
|
|
||||||
* considered permanent, undo() will never be called, and the action cannot
|
|
||||||
* be executed as part of a server script. Additionally, the
|
|
||||||
* minetweaker.clear() function will not work and minetweaker.canClear will
|
|
||||||
* return false.
|
|
||||||
*
|
|
||||||
* @return undoable status
|
|
||||||
*/
|
|
||||||
public boolean canUndo();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Undoes the action. Will only be called after apply() has been executed.
|
|
||||||
* After an undo, apply may be called again. They could be done multiple
|
|
||||||
* times in certain scenarios.
|
|
||||||
*/
|
|
||||||
public void undo();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Describes, in a single human-readable sentence, what this specific action
|
|
||||||
* is doing. Used in logging messages, lists, ...
|
|
||||||
*
|
|
||||||
* Try to be as descriptive as possible without being too verbose.
|
|
||||||
*
|
|
||||||
* Examples: - Adding Peach planks to the woodPlanks ore dictionary entry -
|
|
||||||
* Removing a recipe for Iron Ore
|
|
||||||
*
|
|
||||||
* @return the description of this action
|
|
||||||
*/
|
|
||||||
public String describe();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Describes what this action does if it is undone. Similar to the
|
|
||||||
* describe() method. No implementation is needed if the action cannot be
|
|
||||||
* undone.
|
|
||||||
*
|
|
||||||
* @return the description of this action, when undone
|
|
||||||
*/
|
|
||||||
public String describeUndo();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the override key. Two actions are considered to override each
|
|
||||||
* other if their override key is equal. You can return null to indicate
|
|
||||||
* that an action can never be overridden.
|
|
||||||
*
|
|
||||||
* This value only makes sense for recipes that are not undoable. For
|
|
||||||
* undoable recipes, you should return null.
|
|
||||||
*
|
|
||||||
* @return override key (null for actions that are undoable or which can
|
|
||||||
* never be overridden by another action)
|
|
||||||
*/
|
|
||||||
public Object getOverrideKey();
|
|
||||||
}
|
|
||||||
@@ -1,453 +0,0 @@
|
|||||||
package minetweaker;
|
|
||||||
|
|
||||||
import minetweaker.annotations.BracketHandler;
|
|
||||||
import minetweaker.annotations.ModOnly;
|
|
||||||
import minetweaker.api.client.IClient;
|
|
||||||
import minetweaker.api.compat.*;
|
|
||||||
import minetweaker.api.event.IEventManager;
|
|
||||||
import minetweaker.api.formatting.IFormatter;
|
|
||||||
import minetweaker.api.game.IGame;
|
|
||||||
import minetweaker.api.mods.ILoadedMods;
|
|
||||||
import minetweaker.api.oredict.IOreDict;
|
|
||||||
import minetweaker.api.recipes.IFurnaceManager;
|
|
||||||
import minetweaker.api.recipes.IRecipeManager;
|
|
||||||
import minetweaker.api.server.IServer;
|
|
||||||
import minetweaker.api.vanilla.IVanilla;
|
|
||||||
import minetweaker.runtime.GlobalRegistry;
|
|
||||||
import minetweaker.runtime.ILogger;
|
|
||||||
import minetweaker.runtime.ITweaker;
|
|
||||||
import minetweaker.runtime.MTTweaker;
|
|
||||||
import stanhebben.zenscript.annotations.ZenClass;
|
|
||||||
import stanhebben.zenscript.annotations.ZenExpansion;
|
|
||||||
import stanhebben.zenscript.symbols.IZenSymbol;
|
|
||||||
import stanhebben.zenscript.symbols.SymbolJavaStaticField;
|
|
||||||
import stanhebben.zenscript.symbols.SymbolJavaStaticGetter;
|
|
||||||
import stanhebben.zenscript.symbols.SymbolJavaStaticMethod;
|
|
||||||
import stanhebben.zenscript.type.natives.IJavaMethod;
|
|
||||||
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.
|
|
||||||
*
|
|
||||||
* An implementing platform needs to do the following: - Set a logger - Set the
|
|
||||||
* ore dictionary - Set the recipe manager - Set the furnace manager - Set event
|
|
||||||
* manager - Set resource manager
|
|
||||||
*
|
|
||||||
* - Register additional global symbols to the GlobalRegistry (recipes,
|
|
||||||
* minetweaker, oreDict, logger, as well as the official set of functions) -
|
|
||||||
* Register native classes using the GlobalRegistry - Register bracket handlers
|
|
||||||
* to resolve block/item/... references using the bracket syntax
|
|
||||||
*
|
|
||||||
* @author Stan Hebben
|
|
||||||
*/
|
|
||||||
public class MineTweakerAPI {
|
|
||||||
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();
|
|
||||||
|
|
||||||
static {
|
|
||||||
registerClassRegistry(ClassRegistry.class, "MT-API");
|
|
||||||
|
|
||||||
registerGlobalSymbol("logger", getJavaStaticGetterSymbol(MineTweakerAPI.class, "getLogger"));
|
|
||||||
registerGlobalSymbol("recipes", getJavaStaticFieldSymbol(MineTweakerAPI.class, "recipes"));
|
|
||||||
// registerGlobalSymbol("brewing", getJavaStaticFieldSymbol(MineTweakerAPI.class, "brewing"));
|
|
||||||
registerGlobalSymbol("furnace", getJavaStaticFieldSymbol(MineTweakerAPI.class, "furnace"));
|
|
||||||
registerGlobalSymbol("oreDict", getJavaStaticFieldSymbol(MineTweakerAPI.class, "oreDict"));
|
|
||||||
registerGlobalSymbol("events", getJavaStaticFieldSymbol(MineTweakerAPI.class, "events"));
|
|
||||||
registerGlobalSymbol("server", getJavaStaticFieldSymbol(MineTweakerAPI.class, "server"));
|
|
||||||
registerGlobalSymbol("client", getJavaStaticFieldSymbol(MineTweakerAPI.class, "client"));
|
|
||||||
registerGlobalSymbol("game", getJavaStaticFieldSymbol(MineTweakerAPI.class, "game"));
|
|
||||||
registerGlobalSymbol("loadedMods", getJavaStaticFieldSymbol(MineTweakerAPI.class, "loadedMods"));
|
|
||||||
registerGlobalSymbol("format", getJavaStaticFieldSymbol(MineTweakerAPI.class, "format"));
|
|
||||||
registerGlobalSymbol("vanilla", getJavaStaticFieldSymbol(MineTweakerAPI.class, "vanilla"));
|
|
||||||
}
|
|
||||||
|
|
||||||
private MineTweakerAPI() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The Tweaker is where you apply undoable actions. Any kind of action that
|
|
||||||
* reloads with the scripts should always be submitted to the tweaker.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public static final ITweaker tweaker = new MTTweaker();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The logger can be used to write logging messages to the client. Error and
|
|
||||||
* warning messages should be relayed to admins for further handling.
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static final ILogger getLogger() {
|
|
||||||
return MineTweakerImplementationAPI.logger;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Access point to the ore dictionary.
|
|
||||||
*/
|
|
||||||
public static IOreDict oreDict = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Access point to the recipe manager.
|
|
||||||
*/
|
|
||||||
public static IRecipeManager recipes = null;
|
|
||||||
|
|
||||||
// /**
|
|
||||||
// * Access point to the brewing manager.
|
|
||||||
// */
|
|
||||||
// public static IBrewingManager brewing = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Access point to the furnace manager.
|
|
||||||
*/
|
|
||||||
public static IFurnaceManager furnace = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Access point to the events manager.
|
|
||||||
*/
|
|
||||||
public static final IEventManager events = MineTweakerImplementationAPI.events;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Access point to the server, if any.
|
|
||||||
*/
|
|
||||||
public static IServer server = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Access point to the client, if any.
|
|
||||||
*/
|
|
||||||
public static IClient client = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Access point to general game data, such as items.
|
|
||||||
*/
|
|
||||||
public static IGame game = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Access point to mods list.
|
|
||||||
*/
|
|
||||||
public static ILoadedMods loadedMods = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Access point to the text formatter.
|
|
||||||
*/
|
|
||||||
public static IFormatter format = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Access point to the vanilla functions and data.
|
|
||||||
*/
|
|
||||||
public static IVanilla vanilla = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Applies this given action.
|
|
||||||
*
|
|
||||||
* @param action action object
|
|
||||||
*/
|
|
||||||
public static void apply(IUndoableAction action) {
|
|
||||||
tweaker.apply(action);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Logs a command message. Commands messages are those generated as output
|
|
||||||
* in response to a command.
|
|
||||||
*
|
|
||||||
* @param message command message
|
|
||||||
*/
|
|
||||||
public static void logCommand(String message) {
|
|
||||||
getLogger().logCommand(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Logs an info message. Info messages have low priority and will only be
|
|
||||||
* displayed in the log files, but not directly to players in-game.
|
|
||||||
*
|
|
||||||
* @param message info message
|
|
||||||
*/
|
|
||||||
public static void logInfo(String message) {
|
|
||||||
getLogger().logInfo(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Logs a warning message. Warning messages are displayed to admins and
|
|
||||||
* indicate that there is an issue. However, the issue is not a large
|
|
||||||
* problem, and everything should run fine - besides perhaps a few things
|
|
||||||
* not entirely working as expected.
|
|
||||||
*
|
|
||||||
* @param message warning message
|
|
||||||
*/
|
|
||||||
public static void logWarning(String message) {
|
|
||||||
getLogger().logWarning(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Logs an error message. Error messages indicate a real problem and
|
|
||||||
* indicate that things won't run properly. The scripting system will still
|
|
||||||
* make a best-effort attempt at executing the rest of the scripts, but that
|
|
||||||
* might cause additional errors and issues.
|
|
||||||
*
|
|
||||||
* @param message error message
|
|
||||||
*/
|
|
||||||
public static void logError(String message) {
|
|
||||||
getLogger().logError(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Logs an error message. Error messages indicate a real problem and
|
|
||||||
* indicate that things won't run properly. The scripting system will still
|
|
||||||
* make a best-effort attempt at executing the rest of the scripts, but that
|
|
||||||
* might cause additional errors and issues.
|
|
||||||
*
|
|
||||||
* @param message error message
|
|
||||||
* @param exception exception that was caught related to the error
|
|
||||||
*/
|
|
||||||
public static void logError(String message, Throwable exception) {
|
|
||||||
getLogger().logError(message, exception);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ###################################
|
|
||||||
// ### Plugin registration methods ###
|
|
||||||
// ###################################
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Register a class registry class. Such class must have (at least) a public
|
|
||||||
* static method called "getClasses" with accepts a List of classes and
|
|
||||||
* which stores its classes into that list.
|
|
||||||
*
|
|
||||||
* @param registryClass
|
|
||||||
*/
|
|
||||||
public static void registerClassRegistry(Class registryClass) {
|
|
||||||
registerClassRegistry(registryClass, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Register a class registry class. Such class must have (at least) a public
|
|
||||||
* static method called "getClasses" with accepts a List of classes and
|
|
||||||
* which stores its classes into that list.
|
|
||||||
*
|
|
||||||
* @param registryClass
|
|
||||||
* @param description
|
|
||||||
*/
|
|
||||||
public static void registerClassRegistry(Class registryClass, String description) {
|
|
||||||
try {
|
|
||||||
Method method = registryClass.getMethod("getClasses", List.class);
|
|
||||||
if ((method.getModifiers() & Modifier.STATIC) == 0) {
|
|
||||||
logError("ERROR: getClasses method in " + registryClass.getName() + " isn't static");
|
|
||||||
} else {
|
|
||||||
List<Class> classes = new ArrayList<Class>();
|
|
||||||
method.invoke(null, classes);
|
|
||||||
|
|
||||||
outer: for (Class cls : classes) {
|
|
||||||
for (Annotation annotation : cls.getAnnotations()) {
|
|
||||||
if (annotation instanceof ModOnly) {
|
|
||||||
String[] value = ((ModOnly) annotation).value();
|
|
||||||
String version = ((ModOnly) annotation).version();
|
|
||||||
|
|
||||||
for (String mod : value) {
|
|
||||||
if (!loadedMods.contains(mod))
|
|
||||||
continue outer;
|
|
||||||
|
|
||||||
if (!loadedMods.get(mod).getVersion().startsWith(version))
|
|
||||||
continue outer;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
MineTweakerAPI.registerClass(cls);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (description != null)
|
|
||||||
logInfo("Loaded class registry: " + description);
|
|
||||||
}
|
|
||||||
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
|
|
||||||
if(ex.getCause() instanceof NoClassDefFoundError) {
|
|
||||||
logInfo("Classes for registry " + registryClass + " not found, skipping");
|
|
||||||
} else {
|
|
||||||
logError("Error registering class registry", ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Registers a class registry. Will attempt to resolve the given class name.
|
|
||||||
* Does nothing if the class could not be loaded.
|
|
||||||
*
|
|
||||||
* @param className class name to be loaded
|
|
||||||
* @return true if registration was successful
|
|
||||||
*/
|
|
||||||
public static boolean registerClassRegistry(String className) {
|
|
||||||
return registerClassRegistry(className, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Registers a class registry. Will attempt to resolve the given class name.
|
|
||||||
* Does nothing if the class could not be loaded.
|
|
||||||
*
|
|
||||||
* @param className class name to be loaded
|
|
||||||
* @param description
|
|
||||||
* @return true if registration was successful
|
|
||||||
*/
|
|
||||||
public static boolean registerClassRegistry(String className, String description) {
|
|
||||||
try {
|
|
||||||
registerClassRegistry(Class.forName(className), description);
|
|
||||||
return true;
|
|
||||||
} catch (ClassNotFoundException ex) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Registers an annotated class. A class is annotated with either @ZenClass
|
|
||||||
* or @ZenExpansion. Classes not annotated with either of these will be
|
|
||||||
* ignored.
|
|
||||||
*
|
|
||||||
* @param annotatedClass
|
|
||||||
*/
|
|
||||||
public static void registerClass(Class annotatedClass) {
|
|
||||||
// System.out.println("Registering " + annotatedClass.getName());
|
|
||||||
|
|
||||||
for (Annotation annotation : annotatedClass.getAnnotations()) {
|
|
||||||
if (annotation instanceof ZenExpansion) {
|
|
||||||
GlobalRegistry.registerExpansion(annotatedClass);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (annotation instanceof ZenClass) {
|
|
||||||
GlobalRegistry.registerNativeClass(annotatedClass);
|
|
||||||
}
|
|
||||||
if ((annotation instanceof BracketHandler) && IBracketHandler.class.isAssignableFrom(annotatedClass)) {
|
|
||||||
try {
|
|
||||||
IBracketHandler bracketHandler = (IBracketHandler) annotatedClass.newInstance();
|
|
||||||
registerBracketHandler(bracketHandler);
|
|
||||||
} catch (InstantiationException ex) {
|
|
||||||
Logger.getLogger(MineTweakerAPI.class.getName()).log(Level.SEVERE, null, ex);
|
|
||||||
} catch (IllegalAccessException ex) {
|
|
||||||
Logger.getLogger(MineTweakerAPI.class.getName()).log(Level.SEVERE, null, ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Registers a global symbol. Global symbols are immediately accessible from
|
|
||||||
* anywhere in the scripts.
|
|
||||||
*
|
|
||||||
* @param name symbol name
|
|
||||||
* @param symbol symbol
|
|
||||||
*/
|
|
||||||
public static void registerGlobalSymbol(String name, IZenSymbol symbol) {
|
|
||||||
GlobalRegistry.registerGlobal(name, symbol);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Registers a recipe remover. Removers are called when the global
|
|
||||||
* minetweaker.remove() function is called.
|
|
||||||
*
|
|
||||||
* @param remover recipe remover
|
|
||||||
*/
|
|
||||||
public static void registerRemover(IRecipeRemover remover) {
|
|
||||||
GlobalRegistry.registerRemover(remover);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Registers a bracket handler. Is capable of converting the bracket syntax
|
|
||||||
* to an actual value. This new handler will be added last - it can thus not
|
|
||||||
* intercept values that are already handled by the system.
|
|
||||||
*
|
|
||||||
* @param handler bracket handler to be added
|
|
||||||
*/
|
|
||||||
public static void registerBracketHandler(IBracketHandler handler) {
|
|
||||||
GlobalRegistry.registerBracketHandler(handler);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a symbol that refers to a java method.
|
|
||||||
*
|
|
||||||
* @param cls class that contains the method
|
|
||||||
* @param name method name
|
|
||||||
* @param arguments method argument types
|
|
||||||
* @return corresponding symbol
|
|
||||||
*/
|
|
||||||
public static IZenSymbol getJavaStaticMethodSymbol(Class cls, String name, Class... arguments) {
|
|
||||||
IJavaMethod method = JavaMethod.get(GlobalRegistry.getTypeRegistry(), cls, name, arguments);
|
|
||||||
return new SymbolJavaStaticMethod(method);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a symbol that refers to a java getter. The getter must be a
|
|
||||||
* method with no arguments. The given symbol will act as a variable of
|
|
||||||
* which the value can be retrieved but not set.
|
|
||||||
*
|
|
||||||
* @param cls class that contains the getter method
|
|
||||||
* @param name name of the method
|
|
||||||
* @return corresponding symbol
|
|
||||||
*/
|
|
||||||
public static IZenSymbol getJavaStaticGetterSymbol(Class cls, String name) {
|
|
||||||
IJavaMethod method = JavaMethod.get(GlobalRegistry.getTypeRegistry(), cls, name);
|
|
||||||
return new SymbolJavaStaticGetter(method);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a symbol that refers to a static field. The field must be an
|
|
||||||
* existing public field in the given class. The field will act as a
|
|
||||||
* variable that can be retrieved but not set.
|
|
||||||
*
|
|
||||||
* @param cls class that contains the field
|
|
||||||
* @param name field name (must be public)
|
|
||||||
* @return corresponding symbol
|
|
||||||
*/
|
|
||||||
public static IZenSymbol getJavaStaticFieldSymbol(Class cls, String name) {
|
|
||||||
try {
|
|
||||||
Field field = cls.getField(name);
|
|
||||||
return new SymbolJavaStaticField(cls, field, GlobalRegistry.getTypeRegistry());
|
|
||||||
} catch (NoSuchFieldException ex) {
|
|
||||||
return null;
|
|
||||||
} catch (SecurityException ex) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Loads a Java method from an existing class.
|
|
||||||
*
|
|
||||||
* @param cls method class
|
|
||||||
* @param name method name
|
|
||||||
* @param arguments argument types
|
|
||||||
* @return java method
|
|
||||||
*/
|
|
||||||
public static IJavaMethod getJavaMethod(Class cls, String name, Class... arguments) {
|
|
||||||
return JavaMethod.get(GlobalRegistry.getTypeRegistry(), cls, name, arguments);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IJEIRecipeRegistry getIjeiRecipeRegistry() {
|
|
||||||
return ijeiRecipeRegistry;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setIjeiRecipeRegistry(IJEIRecipeRegistry ijeiRecipeRegistry) {
|
|
||||||
MineTweakerAPI.ijeiRecipeRegistry = ijeiRecipeRegistry;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,831 +0,0 @@
|
|||||||
package minetweaker;
|
|
||||||
|
|
||||||
import minetweaker.api.block.IBlock;
|
|
||||||
import minetweaker.api.block.IBlockDefinition;
|
|
||||||
import minetweaker.api.data.IData;
|
|
||||||
import minetweaker.api.entity.IEntityDefinition;
|
|
||||||
import minetweaker.api.event.*;
|
|
||||||
import minetweaker.api.formatting.IFormatter;
|
|
||||||
import minetweaker.api.game.IGame;
|
|
||||||
import minetweaker.api.item.IItemDefinition;
|
|
||||||
import minetweaker.api.item.IItemStack;
|
|
||||||
import minetweaker.api.item.WeightedItemStack;
|
|
||||||
import minetweaker.api.liquid.ILiquidDefinition;
|
|
||||||
import minetweaker.api.logger.MTLogger;
|
|
||||||
import minetweaker.api.mods.ILoadedMods;
|
|
||||||
import minetweaker.api.mods.IMod;
|
|
||||||
import minetweaker.api.oredict.IOreDict;
|
|
||||||
import minetweaker.api.oredict.IOreDictEntry;
|
|
||||||
import minetweaker.api.player.IPlayer;
|
|
||||||
import minetweaker.api.recipes.*;
|
|
||||||
import minetweaker.api.server.ICommandFunction;
|
|
||||||
import minetweaker.api.server.ICommandValidator;
|
|
||||||
import minetweaker.api.server.IServer;
|
|
||||||
import minetweaker.api.vanilla.IVanilla;
|
|
||||||
import minetweaker.api.vanilla.LootEntry;
|
|
||||||
import minetweaker.api.world.IBiome;
|
|
||||||
import minetweaker.runtime.IScriptProvider;
|
|
||||||
import minetweaker.util.EventList;
|
|
||||||
import minetweaker.util.IEventHandler;
|
|
||||||
import sun.awt.HeadlessToolkit;
|
|
||||||
|
|
||||||
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
|
|
||||||
* communication and initialization.
|
|
||||||
*
|
|
||||||
* @author Stan Hebben
|
|
||||||
*/
|
|
||||||
public class MineTweakerImplementationAPI {
|
|
||||||
private static Set<IPlayer> blockInfoPlayers = new HashSet<IPlayer>();
|
|
||||||
private static IEventHandle blockEventHandler = null;
|
|
||||||
|
|
||||||
private static final Map<String, MineTweakerCommand> minetweakerCommands;
|
|
||||||
|
|
||||||
private static final Comparator<IItemDefinition> ITEM_COMPARATOR = new ItemComparator();
|
|
||||||
private static final Comparator<ILiquidDefinition> LIQUID_COMPARATOR = new LiquidComparator();
|
|
||||||
private static final Comparator<IBlockDefinition> BLOCK_COMPARATOR = new BlockComparator();
|
|
||||||
private static final Comparator<IEntityDefinition> ENTITY_COMPARATOR = new EntityComparator();
|
|
||||||
|
|
||||||
private static final ListenPlayerLoggedIn LISTEN_LOGIN = new ListenPlayerLoggedIn();
|
|
||||||
private static final ListenPlayerLoggedOut LISTEN_LOGOUT = new ListenPlayerLoggedOut();
|
|
||||||
private static final ListenBlockInfo LISTEN_BLOCK_INFO = new ListenBlockInfo();
|
|
||||||
private static final EventList<ReloadEvent> ONROLLBACK = new EventList<>();
|
|
||||||
private static final EventList<ReloadEvent> ONRELOAD = new EventList<>();
|
|
||||||
private static final EventList<ReloadEvent> ONPOSTRELOAD = new EventList<>();
|
|
||||||
|
|
||||||
static {
|
|
||||||
minetweakerCommands = new HashMap<String, MineTweakerCommand>();
|
|
||||||
|
|
||||||
minetweakerCommands.put("reload", new MineTweakerCommand(
|
|
||||||
"reload",
|
|
||||||
new String[]{
|
|
||||||
"/minetweaker reload",
|
|
||||||
" Reloads all scripts"
|
|
||||||
}, new ICommandFunction() {
|
|
||||||
@Override
|
|
||||||
public void execute(String[] arguments, IPlayer player) {
|
|
||||||
reload();
|
|
||||||
player.sendChat("Scripts reloaded");
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
|
|
||||||
minetweakerCommands.put("names", new MineTweakerCommand(
|
|
||||||
"names",
|
|
||||||
new String[]{
|
|
||||||
"/minetweaker names",
|
|
||||||
" Outputs a list of all item names in the game to the minetweaker log"
|
|
||||||
}, new ICommandFunction() {
|
|
||||||
@Override
|
|
||||||
public void execute(String[] arguments, IPlayer player) {
|
|
||||||
List<IItemDefinition> items = MineTweakerAPI.game.getItems();
|
|
||||||
Collections.sort(items, ITEM_COMPARATOR);
|
|
||||||
for (IItemDefinition item : items) {
|
|
||||||
String displayName;
|
|
||||||
|
|
||||||
try {
|
|
||||||
displayName = ", " + item.makeStack(0).getDisplayName();
|
|
||||||
} catch (Throwable ex) {
|
|
||||||
// some mods (such as buildcraft) may throw
|
|
||||||
// exceptions when calling
|
|
||||||
// getDisplayName on an item stack that doesn't
|
|
||||||
// contain valid NBT data
|
|
||||||
// also seems to cause errors in some other
|
|
||||||
// cases too
|
|
||||||
displayName = " -- Name could not be retrieved due to an error: " + ex;
|
|
||||||
}
|
|
||||||
|
|
||||||
MineTweakerAPI.logCommand("<" + item.getId() + ">" + displayName);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (player != null) {
|
|
||||||
player.sendChat("List generated; see minetweaker.log in your minecraft dir");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
|
|
||||||
minetweakerCommands.put("liquids", new MineTweakerCommand(
|
|
||||||
"liquids",
|
|
||||||
new String[]{
|
|
||||||
"/minetweaker liquids",
|
|
||||||
" Outputs a list of all liquid names in the game to the minetweaker log"
|
|
||||||
}, new ICommandFunction() {
|
|
||||||
@Override
|
|
||||||
public void execute(String[] arguments, IPlayer player) {
|
|
||||||
List<ILiquidDefinition> liquids = MineTweakerAPI.game.getLiquids();
|
|
||||||
Collections.sort(liquids, LIQUID_COMPARATOR);
|
|
||||||
|
|
||||||
MineTweakerAPI.logCommand("Liquids:");
|
|
||||||
for (ILiquidDefinition liquid : liquids) {
|
|
||||||
MineTweakerAPI.logCommand("<liquid:" + liquid.getName() + ">, " + liquid.getDisplayName());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (player != null) {
|
|
||||||
player.sendChat("List generated; see minetweaker.log in your minecraft dir");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
|
|
||||||
minetweakerCommands.put("blocks", new MineTweakerCommand(
|
|
||||||
"blocks",
|
|
||||||
new String[]{
|
|
||||||
"/minetweaker blocks",
|
|
||||||
" Outputs a list of all blocks in the game to the minetweaker log"
|
|
||||||
}, new ICommandFunction() {
|
|
||||||
@Override
|
|
||||||
public void execute(String[] arguments, IPlayer player) {
|
|
||||||
List<IBlockDefinition> blocks = MineTweakerAPI.game.getBlocks();
|
|
||||||
Collections.sort(blocks, BLOCK_COMPARATOR);
|
|
||||||
|
|
||||||
MineTweakerAPI.logCommand("Blocks:");
|
|
||||||
for (IBlockDefinition block : blocks) {
|
|
||||||
MineTweakerAPI.logCommand("<block:" + block.getId() + ">, " + block.getDisplayName());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (player != null) {
|
|
||||||
player.sendChat("List generated; see minetweaker.log in your minecraft dir");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
|
|
||||||
minetweakerCommands.put("entities", new MineTweakerCommand(
|
|
||||||
"entities",
|
|
||||||
new String[]{
|
|
||||||
"/minetweaker entities",
|
|
||||||
" Outputs a list of all entity definitions in the game to the minetweaker log"
|
|
||||||
}, new ICommandFunction() {
|
|
||||||
@Override
|
|
||||||
public void execute(String[] arguments, IPlayer player) {
|
|
||||||
List<IEntityDefinition> entities = MineTweakerAPI.game.getEntities();
|
|
||||||
Collections.sort(entities, ENTITY_COMPARATOR);
|
|
||||||
|
|
||||||
MineTweakerAPI.logCommand("Entities:");
|
|
||||||
for (IEntityDefinition entity : entities) {
|
|
||||||
MineTweakerAPI.logCommand(entity.getId() + " -- " + entity.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (player != null) {
|
|
||||||
player.sendChat("List generated; see minetweaker.log in your minecraft dir");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
|
|
||||||
minetweakerCommands.put("recipes", new MineTweakerCommand(
|
|
||||||
"recipes",
|
|
||||||
new String[]{
|
|
||||||
"/minetweaker recipes",
|
|
||||||
" Lists all crafting recipes in the game",
|
|
||||||
"/minetweaker recipes hand",
|
|
||||||
" Lists all crafting recipes for the item in your hand",
|
|
||||||
" Also copies the recipes to clipboard",
|
|
||||||
"/minetweaker recipes furnace",
|
|
||||||
" lists all furnace recipes in the game"
|
|
||||||
}, new ICommandFunction() {
|
|
||||||
@Override
|
|
||||||
public void execute(String[] arguments, IPlayer player) {
|
|
||||||
if (arguments.length == 0) {
|
|
||||||
if (player != null) {
|
|
||||||
player.sendChat("Generating recipe list, this could take a while...");
|
|
||||||
}
|
|
||||||
|
|
||||||
MineTweakerAPI.logCommand("Recipes:");
|
|
||||||
for (ICraftingRecipe recipe : MineTweakerAPI.recipes.getAll()) {
|
|
||||||
try {
|
|
||||||
MineTweakerAPI.logCommand(recipe.toCommandString());
|
|
||||||
} catch (Throwable ex) {
|
|
||||||
// Some recipes can result in an NPE :-(
|
|
||||||
if (recipe instanceof ShapedRecipe) {
|
|
||||||
ShapedRecipe shaped = (ShapedRecipe) recipe;
|
|
||||||
IItemStack out = shaped.getOutput();
|
|
||||||
MineTweakerAPI.logError("Could not dump recipe for " + out, ex);
|
|
||||||
} else if (recipe instanceof ShapelessRecipe) {
|
|
||||||
ShapelessRecipe shapeless = (ShapelessRecipe) recipe;
|
|
||||||
IItemStack out = shapeless.getOutput();
|
|
||||||
MineTweakerAPI.logError("Could not dump recipe for " + out, ex);
|
|
||||||
} else {
|
|
||||||
MineTweakerAPI.logError("Could not dump recipe", ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (player != null) {
|
|
||||||
player.sendChat("Recipe list generated; see minetweaker.log in your minecraft dir");
|
|
||||||
}
|
|
||||||
} else if (arguments[0].equals("hand") && player != null) {
|
|
||||||
IItemStack item = player.getCurrentItem();
|
|
||||||
if (item != null) {
|
|
||||||
List<ICraftingRecipe> recipes = MineTweakerAPI.recipes.getRecipesFor(item.anyAmount());
|
|
||||||
if (recipes.isEmpty()) {
|
|
||||||
player.sendChat("No crafting recipes found for that item");
|
|
||||||
} else {
|
|
||||||
StringBuilder recipesString = new StringBuilder();
|
|
||||||
|
|
||||||
for (ICraftingRecipe recipe : recipes) {
|
|
||||||
MineTweakerAPI.logCommand(recipe.toCommandString());
|
|
||||||
player.sendChat(recipe.toCommandString());
|
|
||||||
recipesString.append(recipe.toCommandString()).append("\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
copyToClipboard(recipesString.toString());
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
player.sendChat("No item was found");
|
|
||||||
}
|
|
||||||
} else if (arguments[0].equals("furnace") && player != null) {
|
|
||||||
if (player != null) {
|
|
||||||
player.sendChat("Generating furnace list, this could take a while...");
|
|
||||||
}
|
|
||||||
|
|
||||||
MineTweakerAPI.logCommand("Furnace Recipes:");
|
|
||||||
for (IFurnaceRecipe recipe : furnace.getAll()) {
|
|
||||||
try {
|
|
||||||
MineTweakerAPI.logCommand(recipe.toCommandString());
|
|
||||||
} catch (Throwable ex) {
|
|
||||||
MineTweakerAPI.logError("Could not dump furnace recipe", ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (player != null) {
|
|
||||||
player.sendChat("Furnace Recipe list generated; see minetweaker.log in your minecraft dir");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (player != null) {
|
|
||||||
player.sendChat("Invalid arguments for recipes command");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
|
|
||||||
minetweakerCommands.put("inventory", new MineTweakerCommand(
|
|
||||||
"inventory",
|
|
||||||
new String[]{
|
|
||||||
"/minetweaker inventory",
|
|
||||||
" Lists all items in your inventory"
|
|
||||||
}, new ICommandFunction() {
|
|
||||||
@Override
|
|
||||||
public void execute(String[] arguments, IPlayer player) {
|
|
||||||
for (int i = 0; i < player.getInventorySize(); i++) {
|
|
||||||
IItemStack stack = player.getInventoryStack(i);
|
|
||||||
if (stack != null) {
|
|
||||||
player.sendChat(stack.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
|
|
||||||
minetweakerCommands.put("hand", new MineTweakerCommand(
|
|
||||||
"hand",
|
|
||||||
new String[]{
|
|
||||||
"/minetweaker hand",
|
|
||||||
" Outputs the name of the item in your hand",
|
|
||||||
" Also copies the name to clipboard and prints",
|
|
||||||
" oredict entries"
|
|
||||||
}, new ICommandFunction() {
|
|
||||||
@Override
|
|
||||||
public void execute(String[] arguments, IPlayer player) {
|
|
||||||
IItemStack hand = player.getCurrentItem();
|
|
||||||
if (hand != null) {
|
|
||||||
String value = hand.toString();
|
|
||||||
player.sendChat(value);
|
|
||||||
copyToClipboard(value);
|
|
||||||
|
|
||||||
List<IOreDictEntry> entries = hand.getOres();
|
|
||||||
for (IOreDictEntry entry : entries) {
|
|
||||||
player.sendChat("Is in <ore:" + entry.getName() + ">");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
|
|
||||||
minetweakerCommands.put("oredict", new MineTweakerCommand(
|
|
||||||
"oredict",
|
|
||||||
new String[]{
|
|
||||||
"/minetweaker oredict",
|
|
||||||
" Outputs all ore dictionary entries in the game to the minetweaker log",
|
|
||||||
"/minetweaker oredict <name>",
|
|
||||||
" Outputs all items in the given ore dictionary entry to the minetweaker log"
|
|
||||||
}, new ICommandFunction() {
|
|
||||||
@Override
|
|
||||||
public void execute(String[] arguments, IPlayer player) {
|
|
||||||
if (arguments.length > 0) {
|
|
||||||
String entryName = arguments[0];
|
|
||||||
IOreDictEntry entry = MineTweakerAPI.oreDict.get(entryName);
|
|
||||||
if (entry.isEmpty()) {
|
|
||||||
player.sendChat("Entry doesn't exist");
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
MineTweakerAPI.logCommand("Ore entries for " + entryName + ":");
|
|
||||||
for (IItemStack ore : entry.getItems()) {
|
|
||||||
MineTweakerAPI.logCommand(" " + ore);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for (IOreDictEntry entry : MineTweakerAPI.oreDict.getEntries()) {
|
|
||||||
if (!entry.isEmpty()) {
|
|
||||||
MineTweakerAPI.logCommand("Ore entries for <ore:" + entry.getName() + "> :");
|
|
||||||
for (IItemStack ore : entry.getItems()) {
|
|
||||||
MineTweakerAPI.logCommand(" " + ore);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
player.sendChat("List generated; see minetweaker.log in your minecraft dir");
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
|
|
||||||
minetweakerCommands.put("mods", new MineTweakerCommand(
|
|
||||||
"mods",
|
|
||||||
new String[]{
|
|
||||||
"/minetweaker mods",
|
|
||||||
" Outputs all active mod IDs and versions in the game"
|
|
||||||
}, new ICommandFunction() {
|
|
||||||
@Override
|
|
||||||
public void execute(String[] arguments, IPlayer player) {
|
|
||||||
MineTweakerAPI.logCommand("Mods list:");
|
|
||||||
for (IMod mod : MineTweakerAPI.loadedMods) {
|
|
||||||
String message = mod.getId() + " - " + mod.getName() + " - " + mod.getVersion();
|
|
||||||
player.sendChat(message);
|
|
||||||
MineTweakerAPI.logCommand("Mod: " + message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
|
|
||||||
minetweakerCommands.put("name", new MineTweakerCommand(
|
|
||||||
"name",
|
|
||||||
new String[]{
|
|
||||||
"/minetweaker name <id>",
|
|
||||||
" Outputs the name for the given item ID",
|
|
||||||
},
|
|
||||||
new ICommandFunction() {
|
|
||||||
@Override
|
|
||||||
public void execute(String[] arguments, IPlayer player) {
|
|
||||||
if (arguments.length < 1) {
|
|
||||||
player.sendChat("missing id parameter");
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
int id = Integer.parseInt(arguments[0]);
|
|
||||||
IItemDefinition definition = platform.getItemDefinition(id);
|
|
||||||
if (definition == null) {
|
|
||||||
player.sendChat("no such item");
|
|
||||||
} else {
|
|
||||||
StringBuilder description = new StringBuilder();
|
|
||||||
description.append('<');
|
|
||||||
description.append(definition.getId());
|
|
||||||
description.append('>');
|
|
||||||
player.sendChat(description.toString());
|
|
||||||
}
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
MineTweakerAPI.logCommand("ID must be an integer");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
|
|
||||||
minetweakerCommands.put("seeds", new MineTweakerCommand(
|
|
||||||
"seeds",
|
|
||||||
new String[]{
|
|
||||||
"/minetweaker seeds",
|
|
||||||
" Prints all seeds registered",
|
|
||||||
" for tall grass"
|
|
||||||
}, new ICommandFunction() {
|
|
||||||
@Override
|
|
||||||
public void execute(String[] arguments, IPlayer player) {
|
|
||||||
MineTweakerAPI.logCommand("Seeds:");
|
|
||||||
for (WeightedItemStack seed : MineTweakerAPI.vanilla.getSeeds().getSeeds()) {
|
|
||||||
String message = seed.getStack() + " - " + (int) seed.getChance();
|
|
||||||
player.sendChat(message);
|
|
||||||
MineTweakerAPI.logCommand("Seed: " + message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
|
|
||||||
minetweakerCommands.put("loot", new MineTweakerCommand(
|
|
||||||
"seeds",
|
|
||||||
new String[]{
|
|
||||||
"/minetweaker seeds",
|
|
||||||
" Prints all seeds registered",
|
|
||||||
" for tall grass"
|
|
||||||
}, new ICommandFunction() {
|
|
||||||
@Override
|
|
||||||
public void execute(String[] arguments, IPlayer player) {
|
|
||||||
if (arguments.length == 0) {
|
|
||||||
MineTweakerAPI.logCommand("Loot chest contents:");
|
|
||||||
List<String> types = MineTweakerAPI.vanilla.getLoot().getLootTypes();
|
|
||||||
Collections.sort(types);
|
|
||||||
for (String lootType : types) {
|
|
||||||
MineTweakerAPI.logCommand("Loot type: " + lootType);
|
|
||||||
|
|
||||||
List<LootEntry> entries = MineTweakerAPI.vanilla.getLoot().getLoot(lootType);
|
|
||||||
for (LootEntry entry : entries) {
|
|
||||||
MineTweakerAPI.logCommand(" " + entry.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
player.sendChat("List generated; see minetweaker.log in your minecraft dir");
|
|
||||||
} else {
|
|
||||||
MineTweakerAPI.logCommand("Loot for type: " + arguments[0]);
|
|
||||||
|
|
||||||
List<LootEntry> entries = MineTweakerAPI.vanilla.getLoot().getLoot(arguments[0]);
|
|
||||||
for (LootEntry entry : entries) {
|
|
||||||
MineTweakerAPI.logCommand(" " + entry.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
player.sendChat("List generated; see minetweaker.log in your minecraft dir");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
|
|
||||||
minetweakerCommands.put("wiki", new MineTweakerCommand(
|
|
||||||
"wiki",
|
|
||||||
new String[]{
|
|
||||||
"/minetweaker wiki",
|
|
||||||
" Opens your browser with the wiki"
|
|
||||||
}, new ICommandFunction() {
|
|
||||||
@Override
|
|
||||||
public void execute(String[] arguments, IPlayer player) {
|
|
||||||
player.openBrowser("http://minetweaker3.powerofbytes.com/wiki/");
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
|
|
||||||
minetweakerCommands.put("bugs", new MineTweakerCommand(
|
|
||||||
"bugs",
|
|
||||||
new String[]{
|
|
||||||
"/minetweaker bugs",
|
|
||||||
" Opens your browser with the GitHub bug tracker"
|
|
||||||
}, new ICommandFunction() {
|
|
||||||
@Override
|
|
||||||
public void execute(String[] arguments, IPlayer player) {
|
|
||||||
player.openBrowser("https://github.com/stanhebben/MineTweaker3/issues");
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
|
|
||||||
minetweakerCommands.put("forum", new MineTweakerCommand(
|
|
||||||
"forum",
|
|
||||||
new String[]{
|
|
||||||
"/minetweaker forum",
|
|
||||||
" Opens your browser with the forum"
|
|
||||||
}, new ICommandFunction() {
|
|
||||||
@Override
|
|
||||||
public void execute(String[] arguments, IPlayer player) {
|
|
||||||
player.openBrowser("http://minetweaker3.powerofbytes.com/forum");
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
|
|
||||||
minetweakerCommands.put("biomes", new MineTweakerCommand(
|
|
||||||
"biomes",
|
|
||||||
new String[]{
|
|
||||||
"/minetweaker biomes",
|
|
||||||
" Lists all the biomes in the game"
|
|
||||||
}, new ICommandFunction() {
|
|
||||||
@Override
|
|
||||||
public void execute(String[] arguments, IPlayer player) {
|
|
||||||
MineTweakerAPI.logCommand("Biomes:");
|
|
||||||
|
|
||||||
for (IBiome biome : MineTweakerAPI.game.getBiomes()) {
|
|
||||||
MineTweakerAPI.logCommand(" " + biome.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
player.sendChat("Biome list generated; see minetweaker.log in your minecraft dir");
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
|
|
||||||
minetweakerCommands.put("blockinfo", new MineTweakerCommand(
|
|
||||||
"blockinfo",
|
|
||||||
new String[]{
|
|
||||||
"/minetweaker blockinfo",
|
|
||||||
" Activates or deactivates block reader. In block info mode,",
|
|
||||||
" right-click a block to see ID, meta and tile entity data"
|
|
||||||
}, new ICommandFunction() {
|
|
||||||
@Override
|
|
||||||
public void execute(String[] arguments, IPlayer player) {
|
|
||||||
if (blockInfoPlayers.isEmpty()) {
|
|
||||||
blockEventHandler = events.onPlayerInteract(LISTEN_BLOCK_INFO);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (blockInfoPlayers.contains(player)) {
|
|
||||||
blockInfoPlayers.remove(player);
|
|
||||||
player.sendChat("Block info mode deactivated.");
|
|
||||||
} else {
|
|
||||||
blockInfoPlayers.add(player);
|
|
||||||
player.sendChat("Block info mode activated. Right-click a block to see its data.");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (blockInfoPlayers.isEmpty()) {
|
|
||||||
blockEventHandler.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Access point to the event handler implementation.
|
|
||||||
*/
|
|
||||||
public static final MTEventManager events = new MTEventManager();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Access point to the internal logger instance.
|
|
||||||
*/
|
|
||||||
public static final MTLogger logger = new MTLogger();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Access point to general platform functions.
|
|
||||||
*/
|
|
||||||
public static IPlatformFunctions platform = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initializes the MineTweaker API.
|
|
||||||
*
|
|
||||||
* @param oreDict ore dictionary interface
|
|
||||||
* @param recipes recipe manager interface
|
|
||||||
* @param furnace furnace manager interface
|
|
||||||
* @param game game interface
|
|
||||||
* @param mods mods interface
|
|
||||||
* @param formatter formatter interface
|
|
||||||
* @param vanilla vanilla interface
|
|
||||||
*/
|
|
||||||
public static void init(
|
|
||||||
IOreDict oreDict,
|
|
||||||
IRecipeManager recipes,
|
|
||||||
IFurnaceManager furnace,
|
|
||||||
IGame game,
|
|
||||||
ILoadedMods mods,
|
|
||||||
IFormatter formatter,
|
|
||||||
IVanilla vanilla) {
|
|
||||||
MineTweakerAPI.oreDict = oreDict;
|
|
||||||
MineTweakerAPI.recipes = recipes;
|
|
||||||
MineTweakerAPI.furnace = furnace;
|
|
||||||
MineTweakerAPI.game = game;
|
|
||||||
MineTweakerAPI.loadedMods = mods;
|
|
||||||
MineTweakerAPI.format = formatter;
|
|
||||||
MineTweakerAPI.vanilla = vanilla;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Register an event handler to be fired upon reload.
|
|
||||||
*
|
|
||||||
* @param handler
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static IEventHandle onRollbackEvent(IEventHandler<ReloadEvent> handler) {
|
|
||||||
return ONROLLBACK.add(handler);
|
|
||||||
}
|
|
||||||
public static IEventHandle onReloadEvent(IEventHandler<ReloadEvent> handler) {
|
|
||||||
return ONRELOAD.add(handler);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IEventHandle onPostReload(IEventHandler<ReloadEvent> handler) {
|
|
||||||
return ONPOSTRELOAD.add(handler);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Must be called upon server start.
|
|
||||||
*
|
|
||||||
* @param server server interface
|
|
||||||
*/
|
|
||||||
public static void onServerStart(IServer server) {
|
|
||||||
MineTweakerAPI.server = server;
|
|
||||||
reload();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Must be called upon server stop.
|
|
||||||
*/
|
|
||||||
public static void onServerStop() {
|
|
||||||
MineTweakerAPI.server = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the script provider.
|
|
||||||
*
|
|
||||||
* @param provider script provider
|
|
||||||
*/
|
|
||||||
public static void setScriptProvider(IScriptProvider provider) {
|
|
||||||
MineTweakerAPI.tweaker.setScriptProvider(provider);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called to reload scripts. Must be called after setting a new script
|
|
||||||
* provider in order to reload scripts.
|
|
||||||
*/
|
|
||||||
public static void reload() {
|
|
||||||
blockInfoPlayers.clear();
|
|
||||||
|
|
||||||
logger.clear();
|
|
||||||
events.clear();
|
|
||||||
|
|
||||||
if (MineTweakerAPI.server != null) {
|
|
||||||
events.onPlayerLoggedIn(LISTEN_LOGIN);
|
|
||||||
events.onPlayerLoggedOut(LISTEN_LOGOUT);
|
|
||||||
}
|
|
||||||
|
|
||||||
MineTweakerAPI.tweaker.rollback();
|
|
||||||
ONROLLBACK.publish(new ReloadEvent());
|
|
||||||
|
|
||||||
if (MineTweakerAPI.server != null) {
|
|
||||||
if (!MineTweakerAPI.server.isCommandAdded("minetweaker")) {
|
|
||||||
server.addCommand("minetweaker", "", new String[]{"mt", "crafttweaker", "ct"}, new ICommandFunction() {
|
|
||||||
@Override
|
|
||||||
public void execute(String[] arguments, IPlayer player) {
|
|
||||||
if (arguments.length == 0) {
|
|
||||||
player.sendChat("Please provide a command. Use /mt help for more info.");
|
|
||||||
} else if (arguments[0].equals("help")) {
|
|
||||||
String[] keys = minetweakerCommands.keySet().toArray(new String[minetweakerCommands.size()]);
|
|
||||||
Arrays.sort(keys);
|
|
||||||
for (String key : keys) {
|
|
||||||
for (String helpMessage : minetweakerCommands.get(key).description) {
|
|
||||||
player.sendChat(helpMessage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
MineTweakerCommand command = minetweakerCommands.get(arguments[0]);
|
|
||||||
if (command == null) {
|
|
||||||
player.sendChat("No such minetweaker command available");
|
|
||||||
} else {
|
|
||||||
command.function.execute(Arrays.copyOfRange(arguments, 1, arguments.length), player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, new ICommandValidator() {
|
|
||||||
@Override
|
|
||||||
public boolean canExecute(IPlayer player) {
|
|
||||||
return server.isOp(player);
|
|
||||||
}
|
|
||||||
}, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ONRELOAD.publish(new ReloadEvent());
|
|
||||||
|
|
||||||
MineTweakerAPI.tweaker.load();
|
|
||||||
|
|
||||||
if (MineTweakerAPI.server != null) {
|
|
||||||
platform.distributeScripts(MineTweakerAPI.tweaker.getScriptData());
|
|
||||||
}
|
|
||||||
|
|
||||||
ONPOSTRELOAD.publish(new ReloadEvent());
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds a new minetweaker command. Can be called with /mt <command&;gt;
|
|
||||||
* <arguments>.
|
|
||||||
*
|
|
||||||
* @param name command name
|
|
||||||
* @param description description strings
|
|
||||||
* @param function command implementation
|
|
||||||
*/
|
|
||||||
public static void addMineTweakerCommand(String name, String[] description, ICommandFunction function) {
|
|
||||||
MineTweakerAPI.apply(new AddMineTweakerCommandAction(new MineTweakerCommand(name, description, function)));
|
|
||||||
}
|
|
||||||
|
|
||||||
// ##############################
|
|
||||||
// ### Private static methods ###
|
|
||||||
// ##############################
|
|
||||||
|
|
||||||
private static void copyToClipboard(String value) {
|
|
||||||
StringSelection stringSelection = new StringSelection(value);
|
|
||||||
if (!(Toolkit.getDefaultToolkit() instanceof HeadlessToolkit)) {
|
|
||||||
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
|
|
||||||
clipboard.setContents(stringSelection, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ############################
|
|
||||||
// ### Public inner classes ###
|
|
||||||
// ############################
|
|
||||||
|
|
||||||
public static class ReloadEvent {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ######################
|
|
||||||
// ### Action classes ###
|
|
||||||
// ######################
|
|
||||||
|
|
||||||
private static class AddMineTweakerCommandAction implements IUndoableAction {
|
|
||||||
private final MineTweakerCommand command;
|
|
||||||
|
|
||||||
public AddMineTweakerCommandAction(MineTweakerCommand command) {
|
|
||||||
this.command = command;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void apply() {
|
|
||||||
if (!minetweakerCommands.containsKey(command.name)) {
|
|
||||||
minetweakerCommands.put(command.name, command);
|
|
||||||
} else {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canUndo() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void undo() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describe() {
|
|
||||||
if (!minetweakerCommands.containsKey(command.name)) {
|
|
||||||
return "Adding minetweaker command " + command.name;
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describeUndo() {
|
|
||||||
return "tried to remove command: " + command.name + " failed. THIS IS NOT AN ERROR!";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getOverrideKey() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// #############################
|
|
||||||
// ### Private inner classes ###
|
|
||||||
// #############################
|
|
||||||
|
|
||||||
private static class MineTweakerCommand {
|
|
||||||
private final String name;
|
|
||||||
private final String[] description;
|
|
||||||
private final ICommandFunction function;
|
|
||||||
|
|
||||||
public MineTweakerCommand(String name, String[] description, ICommandFunction function) {
|
|
||||||
this.name = name;
|
|
||||||
this.description = description;
|
|
||||||
this.function = function;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class ItemComparator implements Comparator<IItemDefinition> {
|
|
||||||
@Override
|
|
||||||
public int compare(IItemDefinition o1, IItemDefinition o2) {
|
|
||||||
return o1.getId().compareTo(o2.getId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class LiquidComparator implements Comparator<ILiquidDefinition> {
|
|
||||||
@Override
|
|
||||||
public int compare(ILiquidDefinition o1, ILiquidDefinition o2) {
|
|
||||||
return o1.getName().compareTo(o2.getName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class BlockComparator implements Comparator<IBlockDefinition> {
|
|
||||||
@Override
|
|
||||||
public int compare(IBlockDefinition o1, IBlockDefinition o2) {
|
|
||||||
return o1.getId().compareTo(o2.getId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class EntityComparator implements Comparator<IEntityDefinition> {
|
|
||||||
@Override
|
|
||||||
public int compare(IEntityDefinition o1, IEntityDefinition o2) {
|
|
||||||
return o1.getId().compareTo(o2.getId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class ListenPlayerLoggedIn implements IEventHandler<PlayerLoggedInEvent> {
|
|
||||||
@Override
|
|
||||||
public void handle(PlayerLoggedInEvent event) {
|
|
||||||
if (MineTweakerAPI.server != null && MineTweakerAPI.server.isOp(event.getPlayer())) {
|
|
||||||
logger.addPlayer(event.getPlayer());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class ListenPlayerLoggedOut implements IEventHandler<PlayerLoggedOutEvent> {
|
|
||||||
@Override
|
|
||||||
public void handle(PlayerLoggedOutEvent event) {
|
|
||||||
logger.removePlayer(event.getPlayer());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class ListenBlockInfo implements IEventHandler<PlayerInteractEvent> {
|
|
||||||
@Override
|
|
||||||
public void handle(PlayerInteractEvent event) {
|
|
||||||
if (blockInfoPlayers.contains(event.getPlayer())) {
|
|
||||||
IBlock block = event.getBlock();
|
|
||||||
event.getPlayer().sendChat("Block ID: " + block.getDefinition().getId());
|
|
||||||
event.getPlayer().sendChat("Meta value: " + block.getMeta());
|
|
||||||
IData data = block.getTileData();
|
|
||||||
if (data != null) {
|
|
||||||
event.getPlayer().sendChat("Tile entity data: " + data.asString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
package minetweaker;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Base implementation for a non-undoable action.
|
|
||||||
*
|
|
||||||
* @author Stan Hebben
|
|
||||||
*/
|
|
||||||
public abstract class OneWayAction implements IUndoableAction {
|
|
||||||
@Override
|
|
||||||
public boolean canUndo() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void undo() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describeUndo() {
|
|
||||||
return "impossibru!";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,96 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package minetweaker.expand;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import minetweaker.MineTweakerAPI;
|
|
||||||
import minetweaker.MineTweakerImplementationAPI;
|
|
||||||
import minetweaker.api.chat.IChatMessage;
|
|
||||||
import minetweaker.api.data.DataString;
|
|
||||||
import minetweaker.api.data.IData;
|
|
||||||
import minetweaker.api.formatting.IFormattedText;
|
|
||||||
import stanhebben.zenscript.annotations.OperatorType;
|
|
||||||
import stanhebben.zenscript.annotations.Optional;
|
|
||||||
import stanhebben.zenscript.annotations.ZenCaster;
|
|
||||||
import stanhebben.zenscript.annotations.ZenExpansion;
|
|
||||||
import stanhebben.zenscript.annotations.ZenMethod;
|
|
||||||
import stanhebben.zenscript.annotations.ZenOperator;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Stanneke
|
|
||||||
*/
|
|
||||||
@ZenExpansion("string")
|
|
||||||
public class ExpandString {
|
|
||||||
@ZenOperator(OperatorType.ADD)
|
|
||||||
public static IFormattedText add(String str, IFormattedText formattedText) {
|
|
||||||
return MineTweakerAPI.format.string(str).add(formattedText);
|
|
||||||
}
|
|
||||||
|
|
||||||
@ZenOperator(OperatorType.CAT)
|
|
||||||
public static IFormattedText cat(String str, IFormattedText formattedText) {
|
|
||||||
return add(str, formattedText);
|
|
||||||
}
|
|
||||||
|
|
||||||
@ZenCaster
|
|
||||||
public static IData asData(String value) {
|
|
||||||
return new DataString(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
@ZenCaster
|
|
||||||
public static IChatMessage asChatMessage(String value) {
|
|
||||||
return MineTweakerImplementationAPI.platform.getMessage(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
@ZenCaster
|
|
||||||
public static IFormattedText asFormattedText(String value) {
|
|
||||||
return MineTweakerAPI.format.string(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
@ZenMethod
|
|
||||||
public static List<String> split(String value, String separator, @Optional int maximum) {
|
|
||||||
List<String> result = new ArrayList<String>();
|
|
||||||
int minIndex = 0;
|
|
||||||
int numSplits = 0;
|
|
||||||
|
|
||||||
while (minIndex + separator.length() <= value.length()) {
|
|
||||||
int index = value.indexOf(separator, minIndex);
|
|
||||||
if (index < 0)
|
|
||||||
break;
|
|
||||||
result.add(value.substring(minIndex, index));
|
|
||||||
minIndex = index + separator.length();
|
|
||||||
|
|
||||||
numSplits++;
|
|
||||||
if (maximum > 0 && numSplits >= maximum)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
result.add(value.substring(minIndex));
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@ZenMethod
|
|
||||||
public static int indexOf(String value, String needle) {
|
|
||||||
return value.indexOf(needle);
|
|
||||||
}
|
|
||||||
|
|
||||||
@ZenMethod
|
|
||||||
public static int indexOf(String value, String needle, int fromIndex) {
|
|
||||||
return value.indexOf(needle, fromIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
@ZenMethod
|
|
||||||
public static int lastIndexOf(String value, String needle) {
|
|
||||||
return value.lastIndexOf(needle);
|
|
||||||
}
|
|
||||||
|
|
||||||
@ZenMethod
|
|
||||||
public static int lastIndexOf(String value, String needle, int fromIndex) {
|
|
||||||
return value.lastIndexOf(value, fromIndex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package minetweaker.runtime;
|
|
||||||
|
|
||||||
import minetweaker.MineTweakerAPI;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class GlobalFunctions {
|
|
||||||
private GlobalFunctions() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void print(String message) {
|
|
||||||
MineTweakerAPI.logInfo(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isNull(Object any){
|
|
||||||
return any == null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,347 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package minetweaker.runtime;
|
|
||||||
|
|
||||||
import minetweaker.*;
|
|
||||||
import minetweaker.api.item.*;
|
|
||||||
import stanhebben.zenscript.*;
|
|
||||||
import stanhebben.zenscript.annotations.*;
|
|
||||||
import stanhebben.zenscript.compiler.*;
|
|
||||||
import stanhebben.zenscript.expression.partial.*;
|
|
||||||
import stanhebben.zenscript.parser.*;
|
|
||||||
import stanhebben.zenscript.symbols.*;
|
|
||||||
import stanhebben.zenscript.type.*;
|
|
||||||
import stanhebben.zenscript.type.natives.*;
|
|
||||||
import stanhebben.zenscript.util.*;
|
|
||||||
|
|
||||||
import java.lang.annotation.*;
|
|
||||||
import java.lang.reflect.*;
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.logging.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class GlobalRegistry {
|
|
||||||
private static final Map<String, IZenSymbol> globals = new HashMap<String, IZenSymbol>();
|
|
||||||
private static final List<IRecipeRemover> removers = new ArrayList<IRecipeRemover>();
|
|
||||||
private static final List<IBracketHandler> bracketHandlers = new ArrayList<IBracketHandler>();
|
|
||||||
private static final TypeRegistry types = new TypeRegistry();
|
|
||||||
private static final SymbolPackage root = new SymbolPackage("<root>");
|
|
||||||
private static final IZenErrorLogger errors = new MyErrorLogger();
|
|
||||||
private static final IZenCompileEnvironment environment = new MyCompileEnvironment();
|
|
||||||
private static final Map<String, TypeExpansion> expansions = new HashMap<String, TypeExpansion>();
|
|
||||||
|
|
||||||
static {
|
|
||||||
registerGlobal("print", getStaticFunction(GlobalFunctions.class, "print", String.class));
|
|
||||||
registerGlobal("isNull", getStaticFunction(GlobalFunctions.class, "isNull", Object.class));
|
|
||||||
registerGlobal("max", getStaticFunction(Math.class, "max", int.class, int.class));
|
|
||||||
registerGlobal("min", getStaticFunction(Math.class, "min", int.class, int.class));
|
|
||||||
registerGlobal("pow", getStaticFunction(Math.class, "pow", double.class, double.class));
|
|
||||||
}
|
|
||||||
public static IZenErrorLogger getErrors() {
|
|
||||||
return errors;
|
|
||||||
}
|
|
||||||
|
|
||||||
private GlobalRegistry() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void registerGlobal(String name, IZenSymbol symbol) {
|
|
||||||
if (globals.containsKey(name)) {
|
|
||||||
throw new IllegalArgumentException("symbol already exists: " + name);
|
|
||||||
}
|
|
||||||
|
|
||||||
globals.put(name, symbol);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void registerExpansion(Class<?> cls) {
|
|
||||||
try {
|
|
||||||
for (Annotation annotation : cls.getAnnotations()) {
|
|
||||||
if (annotation instanceof ZenExpansion) {
|
|
||||||
ZenExpansion eAnnotation = (ZenExpansion) annotation;
|
|
||||||
if (!expansions.containsKey(eAnnotation.value())) {
|
|
||||||
expansions.put(eAnnotation.value(), new TypeExpansion(eAnnotation.value()));
|
|
||||||
}
|
|
||||||
expansions.get(eAnnotation.value()).expand(cls, types);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Throwable ex) {
|
|
||||||
errors.error("Error while applying expansion", ex);
|
|
||||||
ex.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void registerRemover(IRecipeRemover remover) {
|
|
||||||
removers.add(remover);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void registerBracketHandler(IBracketHandler handler) {
|
|
||||||
bracketHandlers.add(handler);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void registerNativeClass(Class<?> cls) {
|
|
||||||
//MineTweakerAPI.logInfo("Registering class: " + cls);
|
|
||||||
try {
|
|
||||||
|
|
||||||
ZenTypeNative type = new ZenTypeNative(cls);
|
|
||||||
type.complete(types);
|
|
||||||
|
|
||||||
root.put(type.getName(), new SymbolType(type), errors);
|
|
||||||
} catch (Throwable ex) {
|
|
||||||
MineTweakerAPI.logError("Error for " + cls, ex);
|
|
||||||
ex.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static TypeRegistry getTypeRegistry() {
|
|
||||||
return types;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void remove(IIngredient ingredient) {
|
|
||||||
for (IRecipeRemover remover : removers) {
|
|
||||||
remover.remove(ingredient);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IZenSymbol resolveBracket(IEnvironmentGlobal environment, List<Token> tokens) {
|
|
||||||
for (IBracketHandler handler : bracketHandlers) {
|
|
||||||
IZenSymbol symbol = handler.resolve(environment, tokens);
|
|
||||||
if (symbol != null) {
|
|
||||||
return symbol;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IZenSymbol getStaticFunction(Class cls, String name, Class... arguments) {
|
|
||||||
IJavaMethod method = JavaMethod.get(types, cls, name, arguments);
|
|
||||||
if (method == null)
|
|
||||||
return null;
|
|
||||||
return new SymbolJavaStaticMethod(method);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IZenSymbol getStaticField(Class cls, String name) {
|
|
||||||
try {
|
|
||||||
Field field = cls.getDeclaredField(name);
|
|
||||||
return new SymbolJavaStaticField(cls, field, types);
|
|
||||||
} catch (NoSuchFieldException ex) {
|
|
||||||
Logger.getLogger(GlobalRegistry.class.getName()).log(Level.SEVERE, null, ex);
|
|
||||||
return null;
|
|
||||||
} catch (SecurityException ex) {
|
|
||||||
Logger.getLogger(GlobalRegistry.class.getName()).log(Level.SEVERE, null, ex);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IEnvironmentGlobal makeGlobalEnvironment(Map<String, byte[]> classes) {
|
|
||||||
return new MyGlobalEnvironment(classes);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class MyErrorLogger implements IZenErrorLogger {
|
|
||||||
@Override
|
|
||||||
public void error(ZenPosition position, String message) {
|
|
||||||
if (position == null) {
|
|
||||||
MineTweakerAPI.logError("system: " + message);
|
|
||||||
} else {
|
|
||||||
MineTweakerAPI.logError(position + ": " + message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void warning(ZenPosition position, String message) {
|
|
||||||
if (position == null) {
|
|
||||||
MineTweakerAPI.logWarning("system: " + message);
|
|
||||||
} else {
|
|
||||||
MineTweakerAPI.logWarning(position + ": " + message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void info(ZenPosition position, String message) {
|
|
||||||
if (position == null) {
|
|
||||||
MineTweakerAPI.logInfo("system: " + message);
|
|
||||||
} else {
|
|
||||||
MineTweakerAPI.logInfo(position + ": " + message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void error(String message) {
|
|
||||||
error(null, message);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void error(String message, Throwable e) {
|
|
||||||
error(null, message);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void warning(String message) {
|
|
||||||
warning(null, message);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void info(String message) {
|
|
||||||
info(null, message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class MyCompileEnvironment implements IZenCompileEnvironment {
|
|
||||||
@Override
|
|
||||||
public IZenErrorLogger getErrorLogger() {
|
|
||||||
return errors;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IZenSymbol getGlobal(String name) {
|
|
||||||
if (globals.containsKey(name)) {
|
|
||||||
return globals.get(name);
|
|
||||||
} else {
|
|
||||||
return root.get(name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IZenSymbol getBracketed(IEnvironmentGlobal environment, List<Token> tokens) {
|
|
||||||
return resolveBracket(environment, tokens);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TypeRegistry getTypeRegistry() {
|
|
||||||
return types;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TypeExpansion getExpansion(String type) {
|
|
||||||
return expansions.get(type);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setRegistry(IZenRegistry registry) {
|
|
||||||
//NO-OP
|
|
||||||
throw new UnsupportedOperationException("Registry is not local");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class MyGlobalEnvironment implements IEnvironmentGlobal {
|
|
||||||
private final Map<String, byte[]> classes;
|
|
||||||
private final Map<String, IZenSymbol> symbols;
|
|
||||||
private final ClassNameGenerator generator;
|
|
||||||
|
|
||||||
public MyGlobalEnvironment(Map<String, byte[]> classes) {
|
|
||||||
this.classes = classes;
|
|
||||||
symbols = new HashMap<String, IZenSymbol>();
|
|
||||||
generator = new ClassNameGenerator();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IZenCompileEnvironment getEnvironment() {
|
|
||||||
return environment;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TypeExpansion getExpansion(String name) {
|
|
||||||
return expansions.get(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String makeClassName() {
|
|
||||||
return generator.generate();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String makeClassNameWithMiddleName(String middleName) {
|
|
||||||
return generator.generateWithMiddleName(middleName);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean containsClass(String name) {
|
|
||||||
return classes.containsKey(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void putClass(String name, byte[] data) {
|
|
||||||
classes.put(name, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IPartialExpression getValue(String name, ZenPosition position) {
|
|
||||||
if (symbols.containsKey(name)) {
|
|
||||||
return symbols.get(name).instance(position);
|
|
||||||
} else if (globals.containsKey(name)) {
|
|
||||||
return globals.get(name).instance(position);
|
|
||||||
} else {
|
|
||||||
IZenSymbol pkg = root.get(name);
|
|
||||||
if (pkg == null) {
|
|
||||||
return null;
|
|
||||||
} else {
|
|
||||||
return pkg.instance(position);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void putValue(String name, IZenSymbol value, ZenPosition position) {
|
|
||||||
if (symbols.containsKey(name)) {
|
|
||||||
error(position, "Value already defined in this scope: " + name);
|
|
||||||
} else {
|
|
||||||
symbols.put(name, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ZenType getType(Type type) {
|
|
||||||
return types.getType(type);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void error(ZenPosition position, String message) {
|
|
||||||
MineTweakerAPI.logError(position.toString() + " > " + message);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void warning(ZenPosition position, String message) {
|
|
||||||
MineTweakerAPI.logWarning(position.toString() + " > " + message);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void info(ZenPosition position, String message) {
|
|
||||||
MineTweakerAPI.logInfo(position.toString() + " > " + message);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void error(String message) {
|
|
||||||
MineTweakerAPI.logError(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void error(String message, Throwable e) {
|
|
||||||
MineTweakerAPI.logError(message, e);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void warning(String message) {
|
|
||||||
MineTweakerAPI.logWarning(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void info(String message) {
|
|
||||||
MineTweakerAPI.logInfo(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Set<String> getClassNames() {
|
|
||||||
return classes.keySet();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public byte[] getClass(String name) {
|
|
||||||
return classes.get(name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package minetweaker.runtime;
|
|
||||||
|
|
||||||
import stanhebben.zenscript.annotations.ZenMethod;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public interface ILogger {
|
|
||||||
@ZenMethod
|
|
||||||
public void logCommand(String message);
|
|
||||||
|
|
||||||
@ZenMethod
|
|
||||||
public void logInfo(String message);
|
|
||||||
|
|
||||||
@ZenMethod
|
|
||||||
public void logWarning(String message);
|
|
||||||
|
|
||||||
@ZenMethod
|
|
||||||
public void logError(String message);
|
|
||||||
|
|
||||||
@ZenMethod
|
|
||||||
public void logError(String message, Throwable exception);
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package minetweaker.runtime;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public interface IScriptIterator {
|
|
||||||
public String getGroupName();
|
|
||||||
|
|
||||||
public boolean next();
|
|
||||||
|
|
||||||
public String getName();
|
|
||||||
|
|
||||||
public InputStream open() throws IOException;
|
|
||||||
}
|
|
||||||
@@ -1,72 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package minetweaker.runtime;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import minetweaker.IUndoableAction;
|
|
||||||
import minetweaker.api.item.IIngredient;
|
|
||||||
import stanhebben.zenscript.annotations.ZenClass;
|
|
||||||
import stanhebben.zenscript.annotations.ZenMethod;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
@ZenClass("minetweaker.IMineTweaker")
|
|
||||||
public interface ITweaker {
|
|
||||||
/**
|
|
||||||
* Retrieves the script data to be loaded.
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public byte[] getStagedScriptData();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Executes a specified MineTweaker action. Will print a log message and
|
|
||||||
* adds the action to the undo list.
|
|
||||||
*
|
|
||||||
* @param action action to execute
|
|
||||||
*/
|
|
||||||
public void apply(IUndoableAction action);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes a specific item from all known recipes handlers.
|
|
||||||
*
|
|
||||||
* @param items items to remove
|
|
||||||
*/
|
|
||||||
@ZenMethod
|
|
||||||
public void remove(IIngredient items);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Rolls back all actions performed by MineTweaker. Returns the list of
|
|
||||||
* actions that could not be rolled back (the "stuck" ones that are not
|
|
||||||
* undoable).
|
|
||||||
*
|
|
||||||
* @return stuck action list
|
|
||||||
*/
|
|
||||||
public List<IUndoableAction> rollback();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the script provider.
|
|
||||||
*
|
|
||||||
* @param provider
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void setScriptProvider(IScriptProvider provider);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Executes all scripts provided by the script provider.
|
|
||||||
*/
|
|
||||||
public void load();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves the data from the scripts that were loaded last.
|
|
||||||
*
|
|
||||||
* @return scripts data
|
|
||||||
*/
|
|
||||||
public byte[] getScriptData();
|
|
||||||
}
|
|
||||||
@@ -1,184 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package minetweaker.runtime;
|
|
||||||
|
|
||||||
import minetweaker.IUndoableAction;
|
|
||||||
import minetweaker.MineTweakerAPI;
|
|
||||||
import minetweaker.api.item.IIngredient;
|
|
||||||
import minetweaker.runtime.providers.ScriptProviderMemory;
|
|
||||||
import stanhebben.zenscript.ZenModule;
|
|
||||||
import stanhebben.zenscript.ZenParsedFile;
|
|
||||||
import stanhebben.zenscript.ZenTokener;
|
|
||||||
import stanhebben.zenscript.compiler.IEnvironmentGlobal;
|
|
||||||
import stanhebben.zenscript.parser.ParseException;
|
|
||||||
|
|
||||||
import java.io.BufferedInputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.io.Reader;
|
|
||||||
import java.nio.charset.*;
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
import static stanhebben.zenscript.ZenModule.compileScripts;
|
|
||||||
import static stanhebben.zenscript.ZenModule.extractClassName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @author Stan Hebben
|
|
||||||
*/
|
|
||||||
public class MTTweaker implements ITweaker {
|
|
||||||
private static final boolean DEBUG = false;
|
|
||||||
|
|
||||||
private final List<IUndoableAction> actions = new ArrayList<IUndoableAction>();
|
|
||||||
private final Set<IUndoableAction> wereStuck = new LinkedHashSet<IUndoableAction>();
|
|
||||||
private final Map<Object, IUndoableAction> stuckOverridable = new HashMap<Object, IUndoableAction>();
|
|
||||||
|
|
||||||
private IScriptProvider scriptProvider;
|
|
||||||
private byte[] scriptData;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public byte[] getStagedScriptData() {
|
|
||||||
return ScriptProviderMemory.collect(scriptProvider);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void apply(IUndoableAction action) {
|
|
||||||
MineTweakerAPI.logInfo(action.describe());
|
|
||||||
|
|
||||||
Object overrideKey = action.getOverrideKey();
|
|
||||||
if (wereStuck.contains(action)) {
|
|
||||||
MineTweakerAPI.logInfo("WAS STUCK");
|
|
||||||
wereStuck.remove(action);
|
|
||||||
|
|
||||||
if (overrideKey != null) {
|
|
||||||
stuckOverridable.remove(overrideKey);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (overrideKey != null && stuckOverridable.containsKey(overrideKey)) {
|
|
||||||
wereStuck.remove(stuckOverridable.get(overrideKey));
|
|
||||||
stuckOverridable.remove(overrideKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
action.apply();
|
|
||||||
}
|
|
||||||
|
|
||||||
actions.add(action);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void remove(IIngredient items) {
|
|
||||||
GlobalRegistry.remove(items);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<IUndoableAction> rollback() {
|
|
||||||
// Note: Requires a OnRollback event to be fired. If this is called from MineTweakerImplementationAPI it's handled there.
|
|
||||||
List<IUndoableAction> stuck = new ArrayList<>();
|
|
||||||
for (int i = actions.size() - 1; i >= 0; i--) {
|
|
||||||
IUndoableAction action = actions.get(i);
|
|
||||||
if (action.canUndo()) {
|
|
||||||
MineTweakerAPI.logInfo(action.describeUndo());
|
|
||||||
action.undo();
|
|
||||||
} else {
|
|
||||||
MineTweakerAPI.logInfo("[Stuck] 1 " + action.describe());
|
|
||||||
MineTweakerAPI.logInfo("[Stuck] 2 " + action.describeUndo());
|
|
||||||
MineTweakerAPI.logInfo("[Stuck] 3 " + action.toString());
|
|
||||||
|
|
||||||
stuck.add(0, action);
|
|
||||||
wereStuck.add(action);
|
|
||||||
|
|
||||||
Object overrideKey = action.getOverrideKey();
|
|
||||||
if (overrideKey != null) {
|
|
||||||
stuckOverridable.put(overrideKey, action);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
actions.clear();
|
|
||||||
return stuck;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setScriptProvider(IScriptProvider provider) {
|
|
||||||
scriptProvider = provider;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void load() {
|
|
||||||
ZenModule.loadedClasses.clear();
|
|
||||||
System.out.println("Loading scripts");
|
|
||||||
|
|
||||||
scriptData = ScriptProviderMemory.collect(scriptProvider);
|
|
||||||
Set<String> executed = new HashSet<>();
|
|
||||||
|
|
||||||
Iterator<IScriptIterator> scripts = scriptProvider.getScripts();
|
|
||||||
while (scripts.hasNext()) {
|
|
||||||
IScriptIterator script = scripts.next();
|
|
||||||
|
|
||||||
if (!executed.contains(script.getGroupName())) {
|
|
||||||
executed.add(script.getGroupName());
|
|
||||||
|
|
||||||
Map<String, byte[]> classes = new HashMap<>();
|
|
||||||
IEnvironmentGlobal environmentGlobal = GlobalRegistry.makeGlobalEnvironment(classes);
|
|
||||||
|
|
||||||
List<ZenParsedFile> files = new ArrayList<>();
|
|
||||||
|
|
||||||
while (script.next()) {
|
|
||||||
Reader reader = null;
|
|
||||||
try {
|
|
||||||
reader = new InputStreamReader(new BufferedInputStream(script.open()), StandardCharsets.UTF_8);
|
|
||||||
|
|
||||||
String filename = script.getName();
|
|
||||||
String className = extractClassName(filename);
|
|
||||||
|
|
||||||
ZenTokener parser = new ZenTokener(reader, environmentGlobal.getEnvironment(), filename, false);
|
|
||||||
ZenParsedFile pfile = new ZenParsedFile(filename, className, parser, environmentGlobal);
|
|
||||||
files.add(pfile);
|
|
||||||
} catch (IOException ex) {
|
|
||||||
MineTweakerAPI.logError("Could not load script " + script.getName() + ": " + ex.getMessage());
|
|
||||||
} catch (ParseException ex) {
|
|
||||||
// ex.printStackTrace();
|
|
||||||
MineTweakerAPI.logError("Error parsing " + ex.getFile().getFileName() + ":" + ex.getLine() + " -- " + ex.getExplanation());
|
|
||||||
} catch (Exception ex) {
|
|
||||||
MineTweakerAPI.logError("Error loading " + script.getName() + ": " + ex.toString(), ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (reader != null) {
|
|
||||||
try {
|
|
||||||
reader.close();
|
|
||||||
} catch (IOException ignored) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
String filename = script.getGroupName();
|
|
||||||
System.out.println("MineTweaker: Loading " + filename);
|
|
||||||
compileScripts(filename, files, environmentGlobal, DEBUG);
|
|
||||||
|
|
||||||
// execute scripts
|
|
||||||
ZenModule module = new ZenModule(classes, MineTweakerAPI.class.getClassLoader());
|
|
||||||
module.getMain().run();
|
|
||||||
} catch (Throwable ex) {
|
|
||||||
MineTweakerAPI.logError("Error executing " + script.getGroupName() + ": " + ex.getMessage(), ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (wereStuck.size() > 0) {
|
|
||||||
MineTweakerAPI.logWarning(Integer.toString(wereStuck.size()) + " modifications were stuck");
|
|
||||||
for (IUndoableAction action : wereStuck) {
|
|
||||||
MineTweakerAPI.logInfo("Stuck: " + action.describe());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public byte[] getScriptData() {
|
|
||||||
return scriptData;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-73
@@ -1,73 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package minetweaker.runtime.providers;
|
|
||||||
|
|
||||||
import java.io.BufferedInputStream;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import minetweaker.runtime.IScriptIterator;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class ScriptIteratorDirectory implements IScriptIterator {
|
|
||||||
private final File directory;
|
|
||||||
private Iterator<File> contents;
|
|
||||||
private File current;
|
|
||||||
|
|
||||||
public ScriptIteratorDirectory(File directory) {
|
|
||||||
this.directory = directory;
|
|
||||||
|
|
||||||
File scriptDir = new File(directory, "scripts");
|
|
||||||
List<File> contentsList = new ArrayList<File>();
|
|
||||||
if (scriptDir.exists()) {
|
|
||||||
iterate(scriptDir, contentsList);
|
|
||||||
}
|
|
||||||
contents = contentsList.iterator();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getGroupName() {
|
|
||||||
return directory.getName();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean next() {
|
|
||||||
if (contents.hasNext()) {
|
|
||||||
current = contents.next();
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return current.getAbsolutePath().substring(directory.getAbsolutePath().length());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public InputStream open() throws IOException {
|
|
||||||
return new BufferedInputStream(new FileInputStream(current));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void iterate(File directory, List<File> contentsList) {
|
|
||||||
for (File file : directory.listFiles()) {
|
|
||||||
if (file.isDirectory()) {
|
|
||||||
iterate(file, contentsList);
|
|
||||||
} else if (file.isFile() && file.getName().endsWith(".zs")) {
|
|
||||||
contentsList.add(file);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-52
@@ -1,52 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package minetweaker.runtime.providers;
|
|
||||||
|
|
||||||
import java.io.BufferedInputStream;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import minetweaker.runtime.IScriptIterator;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class ScriptIteratorSingle implements IScriptIterator {
|
|
||||||
private final File file;
|
|
||||||
private boolean first = true;
|
|
||||||
|
|
||||||
public ScriptIteratorSingle(File file) {
|
|
||||||
this.file = file;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getGroupName() {
|
|
||||||
return file.getName();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean next() {
|
|
||||||
if (first) {
|
|
||||||
first = false;
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return file.getName();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public InputStream open() throws IOException {
|
|
||||||
return new BufferedInputStream(new FileInputStream(file));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,70 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package minetweaker.runtime.providers;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Enumeration;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.zip.ZipEntry;
|
|
||||||
import java.util.zip.ZipFile;
|
|
||||||
import minetweaker.runtime.IScriptIterator;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class ScriptIteratorZip implements IScriptIterator {
|
|
||||||
private final File file;
|
|
||||||
private final ZipFile zipFile;
|
|
||||||
private final Iterator<ZipEntry> entries;
|
|
||||||
private ZipEntry current;
|
|
||||||
|
|
||||||
public ScriptIteratorZip(File file) throws IOException {
|
|
||||||
this.file = file;
|
|
||||||
|
|
||||||
zipFile = new ZipFile(file);
|
|
||||||
List<ZipEntry> entriesList = new ArrayList<ZipEntry>();
|
|
||||||
Enumeration<? extends ZipEntry> original = zipFile.entries();
|
|
||||||
while (original.hasMoreElements()) {
|
|
||||||
ZipEntry entry = original.nextElement();
|
|
||||||
if (entry.getName().startsWith("scripts/") && entry.getName().endsWith(".zs")) {
|
|
||||||
entriesList.add(entry);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
entries = entriesList.iterator();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getGroupName() {
|
|
||||||
return file.getName().substring(0, file.getName().lastIndexOf('.'));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean next() {
|
|
||||||
if (entries.hasNext()) {
|
|
||||||
current = entries.next();
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return current.getName().substring("scripts/".length());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public InputStream open() throws IOException {
|
|
||||||
return zipFile.getInputStream(current);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-90
@@ -1,90 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package minetweaker.runtime.providers;
|
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.Set;
|
|
||||||
import minetweaker.runtime.IScriptIterator;
|
|
||||||
import minetweaker.runtime.IScriptProvider;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Stan Hebben
|
|
||||||
*/
|
|
||||||
public class ScriptProviderCascade implements IScriptProvider {
|
|
||||||
private final IScriptProvider[] providers;
|
|
||||||
|
|
||||||
public ScriptProviderCascade(IScriptProvider... providers) {
|
|
||||||
this.providers = providers;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Iterator<IScriptIterator> getScripts() {
|
|
||||||
return new MyScripterator();
|
|
||||||
}
|
|
||||||
|
|
||||||
private class MyScripterator implements Iterator<IScriptIterator> {
|
|
||||||
private final Set<String> executed = new HashSet<String>();
|
|
||||||
|
|
||||||
private int currentIndex = providers.length - 1;
|
|
||||||
private Iterator<IScriptIterator> current;
|
|
||||||
private IScriptIterator currentValue;
|
|
||||||
|
|
||||||
public MyScripterator() {
|
|
||||||
currentIndex = providers.length - 1;
|
|
||||||
current = providers[currentIndex].getScripts();
|
|
||||||
|
|
||||||
advance();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasNext() {
|
|
||||||
return currentIndex >= 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IScriptIterator next() {
|
|
||||||
IScriptIterator result = currentValue;
|
|
||||||
executed.add(result.getGroupName());
|
|
||||||
|
|
||||||
advance();
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void advance() {
|
|
||||||
do {
|
|
||||||
while (!current.hasNext()) {
|
|
||||||
currentIndex--;
|
|
||||||
if (currentIndex < 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
current = providers[currentIndex].getScripts();
|
|
||||||
}
|
|
||||||
if (currentIndex < 0)
|
|
||||||
break;
|
|
||||||
|
|
||||||
currentValue = current.next();
|
|
||||||
} while (executed.contains(currentValue.getGroupName()) && hasNext());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void remove() {
|
|
||||||
throw new UnsupportedOperationException("Not supported yet."); // To
|
|
||||||
// change
|
|
||||||
// body
|
|
||||||
// of
|
|
||||||
// generated
|
|
||||||
// methods,
|
|
||||||
// choose
|
|
||||||
// Tools
|
|
||||||
// |
|
|
||||||
// Templates.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-89
@@ -1,89 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package minetweaker.runtime.providers;
|
|
||||||
|
|
||||||
import minetweaker.runtime.IScriptIterator;
|
|
||||||
import minetweaker.runtime.IScriptProvider;
|
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.nio.charset.Charset;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class ScriptProviderCustom implements IScriptProvider {
|
|
||||||
private static final Charset UTF8 = Charset.forName("UTF-8");
|
|
||||||
|
|
||||||
private final String moduleName;
|
|
||||||
private final List<CustomScript> scripts;
|
|
||||||
|
|
||||||
public ScriptProviderCustom(String moduleName) {
|
|
||||||
this.moduleName = moduleName;
|
|
||||||
scripts = new ArrayList<CustomScript>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void add(String name, byte[] content) {
|
|
||||||
scripts.add(new CustomScript(name, content));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void add(String name, String content) {
|
|
||||||
add(name, content.getBytes(UTF8));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Iterator<IScriptIterator> getScripts() {
|
|
||||||
|
|
||||||
return Collections.<IScriptIterator>singleton(new CustomScriptIterator()).iterator();
|
|
||||||
}
|
|
||||||
|
|
||||||
private class CustomScript {
|
|
||||||
private final String name;
|
|
||||||
private final byte[] content;
|
|
||||||
|
|
||||||
public CustomScript(String name, byte[] content) {
|
|
||||||
this.name = name;
|
|
||||||
this.content = content;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class CustomScriptIterator implements IScriptIterator {
|
|
||||||
private CustomScript current;
|
|
||||||
private final Iterator<CustomScript> iterator = scripts.iterator();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getGroupName() {
|
|
||||||
return moduleName;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean next() {
|
|
||||||
if (iterator.hasNext()) {
|
|
||||||
current = iterator.next();
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return current.name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public InputStream open() throws IOException {
|
|
||||||
return new ByteArrayInputStream(current.content);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-195
@@ -1,195 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package minetweaker.runtime.providers;
|
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.DataInputStream;
|
|
||||||
import java.io.DataOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.zip.DeflaterOutputStream;
|
|
||||||
import java.util.zip.InflaterInputStream;
|
|
||||||
import minetweaker.MineTweakerAPI;
|
|
||||||
import minetweaker.util.FileUtil;
|
|
||||||
import minetweaker.runtime.IScriptIterator;
|
|
||||||
import minetweaker.runtime.IScriptProvider;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class ScriptProviderMemory implements IScriptProvider {
|
|
||||||
public static byte[] collect(IScriptProvider provider) {
|
|
||||||
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
|
||||||
try {
|
|
||||||
DeflaterOutputStream deflater = new DeflaterOutputStream(output);
|
|
||||||
DataOutputStream deflaterData = new DataOutputStream(deflater);
|
|
||||||
Set<String> executed = new HashSet<String>();
|
|
||||||
|
|
||||||
Iterator<IScriptIterator> scripts = provider.getScripts();
|
|
||||||
while (scripts.hasNext()) {
|
|
||||||
IScriptIterator script = scripts.next();
|
|
||||||
|
|
||||||
if (!executed.contains(script.getGroupName())) {
|
|
||||||
executed.add(script.getGroupName());
|
|
||||||
|
|
||||||
deflaterData.writeUTF(script.getGroupName());
|
|
||||||
|
|
||||||
while (script.next()) {
|
|
||||||
String name = script.getName();
|
|
||||||
byte[] data = FileUtil.read(script.open());
|
|
||||||
if (data.length == 0)
|
|
||||||
continue; // skip empty files
|
|
||||||
|
|
||||||
deflaterData.writeUTF(name);
|
|
||||||
deflaterData.writeInt(data.length);
|
|
||||||
deflaterData.write(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
deflaterData.writeUTF("");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
deflaterData.writeUTF("");
|
|
||||||
|
|
||||||
deflater.close();
|
|
||||||
} catch (IOException ex) {
|
|
||||||
MineTweakerAPI.logError("Could not collect scripts: " + ex.getMessage());
|
|
||||||
}
|
|
||||||
return output.toByteArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
private final Map<String, MemoryModule> modules;
|
|
||||||
|
|
||||||
public ScriptProviderMemory(byte[] scripts) {
|
|
||||||
modules = new HashMap<String, MemoryModule>();
|
|
||||||
|
|
||||||
try {
|
|
||||||
InflaterInputStream inflater = new InflaterInputStream(new ByteArrayInputStream(scripts));
|
|
||||||
DataInputStream inflaterData = new DataInputStream(inflater);
|
|
||||||
|
|
||||||
String moduleName = inflaterData.readUTF();
|
|
||||||
while (moduleName.length() > 0) {
|
|
||||||
List<MemoryFile> files = new ArrayList<MemoryFile>();
|
|
||||||
|
|
||||||
String fileName = inflaterData.readUTF();
|
|
||||||
while (fileName.length() > 0) {
|
|
||||||
byte[] data = new byte[inflaterData.readInt()];
|
|
||||||
inflaterData.readFully(data);
|
|
||||||
files.add(new MemoryFile(fileName, data));
|
|
||||||
|
|
||||||
fileName = inflaterData.readUTF();
|
|
||||||
}
|
|
||||||
modules.put(moduleName, new MemoryModule(moduleName, files));
|
|
||||||
|
|
||||||
moduleName = inflaterData.readUTF();
|
|
||||||
}
|
|
||||||
|
|
||||||
inflaterData.close();
|
|
||||||
} catch (IOException ex) {
|
|
||||||
MineTweakerAPI.logError("Could not load transmitted scripts: " + ex.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Iterator<IScriptIterator> getScripts() {
|
|
||||||
return new ProviderIterator();
|
|
||||||
}
|
|
||||||
|
|
||||||
private class ProviderIterator implements Iterator<IScriptIterator> {
|
|
||||||
private final Iterator<MemoryModule> baseIterator = modules.values().iterator();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasNext() {
|
|
||||||
return baseIterator.hasNext();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IScriptIterator next() {
|
|
||||||
return new ScriptIterator(baseIterator.next());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void remove() {
|
|
||||||
throw new UnsupportedOperationException("Not supported yet."); // To
|
|
||||||
// change
|
|
||||||
// body
|
|
||||||
// of
|
|
||||||
// generated
|
|
||||||
// methods,
|
|
||||||
// choose
|
|
||||||
// Tools
|
|
||||||
// |
|
|
||||||
// Templates.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class ScriptIterator implements IScriptIterator {
|
|
||||||
private final MemoryModule module;
|
|
||||||
private final Iterator<MemoryFile> files;
|
|
||||||
private MemoryFile current;
|
|
||||||
|
|
||||||
public ScriptIterator(MemoryModule module) {
|
|
||||||
this.module = module;
|
|
||||||
files = module.data.iterator();
|
|
||||||
current = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getGroupName() {
|
|
||||||
return module.name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean next() {
|
|
||||||
if (files.hasNext()) {
|
|
||||||
current = files.next();
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return current.name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public InputStream open() throws IOException {
|
|
||||||
return new ByteArrayInputStream(current.data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class MemoryModule {
|
|
||||||
private final String name;
|
|
||||||
private final List<MemoryFile> data;
|
|
||||||
|
|
||||||
public MemoryModule(String name, List<MemoryFile> data) {
|
|
||||||
this.name = name;
|
|
||||||
this.data = data;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class MemoryFile {
|
|
||||||
private final String name;
|
|
||||||
private final byte[] data;
|
|
||||||
|
|
||||||
public MemoryFile(String name, byte[] data) {
|
|
||||||
this.name = name;
|
|
||||||
this.data = data;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package minetweaker.util;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import minetweaker.api.block.IBlockPattern;
|
|
||||||
import minetweaker.api.item.IIngredient;
|
|
||||||
import minetweaker.api.item.IItemCondition;
|
|
||||||
import minetweaker.api.item.IItemTransformer;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class ArrayUtil {
|
|
||||||
public static final IItemCondition[] EMPTY_CONDITIONS = new IItemCondition[0];
|
|
||||||
public static final IItemTransformer[] EMPTY_TRANSFORMERS = new IItemTransformer[0];
|
|
||||||
|
|
||||||
public static IItemCondition[] append(IItemCondition[] values, IItemCondition value) {
|
|
||||||
IItemCondition[] result = Arrays.copyOf(values, values.length + 1);
|
|
||||||
result[values.length] = value;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IItemTransformer[] append(IItemTransformer[] values, IItemTransformer value) {
|
|
||||||
IItemTransformer[] result = Arrays.copyOf(values, values.length + 1);
|
|
||||||
result[values.length] = value;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IIngredient[] append(IIngredient[] values, IIngredient value) {
|
|
||||||
IIngredient[] result = Arrays.copyOf(values, values.length + 1);
|
|
||||||
result[values.length] = value;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IBlockPattern[] append(IBlockPattern[] values, IBlockPattern value) {
|
|
||||||
IBlockPattern[] result = Arrays.copyOf(values, values.length + 1);
|
|
||||||
result[values.length] = value;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,91 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package minetweaker.util;
|
|
||||||
|
|
||||||
import minetweaker.api.event.IEventHandle;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class EventList<T> {
|
|
||||||
private EventNode first = null;
|
|
||||||
private EventNode last = null;
|
|
||||||
|
|
||||||
public void clear() {
|
|
||||||
first = last = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEventHandle add(IEventHandler<T> handler) {
|
|
||||||
EventNode node = new EventNode(handler, last, null);
|
|
||||||
|
|
||||||
synchronized (this) {
|
|
||||||
if (first == null) {
|
|
||||||
first = node;
|
|
||||||
}
|
|
||||||
if (last != null) {
|
|
||||||
last.next = node;
|
|
||||||
}
|
|
||||||
last = node;
|
|
||||||
}
|
|
||||||
|
|
||||||
return node;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasHandlers() {
|
|
||||||
return first != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isEmpty() {
|
|
||||||
return first == null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void publish(T event) {
|
|
||||||
EventNode current = null;
|
|
||||||
|
|
||||||
synchronized (this) {
|
|
||||||
current = first;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (current != null) {
|
|
||||||
current.handler.handle(event);
|
|
||||||
|
|
||||||
synchronized (this) {
|
|
||||||
current = current.next;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class EventNode implements IEventHandle {
|
|
||||||
private final IEventHandler<T> handler;
|
|
||||||
private EventNode next;
|
|
||||||
private EventNode prev;
|
|
||||||
|
|
||||||
public EventNode(IEventHandler<T> handler, EventNode prev, EventNode next) {
|
|
||||||
this.handler = handler;
|
|
||||||
this.prev = prev;
|
|
||||||
this.next = next;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void close() {
|
|
||||||
synchronized (EventList.this) {
|
|
||||||
if (prev == null) {
|
|
||||||
first = next;
|
|
||||||
} else {
|
|
||||||
prev.next = next;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (next == null) {
|
|
||||||
last = prev;
|
|
||||||
} else {
|
|
||||||
next.prev = prev;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package minetweaker.util;
|
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class FileUtil {
|
|
||||||
public static final byte[] read(InputStream input) throws IOException {
|
|
||||||
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
|
||||||
byte[] buffer = new byte[65536];
|
|
||||||
while (input.available() > 0) {
|
|
||||||
int bytesRead = input.read(buffer);
|
|
||||||
output.write(buffer, 0, bytesRead);
|
|
||||||
}
|
|
||||||
return output.toByteArray();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package minetweaker.util;
|
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
|
||||||
import java.nio.charset.Charset;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class StringUtil
|
|
||||||
{
|
|
||||||
private static final Charset UTF8 = Charset.forName("UTF-8");
|
|
||||||
|
|
||||||
private StringUtil() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String decodeUTF8(byte[] data)
|
|
||||||
{
|
|
||||||
return UTF8.decode(ByteBuffer.wrap(data)).toString().trim();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static byte[] encodeUTF8(String data)
|
|
||||||
{
|
|
||||||
return UTF8.encode(data).array();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,64 +0,0 @@
|
|||||||
import minetweaker.tasks.RegisterZenClassesTask;
|
|
||||||
|
|
||||||
buildscript {
|
|
||||||
repositories {
|
|
||||||
mavenCentral()
|
|
||||||
maven {
|
|
||||||
name = "forge"
|
|
||||||
url = "http://files.minecraftforge.net/maven"
|
|
||||||
}
|
|
||||||
maven {
|
|
||||||
name = "sonatype"
|
|
||||||
url = "https://oss.sonatype.org/content/repositories/snapshots/"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
dependencies {
|
|
||||||
classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
apply plugin: 'forge'
|
|
||||||
apply plugin: 'maven'
|
|
||||||
|
|
||||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
|
||||||
targetCompatibility = JavaVersion.VERSION_1_8
|
|
||||||
sourceCompatibility = 1.8
|
|
||||||
targetCompatibility = 1.8
|
|
||||||
|
|
||||||
version = "1.7.10-" + ext.mineTweakerVersion
|
|
||||||
archivesBaseName = project.projectDir.name
|
|
||||||
|
|
||||||
minecraft {
|
|
||||||
version = forgeVersion1710
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
dependencies {
|
|
||||||
compile project(':ZenScript')
|
|
||||||
compile project(':MineTweaker3-API')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
task makeRegistry(type: RegisterZenClassesTask) {
|
|
||||||
inputDir = file('build/classes/main')
|
|
||||||
outputDir = file('build/classes/main')
|
|
||||||
className = 'minetweaker.mc1710.MineTweakerRegistry'
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.jar.dependsOn(makeRegistry)
|
|
||||||
|
|
||||||
processResources
|
|
||||||
{
|
|
||||||
// replace stuff in mcmod.info, nothing else
|
|
||||||
from(sourceSets.main.resources.srcDirs) {
|
|
||||||
include 'mcmod.info'
|
|
||||||
|
|
||||||
// replace version and mcversion
|
|
||||||
expand 'version':project.version, 'mcversion':project.minecraft.version
|
|
||||||
}
|
|
||||||
|
|
||||||
// copy everything else, thats not the mcmod.info
|
|
||||||
from(sourceSets.main.resources.srcDirs) {
|
|
||||||
exclude 'mcmod.info'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
BIN
Binary file not shown.
BIN
Binary file not shown.
-4
@@ -1,4 +0,0 @@
|
|||||||
#Sun Jun 05 18:58:07 CEST 2011
|
|
||||||
version=1
|
|
||||||
eclipse.preferences.version=1
|
|
||||||
refresh.enabled=true
|
|
||||||
-7
@@ -1,7 +0,0 @@
|
|||||||
#Sun Jun 05 19:03:53 CEST 2011
|
|
||||||
eclipse.preferences.version=1
|
|
||||||
org.eclipse.debug.ui.UseContextualLaunch=false
|
|
||||||
Console.highWaterMark=88000
|
|
||||||
org.eclipse.debug.ui.PREF_LAUNCH_PERSPECTIVES=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?>\r\n<launchPerspectives/>\r\n
|
|
||||||
org.eclipse.debug.ui.user_view_bindings=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?>\r\n<viewBindings>\r\n<view id\="org.eclipse.ui.console.ConsoleView">\r\n<perspective id\="org.eclipse.jdt.ui.JavaPerspective" userAction\="opened"/>\r\n</view>\r\n</viewBindings>\r\n
|
|
||||||
StringVariablePreferencePage=130,107,107,86,
|
|
||||||
-3
@@ -1,3 +0,0 @@
|
|||||||
#Sun Jun 05 18:58:07 CEST 2011
|
|
||||||
eclipse.preferences.version=1
|
|
||||||
org.eclipse.epp.usagedata.gathering.enabled=false
|
|
||||||
-14
@@ -1,14 +0,0 @@
|
|||||||
#Sun Sep 18 16:44:39 NZST 2011
|
|
||||||
org.eclipse.jdt.core.compiler.compliance=1.6
|
|
||||||
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=ignore
|
|
||||||
org.eclipse.jdt.core.compiler.problem.deprecation=ignore
|
|
||||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
|
||||||
org.eclipse.jdt.core.compiler.problem.unusedLocal=ignore
|
|
||||||
org.eclipse.jdt.core.compiler.problem.unusedImport=ignore
|
|
||||||
eclipse.preferences.version=1
|
|
||||||
org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=ignore
|
|
||||||
org.eclipse.jdt.core.compiler.problem.rawTypeReference=ignore
|
|
||||||
org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=ignore
|
|
||||||
org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore
|
|
||||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
|
||||||
org.eclipse.jdt.core.compiler.source=1.6
|
|
||||||
-4
@@ -1,4 +0,0 @@
|
|||||||
#Sun Jun 05 18:58:05 CEST 2011
|
|
||||||
spacesForTabs=true
|
|
||||||
eclipse.preferences.version=1
|
|
||||||
overviewRuler_migration=migrated_3.1
|
|
||||||
-9
@@ -1,9 +0,0 @@
|
|||||||
#Sun Jun 05 18:58:07 CEST 2011
|
|
||||||
IMPORT_FILES_AND_FOLDERS_MODE=prompt
|
|
||||||
IMPORT_FILES_AND_FOLDERS_VIRTUAL_FOLDER_MODE=prompt
|
|
||||||
SAVE_ALL_BEFORE_BUILD=true
|
|
||||||
eclipse.preferences.version=1
|
|
||||||
tipsAndTricks=true
|
|
||||||
platformState=1287081747687
|
|
||||||
quickStart=false
|
|
||||||
PROBLEMS_FILTERS_MIGRATE=true
|
|
||||||
-3
@@ -1,3 +0,0 @@
|
|||||||
#Sun Jun 05 18:50:08 CEST 2011
|
|
||||||
eclipse.preferences.version=1
|
|
||||||
showIntro=false
|
|
||||||
-14
@@ -1,14 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
||||||
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
|
|
||||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
|
||||||
<listEntry value="/Minecraft/lib/net/minecraft/launchwrapper/1.8/launchwrapper-1.8.jar"/>
|
|
||||||
</listAttribute>
|
|
||||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
|
||||||
<listEntry value="1"/>
|
|
||||||
</listAttribute>
|
|
||||||
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="net.minecraft.launchwrapper.Launch"/>
|
|
||||||
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="--version 1.7 --tweakClass cpw.mods.fml.common.launcher.FMLTweaker --username=ForgeDevName --accessToken FML --userProperties={}"/>
|
|
||||||
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="Minecraft"/>
|
|
||||||
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xincgc -Xmx1024M -Xms1024M -Dfml.ignoreInvalidMinecraftCertificates=true"/>
|
|
||||||
<stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY" value="${workspace_loc}"/>
|
|
||||||
</launchConfiguration>
|
|
||||||
-13
@@ -1,13 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
||||||
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
|
|
||||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
|
||||||
<listEntry value="/Minecraft/src/net/minecraft/server/MinecraftServer.java"/>
|
|
||||||
</listAttribute>
|
|
||||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
|
||||||
<listEntry value="1"/>
|
|
||||||
</listAttribute>
|
|
||||||
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="cpw.mods.fml.relauncher.ServerLaunchWrapper"/>
|
|
||||||
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="Minecraft"/>
|
|
||||||
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xincgc -Xmx1024M -Xms1024M"/>
|
|
||||||
<stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY" value="${workspace_loc}"/>
|
|
||||||
</launchConfiguration>
|
|
||||||
-25
@@ -1,25 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
||||||
<launchHistory>
|
|
||||||
<launchGroup id="org.eclipse.ui.externaltools.launchGroup">
|
|
||||||
<mruHistory/>
|
|
||||||
<favorites/>
|
|
||||||
</launchGroup>
|
|
||||||
<launchGroup id="org.eclipse.debug.ui.launchGroup.profile">
|
|
||||||
<mruHistory/>
|
|
||||||
<favorites/>
|
|
||||||
</launchGroup>
|
|
||||||
<launchGroup id="org.eclipse.debug.ui.launchGroup.debug">
|
|
||||||
<mruHistory>
|
|
||||||
<launch memento="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <launchConfiguration local="true" path="Client"/> "/>
|
|
||||||
<launch memento="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <launchConfiguration local="true" path="Server"/> "/>
|
|
||||||
</mruHistory>
|
|
||||||
<favorites/>
|
|
||||||
</launchGroup>
|
|
||||||
<launchGroup id="org.eclipse.debug.ui.launchGroup.run">
|
|
||||||
<mruHistory>
|
|
||||||
<launch memento="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <launchConfiguration local="true" path="Client"/> "/>
|
|
||||||
<launch memento="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <launchConfiguration local="true" path="Server"/> "/>
|
|
||||||
</mruHistory>
|
|
||||||
<favorites/>
|
|
||||||
</launchGroup>
|
|
||||||
</launchHistory>
|
|
||||||
@@ -1,295 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
||||||
<profiles version="12">
|
|
||||||
<profile kind="CodeFormatterProfile" name="NOVA" version="12">
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_ellipsis" value="insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations" value="insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration" value="insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration" value="insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries" value="true"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters" value="insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package" value="insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_imports" value="1"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags" value="insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.comment.format_javadoc_comments" value="true"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.indentation.size" value="4"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments" value="insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments" value="insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration" value="insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for" value="insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.disabling_tag" value="@formatter:off"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.continuation_indentation" value="2"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_enum_constants" value="0"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_imports" value="1"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_package" value="1"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_binary_operator" value="insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations" value="insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant" value="0"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.comment.indent_root_tags" value="true"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch" value="true"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.enabling_tag" value="@formatter:on"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block" value="insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return" value="insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration" value="0"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line" value="false"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field" value="insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments" value="insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block" value="insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations" value="1"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer" value="insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method" value="insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration" value="insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column" value="false"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.compiler.problem.enumIdentifier" value="error"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter" value="insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits" value="insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_block" value="true"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration" value="end_of_line"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch" value="insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.comment.line_length" value="80"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.use_on_off_tags" value="false"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant" value="insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator" value="insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration" value="insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments" value="false"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable" value="insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_method_declaration" value="end_of_line"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch" value="0"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for" value="insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body" value="0"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line" value="false"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_binary_expression" value="0"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference" value="insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations" value="insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call" value="0"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header" value="true"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces" value="insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional" value="insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block" value="end_of_line"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration" value="end_of_line"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_lambda_body" value="end_of_line"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.compact_else_if" value="true"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch" value="insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line" value="true"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration" value="0"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments" value="insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation" value="0"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration" value="0"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.compiler.problem.assertIdentifier" value="error"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment" value="false"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try" value="insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment" value="false"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer" value="insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_binary_operator" value="insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_unary_operator" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer" value="0"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column" value="true"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve" value="1"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case" value="insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_ellipsis" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert" value="insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter" value="insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration" value="insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.comment.format_line_comments" value="true"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement" value="insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.align_type_members_on_columns" value="false"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_assignment" value="0"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body" value="insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header" value="true"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration" value="0"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration" value="0"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_conditional_expression" value="0"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line" value="false"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if" value="insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type" value="insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block" value="insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration" value="end_of_line"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block_in_case" value="end_of_line"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.comment.format_header" value="false"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression" value="0"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while" value="insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode" value="enabled"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_method_declaration" value="0"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.join_wrapped_lines" value="false"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases" value="true"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries" value="true"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration" value="end_of_line"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for" value="insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_resources_in_try" value="80"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations" value="false"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation" value="4"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column" value="false"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.compiler.source" value="1.8"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws" value="insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.tabulation.size" value="4"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant" value="insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression" value="insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional" value="insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.comment.format_source_code" value="true"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer" value="insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources" value="insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_field" value="0"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer" value="2"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_method" value="1"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration" value="0"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration" value="16"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw" value="insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.compiler.codegen.targetPlatform" value="1.8"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_switch" value="end_of_line"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters" value="insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer" value="insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.comment.format_html" value="true"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters" value="insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_compact_if" value="16"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.indent_empty_lines" value="false"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_unary_operator" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation" value="0"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line" value="false"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch" value="true"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator" value="insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk" value="1"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_label" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header" value="true"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional" value="insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert" value="insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_member_type" value="1"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression" value="0"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration" value="insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases" value="true"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.comment.format_block_comments" value="true"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow" value="insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line" value="false"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration" value="insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration" value="0"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws" value="insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_body" value="true"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_multiple_fields" value="16"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments" value="insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_array_initializer" value="end_of_line"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.wrap_before_binary_operator" value="true"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration" value="insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters" value="insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.compiler.compliance" value="1.8"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation" value="insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration" value="insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested" value="true"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast" value="insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_constant" value="end_of_line"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_type_declaration" value="end_of_line"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_package" value="0"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for" value="insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized" value="insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header" value="true"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow" value="insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration" value="insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.join_lines_in_comments" value="true"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional" value="insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.comment.indent_parameter_description" value="false"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.tabulation.char" value="tab"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_import_groups" value="1"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.lineSplit" value="80"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation" value="do not insert"/>
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch" value="insert"/>
|
|
||||||
</profile>
|
|
||||||
</profiles>
|
|
||||||
Binary file not shown.
@@ -1,6 +0,0 @@
|
|||||||
#Tue May 06 21:57:37 CEST 2014
|
|
||||||
distributionBase=GRADLE_USER_HOME
|
|
||||||
distributionPath=wrapper/dists
|
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
|
||||||
zipStorePath=wrapper/dists
|
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-1.12-bin.zip
|
|
||||||
@@ -1,495 +0,0 @@
|
|||||||
package minetweaker.api.minecraft;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import minetweaker.MineTweakerAPI;
|
|
||||||
import minetweaker.api.block.IBlock;
|
|
||||||
import minetweaker.api.block.IBlockDefinition;
|
|
||||||
import minetweaker.api.data.IData;
|
|
||||||
import minetweaker.api.item.IIngredient;
|
|
||||||
import minetweaker.api.item.IItemStack;
|
|
||||||
import minetweaker.api.item.IngredientUnknown;
|
|
||||||
import minetweaker.api.liquid.ILiquidStack;
|
|
||||||
import minetweaker.api.oredict.IOreDictEntry;
|
|
||||||
import minetweaker.api.player.IPlayer;
|
|
||||||
import minetweaker.api.world.IBiome;
|
|
||||||
import minetweaker.api.world.IDimension;
|
|
||||||
import minetweaker.mc1710.block.MCBlockDefinition;
|
|
||||||
import minetweaker.mc1710.block.MCSpecificBlock;
|
|
||||||
import minetweaker.mc1710.data.NBTConverter;
|
|
||||||
import minetweaker.mc1710.item.MCItemStack;
|
|
||||||
import minetweaker.mc1710.oredict.MCOreDictEntry;
|
|
||||||
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 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;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* MineTweaker - MineCraft API bridge.
|
|
||||||
*
|
|
||||||
* @author Stan Hebben
|
|
||||||
*/
|
|
||||||
public class MineTweakerMC {
|
|
||||||
private static final Map<Block, MCBlockDefinition> blockDefinitions = new HashMap<Block, MCBlockDefinition>();
|
|
||||||
public static final IBiome[] biomes;
|
|
||||||
|
|
||||||
static {
|
|
||||||
biomes = new IBiome[BiomeGenBase.getBiomeGenArray().length];
|
|
||||||
for (int i = 0; i < BiomeGenBase.getBiomeGenArray().length; i++) {
|
|
||||||
if (BiomeGenBase.getBiomeGenArray()[i] != null)
|
|
||||||
biomes[i] = new MCBiome(BiomeGenBase.getBiomeGenArray()[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private MineTweakerMC() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the Minecraft item for this MineTweaker item.
|
|
||||||
*
|
|
||||||
* @param item minetweaker item stack
|
|
||||||
* @return minecraft item stack
|
|
||||||
*/
|
|
||||||
public static ItemStack getItemStack(IItemStack item) {
|
|
||||||
if (item == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
Object internal = item.getInternal();
|
|
||||||
if (internal == null || !(internal instanceof ItemStack)) {
|
|
||||||
MineTweakerAPI.logError("Not a valid item stack: " + item);
|
|
||||||
}
|
|
||||||
return (ItemStack) internal;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the Minecraft ingredient for this ingredient. This method is only
|
|
||||||
* useful for ingredients that represent a single item stack.
|
|
||||||
*
|
|
||||||
* @param ingredient item ingredient
|
|
||||||
* @return minecraft item stack
|
|
||||||
*/
|
|
||||||
public static ItemStack getItemStack(IIngredient ingredient) {
|
|
||||||
if (ingredient == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
List<IItemStack> items = ingredient.getItems();
|
|
||||||
if (items.size() != 1) {
|
|
||||||
MineTweakerAPI.logError("Not an ingredient with a single item: " + ingredient);
|
|
||||||
}
|
|
||||||
return getItemStack(items.get(0));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the MineTweaker item stack for this item.
|
|
||||||
*
|
|
||||||
* @param item minecraft item stack
|
|
||||||
* @return minetweaker item stack
|
|
||||||
*/
|
|
||||||
public static IItemStack getIItemStack(ItemStack item) {
|
|
||||||
if (item == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
return new MCItemStack(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs an item stack with wildcard size.
|
|
||||||
*
|
|
||||||
* @param item minecraft item stack
|
|
||||||
* @return minetweaker stack
|
|
||||||
*/
|
|
||||||
public static IItemStack getIItemStackWildcardSize(ItemStack item) {
|
|
||||||
if (item == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
return new MCItemStack(item, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs an item stack with wildcard size.
|
|
||||||
*
|
|
||||||
* @param item
|
|
||||||
* @param meta
|
|
||||||
* @return minetweaker stack
|
|
||||||
*/
|
|
||||||
public static IItemStack getIItemStackWildcardSize(Item item, int meta) {
|
|
||||||
if (item == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
return new MCItemStack(new ItemStack(item, 1, meta), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs an item stack with wildcard damage.
|
|
||||||
*
|
|
||||||
* @param item stack item
|
|
||||||
* @param amount stack size
|
|
||||||
* @return minetweaker item stack
|
|
||||||
*/
|
|
||||||
public static IItemStack getIItemStackWildcard(Item item, int amount) {
|
|
||||||
if (item == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
return new MCItemStack(new ItemStack(item, 1, OreDictionary.WILDCARD_VALUE));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ItemStack[] getExamples(IIngredient ingredient) {
|
|
||||||
List<IItemStack> examples = ingredient.getItems();
|
|
||||||
ItemStack[] result = new ItemStack[examples.size()];
|
|
||||||
for (int i = 0; i < examples.size(); i++) {
|
|
||||||
result[i] = MineTweakerMC.getItemStack(examples.get(i));
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs an item stack with given item, damage and amount.
|
|
||||||
*
|
|
||||||
* @param item stack item
|
|
||||||
* @param damage stack damage
|
|
||||||
* @param amount stack amount
|
|
||||||
* @return minetweaker item stack
|
|
||||||
*/
|
|
||||||
public static IItemStack getItemStack(Item item, int amount, int damage) {
|
|
||||||
if (item == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
return new MCItemStack(new ItemStack(item, amount, damage));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts an array of minetweaker item stacks into an array of minecraft
|
|
||||||
* item stacks.
|
|
||||||
*
|
|
||||||
* @param items minetweker item stacks
|
|
||||||
* @return minecraft item stacks
|
|
||||||
*/
|
|
||||||
public static ItemStack[] getItemStacks(IItemStack... items) {
|
|
||||||
if (items == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
ItemStack[] output = new ItemStack[items.length];
|
|
||||||
for (int i = 0; i < items.length; i++) {
|
|
||||||
Object internal = items[i].getInternal();
|
|
||||||
if (internal != null && internal instanceof ItemStack) {
|
|
||||||
output[i] = (ItemStack) internal;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return output;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts a list of minetweaker item stacks into an array of minecraft
|
|
||||||
* item stacks.
|
|
||||||
*
|
|
||||||
* @param items minetweaker items
|
|
||||||
* @return minecraft items
|
|
||||||
*/
|
|
||||||
public static ItemStack[] getItemStacks(List<IItemStack> items) {
|
|
||||||
if (items == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
ItemStack[] output = new ItemStack[items.size()];
|
|
||||||
for (int i = 0; i < items.size(); i++) {
|
|
||||||
Object internal = items.get(i).getInternal();
|
|
||||||
if (internal != null && internal instanceof ItemStack) {
|
|
||||||
output[i] = (ItemStack) internal;
|
|
||||||
} else {
|
|
||||||
MineTweakerAPI.logError("Invalid item stack: " + items.get(i));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return output;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts an array of minecraft item stacks into an array of minetweaker
|
|
||||||
* item stacks.
|
|
||||||
*
|
|
||||||
* @param items minecraft item stacks
|
|
||||||
* @return minetweaker item stacks
|
|
||||||
*/
|
|
||||||
public static IItemStack[] getIItemStacks(ItemStack... items) {
|
|
||||||
if (items == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
IItemStack[] result = new IItemStack[items.length];
|
|
||||||
for (int i = 0; i < items.length; i++) {
|
|
||||||
result[i] = new MCItemStack(items[i]);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts a list of minecraft item stacks into an array of minetweaker
|
|
||||||
* item stacks.
|
|
||||||
*
|
|
||||||
* @param items minecraft item stacks
|
|
||||||
* @return minetweaker item stacks
|
|
||||||
*/
|
|
||||||
public static IItemStack[] getIItemStacks(List<ItemStack> items) {
|
|
||||||
if (items == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
IItemStack[] result = new IItemStack[items.size()];
|
|
||||||
for (int i = 0; i < result.length; i++) {
|
|
||||||
result[i] = new MCItemStack(items.get(i));
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the ore dictionary entry with the given name. If the entry didn't
|
|
||||||
* exist yet, it will create it and return an empty entry.
|
|
||||||
*
|
|
||||||
* @param name ore entry name
|
|
||||||
* @return ore dictionary entry
|
|
||||||
*/
|
|
||||||
public static IOreDictEntry getOreDict(String name) {
|
|
||||||
return new MCOreDictEntry(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts a Minecraft player into a MineTweaker player.
|
|
||||||
*
|
|
||||||
* @param player minecraft player
|
|
||||||
* @return minetweaker player
|
|
||||||
*/
|
|
||||||
public static IPlayer getIPlayer(EntityPlayer player) {
|
|
||||||
if (player == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
return new MCPlayer(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts a MineTweaker player into a Minecraft player.
|
|
||||||
*
|
|
||||||
* @param player minetweaker player
|
|
||||||
* @return minecraft player
|
|
||||||
*/
|
|
||||||
public static EntityPlayer getPlayer(IPlayer player) {
|
|
||||||
if (player == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
if (!(player instanceof MCPlayer)) {
|
|
||||||
MineTweakerAPI.logError("Invalid player: " + player);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ((MCPlayer) player).getInternal();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts a Minecraft NBT to an IData instance. The IData instance is
|
|
||||||
* immutable (not modifyiable).
|
|
||||||
*
|
|
||||||
* @param nbt nbt data
|
|
||||||
* @return IData value
|
|
||||||
*/
|
|
||||||
public static IData getIData(NBTBase nbt) {
|
|
||||||
if (nbt == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
return NBTConverter.from(nbt, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts a Minecraft NBT to a modifyable IData instance.
|
|
||||||
*
|
|
||||||
* @param nbt nbt data
|
|
||||||
* @return mutable IData value
|
|
||||||
*/
|
|
||||||
public static IData getIDataModifyable(NBTBase nbt) {
|
|
||||||
if (nbt == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
return NBTConverter.from(nbt, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts an IData instance to an NBT value.
|
|
||||||
*
|
|
||||||
* @param data IData value
|
|
||||||
* @return nbt data
|
|
||||||
*/
|
|
||||||
public static NBTBase getNBT(IData data) {
|
|
||||||
if (data == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
return NBTConverter.from(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts an IData instance to an NBT Tag compound.
|
|
||||||
*
|
|
||||||
* @param data IData value
|
|
||||||
* @return nbt compound data
|
|
||||||
*/
|
|
||||||
public static NBTTagCompound getNBTCompound(IData data) {
|
|
||||||
if (data == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
return (NBTTagCompound) NBTConverter.from(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves the block at the given position.
|
|
||||||
*
|
|
||||||
* @param blocks block access
|
|
||||||
* @param x block x position
|
|
||||||
* @param y block y position
|
|
||||||
* @param z block z position
|
|
||||||
* @return block instance
|
|
||||||
*/
|
|
||||||
public static IBlock getBlock(IBlockAccess blocks, int x, int y, int z) {
|
|
||||||
return new MCWorldBlock(blocks, x, y, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves the block definition for the given block.
|
|
||||||
*
|
|
||||||
* @param block block object
|
|
||||||
* @return block definition
|
|
||||||
*/
|
|
||||||
public static IBlockDefinition getBlockDefinition(Block block) {
|
|
||||||
if (!blockDefinitions.containsKey(block)) {
|
|
||||||
blockDefinitions.put(block, new MCBlockDefinition(block));
|
|
||||||
}
|
|
||||||
return blockDefinitions.get(block);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves the dimension instance for a given world.
|
|
||||||
*
|
|
||||||
* @param world world
|
|
||||||
* @return dimension
|
|
||||||
*/
|
|
||||||
public static IDimension getDimension(World world) {
|
|
||||||
if (world == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
return new MCDimension(world);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns an instance of the given block.
|
|
||||||
*
|
|
||||||
* @param block MC block definition
|
|
||||||
* @return MT block instance
|
|
||||||
*/
|
|
||||||
public static IBlock getBlockAnyMeta(Block block) {
|
|
||||||
return new MCSpecificBlock(block, OreDictionary.WILDCARD_VALUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns an instance of the given block.
|
|
||||||
*
|
|
||||||
* @param block MC block definition
|
|
||||||
* @param meta block meta value
|
|
||||||
* @return MT block instance
|
|
||||||
*/
|
|
||||||
public static IBlock getBlock(Block block, int meta) {
|
|
||||||
return new MCSpecificBlock(block, meta);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves the block from an item stack.
|
|
||||||
*
|
|
||||||
* @param itemStack
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static Block getBlock(IItemStack itemStack) {
|
|
||||||
return ((MCBlockDefinition) itemStack.asBlock().getDefinition()).getInternalBlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Block getBlock(IBlock block) {
|
|
||||||
return ((MCBlockDefinition) block.getDefinition()).getInternalBlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves the internal fluid stack of the given stack.
|
|
||||||
*
|
|
||||||
* @param stack MT liquid stack
|
|
||||||
* @return MCF fluid stack
|
|
||||||
*/
|
|
||||||
public static FluidStack getLiquidStack(ILiquidStack stack) {
|
|
||||||
if (stack == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
return (FluidStack) stack.getInternal();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts an array of MT liquid stacks into an array of MCF fluid stacks
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public static FluidStack[] getLiquidStacks(ILiquidStack[] stacks) {
|
|
||||||
if (stacks == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
FluidStack[] res = new FluidStack[stacks.length];
|
|
||||||
|
|
||||||
for (int i = 0; i < stacks.length; i++) {
|
|
||||||
ILiquidStack liquidStack = stacks[i];
|
|
||||||
res[i] = getLiquidStack(liquidStack);
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final HashMap<List, IOreDictEntry> oreDictArrays = new HashMap<List, IOreDictEntry>();
|
|
||||||
|
|
||||||
public static IOreDictEntry getOreDictEntryFromArray(List array) {
|
|
||||||
if (!oreDictArrays.containsKey(array)) {
|
|
||||||
for (String ore : OreDictionary.getOreNames()) {
|
|
||||||
if (OreDictionary.getOres(ore) == array) {
|
|
||||||
oreDictArrays.put(array, MineTweakerAPI.oreDict.get(ore));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return oreDictArrays.get(array);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts a Minecraft ingredient to a MineTweaker ingredient.
|
|
||||||
*
|
|
||||||
* @param ingredient minecraft ingredient
|
|
||||||
* @return minetweaker ingredient
|
|
||||||
*/
|
|
||||||
public static IIngredient getIIngredient(Object ingredient) {
|
|
||||||
if (ingredient == null) {
|
|
||||||
return null;
|
|
||||||
} else if (ingredient instanceof String) {
|
|
||||||
return MineTweakerAPI.oreDict.get((String) ingredient);
|
|
||||||
} else if (ingredient instanceof Item) {
|
|
||||||
return getIItemStack(new ItemStack((Item) ingredient, 1, 0));
|
|
||||||
} else if (ingredient instanceof ItemStack) {
|
|
||||||
return getIItemStack((ItemStack) ingredient);
|
|
||||||
} else if (ingredient instanceof List) {
|
|
||||||
IOreDictEntry entry = getOreDictEntryFromArray((List) ingredient);
|
|
||||||
|
|
||||||
if (entry == null) {
|
|
||||||
return IngredientUnknown.INSTANCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return entry;
|
|
||||||
} else if (ingredient instanceof FluidStack) {
|
|
||||||
return new MCLiquidStack((FluidStack) ingredient);
|
|
||||||
} else {
|
|
||||||
throw new IllegalArgumentException("Not a valid ingredient: " + ingredient);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,57 +0,0 @@
|
|||||||
package minetweaker.mc1710;
|
|
||||||
|
|
||||||
import minetweaker.MineTweakerAPI;
|
|
||||||
import minetweaker.MineTweakerImplementationAPI;
|
|
||||||
import minetweaker.api.event.PlayerCraftedEvent;
|
|
||||||
import minetweaker.api.event.PlayerLoggedInEvent;
|
|
||||||
import minetweaker.api.event.PlayerLoggedOutEvent;
|
|
||||||
import minetweaker.api.event.PlayerSmeltedEvent;
|
|
||||||
import minetweaker.api.minecraft.MineTweakerMC;
|
|
||||||
import minetweaker.api.player.IPlayer;
|
|
||||||
import minetweaker.mc1710.network.MineTweakerLoadScriptsPacket;
|
|
||||||
import minetweaker.mc1710.recipes.MCCraftingInventory;
|
|
||||||
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
|
|
||||||
*/
|
|
||||||
public class FMLEventHandler {
|
|
||||||
@SubscribeEvent
|
|
||||||
public void onPlayerLoggedIn(PlayerEvent.PlayerLoggedInEvent ev) {
|
|
||||||
if (ev.player instanceof EntityPlayerMP) {
|
|
||||||
EntityPlayerMP player = (EntityPlayerMP) ev.player;
|
|
||||||
MineTweakerMod.NETWORK.sendTo(new MineTweakerLoadScriptsPacket(MineTweakerAPI.tweaker.getScriptData()), player);
|
|
||||||
}
|
|
||||||
|
|
||||||
MineTweakerImplementationAPI.events.publishPlayerLoggedIn(new PlayerLoggedInEvent(MineTweakerMC.getIPlayer(ev.player)));
|
|
||||||
}
|
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public void onPlayerItemCrafted(PlayerEvent.ItemCraftedEvent ev) {
|
|
||||||
IPlayer iPlayer = MineTweakerMC.getIPlayer(ev.player);
|
|
||||||
if (MCRecipeManager.hasTransformerRecipes()) {
|
|
||||||
MCRecipeManager.applyTransformations(MCCraftingInventory.get(ev.craftMatrix, ev.player), iPlayer);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (MineTweakerImplementationAPI.events.hasPlayerCrafted()) {
|
|
||||||
MineTweakerImplementationAPI.events.publishPlayerCrafted(new PlayerCraftedEvent(iPlayer, MineTweakerMC.getIItemStack(ev.crafting), MCCraftingInventory.get(ev.craftMatrix, ev.player)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public void onPlayerItemSmelted(PlayerEvent.ItemSmeltedEvent ev) {
|
|
||||||
if (MineTweakerImplementationAPI.events.hasPlayerSmelted()) {
|
|
||||||
MineTweakerImplementationAPI.events.publishPlayerSmelted(new PlayerSmeltedEvent(MineTweakerMC.getIPlayer(ev.player), MineTweakerMC.getIItemStack(ev.smelting)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public void onPlayerLoggedOut(PlayerEvent.PlayerLoggedOutEvent ev) {
|
|
||||||
MineTweakerImplementationAPI.events.publishPlayerLoggedOut(new PlayerLoggedOutEvent(MineTweakerMC.getIPlayer(ev.player)));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,111 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package minetweaker.mc1710;
|
|
||||||
|
|
||||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
|
||||||
import minetweaker.*;
|
|
||||||
import minetweaker.api.entity.*;
|
|
||||||
import minetweaker.api.formatting.IFormattedText;
|
|
||||||
import minetweaker.api.item.IItemStack;
|
|
||||||
import minetweaker.api.minecraft.MineTweakerMC;
|
|
||||||
import minetweaker.api.tooltip.IngredientTooltips;
|
|
||||||
import minetweaker.mc1710.formatting.IMCFormattedString;
|
|
||||||
import minetweaker.mc1710.item.*;
|
|
||||||
import net.minecraft.entity.*;
|
|
||||||
import net.minecraft.entity.item.*;
|
|
||||||
import net.minecraft.entity.player.*;
|
|
||||||
import net.minecraft.item.*;
|
|
||||||
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 java.util.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class ForgeEventHandler {
|
|
||||||
@SubscribeEvent
|
|
||||||
public void onPlayerInteract(PlayerInteractEvent ev) {
|
|
||||||
minetweaker.api.event.PlayerInteractEvent event = new minetweaker.api.event.PlayerInteractEvent(
|
|
||||||
MineTweakerMC.getIPlayer(ev.entityPlayer),
|
|
||||||
MineTweakerMC.getDimension(ev.world),
|
|
||||||
ev.x, ev.y, ev.z
|
|
||||||
);
|
|
||||||
|
|
||||||
MineTweakerImplementationAPI.events.publishPlayerInteract(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public void onItemTooltip(ItemTooltipEvent ev) {
|
|
||||||
if(ev.itemStack!= null) {
|
|
||||||
IItemStack itemStack = MineTweakerMC.getIItemStack(ev.itemStack);
|
|
||||||
for(IFormattedText tooltip : IngredientTooltips.getTooltips(itemStack)) {
|
|
||||||
ev.toolTip.add(((IMCFormattedString) tooltip).getTooltipString());
|
|
||||||
}
|
|
||||||
|
|
||||||
if(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) {
|
|
||||||
for(IFormattedText tooltip : IngredientTooltips.getShiftTooltips(itemStack)) {
|
|
||||||
ev.toolTip.add(((IMCFormattedString) tooltip).getTooltipString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public void onLivingDeathDrops(LivingDropsEvent ev) {
|
|
||||||
final EntityLivingBase entity = ev.entityLiving;
|
|
||||||
final IEntityDefinition iEntity = MineTweakerAPI.game.getEntity(EntityList.getEntityString(entity));
|
|
||||||
if(iEntity == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!iEntity.getDropsToAdd().isEmpty()) {
|
|
||||||
for(Map.Entry<IItemStack, IntRange> dropToAdd : iEntity.getDropsToAdd().entrySet()) {
|
|
||||||
final IItemStack key = dropToAdd.getKey();
|
|
||||||
final IntRange val = dropToAdd.getValue();
|
|
||||||
|
|
||||||
final EntityItem item;
|
|
||||||
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());
|
|
||||||
} 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());
|
|
||||||
}
|
|
||||||
ev.drops.add(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!iEntity.getDropsToAddPlayerOnly().isEmpty() && ev.source.getEntity() instanceof EntityPlayer) {
|
|
||||||
for(Map.Entry<IItemStack, IntRange> dropToAdd : iEntity.getDropsToAddPlayerOnly().entrySet()) {
|
|
||||||
final IItemStack key = dropToAdd.getKey();
|
|
||||||
final IntRange val = dropToAdd.getValue();
|
|
||||||
|
|
||||||
final EntityItem item;
|
|
||||||
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());
|
|
||||||
} 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());
|
|
||||||
}
|
|
||||||
ev.drops.add(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!iEntity.getDropsToRemove().isEmpty()) {
|
|
||||||
for(IItemStack iItemStack : iEntity.getDropsToRemove()) {
|
|
||||||
for(Iterator<EntityItem> iterator = ev.drops.iterator(); iterator.hasNext(); ) {
|
|
||||||
EntityItem drop = iterator.next();
|
|
||||||
if(iItemStack.matches(new MCItemStack(drop.getEntityItem()))) {
|
|
||||||
iterator.remove();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,60 +0,0 @@
|
|||||||
package minetweaker.mc1710;
|
|
||||||
|
|
||||||
import net.minecraft.client.gui.GuiButton;
|
|
||||||
import net.minecraft.client.gui.GuiScreen;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This screen is shown when a client has been modified with a permanent
|
|
||||||
* modification and the player logs into a game with a different script. It asks
|
|
||||||
* the player to restart the game.
|
|
||||||
*
|
|
||||||
* @author Stan Hebben
|
|
||||||
*/
|
|
||||||
public class GuiCannotRemodify extends GuiScreen {
|
|
||||||
private final String message1;
|
|
||||||
private final String message2;
|
|
||||||
private final String message3;
|
|
||||||
|
|
||||||
public GuiCannotRemodify(String message1, String message2, String message3) {
|
|
||||||
this.message1 = message1;
|
|
||||||
this.message2 = message2;
|
|
||||||
this.message3 = message3;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void initGui() {
|
|
||||||
this.buttonList.clear();
|
|
||||||
this.buttonList.add(
|
|
||||||
new GuiButton(0, this.width / 2 - 100, this.height / 4 + 120 + 12, "Close")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void drawScreen(int par1, int par2, float par3) {
|
|
||||||
this.drawDefaultBackground();
|
|
||||||
this.drawCenteredString(
|
|
||||||
this.fontRendererObj,
|
|
||||||
message1,
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void actionPerformed(GuiButton par1GuiButton) {
|
|
||||||
if (par1GuiButton.id == 0) {
|
|
||||||
System.exit(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package minetweaker.mc1710;
|
|
||||||
|
|
||||||
import minetweaker.IPlatformFunctions;
|
|
||||||
import minetweaker.api.chat.IChatMessage;
|
|
||||||
import minetweaker.api.item.IItemDefinition;
|
|
||||||
|
|
||||||
import minetweaker.mc1710.item.MCItemDefinition;
|
|
||||||
import minetweaker.mc1710.network.MineTweakerLoadScriptsPacket;
|
|
||||||
import minetweaker.mc1710.chat.MCChatMessage;
|
|
||||||
import net.minecraft.item.Item;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class MCPlatformFunctions implements IPlatformFunctions {
|
|
||||||
public static final MCPlatformFunctions INSTANCE = new MCPlatformFunctions();
|
|
||||||
|
|
||||||
private MCPlatformFunctions() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IChatMessage getMessage(String message) {
|
|
||||||
return new MCChatMessage(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void distributeScripts(byte[] data) {
|
|
||||||
MineTweakerMod.NETWORK.sendToAll(new MineTweakerLoadScriptsPacket(data));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IItemDefinition getItemDefinition(int id) {
|
|
||||||
Item item = Item.getItemById(id);
|
|
||||||
if (item == null)
|
|
||||||
return null;
|
|
||||||
String sid = Item.itemRegistry.getNameForObject(item);
|
|
||||||
return new MCItemDefinition(sid, item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,184 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package minetweaker.mc1710;
|
|
||||||
|
|
||||||
import cpw.mods.fml.common.FMLCommonHandler;
|
|
||||||
import cpw.mods.fml.common.Mod;
|
|
||||||
import cpw.mods.fml.common.Mod.EventHandler;
|
|
||||||
import cpw.mods.fml.common.event.*;
|
|
||||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
|
||||||
import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper;
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
|
||||||
import minetweaker.MineTweakerAPI;
|
|
||||||
import minetweaker.MineTweakerImplementationAPI;
|
|
||||||
import minetweaker.api.logger.FileLogger;
|
|
||||||
import minetweaker.mc1710.brackets.ItemBracketHandler;
|
|
||||||
import minetweaker.mc1710.brackets.LiquidBracketHandler;
|
|
||||||
import minetweaker.mc1710.client.MCClient;
|
|
||||||
import minetweaker.mc1710.formatting.MCFormatter;
|
|
||||||
import minetweaker.mc1710.furnace.FuelTweaker;
|
|
||||||
import minetweaker.mc1710.furnace.MCFurnaceManager;
|
|
||||||
import minetweaker.mc1710.game.MCGame;
|
|
||||||
import minetweaker.mc1710.mods.MCLoadedMods;
|
|
||||||
import minetweaker.mc1710.network.*;
|
|
||||||
import minetweaker.mc1710.oredict.MCOreDict;
|
|
||||||
import minetweaker.mc1710.recipes.MCRecipeManager;
|
|
||||||
import minetweaker.mc1710.server.MCServer;
|
|
||||||
import minetweaker.mc1710.util.MineTweakerHacks;
|
|
||||||
import minetweaker.mc1710.util.MineTweakerPlatformUtils;
|
|
||||||
import minetweaker.mc1710.vanilla.MCVanilla;
|
|
||||||
import minetweaker.runtime.*;
|
|
||||||
import minetweaker.runtime.providers.ScriptProviderCascade;
|
|
||||||
import minetweaker.runtime.providers.ScriptProviderCustom;
|
|
||||||
import minetweaker.runtime.providers.ScriptProviderDirectory;
|
|
||||||
import net.minecraft.item.crafting.CraftingManager;
|
|
||||||
import net.minecraft.item.crafting.IRecipe;
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Main mod class. Performs some general logic, initialization of the API and
|
|
||||||
* FML event handling.
|
|
||||||
*
|
|
||||||
* @author Stan Hebben
|
|
||||||
*/
|
|
||||||
@Mod(modid = MineTweakerMod.MODID, version = "3.1.0")
|
|
||||||
public class MineTweakerMod {
|
|
||||||
public static final String MODID = "MineTweaker3";
|
|
||||||
public static final String MCVERSION = "1.7.10";
|
|
||||||
|
|
||||||
public static final SimpleNetworkWrapper NETWORK = NetworkRegistry.INSTANCE.newSimpleChannel(MODID);
|
|
||||||
|
|
||||||
private static final String[] REGISTRIES = {
|
|
||||||
"minetweaker.mods.ic2.ClassRegistry",
|
|
||||||
"minetweaker.mods.nei.ClassRegistry",
|
|
||||||
"minetweaker.mods.mfr.ClassRegistry",
|
|
||||||
"minetweaker.mods.gregtech.ClassRegistry",
|
|
||||||
"minetweaker.mods.buildcraft.ClassRegistry"
|
|
||||||
};
|
|
||||||
private static final String[] REGISTRY_DESCRIPTIONS = {
|
|
||||||
"IC2 mod support",
|
|
||||||
"NEI mod support",
|
|
||||||
"MFR mod support",
|
|
||||||
"GregTech mod support",
|
|
||||||
"Buildcraft mod support"
|
|
||||||
};
|
|
||||||
|
|
||||||
static {
|
|
||||||
NETWORK.registerMessage(MineTweakerLoadScriptsHandler.class, MineTweakerLoadScriptsPacket.class, 0, Side.CLIENT);
|
|
||||||
NETWORK.registerMessage(MineTweakerOpenBrowserHandler.class, MineTweakerOpenBrowserPacket.class, 1, Side.CLIENT);
|
|
||||||
NETWORK.registerMessage(MineTweakerCopyClipboardHandler.class, MineTweakerCopyClipboardPacket.class, 2, Side.CLIENT);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Mod.Instance(MODID)
|
|
||||||
public static MineTweakerMod INSTANCE;
|
|
||||||
|
|
||||||
private final IScriptProvider scriptsGlobal;
|
|
||||||
private final ScriptProviderCustom scriptsIMC;
|
|
||||||
|
|
||||||
public MineTweakerMod() {
|
|
||||||
MCRecipeManager.recipes = (List<IRecipe>) CraftingManager.getInstance().getRecipeList();
|
|
||||||
MineTweakerImplementationAPI.init(
|
|
||||||
new MCOreDict(),
|
|
||||||
new MCRecipeManager(),
|
|
||||||
new MCFurnaceManager(),
|
|
||||||
MCGame.INSTANCE,
|
|
||||||
new MCLoadedMods(),
|
|
||||||
new MCFormatter(),
|
|
||||||
new MCVanilla());
|
|
||||||
|
|
||||||
|
|
||||||
MineTweakerImplementationAPI.logger.addLogger(new FileLogger(new File("minetweaker.log")));
|
|
||||||
MineTweakerImplementationAPI.platform = MCPlatformFunctions.INSTANCE;
|
|
||||||
|
|
||||||
File globalDir = new File("scripts");
|
|
||||||
if (!globalDir.exists())
|
|
||||||
globalDir.mkdirs();
|
|
||||||
|
|
||||||
scriptsIMC = new ScriptProviderCustom("intermod");
|
|
||||||
scriptsGlobal = new ScriptProviderDirectory(globalDir);
|
|
||||||
MineTweakerImplementationAPI.setScriptProvider(scriptsGlobal);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ##########################
|
|
||||||
// ### FML Event Handlers ###
|
|
||||||
// ##########################
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onIMCEvent(FMLInterModComms.IMCEvent event) {
|
|
||||||
for (final FMLInterModComms.IMCMessage imcMessage : event.getMessages()) {
|
|
||||||
if (imcMessage.key.equalsIgnoreCase("addMineTweakerScript")) {
|
|
||||||
if (imcMessage.isStringMessage()) {
|
|
||||||
scriptsIMC.add(imcMessage.getSender() + "::imc", imcMessage.getStringValue());
|
|
||||||
} else if (imcMessage.isNBTMessage()) {
|
|
||||||
NBTTagCompound message = imcMessage.getNBTValue();
|
|
||||||
scriptsIMC.add(imcMessage.getSender() + "::" + message.getString("name"), message.getString("content"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onLoad(FMLPreInitializationEvent ev) {
|
|
||||||
MinecraftForge.EVENT_BUS.register(new ForgeEventHandler());
|
|
||||||
FMLCommonHandler.instance().bus().register(new FMLEventHandler());
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onPostInit(FMLPostInitializationEvent ev) {
|
|
||||||
MineTweakerAPI.registerClassRegistry(MineTweakerRegistry.class);
|
|
||||||
|
|
||||||
for (int i = 0; i < REGISTRIES.length; i++) {
|
|
||||||
MineTweakerAPI.registerClassRegistry(REGISTRIES[i], REGISTRY_DESCRIPTIONS[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
FuelTweaker.INSTANCE.register();
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onComplete(FMLLoadCompleteEvent ev) {
|
|
||||||
MineTweakerAPI.logInfo("MineTweaker: Building registry");
|
|
||||||
ItemBracketHandler.rebuildItemRegistry();
|
|
||||||
LiquidBracketHandler.rebuildLiquidRegistry();
|
|
||||||
MineTweakerAPI.logInfo("MineTweaker: Sucessfully built item registry");
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onServerAboutToStart(FMLServerAboutToStartEvent ev) {
|
|
||||||
// starts before loading worlds
|
|
||||||
// perfect place to start MineTweaker!
|
|
||||||
|
|
||||||
if (MineTweakerPlatformUtils.isClient()) {
|
|
||||||
MineTweakerAPI.client = new MCClient();
|
|
||||||
}
|
|
||||||
|
|
||||||
File scriptsDir = new File(MineTweakerHacks.getWorldDirectory(ev.getServer()), "scripts");
|
|
||||||
if (!scriptsDir.exists()) {
|
|
||||||
scriptsDir.mkdir();
|
|
||||||
}
|
|
||||||
|
|
||||||
IScriptProvider scriptsLocal = new ScriptProviderDirectory(scriptsDir);
|
|
||||||
IScriptProvider cascaded = new ScriptProviderCascade(scriptsIMC, scriptsGlobal,scriptsLocal);
|
|
||||||
|
|
||||||
MineTweakerImplementationAPI.setScriptProvider(cascaded);
|
|
||||||
MineTweakerImplementationAPI.onServerStart(new MCServer(ev.getServer()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onServerStarting(FMLServerStartingEvent ev) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onServerStopped(FMLServerStoppedEvent ev) {
|
|
||||||
MineTweakerImplementationAPI.onServerStop();
|
|
||||||
MineTweakerImplementationAPI.setScriptProvider(scriptsGlobal);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package minetweaker.mc1710;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class MineTweakerRegistry {
|
|
||||||
public static void getClasses(List<Class> classes) {
|
|
||||||
// method stub, actual content is generated by build process
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-61
@@ -1,61 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package minetweaker.mc1710.actions;
|
|
||||||
|
|
||||||
import minetweaker.IUndoableAction;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Jared
|
|
||||||
*/
|
|
||||||
public class SetStackSizeAction implements IUndoableAction {
|
|
||||||
|
|
||||||
private final ItemStack stack;
|
|
||||||
private final int size;
|
|
||||||
private final int oldSize;
|
|
||||||
|
|
||||||
public SetStackSizeAction(ItemStack stack, int size) {
|
|
||||||
this.stack = stack;
|
|
||||||
this.size = size;
|
|
||||||
this.oldSize = stack.getMaxStackSize();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void apply() {
|
|
||||||
set(stack, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canUndo() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void undo() {
|
|
||||||
set(stack, oldSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describe() {
|
|
||||||
return "Setting max stack size of " + stack.getDisplayName() + " to " + size;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describeUndo() {
|
|
||||||
return "Reverting max stack size of " + stack.getDisplayName() + " to " + oldSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void set(ItemStack stack, int size) {
|
|
||||||
stack.getItem().setMaxStackSize(size);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getOverrideKey() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-61
@@ -1,61 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package minetweaker.mc1710.actions;
|
|
||||||
|
|
||||||
import minetweaker.IUndoableAction;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Jared
|
|
||||||
*/
|
|
||||||
public class SetStackmaxDamageAction implements IUndoableAction {
|
|
||||||
|
|
||||||
private final ItemStack stack;
|
|
||||||
private final int damage;
|
|
||||||
private final int oldDamage;
|
|
||||||
|
|
||||||
public SetStackmaxDamageAction(ItemStack stack, int damage) {
|
|
||||||
this.stack = stack;
|
|
||||||
this.damage= damage;
|
|
||||||
this.oldDamage= stack.getMaxDamage();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void apply() {
|
|
||||||
set(stack, damage);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canUndo() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void undo() {
|
|
||||||
set(stack, oldDamage);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describe() {
|
|
||||||
return "Setting max damage of " + stack.getDisplayName() + " to " + damage;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describeUndo() {
|
|
||||||
return "Reverting max damage of " + stack.getDisplayName() + " to " + oldDamage;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void set(ItemStack stack, int damage) {
|
|
||||||
stack.getItem().setMaxDamage(damage);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getOverrideKey() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-69
@@ -1,69 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package minetweaker.mc1710.actions;
|
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.nio.charset.Charset;
|
|
||||||
import minetweaker.IUndoableAction;
|
|
||||||
import minetweaker.mc1710.util.MineTweakerHacks;
|
|
||||||
import net.minecraft.util.StringTranslate;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class SetTranslationAction implements IUndoableAction {
|
|
||||||
private static final StringTranslate INSTANCE = MineTweakerHacks.getStringTranslateInstance();
|
|
||||||
private static final Charset UTF8 = Charset.forName("utf-8");
|
|
||||||
|
|
||||||
private final String key;
|
|
||||||
private final String newValue;
|
|
||||||
private final String oldValue;
|
|
||||||
|
|
||||||
public SetTranslationAction(String key, String value) {
|
|
||||||
this.key = key;
|
|
||||||
newValue = value;
|
|
||||||
oldValue = INSTANCE.translateKey(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void apply() {
|
|
||||||
set(key, newValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canUndo() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void undo() {
|
|
||||||
set(key, oldValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describe() {
|
|
||||||
return "Translating " + key + " to " + newValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describeUndo() {
|
|
||||||
return "Reverting " + key + " to " + oldValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void set(String key, String value) {
|
|
||||||
if (value.contains("\\\"")) {
|
|
||||||
value = value.replace("\\\"", "\"");
|
|
||||||
}
|
|
||||||
StringTranslate.inject(new ByteArrayInputStream((key + "=" + value).getBytes(UTF8)));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getOverrideKey() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-36
@@ -1,36 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package minetweaker.mc1710.block;
|
|
||||||
|
|
||||||
import minetweaker.api.block.IBlockDefinition;
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class MCBlockDefinition implements IBlockDefinition {
|
|
||||||
private final Block block;
|
|
||||||
|
|
||||||
public MCBlockDefinition(Block block) {
|
|
||||||
this.block = block;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Block getInternalBlock() {
|
|
||||||
return block;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getId() {
|
|
||||||
return Block.blockRegistry.getNameForObject(block);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getDisplayName() {
|
|
||||||
return block.getLocalizedName();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,71 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package minetweaker.mc1710.block;
|
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import minetweaker.api.block.BlockPatternOr;
|
|
||||||
import minetweaker.api.block.IBlock;
|
|
||||||
import minetweaker.api.block.IBlockDefinition;
|
|
||||||
import minetweaker.api.block.IBlockPattern;
|
|
||||||
import minetweaker.api.data.IData;
|
|
||||||
import minetweaker.api.minecraft.MineTweakerMC;
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraftforge.oredict.OreDictionary;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class MCItemBlock implements IBlock {
|
|
||||||
private final ItemStack item;
|
|
||||||
|
|
||||||
public MCItemBlock(ItemStack item) {
|
|
||||||
this.item = item;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IBlockDefinition getDefinition() {
|
|
||||||
return MineTweakerMC.getBlockDefinition(Block.getBlockFromItem(item.getItem()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getMeta() {
|
|
||||||
return item.getItemDamage();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IData getTileData() {
|
|
||||||
if (item.stackTagCompound == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
return MineTweakerMC.getIData(item.stackTagCompound);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getDisplayName() {
|
|
||||||
return item.getDisplayName();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<IBlock> getBlocks() {
|
|
||||||
return Collections.<IBlock>singletonList(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean matches(IBlock block) {
|
|
||||||
return getDefinition() == block.getDefinition()
|
|
||||||
&& (getMeta() == OreDictionary.WILDCARD_VALUE || getMeta() == block.getMeta())
|
|
||||||
&& (getTileData() == null || (block.getTileData() != null && block.getTileData().contains(getTileData())));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IBlockPattern or(IBlockPattern pattern) {
|
|
||||||
return new BlockPatternOr(this, pattern);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,78 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package minetweaker.mc1710.block;
|
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import minetweaker.api.block.BlockPatternOr;
|
|
||||||
import minetweaker.api.block.IBlock;
|
|
||||||
import minetweaker.api.block.IBlockDefinition;
|
|
||||||
import minetweaker.api.block.IBlockPattern;
|
|
||||||
import minetweaker.api.data.IData;
|
|
||||||
import minetweaker.api.minecraft.MineTweakerMC;
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraftforge.oredict.OreDictionary;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class MCSpecificBlock implements IBlock {
|
|
||||||
private final Block block;
|
|
||||||
private final int meta;
|
|
||||||
|
|
||||||
public MCSpecificBlock(Block block, int meta) {
|
|
||||||
this.block = block;
|
|
||||||
this.meta = meta;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IBlockDefinition getDefinition() {
|
|
||||||
return MineTweakerMC.getBlockDefinition(block);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getMeta() {
|
|
||||||
return meta;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IData getTileData() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<IBlock> getBlocks() {
|
|
||||||
return Collections.<IBlock>singletonList(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean matches(IBlock block) {
|
|
||||||
return block.getDefinition() == getDefinition()
|
|
||||||
&& (meta == OreDictionary.WILDCARD_VALUE || block.getMeta() == meta);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IBlockPattern or(IBlockPattern pattern) {
|
|
||||||
return new BlockPatternOr(this, pattern);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getDisplayName() {
|
|
||||||
return block.getLocalizedName();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "<block:" + getBlockId(block) + ":" + (meta == OreDictionary.WILDCARD_VALUE ? '*' : meta) + ">";
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String getBlockId(Block block)
|
|
||||||
{
|
|
||||||
return Block.blockRegistry.getNameForObject(block);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,91 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package minetweaker.mc1710.block;
|
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import minetweaker.api.block.BlockPatternOr;
|
|
||||||
import minetweaker.api.block.IBlock;
|
|
||||||
import minetweaker.api.block.IBlockDefinition;
|
|
||||||
import minetweaker.api.block.IBlockPattern;
|
|
||||||
import minetweaker.api.data.IData;
|
|
||||||
import minetweaker.api.minecraft.MineTweakerMC;
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.item.Item;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraft.world.IBlockAccess;
|
|
||||||
import net.minecraftforge.oredict.OreDictionary;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class MCWorldBlock implements IBlock {
|
|
||||||
private final IBlockAccess blocks;
|
|
||||||
private final int x;
|
|
||||||
private final int y;
|
|
||||||
private final int z;
|
|
||||||
|
|
||||||
public MCWorldBlock(IBlockAccess blocks, int x, int y, int z) {
|
|
||||||
this.blocks = blocks;
|
|
||||||
this.x = x;
|
|
||||||
this.y = y;
|
|
||||||
this.z = z;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IBlockDefinition getDefinition() {
|
|
||||||
return MineTweakerMC.getBlockDefinition(blocks.getBlock(x, y, z));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getMeta() {
|
|
||||||
return blocks.getBlockMetadata(x, y, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IData getTileData() {
|
|
||||||
TileEntity tileEntity = blocks.getTileEntity(x, y, z);
|
|
||||||
|
|
||||||
if (tileEntity == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
NBTTagCompound nbt = new NBTTagCompound();
|
|
||||||
tileEntity.writeToNBT(nbt);
|
|
||||||
return MineTweakerMC.getIData(nbt);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getDisplayName() {
|
|
||||||
Block block = blocks.getBlock(x, y, z);
|
|
||||||
Item item = Item.getItemFromBlock(block);
|
|
||||||
if (item != null) {
|
|
||||||
return (new ItemStack(item, 1, getMeta())).getDisplayName();
|
|
||||||
} else {
|
|
||||||
return block.getLocalizedName();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<IBlock> getBlocks() {
|
|
||||||
return Collections.<IBlock>singletonList(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean matches(IBlock block) {
|
|
||||||
return getDefinition() == block.getDefinition()
|
|
||||||
&& (getMeta() == OreDictionary.WILDCARD_VALUE || getMeta() == block.getMeta())
|
|
||||||
&& (getTileData() == null || (block.getTileData() != null && block.getTileData().contains(getTileData())));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IBlockPattern or(IBlockPattern pattern) {
|
|
||||||
return new BlockPatternOr(this, pattern);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-143
@@ -1,143 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package minetweaker.mc1710.brackets;
|
|
||||||
|
|
||||||
import static minetweaker.api.minecraft.MineTweakerMC.getIItemStackWildcardSize;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import minetweaker.IBracketHandler;
|
|
||||||
import minetweaker.MineTweakerAPI;
|
|
||||||
import minetweaker.annotations.BracketHandler;
|
|
||||||
import minetweaker.api.item.IItemStack;
|
|
||||||
import minetweaker.api.item.IngredientAny;
|
|
||||||
import net.minecraft.item.Item;
|
|
||||||
import net.minecraftforge.oredict.OreDictionary;
|
|
||||||
import stanhebben.zenscript.ZenTokener;
|
|
||||||
import stanhebben.zenscript.compiler.IEnvironmentGlobal;
|
|
||||||
import stanhebben.zenscript.expression.ExpressionCallStatic;
|
|
||||||
import stanhebben.zenscript.expression.ExpressionInt;
|
|
||||||
import stanhebben.zenscript.expression.ExpressionString;
|
|
||||||
import stanhebben.zenscript.expression.partial.IPartialExpression;
|
|
||||||
import stanhebben.zenscript.parser.Token;
|
|
||||||
import stanhebben.zenscript.symbols.IZenSymbol;
|
|
||||||
import stanhebben.zenscript.type.ZenType;
|
|
||||||
import stanhebben.zenscript.type.natives.IJavaMethod;
|
|
||||||
import stanhebben.zenscript.util.ZenPosition;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
@BracketHandler(priority = 100)
|
|
||||||
public class ItemBracketHandler implements IBracketHandler {
|
|
||||||
private static final Map<String, Item> itemNames = new HashMap<String, Item>();
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public static void rebuildItemRegistry()
|
|
||||||
{
|
|
||||||
itemNames.clear();
|
|
||||||
|
|
||||||
for (String itemName : (Set<String>) Item.itemRegistry.getKeys()) {
|
|
||||||
itemNames.put(itemName.replace(" ", "").replace("'", ""), (Item) Item.itemRegistry.getObject(itemName));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IItemStack getItem(String name, int meta) {
|
|
||||||
// Item item = (Item) Item.itemRegistry.getObject(name);
|
|
||||||
Item item = itemNames.get(name);
|
|
||||||
if (item != null) {
|
|
||||||
return getIItemStackWildcardSize(item, meta);
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private final IZenSymbol symbolAny;
|
|
||||||
private final IJavaMethod method;
|
|
||||||
|
|
||||||
public ItemBracketHandler() {
|
|
||||||
symbolAny = MineTweakerAPI.getJavaStaticFieldSymbol(IngredientAny.class, "INSTANCE");
|
|
||||||
method = MineTweakerAPI.getJavaMethod(
|
|
||||||
ItemBracketHandler.class,
|
|
||||||
"getItem",
|
|
||||||
String.class, int.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IZenSymbol resolve(IEnvironmentGlobal environment, List<Token> tokens) {
|
|
||||||
// any symbol
|
|
||||||
if (tokens.size() == 1 && tokens.get(0).getValue().equals("*")) {
|
|
||||||
return symbolAny;
|
|
||||||
}
|
|
||||||
|
|
||||||
// detect special cases:
|
|
||||||
// item: at the start means item-specific syntax
|
|
||||||
// :xxx with xxx an integer means sub-item syntax
|
|
||||||
// :* means any-subitem-syntax
|
|
||||||
int fromIndex = 0;
|
|
||||||
int toIndex = tokens.size();
|
|
||||||
int meta = 0;
|
|
||||||
|
|
||||||
if (tokens.size() > 2) {
|
|
||||||
if (tokens.get(0).getValue().equals("item") && tokens.get(1).getValue().equals(":")) {
|
|
||||||
fromIndex = 2;
|
|
||||||
}
|
|
||||||
if (tokens.get(tokens.size() - 1).getType() == ZenTokener.T_INTVALUE
|
|
||||||
&& tokens.get(tokens.size() - 2).getValue().equals(":")) {
|
|
||||||
toIndex = tokens.size() - 2;
|
|
||||||
meta = Integer.parseInt(tokens.get(tokens.size() - 1).getValue());
|
|
||||||
} else if (tokens.get(tokens.size() - 1).getValue().equals("*")
|
|
||||||
&& tokens.get(tokens.size() - 2).getValue().equals(":")) {
|
|
||||||
toIndex = tokens.size() - 2;
|
|
||||||
meta = OreDictionary.WILDCARD_VALUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return find(environment, tokens, fromIndex, toIndex, meta);
|
|
||||||
}
|
|
||||||
|
|
||||||
private IZenSymbol find(IEnvironmentGlobal environment, List<Token> tokens, int startIndex, int endIndex, int meta) {
|
|
||||||
StringBuilder valueBuilder = new StringBuilder();
|
|
||||||
for (int i = startIndex; i < endIndex; i++) {
|
|
||||||
Token token = tokens.get(i);
|
|
||||||
valueBuilder.append(token.getValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
String itemName = valueBuilder.toString();
|
|
||||||
if (itemNames.containsKey(itemName)) {
|
|
||||||
return new ItemReferenceSymbol(environment, itemName, meta);
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private class ItemReferenceSymbol implements IZenSymbol {
|
|
||||||
private final IEnvironmentGlobal environment;
|
|
||||||
private final String name;
|
|
||||||
private final int meta;
|
|
||||||
|
|
||||||
public ItemReferenceSymbol(IEnvironmentGlobal environment, String name, int meta) {
|
|
||||||
this.environment = environment;
|
|
||||||
this.name = name;
|
|
||||||
this.meta = meta;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IPartialExpression instance(ZenPosition position) {
|
|
||||||
return new ExpressionCallStatic(
|
|
||||||
position,
|
|
||||||
environment,
|
|
||||||
method,
|
|
||||||
new ExpressionString(position, name),
|
|
||||||
new ExpressionInt(position, meta, ZenType.INT));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-97
@@ -1,97 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package minetweaker.mc1710.brackets;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
import minetweaker.IBracketHandler;
|
|
||||||
import minetweaker.MineTweakerAPI;
|
|
||||||
import minetweaker.annotations.BracketHandler;
|
|
||||||
import minetweaker.mc1710.oredict.MCOreDictEntry;
|
|
||||||
import minetweaker.api.oredict.IOreDictEntry;
|
|
||||||
import minetweaker.runtime.GlobalRegistry;
|
|
||||||
import stanhebben.zenscript.compiler.IEnvironmentGlobal;
|
|
||||||
import stanhebben.zenscript.expression.ExpressionCallStatic;
|
|
||||||
import stanhebben.zenscript.expression.ExpressionString;
|
|
||||||
import stanhebben.zenscript.expression.partial.IPartialExpression;
|
|
||||||
import stanhebben.zenscript.parser.Token;
|
|
||||||
import stanhebben.zenscript.symbols.IZenSymbol;
|
|
||||||
import stanhebben.zenscript.type.natives.IJavaMethod;
|
|
||||||
import stanhebben.zenscript.type.natives.JavaMethod;
|
|
||||||
import stanhebben.zenscript.util.ZenPosition;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
@BracketHandler
|
|
||||||
public class OreBracketHandler implements IBracketHandler {
|
|
||||||
public static IOreDictEntry getOre(String name) {
|
|
||||||
return new MCOreDictEntry(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<IOreDictEntry> getOreList(String wildcardName) {
|
|
||||||
List<IOreDictEntry> result = new ArrayList<IOreDictEntry>();
|
|
||||||
Pattern wildcardPattern = Pattern.compile(wildcardName.replaceAll("\\*", ".+"));
|
|
||||||
|
|
||||||
for (IOreDictEntry someOreDict : MineTweakerAPI.oreDict.getEntries()) {
|
|
||||||
String oreDictName = someOreDict.getName();
|
|
||||||
if (wildcardPattern.matcher(oreDictName).matches()) {
|
|
||||||
result.add(getOre(oreDictName));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IZenSymbol resolve(IEnvironmentGlobal environment, List<Token> tokens) {
|
|
||||||
if (tokens.size() > 2) {
|
|
||||||
if (tokens.get(0).getValue().equals("ore") && tokens.get(1).getValue().equals(":")) {
|
|
||||||
return find(environment, tokens, 2, tokens.size());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private IZenSymbol find(IEnvironmentGlobal environment, List<Token> tokens, int startIndex, int endIndex) {
|
|
||||||
StringBuilder valueBuilder = new StringBuilder();
|
|
||||||
for (int i = startIndex; i < endIndex; i++) {
|
|
||||||
Token token = tokens.get(i);
|
|
||||||
valueBuilder.append(token.getValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
return new OreReferenceSymbol(environment, valueBuilder.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
private class OreReferenceSymbol implements IZenSymbol {
|
|
||||||
private final IEnvironmentGlobal environment;
|
|
||||||
private final String name;
|
|
||||||
|
|
||||||
public OreReferenceSymbol(IEnvironmentGlobal environment, String name) {
|
|
||||||
this.environment = environment;
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IPartialExpression instance(ZenPosition position) {
|
|
||||||
IJavaMethod method = JavaMethod.get(
|
|
||||||
GlobalRegistry.getTypeRegistry(),
|
|
||||||
OreBracketHandler.class,
|
|
||||||
name.contains("*") ? "getOreList" : "getOre",
|
|
||||||
String.class);
|
|
||||||
|
|
||||||
return new ExpressionCallStatic(
|
|
||||||
position,
|
|
||||||
environment,
|
|
||||||
method,
|
|
||||||
new ExpressionString(position, name));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package minetweaker.mc1710.chat;
|
|
||||||
|
|
||||||
import minetweaker.api.chat.IChatMessage;
|
|
||||||
import net.minecraft.util.ChatComponentText;
|
|
||||||
import net.minecraft.util.IChatComponent;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class MCChatMessage implements IChatMessage {
|
|
||||||
private final IChatComponent data;
|
|
||||||
|
|
||||||
public MCChatMessage(String message) {
|
|
||||||
data = new ChatComponentText(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
public MCChatMessage(IChatComponent data) {
|
|
||||||
this.data = data;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IChatMessage add(IChatMessage other) {
|
|
||||||
return new MCChatMessage(data.appendSibling((IChatComponent) other.getInternal()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getInternal() {
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,172 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package minetweaker.mc1710.data;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import minetweaker.mc1710.util.MineTweakerHacks;
|
|
||||||
import minetweaker.api.data.DataByte;
|
|
||||||
import minetweaker.api.data.DataByteArray;
|
|
||||||
import minetweaker.api.data.DataDouble;
|
|
||||||
import minetweaker.api.data.DataFloat;
|
|
||||||
import minetweaker.api.data.DataInt;
|
|
||||||
import minetweaker.api.data.DataIntArray;
|
|
||||||
import minetweaker.api.data.DataList;
|
|
||||||
import minetweaker.api.data.DataLong;
|
|
||||||
import minetweaker.api.data.DataMap;
|
|
||||||
import minetweaker.api.data.DataShort;
|
|
||||||
import minetweaker.api.data.DataString;
|
|
||||||
import minetweaker.api.data.IData;
|
|
||||||
import minetweaker.api.data.IDataConverter;
|
|
||||||
import net.minecraft.nbt.NBTBase;
|
|
||||||
import net.minecraft.nbt.NBTTagByte;
|
|
||||||
import net.minecraft.nbt.NBTTagByteArray;
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
|
||||||
import net.minecraft.nbt.NBTTagDouble;
|
|
||||||
import net.minecraft.nbt.NBTTagFloat;
|
|
||||||
import net.minecraft.nbt.NBTTagInt;
|
|
||||||
import net.minecraft.nbt.NBTTagIntArray;
|
|
||||||
import net.minecraft.nbt.NBTTagList;
|
|
||||||
import net.minecraft.nbt.NBTTagLong;
|
|
||||||
import net.minecraft.nbt.NBTTagShort;
|
|
||||||
import net.minecraft.nbt.NBTTagString;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class NBTConverter implements IDataConverter<NBTBase> {
|
|
||||||
private static final NBTConverter INSTANCE = new NBTConverter();
|
|
||||||
|
|
||||||
public static NBTBase from(IData data) {
|
|
||||||
return data.convert(INSTANCE);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IData from(NBTBase nbt, boolean immutable) {
|
|
||||||
if (nbt == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
switch (nbt.getId()) {
|
|
||||||
case 1: // byte
|
|
||||||
return new DataByte(((NBTBase.NBTPrimitive) nbt).func_150290_f());
|
|
||||||
case 2: // short
|
|
||||||
return new DataShort(((NBTBase.NBTPrimitive) nbt).func_150289_e());
|
|
||||||
case 3: // int
|
|
||||||
return new DataInt(((NBTBase.NBTPrimitive) nbt).func_150287_d());
|
|
||||||
case 4: // long
|
|
||||||
return new DataLong(((NBTBase.NBTPrimitive) nbt).func_150291_c());
|
|
||||||
case 5: // float
|
|
||||||
return new DataFloat(((NBTBase.NBTPrimitive) nbt).func_150288_h());
|
|
||||||
case 6: // double
|
|
||||||
return new DataDouble(((NBTBase.NBTPrimitive) nbt).func_150286_g());
|
|
||||||
case 7: // byte[]
|
|
||||||
return new DataByteArray(((NBTTagByteArray) nbt).func_150292_c(), immutable);
|
|
||||||
case 8: // string
|
|
||||||
return new DataString(((NBTTagString) nbt).func_150285_a_());
|
|
||||||
case 9: { // list
|
|
||||||
List<IData> values = new ArrayList<IData>();
|
|
||||||
List<NBTBase> original = MineTweakerHacks.getTagList((NBTTagList) nbt);
|
|
||||||
for (NBTBase value : original) {
|
|
||||||
values.add(from(value, immutable));
|
|
||||||
}
|
|
||||||
return new DataList(values, immutable);
|
|
||||||
}
|
|
||||||
case 10: { // compound
|
|
||||||
Map<String, IData> values = new HashMap<String, IData>();
|
|
||||||
NBTTagCompound original = (NBTTagCompound) nbt;
|
|
||||||
for (String key : (Set<String>) original.func_150296_c()) {
|
|
||||||
values.put(key, from(original.getTag(key), immutable));
|
|
||||||
}
|
|
||||||
return new DataMap(values, immutable);
|
|
||||||
}
|
|
||||||
case 11: // int[]
|
|
||||||
return new DataIntArray(((NBTTagIntArray) nbt).func_150302_c(), immutable);
|
|
||||||
default:
|
|
||||||
throw new RuntimeException("Unknown tag type: " + nbt.getId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void updateMap(NBTTagCompound nbt, IData data) {
|
|
||||||
NBTUpdater updater = new NBTUpdater(nbt);
|
|
||||||
data.convert(updater);
|
|
||||||
}
|
|
||||||
|
|
||||||
public NBTConverter() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public NBTBase fromBool(boolean value) {
|
|
||||||
return new NBTTagInt(value ? 1 : 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public NBTBase fromByte(byte value) {
|
|
||||||
return new NBTTagByte(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public NBTBase fromShort(short value) {
|
|
||||||
return new NBTTagShort(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public NBTBase fromInt(int value) {
|
|
||||||
return new NBTTagInt(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public NBTBase fromLong(long value) {
|
|
||||||
return new NBTTagLong(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public NBTBase fromFloat(float value) {
|
|
||||||
return new NBTTagFloat(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public NBTBase fromDouble(double value) {
|
|
||||||
return new NBTTagDouble(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public NBTBase fromString(String value) {
|
|
||||||
return new NBTTagString(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public NBTBase fromList(List<IData> values) {
|
|
||||||
NBTTagList result = new NBTTagList();
|
|
||||||
for (IData value : values) {
|
|
||||||
result.appendTag(from(value));
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public NBTBase fromMap(Map<String, IData> values) {
|
|
||||||
NBTTagCompound result = new NBTTagCompound();
|
|
||||||
for (Map.Entry<String, IData> entry : values.entrySet()) {
|
|
||||||
result.setTag(entry.getKey(), from(entry.getValue()));
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public NBTBase fromByteArray(byte[] value) {
|
|
||||||
return new NBTTagByteArray(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public NBTBase fromIntArray(int[] value) {
|
|
||||||
return new NBTTagIntArray(value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package minetweaker.mc1710.data;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
import minetweaker.api.data.IData;
|
|
||||||
import minetweaker.api.data.IDataConverter;
|
|
||||||
import net.minecraft.nbt.NBTBase;
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class NBTUpdater extends NBTConverter implements IDataConverter<NBTBase> {
|
|
||||||
private final NBTTagCompound nbt;
|
|
||||||
|
|
||||||
public NBTUpdater(NBTTagCompound compound) {
|
|
||||||
this.nbt = compound;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public NBTBase fromMap(Map<String, IData> map) {
|
|
||||||
for (Map.Entry<String, IData> entry : map.entrySet()) {
|
|
||||||
if (nbt.hasKey(entry.getKey())) {
|
|
||||||
if (entry.getValue() == null) {
|
|
||||||
nbt.removeTag(entry.getKey());
|
|
||||||
} else {
|
|
||||||
if (nbt.getTag(entry.getKey()).getId() == 10) {
|
|
||||||
NBTTagCompound tag = (NBTTagCompound) nbt.getTag(entry.getKey());
|
|
||||||
nbt.setTag(entry.getKey(), entry.getValue().convert(new NBTUpdater(nbt)));
|
|
||||||
} else {
|
|
||||||
nbt.setTag(entry.getKey(), from(entry.getValue()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (entry.getValue() != null) {
|
|
||||||
nbt.setTag(entry.getKey(), from(entry.getValue()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nbt;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-44
@@ -1,44 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package minetweaker.mc1710.formatting;
|
|
||||||
|
|
||||||
import minetweaker.api.formatting.IFormattedText;
|
|
||||||
import net.minecraft.util.EnumChatFormatting;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class FormattedMarkupString implements IMCFormattedString {
|
|
||||||
private final EnumChatFormatting markup;
|
|
||||||
private final IMCFormattedString contents;
|
|
||||||
|
|
||||||
public FormattedMarkupString(EnumChatFormatting markup, IMCFormattedString contents) {
|
|
||||||
this.markup = markup;
|
|
||||||
this.contents = contents;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getTooltipString() {
|
|
||||||
return markup + contents.getTooltipString(markup.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getTooltipString(String context) {
|
|
||||||
return markup + contents.getTooltipString(context + markup);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IFormattedText add(IFormattedText other) {
|
|
||||||
return cat(other);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IFormattedText cat(IFormattedText other) {
|
|
||||||
return new FormattedStringJoin(this, (IMCFormattedString) other);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-41
@@ -1,41 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package minetweaker.mc1710.formatting;
|
|
||||||
|
|
||||||
import minetweaker.api.formatting.IFormattedText;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class FormattedString implements IMCFormattedString {
|
|
||||||
private final String value;
|
|
||||||
|
|
||||||
public FormattedString(String value) {
|
|
||||||
this.value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getTooltipString() {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getTooltipString(String context) {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IFormattedText add(IFormattedText other) {
|
|
||||||
return cat(other);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IFormattedText cat(IFormattedText other) {
|
|
||||||
return new FormattedStringJoin(this, (IMCFormattedString) other);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-67
@@ -1,67 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package minetweaker.mc1710.formatting;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import minetweaker.api.formatting.IFormattedText;
|
|
||||||
import net.minecraft.util.EnumChatFormatting;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class FormattedStringJoin implements IMCFormattedString {
|
|
||||||
private final IMCFormattedString[] values;
|
|
||||||
|
|
||||||
public FormattedStringJoin(IMCFormattedString first, IMCFormattedString second) {
|
|
||||||
values = new IMCFormattedString[] { first, second };
|
|
||||||
}
|
|
||||||
|
|
||||||
public FormattedStringJoin(IMCFormattedString[] values) {
|
|
||||||
this.values = values;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getTooltipString() {
|
|
||||||
StringBuilder result = new StringBuilder();
|
|
||||||
for (IMCFormattedString value : values) {
|
|
||||||
result.append(value.getTooltipString());
|
|
||||||
}
|
|
||||||
return result.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getTooltipString(String context) {
|
|
||||||
boolean first = true;
|
|
||||||
|
|
||||||
StringBuilder result = new StringBuilder();
|
|
||||||
for (IMCFormattedString value : values) {
|
|
||||||
if (first) {
|
|
||||||
first = false;
|
|
||||||
} else {
|
|
||||||
result.append(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
result.append(value.getTooltipString());
|
|
||||||
result.append(EnumChatFormatting.RESET);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IFormattedText add(IFormattedText other) {
|
|
||||||
return cat(other);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IFormattedText cat(IFormattedText other) {
|
|
||||||
IMCFormattedString[] newValues = Arrays.copyOf(values, values.length + 1);
|
|
||||||
newValues[values.length] = (IMCFormattedString) other;
|
|
||||||
return new FormattedStringJoin(newValues);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-128
@@ -1,128 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package minetweaker.mc1710.formatting;
|
|
||||||
|
|
||||||
import minetweaker.api.formatting.IFormattedText;
|
|
||||||
import minetweaker.api.formatting.IFormatter;
|
|
||||||
import net.minecraft.util.EnumChatFormatting;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class MCFormatter implements IFormatter {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IFormattedText string(String text) {
|
|
||||||
return new FormattedString(text);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IFormattedText black(IFormattedText text) {
|
|
||||||
return new FormattedMarkupString(EnumChatFormatting.BLACK, (IMCFormattedString) text);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IFormattedText darkBlue(IFormattedText text) {
|
|
||||||
return new FormattedMarkupString(EnumChatFormatting.DARK_BLUE, (IMCFormattedString) text);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IFormattedText darkGreen(IFormattedText text) {
|
|
||||||
return new FormattedMarkupString(EnumChatFormatting.DARK_GREEN, (IMCFormattedString) text);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IFormattedText darkAqua(IFormattedText text) {
|
|
||||||
return new FormattedMarkupString(EnumChatFormatting.DARK_AQUA, (IMCFormattedString) text);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IFormattedText darkRed(IFormattedText text) {
|
|
||||||
return new FormattedMarkupString(EnumChatFormatting.DARK_RED, (IMCFormattedString) text);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IFormattedText darkPurple(IFormattedText text) {
|
|
||||||
return new FormattedMarkupString(EnumChatFormatting.DARK_PURPLE, (IMCFormattedString) text);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IFormattedText gold(IFormattedText text) {
|
|
||||||
return new FormattedMarkupString(EnumChatFormatting.GOLD, (IMCFormattedString) text);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IFormattedText gray(IFormattedText text) {
|
|
||||||
return new FormattedMarkupString(EnumChatFormatting.GRAY, (IMCFormattedString) text);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IFormattedText darkGray(IFormattedText text) {
|
|
||||||
return new FormattedMarkupString(EnumChatFormatting.DARK_GRAY, (IMCFormattedString) text);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IFormattedText blue(IFormattedText text) {
|
|
||||||
return new FormattedMarkupString(EnumChatFormatting.BLUE, (IMCFormattedString) text);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IFormattedText green(IFormattedText text) {
|
|
||||||
return new FormattedMarkupString(EnumChatFormatting.GREEN, (IMCFormattedString) text);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IFormattedText aqua(IFormattedText text) {
|
|
||||||
return new FormattedMarkupString(EnumChatFormatting.AQUA, (IMCFormattedString) text);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IFormattedText red(IFormattedText text) {
|
|
||||||
return new FormattedMarkupString(EnumChatFormatting.RED, (IMCFormattedString) text);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IFormattedText lightPurple(IFormattedText text) {
|
|
||||||
return new FormattedMarkupString(EnumChatFormatting.LIGHT_PURPLE, (IMCFormattedString) text);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IFormattedText yellow(IFormattedText text) {
|
|
||||||
return new FormattedMarkupString(EnumChatFormatting.YELLOW, (IMCFormattedString) text);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IFormattedText white(IFormattedText text) {
|
|
||||||
return new FormattedMarkupString(EnumChatFormatting.WHITE, (IMCFormattedString) text);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IFormattedText obfuscated(IFormattedText text) {
|
|
||||||
return new FormattedMarkupString(EnumChatFormatting.OBFUSCATED, (IMCFormattedString) text);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IFormattedText bold(IFormattedText text) {
|
|
||||||
return new FormattedMarkupString(EnumChatFormatting.BOLD, (IMCFormattedString) text);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IFormattedText strikethrough(IFormattedText text) {
|
|
||||||
return new FormattedMarkupString(EnumChatFormatting.STRIKETHROUGH, (IMCFormattedString) text);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IFormattedText underline(IFormattedText text) {
|
|
||||||
return new FormattedMarkupString(EnumChatFormatting.UNDERLINE, (IMCFormattedString) text);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IFormattedText italic(IFormattedText text) {
|
|
||||||
return new FormattedMarkupString(EnumChatFormatting.ITALIC, (IMCFormattedString) text);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,94 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package minetweaker.mc1710.furnace;
|
|
||||||
|
|
||||||
import cpw.mods.fml.common.IFuelHandler;
|
|
||||||
import cpw.mods.fml.common.registry.GameRegistry;
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import minetweaker.MineTweakerAPI;
|
|
||||||
import minetweaker.api.item.IItemStack;
|
|
||||||
import minetweaker.api.minecraft.MineTweakerMC;
|
|
||||||
import net.minecraft.item.Item;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
|
|
||||||
public class FuelTweaker {
|
|
||||||
public static final FuelTweaker INSTANCE = new FuelTweaker();
|
|
||||||
|
|
||||||
private List<IFuelHandler> original;
|
|
||||||
private final HashMap<Item, List<SetFuelPattern>> quickList = new HashMap<Item, List<SetFuelPattern>>();
|
|
||||||
|
|
||||||
private FuelTweaker() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public void register() {
|
|
||||||
try {
|
|
||||||
Field fuelHandlers = GameRegistry.class.getDeclaredField("fuelHandlers");
|
|
||||||
fuelHandlers.setAccessible(true);
|
|
||||||
original = (List<IFuelHandler>) fuelHandlers.get(null);
|
|
||||||
List<IFuelHandler> modified = new ArrayList<IFuelHandler>();
|
|
||||||
modified.add(new OverridingFuelHandler());
|
|
||||||
fuelHandlers.set(null, modified);
|
|
||||||
} catch (NoSuchFieldException ex) {
|
|
||||||
System.out.println("[MineTweaker] Error: could not get GameRegistry fuel handlers field. Cannot use custom fuel values.");
|
|
||||||
} catch (SecurityException ex) {
|
|
||||||
System.out.println("[MineTweaker] Error: could not alter GameRegistry fuel handlers field. Cannot use custom fuel values.");
|
|
||||||
} catch (IllegalAccessException ex) {
|
|
||||||
System.out.println("[MineTweaker] Error: could not alter GameRegistry fuel handlers field. Cannot use custom fuel values.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addFuelPattern(SetFuelPattern pattern) {
|
|
||||||
List<IItemStack> items = pattern.getPattern().getItems();
|
|
||||||
if (items == null) {
|
|
||||||
MineTweakerAPI.logError("Cannot set fuel for <*>");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (IItemStack item : pattern.getPattern().getItems()) {
|
|
||||||
ItemStack itemStack = MineTweakerMC.getItemStack(item);
|
|
||||||
Item mcItem = itemStack.getItem();
|
|
||||||
if (!quickList.containsKey(mcItem)) {
|
|
||||||
quickList.put(mcItem, new ArrayList<SetFuelPattern>());
|
|
||||||
}
|
|
||||||
quickList.get(mcItem).add(pattern);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removeFuelPattern(SetFuelPattern pattern) {
|
|
||||||
for (IItemStack item : pattern.getPattern().getItems()) {
|
|
||||||
ItemStack itemStack = MineTweakerMC.getItemStack(item);
|
|
||||||
Item mcItem = itemStack.getItem();
|
|
||||||
if (quickList.containsKey(mcItem)) {
|
|
||||||
quickList.get(mcItem).remove(pattern);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class OverridingFuelHandler implements IFuelHandler {
|
|
||||||
@Override
|
|
||||||
public int getBurnTime(ItemStack fuel) {
|
|
||||||
if (quickList.containsKey(fuel.getItem())) {
|
|
||||||
IItemStack stack = MineTweakerMC.getIItemStack(fuel);
|
|
||||||
|
|
||||||
for (SetFuelPattern override : quickList.get(fuel.getItem())) {
|
|
||||||
if (override.getPattern().matches(stack)) {
|
|
||||||
return override.getValue();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int max = 0;
|
|
||||||
for (IFuelHandler handler : original) {
|
|
||||||
max = Math.max(max, handler.getBurnTime(fuel));
|
|
||||||
}
|
|
||||||
return max;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
package minetweaker.mc1710.furnace;
|
|
||||||
|
|
||||||
import minetweaker.api.item.IIngredient;
|
|
||||||
|
|
||||||
public class SetFuelPattern {
|
|
||||||
private final IIngredient pattern;
|
|
||||||
private final int value;
|
|
||||||
|
|
||||||
public SetFuelPattern(IIngredient pattern, int value) {
|
|
||||||
this.pattern = pattern;
|
|
||||||
this.value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IIngredient getPattern() {
|
|
||||||
return pattern;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getValue() {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,248 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package minetweaker.mc1710.game;
|
|
||||||
|
|
||||||
import com.google.common.collect.*;
|
|
||||||
import cpw.mods.fml.common.registry.EntityRegistry;
|
|
||||||
import cpw.mods.fml.common.registry.LanguageRegistry;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import minetweaker.IUndoableAction;
|
|
||||||
import minetweaker.MineTweakerAPI;
|
|
||||||
import minetweaker.api.block.IBlockDefinition;
|
|
||||||
import minetweaker.api.entity.IEntityDefinition;
|
|
||||||
import minetweaker.api.event.*;
|
|
||||||
import minetweaker.api.game.IGame;
|
|
||||||
import minetweaker.api.item.IItemDefinition;
|
|
||||||
import minetweaker.api.liquid.ILiquidDefinition;
|
|
||||||
import minetweaker.api.minecraft.MineTweakerMC;
|
|
||||||
import minetweaker.api.world.IBiome;
|
|
||||||
// TODO Find this
|
|
||||||
// import GuiCannotRemodify;
|
|
||||||
import minetweaker.mc1710.entity.MCEntityDefinition;
|
|
||||||
import minetweaker.mc1710.item.MCItemDefinition;
|
|
||||||
import minetweaker.mc1710.liquid.MCLiquidDefinition;
|
|
||||||
import minetweaker.mc1710.util.MineTweakerHacks;
|
|
||||||
import minetweaker.mc1710.util.MineTweakerPlatformUtils;
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.item.Item;
|
|
||||||
import net.minecraft.util.*;
|
|
||||||
import net.minecraftforge.fluids.Fluid;
|
|
||||||
import net.minecraftforge.fluids.FluidRegistry;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class MCGame implements IGame {
|
|
||||||
private static final Map<String, String> TRANSLATIONS = MineTweakerHacks.getTranslations();
|
|
||||||
|
|
||||||
public static final MCGame INSTANCE = new MCGame();
|
|
||||||
|
|
||||||
private boolean locked = false;
|
|
||||||
private static final List<IEntityDefinition> ENTITY_DEFINITIONS = new ArrayList<IEntityDefinition>();
|
|
||||||
|
|
||||||
private MCGame() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<IItemDefinition> getItems() {
|
|
||||||
List<IItemDefinition> result = new ArrayList<IItemDefinition>();
|
|
||||||
for (String item : (Set<String>) Item.itemRegistry.getKeys()) {
|
|
||||||
result.add(new MCItemDefinition(item, (Item) Item.itemRegistry.getObject(item)));
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<IBlockDefinition> getBlocks() {
|
|
||||||
List<IBlockDefinition> result = new ArrayList<IBlockDefinition>();
|
|
||||||
for (String block : (Set<String>) Block.blockRegistry.getKeys()) {
|
|
||||||
result.add(MineTweakerMC.getBlockDefinition((Block) Block.blockRegistry.getObject(block)));
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<ILiquidDefinition> getLiquids() {
|
|
||||||
List<ILiquidDefinition> result = new ArrayList<ILiquidDefinition>();
|
|
||||||
for (Map.Entry<String, Fluid> entry : FluidRegistry.getRegisteredFluids().entrySet()) {
|
|
||||||
result.add(new MCLiquidDefinition(entry.getValue()));
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<IBiome> getBiomes() {
|
|
||||||
List<IBiome> result = new ArrayList<IBiome>();
|
|
||||||
for (IBiome biome : MineTweakerMC.biomes) {
|
|
||||||
if (biome != null) {
|
|
||||||
result.add(biome);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<IEntityDefinition> getEntities() {
|
|
||||||
final Set<EntityRegistry.EntityRegistration> values = MineTweakerHacks.getEntityClassRegistrations().values();
|
|
||||||
if(Iterables.size(values) != ENTITY_DEFINITIONS.size()) {
|
|
||||||
ENTITY_DEFINITIONS.clear();
|
|
||||||
for(EntityRegistry.EntityRegistration entry : values) {
|
|
||||||
ENTITY_DEFINITIONS.add(new MCEntityDefinition(entry));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ENTITY_DEFINITIONS;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IEntityDefinition getEntity(String entityName) {
|
|
||||||
for(IEntityDefinition ent : getEntities()) {
|
|
||||||
if(ent.getName().equalsIgnoreCase(entityName)) {
|
|
||||||
return ent;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
boolean needsReloading = false;
|
|
||||||
for(EntityRegistry.EntityRegistration res : MineTweakerHacks.getEntityClassRegistrations().values()) {
|
|
||||||
if(res.getEntityName().equalsIgnoreCase(entityName)) {
|
|
||||||
needsReloading = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(needsReloading) {
|
|
||||||
ENTITY_DEFINITIONS.clear();
|
|
||||||
for(EntityRegistry.EntityRegistration entry : MineTweakerHacks.getEntityClassRegistrations().values()) {
|
|
||||||
ENTITY_DEFINITIONS.add(new MCEntityDefinition(entry));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for(IEntityDefinition entity : getEntities()) {
|
|
||||||
if(entity.getName().equalsIgnoreCase(entityName)) {
|
|
||||||
return entity;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setLocalization(String key, String value) {
|
|
||||||
MineTweakerAPI.apply(new SetTranslation(null, key, value));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setLocalization(String lang, String key, String value) {
|
|
||||||
MineTweakerAPI.apply(new SetTranslation(lang, key, value));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String localize(String key) {
|
|
||||||
return LanguageRegistry.instance().getStringLocalization(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String localize(String key, String lang) {
|
|
||||||
return LanguageRegistry.instance().getStringLocalization(key, lang);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void lock()
|
|
||||||
{
|
|
||||||
locked = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isLocked()
|
|
||||||
{
|
|
||||||
return locked;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void signalLockError()
|
|
||||||
{
|
|
||||||
MineTweakerAPI.getLogger().logError("Reload of scripts blocked (script lock)");
|
|
||||||
|
|
||||||
if (Minecraft.isGuiEnabled()) {
|
|
||||||
// Commented out due to unresolved import
|
|
||||||
/**
|
|
||||||
* Minecraft.getMinecraft().displayGuiScreen( new GuiCannotRemodify(
|
|
||||||
* "Minecraft has been tweaked for another server",
|
|
||||||
* "with modifications that cannot be rolled back.",
|
|
||||||
* "Please restart your game."));
|
|
||||||
**/
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ######################
|
|
||||||
// ### Action classes ###
|
|
||||||
// ######################
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Ported from ModTweaker.
|
|
||||||
*
|
|
||||||
* @author Joshiejack
|
|
||||||
*/
|
|
||||||
private static class SetTranslation implements IUndoableAction {
|
|
||||||
private String original;
|
|
||||||
private final String lang;
|
|
||||||
private final String key;
|
|
||||||
private final String text;
|
|
||||||
private boolean added;
|
|
||||||
|
|
||||||
public SetTranslation(String lang, String key, String text) {
|
|
||||||
this.lang = lang;
|
|
||||||
this.key = key;
|
|
||||||
this.text = text;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void apply() {
|
|
||||||
if (lang == null || MineTweakerPlatformUtils.isLanguageActive(lang)) {
|
|
||||||
original = TRANSLATIONS.get(key);
|
|
||||||
TRANSLATIONS.put(key, text);
|
|
||||||
added = true;
|
|
||||||
} else {
|
|
||||||
added = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canUndo() {
|
|
||||||
return TRANSLATIONS != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void undo() {
|
|
||||||
if (added) {
|
|
||||||
if (original == null) {
|
|
||||||
TRANSLATIONS.remove(key);
|
|
||||||
} else {
|
|
||||||
TRANSLATIONS.put(key, original);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describe() {
|
|
||||||
return "Setting localization for the key: " + key + " to " + text;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describeUndo() {
|
|
||||||
return "Setting localization for the key: " + key + " to " + original;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getOverrideKey() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,89 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package minetweaker.mc1710.item;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import minetweaker.MineTweakerAPI;
|
|
||||||
import minetweaker.api.item.IItemDefinition;
|
|
||||||
import minetweaker.api.item.IItemStack;
|
|
||||||
import minetweaker.api.minecraft.MineTweakerMC;
|
|
||||||
import minetweaker.api.oredict.IOreDictEntry;
|
|
||||||
import net.minecraft.item.Item;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraftforge.oredict.OreDictionary;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class MCItemDefinition implements IItemDefinition {
|
|
||||||
private final String id;
|
|
||||||
private final Item item;
|
|
||||||
|
|
||||||
public MCItemDefinition(String id, Item item) {
|
|
||||||
this.id = id;
|
|
||||||
this.item = item;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return item.getUnlocalizedName();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IItemStack makeStack(int meta) {
|
|
||||||
return MineTweakerMC.getIItemStackWildcardSize(new ItemStack(item, 1, meta));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<IOreDictEntry> getOres() {
|
|
||||||
List<IOreDictEntry> result = new ArrayList<IOreDictEntry>();
|
|
||||||
|
|
||||||
for (String key : OreDictionary.getOreNames()) {
|
|
||||||
for (ItemStack is : OreDictionary.getOres(key)) {
|
|
||||||
if (is.getItem() == item) {
|
|
||||||
result.add(MineTweakerAPI.oreDict.get(key));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
// #############################
|
|
||||||
// ### Object implementation ###
|
|
||||||
// #############################
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
int hash = 7;
|
|
||||||
hash = 37 * hash + (this.item != null ? this.item.hashCode() : 0);
|
|
||||||
return hash;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object obj) {
|
|
||||||
if (obj == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (getClass() != obj.getClass()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
final MCItemDefinition other = (MCItemDefinition) obj;
|
|
||||||
if (this.item != other.item && (this.item == null || !this.item.equals(other.item))) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,432 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package minetweaker.mc1710.item;
|
|
||||||
|
|
||||||
import cpw.mods.fml.relauncher.ReflectionHelper;
|
|
||||||
import minetweaker.MineTweakerAPI;
|
|
||||||
import minetweaker.api.block.IBlock;
|
|
||||||
import minetweaker.api.data.DataMap;
|
|
||||||
import minetweaker.api.data.IData;
|
|
||||||
import minetweaker.api.item.*;
|
|
||||||
import minetweaker.api.liquid.ILiquidStack;
|
|
||||||
import minetweaker.api.oredict.IOreDictEntry;
|
|
||||||
import minetweaker.api.player.IPlayer;
|
|
||||||
import minetweaker.mc1710.actions.SetBlockHardnessAction;
|
|
||||||
import minetweaker.mc1710.actions.SetStackSizeAction;
|
|
||||||
import minetweaker.mc1710.actions.SetStackmaxDamageAction;
|
|
||||||
import minetweaker.mc1710.actions.SetTranslationAction;
|
|
||||||
import minetweaker.mc1710.block.MCItemBlock;
|
|
||||||
import minetweaker.mc1710.data.NBTConverter;
|
|
||||||
import minetweaker.mc1710.liquid.MCLiquidStack;
|
|
||||||
import minetweaker.util.ArrayUtil;
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.item.Item;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
|
||||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
|
||||||
import net.minecraftforge.oredict.OreDictionary;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import static minetweaker.api.minecraft.MineTweakerMC.getItemStack;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class MCItemStack implements IItemStack {
|
|
||||||
private final ItemStack stack;
|
|
||||||
private final List<IItemStack> items;
|
|
||||||
private IData tag = null;
|
|
||||||
private boolean wildcardSize;
|
|
||||||
|
|
||||||
public MCItemStack(ItemStack itemStack) {
|
|
||||||
if (itemStack == null)
|
|
||||||
throw new IllegalArgumentException("stack cannot be null");
|
|
||||||
|
|
||||||
stack = itemStack.copy();
|
|
||||||
items = Collections.singletonList(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public MCItemStack(ItemStack itemStack, boolean wildcardSize) {
|
|
||||||
this(itemStack);
|
|
||||||
|
|
||||||
this.wildcardSize = wildcardSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
private MCItemStack(ItemStack itemStack, IData tag) {
|
|
||||||
if (itemStack == null)
|
|
||||||
throw new IllegalArgumentException("stack cannot be null");
|
|
||||||
|
|
||||||
stack = itemStack;
|
|
||||||
items = Collections.singletonList(this);
|
|
||||||
this.tag = tag;
|
|
||||||
}
|
|
||||||
|
|
||||||
private MCItemStack(ItemStack itemStack, IData tag, boolean wildcardSize) {
|
|
||||||
stack = itemStack;
|
|
||||||
items = Collections.singletonList(this);
|
|
||||||
this.tag = tag;
|
|
||||||
this.wildcardSize = wildcardSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IItemDefinition getDefinition() {
|
|
||||||
return new MCItemDefinition(Item.itemRegistry.getNameForObject(stack.getItem()), stack.getItem());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return stack.getUnlocalizedName();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getDisplayName() {
|
|
||||||
return stack.getDisplayName();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setDisplayName(String name) {
|
|
||||||
MineTweakerAPI.apply(new SetTranslationAction(getName() + ".name", name));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setMaxDamage(int damage) {
|
|
||||||
MineTweakerAPI.apply(new SetStackmaxDamageAction(stack, damage));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getMaxStackSize() {
|
|
||||||
return stack.getMaxStackSize();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setMaxStackSize(int size) {
|
|
||||||
MineTweakerAPI.apply(new SetStackSizeAction((ItemStack) getInternal(), size));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public float getBlockHardness() {
|
|
||||||
return ReflectionHelper.getPrivateValue(Block.class, Block.getBlockFromItem(stack.getItem()), "blockHardness");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setBlockHardness(float hardness) {
|
|
||||||
MineTweakerAPI.apply(new SetBlockHardnessAction(stack, hardness));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getDamage() {
|
|
||||||
return stack.getItemDamage();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IData getTag() {
|
|
||||||
if (tag == null) {
|
|
||||||
if (stack.stackTagCompound == null) {
|
|
||||||
return DataMap.EMPTY;
|
|
||||||
}
|
|
||||||
|
|
||||||
tag = NBTConverter.from(stack.stackTagCompound, true);
|
|
||||||
}
|
|
||||||
return tag;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getMaxDamage() {
|
|
||||||
return stack.getMaxDamage();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ILiquidStack getLiquid() {
|
|
||||||
FluidStack liquid = FluidContainerRegistry.getFluidForFilledItem(stack);
|
|
||||||
return liquid == null ? null : new MCLiquidStack(liquid);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IIngredient anyDamage() {
|
|
||||||
if (stack.getItem().getHasSubtypes()) {
|
|
||||||
MineTweakerAPI.logWarning("subitems don't have damaged states");
|
|
||||||
return this;
|
|
||||||
} else {
|
|
||||||
ItemStack result = new ItemStack(stack.getItem(), stack.stackSize, OreDictionary.WILDCARD_VALUE);
|
|
||||||
result.stackTagCompound = stack.stackTagCompound;
|
|
||||||
return new MCItemStack(result, tag);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IItemStack withDamage(int damage) {
|
|
||||||
if (stack.getItem().getHasSubtypes()) {
|
|
||||||
MineTweakerAPI.logWarning("subitems don't have damaged states");
|
|
||||||
return this;
|
|
||||||
} else {
|
|
||||||
ItemStack result = new ItemStack(stack.getItem(), stack.stackSize, damage);
|
|
||||||
result.stackTagCompound = stack.stackTagCompound;
|
|
||||||
return new MCItemStack(result, tag);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IItemStack anyAmount() {
|
|
||||||
ItemStack result = new ItemStack(stack.getItem(), 1, stack.getItemDamage());
|
|
||||||
result.stackTagCompound = stack.stackTagCompound;
|
|
||||||
return new MCItemStack(result, tag, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IItemStack withAmount(int amount) {
|
|
||||||
ItemStack result = new ItemStack(stack.getItem(), amount, stack.getItemDamage());
|
|
||||||
result.stackTagCompound = stack.stackTagCompound;
|
|
||||||
return new MCItemStack(result, tag);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IItemStack withTag(IData tag) {
|
|
||||||
ItemStack result = new ItemStack(stack.getItem(), stack.stackSize, stack.getItemDamage());
|
|
||||||
if (tag == null) {
|
|
||||||
result.stackTagCompound = null;
|
|
||||||
} else {
|
|
||||||
result.stackTagCompound = (NBTTagCompound) NBTConverter.from(tag);
|
|
||||||
}
|
|
||||||
return new MCItemStack(result, tag);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IItemStack withEmptyTag() {
|
|
||||||
final ItemStack itemStack = new ItemStack(stack.getItem(), stack.stackSize, stack.getItemDamage());
|
|
||||||
itemStack.stackTagCompound = null;
|
|
||||||
return new MCItemStack(itemStack);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IItemStack updateTag(IData tagUpdate) {
|
|
||||||
if (tag == null) {
|
|
||||||
if (stack.stackTagCompound == null) {
|
|
||||||
return withTag(tagUpdate);
|
|
||||||
}
|
|
||||||
|
|
||||||
tag = NBTConverter.from(stack.stackTagCompound, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
IData updated = tag.update(tagUpdate);
|
|
||||||
return withTag(updated);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IItemStack removeTag(String tag) {
|
|
||||||
ItemStack result = new ItemStack(stack.getItem(), stack.stackSize, stack.getItemDamage());
|
|
||||||
|
|
||||||
if (tag == null) {
|
|
||||||
result.stackTagCompound = null;
|
|
||||||
} else {
|
|
||||||
result.stackTagCompound.removeTag(tag);
|
|
||||||
}
|
|
||||||
IData dataTag = NBTConverter.from(result.stackTagCompound, false);
|
|
||||||
return new MCItemStack(result, dataTag);
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public String getMark() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getAmount() {
|
|
||||||
return stack.stackSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<IItemStack> getItems() {
|
|
||||||
return items;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<ILiquidStack> getLiquids() {
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IItemStack amount(int amount) {
|
|
||||||
return withAmount(amount);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public WeightedItemStack percent(float chance) {
|
|
||||||
return new WeightedItemStack(this, chance * 0.01f);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public WeightedItemStack weight(float chance) {
|
|
||||||
return new WeightedItemStack(this, chance);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IIngredient transform(IItemTransformer transformer) {
|
|
||||||
return new IngredientItem(this, null, ArrayUtil.EMPTY_CONDITIONS, new IItemTransformer[] { transformer });
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IIngredient only(IItemCondition condition) {
|
|
||||||
return new IngredientItem(this, null, new IItemCondition[] { condition }, ArrayUtil.EMPTY_TRANSFORMERS);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IIngredient marked(String mark) {
|
|
||||||
return new IngredientItem(this, mark, ArrayUtil.EMPTY_CONDITIONS, ArrayUtil.EMPTY_TRANSFORMERS);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IIngredient or(IIngredient ingredient) {
|
|
||||||
return new IngredientOr(this, ingredient);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean matches(IItemStack item) {
|
|
||||||
ItemStack internal = getItemStack(item);
|
|
||||||
return internal !=null && stack !=null &&internal.getItem() == stack.getItem() && (wildcardSize || internal.stackSize >= stack.stackSize) && (stack.getItemDamage() == OreDictionary.WILDCARD_VALUE || stack.getItemDamage() == internal.getItemDamage() || (!stack.getHasSubtypes() && !stack.getItem().isDamageable()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean matchesExact(IItemStack item) {
|
|
||||||
ItemStack internal = getItemStack(item);
|
|
||||||
if (internal.getTagCompound() != null && stack.getTagCompound() == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (internal.getTagCompound() == null && stack.getTagCompound() != null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (internal.getTagCompound() == null && stack.getTagCompound() == null) {
|
|
||||||
return stack.getItem() == internal.getItem() && (internal.getItemDamage() == 32767 || stack.getItemDamage() == internal.getItemDamage());
|
|
||||||
}
|
|
||||||
if (internal.getTagCompound().func_150296_c().equals(stack.getTagCompound().func_150296_c())) {
|
|
||||||
for (String s : (Set<String>)internal.getTagCompound().func_150296_c()) {
|
|
||||||
if (!internal.getTagCompound().getTag(s).equals(stack.getTagCompound().getTag(s))) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return stack.getItem() == internal.getItem() && (internal.getItemDamage() == 32767 || stack.getItemDamage() == internal.getItemDamage());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean matches(ILiquidStack liquid) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean contains(IIngredient ingredient) {
|
|
||||||
List<IItemStack> iitems = ingredient.getItems();
|
|
||||||
if (iitems == null || iitems.size() != 1)
|
|
||||||
return false;
|
|
||||||
return matches(iitems.get(0));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IItemStack applyTransform(IItemStack item, IPlayer byPlayer) {
|
|
||||||
return item;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasTransformers() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getInternal() {
|
|
||||||
return stack;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IBlock asBlock() {
|
|
||||||
String name = Block.blockRegistry.getNameForObject(Block.getBlockFromItem(stack.getItem()));
|
|
||||||
if (Block.blockRegistry.containsKey(name)) {
|
|
||||||
return new MCItemBlock(stack);
|
|
||||||
} else {
|
|
||||||
throw new ClassCastException("This item is not a block");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<IOreDictEntry> getOres() {
|
|
||||||
List<IOreDictEntry> result = new ArrayList<IOreDictEntry>();
|
|
||||||
|
|
||||||
for (String key : OreDictionary.getOreNames()) {
|
|
||||||
for (ItemStack is : OreDictionary.getOres(key)) {
|
|
||||||
if (is.getItem() == stack.getItem() && (is.getItemDamage() == OreDictionary.WILDCARD_VALUE || is.getItemDamage() == stack.getItemDamage())) {
|
|
||||||
result.add(MineTweakerAPI.oreDict.get(key));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
// #############################
|
|
||||||
// ### Object implementation ###
|
|
||||||
// #############################
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
int hash = 7;
|
|
||||||
hash = 41 * hash + stack.getItem().hashCode();
|
|
||||||
hash = 41 * hash + stack.getItemDamage();
|
|
||||||
hash = 41 * hash + stack.stackSize;
|
|
||||||
hash = 41 * hash + (stack.stackTagCompound == null ? 0 : stack.stackTagCompound.hashCode());
|
|
||||||
hash = 41 * hash + (this.wildcardSize ? 1 : 0);
|
|
||||||
return hash;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object obj) {
|
|
||||||
if (obj == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (getClass() != obj.getClass()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
final MCItemStack other = (MCItemStack) obj;
|
|
||||||
if (this.stack.getItem() != other.stack.getItem())
|
|
||||||
return false;
|
|
||||||
if (this.stack.getItemDamage() != other.stack.getItemDamage())
|
|
||||||
return false;
|
|
||||||
if (this.stack.stackSize != other.stack.stackSize)
|
|
||||||
return false;
|
|
||||||
if (this.stack.stackTagCompound != other.stack.stackTagCompound && (this.stack == null || this.stack.equals(other.stack)))
|
|
||||||
return false;
|
|
||||||
if (this.wildcardSize != other.wildcardSize)
|
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
StringBuilder result = new StringBuilder();
|
|
||||||
result.append('<');
|
|
||||||
result.append(Item.itemRegistry.getNameForObject(stack.getItem()));
|
|
||||||
|
|
||||||
if (stack.getItemDamage() == OreDictionary.WILDCARD_VALUE) {
|
|
||||||
result.append(":*");
|
|
||||||
} else if (stack.getItemDamage() > 0) {
|
|
||||||
result.append(':').append(stack.getItemDamage());
|
|
||||||
}
|
|
||||||
result.append('>');
|
|
||||||
|
|
||||||
if (stack.getTagCompound() != null) {
|
|
||||||
result.append(".withTag(");
|
|
||||||
result.append(NBTConverter.from(stack.getTagCompound(), wildcardSize).toString());
|
|
||||||
result.append(")");
|
|
||||||
}
|
|
||||||
|
|
||||||
return result.toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-423
@@ -1,423 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package minetweaker.mc1710.liquid;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import minetweaker.IUndoableAction;
|
|
||||||
import minetweaker.MineTweakerAPI;
|
|
||||||
import minetweaker.api.item.IItemStack;
|
|
||||||
import minetweaker.api.liquid.ILiquidDefinition;
|
|
||||||
import minetweaker.api.liquid.ILiquidStack;
|
|
||||||
import minetweaker.api.minecraft.MineTweakerMC;
|
|
||||||
import net.minecraftforge.fluids.Fluid;
|
|
||||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class MCLiquidDefinition implements ILiquidDefinition {
|
|
||||||
private final Fluid fluid;
|
|
||||||
|
|
||||||
public MCLiquidDefinition(Fluid fluid) {
|
|
||||||
this.fluid = fluid;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return fluid.getName();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getDisplayName() {
|
|
||||||
return fluid.getLocalizedName();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ILiquidStack asStack(int millibuckets) {
|
|
||||||
return new MCLiquidStack(new FluidStack(fluid, millibuckets));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getLuminosity() {
|
|
||||||
return fluid.getLuminosity();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setLuminosity(int value) {
|
|
||||||
MineTweakerAPI.apply(new ActionSetLuminosity(value));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getDensity() {
|
|
||||||
return fluid.getDensity();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setDensity(int density) {
|
|
||||||
MineTweakerAPI.apply(new ActionSetDensity(density));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getTemperature() {
|
|
||||||
return fluid.getTemperature();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setTemperature(int temperature) {
|
|
||||||
MineTweakerAPI.apply(new ActionSetTemperature(temperature));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getViscosity() {
|
|
||||||
return fluid.getViscosity();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setViscosity(int viscosity) {
|
|
||||||
MineTweakerAPI.apply(new ActionSetViscosity(viscosity));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isGaseous() {
|
|
||||||
return fluid.isGaseous();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setGaseous(boolean gaseous) {
|
|
||||||
MineTweakerAPI.apply(new ActionSetGaseous(gaseous));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<IItemStack> getContainers() {
|
|
||||||
List<IItemStack> result = new ArrayList<IItemStack>();
|
|
||||||
for (FluidContainerRegistry.FluidContainerData data : FluidContainerRegistry.getRegisteredFluidContainerData()) {
|
|
||||||
if (data.fluid.getFluid() == fluid) {
|
|
||||||
result.add(MineTweakerMC.getIItemStack(data.filledContainer));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addContainer(IItemStack filled, IItemStack empty, int amount) {
|
|
||||||
MineTweakerAPI.apply(new AddContainerAction(filled, empty, amount));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void removeContainer(IItemStack filled) {
|
|
||||||
// MineTweakerAPI.apply(new RemoveContainerAction(filled));
|
|
||||||
MineTweakerAPI.logError("Cannot remove container items in MineCraft 1.7.X");
|
|
||||||
}
|
|
||||||
|
|
||||||
// #######################
|
|
||||||
// ### Private methods ###
|
|
||||||
// #######################
|
|
||||||
|
|
||||||
/*
|
|
||||||
* private void removeContainerInner(IItemStack filled) { ItemStack
|
|
||||||
* filledItem = MineTweakerMC.getItemStack(filled);
|
|
||||||
* FluidContainerRegistry.FluidContainerData data =
|
|
||||||
* filledContainerMap.get(Arrays.asList(filledItem.itemID,
|
|
||||||
* filledItem.getItemDamage())); if (data != null) {
|
|
||||||
* filledContainerMap.remove(Arrays.asList(filledItem.itemID,
|
|
||||||
* filledItem.getItemDamage()));
|
|
||||||
* containerFluidMap.remove(Arrays.asList(data.emptyContainer.itemID,
|
|
||||||
* data.emptyContainer.getItemDamage()));
|
|
||||||
*
|
|
||||||
* // rebuild empty containers set emptyContainers.clear(); for
|
|
||||||
* (FluidContainerRegistry.FluidContainerData fdata :
|
|
||||||
* filledContainerMap.values()) {
|
|
||||||
* emptyContainers.add(Arrays.asList(fdata.emptyContainer.itemID,
|
|
||||||
* fdata.emptyContainer.getItemDamage())); } }
|
|
||||||
* MineTweakerAPI.logError("Removal of containers is not possible in 1.7.X"
|
|
||||||
* ); }
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* private FluidContainerRegistry.FluidContainerData getData(IItemStack
|
|
||||||
* filled) { ItemStack filledStack = MineTweakerMC.getItemStack(filled);
|
|
||||||
* return filledContainerMap.get(Arrays.asList(filledStack.itemID,
|
|
||||||
* filledStack.getItemDamage())); }
|
|
||||||
*/
|
|
||||||
|
|
||||||
// ######################
|
|
||||||
// ### Action classes ###
|
|
||||||
// ######################
|
|
||||||
|
|
||||||
private class AddContainerAction implements IUndoableAction {
|
|
||||||
private final IItemStack filled;
|
|
||||||
private final IItemStack empty;
|
|
||||||
private final int amount;
|
|
||||||
|
|
||||||
public AddContainerAction(IItemStack filled, IItemStack empty, int amount) {
|
|
||||||
this.filled = filled;
|
|
||||||
this.empty = empty;
|
|
||||||
this.amount = amount;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void apply() {
|
|
||||||
FluidContainerRegistry.registerFluidContainer(new FluidStack(fluid, amount), MineTweakerMC.getItemStack(filled), MineTweakerMC.getItemStack(empty));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canUndo() {
|
|
||||||
return false;
|
|
||||||
// return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void undo() {
|
|
||||||
// removeContainerInner(filled);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describe() {
|
|
||||||
return "Adding " + filled.getDisplayName() + " as liquid container for " + fluid.getLocalizedName();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describeUndo() {
|
|
||||||
return "Removing liquid container " + filled;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getOverrideKey() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* private class RemoveContainerAction implements IUndoableAction { private
|
|
||||||
* final IItemStack filled; private final IItemStack empty; private final
|
|
||||||
* FluidStack amount;
|
|
||||||
*
|
|
||||||
* public RemoveContainerAction(IItemStack filled) { this.filled = filled;
|
|
||||||
*
|
|
||||||
* FluidContainerRegistry.FluidContainerData data = getData(filled); empty =
|
|
||||||
* MineTweakerMC.getIItemStack(data.emptyContainer); amount = data.fluid; }
|
|
||||||
*
|
|
||||||
* @Override public void apply() { removeContainerInner(filled); }
|
|
||||||
*
|
|
||||||
* @Override public boolean canUndo() { return true; }
|
|
||||||
*
|
|
||||||
* @Override public void undo() {
|
|
||||||
* FluidContainerRegistry.registerFluidContainer(amount,
|
|
||||||
* MineTweakerMC.getItemStack(filled), MineTweakerMC.getItemStack(empty)); }
|
|
||||||
*
|
|
||||||
* @Override public String describe() { return "Removing liquid container "
|
|
||||||
* + filled; }
|
|
||||||
*
|
|
||||||
* @Override public String describeUndo() { return
|
|
||||||
* "Restoring liquid container " + filled; }
|
|
||||||
*
|
|
||||||
* @Override public Object getOverrideKey() { return null; } }
|
|
||||||
*/
|
|
||||||
|
|
||||||
private class ActionSetLuminosity implements IUndoableAction {
|
|
||||||
private final int oldValue;
|
|
||||||
private final int newValue;
|
|
||||||
|
|
||||||
public ActionSetLuminosity(int newValue) {
|
|
||||||
oldValue = getLuminosity();
|
|
||||||
this.newValue = newValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void apply() {
|
|
||||||
fluid.setLuminosity(newValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canUndo() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void undo() {
|
|
||||||
fluid.setLuminosity(oldValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describe() {
|
|
||||||
return "Setting " + fluid.getName() + " luminosity to " + newValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describeUndo() {
|
|
||||||
return "Restoring " + fluid.getName() + " luminosity to " + oldValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getOverrideKey() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class ActionSetDensity implements IUndoableAction {
|
|
||||||
private final int oldValue;
|
|
||||||
private final int newValue;
|
|
||||||
|
|
||||||
public ActionSetDensity(int newValue) {
|
|
||||||
oldValue = getDensity();
|
|
||||||
this.newValue = newValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void apply() {
|
|
||||||
fluid.setDensity(newValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canUndo() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void undo() {
|
|
||||||
fluid.setDensity(oldValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describe() {
|
|
||||||
return "Setting " + fluid.getName() + " density to " + newValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describeUndo() {
|
|
||||||
return "Restoring " + fluid.getName() + " density to " + oldValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getOverrideKey() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class ActionSetTemperature implements IUndoableAction {
|
|
||||||
private final int oldValue;
|
|
||||||
private final int newValue;
|
|
||||||
|
|
||||||
public ActionSetTemperature(int newValue) {
|
|
||||||
oldValue = getTemperature();
|
|
||||||
this.newValue = newValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void apply() {
|
|
||||||
fluid.setTemperature(newValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canUndo() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void undo() {
|
|
||||||
fluid.setTemperature(oldValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describe() {
|
|
||||||
return "Setting " + fluid.getName() + " temperature to " + newValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describeUndo() {
|
|
||||||
return "Restoring " + fluid.getName() + " temperature to " + oldValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getOverrideKey() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class ActionSetViscosity implements IUndoableAction {
|
|
||||||
private final int oldValue;
|
|
||||||
private final int newValue;
|
|
||||||
|
|
||||||
public ActionSetViscosity(int newValue) {
|
|
||||||
oldValue = getViscosity();
|
|
||||||
this.newValue = newValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void apply() {
|
|
||||||
fluid.setViscosity(newValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canUndo() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void undo() {
|
|
||||||
fluid.setViscosity(oldValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describe() {
|
|
||||||
return "Setting " + fluid.getName() + " viscosity to " + newValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describeUndo() {
|
|
||||||
return "Restoring " + fluid.getName() + " viscosity to " + oldValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getOverrideKey() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class ActionSetGaseous implements IUndoableAction {
|
|
||||||
private final boolean oldValue;
|
|
||||||
private final boolean newValue;
|
|
||||||
|
|
||||||
public ActionSetGaseous(boolean newValue) {
|
|
||||||
oldValue = isGaseous();
|
|
||||||
this.newValue = newValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void apply() {
|
|
||||||
fluid.setGaseous(newValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canUndo() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void undo() {
|
|
||||||
fluid.setGaseous(oldValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describe() {
|
|
||||||
return "Setting " + fluid.getName() + " gaseous to " + newValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String describeUndo() {
|
|
||||||
return "Restoring " + fluid.getName() + " gaseous to " + oldValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getOverrideKey() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
package minetweaker.mc1710.mods;
|
|
||||||
|
|
||||||
import cpw.mods.fml.common.Loader;
|
|
||||||
import cpw.mods.fml.common.ModContainer;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import minetweaker.api.mods.ILoadedMods;
|
|
||||||
import minetweaker.api.mods.IMod;
|
|
||||||
import stanhebben.zenscript.util.MappingIterator;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class MCLoadedMods implements ILoadedMods {
|
|
||||||
public MCLoadedMods() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean contains(String name) {
|
|
||||||
return Loader.isModLoaded(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IMod get(String name) {
|
|
||||||
for (ModContainer mod : Loader.instance().getActiveModList()) {
|
|
||||||
if (mod.getModId().equals(name)) {
|
|
||||||
return new MCMod(mod);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Iterator<IMod> iterator() {
|
|
||||||
List<ModContainer> mods = Loader.instance().getActiveModList();
|
|
||||||
return new MappingIterator<ModContainer, IMod>(mods.iterator()) {
|
|
||||||
@Override
|
|
||||||
public IMod map(ModContainer value) {
|
|
||||||
return new MCMod(value);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package minetweaker.mc1710.mods;
|
|
||||||
|
|
||||||
import cpw.mods.fml.common.ModContainer;
|
|
||||||
import minetweaker.api.mods.IMod;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class MCMod implements IMod {
|
|
||||||
private final ModContainer mod;
|
|
||||||
|
|
||||||
public MCMod(ModContainer mod) {
|
|
||||||
this.mod = mod;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getId() {
|
|
||||||
return mod.getModId();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return mod.getName();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getVersion() {
|
|
||||||
return mod.getVersion();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getDescription() {
|
|
||||||
return mod.getMetadata().description;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-32
@@ -1,32 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package minetweaker.mc1710.network;
|
|
||||||
|
|
||||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
|
||||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
|
||||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
|
||||||
import java.awt.Desktop;
|
|
||||||
import java.awt.Toolkit;
|
|
||||||
import java.awt.datatransfer.Clipboard;
|
|
||||||
import java.awt.datatransfer.StringSelection;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class MineTweakerCopyClipboardHandler implements IMessageHandler<MineTweakerCopyClipboardPacket, IMessage> {
|
|
||||||
@Override
|
|
||||||
public IMessage onMessage(MineTweakerCopyClipboardPacket message, MessageContext ctx) {
|
|
||||||
if (Desktop.isDesktopSupported()) {
|
|
||||||
StringSelection stringSelection = new StringSelection(message.getData());
|
|
||||||
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
|
|
||||||
clipboard.setContents(stringSelection, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-42
@@ -1,42 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package minetweaker.mc1710.network;
|
|
||||||
|
|
||||||
import static com.google.common.base.Charsets.UTF_8;
|
|
||||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
|
||||||
import io.netty.buffer.ByteBuf;
|
|
||||||
import java.nio.ByteBuffer;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class MineTweakerCopyClipboardPacket implements IMessage
|
|
||||||
{
|
|
||||||
private String data;
|
|
||||||
|
|
||||||
public MineTweakerCopyClipboardPacket() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public MineTweakerCopyClipboardPacket(String data) {
|
|
||||||
this.data = data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getData() {
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void fromBytes(ByteBuf buf) {
|
|
||||||
data = UTF_8.decode(ByteBuffer.wrap(buf.array())).toString().trim();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void toBytes(ByteBuf buf) {
|
|
||||||
buf.writeBytes(UTF_8.encode(data).array());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-43
@@ -1,43 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package minetweaker.mc1710.network;
|
|
||||||
|
|
||||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
|
||||||
import io.netty.buffer.ByteBuf;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class MineTweakerLoadScriptsPacket implements IMessage {
|
|
||||||
private byte[] data;
|
|
||||||
|
|
||||||
public MineTweakerLoadScriptsPacket() {
|
|
||||||
// used for deserialization
|
|
||||||
}
|
|
||||||
|
|
||||||
public MineTweakerLoadScriptsPacket(byte[] data) {
|
|
||||||
this.data = data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte[] getData() {
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void fromBytes(ByteBuf buf) {
|
|
||||||
int size = buf.readInt();
|
|
||||||
data = new byte[size];
|
|
||||||
buf.readBytes(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void toBytes(ByteBuf buf) {
|
|
||||||
buf.writeInt(data.length);
|
|
||||||
buf.writeBytes(data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-37
@@ -1,37 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package minetweaker.mc1710.network;
|
|
||||||
|
|
||||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
|
||||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
|
||||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
|
||||||
import java.awt.Desktop;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.URI;
|
|
||||||
import java.net.URISyntaxException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class MineTweakerOpenBrowserHandler implements IMessageHandler<MineTweakerOpenBrowserPacket, IMessage> {
|
|
||||||
@Override
|
|
||||||
public IMessage onMessage(MineTweakerOpenBrowserPacket message, MessageContext ctx) {
|
|
||||||
if (Desktop.isDesktopSupported()) {
|
|
||||||
Desktop desktop = Desktop.getDesktop();
|
|
||||||
try {
|
|
||||||
desktop.browse(new URI(message.getUrl()));
|
|
||||||
} catch (IOException e) {
|
|
||||||
} catch (URISyntaxException e) {
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
System.out.println("Desktop not supported");
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-44
@@ -1,44 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package minetweaker.mc1710.network;
|
|
||||||
|
|
||||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
|
||||||
import io.netty.buffer.ByteBuf;
|
|
||||||
import java.nio.ByteBuffer;
|
|
||||||
import java.nio.charset.Charset;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class MineTweakerOpenBrowserPacket implements IMessage {
|
|
||||||
private static final Charset UTF8 = Charset.forName("utf-8");
|
|
||||||
|
|
||||||
private String url;
|
|
||||||
|
|
||||||
public MineTweakerOpenBrowserPacket() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public MineTweakerOpenBrowserPacket(String url) {
|
|
||||||
this.url = url;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUrl() {
|
|
||||||
return url;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void fromBytes(ByteBuf buf) {
|
|
||||||
url = UTF8.decode(ByteBuffer.wrap(buf.array())).toString().trim();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void toBytes(ByteBuf buf) {
|
|
||||||
buf.writeBytes(UTF8.encode(url).array());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package minetweaker.mc1710.oredict;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import minetweaker.api.minecraft.MineTweakerMC;
|
|
||||||
import static minetweaker.api.minecraft.MineTweakerMC.getOreDict;
|
|
||||||
import minetweaker.api.oredict.IOreDict;
|
|
||||||
import minetweaker.api.oredict.IOreDictEntry;
|
|
||||||
import net.minecraftforge.oredict.OreDictionary;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class MCOreDict implements IOreDict {
|
|
||||||
@Override
|
|
||||||
public IOreDictEntry get(String name) {
|
|
||||||
return getOreDict(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<IOreDictEntry> getEntries() {
|
|
||||||
List<IOreDictEntry> entries = new ArrayList<IOreDictEntry>();
|
|
||||||
for (String key : OreDictionary.getOreNames()) {
|
|
||||||
if (!OreDictionary.getOres(key).isEmpty()) {
|
|
||||||
entries.add(MineTweakerMC.getOreDict(key));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return entries;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,164 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package minetweaker.mc1710.player;
|
|
||||||
|
|
||||||
import minetweaker.MineTweakerAPI;
|
|
||||||
import minetweaker.api.chat.IChatMessage;
|
|
||||||
import minetweaker.api.data.IData;
|
|
||||||
import minetweaker.api.item.IItemStack;
|
|
||||||
import minetweaker.api.minecraft.MineTweakerMC;
|
|
||||||
import minetweaker.api.player.IPlayer;
|
|
||||||
import minetweaker.mc1710.MineTweakerMod;
|
|
||||||
import minetweaker.mc1710.data.NBTConverter;
|
|
||||||
import minetweaker.mc1710.network.MineTweakerCopyClipboardPacket;
|
|
||||||
import minetweaker.mc1710.network.MineTweakerOpenBrowserPacket;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.entity.player.EntityPlayerMP;
|
|
||||||
import net.minecraft.util.ChatComponentText;
|
|
||||||
import net.minecraft.util.IChatComponent;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class MCPlayer implements IPlayer {
|
|
||||||
private final EntityPlayer player;
|
|
||||||
|
|
||||||
public MCPlayer(EntityPlayer player) {
|
|
||||||
this.player = player;
|
|
||||||
}
|
|
||||||
|
|
||||||
public EntityPlayer getInternal() {
|
|
||||||
return player;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getId() {
|
|
||||||
return null; // TODO: we should be having this for MC 1.7.10, right?
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return player.getCommandSenderName();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IData getData() {
|
|
||||||
return NBTConverter.from(player.getEntityData(), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getXP() {
|
|
||||||
return player.experienceLevel;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setXP(int xp) {
|
|
||||||
player.experienceLevel = 0;
|
|
||||||
player.addExperienceLevel(xp);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void removeXP(int xp) {
|
|
||||||
final int newLvl = Math.max(0, player.experienceLevel - xp);
|
|
||||||
player.experienceLevel = 0;
|
|
||||||
player.addExperienceLevel(newLvl);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void update(IData data) {
|
|
||||||
NBTConverter.updateMap(player.getEntityData(), data);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendChat(IChatMessage message) {
|
|
||||||
Object internal = message.getInternal();
|
|
||||||
if (!(internal instanceof IChatComponent)) {
|
|
||||||
MineTweakerAPI.logError("not a valid chat message");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
player.addChatMessage((IChatComponent) internal);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendChat(String message) {
|
|
||||||
player.addChatMessage(new ChatComponentText(message));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getHotbarSize() {
|
|
||||||
return 9;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IItemStack getHotbarStack(int i) {
|
|
||||||
return i < 0 || i >= 9 ? null : MineTweakerMC.getIItemStack(player.inventory.getStackInSlot(i));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getInventorySize() {
|
|
||||||
return player.inventory.getSizeInventory();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IItemStack getInventoryStack(int i) {
|
|
||||||
return MineTweakerMC.getIItemStack(player.inventory.getStackInSlot(i));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IItemStack getCurrentItem() {
|
|
||||||
return MineTweakerMC.getIItemStack(player.getCurrentEquippedItem());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isCreative() {
|
|
||||||
return player.capabilities.isCreativeMode;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAdventure() {
|
|
||||||
return !player.capabilities.allowEdit;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void openBrowser(String url) {
|
|
||||||
if (player instanceof EntityPlayerMP) {
|
|
||||||
MineTweakerMod.NETWORK.sendTo(
|
|
||||||
new MineTweakerOpenBrowserPacket(url),
|
|
||||||
(EntityPlayerMP) player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void copyToClipboard(String value) {
|
|
||||||
if (player instanceof EntityPlayerMP) {
|
|
||||||
MineTweakerMod.NETWORK.sendTo(
|
|
||||||
new MineTweakerCopyClipboardPacket(value),
|
|
||||||
(EntityPlayerMP) player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object other) {
|
|
||||||
if (other.getClass() != this.getClass())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return ((MCPlayer) other).player == player;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
int hash = 5;
|
|
||||||
hash = 23 * hash + (this.player != null ? this.player.hashCode() : 0);
|
|
||||||
return hash;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void give(IItemStack stack) {
|
|
||||||
player.inventory.addItemStackToInventory(MineTweakerMC.getItemStack(stack).copy());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-213
@@ -1,213 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package minetweaker.mc1710.recipes;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import minetweaker.mc1710.player.MCPlayer;
|
|
||||||
import minetweaker.mc1710.util.MineTweakerHacks;
|
|
||||||
import minetweaker.api.item.IItemStack;
|
|
||||||
import static minetweaker.api.minecraft.MineTweakerMC.getIItemStack;
|
|
||||||
import static minetweaker.api.minecraft.MineTweakerMC.getIPlayer;
|
|
||||||
import static minetweaker.api.minecraft.MineTweakerMC.getItemStack;
|
|
||||||
import minetweaker.api.player.IPlayer;
|
|
||||||
import minetweaker.api.recipes.ICraftingInventory;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.inventory.Container;
|
|
||||||
import net.minecraft.inventory.IInventory;
|
|
||||||
import net.minecraft.inventory.InventoryCrafting;
|
|
||||||
import net.minecraft.inventory.Slot;
|
|
||||||
import net.minecraft.inventory.SlotCrafting;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class MCCraftingInventory implements ICraftingInventory {
|
|
||||||
private static final ThreadLocal<MCCraftingInventory> cache = new ThreadLocal<MCCraftingInventory>();
|
|
||||||
private static final ThreadLocal<MCCraftingInventory> cache2 = new ThreadLocal<MCCraftingInventory>();
|
|
||||||
|
|
||||||
public static MCCraftingInventory get(InventoryCrafting inventory) {
|
|
||||||
if (cache.get() == null || cache.get().inventory != inventory) {
|
|
||||||
MCCraftingInventory result = new MCCraftingInventory(inventory);
|
|
||||||
cache.set(result);
|
|
||||||
return result;
|
|
||||||
} else {
|
|
||||||
MCCraftingInventory result = cache.get();
|
|
||||||
result.update();
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static MCCraftingInventory get(IInventory inventory, EntityPlayer player) {
|
|
||||||
if (cache2.get() == null || cache2.get().inventory != inventory || cache2.get().player != player) {
|
|
||||||
MCCraftingInventory result = new MCCraftingInventory(inventory, player);
|
|
||||||
cache2.set(result);
|
|
||||||
return result;
|
|
||||||
} else {
|
|
||||||
MCCraftingInventory result = cache2.get();
|
|
||||||
result.update();
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private int width;
|
|
||||||
private int height;
|
|
||||||
private final IInventory inventory;
|
|
||||||
private IItemStack[] stacks;
|
|
||||||
private ItemStack[] original;
|
|
||||||
private int stackCount;
|
|
||||||
private final IPlayer player;
|
|
||||||
private final EntityPlayer playerOrig;
|
|
||||||
|
|
||||||
private MCCraftingInventory(InventoryCrafting inventory) {
|
|
||||||
this.inventory = inventory;
|
|
||||||
width = height = (int) Math.sqrt(inventory.getSizeInventory());
|
|
||||||
stacks = new IItemStack[width * height];
|
|
||||||
original = new ItemStack[stacks.length];
|
|
||||||
stackCount = 0;
|
|
||||||
update();
|
|
||||||
|
|
||||||
Container container = MineTweakerHacks.getCraftingContainer(inventory);
|
|
||||||
if (container != null) {
|
|
||||||
List<Slot> slots = container.inventorySlots;
|
|
||||||
if (!slots.isEmpty() && slots.get(0) instanceof SlotCrafting) {
|
|
||||||
SlotCrafting slotCrafting = (SlotCrafting) slots.get(0);
|
|
||||||
playerOrig = MineTweakerHacks.getCraftingSlotPlayer(slotCrafting);
|
|
||||||
player = getIPlayer(playerOrig);
|
|
||||||
} else {
|
|
||||||
playerOrig = null;
|
|
||||||
player = null;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
playerOrig = null;
|
|
||||||
player = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public MCCraftingInventory(IInventory inventory, EntityPlayer player) {
|
|
||||||
this.inventory = inventory;
|
|
||||||
width = height = (int) Math.sqrt(inventory.getSizeInventory());
|
|
||||||
stacks = new IItemStack[width * height];
|
|
||||||
original = new ItemStack[stacks.length];
|
|
||||||
stackCount = 0;
|
|
||||||
update();
|
|
||||||
|
|
||||||
playerOrig = player;
|
|
||||||
this.player = player == null ? null : new MCPlayer(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void update() {
|
|
||||||
if (inventory.getSizeInventory() != original.length) {
|
|
||||||
width = height = (int) Math.sqrt(inventory.getSizeInventory());
|
|
||||||
stacks = new IItemStack[inventory.getSizeInventory()];
|
|
||||||
original = new ItemStack[stacks.length];
|
|
||||||
stackCount = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < inventory.getSizeInventory(); i++) {
|
|
||||||
if (changed(i)) {
|
|
||||||
// System.out.println("Slot " + i + " changed");
|
|
||||||
original[i] = inventory.getStackInSlot(i);
|
|
||||||
if (inventory.getStackInSlot(i) != null) {
|
|
||||||
if (stacks[i] == null)
|
|
||||||
stackCount++;
|
|
||||||
stacks[i] = getIItemStack(original[i]);
|
|
||||||
} else {
|
|
||||||
if (stacks[i] != null)
|
|
||||||
stackCount--;
|
|
||||||
stacks[i] = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// System.out.println("Num stack count: " + stackCount);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IPlayer getPlayer() {
|
|
||||||
return player;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getSize() {
|
|
||||||
return width * height;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getWidth() {
|
|
||||||
return width;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getHeight() {
|
|
||||||
return height;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getStackCount() {
|
|
||||||
return stackCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IItemStack getStack(int i) {
|
|
||||||
return stacks[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IItemStack getStack(int x, int y) {
|
|
||||||
return stacks[y * width + x];
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setStack(int x, int y, IItemStack stack) {
|
|
||||||
// System.out.println("SetStack(" + x + ", " + y + ") " + stack);
|
|
||||||
|
|
||||||
int ix = y * width + x;
|
|
||||||
if (stack != stacks[ix]) {
|
|
||||||
if (stack == null) {
|
|
||||||
stackCount--;
|
|
||||||
inventory.setInventorySlotContents(ix, null);
|
|
||||||
} else {
|
|
||||||
inventory.setInventorySlotContents(ix, getItemStack(stack));
|
|
||||||
|
|
||||||
if (stacks[ix] == null) {
|
|
||||||
stackCount++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
stacks[ix] = stack;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setStack(int i, IItemStack stack) {
|
|
||||||
// System.out.println("SetStack(" + i + ") " + stack);
|
|
||||||
|
|
||||||
if (stack != stacks[i]) {
|
|
||||||
if (stack == null) {
|
|
||||||
stackCount--;
|
|
||||||
inventory.setInventorySlotContents(i, null);
|
|
||||||
} else {
|
|
||||||
inventory.setInventorySlotContents(i, getItemStack(stack));
|
|
||||||
|
|
||||||
if (stacks[i] == null) {
|
|
||||||
stackCount++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
stacks[i] = stack;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean changed(int i) {
|
|
||||||
if (original[i] != inventory.getStackInSlot(i))
|
|
||||||
return true;
|
|
||||||
if (original[i] != null && stacks[i].getAmount() != original[i].stackSize)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-187
@@ -1,187 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package minetweaker.mc1710.recipes;
|
|
||||||
|
|
||||||
import minetweaker.api.recipes.ShapedRecipe;
|
|
||||||
import minetweaker.api.recipes.ShapelessRecipe;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import minetweaker.api.item.IIngredient;
|
|
||||||
import minetweaker.api.item.IItemStack;
|
|
||||||
import minetweaker.api.minecraft.MineTweakerMC;
|
|
||||||
import static minetweaker.api.minecraft.MineTweakerMC.getItemStack;
|
|
||||||
import minetweaker.api.recipes.ICraftingRecipe;
|
|
||||||
import minetweaker.api.recipes.UnknownRecipe;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.item.crafting.IRecipe;
|
|
||||||
import net.minecraft.item.crafting.ShapedRecipes;
|
|
||||||
import net.minecraft.item.crafting.ShapelessRecipes;
|
|
||||||
import net.minecraftforge.oredict.ShapedOreRecipe;
|
|
||||||
import net.minecraftforge.oredict.ShapelessOreRecipe;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class RecipeConverter {
|
|
||||||
private RecipeConverter() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final int TYPE_ADVANCED = 0;
|
|
||||||
public static final int TYPE_ORE = 1;
|
|
||||||
public static final int TYPE_BASIC = 2;
|
|
||||||
|
|
||||||
private static int getIngredientType(IIngredient pattern) {
|
|
||||||
Object internal = pattern.getInternal();
|
|
||||||
if (internal == null) {
|
|
||||||
return TYPE_ADVANCED;
|
|
||||||
} else if (internal instanceof ItemStack) {
|
|
||||||
return TYPE_BASIC;
|
|
||||||
} else {
|
|
||||||
return TYPE_ORE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static int getRecipeType(IIngredient[] ingredients) {
|
|
||||||
int type = TYPE_BASIC;
|
|
||||||
for (IIngredient ingredient : ingredients) {
|
|
||||||
type = Math.min(type, getIngredientType(ingredient));
|
|
||||||
}
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
public static IRecipe convert(ICraftingRecipe recipe) {
|
|
||||||
if (recipe instanceof ShapedRecipe)
|
|
||||||
return RecipeConverter.convert((ShapedRecipe)recipe);
|
|
||||||
else
|
|
||||||
return RecipeConverter.convert((ShapelessRecipe) recipe);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IRecipe convert(ShapelessRecipe recipe) {
|
|
||||||
IIngredient[] ingredients = recipe.getIngredients();
|
|
||||||
int type = getRecipeType(ingredients);
|
|
||||||
|
|
||||||
if (type == TYPE_BASIC) {
|
|
||||||
ItemStack[] items = new ItemStack[ingredients.length];
|
|
||||||
for (int i = 0; i < ingredients.length; i++) {
|
|
||||||
items[i] = getItemStack(ingredients[i]);
|
|
||||||
}
|
|
||||||
return new ShapelessRecipeBasic(items, recipe);
|
|
||||||
} else if (type == TYPE_ORE) {
|
|
||||||
Object[] items = new Object[ingredients.length];
|
|
||||||
for (int i = 0; i < ingredients.length; i++) {
|
|
||||||
items[i] = ingredients[i].getInternal();
|
|
||||||
}
|
|
||||||
return new ShapelessRecipeOre(items, recipe);
|
|
||||||
} else {
|
|
||||||
return new ShapelessRecipeAdvanced(recipe);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IRecipe convert(ShapedRecipe recipe) {
|
|
||||||
IIngredient[] ingredients = recipe.getIngredients();
|
|
||||||
byte[] posx = recipe.getIngredientsX();
|
|
||||||
byte[] posy = recipe.getIngredientsY();
|
|
||||||
|
|
||||||
// determine recipe type
|
|
||||||
int type = getRecipeType(ingredients);
|
|
||||||
|
|
||||||
// construct recipe
|
|
||||||
if (type == TYPE_BASIC) {
|
|
||||||
ItemStack[] basicIngredients = new ItemStack[recipe.getHeight() * recipe.getWidth()];
|
|
||||||
for (int i = 0; i < ingredients.length; i++) {
|
|
||||||
basicIngredients[posx[i] + posy[i] * recipe.getWidth()] = getItemStack(ingredients[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return new ShapedRecipeBasic(basicIngredients, recipe);
|
|
||||||
} else if (type == TYPE_ORE) {
|
|
||||||
Object[] converted = new Object[recipe.getHeight() * recipe.getWidth()];
|
|
||||||
for (int i = 0; i < ingredients.length; i++) {
|
|
||||||
converted[posx[i] + posy[i] * recipe.getWidth()] = ingredients[i].getInternal();
|
|
||||||
}
|
|
||||||
|
|
||||||
// arguments contents:
|
|
||||||
// 1) recipe patterns
|
|
||||||
// 2) characters + ingredients
|
|
||||||
|
|
||||||
int counter = 0;
|
|
||||||
String[] parts = new String[recipe.getHeight()];
|
|
||||||
ArrayList rarguments = new ArrayList();
|
|
||||||
for (int i = 0; i < recipe.getHeight(); i++) {
|
|
||||||
char[] pattern = new char[recipe.getWidth()];
|
|
||||||
for (int j = 0; j < recipe.getWidth(); j++) {
|
|
||||||
int off = i * recipe.getWidth() + j;
|
|
||||||
if (converted[off] == null) {
|
|
||||||
pattern[j] = ' ';
|
|
||||||
} else {
|
|
||||||
pattern[j] = (char) ('A' + counter);
|
|
||||||
rarguments.add(pattern[j]);
|
|
||||||
rarguments.add(converted[off]);
|
|
||||||
counter++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
parts[i] = new String(pattern);
|
|
||||||
}
|
|
||||||
|
|
||||||
rarguments.addAll(0, Arrays.asList(parts));
|
|
||||||
|
|
||||||
return new ShapedRecipeOre(rarguments.toArray(), recipe);
|
|
||||||
} else {
|
|
||||||
return new ShapedRecipeAdvanced(recipe);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ICraftingRecipe toCraftingRecipe(IRecipe recipe) {
|
|
||||||
IItemStack output = MineTweakerMC.getIItemStack(recipe.getRecipeOutput());
|
|
||||||
|
|
||||||
if (recipe instanceof ShapelessRecipes) {
|
|
||||||
ShapelessRecipes shapeless = (ShapelessRecipes) recipe;
|
|
||||||
|
|
||||||
IIngredient[] ingredients = new IIngredient[shapeless.recipeItems.size()];
|
|
||||||
for (int i = 0; i < ingredients.length; i++) {
|
|
||||||
ingredients[i] = MineTweakerMC.getIIngredient(shapeless.recipeItems.get(i));
|
|
||||||
}
|
|
||||||
|
|
||||||
return new ShapelessRecipe(output, ingredients, null, null);
|
|
||||||
} else if (recipe instanceof ShapedRecipes) {
|
|
||||||
ShapedRecipes shaped = (ShapedRecipes) recipe;
|
|
||||||
|
|
||||||
IIngredient[][] ingredients = new IIngredient[shaped.recipeHeight][shaped.recipeWidth];
|
|
||||||
for (int i = 0; i < shaped.recipeHeight; i++) {
|
|
||||||
for (int j = 0; j < shaped.recipeWidth; j++) {
|
|
||||||
ingredients[i][j] = MineTweakerMC.getIItemStack(shaped.recipeItems[i * shaped.recipeWidth + j]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return new ShapedRecipe(output, ingredients, null, null, false);
|
|
||||||
} else if (recipe instanceof ShapedOreRecipe) {
|
|
||||||
ShapedOreRecipe shaped = (ShapedOreRecipe) recipe;
|
|
||||||
|
|
||||||
int width = (int) Math.sqrt(recipe.getRecipeSize());
|
|
||||||
int height = recipe.getRecipeSize() / width;
|
|
||||||
|
|
||||||
IIngredient[][] recipeIngredients = new IIngredient[height][width];
|
|
||||||
for (int i = 0; i < height; i++) {
|
|
||||||
for (int j = 0; j < width; j++) {
|
|
||||||
recipeIngredients[i][j] = MineTweakerMC.getIIngredient(shaped.getInput()[i * width + j]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return new ShapedRecipe(output, recipeIngredients, null, null, false);
|
|
||||||
} else if (recipe instanceof ShapelessOreRecipe) {
|
|
||||||
ShapelessOreRecipe shapeless = (ShapelessOreRecipe) recipe;
|
|
||||||
|
|
||||||
IIngredient[] ingredients = new IIngredient[shapeless.getRecipeSize()];
|
|
||||||
for (int i = 0; i < ingredients.length; i++) {
|
|
||||||
ingredients[i] = MineTweakerMC.getIIngredient(shapeless.getInput().get(i));
|
|
||||||
}
|
|
||||||
|
|
||||||
return new ShapelessRecipe(output, ingredients, null, null);
|
|
||||||
} else {
|
|
||||||
return new UnknownRecipe(output);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-47
@@ -1,47 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package minetweaker.mc1710.recipes;
|
|
||||||
|
|
||||||
import static minetweaker.api.minecraft.MineTweakerMC.getItemStack;
|
|
||||||
import minetweaker.api.recipes.ShapedRecipe;
|
|
||||||
import net.minecraft.inventory.InventoryCrafting;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.item.crafting.IRecipe;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* TODO: NEI integration for this kind of recipes.
|
|
||||||
*
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class ShapedRecipeAdvanced implements IRecipe {
|
|
||||||
private final ShapedRecipe recipe;
|
|
||||||
|
|
||||||
public ShapedRecipeAdvanced(ShapedRecipe recipe) {
|
|
||||||
this.recipe = recipe;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean matches(InventoryCrafting inventory, World world) {
|
|
||||||
return recipe.matches(MCCraftingInventory.get(inventory));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ItemStack getCraftingResult(InventoryCrafting inventory) {
|
|
||||||
return getItemStack(recipe.getCraftingResult(MCCraftingInventory.get(inventory))).copy();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getRecipeSize() {
|
|
||||||
return recipe.getWidth() * recipe.getHeight();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ItemStack getRecipeOutput() {
|
|
||||||
return getItemStack(recipe.getOutput());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-44
@@ -1,44 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package minetweaker.mc1710.recipes;
|
|
||||||
|
|
||||||
import minetweaker.api.item.IItemStack;
|
|
||||||
import static minetweaker.api.minecraft.MineTweakerMC.getItemStack;
|
|
||||||
import minetweaker.api.recipes.ShapedRecipe;
|
|
||||||
import net.minecraft.inventory.InventoryCrafting;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.item.crafting.ShapedRecipes;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class ShapedRecipeBasic extends ShapedRecipes {
|
|
||||||
private final ShapedRecipe recipe;
|
|
||||||
|
|
||||||
public ShapedRecipeBasic(ItemStack[] basicInputs, ShapedRecipe recipe) {
|
|
||||||
super(recipe.getWidth(), recipe.getHeight(), basicInputs, getItemStack(recipe.getOutput()));
|
|
||||||
|
|
||||||
this.recipe = recipe;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean matches(InventoryCrafting inventory, World world) {
|
|
||||||
return recipe.matches(MCCraftingInventory.get(inventory));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ItemStack getCraftingResult(InventoryCrafting inventory) {
|
|
||||||
IItemStack result = recipe.getCraftingResult(MCCraftingInventory.get(inventory));
|
|
||||||
if (result == null) {
|
|
||||||
return null;
|
|
||||||
} else {
|
|
||||||
return getItemStack(result).copy();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-46
@@ -1,46 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package minetweaker.mc1710.recipes;
|
|
||||||
|
|
||||||
import static minetweaker.api.minecraft.MineTweakerMC.getItemStack;
|
|
||||||
import minetweaker.api.recipes.ShapelessRecipe;
|
|
||||||
import net.minecraft.inventory.InventoryCrafting;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.item.crafting.IRecipe;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class ShapelessRecipeAdvanced implements IRecipe {
|
|
||||||
private final ShapelessRecipe recipe;
|
|
||||||
|
|
||||||
public ShapelessRecipeAdvanced(ShapelessRecipe recipe) {
|
|
||||||
this.recipe = recipe;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean matches(InventoryCrafting inventory, World world) {
|
|
||||||
return recipe.matches(MCCraftingInventory.get(inventory));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ItemStack getCraftingResult(InventoryCrafting inventory) {
|
|
||||||
return getItemStack(recipe.getCraftingResult(MCCraftingInventory.get(inventory))).copy();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getRecipeSize() {
|
|
||||||
return recipe.getSize();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ItemStack getRecipeOutput() {
|
|
||||||
return getItemStack(recipe.getOutput());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-39
@@ -1,39 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package minetweaker.mc1710.recipes;
|
|
||||||
|
|
||||||
import minetweaker.api.recipes.ShapelessRecipe;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import static minetweaker.api.minecraft.MineTweakerMC.getItemStack;
|
|
||||||
import net.minecraft.inventory.InventoryCrafting;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.item.crafting.ShapelessRecipes;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class ShapelessRecipeBasic extends ShapelessRecipes {
|
|
||||||
private final ShapelessRecipe recipe;
|
|
||||||
|
|
||||||
public ShapelessRecipeBasic(ItemStack[] ingredients, ShapelessRecipe recipe) {
|
|
||||||
super(getItemStack(recipe.getOutput()), Arrays.asList(ingredients));
|
|
||||||
|
|
||||||
this.recipe = recipe;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean matches(InventoryCrafting inventory, World world) {
|
|
||||||
return recipe.matches(MCCraftingInventory.get(inventory));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ItemStack getCraftingResult(InventoryCrafting inventory) {
|
|
||||||
return getItemStack(recipe.getCraftingResult(MCCraftingInventory.get(inventory))).copy();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-38
@@ -1,38 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package minetweaker.mc1710.recipes;
|
|
||||||
|
|
||||||
import static minetweaker.api.minecraft.MineTweakerMC.getItemStack;
|
|
||||||
import minetweaker.api.recipes.ShapelessRecipe;
|
|
||||||
import net.minecraft.inventory.InventoryCrafting;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import net.minecraftforge.oredict.ShapelessOreRecipe;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class ShapelessRecipeOre extends ShapelessOreRecipe {
|
|
||||||
private final ShapelessRecipe recipe;
|
|
||||||
|
|
||||||
public ShapelessRecipeOre(Object[] ingredients, ShapelessRecipe recipe) {
|
|
||||||
super(getItemStack(recipe.getOutput()), ingredients);
|
|
||||||
|
|
||||||
this.recipe = recipe;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean matches(InventoryCrafting inventory, World world) {
|
|
||||||
return recipe.matches(MCCraftingInventory.get(inventory));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ItemStack getCraftingResult(InventoryCrafting inventory) {
|
|
||||||
return getItemStack(recipe.getCraftingResult(MCCraftingInventory.get(inventory))).copy();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,141 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package minetweaker.mc1710.server;
|
|
||||||
|
|
||||||
import java.awt.Desktop;
|
|
||||||
import java.awt.Toolkit;
|
|
||||||
import java.awt.datatransfer.Clipboard;
|
|
||||||
import java.awt.datatransfer.StringSelection;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.URI;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
import minetweaker.api.chat.IChatMessage;
|
|
||||||
import minetweaker.api.data.IData;
|
|
||||||
import minetweaker.api.item.IItemStack;
|
|
||||||
import minetweaker.api.player.IPlayer;
|
|
||||||
import net.minecraft.server.dedicated.DedicatedServer;
|
|
||||||
import net.minecraft.util.ChatComponentText;
|
|
||||||
import net.minecraft.util.IChatComponent;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class ServerPlayer implements IPlayer {
|
|
||||||
public static final ServerPlayer INSTANCE = new ServerPlayer();
|
|
||||||
|
|
||||||
private ServerPlayer() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getId() {
|
|
||||||
return "server";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return "Server";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IData getData() {
|
|
||||||
// TODO: implement
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getXP() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setXP(int xp) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void removeXP(int xp) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void update(IData data) {
|
|
||||||
// TODO: implement
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendChat(IChatMessage message) {
|
|
||||||
DedicatedServer.getServer().addChatMessage((IChatComponent) message.getInternal());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendChat(String message) {
|
|
||||||
DedicatedServer.getServer().addChatMessage(new ChatComponentText(message));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getHotbarSize() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IItemStack getHotbarStack(int i) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getInventorySize() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IItemStack getInventoryStack(int i) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IItemStack getCurrentItem() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isCreative() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAdventure() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void openBrowser(String url) {
|
|
||||||
if (Desktop.isDesktopSupported()) {
|
|
||||||
try {
|
|
||||||
Desktop.getDesktop().browse(URI.create(url));
|
|
||||||
} catch (IOException ex) {
|
|
||||||
Logger.getLogger(ServerPlayer.class.getName()).log(Level.SEVERE, null, ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void copyToClipboard(String value) {
|
|
||||||
if (Desktop.isDesktopSupported()) {
|
|
||||||
StringSelection stringSelection = new StringSelection(value);
|
|
||||||
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
|
|
||||||
clipboard.setContents(stringSelection, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void give(IItemStack stack) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,289 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package minetweaker.mc1710.util;
|
|
||||||
|
|
||||||
import com.google.common.collect.BiMap;
|
|
||||||
import cpw.mods.fml.common.registry.EntityRegistry;
|
|
||||||
import java.io.File;
|
|
||||||
import java.lang.reflect.Constructor;
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
import minetweaker.MineTweakerAPI;
|
|
||||||
import minetweaker.api.item.WeightedItemStack;
|
|
||||||
import minetweaker.api.minecraft.MineTweakerMC;
|
|
||||||
import net.minecraft.entity.Entity;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.inventory.Container;
|
|
||||||
import net.minecraft.inventory.InventoryCrafting;
|
|
||||||
import net.minecraft.inventory.SlotCrafting;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.nbt.NBTBase;
|
|
||||||
import net.minecraft.nbt.NBTTagList;
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
|
||||||
import net.minecraft.util.StatCollector;
|
|
||||||
import net.minecraft.util.StringTranslate;
|
|
||||||
import net.minecraft.util.WeightedRandom;
|
|
||||||
import net.minecraftforge.common.ChestGenHooks;
|
|
||||||
import net.minecraftforge.common.ForgeHooks;
|
|
||||||
import net.minecraftforge.oredict.OreDictionary;
|
|
||||||
import net.minecraftforge.oredict.ShapedOreRecipe;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Common class for all runtime hacks (stuff requiring reflection). It is not
|
|
||||||
* unexpected to have it break with new minecraft versions and may need regular
|
|
||||||
* adjustment - as such, those have been collected here.
|
|
||||||
*
|
|
||||||
* @author Stan Hebben
|
|
||||||
*/
|
|
||||||
public class MineTweakerHacks {
|
|
||||||
private static final Field NBTTAGLIST_TAGLIST;
|
|
||||||
private static final Field OREDICTIONARY_IDTOSTACK;
|
|
||||||
private static final Field OREDICTIONARY_IDTOSTACKUN;
|
|
||||||
private static final Field MINECRAFTSERVER_ANVILFILE;
|
|
||||||
private static final Field SHAPEDORERECIPE_WIDTH;
|
|
||||||
private static final Field INVENTORYCRAFTING_EVENTHANDLER;
|
|
||||||
private static final Field SLOTCRAFTING_PLAYER;
|
|
||||||
|
|
||||||
private static final Field ENTITYREGISTRY_CLASSREGISTRATIONS;
|
|
||||||
private static final Field SEEDENTRY_SEED;
|
|
||||||
private static final Constructor<? extends WeightedRandom.Item> SEEDENTRY_CONSTRUCTOR;
|
|
||||||
|
|
||||||
static {
|
|
||||||
NBTTAGLIST_TAGLIST = getField(NBTTagList.class, MineTweakerObfuscation.NBTTAGLIST_TAGLIST);
|
|
||||||
OREDICTIONARY_IDTOSTACK = getField(OreDictionary.class, MineTweakerObfuscation.OREDICTIONARY_IDTOSTACK);
|
|
||||||
OREDICTIONARY_IDTOSTACKUN = getField(OreDictionary.class, MineTweakerObfuscation.OREDICTIONARY_IDTOSTACKUN);
|
|
||||||
MINECRAFTSERVER_ANVILFILE = getField(MinecraftServer.class, MineTweakerObfuscation.MINECRAFTSERVER_ANVILFILE);
|
|
||||||
SHAPEDORERECIPE_WIDTH = getField(ShapedOreRecipe.class, new String[] { "width" });
|
|
||||||
INVENTORYCRAFTING_EVENTHANDLER = getField(InventoryCrafting.class, MineTweakerObfuscation.INVENTORYCRAFTING_EVENTHANDLER);
|
|
||||||
SLOTCRAFTING_PLAYER = getField(SlotCrafting.class, MineTweakerObfuscation.SLOTCRAFTING_PLAYER);
|
|
||||||
|
|
||||||
ENTITYREGISTRY_CLASSREGISTRATIONS = getField(EntityRegistry.class, new String[] { "entityClassRegistrations" });
|
|
||||||
|
|
||||||
Class<? extends WeightedRandom.Item> forgeSeedEntry = null;
|
|
||||||
try {
|
|
||||||
forgeSeedEntry = (Class<? extends WeightedRandom.Item>) Class.forName("net.minecraftforge.common.ForgeHooks$SeedEntry");
|
|
||||||
} catch (ClassNotFoundException ex) {
|
|
||||||
}
|
|
||||||
|
|
||||||
SEEDENTRY_SEED = getField(forgeSeedEntry, "seed");
|
|
||||||
|
|
||||||
Constructor<? extends WeightedRandom.Item> seedEntryConstructor = null;
|
|
||||||
|
|
||||||
try {
|
|
||||||
seedEntryConstructor = forgeSeedEntry.getConstructor(ItemStack.class, int.class);
|
|
||||||
seedEntryConstructor.setAccessible(true);
|
|
||||||
} catch (NoSuchMethodException ex) {
|
|
||||||
Logger.getLogger(MineTweakerHacks.class.getName()).log(Level.SEVERE, null, ex);
|
|
||||||
} catch (SecurityException ex) {
|
|
||||||
Logger.getLogger(MineTweakerHacks.class.getName()).log(Level.SEVERE, null, ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
SEEDENTRY_CONSTRUCTOR = seedEntryConstructor;
|
|
||||||
}
|
|
||||||
|
|
||||||
private MineTweakerHacks() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public static BiMap<Class<? extends Entity>, EntityRegistry.EntityRegistration> getEntityClassRegistrations() {
|
|
||||||
try {
|
|
||||||
return (BiMap<Class<? extends Entity>, EntityRegistry.EntityRegistration>) ENTITYREGISTRY_CLASSREGISTRATIONS.get(EntityRegistry.instance());
|
|
||||||
} catch (IllegalArgumentException ex) {
|
|
||||||
return null;
|
|
||||||
} catch (IllegalAccessException ex) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<NBTBase> getTagList(NBTTagList list) {
|
|
||||||
if (NBTTAGLIST_TAGLIST == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
return (List) NBTTAGLIST_TAGLIST.get(list);
|
|
||||||
} catch (IllegalArgumentException ex) {
|
|
||||||
return null;
|
|
||||||
} catch (IllegalAccessException ex) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List getSeeds() {
|
|
||||||
return getPrivateStaticObject(ForgeHooks.class, "seedList");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Map<String, ChestGenHooks> getChestLoot() {
|
|
||||||
return getPrivateStaticObject(ChestGenHooks.class, "chestInfo");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Map getTranslations() {
|
|
||||||
return getPrivateObject(
|
|
||||||
getPrivateStaticObject(StatCollector.class, "localizedName", "field_74839_a"),
|
|
||||||
"languageList",
|
|
||||||
"field_74816_c");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<ArrayList<ItemStack>> getOreIdStacks() {
|
|
||||||
try {
|
|
||||||
return (List<ArrayList<ItemStack>>) OREDICTIONARY_IDTOSTACK.get(null);
|
|
||||||
} catch (IllegalAccessException ex) {
|
|
||||||
MineTweakerAPI.logError("ERROR - could not load ore dictionary stacks!");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<ArrayList<ItemStack>> getOreIdStacksUn() {
|
|
||||||
try {
|
|
||||||
return (List<ArrayList<ItemStack>>) OREDICTIONARY_IDTOSTACKUN.get(null);
|
|
||||||
} catch (IllegalAccessException ex) {
|
|
||||||
MineTweakerAPI.logError("ERROR - could not load ore dictionary stacks!");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static File getAnvilFile(MinecraftServer server) {
|
|
||||||
try {
|
|
||||||
return (File) MINECRAFTSERVER_ANVILFILE.get(server);
|
|
||||||
} catch (IllegalAccessException ex) {
|
|
||||||
MineTweakerAPI.logError("could not load anvil file!");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static File getWorldDirectory(MinecraftServer server) {
|
|
||||||
if (server.isDedicatedServer()) {
|
|
||||||
return server.getFile("world");
|
|
||||||
} else {
|
|
||||||
File worldsDir = getAnvilFile(server);
|
|
||||||
if (worldsDir == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
return new File(worldsDir, server.getFolderName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getShapedOreRecipeWidth(ShapedOreRecipe recipe) {
|
|
||||||
try {
|
|
||||||
return SHAPEDORERECIPE_WIDTH.getInt(recipe);
|
|
||||||
} catch (IllegalAccessException ex) {
|
|
||||||
MineTweakerAPI.logError("could not load anvil file!");
|
|
||||||
return 3;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Container getCraftingContainer(InventoryCrafting inventory) {
|
|
||||||
try {
|
|
||||||
return (Container) INVENTORYCRAFTING_EVENTHANDLER.get(inventory);
|
|
||||||
} catch (IllegalAccessException ex) {
|
|
||||||
MineTweakerAPI.logError("could not get inventory eventhandler");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static EntityPlayer getCraftingSlotPlayer(SlotCrafting slot) {
|
|
||||||
try {
|
|
||||||
return (EntityPlayer) SLOTCRAFTING_PLAYER.get(slot);
|
|
||||||
} catch (IllegalAccessException ex) {
|
|
||||||
MineTweakerAPI.logError("could not get inventory eventhandler");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static StringTranslate getStringTranslateInstance() {
|
|
||||||
try {
|
|
||||||
Field field = getField(StringTranslate.class, MineTweakerObfuscation.STRINGTRANSLATE_INSTANCE);
|
|
||||||
return (StringTranslate) field.get(null);
|
|
||||||
} catch (IllegalAccessException ex) {
|
|
||||||
MineTweakerAPI.logError("could not get string translator");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ItemStack getSeedEntrySeed(Object entry) {
|
|
||||||
try {
|
|
||||||
return (ItemStack) SEEDENTRY_SEED.get(entry);
|
|
||||||
} catch (IllegalAccessException ex) {
|
|
||||||
MineTweakerAPI.logError("could not get SeedEntry seed");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static WeightedRandom.Item constructSeedEntry(WeightedItemStack stack) {
|
|
||||||
try {
|
|
||||||
return SEEDENTRY_CONSTRUCTOR.newInstance(MineTweakerMC.getItemStack(stack.getStack()), (int) stack.getChance());
|
|
||||||
} catch (InstantiationException ex) {
|
|
||||||
MineTweakerAPI.logError("could not construct SeedEntry");
|
|
||||||
} catch (IllegalAccessException ex) {
|
|
||||||
MineTweakerAPI.logError("could not construct SeedEntry");
|
|
||||||
} catch (IllegalArgumentException ex) {
|
|
||||||
MineTweakerAPI.logError("could not construct SeedEntry");
|
|
||||||
} catch (InvocationTargetException ex) {
|
|
||||||
MineTweakerAPI.logError("could not construct SeedEntry");
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T> T getPrivateStaticObject(Class<?> cls, String... names) {
|
|
||||||
for (String name : names) {
|
|
||||||
try {
|
|
||||||
Field field = cls.getDeclaredField(name);
|
|
||||||
field.setAccessible(true);
|
|
||||||
return (T) field.get(null);
|
|
||||||
} catch (NoSuchFieldException ex) {
|
|
||||||
|
|
||||||
} catch (SecurityException ex) {
|
|
||||||
|
|
||||||
} catch (IllegalAccessException ex) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T> T getPrivateObject(Object object, String... names) {
|
|
||||||
Class<?> cls = object.getClass();
|
|
||||||
for (String name : names) {
|
|
||||||
try {
|
|
||||||
Field field = cls.getDeclaredField(name);
|
|
||||||
field.setAccessible(true);
|
|
||||||
return (T) field.get(object);
|
|
||||||
} catch (NoSuchFieldException ex) {
|
|
||||||
|
|
||||||
} catch (SecurityException ex) {
|
|
||||||
|
|
||||||
} catch (IllegalAccessException ex) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// #######################
|
|
||||||
// ### Private Methods ###
|
|
||||||
// #######################
|
|
||||||
|
|
||||||
private static Field getField(Class cls, String... names) {
|
|
||||||
for (String name : names) {
|
|
||||||
try {
|
|
||||||
Field field = cls.getDeclaredField(name);
|
|
||||||
field.setAccessible(true);
|
|
||||||
return field;
|
|
||||||
} catch (NoSuchFieldException ex) {
|
|
||||||
} catch (SecurityException ex) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loaded 100 of 450 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user