mirror of
https://github.com/GTMEGA/EndlessIDs.git
synced 2026-11-24 10:34:29 +00:00
Compare commits
26
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e3820669f8 | ||
|
|
42b2968fde | ||
|
|
32e88ec680 | ||
|
|
b46cd34868 | ||
|
|
6bcf0e8bd5 | ||
|
|
e468253906 | ||
|
|
ed3adba5e3 | ||
|
|
2a72daa6cf | ||
|
|
072ca7bcf8 | ||
|
|
164ec7b923 | ||
|
|
b92ae7985f | ||
|
|
f15acb23ba | ||
|
|
18d1e77e56 | ||
|
|
2efcbe2e16 | ||
|
|
d4b2e9f5da | ||
|
|
e8212e3224 | ||
|
|
066ae631c1 | ||
|
|
1d32553b2d | ||
|
|
2b8bc1c1c1 | ||
|
|
345ec097d7 | ||
|
|
72bfd43b9f | ||
|
|
4f1e4a22cc | ||
|
|
2a4d841b9d | ||
|
|
31e4d39338 | ||
|
|
1d0e0550fa | ||
|
|
5a61d8afe0 |
No files matched your search
@@ -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
|
||||
@@ -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
|
||||
@@ -11,6 +11,9 @@ on:
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
MAVEN_DEPLOY_USER: ${{ secrets.MAVEN_DEPLOY_USER }}
|
||||
MAVEN_DEPLOY_PASSWORD: ${{ secrets.MAVEN_DEPLOY_PASSWORD }}
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
@@ -43,3 +46,6 @@ jobs:
|
||||
prerelease: false
|
||||
title: "${{ env.RELEASE_VERSION }}"
|
||||
files: build/libs/*.jar
|
||||
|
||||
- name: Publish to maven
|
||||
run: ./gradlew publish
|
||||
Generated
+33
@@ -0,0 +1,33 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<code_scheme name="Project" version="173">
|
||||
<JavaCodeStyleSettings>
|
||||
<option name="ANNOTATION_PARAMETER_WRAP" value="2" />
|
||||
<option name="ALIGN_MULTILINE_ANNOTATION_PARAMETERS" value="true" />
|
||||
<option name="PACKAGES_TO_USE_IMPORT_ON_DEMAND">
|
||||
<value>
|
||||
<package name="java.awt" withSubpackages="false" static="false" />
|
||||
<package name="javax.swing" withSubpackages="false" static="false" />
|
||||
</value>
|
||||
</option>
|
||||
</JavaCodeStyleSettings>
|
||||
<codeStyleSettings language="JAVA">
|
||||
<option name="KEEP_LINE_BREAKS" value="false" />
|
||||
<option name="KEEP_FIRST_COLUMN_COMMENT" value="false" />
|
||||
<option name="KEEP_CONTROL_STATEMENT_IN_ONE_LINE" value="false" />
|
||||
<option name="ALIGN_MULTILINE_CHAINED_METHODS" value="true" />
|
||||
<option name="ALIGN_MULTILINE_BINARY_OPERATION" value="true" />
|
||||
<option name="ALIGN_MULTILINE_ASSIGNMENT" value="true" />
|
||||
<option name="ALIGN_MULTILINE_TERNARY_OPERATION" value="true" />
|
||||
<option name="ALIGN_MULTILINE_THROWS_LIST" value="true" />
|
||||
<option name="ALIGN_MULTILINE_EXTENDS_LIST" value="true" />
|
||||
<option name="ALIGN_MULTILINE_METHOD_BRACKETS" value="true" />
|
||||
<option name="ALIGN_MULTILINE_PARENTHESIZED_EXPRESSION" value="true" />
|
||||
<option name="KEEP_SIMPLE_BLOCKS_IN_ONE_LINE" value="true" />
|
||||
<option name="KEEP_SIMPLE_LAMBDAS_IN_ONE_LINE" value="true" />
|
||||
<option name="KEEP_SIMPLE_CLASSES_IN_ONE_LINE" value="true" />
|
||||
<option name="PARAMETER_ANNOTATION_WRAP" value="2" />
|
||||
<option name="VARIABLE_ANNOTATION_WRAP" value="2" />
|
||||
<option name="ENUM_CONSTANTS_WRAP" value="2" />
|
||||
</codeStyleSettings>
|
||||
</code_scheme>
|
||||
</component>
|
||||
Generated
+5
@@ -0,0 +1,5 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<state>
|
||||
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
|
||||
</state>
|
||||
</component>
|
||||
@@ -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/.
|
||||
@@ -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.
|
||||
@@ -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.
|
||||
@@ -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
|
||||
@@ -7,13 +7,19 @@ EndlessIDs is a modern rewrite of NotEnoughIDs which increases the limit even mo
|
||||
|
||||
This mod also contains patches for the following mods:
|
||||
|
||||
- [UndergroundBiomesConstructs](https://www.curseforge.com/minecraft/mc-mods/undergroundbiomesconstructs)
|
||||
- [More Fun Quicksand Mod](https://www.curseforge.com/minecraft/mc-mods/more-fun-quicksand-mod)
|
||||
- [WorldEdit](https://www.curseforge.com/minecraft/mc-mods/worldedit)
|
||||
- [CoFH Lib](https://www.curseforge.com/minecraft/mc-mods/cofh-lib)
|
||||
- [DragonAPI](https://www.curseforge.com/minecraft/mc-mods/dragonapi)
|
||||
- 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.
|
||||
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)
|
||||
|
||||
[](https://gist.github.com/poop-person/991e80f390384bbeef09d208bff208f4)
|
||||
+23
-12
@@ -1,4 +1,4 @@
|
||||
//version: 1641429628falsepattern12
|
||||
//version: 1641429628falsepattern18
|
||||
/*
|
||||
DO NOT CHANGE THIS FILE!
|
||||
|
||||
@@ -95,6 +95,7 @@ checkPropertyExists("repositoryName")
|
||||
checkPropertyExists("mavenGroupId")
|
||||
checkPropertyExists("mavenArtifactId")
|
||||
checkPropertyExists("hasMixinDeps")
|
||||
checkPropertyExists("mixinPreinitConfig")
|
||||
|
||||
|
||||
String javaSourceDir = "src/main/java/"
|
||||
@@ -441,7 +442,7 @@ def getManifestAttributes() {
|
||||
if(usesMixins.toBoolean()) {
|
||||
manifestAttributes += [
|
||||
"TweakClass" : "org.spongepowered.asm.launch.MixinTweaker",
|
||||
"MixinConfigs" : "mixins." + modId + ".json",
|
||||
"MixinConfigs" : "mixins." + modId + ".json" + (mixinPreinitConfig ? "," + mixinPreinitConfig : ""),
|
||||
"ForceLoadAsMod" : containsMixinsAndOrCoreModOnly.toBoolean() == false
|
||||
]
|
||||
}
|
||||
@@ -545,8 +546,16 @@ def getCredentials = {
|
||||
return [username: entry.username.text(), password: entry.password.text()]
|
||||
}
|
||||
}
|
||||
throw new Exception();
|
||||
} 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 {
|
||||
publications {
|
||||
maven(MavenPublication) {
|
||||
artifact source: jar
|
||||
artifact source: (jar.enabled ? jar : shadowJar)
|
||||
artifact source: sourcesJar, classifier: "src"
|
||||
artifact source: devJar, classifier: "dev"
|
||||
artifact source: (devJar.enabled ? devJar : shadowDevJar), classifier: "dev"
|
||||
if (apiPackage) {
|
||||
artifact source: apiJar, classifier: "api"
|
||||
}
|
||||
@@ -568,13 +577,15 @@ publishing {
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
name = repositoryName
|
||||
url = repositoryURL
|
||||
def creds = getCredentials()
|
||||
credentials {
|
||||
username = creds == null ? "none" : creds.username
|
||||
password = creds == null ? "none" : creds.password
|
||||
if (repositoryURL.trim() != "") {
|
||||
maven {
|
||||
name = repositoryName
|
||||
url = repositoryURL
|
||||
def creds = getCredentials()
|
||||
credentials {
|
||||
username = creds == null ? "none" : creds.username
|
||||
password = creds == null ? "none" : creds.password
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@ dependencies {
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
@@ -68,6 +68,8 @@ hasMixinDeps = false
|
||||
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!
|
||||
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!
|
||||
# This parameter is for legacy compatibility only
|
||||
# Example value: coreModClass = asm.FMLPlugin + modGroup = com.myname.mymodid -> com.myname.mymodid.asm.FMLPlugin
|
||||
|
||||
@@ -8,4 +8,8 @@ repositories {
|
||||
includeGroup "curse.maven"
|
||||
}
|
||||
}
|
||||
maven {
|
||||
name = "mavenpattern"
|
||||
url = "https://maven.falsepattern.com/"
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,14 @@
|
||||
package com.falsepattern.endlessids;
|
||||
|
||||
import cpw.mods.fml.common.Mod;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
@Mod(modid = Tags.MODID, name = Tags.MODNAME, version = Tags.VERSION)
|
||||
public class EndlessIDs {}
|
||||
@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 static final Logger LOG = LogManager.getLogger(Tags.MODNAME);
|
||||
}
|
||||
@@ -1,11 +1,14 @@
|
||||
package com.falsepattern.endlessids;
|
||||
|
||||
import com.falsepattern.endlessids.constants.ExtendedConstants;
|
||||
import com.falsepattern.endlessids.mixin.helpers.IChunkMixin;
|
||||
import com.falsepattern.endlessids.mixin.helpers.IExtendedBlockStorageMixin;
|
||||
import lombok.val;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
|
||||
import java.nio.ShortBuffer;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
@@ -124,7 +127,7 @@ public class Hooks {
|
||||
public static int getIdFromBlockWithCheck(final Block block, final Block oldBlock) {
|
||||
final int id = Block.getIdFromBlock(block);
|
||||
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) {
|
||||
return id;
|
||||
@@ -134,5 +137,66 @@ public class Hooks {
|
||||
}
|
||||
throw new IllegalArgumentException("id out of range: " + id);
|
||||
}
|
||||
|
||||
|
||||
//Biome ID Extender Code
|
||||
|
||||
public static byte[] shortToByteArray(short[] shortArray) {
|
||||
byte[] byteArray = new byte[512];
|
||||
|
||||
for(int i = 0; i < 256; ++i) {
|
||||
byteArray[i] = (byte)(shortArray[i] & 255);
|
||||
byteArray[i + 256] = (byte)(shortArray[i] >>> 8);
|
||||
}
|
||||
return byteArray;
|
||||
}
|
||||
|
||||
public static short[] byteToShortArray(byte[] byteArray) {
|
||||
short[] shortArray = new short[256];
|
||||
|
||||
for(int i = 0; i < 256; ++i) {
|
||||
shortArray[i] = (short)(byteArray[i + 256] << 8 | byteArray[i]);
|
||||
}
|
||||
|
||||
return shortArray;
|
||||
}
|
||||
|
||||
public static short[] oldBiomeByteToNewShortArray(byte[] byteArray) {
|
||||
short[] shortArray = new short[256];
|
||||
|
||||
for (int i = 0; i < 256; i++) {
|
||||
shortArray[i] = (short)(byteArray[i] & 0xff);
|
||||
}
|
||||
|
||||
return shortArray;
|
||||
}
|
||||
|
||||
public static int readBiomeArrayFromPacket(Chunk chunk, byte[] array, int offset) {
|
||||
byte[] byteArray = new byte[512];
|
||||
System.arraycopy(array, offset, byteArray, 0, 512);
|
||||
((IChunkMixin)chunk).setBiomeShortArray(byteToShortArray(byteArray));
|
||||
return byteArray.length;
|
||||
}
|
||||
|
||||
public static int writeBiomeArrayToPacket(Chunk chunk, byte[] array, int offset) {
|
||||
byte[] byteArray = shortToByteArray(((IChunkMixin)chunk).getBiomeShortArray());
|
||||
System.arraycopy(byteArray, 0, array, offset, 512);
|
||||
return byteArray.length;
|
||||
}
|
||||
|
||||
public static void writeChunkBiomeArrayToNbt(Chunk chunk, NBTTagCompound nbt) {
|
||||
byte[] byteArray = shortToByteArray(((IChunkMixin)chunk).getBiomeShortArray());
|
||||
nbt.setByteArray("Biomes16", byteArray);
|
||||
}
|
||||
|
||||
public static void readChunkBiomeArrayFromNbt(Chunk chunk, NBTTagCompound nbt) {
|
||||
short[] data = null;
|
||||
if (nbt.hasKey("Biomes16", 7)) {
|
||||
data = byteToShortArray(nbt.getByteArray("Biomes16"));
|
||||
} else if (nbt.hasKey("Biomes", 7)) {
|
||||
data = oldBiomeByteToNewShortArray(nbt.getByteArray("Biomes"));
|
||||
}
|
||||
if (data != null) {
|
||||
((IChunkMixin)chunk).setBiomeShortArray(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,32 +1,22 @@
|
||||
package com.falsepattern.endlessids;
|
||||
|
||||
import java.io.File;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
import com.falsepattern.lib.config.Config;
|
||||
|
||||
@Config(modid = Tags.MODID)
|
||||
public class IEConfig {
|
||||
static Configuration config;
|
||||
public static boolean catchUnregisteredBlocks;
|
||||
public static boolean removeInvalidBlocks;
|
||||
public static boolean extendDataWatcher;
|
||||
|
||||
public static void init(final File file) {
|
||||
File newFile;
|
||||
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 {
|
||||
IEConfig.catchUnregisteredBlocks = false;
|
||||
IEConfig.removeInvalidBlocks = false;
|
||||
IEConfig.extendDataWatcher = false;
|
||||
}
|
||||
public static boolean catchUnregisteredBlocks = false;
|
||||
|
||||
@Config.Comment("Remove invalid (corrupted) blocks from the game.")
|
||||
public static boolean removeInvalidBlocks = false;
|
||||
|
||||
@Config.Comment("Extend DataWatcher IDs. Vanilla limit is 31, new limit is 127.")
|
||||
public static boolean 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;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Map;
|
||||
|
||||
import com.falsepattern.endlessids.asm.IETransformer;
|
||||
import com.falsepattern.lib.config.ConfigException;
|
||||
import com.falsepattern.lib.config.ConfigurationManager;
|
||||
import cpw.mods.fml.relauncher.IFMLLoadingPlugin;
|
||||
|
||||
@IFMLLoadingPlugin.MCVersion("1.7.10")
|
||||
@IFMLLoadingPlugin.TransformerExclusions({ "com.falsepattern.endlessids.asm" })
|
||||
import static cpw.mods.fml.relauncher.IFMLLoadingPlugin.*;
|
||||
|
||||
@MCVersion("1.7.10")
|
||||
@Name(Tags.MODID)
|
||||
@TransformerExclusions({ "com.falsepattern.endlessids.asm" })
|
||||
@DependsOn("falsepatternlib")
|
||||
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() {
|
||||
super();
|
||||
}
|
||||
@@ -27,7 +39,6 @@ public class IEPlugin implements IFMLLoadingPlugin
|
||||
}
|
||||
|
||||
public void injectData(final Map<String, Object> data) {
|
||||
IEConfig.init((File) data.get("coremodLocation"));
|
||||
IETransformer.isObfuscated = (Boolean) data.get("runtimeDeobfuscationEnabled");
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,17 @@
|
||||
package com.falsepattern.endlessids.constants;
|
||||
|
||||
import com.falsepattern.endlessids.IEConfig;
|
||||
|
||||
public class ExtendedConstants {
|
||||
//Tunables
|
||||
public static final int bitsPerID = 24;
|
||||
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 bitsPerBiome = 16;
|
||||
|
||||
//IDs
|
||||
//BlockItemIDs
|
||||
public static final int nibblesPerID = bitsPerID / 4;
|
||||
public static final int nibblesPerMetadata = bitsPerMetadata / 4;
|
||||
|
||||
@@ -22,11 +25,19 @@ public class ExtendedConstants {
|
||||
public static final int bitsPerBlock = 8 + bitsPerID + bitsPerMetadata;
|
||||
public static final int nibblesPerBlock = bitsPerBlock / 4;
|
||||
public static final int nibblesPerEBS = nibblesPerBlock * 16 * 16 * 16;
|
||||
public static final int bytesPerEBS = nibblesPerEBS / 2;
|
||||
public static final int bytesPerChunk = 256 + bytesPerEBS * 16;
|
||||
public static final int bytesPerEBS = (nibblesPerEBS + 1) / 2;
|
||||
|
||||
//BiomeIDs
|
||||
public static final int biomeIDCount = 1 << bitsPerBiome;
|
||||
public static final int biomeIDMask = biomeIDCount - 1;
|
||||
public static final int biomeIDNull = biomeIDMask;
|
||||
public static final int bytesPerBiome = (bitsPerBiome + 7) / 8;
|
||||
|
||||
//DataWatcher
|
||||
public static final int watchableCount = 1 << watchableBits;
|
||||
public static final int maxWatchableID = watchableCount - 1;
|
||||
public static final int watchableMask = (0x7 << watchableBits) | maxWatchableID;
|
||||
|
||||
//Chunk
|
||||
public static final int bytesPerChunk = bytesPerBiome * 256 + bytesPerEBS * 16;
|
||||
}
|
||||
@@ -7,8 +7,9 @@ public class VanillaConstants {
|
||||
public static final int countCorrectionBits = 0;
|
||||
|
||||
public static final int watchableBits = 5;
|
||||
public static final int bitsPerBiome = 8;
|
||||
|
||||
//IDs
|
||||
//BlockItemIDs
|
||||
public static final int nibblesPerID = bitsPerID / 4;
|
||||
public static final int nibblesPerMetadata = bitsPerMetadata / 4;
|
||||
|
||||
@@ -22,11 +23,19 @@ public class VanillaConstants {
|
||||
public static final int bitsPerBlock = 8 + bitsPerID + bitsPerMetadata;
|
||||
public static final int nibblesPerBlock = bitsPerBlock / 4;
|
||||
public static final int nibblesPerEBS = nibblesPerBlock * 16 * 16 * 16;
|
||||
public static final int bytesPerEBS = nibblesPerEBS / 2;
|
||||
public static final int bytesPerChunk = 256 + bytesPerEBS * 16;
|
||||
public static final int bytesPerEBS = (nibblesPerEBS + 1) / 2;
|
||||
|
||||
//BiomeIDs
|
||||
public static final int biomeIDCount = 1 << bitsPerBiome;
|
||||
public static final int biomeIDMask = biomeIDCount - 1;
|
||||
public static final int biomeIDNull = biomeIDMask;
|
||||
public static final int bytesPerBiome = (bitsPerBiome + 7) / 8;
|
||||
|
||||
//DataWatcher
|
||||
public static final int watchableCount = 1 << watchableBits;
|
||||
public static final int maxWatchableID = watchableCount - 1;
|
||||
public static final int watchableMask = (0x7 << watchableBits) | maxWatchableID;
|
||||
|
||||
//Chunk
|
||||
public static final int bytesPerChunk = bytesPerBiome * 256 + bytesPerEBS * 16;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.falsepattern.endlessids.mixin.helpers;
|
||||
|
||||
import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
|
||||
|
||||
public interface IChunkMixin {
|
||||
short[] getBiomeShortArray();
|
||||
void setBiomeShortArray(short[] data);
|
||||
}
|
||||
+1
-1
@@ -101,7 +101,7 @@ public abstract class ChunkMixin {
|
||||
}
|
||||
|
||||
if (var4) {
|
||||
System.arraycopy(var1, var16, this.blockBiomeArray, 0, this.blockBiomeArray.length);
|
||||
var16 += Hooks.readBiomeArrayFromPacket((Chunk)(Object)this, var1, var16);
|
||||
}
|
||||
|
||||
for(var8 = 0; var8 < this.storageArrays.length; ++var8) {
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.falsepattern.endlessids.mixin.mixins.common.vanilla.networking;
|
||||
package com.falsepattern.endlessids.mixin.mixins.client.vanilla;
|
||||
|
||||
import com.falsepattern.endlessids.constants.ExtendedConstants;
|
||||
import com.falsepattern.endlessids.constants.VanillaConstants;
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package com.falsepattern.endlessids.mixin.mixins.common.vanilla.misc;
|
||||
|
||||
import com.falsepattern.endlessids.constants.ExtendedConstants;
|
||||
import com.falsepattern.endlessids.constants.VanillaConstants;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.Constant;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyConstant;
|
||||
|
||||
@Mixin(BiomeGenBase.class)
|
||||
public abstract class BiomeGenBaseMixin {
|
||||
@ModifyConstant(method = "<clinit>",
|
||||
constant = @Constant(intValue = VanillaConstants.biomeIDCount))
|
||||
private static int extendBiomeList(int constant) {
|
||||
return ExtendedConstants.biomeIDCount;
|
||||
}
|
||||
}
|
||||
+10
@@ -3,8 +3,10 @@ package com.falsepattern.endlessids.mixin.mixins.common.vanilla.networking;
|
||||
import com.falsepattern.endlessids.Hooks;
|
||||
import com.falsepattern.endlessids.constants.ExtendedConstants;
|
||||
import com.falsepattern.endlessids.constants.VanillaConstants;
|
||||
import com.falsepattern.endlessids.mixin.helpers.IChunkMixin;
|
||||
import com.falsepattern.endlessids.mixin.helpers.IExtendedBlockStorageMixin;
|
||||
import net.minecraft.network.play.server.S21PacketChunkData;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@@ -36,4 +38,12 @@ public abstract class S21PacketChunkDataMixin {
|
||||
private static byte[] hookGetBlockData(ExtendedBlockStorage instance) {
|
||||
return Hooks.getBlockData((IExtendedBlockStorageMixin) instance);
|
||||
}
|
||||
|
||||
@Redirect(method = "func_149269_a",
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/chunk/Chunk;getBiomeArray()[B"),
|
||||
require = 1)
|
||||
private static byte[] getBiomesArrayShort(Chunk instance) {
|
||||
return Hooks.shortToByteArray(((IChunkMixin)instance).getBiomeShortArray());
|
||||
}
|
||||
}
|
||||
+9
-3
@@ -9,11 +9,17 @@ import org.spongepowered.asm.mixin.injection.ModifyConstant;
|
||||
|
||||
@Mixin(S26PacketMapChunkBulk.class)
|
||||
public abstract class S26PacketMapChunkBulkMixin {
|
||||
//TODO magic number
|
||||
@ModifyConstant(method = "readPacketData",
|
||||
constant = @Constant(intValue = VanillaConstants.bytesPerIDPlusMetadata * 0x1000),
|
||||
constant = @Constant(intValue = VanillaConstants.bytesPerIDPlusMetadata * 16 * 16 * 16),
|
||||
require = 1)
|
||||
private int extend1(int constant) {
|
||||
return ExtendedConstants.bytesPerIDPlusMetadata * 0x1000;
|
||||
return ExtendedConstants.bytesPerIDPlusMetadata * 16 * 16 * 16;
|
||||
}
|
||||
|
||||
@ModifyConstant(method = "readPacketData",
|
||||
constant = @Constant(intValue = VanillaConstants.bytesPerBiome * 16 * 16),
|
||||
require = 1)
|
||||
private int extend2(int contant) {
|
||||
return ExtendedConstants.bytesPerBiome * 16 * 16;
|
||||
}
|
||||
}
|
||||
+2
-5
@@ -63,7 +63,7 @@ public abstract class AnvilChunkLoaderMixin {
|
||||
}
|
||||
|
||||
p_75820_3_.setTag("Sections", var5);
|
||||
p_75820_3_.setByteArray("Biomes", p_75820_1_.getBiomeArray());
|
||||
Hooks.writeChunkBiomeArrayToNbt(p_75820_1_, p_75820_3_);
|
||||
p_75820_1_.hasEntities = false;
|
||||
NBTTagList var21 = new NBTTagList();
|
||||
|
||||
@@ -150,10 +150,7 @@ public abstract class AnvilChunkLoaderMixin {
|
||||
}
|
||||
|
||||
var5.setStorageArrays(var8);
|
||||
if (p_75823_2_.hasKey("Biomes", 7)) {
|
||||
var5.setBiomeArray(p_75823_2_.getByteArray("Biomes"));
|
||||
}
|
||||
|
||||
Hooks.readChunkBiomeArrayFromNbt(var5, p_75823_2_);
|
||||
return var5;
|
||||
}
|
||||
}
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
package com.falsepattern.endlessids.mixin.mixins.common.vanilla.storage;
|
||||
|
||||
import com.falsepattern.endlessids.EndlessIDs;
|
||||
import com.falsepattern.endlessids.Tags;
|
||||
import com.falsepattern.endlessids.constants.ExtendedConstants;
|
||||
import com.falsepattern.endlessids.mixin.helpers.IChunkMixin;
|
||||
import lombok.val;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
import net.minecraft.world.biome.WorldChunkManager;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@Mixin(Chunk.class)
|
||||
public abstract class ChunkMixin implements IChunkMixin {
|
||||
@Shadow private byte[] blockBiomeArray;
|
||||
@Shadow @Final public int xPosition;
|
||||
@Shadow @Final public int zPosition;
|
||||
private short[] blockBiomeShortArray;
|
||||
|
||||
@Inject(method = "<init>(Lnet/minecraft/world/World;II)V",
|
||||
at = @At(value = "RETURN"),
|
||||
require = 1)
|
||||
private void initShortArray(World p_i1995_1_, int p_i1995_2_, int p_i1995_3_, CallbackInfo ci) {
|
||||
blockBiomeArray = null;
|
||||
blockBiomeShortArray = new short[16 * 16];
|
||||
Arrays.fill(blockBiomeShortArray, (short)-1);
|
||||
}
|
||||
|
||||
private void emergencyCrash() {
|
||||
val crashMSG = "A mod that is incompatible with " + Tags.MODNAME + " has tried to access the biome array of a" +
|
||||
" chunk like in vanilla! Crashing in fear of potential world corruption!\n" +
|
||||
"Please report this issue on https://github.com/FalsePattern/EndlessIDs ASAP!";
|
||||
EndlessIDs.LOG.fatal(crashMSG);
|
||||
throw new UnsupportedOperationException(crashMSG);
|
||||
}
|
||||
|
||||
@Inject(method = "setBiomeArray",
|
||||
at = @At(value = "HEAD"),
|
||||
require = 1)
|
||||
private void crashSetBiomeArray(byte[] p_76616_1_, CallbackInfo ci) {
|
||||
emergencyCrash();
|
||||
}
|
||||
|
||||
@Inject(method = "getBiomeArray",
|
||||
at = @At(value = "HEAD"),
|
||||
require = 1)
|
||||
private void crashGetBiomeArray(CallbackInfoReturnable<byte[]> cir) {
|
||||
emergencyCrash();
|
||||
}
|
||||
|
||||
/**
|
||||
* @author FalsePattern
|
||||
* @reason Direct port from dumped code
|
||||
*/
|
||||
@Overwrite
|
||||
public BiomeGenBase getBiomeGenForWorldCoords(int x, int z, WorldChunkManager manager) {
|
||||
int id = this.blockBiomeShortArray[z << 4 | x] & ExtendedConstants.biomeIDMask;
|
||||
if (id == ExtendedConstants.biomeIDNull) {
|
||||
BiomeGenBase gen = manager.getBiomeGenAt((this.xPosition << 4) + x, (this.zPosition << 4) + z);
|
||||
id = gen.biomeID;
|
||||
this.blockBiomeShortArray[z << 4 | x] = (short) (id & ExtendedConstants.biomeIDMask);
|
||||
}
|
||||
|
||||
return BiomeGenBase.getBiome(id) == null ? BiomeGenBase.plains : BiomeGenBase.getBiome(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public short[] getBiomeShortArray() {
|
||||
return blockBiomeShortArray;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBiomeShortArray(short[] data) {
|
||||
blockBiomeShortArray = data;
|
||||
}
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
package com.falsepattern.endlessids.mixin.mixins.common.vanilla.worldgen;
|
||||
|
||||
import com.falsepattern.endlessids.mixin.helpers.IChunkMixin;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.gen.ChunkProviderEnd;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Random;
|
||||
|
||||
@Mixin(ChunkProviderEnd.class)
|
||||
public abstract class ChunkProviderEndMixin {
|
||||
|
||||
@Shadow private Random endRNG;
|
||||
|
||||
@Shadow private BiomeGenBase[] biomesForGeneration;
|
||||
|
||||
@Shadow private World endWorld;
|
||||
|
||||
@Shadow public abstract void func_147420_a(int p_147420_1_, int p_147420_2_, Block[] p_147420_3_, BiomeGenBase[] p_147420_4_);
|
||||
|
||||
@Shadow public abstract void replaceBiomeBlocks(int p_147421_1_, int p_147421_2_, Block[] p_147421_3_, BiomeGenBase[] p_147421_4_, byte[] meta);
|
||||
|
||||
/**
|
||||
* @author FalsePattern
|
||||
* @reason Direct port from decompiled code
|
||||
*/
|
||||
@Overwrite
|
||||
public Chunk provideChunk(int x, int z) {
|
||||
this.endRNG.setSeed((long)x * 341873128712L + (long)z * 132897987541L);
|
||||
Block[] blocks = new Block[32768];
|
||||
byte[] metadatas = new byte[blocks.length];
|
||||
this.biomesForGeneration = this.endWorld.getWorldChunkManager().loadBlockGeneratorData(this.biomesForGeneration, x * 16, z * 16, 16, 16);
|
||||
this.func_147420_a(x, z, blocks, this.biomesForGeneration);
|
||||
this.replaceBiomeBlocks(x, z, blocks, this.biomesForGeneration, metadatas);
|
||||
Chunk chunk = new Chunk(this.endWorld, blocks, metadatas, x, z);
|
||||
short[] biomes = ((IChunkMixin)chunk).getBiomeShortArray();
|
||||
|
||||
for(int i = 0; i < biomes.length; ++i) {
|
||||
biomes[i] = (short)this.biomesForGeneration[i].biomeID;
|
||||
}
|
||||
|
||||
chunk.generateSkylightMap();
|
||||
return chunk;
|
||||
}
|
||||
}
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
package com.falsepattern.endlessids.mixin.mixins.common.vanilla.worldgen;
|
||||
|
||||
import com.falsepattern.endlessids.mixin.helpers.IChunkMixin;
|
||||
import com.falsepattern.endlessids.mixin.helpers.IExtendedBlockStorageMixin;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.chunk.IChunkProvider;
|
||||
import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
|
||||
import net.minecraft.world.gen.ChunkProviderFlat;
|
||||
import net.minecraft.world.gen.MapGenBase;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
@Mixin(ChunkProviderFlat.class)
|
||||
public abstract class ChunkProviderFlatMixin implements IChunkProvider {
|
||||
@Shadow private World worldObj;
|
||||
|
||||
@Shadow @Final private Block[] cachedBlockIDs;
|
||||
|
||||
@Shadow @Final private byte[] cachedBlockMetadata;
|
||||
|
||||
@Shadow @Final private List structureGenerators;
|
||||
|
||||
/**
|
||||
* @author FalsePattern
|
||||
* @reason Direct port from dumped code
|
||||
*/
|
||||
@Overwrite
|
||||
public Chunk provideChunk(int x, int z) {
|
||||
Chunk chunk = new Chunk(this.worldObj, x, z);
|
||||
|
||||
for(int Y = 0; Y < this.cachedBlockIDs.length; ++Y) {
|
||||
Block block = this.cachedBlockIDs[Y];
|
||||
if (block != null) {
|
||||
int ebsID = Y >> 4;
|
||||
ExtendedBlockStorage ebs = chunk.getBlockStorageArray()[ebsID];
|
||||
if (ebs == null) {
|
||||
ebs = new ExtendedBlockStorage(Y, !this.worldObj.provider.hasNoSky);
|
||||
chunk.getBlockStorageArray()[ebsID] = ebs;
|
||||
}
|
||||
|
||||
for(int X = 0; X < 16; ++X) {
|
||||
for(int Z = 0; Z < 16; ++Z) {
|
||||
ebs.func_150818_a(X, Y & 15, Z, block);
|
||||
ebs.setExtBlockMetadata(X, Y & 15, Z, this.cachedBlockMetadata[Y]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
chunk.generateSkylightMap();
|
||||
BiomeGenBase[] bgb = this.worldObj.getWorldChunkManager().loadBlockGeneratorData(null, x * 16, z * 16, 16, 16);
|
||||
short[] biomeArray = ((IChunkMixin)chunk).getBiomeShortArray();
|
||||
|
||||
for(int i = 0; i < biomeArray.length; ++i) {
|
||||
biomeArray[i] = (short)bgb[i].biomeID;
|
||||
}
|
||||
|
||||
for (Object o : this.structureGenerators) {
|
||||
MapGenBase structureGenerator = (MapGenBase) o;
|
||||
structureGenerator.func_151539_a(this, this.worldObj, x, z, null);
|
||||
}
|
||||
|
||||
chunk.generateSkylightMap();
|
||||
return chunk;
|
||||
}
|
||||
|
||||
}
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
package com.falsepattern.endlessids.mixin.mixins.common.vanilla.worldgen;
|
||||
|
||||
import com.falsepattern.endlessids.mixin.helpers.IChunkMixin;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.chunk.IChunkProvider;
|
||||
import net.minecraft.world.gen.ChunkProviderGenerate;
|
||||
import net.minecraft.world.gen.MapGenBase;
|
||||
import net.minecraft.world.gen.structure.MapGenMineshaft;
|
||||
import net.minecraft.world.gen.structure.MapGenScatteredFeature;
|
||||
import net.minecraft.world.gen.structure.MapGenStronghold;
|
||||
import net.minecraft.world.gen.structure.MapGenVillage;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
@Mixin(ChunkProviderGenerate.class)
|
||||
public abstract class ChunkProviderGenerateMixin implements IChunkProvider {
|
||||
@Shadow public abstract void func_147424_a(int p_147424_1_, int p_147424_2_, Block[] p_147424_3_);
|
||||
|
||||
@Shadow private Random rand;
|
||||
|
||||
@Shadow private BiomeGenBase[] biomesForGeneration;
|
||||
|
||||
@Shadow private World worldObj;
|
||||
|
||||
@Shadow public abstract void replaceBlocksForBiome(int p_147422_1_, int p_147422_2_, Block[] p_147422_3_, byte[] p_147422_4_, BiomeGenBase[] p_147422_5_);
|
||||
|
||||
@Shadow private MapGenBase caveGenerator;
|
||||
|
||||
@Shadow private MapGenBase ravineGenerator;
|
||||
|
||||
@Shadow @Final private boolean mapFeaturesEnabled;
|
||||
|
||||
@Shadow private MapGenMineshaft mineshaftGenerator;
|
||||
|
||||
@Shadow private MapGenVillage villageGenerator;
|
||||
|
||||
@Shadow private MapGenStronghold strongholdGenerator;
|
||||
|
||||
@Shadow private MapGenScatteredFeature scatteredFeatureGenerator;
|
||||
|
||||
/**
|
||||
* @author FalsePattern
|
||||
* @reason Direct port from dumped code
|
||||
*/
|
||||
@Overwrite
|
||||
public Chunk provideChunk(int x, int z) {
|
||||
this.rand.setSeed((long)x * 341873128712L + (long)z * 132897987541L);
|
||||
Block[] blocks = new Block[65536];
|
||||
byte[] metadata = new byte[65536];
|
||||
this.func_147424_a(x, z, blocks);
|
||||
this.biomesForGeneration = this.worldObj.getWorldChunkManager().loadBlockGeneratorData(this.biomesForGeneration, x * 16, z * 16, 16, 16);
|
||||
this.replaceBlocksForBiome(x, z, blocks, metadata, this.biomesForGeneration);
|
||||
this.caveGenerator.func_151539_a(this, this.worldObj, x, z, blocks);
|
||||
this.ravineGenerator.func_151539_a(this, this.worldObj, x, z, blocks);
|
||||
if (this.mapFeaturesEnabled) {
|
||||
this.mineshaftGenerator.func_151539_a(this, this.worldObj, x, z, blocks);
|
||||
this.villageGenerator.func_151539_a(this, this.worldObj, x, z, blocks);
|
||||
this.strongholdGenerator.func_151539_a(this, this.worldObj, x, z, blocks);
|
||||
this.scatteredFeatureGenerator.func_151539_a(this, this.worldObj, x, z, blocks);
|
||||
}
|
||||
|
||||
Chunk chunk = new Chunk(this.worldObj, blocks, metadata, x, z);
|
||||
short[] biomes = ((IChunkMixin)chunk).getBiomeShortArray();
|
||||
|
||||
for(int i = 0; i < biomes.length; ++i) {
|
||||
biomes[i] = (short)this.biomesForGeneration[i].biomeID;
|
||||
}
|
||||
|
||||
chunk.generateSkylightMap();
|
||||
return chunk;
|
||||
}
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
package com.falsepattern.endlessids.mixin.mixins.common.vanilla.worldgen;
|
||||
|
||||
import com.falsepattern.endlessids.mixin.helpers.IChunkMixin;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.chunk.IChunkProvider;
|
||||
import net.minecraft.world.gen.ChunkProviderHell;
|
||||
import net.minecraft.world.gen.MapGenBase;
|
||||
import net.minecraft.world.gen.structure.MapGenNetherBridge;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
@Mixin(ChunkProviderHell.class)
|
||||
public abstract class ChunkProviderHellMixin implements IChunkProvider {
|
||||
|
||||
@Shadow private Random hellRNG;
|
||||
|
||||
@Shadow private World worldObj;
|
||||
|
||||
@Shadow public abstract void func_147419_a(int p_147419_1_, int p_147419_2_, Block[] p_147419_3_);
|
||||
|
||||
@Shadow public abstract void replaceBiomeBlocks(int p_147418_1_, int p_147418_2_, Block[] p_147418_3_, byte[] meta, BiomeGenBase[] biomes);
|
||||
|
||||
@Shadow private MapGenBase netherCaveGenerator;
|
||||
|
||||
@Shadow public MapGenNetherBridge genNetherBridge;
|
||||
|
||||
/**
|
||||
* @author FalsePattern
|
||||
* @reason Direct port from dumped code
|
||||
*/
|
||||
@Overwrite
|
||||
public Chunk provideChunk(int x, int z) {
|
||||
this.hellRNG.setSeed((long)x * 341873128712L + (long)z * 132897987541L);
|
||||
Block[] blocks = new Block[32768];
|
||||
byte[] metadata = new byte[blocks.length];
|
||||
BiomeGenBase[] bgb = this.worldObj.getWorldChunkManager().loadBlockGeneratorData(null, x * 16, z * 16, 16, 16);
|
||||
this.func_147419_a(x, z, blocks);
|
||||
this.replaceBiomeBlocks(x, z, blocks, metadata, bgb);
|
||||
this.netherCaveGenerator.func_151539_a(this, this.worldObj, x, z, blocks);
|
||||
this.genNetherBridge.func_151539_a(this, this.worldObj, x, z, blocks);
|
||||
Chunk chunk = new Chunk(this.worldObj, blocks, metadata, x, z);
|
||||
short[] biomes = ((IChunkMixin)chunk).getBiomeShortArray();
|
||||
|
||||
for(int i = 0; i < biomes.length; ++i) {
|
||||
biomes[i] = (short)bgb[i].biomeID;
|
||||
}
|
||||
|
||||
chunk.resetRelightChecks();
|
||||
return chunk;
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package com.falsepattern.endlessids.mixin.mixins.common.vanilla.worldgen;
|
||||
|
||||
import com.falsepattern.endlessids.constants.ExtendedConstants;
|
||||
import com.falsepattern.endlessids.constants.VanillaConstants;
|
||||
import net.minecraft.world.gen.layer.GenLayerRiverMix;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.Constant;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyConstant;
|
||||
|
||||
@Mixin(GenLayerRiverMix.class)
|
||||
public abstract class GenLayerRiverMixMixin {
|
||||
@ModifyConstant(method = "getInts",
|
||||
constant = @Constant(intValue = VanillaConstants.biomeIDMask),
|
||||
require = 1)
|
||||
private int extendTheID(int constant) {
|
||||
return ExtendedConstants.biomeIDMask;
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package com.falsepattern.endlessids.mixin.mixins.common.vanilla.worldgen;
|
||||
|
||||
import com.falsepattern.endlessids.constants.ExtendedConstants;
|
||||
import com.falsepattern.endlessids.constants.VanillaConstants;
|
||||
import net.minecraft.world.gen.layer.GenLayerRiverMix;
|
||||
import net.minecraft.world.gen.layer.GenLayerVoronoiZoom;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.Constant;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyConstant;
|
||||
|
||||
@Mixin(GenLayerVoronoiZoom.class)
|
||||
public abstract class GenLayerVoronoiZoomMixin {
|
||||
@ModifyConstant(method = "getInts",
|
||||
constant = @Constant(intValue = VanillaConstants.biomeIDMask),
|
||||
require = 2)
|
||||
private int extendTheID(int constant) {
|
||||
return ExtendedConstants.biomeIDMask;
|
||||
}
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
package com.falsepattern.endlessids.mixin.plugin;
|
||||
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.ModClassLoader;
|
||||
import net.minecraft.launchwrapper.LaunchClassLoader;
|
||||
import sun.misc.URLClassPath;
|
||||
|
||||
import java.io.File;
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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,127 +1,80 @@
|
||||
package com.falsepattern.endlessids.mixin.plugin;
|
||||
|
||||
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.Set;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public enum Mixin {
|
||||
//BEGIN Minecraft
|
||||
//BEGIN common
|
||||
//BEGIN storage
|
||||
AnvilChunkLoaderMixin(builder(Side.COMMON).mixin("vanilla.storage.AnvilChunkLoaderMixin")),
|
||||
ExtendedBlockStorageMixin(builder(Side.COMMON).mixin("vanilla.storage.ExtendedBlockStorageMixin")),
|
||||
ItemStackMixin(builder(Side.COMMON).mixin("vanilla.storage.ItemStackMixin")),
|
||||
//END storage
|
||||
//BEGIN networking
|
||||
PacketBufferMixin(builder(Side.COMMON).mixin("vanilla.networking.PacketBufferMixin")),
|
||||
PlayerControllerMPMixin(builder(Side.COMMON).mixin("vanilla.networking.PlayerControllerMPMixin")),
|
||||
S21PacketChunkDataMixin(builder(Side.COMMON).mixin("vanilla.networking.S21PacketChunkDataMixin")),
|
||||
S22PacketMultiBlockChangeMixin(builder(Side.COMMON).mixin("vanilla.networking.S22PacketMultiBlockChangeMixin")),
|
||||
S24PacketBlockActionMixin(builder(Side.COMMON).mixin("vanilla.networking.S24PacketBlockActionMixin")),
|
||||
S26PacketMapChunkBulkMixin(builder(Side.COMMON).mixin("vanilla.networking.S26PacketMapChunkBulkMixin")),
|
||||
//END networking
|
||||
//BEGIN misc
|
||||
BlockFireMixin(builder(Side.COMMON).mixin("vanilla.misc.BlockFireMixin")),
|
||||
DataWatcherMixin(builder(Side.COMMON).condition(() -> IEConfig.extendDataWatcher).mixin("vanilla.misc.DataWatcherMixin")),
|
||||
ItemInWorldManagerMixin(builder(Side.COMMON).mixin("vanilla.misc.ItemInWorldManagerMixin")),
|
||||
StatListMixin(builder(Side.COMMON).mixin("vanilla.misc.StatListMixin")),
|
||||
WorldMixin(builder(Side.COMMON).mixin("vanilla.misc.WorldMixin")),
|
||||
//END misc
|
||||
//END common
|
||||
//BEGIN client
|
||||
ChunkMixin(builder(Side.CLIENT).mixin("vanilla.ChunkMixin")),
|
||||
NetHandlerPlayClientMixin(builder(Side.CLIENT).mixin("vanilla.NetHandlerPlayClientMixin")),
|
||||
RenderGlobalMixin(builder(Side.CLIENT).mixin("vanilla.RenderGlobalMixin")),
|
||||
//END client
|
||||
//END Minecraft
|
||||
//BEGIN UBC->common
|
||||
OreUBifierMixin(builder(Side.COMMON).target(TargetedMod.UBC).mixin("ubc.OreUBifierMixin")),
|
||||
BiomeUndergroundDecoratorMixin(builder(Side.COMMON).target(TargetedMod.UBC).mixin("ubc.BiomeUndergroundDecoratorMixin")),
|
||||
//END UBC->common
|
||||
//BEGIN CoFHLib->common
|
||||
CofhBlockHelperMixin(builder(Side.COMMON).target(TargetedMod.COFHLIB).mixin("cofhlib.BlockHelperMixin")),
|
||||
//END CoFHLib->common
|
||||
//BEGIN DragonAPI->common
|
||||
BlockPropertiesMixin(builder(Side.COMMON).target(TargetedMod.DRAGONAPI).mixin("dragonapi.BlockPropertiesMixin")),
|
||||
//END DragonAPI->common
|
||||
//BEGIN MFQM->common
|
||||
MFQMMixin(builder(Side.COMMON).target(TargetedMod.MFQM).mixin("mfqm.MFQMMixin")),
|
||||
MFQMDataWatcherMixin(builder(Side.COMMON).target(TargetedMod.MFQM).condition(() -> IEConfig.extendDataWatcher).mixin("mfqm.MFQMDataWatcherMixin")),
|
||||
//END MFQM->common
|
||||
//BEGIN WorldEdit->common
|
||||
BaseBlockMixin(builder(Side.COMMON).target(TargetedMod.WORLDEDIT).mixin("worldedit.BaseBlockMixin")),
|
||||
//END WorldEdit->common
|
||||
import static com.falsepattern.lib.mixin.IMixin.PredicateHelpers.*;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
public enum Mixin implements IMixin {
|
||||
//region Minecraft
|
||||
//region common
|
||||
//region storage
|
||||
AnvilChunkLoaderMixin(Side.COMMON, always(), "vanilla.storage.AnvilChunkLoaderMixin"),
|
||||
ChunkMixin(Side.COMMON, always(), "vanilla.storage.ChunkMixin"),
|
||||
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
|
||||
BiomeGenBaseMixin(Side.COMMON, always(), "vanilla.misc.BiomeGenBaseMixin"),
|
||||
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
|
||||
//region worldgen
|
||||
ChunkProviderEndMixin(Side.COMMON, always(), "vanilla.worldgen.ChunkProviderEndMixin"),
|
||||
ChunkProviderFlatMixin(Side.COMMON, always(), "vanilla.worldgen.ChunkProviderFlatMixin"),
|
||||
ChunkProviderGenerateMixin(Side.COMMON, always(), "vanilla.worldgen.ChunkProviderGenerateMixin"),
|
||||
ChunkProviderHellMixin(Side.COMMON, always(), "vanilla.worldgen.ChunkProviderHellMixin"),
|
||||
GenLayerRiverMixMixin(Side.COMMON, always(), "vanilla.worldgen.GenLayerRiverMixMixin"),
|
||||
GenLayerVoronoiZoomMixin(Side.COMMON, always(), "vanilla.worldgen.GenLayerVoronoiZoomMixin"),
|
||||
//endregion worldgen
|
||||
//endregion common
|
||||
//region client
|
||||
ChunkMixinClient(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
|
||||
;
|
||||
|
||||
public final String mixin;
|
||||
public final Set<TargetedMod> targetedMods;
|
||||
public final Set<TargetedMod> avoidedMods;
|
||||
public final Set<Supplier<Boolean>> allowConditions;
|
||||
@Getter
|
||||
private final Side side;
|
||||
|
||||
Mixin(Builder builder) {
|
||||
this.mixin = builder.mixin;
|
||||
this.targetedMods = builder.targetedMods;
|
||||
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
|
||||
}
|
||||
@Getter
|
||||
private final Predicate<List<ITargetedMod>> filter;
|
||||
@Getter
|
||||
private final String mixin;
|
||||
}
|
||||
|
||||
@@ -1,124 +1,23 @@
|
||||
package com.falsepattern.endlessids.mixin.plugin;
|
||||
|
||||
import com.falsepattern.endlessids.Tags;
|
||||
import lombok.val;
|
||||
import net.minecraft.launchwrapper.Launch;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import com.falsepattern.lib.mixin.IMixin;
|
||||
import com.falsepattern.lib.mixin.IMixinPlugin;
|
||||
import com.falsepattern.lib.mixin.ITargetedMod;
|
||||
import lombok.Getter;
|
||||
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;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
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();
|
||||
public class MixinPlugin implements IMixinPlugin {
|
||||
@Getter
|
||||
private final Logger logger = IMixinPlugin.createLogger(Tags.MODNAME);
|
||||
|
||||
@Override
|
||||
public void onLoad(String mixinPackage) {
|
||||
|
||||
public IMixin[] getMixinEnumValues() {
|
||||
return Mixin.values();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRefMapperConfig() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@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) {
|
||||
|
||||
public ITargetedMod[] getTargetedModEnumValues() {
|
||||
return TargetedMod.values();
|
||||
}
|
||||
}
|
||||
@@ -1,47 +1,27 @@
|
||||
package com.falsepattern.endlessids.mixin.plugin;
|
||||
|
||||
import com.google.common.io.Files;
|
||||
import lombok.val;
|
||||
import com.falsepattern.lib.mixin.ITargetedMod;
|
||||
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),
|
||||
UBC("Underground Biomes Constructs", "undergroundbiomesconstructs-", "", false),
|
||||
COFHLIB("CoFH Lib", "cofhlib-", "", false),
|
||||
DRAGONAPI("DragonAPI", "dragonapi", "", false),
|
||||
MFQM("More Fun Quicksand Mod", "morefunquicksandmod-", "", false),
|
||||
WORLDEDIT("WorldEdit", "worldedit-", "", false),
|
||||
@RequiredArgsConstructor
|
||||
public enum TargetedMod implements ITargetedMod {
|
||||
|
||||
UBC("Underground Biomes Constructs", false, startsWith("undergroundbiomesconstructs-")),
|
||||
COFHLIB("CoFH Lib", false, startsWith("cofhlib-")),
|
||||
DRAGONAPI("DragonAPI", false, startsWith("dragonapi")),
|
||||
MFQM("More Fun Quicksand Mod", false, startsWith("morefunquicksandmod-")),
|
||||
WORLDEDIT("WorldEdit", false, startsWith("worldedit-")),
|
||||
;
|
||||
|
||||
public final String modName;
|
||||
public final String jarNamePrefixLowercase;
|
||||
public final String jarNameContainsLowercase;
|
||||
|
||||
public final boolean loadInDevelopment;
|
||||
|
||||
TargetedMod(String modName, String jarNamePrefix, String jarNameContains, boolean loadInDevelopment) {
|
||||
this.modName = modName;
|
||||
this.jarNamePrefixLowercase = jarNamePrefix.toLowerCase();
|
||||
this.jarNameContainsLowercase = jarNameContains.toLowerCase();
|
||||
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 + '\'' +
|
||||
'}';
|
||||
}
|
||||
@Getter
|
||||
private final String modName;
|
||||
@Getter
|
||||
private final boolean loadInDevelopment;
|
||||
@Getter
|
||||
private final Predicate<String> condition;
|
||||
}
|
||||
Reference in new issue
Block a user