mirror of
https://github.com/GTMEGA/EndlessIDs.git
synced 2026-11-24 10:34:29 +00:00
Compare commits
11
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c1d8e273fc | ||
|
|
484a9175e7 | ||
|
|
1bb71d9448 | ||
|
|
11ff4a4a6a | ||
|
|
6b3d872fbd | ||
|
|
344b788108 | ||
|
|
b61711280b | ||
|
|
67badb8fcb | ||
|
|
e529ad49cb | ||
|
|
10c19feb0c | ||
|
|
fb0096350c |
No files matched your search
@@ -1,18 +1,23 @@
|
||||
EndlessIDs is the unofficial successor of NotEnoughIDs, with more focus on compatibility, stability, and reaching
|
||||
new limits.
|
||||
|
||||
## REQUIRED MODS
|
||||
- [FalsePatternLib](https://github.com/FalsePattern/FalsePatternLib)
|
||||
- [GasStation](https://github.com/FalsePattern/GasStation)
|
||||
- [ChunkAPI](https://github.com/FalsePattern/ChunkAPI)
|
||||
|
||||
Comparison of the known limits:
|
||||
|
||||
| | Vanilla | NotEnoughIDs | EndlessIDs |
|
||||
|-----------------|----------------------------------------------------|--------------|----------------------------------|
|
||||
| Block IDs | 4,096 | 32,000 | 16,777,216 since 1.3 |
|
||||
| Block Metadata | 16 | 16 | 65,536 since 1.5 |
|
||||
| Item IDs | 32,000 | 32,000 | 16,777,216 since 1.3 |
|
||||
| Biome IDs | 256 | 256 | 65,536 since 1.4 |
|
||||
| Entity IDs | 256 | 256 | 256 right now, extension planned |
|
||||
| Potion IDs | 32 | 32 | 65,536 since 1.5 |
|
||||
| Enchantment IDs | 256 | 256 | 32,768 since 1.5 |
|
||||
| Dimension IDs | Theoretically unlimited, 4,294,967,295 in practice | Same | Same |
|
||||
| | Vanilla | NotEnoughIDs | EndlessIDs |
|
||||
|-----------------|----------------------------------------------------|--------------|----------------------|
|
||||
| Block IDs | 4,096 | 32,000 | 16,777,216 since 1.3 |
|
||||
| Block Metadata | 16 | 16 | 65,536 since 1.5 |
|
||||
| Item IDs | 32,000 | 32,000 | 16,777,216 since 1.3 |
|
||||
| Biome IDs | 256 | 256 | 65,536 since 1.4 |
|
||||
| Entity IDs | 256 | 256 | 32,768 since 1.5 |
|
||||
| Potion IDs | 32 | 32 | 65,536 since 1.5 |
|
||||
| Enchantment IDs | 256 | 256 | 32,768 since 1.5 |
|
||||
| Dimension IDs | Theoretically unlimited, 4,294,967,295 in practice | Same | Same |
|
||||
|
||||
This mod also contains patches for the following mods:
|
||||
|
||||
@@ -70,8 +75,3 @@ Mods not listed here may or may not work.
|
||||
user to this GitHub repo.
|
||||
|
||||
If you find any crashes or incompatibilities, don't hesitate to open an issue.
|
||||
|
||||
## Dependencies
|
||||
- [FalsePatternLib](https://github.com/FalsePattern/FalsePatternLib)
|
||||
- [GasStation](https://github.com/FalsePattern/GasStation)
|
||||
- [ChunkAPI](https://github.com/FalsePattern/ChunkAPI) (since 1.5-alpha0006. Incompatible with ChunkAPI in previous versions.)
|
||||
+6
-6
@@ -16,14 +16,14 @@ def deobfCurse(curseDep) {
|
||||
dependencies {
|
||||
////////////////Our dependencies////////////////
|
||||
|
||||
compileOnly("org.projectlombok:lombok:[1.18, 1.19)") {
|
||||
compileOnly("org.projectlombok:lombok:1.18.28") {
|
||||
transitive = false
|
||||
}
|
||||
annotationProcessor("org.projectlombok:lombok:[1.18, 1.19)")
|
||||
annotationProcessor("org.projectlombok:lombok:1.18.28")
|
||||
|
||||
implementation("com.falsepattern:falsepatternlib-mc1.7.10:0.10.15:dev")
|
||||
implementation("com.falsepattern:falsepatternlib-mc1.7.10:0.12.1:dev")
|
||||
|
||||
implementation("com.falsepattern:chunkapi-mc1.7.10:0.1.1:dev")
|
||||
implementation("com.falsepattern:chunkapi-mc1.7.10:0.3.2:dev")
|
||||
|
||||
////////////////Patched mods////////////////
|
||||
|
||||
@@ -73,8 +73,8 @@ dependencies {
|
||||
//DimDoors 2.2.5-test9
|
||||
compileOnly(deobf("https://github.com/CannibalVox/DimDoors/releases/download/2.2.5-test9/DimensionalDoors-2.2.5-test9.jar"))
|
||||
|
||||
//DragonAPI V31b
|
||||
compileOnly(deobfCurse("dragonapi-235591:3574508"))
|
||||
//DragonAPI V32a
|
||||
compileOnly(deobfCurse("dragonapi-235591:4611379"))
|
||||
|
||||
//Dynamic Surroundings 1.0.6.4
|
||||
compileOnly(deobfCurse("dynamicsurrounding-238891:2642381"))
|
||||
|
||||
@@ -20,7 +20,7 @@ import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
version = Tags.VERSION,
|
||||
name = Tags.MODNAME,
|
||||
acceptedMinecraftVersions = "[1.7.10]",
|
||||
dependencies = "required-after:falsepatternlib@[0.11.0,);required-after:gasstation@[0.5.0,);after:antiidconflict")
|
||||
dependencies = "required-after:chunkapi@[0.3.2,);required-after:falsepatternlib@[0.12.1,);required-after:gasstation@[0.5.0,);after:antiidconflict")
|
||||
public class EndlessIDs {
|
||||
public static final byte[] ZERO_LENGTH_BIOME_ARRAY_PLACEHOLDER = new byte[0];
|
||||
public static final byte[] FAKE_BIOME_ARRAY_PLACEHOLDER = new byte[256];
|
||||
@@ -38,9 +38,38 @@ public class EndlessIDs {
|
||||
|
||||
@Mod.EventHandler
|
||||
public void preInit(FMLPreInitializationEvent e) {
|
||||
LOG.info("---------------------------------------------------------");
|
||||
LOG.info("Current EndlessIDs configuration:");
|
||||
logConfig(" Biome Extension", GeneralConfig.extendBiome);
|
||||
logConfig(" Block/Item Extension", GeneralConfig.extendBlockItem);
|
||||
if (GeneralConfig.extendBlockItem) {
|
||||
logConfig(" Extra Item Bits", GeneralConfig.extraItemIDBits);
|
||||
logConfig(" Extra Block Bits", GeneralConfig.extraBlockIDBits);
|
||||
}
|
||||
logConfig(" DataWatcher Extension", GeneralConfig.extendDataWatcher);
|
||||
logConfig(" Enchantment Extension", GeneralConfig.extendEnchantment);
|
||||
logConfig(" Potion Extension", GeneralConfig.extendPotion);
|
||||
logConfig(" Redstone Extension", GeneralConfig.extendRedstone);
|
||||
if (GeneralConfig.extendRedstone) {
|
||||
LOG.warn(" (Redstone extension is an experimental and dangerous feature, and should NEVER be used in worlds that you worry about getting corrupted!)");
|
||||
logConfig(" Max redstone level", GeneralConfig.maxRedstone);
|
||||
}
|
||||
logConfig(" Registry performance tweak", GeneralConfig.enableRegistryPerformanceTweak);
|
||||
if (GeneralConfig.enableRegistryPerformanceTweak) {
|
||||
LOG.warn(" (This tweak has not gone through proper testing yet, so it might corrupt worlds. USE BACKUPS!)");
|
||||
}
|
||||
LOG.info("---------------------------------------------------------");
|
||||
patchManager.preInit();
|
||||
}
|
||||
|
||||
private static void logConfig(String name, boolean value) {
|
||||
LOG.info(name + (value ? ": ENABLED" : ": disabled"));
|
||||
}
|
||||
|
||||
private static void logConfig(String name, int value) {
|
||||
LOG.info(name + ": " + value);
|
||||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
public void init(FMLInitializationEvent e) {
|
||||
patchManager.init();
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
package com.falsepattern.endlessids.asm;
|
||||
|
||||
import Reika.DragonAPI.Libraries.Java.ReikaJavaLibrary;
|
||||
import com.falsepattern.endlessids.asm.stubpackage.Reika.DragonAPI.ModList;
|
||||
import lombok.SneakyThrows;
|
||||
|
||||
import cpw.mods.fml.common.Loader;
|
||||
|
||||
public class ASMHooks {
|
||||
@SneakyThrows
|
||||
public static void DragonAPIModListConstructorTweak(ModList list) {
|
||||
list.successful = false;
|
||||
DragonAPIModListTryLoad(list);
|
||||
}
|
||||
|
||||
public static boolean DragonAPIModListTryLoad(ModList list) {
|
||||
if (!list.successful) {
|
||||
try {
|
||||
list.condition = Loader.isModLoaded(list.modLabel);
|
||||
list.successful = true;
|
||||
if (list.condition) {
|
||||
ReikaJavaLibrary.pConsole(
|
||||
"DRAGONAPI: " + list + " detected in the MC installation. Adjusting behavior accordingly.");
|
||||
} else {
|
||||
ReikaJavaLibrary.pConsole(
|
||||
"DRAGONAPI: " + list + " not detected in the MC installation. No special action taken.");
|
||||
}
|
||||
if (list.condition) {
|
||||
ReikaJavaLibrary.pConsole("DRAGONAPI: Attempting to load data from " + list);
|
||||
if (list.blockClasses == null) {
|
||||
ReikaJavaLibrary.pConsole("DRAGONAPI: Could not block class for " + list +
|
||||
": Specified class was null. This may not be an error.");
|
||||
}
|
||||
if (list.itemClasses == null) {
|
||||
ReikaJavaLibrary.pConsole("DRAGONAPI: Could not item class for " + list +
|
||||
": Specified class was null. This may not be an error.");
|
||||
}
|
||||
}
|
||||
} catch (NullPointerException e) {
|
||||
list.condition = list.successful = false;
|
||||
}
|
||||
}
|
||||
return list.condition;
|
||||
}
|
||||
|
||||
public static void DragonAPIModListSuppressLogging(Object obj) {
|
||||
}
|
||||
}
|
||||
@@ -1,33 +1,38 @@
|
||||
package com.falsepattern.endlessids.asm;
|
||||
|
||||
import com.falsepattern.endlessids.asm.transformer.ChunkProviderSuperPatcher;
|
||||
import com.falsepattern.endlessids.asm.transformer.DragonAPIModList;
|
||||
import com.falsepattern.endlessids.asm.transformer.FmlRegistry;
|
||||
import com.falsepattern.endlessids.asm.transformer.GameDataAccelerator;
|
||||
import com.falsepattern.endlessids.asm.transformer.SpaceCoreModInfoGenerator;
|
||||
import com.falsepattern.endlessids.config.GeneralConfig;
|
||||
import lombok.val;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.BooleanSupplier;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public enum ClassEdit {
|
||||
ChunkProviderSuperPatcher(new ChunkProviderSuperPatcher(), () -> GeneralConfig.extendBiome),
|
||||
DragonAPIModList(new DragonAPIModList(), () -> true, "Reika.DragonAPI.ModList"),
|
||||
FmlRegistry(new FmlRegistry(),
|
||||
() -> GeneralConfig.extendBlockItem,
|
||||
"cpw.mods.fml.common.registry.GameData",
|
||||
"cpw.mods.fml.common.registry.FMLControlledNamespacedRegistry"),
|
||||
SpaceCoreModInfoGenerator(new SpaceCoreModInfoGenerator(), () -> true,
|
||||
"com.spacechase0.minecraft.spacecore.mcp.ModInfoGenerator");
|
||||
"com.spacechase0.minecraft.spacecore.mcp.ModInfoGenerator"),
|
||||
GameDataAccelerator(new GameDataAccelerator(), () -> GeneralConfig.enableRegistryPerformanceTweak, "cpw.mods.fml.common.registry.GameData"),
|
||||
;
|
||||
|
||||
private static final Map<String, ClassEdit> editMap;
|
||||
private static final Map<String, List<ClassEdit>> editMap;
|
||||
|
||||
static {
|
||||
editMap = new HashMap<>();
|
||||
for (final ClassEdit edit : values()) {
|
||||
for (final String name : edit.classNames) {
|
||||
ClassEdit.editMap.put(name, edit);
|
||||
ClassEdit.editMap.computeIfAbsent(name, (ignored) -> new ArrayList<>()).add(edit);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -42,9 +47,14 @@ public enum ClassEdit {
|
||||
this.classNames = classNames;
|
||||
}
|
||||
|
||||
public static ClassEdit get(final String className) {
|
||||
val ret = ClassEdit.editMap.get(className);
|
||||
return ret != null && ret.cond.getAsBoolean() ? ret : null;
|
||||
public static List<ClassEdit> get(final String className) {
|
||||
val edit = ClassEdit.editMap.get(className);
|
||||
if (edit == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return edit.stream()
|
||||
.filter(r -> r.cond.getAsBoolean())
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.falsepattern.endlessids.asm;
|
||||
|
||||
import com.falsepattern.endlessids.asm.stubpackage.cpw.mods.fml.common.registry.GameData;
|
||||
import com.falsepattern.endlessids.util.WeakIdentityHashMap;
|
||||
import lombok.var;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.Collections;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
public class GameDataHooks {
|
||||
private static WeakIdentityHashMap<Block, WeakReference<ItemBlock>> forGameData(GameData gameData) {
|
||||
if (gameData.endlessIDsItemBlockCache == null) {
|
||||
gameData.endlessIDsItemBlockCache = new WeakIdentityHashMap<>();
|
||||
}
|
||||
return gameData.endlessIDsItemBlockCache;
|
||||
}
|
||||
|
||||
public static void cacheItemBlock(ItemBlock itemBlock, GameData gameData) {
|
||||
forGameData(gameData).put(itemBlock.field_150939_a, new WeakReference<>(itemBlock));
|
||||
}
|
||||
|
||||
public static ItemBlock fetchCachedItemBlock(Block block, GameData gameData) {
|
||||
var weakItem = forGameData(gameData).get(block);
|
||||
if (weakItem != null) {
|
||||
return weakItem.get();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Iterable<Item> fakeIterable() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import com.falsepattern.endlessids.Tags;
|
||||
import com.falsepattern.endlessids.asm.transformer.ChunkProviderSuperPatcher;
|
||||
import com.falsepattern.endlessids.asm.transformer.DevFixer;
|
||||
import lombok.val;
|
||||
import lombok.var;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.objectweb.asm.ClassReader;
|
||||
@@ -37,8 +38,7 @@ public class IETransformer implements IClassTransformer {
|
||||
if (blacklist.contains(transformedName)) {
|
||||
return bytes;
|
||||
}
|
||||
ClassEdit[] edits = new ClassEdit[2];
|
||||
edits[0] = ClassEdit.get(transformedName);
|
||||
var edits = new ArrayList<ClassEdit>(ClassEdit.get(transformedName));
|
||||
ClassNode cn = new ClassNode(Opcodes.ASM5);
|
||||
{
|
||||
val reader = new ClassReader(bytes);
|
||||
@@ -52,20 +52,15 @@ public class IETransformer implements IClassTransformer {
|
||||
val reader = new ClassReader(bytes);
|
||||
reader.accept(cn, ClassReader.EXPAND_FRAMES);
|
||||
}
|
||||
if (edits[0] == null) {
|
||||
edits[0] = ClassEdit.ChunkProviderSuperPatcher;
|
||||
} else {
|
||||
edits[1] = ClassEdit.ChunkProviderSuperPatcher;
|
||||
}
|
||||
edits.add(ClassEdit.ChunkProviderSuperPatcher);
|
||||
}
|
||||
if (edits[0] == null) {
|
||||
if (edits.size() == 0) {
|
||||
return isObfuscated ? bytes : DevFixer.fixDev(bytes);
|
||||
}
|
||||
if (!isObfuscated) {
|
||||
DevFixer.transform(cn);
|
||||
}
|
||||
for (int i = 0; i < edits.length; i++) {
|
||||
val edit = edits[i];
|
||||
for (final ClassEdit edit : edits) {
|
||||
if (edit == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
package com.falsepattern.endlessids.asm.stubpackage.Reika.DragonAPI;
|
||||
|
||||
public class ModList {
|
||||
public String modLabel;
|
||||
public boolean condition;
|
||||
public boolean successful;
|
||||
public String[] itemClasses;
|
||||
public String[] blockClasses;
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package com.falsepattern.endlessids.asm.stubpackage.cpw.mods.fml.common.registry;
|
||||
|
||||
import com.falsepattern.endlessids.util.WeakIdentityHashMap;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
public class GameData {
|
||||
public WeakIdentityHashMap<Block, WeakReference<ItemBlock>> endlessIDsItemBlockCache;
|
||||
}
|
||||
@@ -1,140 +0,0 @@
|
||||
package com.falsepattern.endlessids.asm.transformer;
|
||||
|
||||
import com.falsepattern.endlessids.asm.ASMHooks;
|
||||
import com.falsepattern.endlessids.asm.IClassNodeTransformer;
|
||||
import lombok.val;
|
||||
import lombok.var;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
import org.objectweb.asm.Type;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
import org.objectweb.asm.tree.FieldInsnNode;
|
||||
import org.objectweb.asm.tree.FieldNode;
|
||||
import org.objectweb.asm.tree.FrameNode;
|
||||
import org.objectweb.asm.tree.InsnNode;
|
||||
import org.objectweb.asm.tree.LineNumberNode;
|
||||
import org.objectweb.asm.tree.MethodInsnNode;
|
||||
import org.objectweb.asm.tree.MethodNode;
|
||||
import org.objectweb.asm.tree.VarInsnNode;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class DragonAPIModList implements IClassNodeTransformer {
|
||||
private static final List<String> fields = Arrays.asList("condition", "itemClasses", "blockClasses");
|
||||
|
||||
private static void tweakIsLoaded(MethodNode method) {
|
||||
val iterator = method.instructions.iterator();
|
||||
iterator.next();
|
||||
iterator.next();
|
||||
iterator.next();
|
||||
iterator.next();
|
||||
iterator.set(new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(ASMHooks.class),
|
||||
"DragonAPIModListTryLoad", "(LReika/DragonAPI/ModList;)Z", false));
|
||||
}
|
||||
|
||||
private static void tweakInit(MethodNode method) {
|
||||
val iterator = method.instructions.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
var insn = iterator.next();
|
||||
if (insn instanceof LineNumberNode && ((LineNumberNode) insn).line == 154) {
|
||||
//SRC:
|
||||
// L3
|
||||
// LINENUMBER 154 L3
|
||||
// ALOAD 0
|
||||
// ALOAD 0
|
||||
// GETFIELD Reika/DragonAPI/ModList.modLabel : Ljava/lang/String;
|
||||
// INVOKESTATIC cpw/mods/fml/common/Loader.isModLoaded (Ljava/lang/String;)Z
|
||||
// PUTFIELD Reika/DragonAPI/ModList.condition : Z
|
||||
//TGT:
|
||||
// L3
|
||||
// LINENUMBER 154 L3
|
||||
// ALOAD 0
|
||||
// ALOAD 5
|
||||
// PUTFIELD Reika/DragonAPI/ModList.itemClasses : [Ljava/lang/String;
|
||||
// ALOAD 0
|
||||
// ALOAD 4
|
||||
// PUTFIELD Reika/DragonAPI/ModList.blockClasses : [Ljava/lang/String;
|
||||
// ALOAD 0
|
||||
// INVOKESTATIC ASMHooks.isModLoaded (LReika/DragonAPI/ModList;)V
|
||||
// FRAME FULL [Reika/DragonAPI/ModList java/lang/String I java/lang/String [Ljava/lang/String; [Ljava/lang/String;] []
|
||||
// RETURN
|
||||
iterator.add(new VarInsnNode(Opcodes.ALOAD, 0));
|
||||
iterator.add(new VarInsnNode(Opcodes.ALOAD, 5));
|
||||
iterator.add(new FieldInsnNode(Opcodes.PUTFIELD, "Reika/DragonAPI/ModList", "itemClasses",
|
||||
"[Ljava/lang/String;"));
|
||||
iterator.add(new VarInsnNode(Opcodes.ALOAD, 0));
|
||||
iterator.add(new VarInsnNode(Opcodes.ALOAD, 4));
|
||||
iterator.add(new FieldInsnNode(Opcodes.PUTFIELD, "Reika/DragonAPI/ModList", "blockClasses",
|
||||
"[Ljava/lang/String;"));
|
||||
iterator.next();
|
||||
iterator.remove();
|
||||
iterator.next();
|
||||
iterator.next();
|
||||
iterator.remove();
|
||||
var methodInsn = (MethodInsnNode) iterator.next();
|
||||
methodInsn.owner = Type.getInternalName(ASMHooks.class);
|
||||
methodInsn.name = "DragonAPIModListConstructorTweak";
|
||||
methodInsn.desc = "(LReika/DragonAPI/ModList;)V";
|
||||
iterator.add(new FrameNode(Opcodes.F_FULL, 6,
|
||||
new Object[]{"Reika/DragonAPI/ModList", "java/lang/String", Opcodes.INTEGER,
|
||||
"java/lang/String", "[Ljava/lang/String;",
|
||||
"[Ljava/lang/String;"}, 0, new Object[]{}));
|
||||
iterator.add(new InsnNode(Opcodes.RETURN));
|
||||
iterator.add(new FrameNode(Opcodes.F_FULL, 6,
|
||||
new Object[]{"Reika/DragonAPI/ModList", "java/lang/String", Opcodes.INTEGER,
|
||||
"java/lang/String", "[Ljava/lang/String;",
|
||||
"[Ljava/lang/String;"}, 0, new Object[]{}));
|
||||
iterator.next();
|
||||
iterator.remove();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void crash() {
|
||||
throw new IllegalStateException("Tweaking failed!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void transform(final ClassNode cn, final boolean obfuscated) {
|
||||
int state = 0;
|
||||
for (val field : cn.fields) {
|
||||
if (field.name.equals("__MARKER__FALSEPATTERN__MIXINPATCH__")) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
for (val field : cn.fields) {
|
||||
if (field.name.equals("condition") && field.desc.equals("Z")) {
|
||||
field.access &= ~Opcodes.ACC_FINAL;
|
||||
state++;
|
||||
}
|
||||
if (fields.contains(field.name)) {
|
||||
field.access &= ~Opcodes.ACC_PRIVATE;
|
||||
field.access &= ~Opcodes.ACC_PROTECTED;
|
||||
field.access |= Opcodes.ACC_PUBLIC;
|
||||
state++;
|
||||
}
|
||||
}
|
||||
if (state != 4) {
|
||||
crash();
|
||||
}
|
||||
cn.fields.add(new FieldNode(Opcodes.ACC_PUBLIC, "successful", "Z", null, 0));
|
||||
cn.fields.add(new FieldNode(Opcodes.ACC_PRIVATE, "__MARKER__FALSEPATTERN__MIXINPATCH__", "Z", null, 0));
|
||||
|
||||
int state2 = 0;
|
||||
for (val method : cn.methods) {
|
||||
if ((state2 & 1) == 0 && method.name.equals("<init>") &&
|
||||
method.desc.equals("(Ljava/lang/String;ILjava/lang/String;[Ljava/lang/String;[Ljava/lang/String;)V")) {
|
||||
tweakInit(method);
|
||||
state2 |= 1;
|
||||
}
|
||||
if ((state2 & 2) == 0 && method.name.equals("isLoaded") && method.desc.equals("()Z")) {
|
||||
tweakIsLoaded(method);
|
||||
state2 |= 2;
|
||||
}
|
||||
}
|
||||
if (state2 != 3) {
|
||||
crash();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
package com.falsepattern.endlessids.asm.transformer;
|
||||
|
||||
import com.falsepattern.endlessids.asm.IClassNodeTransformer;
|
||||
import com.falsepattern.endlessids.asm.IETransformer;
|
||||
import lombok.val;
|
||||
import lombok.var;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
import org.objectweb.asm.tree.FieldInsnNode;
|
||||
import org.objectweb.asm.tree.FieldNode;
|
||||
import org.objectweb.asm.tree.InsnNode;
|
||||
import org.objectweb.asm.tree.MethodInsnNode;
|
||||
import org.objectweb.asm.tree.MethodNode;
|
||||
import org.objectweb.asm.tree.VarInsnNode;
|
||||
|
||||
public class GameDataAccelerator implements IClassNodeTransformer {
|
||||
private static final int MASK_REGISTER_BLOCK = 0b1;
|
||||
private static final int MASK_REGISTER_ITEM = 0b10;
|
||||
@Override
|
||||
public void transform(ClassNode classNode, boolean obfuscated) {
|
||||
var cacheField = new FieldNode(Opcodes.ACC_PUBLIC | Opcodes.ACC_SYNTHETIC, "endlessIDsItemBlockCache", "Lcom/falsepattern/endlessids/util/WeakIdentityHashMap;", null, null);
|
||||
classNode.fields.add(cacheField);
|
||||
int tweaksLeft = MASK_REGISTER_BLOCK | MASK_REGISTER_ITEM;
|
||||
for (val method: classNode.methods) {
|
||||
if ((tweaksLeft & MASK_REGISTER_BLOCK) != 0 &&
|
||||
method.name.equals("registerBlock") &&
|
||||
method.desc.equals("(Lnet/minecraft/block/Block;Ljava/lang/String;I)I")) {
|
||||
transformRegisterBlock(method);
|
||||
tweaksLeft &= ~MASK_REGISTER_BLOCK;
|
||||
}
|
||||
if ((tweaksLeft & MASK_REGISTER_ITEM) != 0 &&
|
||||
method.name.equals("registerItem") &&
|
||||
method.desc.equals("(Lnet/minecraft/item/Item;Ljava/lang/String;I)I")) {
|
||||
transformRegisterItem(method);
|
||||
tweaksLeft &= ~MASK_REGISTER_ITEM;
|
||||
}
|
||||
if (tweaksLeft == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (tweaksLeft != 0) {
|
||||
IETransformer.logger.error("Could not accelerate block registration!");
|
||||
}
|
||||
}
|
||||
|
||||
private void transformRegisterItem(MethodNode method) {
|
||||
var iter = method.instructions.iterator();
|
||||
while (iter.hasNext()) {
|
||||
var insn = iter.next();
|
||||
if (!(insn instanceof FieldInsnNode))
|
||||
continue;
|
||||
var typeInsn = (FieldInsnNode) insn;
|
||||
if (!(typeInsn.owner.equals("net/minecraft/item/ItemBlock") &&
|
||||
typeInsn.name.equals("field_150939_a") &&
|
||||
typeInsn.desc.equals("Lnet/minecraft/block/Block;")))
|
||||
continue;
|
||||
iter.previous();
|
||||
iter.add(new InsnNode(Opcodes.DUP));
|
||||
iter.add(new VarInsnNode(Opcodes.ALOAD, 0));
|
||||
iter.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "com/falsepattern/endlessids/asm/GameDataHooks", "cacheItemBlock", "(Lnet/minecraft/item/ItemBlock;Lcpw/mods/fml/common/registry/GameData;)V", false));
|
||||
return;
|
||||
}
|
||||
transformError(method);
|
||||
}
|
||||
|
||||
private static void transformError(MethodNode method) {
|
||||
IETransformer.logger.error("Could not add caching code to GameData." + method.name + method.desc);
|
||||
}
|
||||
|
||||
private void transformRegisterBlock(MethodNode method) {
|
||||
var iter = method.instructions.iterator();
|
||||
while (iter.hasNext()) {
|
||||
var insn = iter.next();
|
||||
if (!(insn instanceof FieldInsnNode))
|
||||
continue;
|
||||
var fieldInsn = (FieldInsnNode) insn;
|
||||
if (!(fieldInsn.owner.equals("cpw/mods/fml/common/registry/GameData") &&
|
||||
fieldInsn.name.equals("iItemRegistry") &&
|
||||
fieldInsn.desc.equals("Lcpw/mods/fml/common/registry/FMLControlledNamespacedRegistry;")))
|
||||
continue;
|
||||
iter.previous();
|
||||
iter.previous();
|
||||
iter.remove();
|
||||
iter.next();
|
||||
iter.remove();
|
||||
iter.next();
|
||||
iter.remove();
|
||||
iter.add(new VarInsnNode(Opcodes.ALOAD, 1));
|
||||
iter.add(new VarInsnNode(Opcodes.ALOAD, 0));
|
||||
iter.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "com/falsepattern/endlessids/asm/GameDataHooks", "fetchCachedItemBlock", "(Lnet/minecraft/block/Block;Lcpw/mods/fml/common/registry/GameData;)Lnet/minecraft/item/ItemBlock;", false));
|
||||
iter.add(new VarInsnNode(Opcodes.ASTORE, 4));
|
||||
iter.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "com/falsepattern/endlessids/asm/GameDataHooks", "fakeIterable", "()Ljava/lang/Iterable;", false));
|
||||
return;
|
||||
}
|
||||
transformError(method);
|
||||
}
|
||||
}
|
||||
@@ -38,6 +38,16 @@ public class GeneralConfig {
|
||||
@Config.Comment("Extend Potion IDs. Vanilla limit is 32, new limit is 65536.")
|
||||
@Config.DefaultBoolean(true)
|
||||
public static boolean extendPotion;
|
||||
@Config.Comment("Extend Entity IDs. Vanilla limit is 256, new limit is 32768.")
|
||||
@Config.DefaultBoolean(true)
|
||||
public static boolean extendEntity;
|
||||
|
||||
@Config.Comment("Improves the speed of the block registry by multiple orders of magnitudes. (not thoroughly tested yet)\n" +
|
||||
"It's highly recommended to leave this enabled, especially when using a lot of IDs.\n" +
|
||||
"With this disabled, registering 1 million blocks on a test system took 80 minutes\n" +
|
||||
"With this enabled, registering the same million blocks took 7 seconds")
|
||||
@Config.DefaultBoolean(true)
|
||||
public static boolean enableRegistryPerformanceTweak;
|
||||
@Config.Comment(
|
||||
"Extends the maximum redstone signal strength.\n" + "Only has effect with extendBlockItem enabled.\n" +
|
||||
"WARNING: THIS IS HERE ONLY FOR FUN, IT WILL DEFINITELY CORRUPT YOUR WORLD!")
|
||||
@@ -56,10 +66,30 @@ public class GeneralConfig {
|
||||
"The default setting sets it to 4k (vanilla).\n" +
|
||||
"increase if necessary (when running out of BLOCK IDs in your modpack)\n" +
|
||||
"Only effective if extendBlockItem is enabled.\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")
|
||||
"Effective values: (0: 4k, 1: 8k, 2: 16k, 3: 32k, 4: 64k, 5: 128k, 6: 256k, 7: 512k, 8: 1M, 9: 2M, 10: 4M, 11: 8M, 12: 16M)\n" +
|
||||
"The effective value of this variable must always be smaller or equal to the effective value of extraItemIDBits")
|
||||
@Config.RangeInt(min = 0,
|
||||
max = 12)
|
||||
@Config.DefaultInt(12)
|
||||
@Config.DefaultInt(0)
|
||||
public static int extraBlockIDBits;
|
||||
@Config.Comment("Use this to tune the amount of available item IDs.\n" +
|
||||
"The vanilla default is 32k item IDs, while the maximum is 16 million.\n" +
|
||||
"The default setting sets it to 32k (vanilla).\n" +
|
||||
"increase if necessary (when running out of ITEM IDs in your modpack)\n" +
|
||||
"Only effective if extendBlockItem is enabled.\n" +
|
||||
"Effective values: (0: 32k, 1: 64k, 2: 128k, 3: 256k, 4: 512k, 5: 1M, 6: 2M, 7: 4M, 8: 8M, 9: 16M)\n" +
|
||||
"The effective value of this variable must always be equal or larger than the effective value of extraBlockIDBits")
|
||||
@Config.RangeInt(min = 0,
|
||||
max = 9)
|
||||
@Config.DefaultInt(0)
|
||||
public static int extraItemIDBits;
|
||||
|
||||
|
||||
@Config.Comment("DEPRECATED, will be removed in the next version of EndlessIDs!\n" +
|
||||
"This property does nothing.\n" +
|
||||
"Use extraBlockIDBits and extraItemIDBits instead.")
|
||||
@Config.DefaultInt(0)
|
||||
@Deprecated
|
||||
public static int countCorrectionBits;
|
||||
|
||||
static {
|
||||
|
||||
@@ -7,7 +7,8 @@ public class ExtendedConstants {
|
||||
//Tunables
|
||||
public static final int bitsPerID = 24;
|
||||
public static final int bitsPerMetadata = 16;
|
||||
public static final int countCorrectionBits = GeneralConfig.countCorrectionBits;
|
||||
public static final int countCorrectionItemBits = 9 - GeneralConfig.extraItemIDBits;
|
||||
public static final int countCorrectionBlockBits = 12 - GeneralConfig.extraBlockIDBits;
|
||||
|
||||
public static final int watchableBits = 7;
|
||||
public static final int bitsPerBiome = 16;
|
||||
@@ -15,6 +16,9 @@ public class ExtendedConstants {
|
||||
public static final int maximumPotionIDs = 65536;
|
||||
public static final int maximumEnchantmentIDs = 32768;
|
||||
|
||||
//Align with max item metadata for spawn eggs. Will be treated as short in netcode
|
||||
public static final int bitsPerEntity = 15;
|
||||
|
||||
//BlockItemIDs
|
||||
public static final int nibblesPerID = bitsPerID / 4;
|
||||
public static final int bytesPerID = (nibblesPerID + 1) / 2;
|
||||
@@ -22,10 +26,10 @@ public class ExtendedConstants {
|
||||
public static final int bytesPerIDPlusMetadata = (nibblesPerID + nibblesPerMetadata + 1) / 2;
|
||||
|
||||
public static final int blockIDMask = (1 << bitsPerID) - 1;
|
||||
public static final int blockIDCount = 1 << (bitsPerID - countCorrectionBits);
|
||||
public static final int blockIDCount = 1 << (bitsPerID - countCorrectionBlockBits);
|
||||
public static final int maxBlockID = blockIDCount - 1;
|
||||
|
||||
public static final int itemIDCount = 1 << (bitsPerID);
|
||||
public static final int itemIDCount = 1 << (bitsPerID - countCorrectionItemBits);
|
||||
public static final int maxItemID = itemIDCount - 1;
|
||||
|
||||
public static final int bitsPerBlock = 8 + bitsPerID + bitsPerMetadata;
|
||||
@@ -43,4 +47,9 @@ public class ExtendedConstants {
|
||||
public static final int watchableCount = 1 << watchableBits;
|
||||
public static final int maxWatchableID = watchableCount - 1;
|
||||
public static final int watchableMask = (0x7 << watchableBits) | maxWatchableID;
|
||||
|
||||
//EntityIDs
|
||||
public static final int entityIDCount = 1 << bitsPerEntity;
|
||||
public static final int entityIDMask = entityIDCount - 1;
|
||||
public static final int maxEntityID = entityIDMask;
|
||||
}
|
||||
@@ -10,6 +10,8 @@ public class VanillaConstants {
|
||||
public static final int watchableBits = 5;
|
||||
public static final int bitsPerBiome = 8;
|
||||
|
||||
public static final int bitsPerEntity = 8;
|
||||
|
||||
//BlockItemIDs
|
||||
public static final int nibblesPerID = bitsPerID / 4;
|
||||
public static final int bytesPerID = (nibblesPerID + 1) / 2;
|
||||
@@ -38,4 +40,8 @@ public class VanillaConstants {
|
||||
public static final int watchableCount = 1 << watchableBits;
|
||||
public static final int maxWatchableID = watchableCount - 1;
|
||||
public static final int watchableMask = (0x7 << watchableBits) | maxWatchableID;
|
||||
|
||||
//EntityIDs
|
||||
public static final int entityIDCount = 1 << bitsPerEntity;
|
||||
public static final int maxEntityID = entityIDCount - 1;
|
||||
}
|
||||
+3
-3
@@ -44,7 +44,7 @@ public abstract class ReikaWorldHelperMixin {
|
||||
remap = true),
|
||||
locals = LocalCapture.CAPTURE_FAILHARD,
|
||||
require = 1)
|
||||
private static void customLogicSetBiome(World world, int x, int z, BiomeGenBase biome, CallbackInfo ci, Chunk ch, int ax, int az, byte[] biomes, int index) {
|
||||
private static void customLogicSetBiome(World world, int x, int z, BiomeGenBase biome, boolean applyEnvironment, CallbackInfo ci, Chunk ch, int ax, int az, byte[] biomes, int index) {
|
||||
((IChunkMixin) ch).getBiomeShortArray()[index] = (short) biome.biomeID;
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ public abstract class ReikaWorldHelperMixin {
|
||||
remap = true),
|
||||
locals = LocalCapture.CAPTURE_FAILEXCEPTION,
|
||||
require = 1)
|
||||
private static void captureIndexSetBiomeAndBlocks(World world, int x, int z, BiomeGenBase biome, CallbackInfo ci, Chunk ch, int ax, int az, byte[] biomes, int index) {
|
||||
private static void captureIndexSetBiomeAndBlocks(World world, int x, int z, BiomeGenBase biome, boolean applyEnvironment, CallbackInfo ci, Chunk ch, int ax, int az, byte[] biomes, int index) {
|
||||
fromBiomeID = ((IChunkMixin) ch).getBiomeShortArray()[index];
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ public abstract class ReikaWorldHelperMixin {
|
||||
remap = true),
|
||||
locals = LocalCapture.CAPTURE_FAILEXCEPTION,
|
||||
require = 1)
|
||||
private static void customLogicSetBiomeAndBlocks(World world, int x, int z, BiomeGenBase biome, CallbackInfo ci, Chunk ch, int ax, int az, byte[] biomes, int index, BiomeGenBase from) {
|
||||
private static void customLogicSetBiomeAndBlocks(World world, int x, int z, BiomeGenBase biome, boolean applyEnvironment, CallbackInfo ci, Chunk ch, int ax, int az, byte[] biomes, int index, BiomeGenBase from) {
|
||||
((IChunkMixin) ch).getBiomeShortArray()[index] = (short) biome.biomeID;
|
||||
}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
package com.falsepattern.endlessids.mixin.mixins.common.entity.vanilla;
|
||||
|
||||
import com.falsepattern.endlessids.constants.ExtendedConstants;
|
||||
import com.falsepattern.endlessids.constants.VanillaConstants;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Constant;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyConstant;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
import net.minecraft.entity.EntityList;
|
||||
|
||||
|
||||
@Mixin(EntityList.class)
|
||||
public abstract class EntityListMixin {
|
||||
@Shadow
|
||||
public static void addMapping(Class p_75618_0_, String p_75618_1_, int p_75618_2_) {
|
||||
}
|
||||
|
||||
@Shadow
|
||||
public static void addMapping(Class p_75614_0_, String p_75614_1_, int p_75614_2_, int p_75614_3_, int p_75614_4_) {
|
||||
|
||||
}
|
||||
|
||||
@ModifyConstant(method = "addMapping(Ljava/lang/Class;Ljava/lang/String;I)V",
|
||||
constant = @Constant(intValue = VanillaConstants.maxEntityID),
|
||||
require = 1)
|
||||
private static int extendRange(int constant) {
|
||||
return ExtendedConstants.maxEntityID;
|
||||
}
|
||||
|
||||
@Redirect(method = "<clinit>",
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/entity/EntityList;addMapping(Ljava/lang/Class;Ljava/lang/String;I)V"),
|
||||
require = 1)
|
||||
private static void messUpMappings1(Class p_75618_0_, String p_75618_1_, int p_75618_2_) {
|
||||
addMapping(p_75618_0_, p_75618_1_, p_75618_2_ * 100);
|
||||
}
|
||||
|
||||
|
||||
@Redirect(method = "<clinit>",
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/entity/EntityList;addMapping(Ljava/lang/Class;Ljava/lang/String;III)V"),
|
||||
require = 1)
|
||||
private static void messUpMappings2(Class p_75614_0_, String p_75614_1_, int p_75614_2_, int p_75614_3_, int p_75614_4_) {
|
||||
addMapping(p_75614_0_, p_75614_1_, p_75614_2_ * 100, p_75614_3_, p_75614_4_);
|
||||
}
|
||||
}
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
package com.falsepattern.endlessids.mixin.mixins.common.entity.vanilla;
|
||||
|
||||
import com.falsepattern.endlessids.constants.ExtendedConstants;
|
||||
import com.falsepattern.endlessids.constants.VanillaConstants;
|
||||
import org.apache.logging.log4j.Level;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.Constant;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyConstant;
|
||||
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.registry.EntityRegistry;
|
||||
|
||||
import java.util.BitSet;
|
||||
|
||||
@Mixin(value = EntityRegistry.class,
|
||||
remap = false)
|
||||
public abstract class EntityRegistryMixin {
|
||||
@Shadow private BitSet availableIndicies;
|
||||
|
||||
@ModifyConstant(method = "<init>",
|
||||
constant = @Constant(intValue = VanillaConstants.entityIDCount),
|
||||
require = 1)
|
||||
private int extendIDs1(int constant) {
|
||||
return ExtendedConstants.entityIDCount;
|
||||
}
|
||||
|
||||
@ModifyConstant(method = "<init>",
|
||||
constant = @Constant(intValue = VanillaConstants.maxEntityID),
|
||||
require = 1)
|
||||
private int extendIDs2(int constant) {
|
||||
return ExtendedConstants.maxEntityID;
|
||||
}
|
||||
|
||||
/**
|
||||
* @author FalsePattern
|
||||
* @reason Extended IDs
|
||||
*/
|
||||
@Overwrite
|
||||
private int validateAndClaimId(int id) {
|
||||
//Keeping the legacy sub-0 id workaround here...
|
||||
|
||||
// workaround for broken ML
|
||||
int realId = id;
|
||||
if (id < Byte.MIN_VALUE) {
|
||||
realId += 3000;
|
||||
FMLLog.warning("Compensating for modloader out of range compensation by mod : entityId %d for mod %s is now %d", id, Loader.instance().activeModContainer().getModId(), realId);
|
||||
}
|
||||
|
||||
if (realId < 0) {
|
||||
realId += Byte.MAX_VALUE;
|
||||
}
|
||||
|
||||
if ((realId & ~ExtendedConstants.entityIDMask) != 0) {
|
||||
FMLLog.log(Level.ERROR, "The entity ID %d for mod %s is not in the range 1-" + ExtendedConstants.entityIDMask + " and may not work", id, Loader.instance().activeModContainer().getModId());
|
||||
}
|
||||
|
||||
if (!availableIndicies.get(realId)) {
|
||||
FMLLog.severe("The mod %s has attempted to register an entity ID %d which is already reserved. This could cause severe problems", Loader.instance().activeModContainer().getModId(), id);
|
||||
}
|
||||
availableIndicies.clear(realId);
|
||||
return realId;
|
||||
}
|
||||
}
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
package com.falsepattern.endlessids.mixin.mixins.common.entity.vanilla;
|
||||
|
||||
import com.falsepattern.endlessids.constants.ExtendedConstants;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
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.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import net.minecraft.entity.EntityList;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.play.server.S0FPacketSpawnMob;
|
||||
|
||||
@Mixin(S0FPacketSpawnMob.class)
|
||||
public abstract class S0FPacketSpawnMobMixin {
|
||||
@Shadow private int field_149040_b;
|
||||
|
||||
@Inject(method = "<init>(Lnet/minecraft/entity/EntityLivingBase;)V",
|
||||
at = @At("RETURN"),
|
||||
require = 1)
|
||||
private void unClampType(EntityLivingBase entity, CallbackInfo ci) {
|
||||
field_149040_b = EntityList.getEntityID(entity);
|
||||
}
|
||||
|
||||
@Redirect(method = "readPacketData",
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/network/PacketBuffer;readByte()B",
|
||||
ordinal = 0),
|
||||
require = 1)
|
||||
private byte noReadByte(PacketBuffer data) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Inject(method = "readPacketData",
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/network/PacketBuffer;readByte()B",
|
||||
ordinal = 0),
|
||||
require = 1)
|
||||
private void readType(PacketBuffer data, CallbackInfo ci) {
|
||||
field_149040_b = data.readShort() & ExtendedConstants.entityIDMask;
|
||||
}
|
||||
|
||||
@Redirect(method = "writePacketData",
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/network/PacketBuffer;writeByte(I)Lio/netty/buffer/ByteBuf;",
|
||||
ordinal = 0),
|
||||
require = 1)
|
||||
private ByteBuf noWriteByte(PacketBuffer data, int theByte) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Inject(method = "writePacketData",
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/network/PacketBuffer;writeByte(I)Lio/netty/buffer/ByteBuf;",
|
||||
ordinal = 0),
|
||||
require = 1)
|
||||
private void writeType(PacketBuffer data, CallbackInfo ci) {
|
||||
data.writeShort(field_149040_b & ExtendedConstants.entityIDMask);
|
||||
}
|
||||
}
|
||||
@@ -215,6 +215,13 @@ public enum Mixin implements IMixin {
|
||||
S1EPacketRemoveEntityEffectMixin(Side.COMMON, condition(() -> GeneralConfig.extendPotion), "potion.vanilla.network.S1EPacketRemoveEntityEffectMixin"),
|
||||
//endregion vanilla
|
||||
//endregion potion
|
||||
//region entity
|
||||
//region vanilla
|
||||
EntityListMixin(Side.COMMON, condition(() -> GeneralConfig.extendEntity), "entity.vanilla.EntityListMixin"),
|
||||
EntityRegistryMixin(Side.COMMON, condition(() -> GeneralConfig.extendEntity), "entity.vanilla.EntityRegistryMixin"),
|
||||
S0FPacketSpawnMobMixin(Side.COMMON, condition(() -> GeneralConfig.extendEntity), "entity.vanilla.S0FPacketSpawnMobMixin"),
|
||||
//endregion vanilla
|
||||
//endregion entity
|
||||
//endregion common
|
||||
|
||||
//region client
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.falsepattern.endlessids.util;
|
||||
import java.lang.ref.Reference;
|
||||
import java.lang.ref.ReferenceQueue;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Like WeakHashMap, but uses identity instead of equality when comparing keys.
|
||||
*/
|
||||
public class WeakIdentityHashMap<K,V> {
|
||||
private final HashMap<WeakReference<K>,V> mMap = new HashMap<>();
|
||||
private final ReferenceQueue<Object> mRefQueue = new ReferenceQueue<>();
|
||||
private void cleanUp() {
|
||||
Reference<?> ref;
|
||||
while ((ref = mRefQueue.poll()) != null) {
|
||||
mMap.remove(ref);
|
||||
}
|
||||
}
|
||||
public void put(K key, V value) {
|
||||
cleanUp();
|
||||
mMap.put(new CmpWeakReference<>(key, mRefQueue), value);
|
||||
}
|
||||
public V get(K key) {
|
||||
cleanUp();
|
||||
return mMap.get(new CmpWeakReference<>(key));
|
||||
}
|
||||
public Collection<V> values() {
|
||||
cleanUp();
|
||||
return mMap.values();
|
||||
}
|
||||
public Set<Map.Entry<WeakReference<K>, V>> entrySet() {
|
||||
return mMap.entrySet();
|
||||
}
|
||||
public int size() {
|
||||
cleanUp();
|
||||
return mMap.size();
|
||||
}
|
||||
public boolean isEmpty() {
|
||||
cleanUp();
|
||||
return mMap.isEmpty();
|
||||
}
|
||||
private static class CmpWeakReference<K> extends WeakReference<K> {
|
||||
private final int mHashCode;
|
||||
public CmpWeakReference(K key) {
|
||||
super(key);
|
||||
mHashCode = System.identityHashCode(key);
|
||||
}
|
||||
public CmpWeakReference(K key, ReferenceQueue<Object> refQueue) {
|
||||
super(key, refQueue);
|
||||
mHashCode = System.identityHashCode(key);
|
||||
}
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o == this) {
|
||||
return true;
|
||||
}
|
||||
K k = get();
|
||||
if (k != null && o instanceof CmpWeakReference) {
|
||||
return ((CmpWeakReference) o).get() == k;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return mHashCode;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user