Remove blockstate compression
This commit is contained in:
parent
b21ee9a7e7
commit
c1c9c02ff4
|
|
@ -1,14 +0,0 @@
|
||||||
package org.embeddedt.modernfix.common.mixin.perf.compress_blockstate;
|
|
||||||
|
|
||||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.Overwrite;
|
|
||||||
|
|
||||||
@Mixin(BlockBehaviour.class)
|
|
||||||
public class BlockBehaviourMixin {
|
|
||||||
@Overwrite
|
|
||||||
protected boolean isAir(BlockState state) {
|
|
||||||
return state.getBlock().properties.isAir;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,102 +0,0 @@
|
||||||
package org.embeddedt.modernfix.common.mixin.perf.compress_blockstate;
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
|
||||||
import com.mojang.serialization.MapCodec;
|
|
||||||
import net.minecraft.world.level.block.Block;
|
|
||||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
|
||||||
import net.minecraft.world.level.block.state.StateHolder;
|
|
||||||
import net.minecraft.world.level.block.state.properties.Property;
|
|
||||||
import net.minecraft.world.level.material.Material;
|
|
||||||
import org.objectweb.asm.Opcodes;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
|
||||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
|
||||||
|
|
||||||
@Mixin(BlockBehaviour.BlockStateBase.class)
|
|
||||||
public abstract class BlockStateBaseMixin extends StateHolder<Block, BlockState> {
|
|
||||||
protected BlockStateBaseMixin(Block object, ImmutableMap<Property<?>, Comparable<?>> immutableMap, MapCodec<BlockState> mapCodec) {
|
|
||||||
super(object, immutableMap, mapCodec);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Redirect(method = "*", at = @At(
|
|
||||||
value = "FIELD",
|
|
||||||
opcode = Opcodes.GETFIELD,
|
|
||||||
target = "Lnet/minecraft/world/level/block/state/BlockBehaviour$BlockStateBase;material:Lnet/minecraft/world/level/material/Material;"
|
|
||||||
))
|
|
||||||
private Material getMaterial(BlockBehaviour.BlockStateBase base) {
|
|
||||||
return this.owner.properties.material;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Redirect(method = "*", at = @At(
|
|
||||||
value = "FIELD",
|
|
||||||
opcode = Opcodes.GETFIELD,
|
|
||||||
target = "Lnet/minecraft/world/level/block/state/BlockBehaviour$BlockStateBase;destroySpeed:F"
|
|
||||||
))
|
|
||||||
private float getDestroyTime(BlockBehaviour.BlockStateBase base) {
|
|
||||||
return this.owner.properties.destroyTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Redirect(method = "*", at = @At(
|
|
||||||
value = "FIELD",
|
|
||||||
opcode = Opcodes.GETFIELD,
|
|
||||||
target = "Lnet/minecraft/world/level/block/state/BlockBehaviour$BlockStateBase;requiresCorrectToolForDrops:Z"
|
|
||||||
))
|
|
||||||
private boolean getRequiresTool(BlockBehaviour.BlockStateBase base) {
|
|
||||||
return this.owner.properties.requiresCorrectToolForDrops;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Redirect(method = "*", at = @At(
|
|
||||||
value = "FIELD",
|
|
||||||
opcode = Opcodes.GETFIELD,
|
|
||||||
target = "Lnet/minecraft/world/level/block/state/BlockBehaviour$BlockStateBase;canOcclude:Z"
|
|
||||||
))
|
|
||||||
private boolean getCanOcclude(BlockBehaviour.BlockStateBase base) {
|
|
||||||
return this.owner.properties.canOcclude;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Redirect(method = "*", at = @At(
|
|
||||||
value = "FIELD",
|
|
||||||
opcode = Opcodes.GETFIELD,
|
|
||||||
target = "Lnet/minecraft/world/level/block/state/BlockBehaviour$BlockStateBase;isRedstoneConductor:Lnet/minecraft/world/level/block/state/BlockBehaviour$StatePredicate;"
|
|
||||||
))
|
|
||||||
private BlockBehaviour.StatePredicate getRedstoneConductor(BlockBehaviour.BlockStateBase base) {
|
|
||||||
return this.owner.properties.isRedstoneConductor;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Redirect(method = "*", at = @At(
|
|
||||||
value = "FIELD",
|
|
||||||
opcode = Opcodes.GETFIELD,
|
|
||||||
target = "Lnet/minecraft/world/level/block/state/BlockBehaviour$BlockStateBase;isSuffocating:Lnet/minecraft/world/level/block/state/BlockBehaviour$StatePredicate;"
|
|
||||||
))
|
|
||||||
private BlockBehaviour.StatePredicate getSuffocating(BlockBehaviour.BlockStateBase base) {
|
|
||||||
return this.owner.properties.isSuffocating;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Redirect(method = "*", at = @At(
|
|
||||||
value = "FIELD",
|
|
||||||
opcode = Opcodes.GETFIELD,
|
|
||||||
target = "Lnet/minecraft/world/level/block/state/BlockBehaviour$BlockStateBase;isViewBlocking:Lnet/minecraft/world/level/block/state/BlockBehaviour$StatePredicate;"
|
|
||||||
))
|
|
||||||
private BlockBehaviour.StatePredicate getViewBlocking(BlockBehaviour.BlockStateBase base) {
|
|
||||||
return this.owner.properties.isViewBlocking;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Redirect(method = "*", at = @At(
|
|
||||||
value = "FIELD",
|
|
||||||
opcode = Opcodes.GETFIELD,
|
|
||||||
target = "Lnet/minecraft/world/level/block/state/BlockBehaviour$BlockStateBase;hasPostProcess:Lnet/minecraft/world/level/block/state/BlockBehaviour$StatePredicate;"
|
|
||||||
))
|
|
||||||
private BlockBehaviour.StatePredicate getPostProcess(BlockBehaviour.BlockStateBase base) {
|
|
||||||
return this.owner.properties.hasPostProcess;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Redirect(method = "*", at = @At(
|
|
||||||
value = "FIELD",
|
|
||||||
opcode = Opcodes.GETFIELD,
|
|
||||||
target = "Lnet/minecraft/world/level/block/state/BlockBehaviour$BlockStateBase;emissiveRendering:Lnet/minecraft/world/level/block/state/BlockBehaviour$StatePredicate;"
|
|
||||||
))
|
|
||||||
private BlockBehaviour.StatePredicate getEmissiveRendering(BlockBehaviour.BlockStateBase base) {
|
|
||||||
return this.owner.properties.emissiveRendering;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -14,16 +14,6 @@ accessible field net/minecraft/client/renderer/texture/Stitcher$Holder width I
|
||||||
accessible field net/minecraft/client/renderer/texture/Stitcher$Holder height I
|
accessible field net/minecraft/client/renderer/texture/Stitcher$Holder height I
|
||||||
accessible field net/minecraft/network/syncher/EntityDataAccessor id I
|
accessible field net/minecraft/network/syncher/EntityDataAccessor id I
|
||||||
mutable field net/minecraft/network/syncher/EntityDataAccessor id I
|
mutable field net/minecraft/network/syncher/EntityDataAccessor id I
|
||||||
accessible field net/minecraft/world/level/block/state/BlockBehaviour$Properties isAir Z
|
|
||||||
accessible field net/minecraft/world/level/block/state/BlockBehaviour$Properties material Lnet/minecraft/world/level/material/Material;
|
|
||||||
accessible field net/minecraft/world/level/block/state/BlockBehaviour$Properties destroyTime F
|
|
||||||
accessible field net/minecraft/world/level/block/state/BlockBehaviour$Properties requiresCorrectToolForDrops Z
|
|
||||||
accessible field net/minecraft/world/level/block/state/BlockBehaviour$Properties canOcclude Z
|
|
||||||
accessible field net/minecraft/world/level/block/state/BlockBehaviour$Properties isRedstoneConductor Lnet/minecraft/world/level/block/state/BlockBehaviour$StatePredicate;
|
|
||||||
accessible field net/minecraft/world/level/block/state/BlockBehaviour$Properties isSuffocating Lnet/minecraft/world/level/block/state/BlockBehaviour$StatePredicate;
|
|
||||||
accessible field net/minecraft/world/level/block/state/BlockBehaviour$Properties isViewBlocking Lnet/minecraft/world/level/block/state/BlockBehaviour$StatePredicate;
|
|
||||||
accessible field net/minecraft/world/level/block/state/BlockBehaviour$Properties hasPostProcess Lnet/minecraft/world/level/block/state/BlockBehaviour$StatePredicate;
|
|
||||||
accessible field net/minecraft/world/level/block/state/BlockBehaviour$Properties emissiveRendering Lnet/minecraft/world/level/block/state/BlockBehaviour$StatePredicate;
|
|
||||||
accessible class net/minecraft/client/resources/model/ModelBakery$BlockStateDefinitionException
|
accessible class net/minecraft/client/resources/model/ModelBakery$BlockStateDefinitionException
|
||||||
accessible field net/minecraft/network/syncher/SynchedEntityData itemsById Ljava/util/Map;
|
accessible field net/minecraft/network/syncher/SynchedEntityData itemsById Ljava/util/Map;
|
||||||
accessible field net/minecraft/network/syncher/SynchedEntityData ENTITY_ID_POOL Ljava/util/Map;
|
accessible field net/minecraft/network/syncher/SynchedEntityData ENTITY_ID_POOL Ljava/util/Map;
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ import com.google.common.io.Resources;
|
||||||
import com.mojang.blaze3d.platform.NativeImage;
|
import com.mojang.blaze3d.platform.NativeImage;
|
||||||
import com.mojang.brigadier.CommandDispatcher;
|
import com.mojang.brigadier.CommandDispatcher;
|
||||||
import cpw.mods.modlauncher.*;
|
import cpw.mods.modlauncher.*;
|
||||||
import cpw.mods.modlauncher.api.INameMappingService;
|
|
||||||
import cpw.mods.modlauncher.api.LamdbaExceptionUtils;
|
import cpw.mods.modlauncher.api.LamdbaExceptionUtils;
|
||||||
import net.minecraft.client.renderer.texture.TextureAtlas;
|
import net.minecraft.client.renderer.texture.TextureAtlas;
|
||||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||||
|
|
@ -18,20 +17,21 @@ import net.minecraftforge.client.ForgeHooksClient;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.event.RegisterCommandsEvent;
|
import net.minecraftforge.event.RegisterCommandsEvent;
|
||||||
import net.minecraftforge.fml.ModLoader;
|
import net.minecraftforge.fml.ModLoader;
|
||||||
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
|
|
||||||
import net.minecraftforge.fml.loading.FMLLoader;
|
import net.minecraftforge.fml.loading.FMLLoader;
|
||||||
import net.minecraftforge.fml.loading.FMLPaths;
|
import net.minecraftforge.fml.loading.FMLPaths;
|
||||||
import net.minecraftforge.fml.loading.LoadingModList;
|
import net.minecraftforge.fml.loading.LoadingModList;
|
||||||
import net.minecraftforge.fml.loading.moddiscovery.ExplodedDirectoryLocator;
|
import net.minecraftforge.fml.loading.moddiscovery.ExplodedDirectoryLocator;
|
||||||
import net.minecraftforge.fml.network.PacketDistributor;
|
import net.minecraftforge.fml.network.PacketDistributor;
|
||||||
import net.minecraftforge.fml.server.ServerLifecycleHooks;
|
import net.minecraftforge.fml.server.ServerLifecycleHooks;
|
||||||
|
import org.embeddedt.modernfix.core.ModernFixMixinPlugin;
|
||||||
import org.embeddedt.modernfix.forge.classloading.FastAccessTransformerList;
|
import org.embeddedt.modernfix.forge.classloading.FastAccessTransformerList;
|
||||||
import org.embeddedt.modernfix.forge.classloading.ModernFixResourceFinder;
|
import org.embeddedt.modernfix.forge.classloading.ModernFixResourceFinder;
|
||||||
import org.embeddedt.modernfix.core.ModernFixMixinPlugin;
|
|
||||||
import org.embeddedt.modernfix.forge.packet.PacketHandler;
|
import org.embeddedt.modernfix.forge.packet.PacketHandler;
|
||||||
import org.embeddedt.modernfix.util.DummyList;
|
import org.embeddedt.modernfix.util.DummyList;
|
||||||
import org.objectweb.asm.Opcodes;
|
import org.objectweb.asm.Opcodes;
|
||||||
import org.objectweb.asm.tree.*;
|
import org.objectweb.asm.tree.ClassNode;
|
||||||
|
import org.objectweb.asm.tree.InsnNode;
|
||||||
|
import org.objectweb.asm.tree.MethodNode;
|
||||||
import org.spongepowered.asm.mixin.injection.struct.InjectorGroupInfo;
|
import org.spongepowered.asm.mixin.injection.struct.InjectorGroupInfo;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
@ -43,11 +43,11 @@ import java.lang.reflect.Method;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLClassLoader;
|
import java.net.URLClassLoader;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.*;
|
import java.util.Enumeration;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
public class ModernFixPlatformHooksImpl {
|
public class ModernFixPlatformHooksImpl {
|
||||||
public static boolean isClient() {
|
public static boolean isClient() {
|
||||||
|
|
@ -206,40 +206,7 @@ public class ModernFixPlatformHooksImpl {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void applyASMTransformers(String mixinClassName, ClassNode targetClass) {
|
public static void applyASMTransformers(String mixinClassName, ClassNode targetClass) {
|
||||||
if(mixinClassName.equals("org.embeddedt.modernfix.common.compress_blockstate.perf.mixin.BlockStateBaseMixin")) {
|
if(mixinClassName.equals("org.embeddedt.modernfix.forge.valhesia.chunk_deadlock.bugfix.mixin.BlockStateBaseMixin")) {
|
||||||
// Delete unused fields off BlockStateBase
|
|
||||||
Set<String> fieldsToDelete = Stream.of(
|
|
||||||
"field_235702_f_", // isAir
|
|
||||||
"field_235703_g_", // material
|
|
||||||
"field_235705_i_", // destroySpeed
|
|
||||||
"field_235706_j_", // requiresCorrectToolForDrops
|
|
||||||
"field_235707_k_", // canOcclude
|
|
||||||
"field_235708_l_", // isRedstoneConductor
|
|
||||||
"field_235709_m_", // isSuffocating
|
|
||||||
"field_235710_n_", // isViewBlocking
|
|
||||||
"field_235711_o_", // hasPostProcess
|
|
||||||
"field_235712_p_" // emissiveRendering
|
|
||||||
).map(name -> ObfuscationReflectionHelper.remapName(INameMappingService.Domain.FIELD, name)).collect(Collectors.toSet());
|
|
||||||
targetClass.fields.removeIf(field -> {
|
|
||||||
if(fieldsToDelete.contains(field.name)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
for(MethodNode m : targetClass.methods) {
|
|
||||||
if(m.name.equals("<init>")) {
|
|
||||||
ListIterator<AbstractInsnNode> iter = m.instructions.iterator();
|
|
||||||
while(iter.hasNext()) {
|
|
||||||
AbstractInsnNode node = iter.next();
|
|
||||||
if(node.getOpcode() == Opcodes.PUTFIELD) {
|
|
||||||
if(fieldsToDelete.contains(((FieldInsnNode)node).name)) {
|
|
||||||
iter.remove();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if(mixinClassName.equals("org.embeddedt.modernfix.forge.valhesia.chunk_deadlock.bugfix.mixin.BlockStateBaseMixin")) {
|
|
||||||
// We need to destroy Valhelsia's callback so it can never run getBlockState
|
// We need to destroy Valhelsia's callback so it can never run getBlockState
|
||||||
for(MethodNode m : targetClass.methods) {
|
for(MethodNode m : targetClass.methods) {
|
||||||
if(m.name.contains("valhelsia_placeDousedTorch")) {
|
if(m.name.contains("valhelsia_placeDousedTorch")) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user