Compare commits

..
33 Commits
Author SHA1 Message Date
FalsePattern 072ca7bcf8 modernize config 2022-06-15 22:28:46 +02:00
FalsePattern 164ec7b923 typo fix 2022-06-15 22:28:32 +02:00
FalsePattern b92ae7985f fplib update 2022-06-15 22:28:27 +02:00
FalsePattern f15acb23ba update FalsePatternLib dep 2022-06-15 17:41:04 +02:00
FalsePattern 18d1e77e56 update GitHub actions 2022-06-15 17:40:17 +02:00
FalsePattern 2efcbe2e16 update buildscript 2022-06-15 17:39:28 +02:00
FalsePattern d4b2e9f5da Merge pull request #3 from embeddedt/master
Allow countCorrectionBits to be tuned using the mod config
2022-06-15 17:37:48 +02:00
embeddedt e8212e3224 Allow countCorrectionBits to be tuned using the mod config 2022-06-12 17:05:06 -04:00
FalsePattern 066ae631c1 make issues less restrictive 2022-05-22 00:20:59 +02:00
FalsePattern 1d32553b2d github community boilerplate 2022-05-22 00:16:28 +02:00
FalsePattern 2b8bc1c1c1 Update README.MD 2022-05-21 13:05:19 +02:00
FalsePattern 345ec097d7 Update README.MD 2022-05-21 12:41:04 +02:00
FalsePattern 72bfd43b9f Update README.MD 2022-05-21 12:39:44 +02:00
FalsePattern 4f1e4a22cc Remove dangling examplemod license
Project was always LGPLv3+, i forgot this here from the examplemod bootstrap.
2022-04-23 02:40:28 +02:00
FalsePattern 2a4d841b9d client side mixin snuck into common zone 2022-04-22 01:50:09 +02:00
FalsePattern 31e4d39338 port mixin plugin to falsepatternlib 2022-04-17 21:11:33 +02:00
FalsePattern 1d0e0550fa Grimoire compatibility patch. Fixes #1. 2022-04-17 16:42:42 +02:00
FalsePattern 5a61d8afe0 intellij compatible blocks 2022-04-17 16:41:47 +02:00
FalsePattern 336c4cd54d more code cleanup 2022-03-22 13:47:23 +01:00
FalsePattern 00d2a28264 worldedit hotfix 2022-03-22 13:41:32 +01:00
FalsePattern 798f3d6124 ASM cleanup 2022-03-22 13:40:58 +01:00
FalsePattern 4aecea7066 Update readme 2022-03-22 13:22:38 +01:00
FalsePattern 14a6897297 WorldEdit 2022-03-22 13:17:19 +01:00
FalsePattern a6420b7580 MoreFunQuicksandMod 2022-03-22 12:50:09 +01:00
FalsePattern 6c9ea1c6fd remove remaps from compat code 2022-03-22 12:24:12 +01:00
FalsePattern 2203ab3a34 DragonAPI 2022-03-22 12:23:25 +01:00
FalsePattern e96d0db982 compact comments 2022-03-22 12:22:07 +01:00
FalsePattern 918e880155 CoFH Lib 2022-03-22 11:42:57 +01:00
FalsePattern 1a8aa60577 fix typo 2022-03-22 11:33:22 +01:00
FalsePattern 99fde997de BiomeUndergroundDecorator 2022-03-22 11:30:49 +01:00
FalsePattern 6967fc26fe OreUBifier 2022-03-22 11:30:35 +01:00
FalsePattern 91da87b4d6 prepare for porting UBC asm to mixins 2022-03-22 10:31:38 +01:00
FalsePattern fd6061a946 reorganize mixins in preparation for multiple mods 2022-03-22 10:25:56 +01:00
55 changed files with 650 additions and 903 deletions

No files matched your search

+55
View File
@@ -0,0 +1,55 @@
name: Crash
description: The game has a problem when EndlessIDs is present
title: "[Bug]: "
labels: ["bug"]
assignees:
- falsepattern
body:
# Optional, only for mods that do stuff with rendering/native code
- type: dropdown
id: os
attributes:
label: OS
description: What kind of operating system do you have?
options:
- Windows
- Linux/BSD
- MacOS
validations:
required: true
# Optional, only for graphics mods
- type: dropdown
id: gpu
attributes:
label: GPU
description: What kind of graphics card do you have? If you have multiple, select the one that minecraft uses, you can usually find it somewhere at the top of the crash report.
options:
- AMD
- NVIDIA
- Intel
validations:
required: true
# Recommended for precise context
- type: input
id: modpack
attributes:
label: Modpack (Optional)
description: If you used the mod in a modpack, you should include the pack's exact name and version here to make debugging easier.
validations:
required: false
# Essential
- type: textarea
id: logs
attributes:
label: Game log
description: Attach the fml-client-latest.log file here.
validations:
required: true
# Essential
- type: textarea
id: description
attributes:
label: Description
description: Describe how and when you experience this bug.
validations:
required: false
+78
View File
@@ -0,0 +1,78 @@
name: Compatibility Request
description: If you tested EndlessIDs with another mod and it crashes or has weird bugs, you can ask for a compatibility patch through this.
title: "[Compatibility Request]: "
labels: ["compat-request"]
assignees:
- falsepattern
body:
# Essential
- type: input
id: modname
attributes:
label: Other mod's name
description: The name of the other mod
validations:
required: true
# Essential
- type: input
id: modurl
attributes:
label: Other mod's homepage
description: A link to the main site where the other mod is hosted. Preferrably the original website of a mod, but a modrinth/curseforge/whatever page is also acceptable. Do not post a raw download link, those requests will be ignored.
validations:
required: true
# Important
- type: dropdown
id: license
attributes:
label: Other mod's license
description: What license does the other mod have? (Open source mods are easier to write compatibility patches for)
options:
- AGPLv3
- AGPLv2
- GPLv3
- GPLv2
- LGPLv3
- LGPLv2
- Apache 2.0
- Beerware
- BSD 3-Clause
- BSD 2-Clause
- EPL 2.0
- MIT
- MPL 2.0
- Unlicense
- WTFPL
- Other open source license (please specify in the description)
- All Rights Reserved
validations:
required: true
# Recommended
- type: textarea
id: logs
attributes:
label: Game log
description: Attach the fml-client-latest.log file here.
validations:
required: true
# Recommended
- type: textarea
id: description
attributes:
label: Description
description: Describe any visual errors that appear, and attach screenshots of them. You can leave this empty if it's a crash without any visible stuff.
validations:
required: false
# Modify this after every added patch
# - type: checkboxes
# id: existingpatches
# attributes:
# label: Existing Patches
# description: The mods below already have compatibility patches. If you're experiencing issues with those, submit either a crash or a bug report!
# options:
# - label: This request is not for X
# required: true
# - label: This request is not for Y
# required: true
# - label: This request is not for Z
# required: true
+6
View File
@@ -11,6 +11,9 @@ on:
jobs: jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
env:
MAVEN_DEPLOY_USER: ${{ secrets.MAVEN_DEPLOY_USER }}
MAVEN_DEPLOY_PASSWORD: ${{ secrets.MAVEN_DEPLOY_PASSWORD }}
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
with: with:
@@ -43,3 +46,6 @@ jobs:
prerelease: false prerelease: false
title: "${{ env.RELEASE_VERSION }}" title: "${{ env.RELEASE_VERSION }}"
files: build/libs/*.jar files: build/libs/*.jar
- name: Publish to maven
run: ./gradlew publish
+53
View File
@@ -0,0 +1,53 @@
# Code of Merit
1. The project creators, lead developers, core team, constitute
the managing members of the project and have final say in every decision
of the project, technical or otherwise, including overruling previous decisions.
There are no limitations to this decisional power.
2. Contributions are an expected result of your membership on the project.
Don't expect others to do your work or help you with your work forever.
3. All members have the same opportunities to seek any challenge they want
within the project.
4. Authority or position in the project will be proportional
to the accrued contribution. Seniority must be earned.
5. Software is evolutive: the better implementations must supersede lesser
implementations. Technical advantage is the primary evaluation metric.
6. This is a space for technical prowess; topics outside of the project
will not be tolerated.
7. Non technical conflicts will be discussed in a separate space. Disruption
of the project will not be allowed.
8. Individual characteristics, including but not limited to,
body, sex, sexual preference, race, language, religion, nationality,
or political preferences are irrelevant in the scope of the project and
will not be taken into account concerning your value or that of your contribution
to the project.
9. Discuss or debate the idea, not the person.
10. There is no room for ambiguity: Ambiguity will be met with questioning;
further ambiguity will be met with silence. It is the responsibility
of the originator to provide requested context.
11. If something is illegal outside the scope of the project, it is illegal
in the scope of the project. This Code of Merit does not take precedence over
governing law.
12. This Code of Merit governs the technical procedures of the project not the
activities outside of it.
13. Participation on the project equates to agreement of this Code of Merit.
14. No objectives beyond the stated objectives of this project are relevant
to the project. Any intent to deviate the project from its original purpose
of existence will constitute grounds for remedial action which may include
expulsion from the project.
This document is adapted from the Code of Merit, version 1.0.
See: https://codeofmerit.org/.
+16
View File
@@ -0,0 +1,16 @@
# How to contribute
## Describe everything properly
* Make sure to properly fill out the pull request and issue templates
* Ambiguous changes with no explanation will be rejected.
## Make sure to follow existing coding conventions
The most important conventions to upkeep if you don't want your PR rejected:
* 4 spaces per indent level for code, 2 spaces per indent level for json, yaml, etc.
* Parentheses/Brackes/Braces open on the same line, not on a new line
* Method arguments are lists, not paragraphs. Either ALL arguments go on the same line, or every argument goes a SEPARATE line.
* Not everyone has an ultrawide monitor. Try to keep lines below 120 characters in length.
* Do not reformat existing code. Reformatting is done exclusively by the maintainers.
* Annotations have one parameter per line, no exceptions
* Do not pollute the repo with IDE-specific configuration files.
-21
View File
@@ -1,21 +0,0 @@
MIT License
Copyright (c) 2021 Johann Bernhardt
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+14
View File
@@ -0,0 +1,14 @@
## Describe your changes
## The issue this PR is connected to (if applicable)
## What kind of PR is this?
Delete the ones that do not apply.
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
## Checklist before requesting a review
- [ ] I have tested the code locally and it works
- [ ] I followed the requirements set in the contribution document
+19
View File
@@ -4,3 +4,22 @@ EndlessIDs is a modern rewrite of NotEnoughIDs which increases the limit even mo
|-----------|---------|--------------|------------| |-----------|---------|--------------|------------|
| Block IDs | 4096 | 32000 | 16777216 | | Block IDs | 4096 | 32000 | 16777216 |
| Item IDs | 32000 | 32000 | 16777216 | | Item IDs | 32000 | 32000 | 16777216 |
This mod also contains patches for the following mods:
- UndergroundBiomesConstructs
- More Fun Quicksand Mod
- WorldEdit
- CoFH Lib
- DragonAPI
Mods not listed here may or may not work. A good rule of thumb is that the more invasive a mod is, the higher the chance
it's broken without a patch once the IDs exceed 4096 and 32000.
If you find any crashes or incompatibilities, don't hesitate to open an issue.
## Dependencies
- [FalsePatternLib](https://github.com/FalsePattern/FalsePatternLib)
- [SpongeMixins](https://github.com/TimeConqueror/SpongeMixins)
[![POOP badge](https://raw.githubusercontent.com/gist/poop-person/991e80f390384bbeef09d208bff208f4/raw/a9ef83add84a70f2202896c2d81117ff7b169be1/poop-badge.svg)](https://gist.github.com/poop-person/991e80f390384bbeef09d208bff208f4)
+23 -12
View File
@@ -1,4 +1,4 @@
//version: 1641429628falsepattern12 //version: 1641429628falsepattern18
/* /*
DO NOT CHANGE THIS FILE! DO NOT CHANGE THIS FILE!
@@ -95,6 +95,7 @@ checkPropertyExists("repositoryName")
checkPropertyExists("mavenGroupId") checkPropertyExists("mavenGroupId")
checkPropertyExists("mavenArtifactId") checkPropertyExists("mavenArtifactId")
checkPropertyExists("hasMixinDeps") checkPropertyExists("hasMixinDeps")
checkPropertyExists("mixinPreinitConfig")
String javaSourceDir = "src/main/java/" String javaSourceDir = "src/main/java/"
@@ -441,7 +442,7 @@ def getManifestAttributes() {
if(usesMixins.toBoolean()) { if(usesMixins.toBoolean()) {
manifestAttributes += [ manifestAttributes += [
"TweakClass" : "org.spongepowered.asm.launch.MixinTweaker", "TweakClass" : "org.spongepowered.asm.launch.MixinTweaker",
"MixinConfigs" : "mixins." + modId + ".json", "MixinConfigs" : "mixins." + modId + ".json" + (mixinPreinitConfig ? "," + mixinPreinitConfig : ""),
"ForceLoadAsMod" : containsMixinsAndOrCoreModOnly.toBoolean() == false "ForceLoadAsMod" : containsMixinsAndOrCoreModOnly.toBoolean() == false
] ]
} }
@@ -545,8 +546,16 @@ def getCredentials = {
return [username: entry.username.text(), password: entry.password.text()] return [username: entry.username.text(), password: entry.password.text()]
} }
} }
throw new Exception();
} catch (Exception ignored) { } catch (Exception ignored) {
return [username: "none", password: "none"] //Try from environment variables if file does not exist
String username = System.getenv("MAVEN_DEPLOY_USER")
String password = System.getenv("MAVEN_DEPLOY_PASSWORD")
if (username == null || password == null) {
return [username: null, password: null]
} else {
return [username: username, password: password]
}
} }
} }
@@ -554,9 +563,9 @@ def getCredentials = {
publishing { publishing {
publications { publications {
maven(MavenPublication) { maven(MavenPublication) {
artifact source: jar artifact source: (jar.enabled ? jar : shadowJar)
artifact source: sourcesJar, classifier: "src" artifact source: sourcesJar, classifier: "src"
artifact source: devJar, classifier: "dev" artifact source: (devJar.enabled ? devJar : shadowDevJar), classifier: "dev"
if (apiPackage) { if (apiPackage) {
artifact source: apiJar, classifier: "api" artifact source: apiJar, classifier: "api"
} }
@@ -568,13 +577,15 @@ publishing {
} }
repositories { repositories {
maven { if (repositoryURL.trim() != "") {
name = repositoryName maven {
url = repositoryURL name = repositoryName
def creds = getCredentials() url = repositoryURL
credentials { def creds = getCredentials()
username = creds == null ? "none" : creds.username credentials {
password = creds == null ? "none" : creds.password username = creds == null ? "none" : creds.username
password = creds == null ? "none" : creds.password
}
} }
} }
} }
+22
View File
@@ -3,4 +3,26 @@ dependencies {
transitive = false transitive = false
} }
annotationProcessor("org.projectlombok:lombok:1.18.22") annotationProcessor("org.projectlombok:lombok:1.18.22")
compile("com.falsepattern:falsepatternlib-mc1.7.10:0.8.2:dev")
compileOnly("curse.maven:undergroundbiomesconstructs-72744:2304497") {
transitive = false
}
compileOnly("curse.maven:more-fun-quicksand-mod-321960:2717318") {
transitive = false
}
compileOnly("curse.maven:worldedit-225608:2309699") {
transitive = false
}
compileOnly("curse.maven:cofh-lib-220333:2388747") {
transitive = false
}
compileOnly("curse.maven:dragonapi-235591:3574508") {
transitive = false
}
} }
+2
View File
@@ -68,6 +68,8 @@ hasMixinDeps = false
mixinPlugin = mixin.plugin.MixinPlugin mixinPlugin = mixin.plugin.MixinPlugin
# Specify the package that contains all of your Mixins. You may only place Mixins in this package or the build will fail! # Specify the package that contains all of your Mixins. You may only place Mixins in this package or the build will fail!
mixinsPackage = mixin.mixins mixinsPackage = mixin.mixins
# Specify a preinit mixin here. Preinit mixins should be used very rarely, if at all, so this mixin config will not be managed by the buildscript, only included.
mixinPreinitConfig =
# Specify the core mod entry class if you use a core mod. This class must implement IFMLLoadingPlugin! # Specify the core mod entry class if you use a core mod. This class must implement IFMLLoadingPlugin!
# This parameter is for legacy compatibility only # This parameter is for legacy compatibility only
# Example value: coreModClass = asm.FMLPlugin + modGroup = com.myname.mymodid -> com.myname.mymodid.asm.FMLPlugin # Example value: coreModClass = asm.FMLPlugin + modGroup = com.myname.mymodid -> com.myname.mymodid.asm.FMLPlugin
+11 -1
View File
@@ -1,5 +1,15 @@
// Add any additional repositories for your dependencies here // Add any additional repositories for your dependencies here
repositories { repositories {
maven {
name = "cursemaven"
url = "https://cursemaven.falsepattern.com/"
content {
includeGroup "curse.maven"
}
}
maven {
name = "mavenpattern"
url = "https://maven.falsepattern.com/"
}
} }
@@ -2,5 +2,9 @@ package com.falsepattern.endlessids;
import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod;
@Mod(modid = Tags.MODID, name = Tags.MODNAME, version = Tags.VERSION) @Mod(modid = Tags.MODID,
version = Tags.VERSION,
name = Tags.MODNAME,
acceptedMinecraftVersions = "[1.7.10]",
dependencies = "required-after:falsepatternlib@[0.8.2,);")
public class EndlessIDs {} public class EndlessIDs {}
@@ -124,7 +124,7 @@ public class Hooks {
public static int getIdFromBlockWithCheck(final Block block, final Block oldBlock) { public static int getIdFromBlockWithCheck(final Block block, final Block oldBlock) {
final int id = Block.getIdFromBlock(block); final int id = Block.getIdFromBlock(block);
if (IEConfig.catchUnregisteredBlocks && id == -1) { if (IEConfig.catchUnregisteredBlocks && id == -1) {
throw new IllegalArgumentException("Block " + block + " is not registered. <-- Say about this to the author of this mod, or you can try to enable \"RemoveInvalidBlocks\" option in NEID config."); throw new IllegalArgumentException("Block " + block + " is not registered. <-- Say about this to the author of this mod, or you can try to enable \"RemoveInvalidBlocks\" option in EID config.");
} }
if (id >= 0 && id <= ExtendedConstants.maxBlockID) { if (id >= 0 && id <= ExtendedConstants.maxBlockID) {
return id; return id;
@@ -1,32 +1,22 @@
package com.falsepattern.endlessids; package com.falsepattern.endlessids;
import java.io.File; import com.falsepattern.lib.config.Config;
import net.minecraftforge.common.config.Configuration;
@Config(modid = Tags.MODID)
public class IEConfig { public class IEConfig {
static Configuration config; public static boolean catchUnregisteredBlocks = false;
public static boolean catchUnregisteredBlocks;
public static boolean removeInvalidBlocks;
public static boolean extendDataWatcher;
public static void init(final File file) { @Config.Comment("Remove invalid (corrupted) blocks from the game.")
File newFile; public static boolean removeInvalidBlocks = false;
if (file.getPath().contains("bin")) {
newFile = new File(file.getParent() + "/eclipse/config", Tags.MODID + ".cfg");
}
else {
newFile = new File(file.getParentFile().getParent() + "/config", Tags.MODID + ".cfg");
}
IEConfig.config = new Configuration(newFile);
IEConfig.catchUnregisteredBlocks = IEConfig.config.getBoolean("CatchUnregisteredBlocks", Tags.MODNAME, false, "");
IEConfig.removeInvalidBlocks = IEConfig.config.getBoolean("RemoveInvalidBlocks", Tags.MODNAME, false, "Remove invalid (corrupted) blocks from the game.");
IEConfig.extendDataWatcher = IEConfig.config.getBoolean("ExtendDataWatcher", Tags.MODNAME, false, "Extend DataWatcher IDs. Vanilla limit is 31, new limit is 127.");
IEConfig.config.save();
}
static { @Config.Comment("Extend DataWatcher IDs. Vanilla limit is 31, new limit is 127.")
IEConfig.catchUnregisteredBlocks = false; public static boolean extendDataWatcher = false;
IEConfig.removeInvalidBlocks = false;
IEConfig.extendDataWatcher = false; @Config.Comment("Setting this value greater than 0 will reduce RAM usage, at the cost of less available Block IDs.\n" +
} "Notice: This does not affect ITEM IDs.\n" +
"By default, block IDs can also go up to 16 Million, and each additional bit in this setting halves\n" +
"this value.\n" +
"(0: 16M, 1: 8M, 2: 4M, 3: 2M, 4: 1M, 5: 512K, 6: 256K, 7: 128K, 8: 64K, 9: 32K, 10: 16K, 11: 8K, 12: 4K)\n")
@Config.RangeInt(min = 0, max = 12)
public static int countCorrectionBits = 0;
} }
@@ -1,15 +1,27 @@
package com.falsepattern.endlessids; package com.falsepattern.endlessids;
import java.io.File;
import java.util.Map; import java.util.Map;
import com.falsepattern.endlessids.asm.IETransformer; import com.falsepattern.endlessids.asm.IETransformer;
import com.falsepattern.lib.config.ConfigException;
import com.falsepattern.lib.config.ConfigurationManager;
import cpw.mods.fml.relauncher.IFMLLoadingPlugin; import cpw.mods.fml.relauncher.IFMLLoadingPlugin;
@IFMLLoadingPlugin.MCVersion("1.7.10") import static cpw.mods.fml.relauncher.IFMLLoadingPlugin.*;
@IFMLLoadingPlugin.TransformerExclusions({ "com.falsepattern.endlessids.asm" })
@MCVersion("1.7.10")
@Name(Tags.MODID)
@TransformerExclusions({ "com.falsepattern.endlessids.asm" })
@DependsOn("falsepatternlib")
public class IEPlugin implements IFMLLoadingPlugin public class IEPlugin implements IFMLLoadingPlugin
{ {
static {
try {
ConfigurationManager.registerConfig(IEConfig.class);
} catch (ConfigException e) {
System.err.println("Failed to load EndlessIDs config. Using defaults.");
}
}
public IEPlugin() { public IEPlugin() {
super(); super();
} }
@@ -27,7 +39,6 @@ public class IEPlugin implements IFMLLoadingPlugin
} }
public void injectData(final Map<String, Object> data) { public void injectData(final Map<String, Object> data) {
IEConfig.init((File) data.get("coremodLocation"));
IETransformer.isObfuscated = (Boolean) data.get("runtimeDeobfuscationEnabled"); IETransformer.isObfuscated = (Boolean) data.get("runtimeDeobfuscationEnabled");
} }
@@ -21,42 +21,6 @@ public class AsmUtil
super(); super();
} }
public static MethodNode findMethod(final ClassNode cn, final String name) {
return findMethod(cn, name, false);
}
public static MethodNode findMethod(final ClassNode cn, final String name, final boolean optional) {
for (final MethodNode ret : cn.methods) {
if (ret.name.equals(name)) {
return ret;
}
}
if (optional) {
return null;
}
throw new MethodNotFoundException(name);
}
public static MethodNode findMethod(final ClassNode cn, final Name name) {
return findMethod(cn, name, false);
}
public static MethodNode findMethod(final ClassNode cn, final Name name, final boolean optional) {
for (final MethodNode ret : cn.methods) {
if (name.matches(ret)) {
return ret;
}
}
if (optional) {
return null;
}
throw new MethodNotFoundException(name.deobf);
}
public static FieldNode findField(final ClassNode cn, final String name) {
return findField(cn, name, false);
}
public static FieldNode findField(final ClassNode cn, final String name, final boolean optional) { public static FieldNode findField(final ClassNode cn, final String name, final boolean optional) {
for (final FieldNode ret : cn.fields) { for (final FieldNode ret : cn.fields) {
if (name.equals(ret.name)) { if (name.equals(ret.name)) {
@@ -69,39 +33,11 @@ public class AsmUtil
throw new FieldNotFoundException(name); throw new FieldNotFoundException(name);
} }
public static FieldNode findField(final ClassNode cn, final Name name) {
return findField(cn, name, false);
}
public static FieldNode findField(final ClassNode cn, final Name name, final boolean optional) {
for (final FieldNode ret : cn.fields) {
if (name.matches(ret)) {
return ret;
}
}
if (optional) {
return null;
}
throw new FieldNotFoundException(name.deobf);
}
public static void makePublic(final MethodNode x) {
x.access = ((x.access & 0xFFFFFFF9) | 0x1);
}
public static void makePublic(final FieldNode x) {
x.access = ((x.access & 0xFFFFFFF9) | 0x1);
}
public static boolean transformInlinedSizeMethod(final ClassNode cn, final MethodNode method, final int oldValue, final int newValue) {
return transformInlinedSizeMethod(cn, method, oldValue, newValue, false);
}
public static boolean transformInlinedSizeMethod(final ClassNode cn, final MethodNode method, final int oldValue, final int newValue, final boolean optional) { public static boolean transformInlinedSizeMethod(final ClassNode cn, final MethodNode method, final int oldValue, final int newValue, final boolean optional) {
boolean found = false; boolean found = false;
boolean foundOnce = false; boolean foundOnce = false;
final int i = 0; final int i = 0;
final ListIterator<AbstractInsnNode> it = (ListIterator<AbstractInsnNode>)method.instructions.iterator(); final ListIterator<AbstractInsnNode> it = method.instructions.iterator();
while (it.hasNext()) { while (it.hasNext()) {
final AbstractInsnNode insn = it.next(); final AbstractInsnNode insn = it.next();
if (insn.getOpcode() == 3 && oldValue == 0) { if (insn.getOpcode() == 3 && oldValue == 0) {
@@ -161,7 +97,7 @@ public class AsmUtil
it.set(new IntInsnNode(17, newValue)); it.set(new IntInsnNode(17, newValue));
} }
else { else {
it.set(new LdcInsnNode((Object)Integer.valueOf(newValue))); it.set(new LdcInsnNode(newValue));
} }
found = false; found = false;
} }
@@ -172,12 +108,4 @@ public class AsmUtil
return foundOnce; return foundOnce;
} }
public static void dump(final InsnList list) {
final Textifier textifier = new Textifier();
final TraceMethodVisitor visitor = new TraceMethodVisitor((Printer)textifier);
list.accept((MethodVisitor)visitor);
final PrintWriter writer = new PrintWriter(System.out);
textifier.print(writer);
writer.flush();
}
} }
@@ -1,38 +1,13 @@
package com.falsepattern.endlessids.asm; package com.falsepattern.endlessids.asm;
import java.util.HashMap; import java.util.HashMap;
import com.falsepattern.endlessids.asm.transformer.WorldEditBaseBlock;
import com.falsepattern.endlessids.asm.transformer.MFQM;
import com.falsepattern.endlessids.asm.transformer.UndergroundBiomesBiomeUndergroundDecorator;
import com.falsepattern.endlessids.asm.transformer.UndergroundBiomesOreUBifier;
import com.falsepattern.endlessids.asm.transformer.CofhBlockHelper;
import com.falsepattern.endlessids.asm.transformer.FmlRegistry; import com.falsepattern.endlessids.asm.transformer.FmlRegistry;
import java.util.Map; import java.util.Map;
public enum ClassEdit public enum ClassEdit
{ {
//SelfHooks(new SelfHooks(), new String[] { "com.falsepattern.endlessids.Hooks" }),
//VanillaBlockFire(new VanillaBlockFire(), new String[] { "net.minecraft.block.BlockFire" }),
//VanillaStatList(new VanillaStatList(), new String[] { "net.minecraft.stats.StatList" }),
//VanillaAnvilChunkLoader(new VanillaAnvilChunkLoader(), new String[] { "net.minecraft.world.chunk.storage.AnvilChunkLoader" }),
//VanillaChunk(new VanillaChunk(), new String[] { "net.minecraft.world.chunk.Chunk" }),
//VanillaExtendedBlockStorage(new VanillaExtendedBlockStorage(), new String[] { "net.minecraft.world.chunk.storage.ExtendedBlockStorage" }),
//VanillaDataWatcher(new VanillaDataWatcher(), new String[] { "net.minecraft.entity.DataWatcher" }),
//VanillaNetHandlerPlayClient(new VanillaNetHandlerPlayClient(), new String[] { "net.minecraft.client.network.NetHandlerPlayClient" }),
//VanillaS21PacketChunkData(new VanillaS21PacketChunkData(), new String[] { "net.minecraft.network.play.server.S21PacketChunkData" }),
//VanillaS22PacketMultiBlockChange(new VanillaS22PacketMultiBlockChange(), new String[] { "net.minecraft.network.play.server.S22PacketMultiBlockChange" }),
//VanillaS24PacketBlockActivation(new VanillaS24PacketBlockActivation(), new String[] { "net.minecraft.network.play.server.S24PacketBlockAction" }),
//VanillaS26PacketMapChunkBulk(new VanillaS26PacketMapChunkBulk(), new String[] { "net.minecraft.network.play.server.S26PacketMapChunkBulk" }),
//VanillaRenderGlobal(new VanillaRenderGlobal(), new String[] { "net.minecraft.client.renderer.RenderGlobal" }),
//VanillaPlayerControllerMP(new VanillaPlayerControllerMP(), new String[] { "net.minecraft.client.multiplayer.PlayerControllerMP" }),
//VanillaItemInWorldManager(new VanillaItemInWorldManager(), new String[] { "net.minecraft.server.management.ItemInWorldManager" }),
//VanillaWorld(new VanillaWorld(), new String[] { "net.minecraft.world.World" }),
FmlRegistry(new FmlRegistry(), new String[] { "cpw.mods.fml.common.registry.GameData", "cpw.mods.fml.common.registry.FMLControlledNamespacedRegistry" }), FmlRegistry(new FmlRegistry(), new String[] { "cpw.mods.fml.common.registry.GameData", "cpw.mods.fml.common.registry.FMLControlledNamespacedRegistry" }),
CofhBlockHelper(new CofhBlockHelper(), new String[] { "cofh.lib.util.helpers.BlockHelper" }), ;
UndergroundBiomesOreUBifier(new UndergroundBiomesOreUBifier(), new String[] { "exterminatorJeff.undergroundBiomes.worldGen.OreUBifier" }),
UndergroundBiomesBiomeUndergroundDecorator(new UndergroundBiomesBiomeUndergroundDecorator(), new String[] { "exterminatorJeff.undergroundBiomes.worldGen.BiomeUndergroundDecorator" }),
MFQM(new MFQM(), new String[] { "MoreFunQuicksandMod.main.MFQM" }),
WorldEditBaseBlock(new WorldEditBaseBlock(), new String[] { "com.sk89q.worldedit.blocks.BaseBlock" });
private static final Map<String, ClassEdit> editMap; private static final Map<String, ClassEdit> editMap;
private final IClassNodeTransformer transformer; private final IClassNodeTransformer transformer;
@@ -1,23 +0,0 @@
package com.falsepattern.endlessids.asm;
public class Constants
{
public static final int maxBlockId = 32767;
public static final int blockIdMask = 65535;
public static final int ebsIdArrayLength = 4096;
public static final int ebsIdArraySize = 8192;
public static final int vanillaEbsSize = 12288;
public static final int vanillaSize = 196864;
public static final int newEbsSize = 14336;
public static final int newSize = 229632;
public static final int maxDataWatcherId = 127;
public static final int vanillaIDCount = 4096;
public static final int newIDCount = 32768;
public static final int vanillaIDBits = 12;
public static final int newIDBits = 16;
public Constants() {
super();
}
}
@@ -1,5 +1,6 @@
package com.falsepattern.endlessids.asm; package com.falsepattern.endlessids.asm;
import com.falsepattern.endlessids.Tags;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.objectweb.asm.util.CheckClassAdapter; import org.objectweb.asm.util.CheckClassAdapter;
import org.objectweb.asm.ClassWriter; import org.objectweb.asm.ClassWriter;
@@ -11,11 +12,8 @@ import net.minecraft.launchwrapper.IClassTransformer;
public class IETransformer implements IClassTransformer public class IETransformer implements IClassTransformer
{ {
private static final boolean enablePreVerification = false;
private static final boolean enablePostVerification = true;
public static final Logger logger; public static final Logger logger;
public static boolean isObfuscated; public static boolean isObfuscated;
private static Boolean isClient;
public IETransformer() { public IETransformer() {
super(); super();
@@ -29,44 +27,35 @@ public class IETransformer implements IClassTransformer
if (edit == null) { if (edit == null) {
return bytes; return bytes;
} }
IETransformer.logger.debug("Patching {} with {}...", new Object[] { transformedName, edit.getName() }); IETransformer.logger.debug("Patching {} with {}...", transformedName, edit.getName());
final ClassNode cn = new ClassNode(327680); final ClassNode cn = new ClassNode(327680);
final ClassReader reader = new ClassReader(bytes); final ClassReader reader = new ClassReader(bytes);
final int readFlags = 0; reader.accept(cn, 0);
reader.accept((ClassVisitor)cn, 0);
try { try {
edit.getTransformer().transform(cn, IETransformer.isObfuscated); edit.getTransformer().transform(cn, IETransformer.isObfuscated);
} }
catch (AsmTransformException t) { catch (AsmTransformException t) {
IETransformer.logger.error("Error transforming {} with {}: {}", new Object[] { transformedName, edit.getName(), t.getMessage() }); IETransformer.logger.error("Error transforming {} with {}: {}", transformedName, edit.getName(), t.getMessage());
throw t; throw t;
} }
catch (Throwable t2) { catch (Throwable t2) {
IETransformer.logger.error("Error transforming {} with {}: {}", new Object[] { transformedName, edit.getName(), t2.getMessage() }); IETransformer.logger.error("Error transforming {} with {}: {}", transformedName, edit.getName(), t2.getMessage());
throw new RuntimeException(t2); throw new RuntimeException(t2);
} }
final ClassWriter writer = new ClassWriter(0); final ClassWriter writer = new ClassWriter(0);
try { try {
final ClassVisitor check = (ClassVisitor)new CheckClassAdapter((ClassVisitor)writer); final ClassVisitor check = new CheckClassAdapter(writer);
cn.accept(check); cn.accept(check);
} }
catch (Throwable t3) { catch (Throwable t3) {
IETransformer.logger.error("Error verifying {} transformed with {}: {}", new Object[] { transformedName, edit.getName(), t3.getMessage() }); IETransformer.logger.error("Error verifying {} transformed with {}: {}", transformedName, edit.getName(), t3.getMessage());
throw new RuntimeException(t3); throw new RuntimeException(t3);
} }
IETransformer.logger.debug("Patched {} successfully.", new Object[] { edit.getName() }); IETransformer.logger.debug("Patched {} successfully.", edit.getName());
return writer.toByteArray(); return writer.toByteArray();
} }
public static boolean isClient() {
if (IETransformer.isClient == null) {
IETransformer.isClient = Boolean.valueOf(IETransformer.class.getResource("/net/minecraft/client/main/Main.class") != null);
}
return IETransformer.isClient;
}
static { static {
logger = LogManager.getLogger("NEID"); logger = LogManager.getLogger(Tags.MODNAME + " ASM");
IETransformer.isClient = null;
} }
} }
@@ -1,205 +0,0 @@
package com.falsepattern.endlessids.asm;
import org.objectweb.asm.tree.FieldInsnNode;
import org.objectweb.asm.tree.MethodInsnNode;
import org.objectweb.asm.tree.FieldNode;
import org.objectweb.asm.tree.MethodNode;
public enum Name
{
hooks("com/falsepattern/endlessids/Hooks"),
hooks_create16BArray(Name.hooks, "create16BArray", null, null, "()[S"),
hooks_getBlockData(Name.hooks, "getBlockData", null, null, "(Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;)[B"),
hooks_setBlockData(Name.hooks, "setBlockData", null, null, "(Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;[BI)V"),
hooks_writeChunkToNbt(Name.hooks, "writeChunkToNbt", null, null, "(Lnet/minecraft/nbt/NBTTagCompound;Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;)V"),
hooks_readChunkFromNbt(Name.hooks, "readChunkFromNbt", null, null, "(Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;Lnet/minecraft/nbt/NBTTagCompound;)V"),
hooks_getBlockId(Name.hooks, "getBlockId", null, null, "(Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;III)I"),
hooks_getBlockById(Name.hooks, "getBlock", null, null, "(Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;III)Lnet/minecraft/block/Block;"),
hooks_setBlockId(Name.hooks, "setBlockId", null, null, "(Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;IIII)V"),
hooks_getIdFromBlockWithCheck(Name.hooks, "getIdFromBlockWithCheck", null, null, "(Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;)I"),
acl("net/minecraft/world/chunk/storage/AnvilChunkLoader", "aqk"),
block("net/minecraft/block/Block", "aji"),
chunk("net/minecraft/world/chunk/Chunk", "apx"),
extendedBlockStorage("net/minecraft/world/chunk/storage/ExtendedBlockStorage", "apz"),
iChunkProvider("net/minecraft/world/chunk/IChunkProvider", "apu"),
nbtTagCompound("net/minecraft/nbt/NBTTagCompound", "dh"),
nhpc("net/minecraft/client/network/NetHandlerPlayClient", "bjb"),
nibbleArray("net/minecraft/world/chunk/NibbleArray", "apv"),
packet("net/minecraft/network/Packet", "ft"),
packetBuffer("net/minecraft/network/PacketBuffer", "et"),
s22("net/minecraft/network/play/server/S22PacketMultiBlockChange", "gk"),
s21("net/minecraft/network/play/server/S21PacketChunkData", "gx"),
s21_extracted("net/minecraft/network/play/server/S21PacketChunkData$Extracted", "gy"),
world("net/minecraft/world/World", "ahb"),
dataWatcher("net/minecraft/entity/DataWatcher", "te"),
dataWatcher_watchableObject("net/minecraft/entity/DataWatcher$WatchableObject", "tf"),
renderGlobal("net/minecraft/client/renderer/RenderGlobal", "bma"),
playerControllerMP("net/minecraft/client/multiplayer/PlayerControllerMP", "bje"),
itemInWorldManager("net/minecraft/server/management/ItemInWorldManager", "mx"),
entityPlayer("net/minecraft/entity/player/EntityPlayer", "yz"),
ebs_getBlock(Name.extendedBlockStorage, "getBlockByExtId", "a", "func_150819_a", "(III)Lnet/minecraft/block/Block;"),
ebs_setBlock(Name.extendedBlockStorage, "func_150818_a", "a", null, "(IIILnet/minecraft/block/Block;)V"),
ebs_getBlockLSBArray(Name.extendedBlockStorage, "getBlockLSBArray", "g", "func_76658_g", "()[B"),
ebs_getBlockMSBArray(Name.extendedBlockStorage, "getBlockMSBArray", "i", "func_76660_i", "()Lnet/minecraft/world/chunk/NibbleArray;"),
ebs_setBlockMSBArray(Name.extendedBlockStorage, "setBlockMSBArray", "a", "func_76673_a", "(Lnet/minecraft/world/chunk/NibbleArray;)V"),
ebs_isEmpty(Name.extendedBlockStorage, "isEmpty", "a", "func_76663_a", "()Z"),
ebs_removeInvalidBlocks(Name.extendedBlockStorage, "removeInvalidBlocks", "e", "func_76672_e", "()V"),
dataWatcher_addObject(Name.dataWatcher, "addObject", "a", "func_75682_a", "(ILjava/lang/Object;)V"),
dataWatcher_writeWatchableObjectToPacketBuffer(Name.dataWatcher, "writeWatchableObjectToPacketBuffer", "a", "func_151510_a", "(Lnet/minecraft/network/PacketBuffer;Lnet/minecraft/entity/DataWatcher$WatchableObject;)V"),
dataWatcher_readWatchedListFromPacketBuffer(Name.dataWatcher, "readWatchedListFromPacketBuffer", "b", "func_151508_b", "(Lnet/minecraft/network/PacketBuffer;)Ljava/util/List;"),
dataWatcher_writeWatchedListToPacketBuffer(Name.dataWatcher, "writeWatchedListToPacketBuffer", "a", "func_151507_a", "(Ljava/util/List;Lnet/minecraft/network/PacketBuffer;)V"),
dataWatcher_func_151509_a(Name.dataWatcher, "func_151509_a", "a", "func_151509_a", "(Lnet/minecraft/network/PacketBuffer;)V"),
ebs_blockRefCount(Name.extendedBlockStorage, "blockRefCount", "b", "field_76682_b", "I"),
ebs_tickRefCount(Name.extendedBlockStorage, "tickRefCount", "c", "field_76683_c", "I"),
acl_writeChunkToNBT(Name.acl, "writeChunkToNBT", "a", "func_75820_a", "(Lnet/minecraft/world/chunk/Chunk;Lnet/minecraft/world/World;Lnet/minecraft/nbt/NBTTagCompound;)V"),
acl_readChunkFromNBT(Name.acl, "readChunkFromNBT", "a", "func_75823_a", "(Lnet/minecraft/world/World;Lnet/minecraft/nbt/NBTTagCompound;)Lnet/minecraft/world/chunk/Chunk;"),
block_getIdFromBlock(Name.block, "getIdFromBlock", "b", "func_149682_b", "(Lnet/minecraft/block/Block;)I"),
chunk_fillChunk(Name.chunk, "fillChunk", "a", "func_76607_a", "([BIIZ)V"),
packet_readPacketData(Name.packet, "readPacketData", "a", "func_148837_a", "(Lnet/minecraft/network/PacketBuffer;)V"),
packet_writePacketData(Name.packet, "writePacketData", "b", "func_148840_b", "(Lnet/minecraft/network/PacketBuffer;)V"),
nhpc_handleMultiBlockChange(Name.nhpc, "handleMultiBlockChange", "a", "func_147287_a", "(Lnet/minecraft/network/play/server/S22PacketMultiBlockChange;)V"),
s22_init_server(Name.s22, "<init>", null, null, "(I[SLnet/minecraft/world/chunk/Chunk;)V"),
s21_undefined1(Name.s21, "func_149275_c", "c", null, "()I"),
s21_undefined2(Name.s21, "func_149269_a", "a", null, "(Lnet/minecraft/world/chunk/Chunk;ZI)Lnet/minecraft/network/play/server/S21PacketChunkData$Extracted;"),
renderGlobal_playAuxSFX(Name.renderGlobal, "playAuxSFX", "a", "func_72706_a", "(Lnet/minecraft/entity/player/EntityPlayer;IIIII)V"),
playerControllerMP_onPlayerDestroyBlock(Name.playerControllerMP, "onPlayerDestroyBlock", "a", "func_78751_a", "(IIII)Z"),
itemInWorldManager_tryHarvestBlock(Name.itemInWorldManager, "tryHarvestBlock", "b", "func_73084_b", "(III)Z"),
world_breakBlock(Name.world, "func_147480_a", "a", null, "(IIIZ)Z"),
ub_bud("exterminatorJeff/undergroundBiomes/worldGen/BiomeUndergroundDecorator"),
ub_bud_replaceChunkOres_world(Name.ub_bud, "replaceChunkOres", null, null, "(IILnet/minecraft/world/World;)V"),
ub_bud_replaceChunkOres_iChunkProvider(Name.ub_bud, "replaceChunkOres", null, null, "(Lnet/minecraft/world/chunk/IChunkProvider;II)V"),
MFQM("MoreFunQuicksandMod/main/MFQM"),
MFQM_preInit(Name.MFQM, "preInit", null, null, "(Lcpw/mods/fml/common/event/FMLPreInitializationEvent;)V");
public final Name clazz;
public final String deobf;
public final String obf;
public final String srg;
public final String desc;
public String obfDesc;
Name(final String deobf) {
this(deobf, deobf);
}
Name(final String deobf, final String obf) {
this.clazz = null;
this.deobf = deobf;
this.obf = obf;
this.srg = deobf;
this.desc = null;
}
Name(final Name clazz, final String deobf, final String obf, final String srg, final String desc) {
this.clazz = clazz;
this.deobf = deobf;
this.obf = ((obf != null) ? obf : deobf);
this.srg = ((srg != null) ? srg : deobf);
this.desc = desc;
}
public boolean matches(final MethodNode x) {
assert this.desc.startsWith("(");
return (this.obf.equals(x.name) && this.obfDesc.equals(x.desc)) || (this.srg.equals(x.name) && this.desc.equals(x.desc)) || (this.deobf.equals(x.name) && this.desc.equals(x.desc));
}
public boolean matches(final FieldNode x) {
assert !this.desc.startsWith("(");
return (this.obf.equals(x.name) && this.obfDesc.equals(x.desc)) || (this.srg.equals(x.name) && this.desc.equals(x.desc)) || (this.deobf.equals(x.name) && this.desc.equals(x.desc));
}
public boolean matches(final MethodInsnNode x, final boolean obfuscated) {
assert this.desc.startsWith("(");
if (obfuscated) {
return (this.clazz.obf.equals(x.owner) && this.obf.equals(x.name) && this.obfDesc.equals(x.desc)) || (this.clazz.srg.equals(x.owner) && this.srg.equals(x.name) && this.desc.equals(x.desc));
}
return this.clazz.deobf.equals(x.owner) && this.deobf.equals(x.name) && this.desc.equals(x.desc);
}
public boolean matches(final FieldInsnNode x, final boolean obfuscated) {
assert !this.desc.startsWith("(");
if (obfuscated) {
return (this.clazz.obf.equals(x.owner) && this.obf.equals(x.name) && this.obfDesc.equals(x.desc)) || (this.clazz.srg.equals(x.owner) && this.srg.equals(x.name) && this.desc.equals(x.desc));
}
return this.clazz.deobf.equals(x.owner) && this.deobf.equals(x.name) && this.desc.equals(x.desc);
}
public MethodInsnNode staticInvocation(final boolean obfuscated) {
assert this.desc.startsWith("(");
if (obfuscated) {
return new MethodInsnNode(184, this.clazz.srg, this.srg, this.desc, false);
}
return new MethodInsnNode(184, this.clazz.deobf, this.deobf, this.desc, false);
}
public MethodInsnNode virtualInvocation(final boolean obfuscated) {
assert this.desc.startsWith("(");
if (obfuscated) {
return new MethodInsnNode(182, this.clazz.srg, this.srg, this.desc, false);
}
return new MethodInsnNode(182, this.clazz.deobf, this.deobf, this.desc, false);
}
public FieldInsnNode staticGet(final boolean obfuscated) {
assert !this.desc.startsWith("(");
if (obfuscated) {
return new FieldInsnNode(178, this.clazz.srg, this.srg, this.desc);
}
return new FieldInsnNode(178, this.clazz.deobf, this.deobf, this.desc);
}
public FieldInsnNode virtualGet(final boolean obfuscated) {
assert !this.desc.startsWith("(");
if (obfuscated) {
return new FieldInsnNode(180, this.clazz.srg, this.srg, this.desc);
}
return new FieldInsnNode(180, this.clazz.deobf, this.deobf, this.desc);
}
public FieldInsnNode staticSet(final boolean obfuscated) {
assert !this.desc.startsWith("(");
if (obfuscated) {
return new FieldInsnNode(179, this.clazz.srg, this.srg, this.desc);
}
return new FieldInsnNode(179, this.clazz.deobf, this.deobf, this.desc);
}
public FieldInsnNode virtualSet(final boolean obfuscated) {
assert !this.desc.startsWith("(");
if (obfuscated) {
return new FieldInsnNode(181, this.clazz.srg, this.srg, this.desc);
}
return new FieldInsnNode(181, this.clazz.deobf, this.deobf, this.desc);
}
private static void translateDescs() {
final StringBuilder sb = new StringBuilder();
for (final Name name : values()) {
if (name.desc != null) {
int pos;
int endPos;
for (pos = 0, endPos = -1; (pos = name.desc.indexOf(76, pos)) != -1; pos = endPos + 1) {
sb.append(name.desc, endPos + 1, pos);
endPos = name.desc.indexOf(59, pos + 1);
String cName = name.desc.substring(pos + 1, endPos);
for (final Name name2 : values()) {
if (name2.deobf.equals(cName)) {
cName = name2.obf;
break;
}
}
sb.append('L');
sb.append(cName);
sb.append(';');
}
sb.append(name.desc, endPos + 1, name.desc.length());
name.obfDesc = sb.toString();
sb.setLength(0);
}
}
}
static {
translateDescs();
}
}
@@ -1,23 +0,0 @@
package com.falsepattern.endlessids.asm.transformer;
import com.falsepattern.endlessids.constants.ExtendedConstants;
import com.falsepattern.endlessids.constants.VanillaConstants;
import org.objectweb.asm.tree.MethodNode;
import com.falsepattern.endlessids.asm.AsmUtil;
import org.objectweb.asm.tree.ClassNode;
import com.falsepattern.endlessids.asm.IClassNodeTransformer;
public class CofhBlockHelper implements IClassNodeTransformer
{
public CofhBlockHelper() {
super();
}
@Override
public void transform(final ClassNode cn, final boolean obfuscated) {
final MethodNode method = AsmUtil.findMethod(cn, "<clinit>");
if (!AsmUtil.transformInlinedSizeMethod(cn, method, VanillaConstants.blockIDCount, ExtendedConstants.blockIDCount, true)) {
AsmUtil.transformInlinedSizeMethod(cn, method, VanillaConstants.blockIDCount / 4, ExtendedConstants.blockIDCount);
}
}
}
@@ -1,25 +0,0 @@
package com.falsepattern.endlessids.asm.transformer;
import com.falsepattern.endlessids.constants.ExtendedConstants;
import com.falsepattern.endlessids.constants.VanillaConstants;
import org.objectweb.asm.tree.MethodNode;
import com.falsepattern.endlessids.asm.AsmUtil;
import com.falsepattern.endlessids.asm.Name;
import com.falsepattern.endlessids.IEConfig;
import org.objectweb.asm.tree.ClassNode;
import com.falsepattern.endlessids.asm.IClassNodeTransformer;
public class MFQM implements IClassNodeTransformer
{
public MFQM() {
super();
}
@Override
public void transform(final ClassNode cn, final boolean obfuscated) {
if (IEConfig.extendDataWatcher) {
final MethodNode method = AsmUtil.findMethod(cn, Name.MFQM_preInit);
AsmUtil.transformInlinedSizeMethod(cn, method, VanillaConstants.watchableMask, ExtendedConstants.watchableMask);
}
}
}
@@ -1,46 +0,0 @@
package com.falsepattern.endlessids.asm.transformer;
import java.util.ListIterator;
import org.objectweb.asm.tree.InsnList;
import org.objectweb.asm.tree.VarInsnNode;
import org.objectweb.asm.tree.MethodInsnNode;
import org.objectweb.asm.tree.AbstractInsnNode;
import org.objectweb.asm.tree.MethodNode;
import com.falsepattern.endlessids.asm.AsmUtil;
import com.falsepattern.endlessids.asm.Name;
import org.objectweb.asm.tree.ClassNode;
import com.falsepattern.endlessids.asm.IClassNodeTransformer;
public class UndergroundBiomesBiomeUndergroundDecorator implements IClassNodeTransformer
{
public UndergroundBiomesBiomeUndergroundDecorator() {
super();
}
@Override
public void transform(final ClassNode cn, final boolean obfuscated) {
MethodNode method = AsmUtil.findMethod(cn, Name.ub_bud_replaceChunkOres_world);
this.transformReplaceChunkOres(cn, method, obfuscated, 1);
method = AsmUtil.findMethod(cn, Name.ub_bud_replaceChunkOres_iChunkProvider);
this.transformReplaceChunkOres(cn, method, obfuscated, 0);
}
private void transformReplaceChunkOres(final ClassNode cn, final MethodNode method, final boolean obfuscated, final int varOffset) {
final InsnList code = method.instructions;
final ListIterator<AbstractInsnNode> iterator = (ListIterator<AbstractInsnNode>)code.iterator();
while (iterator.hasNext()) {
final AbstractInsnNode insn = (AbstractInsnNode)iterator.next();
if (insn.getOpcode() == 182 && Name.ebs_getBlockLSBArray.matches((MethodInsnNode)insn, obfuscated)) {
iterator.remove();
iterator.add((AbstractInsnNode)new VarInsnNode(21, 9 + varOffset));
iterator.add((AbstractInsnNode)new VarInsnNode(21, 18 + varOffset));
iterator.add((AbstractInsnNode)new VarInsnNode(21, 10 + varOffset));
iterator.add((AbstractInsnNode)Name.hooks_getBlockId.staticInvocation(obfuscated));
while (((AbstractInsnNode)iterator.next()).getOpcode() != 54) {
iterator.remove();
}
break;
}
}
}
}
@@ -1,21 +0,0 @@
package com.falsepattern.endlessids.asm.transformer;
import com.falsepattern.endlessids.constants.ExtendedConstants;
import com.falsepattern.endlessids.constants.VanillaConstants;
import org.objectweb.asm.tree.MethodNode;
import com.falsepattern.endlessids.asm.AsmUtil;
import org.objectweb.asm.tree.ClassNode;
import com.falsepattern.endlessids.asm.IClassNodeTransformer;
public class UndergroundBiomesOreUBifier implements IClassNodeTransformer
{
public UndergroundBiomesOreUBifier() {
super();
}
@Override
public void transform(final ClassNode cn, final boolean obfuscated) {
final MethodNode method = AsmUtil.findMethod(cn, "renewBlockReplacers");
AsmUtil.transformInlinedSizeMethod(cn, method, VanillaConstants.blockIDCount, ExtendedConstants.blockIDCount, false);
}
}
@@ -1,39 +0,0 @@
package com.falsepattern.endlessids.asm.transformer;
import com.falsepattern.endlessids.constants.ExtendedConstants;
import com.falsepattern.endlessids.constants.VanillaConstants;
import lombok.val;
import org.objectweb.asm.tree.InsnList;
import org.objectweb.asm.tree.MethodNode;
import org.objectweb.asm.tree.LdcInsnNode;
import com.falsepattern.endlessids.asm.AsmUtil;
import org.objectweb.asm.tree.ClassNode;
import com.falsepattern.endlessids.asm.IClassNodeTransformer;
public class WorldEditBaseBlock implements IClassNodeTransformer
{
public WorldEditBaseBlock() {
super();
}
@Override
public void transform(final ClassNode cn, final boolean obfuscated) {
final MethodNode method = AsmUtil.findMethod(cn, "internalSetId", true);
if (method == null) {
return;
}
AsmUtil.transformInlinedSizeMethod(cn, method, VanillaConstants.maxBlockID, ExtendedConstants.maxBlockID);
final InsnList code = method.instructions;
val iter = code.iterator();
while (iter.hasNext()) {
val insn = iter.next();
if (insn.getType() == 9 && ((LdcInsnNode)insn).cst instanceof String) {
final String string = (String)((LdcInsnNode)insn).cst;
if (string.contains(Integer.toString(VanillaConstants.maxBlockID))) {
((LdcInsnNode)insn).cst = string.replace(Integer.toString(VanillaConstants.maxBlockID), Integer.toString(ExtendedConstants.maxBlockID));
break;
}
}
}
}
}
@@ -1,10 +1,12 @@
package com.falsepattern.endlessids.constants; package com.falsepattern.endlessids.constants;
import com.falsepattern.endlessids.IEConfig;
public class ExtendedConstants { public class ExtendedConstants {
//Tunables //Tunables
public static final int bitsPerID = 24; public static final int bitsPerID = 24;
public static final int bitsPerMetadata = 4; public static final int bitsPerMetadata = 4;
public static final int countCorrectionBits = 0; public static final int countCorrectionBits = IEConfig.countCorrectionBits;
public static final int watchableBits = 7; public static final int watchableBits = 7;
@@ -1,4 +1,4 @@
package com.falsepattern.endlessids.mixin.mixins.client; package com.falsepattern.endlessids.mixin.mixins.client.vanilla;
import com.falsepattern.endlessids.Hooks; import com.falsepattern.endlessids.Hooks;
import com.falsepattern.endlessids.constants.ExtendedConstants; import com.falsepattern.endlessids.constants.ExtendedConstants;
@@ -19,7 +19,7 @@ import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map; import java.util.Map;
@SideOnly(Side.CLIENT) @SuppressWarnings({"rawtypes", "WhileLoopReplaceableByForEach", "unchecked"})
@Mixin(Chunk.class) @Mixin(Chunk.class)
public abstract class ChunkMixin { public abstract class ChunkMixin {
@Shadow public Map chunkTileEntityMap; @Shadow public Map chunkTileEntityMap;
@@ -44,6 +44,7 @@ public abstract class ChunkMixin {
* @author FalsePattern * @author FalsePattern
* @reason Direct port from dumped code * @reason Direct port from dumped code
*/ */
@SideOnly(Side.CLIENT)
@Overwrite @Overwrite
public void fillChunk(byte[] var1, int var2, int var3, boolean var4) { public void fillChunk(byte[] var1, int var2, int var3, boolean var4) {
Iterator var5 = this.chunkTileEntityMap.values().iterator(); Iterator var5 = this.chunkTileEntityMap.values().iterator();
@@ -1,4 +1,4 @@
package com.falsepattern.endlessids.mixin.mixins.client; package com.falsepattern.endlessids.mixin.mixins.client.vanilla;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
@@ -1,6 +1,5 @@
package com.falsepattern.endlessids.mixin.mixins.common; package com.falsepattern.endlessids.mixin.mixins.client.vanilla;
import com.falsepattern.endlessids.asm.Constants;
import com.falsepattern.endlessids.constants.ExtendedConstants; import com.falsepattern.endlessids.constants.ExtendedConstants;
import com.falsepattern.endlessids.constants.VanillaConstants; import com.falsepattern.endlessids.constants.VanillaConstants;
import net.minecraft.client.multiplayer.PlayerControllerMP; import net.minecraft.client.multiplayer.PlayerControllerMP;
@@ -1,4 +1,4 @@
package com.falsepattern.endlessids.mixin.mixins.client; package com.falsepattern.endlessids.mixin.mixins.client.vanilla;
import com.falsepattern.endlessids.constants.ExtendedConstants; import com.falsepattern.endlessids.constants.ExtendedConstants;
import com.falsepattern.endlessids.constants.VanillaConstants; import com.falsepattern.endlessids.constants.VanillaConstants;
@@ -0,0 +1,18 @@
package com.falsepattern.endlessids.mixin.mixins.common.cofhlib;
import cofh.lib.util.helpers.BlockHelper;
import com.falsepattern.endlessids.constants.ExtendedConstants;
import com.falsepattern.endlessids.constants.VanillaConstants;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
@Mixin(value = BlockHelper.class, remap = false)
public abstract class BlockHelperMixin {
@ModifyConstant(method = "<clinit>",
constant = {@Constant(intValue = VanillaConstants.blockIDCount), @Constant(intValue = VanillaConstants.blockIDCount / 4)},
require = 1)
private static int extend(int constant) {
return ExtendedConstants.blockIDCount;
}
}
@@ -0,0 +1,18 @@
package com.falsepattern.endlessids.mixin.mixins.common.dragonapi;
import Reika.DragonAPI.Extras.BlockProperties;
import com.falsepattern.endlessids.constants.ExtendedConstants;
import com.falsepattern.endlessids.constants.VanillaConstants;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
@Mixin(value = BlockProperties.class, remap = false)
public abstract class BlockPropertiesMixin {
@ModifyConstant(method = "<clinit>",
constant = @Constant(intValue = VanillaConstants.blockIDCount),
require = 1)
private static int extendColorArray(int constant) {
return ExtendedConstants.blockIDCount;
}
}
@@ -0,0 +1,22 @@
package com.falsepattern.endlessids.mixin.mixins.common.mfqm;
import MoreFunQuicksandMod.main.MFQM;
import com.falsepattern.endlessids.constants.ExtendedConstants;
import com.falsepattern.endlessids.constants.VanillaConstants;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
@Mixin(value = MFQM.class, remap = false)
public abstract class MFQMDataWatcherMixin {
@ModifyConstant(method = "preInit",
constant = {
@Constant(intValue = VanillaConstants.maxWatchableID, ordinal = 0),
@Constant(intValue = VanillaConstants.maxWatchableID, ordinal = 1),
@Constant(intValue = VanillaConstants.maxWatchableID, ordinal = 2)
},
require = 3)
private int extendWatchableIDLimit(int constant) {
return ExtendedConstants.maxWatchableID;
}
}
@@ -0,0 +1,28 @@
package com.falsepattern.endlessids.mixin.mixins.common.mfqm;
import MoreFunQuicksandMod.main.MFQM;
import com.falsepattern.endlessids.constants.ExtendedConstants;
import com.falsepattern.endlessids.constants.VanillaConstants;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
@Mixin(value = MFQM.class, remap = false)
public abstract class MFQMMixin {
@ModifyConstant(method = "preInit",
constant = {
@Constant(intValue = VanillaConstants.maxBlockID),
@Constant(intValue = 31999)
},
require = 2)
private int extendWatchableIDLimit(int constant) {
return ExtendedConstants.maxBlockID;
}
@ModifyConstant(method = "preInit",
constant = @Constant(stringValue = "Must be different in range between 20 and 31"),
require = 1)
private String changeConfigText(String constant) {
return constant + " (Notice from EndlessIDs: If you enable the ExtendDataWatcher config option in the endlessids config file, the maximum value will be 127 instead, same for the other datawatcher ids in this file)";
}
}
@@ -0,0 +1,52 @@
package com.falsepattern.endlessids.mixin.mixins.common.ubc;
import com.falsepattern.endlessids.mixin.helpers.IExtendedBlockStorageMixin;
import exterminatorJeff.undergroundBiomes.worldGen.BiomeUndergroundDecorator;
import exterminatorJeff.undergroundBiomes.worldGen.OreUBifier;
import net.minecraft.world.chunk.NibbleArray;
import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(value = BiomeUndergroundDecorator.class, remap = false)
public abstract class BiomeUndergroundDecoratorMixin {
private static NibbleArray fakeArray;
private ThreadLocal<IExtendedBlockStorageMixin> ebs;
@Redirect(method = {"replaceChunkOres(IILnet/minecraft/world/World;)V", "replaceChunkOres(Lnet/minecraft/world/chunk/IChunkProvider;II)V"},
at = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;func_76658_g()[B"),
require = 2)
private byte[] returnMSBasLSB(ExtendedBlockStorage instance) {
if (ebs == null) ebs = new ThreadLocal<>();
IExtendedBlockStorageMixin iebs = (IExtendedBlockStorageMixin) instance;
ebs.set(iebs);
return iebs.getMSB();
}
@Redirect(method = {"replaceChunkOres(IILnet/minecraft/world/World;)V", "replaceChunkOres(Lnet/minecraft/world/chunk/IChunkProvider;II)V"},
at = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;func_76660_i()Lnet/minecraft/world/chunk/NibbleArray;"),
require = 4)
private NibbleArray returnFakeArray(ExtendedBlockStorage instance) {
return fakeArray == null ? (fakeArray = new NibbleArray(4096, 4)) : fakeArray;
}
@Redirect(method = {"replaceChunkOres(IILnet/minecraft/world/World;)V", "replaceChunkOres(Lnet/minecraft/world/chunk/IChunkProvider;II)V"},
at = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/NibbleArray;func_76582_a(III)I"),
require = 2)
private int returnRestOfID(NibbleArray instance, int x, int y, int z) {
return ebs.get().getLSB()[y << 8 | z << 4 | x] & 0xFFFF;
}
@Redirect(method = {"replaceChunkOres(IILnet/minecraft/world/World;)V", "replaceChunkOres(Lnet/minecraft/world/chunk/IChunkProvider;II)V"},
at = @At(value = "INVOKE",
target = "LexterminatorJeff/undergroundBiomes/worldGen/OreUBifier;blockReplacer(I)LexterminatorJeff/undergroundBiomes/worldGen/OreUBifier$BlockReplacer;"),
require = 2)
private OreUBifier.BlockReplacer reshuffleID(OreUBifier instance, int blockID) {
blockID = ((blockID & 0xFF) << 16) | ((blockID & 0xFFFF00) >>> 8);
return instance.blockReplacer(blockID);
}
}
@@ -0,0 +1,18 @@
package com.falsepattern.endlessids.mixin.mixins.common.ubc;
import com.falsepattern.endlessids.constants.ExtendedConstants;
import com.falsepattern.endlessids.constants.VanillaConstants;
import exterminatorJeff.undergroundBiomes.worldGen.OreUBifier;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
@Mixin(value = OreUBifier.class, remap = false)
public abstract class OreUBifierMixin {
@ModifyConstant(method = "renewBlockReplacers",
constant = @Constant(intValue = VanillaConstants.blockIDCount),
require = 1)
private int extendReplacerArraySize(int constant) {
return ExtendedConstants.blockIDCount;
}
}
@@ -1,4 +1,4 @@
package com.falsepattern.endlessids.mixin.mixins.common; package com.falsepattern.endlessids.mixin.mixins.common.vanilla.misc;
import com.falsepattern.endlessids.constants.ExtendedConstants; import com.falsepattern.endlessids.constants.ExtendedConstants;
import com.falsepattern.endlessids.constants.VanillaConstants; import com.falsepattern.endlessids.constants.VanillaConstants;
@@ -1,4 +1,4 @@
package com.falsepattern.endlessids.mixin.mixins.common; package com.falsepattern.endlessids.mixin.mixins.common.vanilla.misc;
import com.falsepattern.endlessids.constants.ExtendedConstants; import com.falsepattern.endlessids.constants.ExtendedConstants;
import com.falsepattern.endlessids.constants.VanillaConstants; import com.falsepattern.endlessids.constants.VanillaConstants;
@@ -1,4 +1,4 @@
package com.falsepattern.endlessids.mixin.mixins.common; package com.falsepattern.endlessids.mixin.mixins.common.vanilla.misc;
import com.falsepattern.endlessids.constants.ExtendedConstants; import com.falsepattern.endlessids.constants.ExtendedConstants;
import com.falsepattern.endlessids.constants.VanillaConstants; import com.falsepattern.endlessids.constants.VanillaConstants;
@@ -1,4 +1,4 @@
package com.falsepattern.endlessids.mixin.mixins.common; package com.falsepattern.endlessids.mixin.mixins.common.vanilla.misc;
import com.falsepattern.endlessids.constants.ExtendedConstants; import com.falsepattern.endlessids.constants.ExtendedConstants;
import com.falsepattern.endlessids.constants.VanillaConstants; import com.falsepattern.endlessids.constants.VanillaConstants;
@@ -1,4 +1,4 @@
package com.falsepattern.endlessids.mixin.mixins.common; package com.falsepattern.endlessids.mixin.mixins.common.vanilla.misc;
import com.falsepattern.endlessids.constants.ExtendedConstants; import com.falsepattern.endlessids.constants.ExtendedConstants;
import com.falsepattern.endlessids.constants.VanillaConstants; import com.falsepattern.endlessids.constants.VanillaConstants;
@@ -1,4 +1,4 @@
package com.falsepattern.endlessids.mixin.mixins.common; package com.falsepattern.endlessids.mixin.mixins.common.vanilla.networking;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import net.minecraft.item.Item; import net.minecraft.item.Item;
@@ -1,7 +1,6 @@
package com.falsepattern.endlessids.mixin.mixins.common; package com.falsepattern.endlessids.mixin.mixins.common.vanilla.networking;
import com.falsepattern.endlessids.Hooks; import com.falsepattern.endlessids.Hooks;
import com.falsepattern.endlessids.asm.Constants;
import com.falsepattern.endlessids.constants.ExtendedConstants; import com.falsepattern.endlessids.constants.ExtendedConstants;
import com.falsepattern.endlessids.constants.VanillaConstants; import com.falsepattern.endlessids.constants.VanillaConstants;
import com.falsepattern.endlessids.mixin.helpers.IExtendedBlockStorageMixin; import com.falsepattern.endlessids.mixin.helpers.IExtendedBlockStorageMixin;
@@ -1,4 +1,4 @@
package com.falsepattern.endlessids.mixin.mixins.common; package com.falsepattern.endlessids.mixin.mixins.common.vanilla.networking;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.network.play.server.S22PacketMultiBlockChange; import net.minecraft.network.play.server.S22PacketMultiBlockChange;
@@ -1,6 +1,5 @@
package com.falsepattern.endlessids.mixin.mixins.common; package com.falsepattern.endlessids.mixin.mixins.common.vanilla.networking;
import com.falsepattern.endlessids.asm.Constants;
import com.falsepattern.endlessids.constants.ExtendedConstants; import com.falsepattern.endlessids.constants.ExtendedConstants;
import com.falsepattern.endlessids.constants.VanillaConstants; import com.falsepattern.endlessids.constants.VanillaConstants;
import net.minecraft.network.play.server.S24PacketBlockAction; import net.minecraft.network.play.server.S24PacketBlockAction;
@@ -1,4 +1,4 @@
package com.falsepattern.endlessids.mixin.mixins.common; package com.falsepattern.endlessids.mixin.mixins.common.vanilla.networking;
import com.falsepattern.endlessids.constants.ExtendedConstants; import com.falsepattern.endlessids.constants.ExtendedConstants;
import com.falsepattern.endlessids.constants.VanillaConstants; import com.falsepattern.endlessids.constants.VanillaConstants;
@@ -1,4 +1,4 @@
package com.falsepattern.endlessids.mixin.mixins.common; package com.falsepattern.endlessids.mixin.mixins.common.vanilla.storage;
import com.falsepattern.endlessids.Hooks; import com.falsepattern.endlessids.Hooks;
import com.falsepattern.endlessids.mixin.helpers.IExtendedBlockStorageMixin; import com.falsepattern.endlessids.mixin.helpers.IExtendedBlockStorageMixin;
@@ -1,4 +1,4 @@
package com.falsepattern.endlessids.mixin.mixins.common; package com.falsepattern.endlessids.mixin.mixins.common.vanilla.storage;
import com.falsepattern.endlessids.Hooks; import com.falsepattern.endlessids.Hooks;
import com.falsepattern.endlessids.mixin.helpers.IExtendedBlockStorageMixin; import com.falsepattern.endlessids.mixin.helpers.IExtendedBlockStorageMixin;
@@ -1,4 +1,4 @@
package com.falsepattern.endlessids.mixin.mixins.common; package com.falsepattern.endlessids.mixin.mixins.common.vanilla.storage;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@@ -0,0 +1,36 @@
package com.falsepattern.endlessids.mixin.mixins.common.worldedit;
import com.falsepattern.endlessids.constants.ExtendedConstants;
import com.sk89q.worldedit.blocks.BaseBlock;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
@Mixin(value = BaseBlock.class, remap = false)
public abstract class BaseBlockMixin {
private int idExtended;
/**
* @author FalsePattern
* @reason ID limit extension
*/
@Overwrite
protected final void internalSetId(int id) {
if (id > ExtendedConstants.maxBlockID) {
throw new IllegalArgumentException("Can't have a block ID above " + ExtendedConstants.maxBlockID + " (" + id + " given)");
} else if (id < 0) {
throw new IllegalArgumentException("Can't have a block ID below 0");
} else {
this.idExtended = id;
}
}
/**
* @author FalsePattern
* @reason ID limit extension
*/
@Overwrite
public int getId() {
return idExtended;
}
}
@@ -1,81 +0,0 @@
package com.falsepattern.endlessids.mixin.plugin;
import com.google.common.io.Files;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.ModClassLoader;
import net.minecraft.launchwrapper.Launch;
import net.minecraft.launchwrapper.LaunchClassLoader;
import sun.misc.URLClassPath;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Field;
import java.nio.file.Path;
/**
* Backport from spongemixins 1.3
*/
public final class MinecraftURLClassPath {
/**
* Utility to manipulate the minecraft URL ClassPath
*/
private static final Field modClassLoaderField;
private static final Field loaderinstanceField;
private static final Field mainClassLoaderField;
private static final Field ucpField;
private static final ModClassLoader modClassLoader;
private static final LaunchClassLoader mainClassLoader;
private static final URLClassPath ucp;
static {
try {
modClassLoaderField = Loader.class.getDeclaredField("modClassLoader");
modClassLoaderField.setAccessible(true);
loaderinstanceField = Loader.class.getDeclaredField("instance");
loaderinstanceField.setAccessible(true);
mainClassLoaderField = ModClassLoader.class.getDeclaredField("mainClassLoader");
mainClassLoaderField.setAccessible(true);
ucpField = LaunchClassLoader.class.getSuperclass().getDeclaredField("ucp");
ucpField.setAccessible(true);
Object loader = loaderinstanceField.get(null);
modClassLoader = (ModClassLoader)modClassLoaderField.get(loader);
mainClassLoader = (LaunchClassLoader)mainClassLoaderField.get(modClassLoader);
ucp = (URLClassPath)ucpField.get(mainClassLoader);
} catch (NoSuchFieldException | IllegalAccessException e) {
throw new RuntimeException(e.getMessage());
}
}
/**
* Get a jar within the minecraft mods directory
*/
public static File getJarInModPath(final String jarname) {
try {
return java.nio.file.Files.walk(new File(Launch.minecraftHome, "mods/").toPath()).filter( p -> {
final String filename = p.toString();
return Files.getNameWithoutExtension(filename).contains(jarname) && Files.getFileExtension(filename).equals("jar");
}).map(Path::toFile).findFirst().orElse(null);
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
/**
* Adds a Jar to the Minecraft URL ClassPath
* - Needed when using mixins on classes outside of Minecraft or other coremods
*/
public static void addJar(File pathToJar) throws Exception {
ucp.addURL(pathToJar.toURI().toURL());
}
private MinecraftURLClassPath() {
}
}
@@ -1,99 +1,70 @@
package com.falsepattern.endlessids.mixin.plugin; package com.falsepattern.endlessids.mixin.plugin;
import com.falsepattern.endlessids.IEConfig; import com.falsepattern.endlessids.IEConfig;
import cpw.mods.fml.relauncher.FMLLaunchHandler; import com.falsepattern.lib.mixin.IMixin;
import com.falsepattern.lib.mixin.ITargetedMod;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.function.Predicate;
import java.util.function.Supplier;
public enum Mixin { import static com.falsepattern.lib.mixin.IMixin.PredicateHelpers.*;
AnvilChunkLoaderMixin(builder(Side.COMMON).mixin("AnvilChunkLoaderMixin")),
BlockFireMixin(builder(Side.COMMON).mixin("BlockFireMixin")),
DataWatcherMixin(builder(Side.COMMON).condition(() -> IEConfig.extendDataWatcher).mixin("DataWatcherMixin")),
ExtendedBlockStorageMixin(builder(Side.COMMON).mixin("ExtendedBlockStorageMixin")),
ItemInWorldManagerMixin(builder(Side.COMMON).mixin("ItemInWorldManagerMixin")),
ItemStackMixin(builder(Side.COMMON).mixin("ItemStackMixin")),
PacketBufferMixin(builder(Side.COMMON).mixin("PacketBufferMixin")),
PlayerControllerMPMixin(builder(Side.COMMON).mixin("PlayerControllerMPMixin")),
S21PacketChunkDataMixin(builder(Side.COMMON).mixin("S21PacketChunkDataMixin")),
S22PacketMultiBlockChangeMixin(builder(Side.COMMON).mixin("S22PacketMultiBlockChangeMixin")),
S24PacketBlockActionMixin(builder(Side.COMMON).mixin("S24PacketBlockActionMixin")),
S26PacketMapChunkBulkMixin(builder(Side.COMMON).mixin("S26PacketMapChunkBulkMixin")),
StatListMixin(builder(Side.COMMON).mixin("StatListMixin")),
WorldMixin(builder(Side.COMMON).mixin("WorldMixin")),
ChunkMixin(builder(Side.CLIENT).mixin("ChunkMixin")), @RequiredArgsConstructor
NetHandlerPlayClientMixin(builder(Side.CLIENT).mixin("NetHandlerPlayClientMixin")), public enum Mixin implements IMixin {
RenderGlobalMixin(builder(Side.CLIENT).mixin("RenderGlobalMixin")), //region Minecraft
//region common
//region storage
AnvilChunkLoaderMixin(Side.COMMON, always(), "vanilla.storage.AnvilChunkLoaderMixin"),
ExtendedBlockStorageMixin(Side.COMMON, always(), "vanilla.storage.ExtendedBlockStorageMixin"),
ItemStackMixin(Side.COMMON, always(), "vanilla.storage.ItemStackMixin"),
//endregion storage
//region networking
PacketBufferMixin(Side.COMMON, always(), "vanilla.networking.PacketBufferMixin"),
S21PacketChunkDataMixin(Side.COMMON, always(), "vanilla.networking.S21PacketChunkDataMixin"),
S22PacketMultiBlockChangeMixin(Side.COMMON, always(), "vanilla.networking.S22PacketMultiBlockChangeMixin"),
S24PacketBlockActionMixin(Side.COMMON, always(), "vanilla.networking.S24PacketBlockActionMixin"),
S26PacketMapChunkBulkMixin(Side.COMMON, always(), "vanilla.networking.S26PacketMapChunkBulkMixin"),
//endregion networking
//region misc
BlockFireMixin(Side.COMMON, always(), "vanilla.misc.BlockFireMixin"),
DataWatcherMixin(Side.COMMON, condition(() -> IEConfig.extendDataWatcher), "vanilla.misc.DataWatcherMixin"),
ItemInWorldManagerMixin(Side.COMMON, always(), "vanilla.misc.ItemInWorldManagerMixin"),
StatListMixin(Side.COMMON, always(), "vanilla.misc.StatListMixin"),
WorldMixin(Side.COMMON, always(), "vanilla.misc.WorldMixin"),
//endregion misc
//endregion common
//region client
ChunkMixin(Side.CLIENT, always(), "vanilla.ChunkMixin"),
NetHandlerPlayClientMixin(Side.CLIENT, always(), "vanilla.NetHandlerPlayClientMixin"),
PlayerControllerMPMixin(Side.CLIENT, always(), "vanilla.PlayerControllerMPMixin"),
RenderGlobalMixin(Side.CLIENT, always(), "vanilla.RenderGlobalMixin"),
//endregion client
//endregion Minecraft
//region UBC->common
OreUBifierMixin(Side.COMMON, require(TargetedMod.UBC), "ubc.OreUBifierMixin"),
BiomeUndergroundDecoratorMixin(Side.COMMON, require(TargetedMod.UBC), "ubc.BiomeUndergroundDecoratorMixin"),
//endregion UBC->common
//region CoFHLib->common
CofhBlockHelperMixin(Side.COMMON, require(TargetedMod.COFHLIB), "cofhlib.BlockHelperMixin"),
//endregion CoFHLib->common
//region DragonAPI->common
BlockPropertiesMixin(Side.COMMON, require(TargetedMod.DRAGONAPI), "dragonapi.BlockPropertiesMixin"),
//endregion DragonAPI->common
//region MFQM->common
MFQMMixin(Side.COMMON, require(TargetedMod.MFQM), "mfqm.MFQMMixin"),
MFQMDataWatcherMixin(Side.COMMON, require(TargetedMod.MFQM).and(condition(() -> IEConfig.extendDataWatcher)), "mfqm.MFQMDataWatcherMixin"),
//endregion MFQM->common
//region WorldEdit->common
BaseBlockMixin(Side.COMMON, require(TargetedMod.WORLDEDIT), "worldedit.BaseBlockMixin"),
//endregion WorldEdit->common
; ;
@Getter
public final String mixin;
public final Set<TargetedMod> targetedMods;
public final Set<TargetedMod> avoidedMods;
public final Set<Supplier<Boolean>> allowConditions;
private final Side side; private final Side side;
@Getter
Mixin(Builder builder) { private final Predicate<List<ITargetedMod>> filter;
this.mixin = builder.mixin; @Getter
this.targetedMods = builder.targetedMods; private final String mixin;
this.avoidedMods = builder.avoidedMods;
this.allowConditions = builder.allowConditions;
this.side = builder.side;
}
public boolean shouldLoad(List<TargetedMod> loadedMods) {
return (side == Side.COMMON
|| side == Side.SERVER && FMLLaunchHandler.side().isServer()
|| side == Side.CLIENT && FMLLaunchHandler.side().isClient())
&& loadedMods.containsAll(targetedMods)
&& avoidedMods.stream().noneMatch(loadedMods::contains)
&& allowConditions.stream().allMatch(Supplier::get);
}
@SuppressWarnings("SameParameterValue")
private static Builder builder(Side side) {
return new Builder(side);
}
private static class Builder {
public String mixin;
public Side side;
public final Set<TargetedMod> targetedMods = new HashSet<>();
public final Set<TargetedMod> avoidedMods = new HashSet<>();
public final Set<Supplier<Boolean>> allowConditions = new HashSet<>();
public Builder(Side side) {
this.side = side;
}
public Builder mixin(String mixinClass) {
mixin = side.name().toLowerCase() + "." + mixinClass;
return this;
}
public Builder target(TargetedMod mod) {
targetedMods.add(mod);
return this;
}
public Builder avoid(TargetedMod mod) {
avoidedMods.add(mod);
return this;
}
public Builder condition(Supplier<Boolean> cond) {
allowConditions.add(cond);
return this;
}
}
private enum Side {
COMMON,
CLIENT,
SERVER
}
} }
@@ -1,124 +1,23 @@
package com.falsepattern.endlessids.mixin.plugin; package com.falsepattern.endlessids.mixin.plugin;
import com.falsepattern.endlessids.Tags; import com.falsepattern.endlessids.Tags;
import lombok.val; import com.falsepattern.lib.mixin.IMixin;
import net.minecraft.launchwrapper.Launch; import com.falsepattern.lib.mixin.IMixinPlugin;
import org.apache.logging.log4j.LogManager; import com.falsepattern.lib.mixin.ITargetedMod;
import lombok.Getter;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.spongepowered.asm.lib.tree.ClassNode;
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
import java.io.File; public class MixinPlugin implements IMixinPlugin {
import java.io.FileNotFoundException; @Getter
import java.io.IOException; private final Logger logger = IMixinPlugin.createLogger(Tags.MODNAME);
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import static java.nio.file.Files.walk;
public class MixinPlugin implements IMixinConfigPlugin {
private static final Logger LOG = LogManager.getLogger(Tags.MODNAME + " Mixin Loader");
private static final Path MODS_DIRECTORY_PATH = new File(Launch.minecraftHome, "mods/").toPath();
@Override @Override
public void onLoad(String mixinPackage) { public IMixin[] getMixinEnumValues() {
return Mixin.values();
} }
@Override @Override
public String getRefMapperConfig() { public ITargetedMod[] getTargetedModEnumValues() {
return null; return TargetedMod.values();
}
@Override
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
return true;
}
@Override
public void acceptTargets(Set<String> myTargets, Set<String> otherTargets) {
}
// This method return a List<String> of mixins. Every mixins in this list will be loaded.
@Override
public List<String> getMixins() {
val isDevelopmentEnvironment = (boolean) Launch.blackboard.get("fml.deobfuscatedEnvironment");
val loadedMods =
Arrays.stream(TargetedMod.values())
.filter(mod -> mod == TargetedMod.VANILLA
|| (mod.loadInDevelopment && isDevelopmentEnvironment)
|| loadJarOf(mod))
.collect(Collectors.toList());
for (TargetedMod mod : TargetedMod.values()) {
if(loadedMods.contains(mod)) {
LOG.info("Found " + mod.modName + "! Integrating now...");
}
else {
LOG.info("Could not find " + mod.modName + "! Skipping integration....");
}
}
val mixins = new ArrayList<String>();
for (val mixin : Mixin.values()) {
if (mixin.shouldLoad(loadedMods)) {
mixins.add(mixin.mixin);
LOG.info("Loading mixin: " + mixin.mixin);
}
}
return mixins;
}
private boolean loadJarOf(final TargetedMod mod) {
try {
val jar = findJarOf(mod);
if(jar == null) {
LOG.info("Jar not found for " + mod);
return false;
}
LOG.info("Attempting to add " + jar + " to the URL Class Path");
if(!jar.exists()) {
throw new FileNotFoundException(jar.toString());
}
MinecraftURLClassPath.addJar(jar);
return true;
}
catch (Exception e) {
e.printStackTrace();
return false;
}
}
public static File findJarOf(final TargetedMod mod) {
try {
return walk(MODS_DIRECTORY_PATH)
.filter(mod::isMatchingJar)
.map(Path::toFile)
.findFirst()
.orElse(null);
}
catch (IOException e) {
e.printStackTrace();
return null;
}
}
@Override
public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
}
@Override
public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
} }
} }
@@ -1,41 +1,27 @@
package com.falsepattern.endlessids.mixin.plugin; package com.falsepattern.endlessids.mixin.plugin;
import com.google.common.io.Files; import com.falsepattern.lib.mixin.ITargetedMod;
import lombok.val; import lombok.Getter;
import lombok.RequiredArgsConstructor;
import java.nio.file.Path; import java.util.function.Predicate;
public enum TargetedMod { import static com.falsepattern.lib.mixin.ITargetedMod.PredicateHelpers.*;
VANILLA("Minecraft", "", "", true); @RequiredArgsConstructor
public enum TargetedMod implements ITargetedMod {
public final String modName; UBC("Underground Biomes Constructs", false, startsWith("undergroundbiomesconstructs-")),
public final String jarNamePrefixLowercase; COFHLIB("CoFH Lib", false, startsWith("cofhlib-")),
public final String jarNameContainsLowercase; DRAGONAPI("DragonAPI", false, startsWith("dragonapi")),
MFQM("More Fun Quicksand Mod", false, startsWith("morefunquicksandmod-")),
WORLDEDIT("WorldEdit", false, startsWith("worldedit-")),
;
public final boolean loadInDevelopment; @Getter
private final String modName;
TargetedMod(String modName, String jarNamePrefix, String jarNameContains, boolean loadInDevelopment) { @Getter
this.modName = modName; private final boolean loadInDevelopment;
this.jarNamePrefixLowercase = jarNamePrefix.toLowerCase(); @Getter
this.jarNameContainsLowercase = jarNameContains.toLowerCase(); private final Predicate<String> condition;
this.loadInDevelopment = loadInDevelopment;
}
@SuppressWarnings("UnstableApiUsage")
public boolean isMatchingJar(Path path) {
val pathString = path.toString();
val nameLowerCase = Files.getNameWithoutExtension(pathString).toLowerCase();
val fileExtension = Files.getFileExtension(pathString);
return "jar".equals(fileExtension) && nameLowerCase.startsWith(jarNamePrefixLowercase) && nameLowerCase.contains(jarNameContainsLowercase);
}
@Override
public String toString() {
return "TargetedMod{" +
"modName='" + modName + '\'' +
", jarNamePrefixLowercase='" + jarNamePrefixLowercase + '\'' +
'}';
}
} }