mirror of
https://github.com/GTMEGA/EndlessIDs.git
synced 2026-11-20 01:49:43 +00:00
port over the block tool fixes
This commit is contained in:
6 files changed
+144
-3
No files matched your search
@@ -1,5 +1,6 @@
|
||||
The code is a rewrite of NotEnoughIDs, created by fewizz and Player,
|
||||
which was released under the MIT license on CurseForge at https://www.curseforge.com/minecraft/mc-mods/notenoughids
|
||||
which was released under the MIT license on CurseForge at
|
||||
https://www.curseforge.com/minecraft/mc-mods/notenoughids
|
||||
|
||||
Original License text of NotEnoughIDs:
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
@@ -18,4 +19,12 @@ 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.
|
||||
THE SOFTWARE.
|
||||
------------------------------------------------------------------------------
|
||||
Some patches have been adapted from the GTNH fork of NotEnoughIDs,
|
||||
its license is as follows:
|
||||
|
||||
GTNH modifications Copyright (c) 2021-2022 The GTNH Team
|
||||
|
||||
This code is licensed LGPL v3.0 or later. Feel free to use our changes,
|
||||
just give back any changes you make to the community as well!
|
||||
@@ -22,6 +22,7 @@ dependencies {
|
||||
annotationProcessor("org.projectlombok:lombok:1.18.32")
|
||||
|
||||
implementation("com.falsepattern:falsepatternlib-mc1.7.10:1.2.4:dev")
|
||||
implementation("it.unimi.dsi:fastutil:8.5.13")
|
||||
|
||||
compileOnly("com.falsepattern:chunkapi-mc1.7.10:0.5.1:api")
|
||||
runtimeOnly("com.falsepattern:chunkapi-mc1.7.10:0.5.1:dev")
|
||||
|
||||
@@ -21,7 +21,7 @@ import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
name = Tags.MODNAME,
|
||||
acceptedMinecraftVersions = "[1.7.10]",
|
||||
dependencies = "required-after:chunkapi@[0.5.0,0.6.0);" +
|
||||
"required-after:falsepatternlib@[1.0.0,);" +
|
||||
"required-after:falsepatternlib@[1.2.0,);" +
|
||||
"after:antiidconflict")
|
||||
public class EndlessIDs {
|
||||
public static final byte[] ZERO_LENGTH_BIOME_ARRAY_PLACEHOLDER = new byte[0];
|
||||
|
||||
+105
@@ -0,0 +1,105 @@
|
||||
package com.falsepattern.endlessids.mixin.mixins.common.blockitem.vanilla;
|
||||
|
||||
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
|
||||
/**
|
||||
* This mixin exists to completely re-work the way that block harvestability is calculated. Forge adds this system
|
||||
* on-top of vanilla, which creates a pre-populated array on each block with the size of the maximum metadata value. For
|
||||
* instance, in vanilla we get a String array, and an int array both of size 16, pre-populated with null and -1,
|
||||
* respectively. This is awful for scalability with adding more possible Blocks, and increasing the metadata to 16-bits
|
||||
* from 4. This uproots the under-workings of that system to use a default and dynamic HashMaps for metadata specific
|
||||
* values, so we only use the memory we need, because most things don't even take advantage of this system, especially
|
||||
* based on block metadatas. The public methods of this system maintain API compatibility, so anything using those
|
||||
* should still function perfectly the same. The only potential breakage is if something were to reflect/ASM/mixin with
|
||||
* the private values/methods we're overwriting.
|
||||
*/
|
||||
@Mixin(Block.class)
|
||||
public abstract class BlockMixin {
|
||||
|
||||
@Unique
|
||||
private String eid$defaultHarvestTool = null;
|
||||
|
||||
@Unique
|
||||
private int eid$defaultHarvestLevel = -1;
|
||||
|
||||
@Unique
|
||||
private final Int2ObjectOpenHashMap<String> eid$harvestToolMap = new Int2ObjectOpenHashMap<>();
|
||||
|
||||
@Unique
|
||||
private final Int2IntOpenHashMap eid$harvestLevelMap = new Int2IntOpenHashMap();
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Shadow(remap = false)
|
||||
private String[] harvestTool = null;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Shadow(remap = false)
|
||||
private int[] harvestLevel = null;
|
||||
|
||||
/**
|
||||
* @author Cleptomania
|
||||
* @reason Support 16-bit metadata without using GBs of memory.
|
||||
*/
|
||||
@Overwrite(remap = false)
|
||||
public void setHarvestLevel(String toolClass, int level) {
|
||||
this.eid$defaultHarvestTool = toolClass;
|
||||
this.eid$defaultHarvestLevel = level;
|
||||
this.eid$harvestToolMap.clear();
|
||||
this.eid$harvestLevelMap.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* @author Cleptomania
|
||||
* @reason Support 16-bit metadata without using GBs of memory.
|
||||
*/
|
||||
@Overwrite(remap = false)
|
||||
public void setHarvestLevel(String toolClass, int level, int metadata) {
|
||||
this.eid$harvestToolMap.put(metadata, toolClass);
|
||||
this.eid$harvestLevelMap.put(metadata, level);
|
||||
}
|
||||
|
||||
/**
|
||||
* @author Cleptomania
|
||||
* @reason Support 16-bit metadata without using GBs of memory.
|
||||
*/
|
||||
@Overwrite(remap = false)
|
||||
public String getHarvestTool(int metadata) {
|
||||
return this.eid$harvestToolMap.getOrDefault(metadata, this.eid$defaultHarvestTool);
|
||||
}
|
||||
|
||||
/**
|
||||
* @author Cleptmania
|
||||
* @reason Support 16-bit metadata without using GBs of memory.
|
||||
*/
|
||||
@Overwrite(remap = false)
|
||||
public int getHarvestLevel(int metadata) {
|
||||
return this.eid$harvestLevelMap.getOrDefault(metadata, this.eid$defaultHarvestLevel);
|
||||
}
|
||||
|
||||
/**
|
||||
* @author Cleptomania
|
||||
* @reason Support 16-bit metadata without using GBs of memory.
|
||||
*/
|
||||
@Overwrite(remap = false)
|
||||
public boolean isToolEffective(String type, int metadata) {
|
||||
Block self = ((Block) (Object) this);
|
||||
if ("pickaxe".equals(type) &&
|
||||
(self == Blocks.redstone_ore || self == Blocks.lit_redstone_ore || self == Blocks.obsidian)) {
|
||||
return false;
|
||||
}
|
||||
String harvestTool = this.getHarvestTool(metadata);
|
||||
if (harvestTool == null) {
|
||||
return false;
|
||||
}
|
||||
return harvestTool.equals(type);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -167,6 +167,7 @@ public enum Mixin implements IMixin {
|
||||
//region blockitem
|
||||
//region vanilla
|
||||
BlockFireMixin(Side.COMMON, condition(() -> GeneralConfig.extendBlockItem), "blockitem.vanilla.BlockFireMixin"),
|
||||
BlockMixin(Side.COMMON, condition(() -> GeneralConfig.extendBlockItem), "blockitem.vanilla.BlockMixin"),
|
||||
ExtendedBlockStorageMixin(Side.COMMON, condition(() -> GeneralConfig.extendBlockItem), "blockitem.vanilla.ExtendedBlockStorageMixin"),
|
||||
ItemInWorldManagerMixin(Side.COMMON, condition(() -> GeneralConfig.extendBlockItem), "blockitem.vanilla.ItemInWorldManagerMixin"),
|
||||
ItemStackMixin(Side.COMMON, condition(() -> GeneralConfig.extendBlockItem), "blockitem.vanilla.ItemStackMixin"),
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"identifier": "falsepatternlib_dependencies",
|
||||
"repositories": [
|
||||
"https://repo1.maven.org/maven2/"
|
||||
],
|
||||
"dependencies": {
|
||||
"always": {
|
||||
"common": [
|
||||
"it.unimi.dsi:fastutil:8.5.13"
|
||||
],
|
||||
"client": [],
|
||||
"server": []
|
||||
},
|
||||
"obf": {
|
||||
"common": [],
|
||||
"client": [],
|
||||
"server": []
|
||||
},
|
||||
"dev": {
|
||||
"common": [],
|
||||
"client": [],
|
||||
"server": []
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user