Compare commits

..
2 Commits
Author SHA1 Message Date
FalsePattern a43f85b18c Entity ID extension fixes 2025-08-27 18:57:15 +02:00
FalsePattern 986a614028 update gradle and buildscript 2025-08-27 18:56:57 +02:00
8 changed files with 90 additions and 6 deletions

No files matched your search

+1 -1
View File
@@ -1,5 +1,5 @@
plugins {
id("com.falsepattern.fpgradle-mc") version ("1.0.0")
id("com.falsepattern.fpgradle-mc") version ("1.1.4")
}
group = "com.falsepattern"
Binary file not shown.
+1 -1
View File
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.0.0-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Vendored
+1 -1
View File
@@ -1,7 +1,7 @@
#!/bin/sh
#
# Copyright © 2015-2021 the original authors.
# Copyright © 2015 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
+1 -1
View File
@@ -1,5 +1,5 @@
plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version("0.9.0")
id("org.gradle.toolchains.foojay-resolver-convention") version("1.0.0")
}
rootProject.name = "EndlessIDs"
@@ -0,0 +1,29 @@
/*
* EndlessIDs
*
* Copyright (C) 2022-2025 FalsePattern, The MEGA Team
* All Rights Reserved
*
* The above copyright notice, this permission notice and the word "MEGA"
* shall be included in all copies or substantial portions of the Software.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, only version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.falsepattern.endlessids.mixin.helpers;
import java.util.BitSet;
public interface EntityRegistryAccessor {
BitSet eids$availableIndicies();
}
@@ -24,18 +24,51 @@ package com.falsepattern.endlessids.mixin.mixins.common.entity.vanilla;
import com.falsepattern.endlessids.constants.ExtendedConstants;
import com.falsepattern.endlessids.constants.VanillaConstants;
import com.falsepattern.endlessids.mixin.helpers.EntityRegistryAccessor;
import lombok.val;
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.Inject;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityList;
import cpw.mods.fml.common.registry.EntityRegistry;
import java.util.HashMap;
import java.util.Map;
@Mixin(EntityList.class)
public abstract class EntityListMixin {
@Shadow
public static Map<Integer, Class<? extends Entity>> IDtoClassMapping;
@Inject(method = "<clinit>",
at = @At(value = "RETURN"),
require = 1)
private static void hijackMap(CallbackInfo ci) {
IDtoClassMapping = new HashMap<Integer, Class<? extends Entity>>(IDtoClassMapping) {
@Override
public Class<? extends Entity> put(Integer key, Class<? extends Entity> value) {
val availableIndicies = ((EntityRegistryAccessor) EntityRegistry.instance()).eids$availableIndicies();
availableIndicies.clear(key);
return super.put(key, value);
}
@Override
public void putAll(Map<? extends Integer, ? extends Class<? extends Entity>> m) {
val availableIndicies = ((EntityRegistryAccessor) EntityRegistry.instance()).eids$availableIndicies();
for (val entry : m.entrySet()) {
availableIndicies.clear(entry.getKey());
}
super.putAll(m);
}
};
}
@ModifyConstant(method = "addMapping(Ljava/lang/Class;Ljava/lang/String;I)V",
constant = @Constant(intValue = VanillaConstants.maxEntityID),
@@ -43,4 +76,14 @@ public abstract class EntityListMixin {
private static int extendRange(int constant) {
return ExtendedConstants.maxEntityID;
}
@Inject(method = "addMapping(Ljava/lang/Class;Ljava/lang/String;I)V",
at = @At(value = "INVOKE",
target = "Ljava/util/Map;put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;",
ordinal = 0),
require = 1)
private static void updateForgeIDMap(Class<? extends Entity> entityClass, String entityName, int id, CallbackInfo ci) {
val availableIndicies = ((EntityRegistryAccessor) EntityRegistry.instance()).eids$availableIndicies();
availableIndicies.clear(id);
}
}
@@ -24,6 +24,8 @@ package com.falsepattern.endlessids.mixin.mixins.common.entity.vanilla;
import com.falsepattern.endlessids.constants.ExtendedConstants;
import com.falsepattern.endlessids.constants.VanillaConstants;
import com.falsepattern.endlessids.mixin.helpers.EntityRegistryAccessor;
import lombok.val;
import org.apache.logging.log4j.Level;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
@@ -31,6 +33,7 @@ import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
import net.minecraft.entity.EntityList;
import cpw.mods.fml.common.FMLLog;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.registry.EntityRegistry;
@@ -39,9 +42,14 @@ import java.util.BitSet;
@Mixin(value = EntityRegistry.class,
remap = false)
public abstract class EntityRegistryMixin {
public abstract class EntityRegistryMixin implements EntityRegistryAccessor {
@Shadow private BitSet availableIndicies;
@Override
public BitSet eids$availableIndicies() {
return availableIndicies;
}
@ModifyConstant(method = "<init>",
constant = @Constant(intValue = VanillaConstants.entityIDCount),
require = 1)
@@ -62,6 +70,10 @@ public abstract class EntityRegistryMixin {
*/
@Overwrite
private int validateAndClaimId(int id) {
//Refresh available indices
for (val key: EntityList.IDtoClassMapping.keySet()) {
availableIndicies.clear(key);
}
//Keeping the legacy sub-0 id workaround here...
// workaround for broken ML