Add option to reduce memory usage of entity models
This commit is contained in:
parent
8ee85f2c16
commit
5a9c49f8d4
|
|
@ -0,0 +1,40 @@
|
|||
package org.embeddedt.modernfix.common.mixin.perf.compact_entity_models;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||
import net.minecraft.client.model.geom.ModelPart;
|
||||
import net.minecraft.client.model.geom.builders.CubeDefinition;
|
||||
import org.embeddedt.modernfix.annotation.ClientOnlyMixin;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@Mixin(CubeDefinition.class)
|
||||
@ClientOnlyMixin
|
||||
public class CubeDefinitionMixin {
|
||||
@Unique
|
||||
private static final ConcurrentHashMap<List<Object>, ModelPart.Cube> MFIX_CUBE_CACHE = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* @author embeddedt
|
||||
* @reason deduplicate creation of Cube objects
|
||||
*/
|
||||
@WrapOperation(method = "bake", at = @At(value = "NEW", target = "(IIFFFFFFFFFZFFLjava/util/Set;)Lnet/minecraft/client/model/geom/ModelPart$Cube;"))
|
||||
private ModelPart.Cube modernfix$deduplicateCube(int texCoordU, int texCoordV, float originX, float originY, float originZ,
|
||||
float dimensionX, float dimensionY, float dimensionZ, float gtowX,
|
||||
float growY, float growZ, boolean mirror, float texScaleU,
|
||||
float texScaleV, Set visibleFaces,
|
||||
Operation<ModelPart.Cube> original) {
|
||||
List<Object> cacheKey = List.of(texCoordU, texCoordV, originX, originY, originZ, dimensionX, dimensionY, dimensionZ, gtowX, growY, growZ, mirror, texScaleU, texScaleV, visibleFaces);
|
||||
var cube = MFIX_CUBE_CACHE.get(cacheKey);
|
||||
if (cube == null) {
|
||||
cube = original.call((Object[])cacheKey.toArray());
|
||||
MFIX_CUBE_CACHE.put(cacheKey, cube);
|
||||
}
|
||||
return cube;
|
||||
}
|
||||
}
|
||||
|
|
@ -174,15 +174,12 @@ public class ModernFixEarlyConfig {
|
|||
.put("mixin.feature.blockentity_incorrect_thread", false)
|
||||
.put("mixin.perf.clear_mixin_classinfo", false)
|
||||
.put("mixin.perf.deduplicate_climate_parameters", false)
|
||||
.put("mixin.perf.faster_capabilities.bytecode_analysis", false)
|
||||
.put("mixin.bugfix.packet_leak", false)
|
||||
.put("mixin.perf.deduplicate_location", false)
|
||||
.put("mixin.perf.dynamic_entity_renderers", false)
|
||||
.put("mixin.feature.integrated_server_watchdog", true)
|
||||
.put("mixin.perf.faster_item_rendering", false)
|
||||
.put("mixin.perf.ingredient_item_deduplication", false)
|
||||
.put("mixin.feature.spam_thread_dump", false)
|
||||
.put("mixin.feature.disable_unihex_font", false)
|
||||
.put("mixin.feature.remove_chat_signing", false)
|
||||
.put("mixin.bugfix.skip_redundant_saves", false)
|
||||
.put("mixin.feature.snapshot_easter_egg", true)
|
||||
|
|
@ -195,7 +192,11 @@ public class ModernFixEarlyConfig {
|
|||
.putConditionally(() -> !isFabric, "mixin.bugfix.fix_config_crashes", true)
|
||||
.putConditionally(() -> !isFabric, "mixin.bugfix.forge_at_inject_error", true)
|
||||
.putConditionally(() -> !isFabric, "mixin.feature.registry_event_progress", false)
|
||||
.putConditionally(() -> isFabric, "mixin.perf.clear_fabric_mapping_tables", false)
|
||||
// Beta (promote on next release)
|
||||
.put("mixin.perf.compact_entity_models", false)
|
||||
.put("mixin.perf.faster_capabilities.bytecode_analysis", false)
|
||||
.put("mixin.perf.ingredient_item_deduplication", false)
|
||||
// END
|
||||
.build();
|
||||
|
||||
private ModernFixEarlyConfig(File file) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user