accesswideners B)

This commit is contained in:
dfsek 2021-02-24 13:14:21 -07:00
parent 2b114f225e
commit 1637644bdd
9 changed files with 15 additions and 74 deletions

View File

@ -31,6 +31,7 @@ configure<LoomGradleExtension> {
} }
tasks.register<RemapJarTask>("remapShadedJar") { tasks.register<RemapJarTask>("remapShadedJar") {
dependsOn("shadowJar")
setProperty("input", file("build/libs/Terra-fabric-${version}-shaded.jar")) setProperty("input", file("build/libs/Terra-fabric-${version}-shaded.jar"))
setProperty("addNestedDependencies", false) setProperty("addNestedDependencies", false)
setProperty("remapAccessWidener", true) setProperty("remapAccessWidener", true)

View File

@ -30,7 +30,6 @@ import com.dfsek.terra.config.lang.LangUtil;
import com.dfsek.terra.config.lang.Language; import com.dfsek.terra.config.lang.Language;
import com.dfsek.terra.config.pack.ConfigPack; import com.dfsek.terra.config.pack.ConfigPack;
import com.dfsek.terra.fabric.inventory.FabricItemHandle; import com.dfsek.terra.fabric.inventory.FabricItemHandle;
import com.dfsek.terra.fabric.mixin.GeneratorTypeAccessor;
import com.dfsek.terra.fabric.world.FabricBiome; import com.dfsek.terra.fabric.world.FabricBiome;
import com.dfsek.terra.fabric.world.FabricTree; import com.dfsek.terra.fabric.world.FabricTree;
import com.dfsek.terra.fabric.world.FabricWorldHandle; import com.dfsek.terra.fabric.world.FabricWorldHandle;
@ -299,8 +298,8 @@ public class TerraFabricPlugin implements TerraPlugin, ModInitializer {
} }
}; };
//noinspection ConstantConditions //noinspection ConstantConditions
((GeneratorTypeAccessor) generatorType).setTranslationKey(new LiteralText("Terra:" + pack.getTemplate().getID())); generatorType.translationKey = (new LiteralText("Terra:" + pack.getTemplate().getID()));
GeneratorTypeAccessor.getVALUES().add(generatorType); GeneratorType.VALUES.add(generatorType);
}); });
} }

View File

@ -1,34 +0,0 @@
package com.dfsek.terra.fabric.mixin;
import net.minecraft.client.world.GeneratorType;
import net.minecraft.text.Text;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Mutable;
import org.spongepowered.asm.mixin.gen.Accessor;
import java.util.List;
import java.util.Map;
import java.util.Optional;
@Mixin(GeneratorType.class)
public interface GeneratorTypeAccessor {
@Accessor
static List<GeneratorType> getVALUES() {
throw new AssertionError();
}
@Accessor
static Map<Optional<GeneratorType>, GeneratorType.ScreenProvider> getSCREEN_PROVIDERS() {
throw new UnsupportedOperationException();
}
@Mutable
@Accessor
static void setSCREEN_PROVIDERS(Map<Optional<GeneratorType>, GeneratorType.ScreenProvider> SCREEN_PROVIDERS) {
throw new UnsupportedOperationException();
}
@Mutable
@Accessor
void setTranslationKey(Text translationKey);
}

View File

@ -1,12 +0,0 @@
package com.dfsek.terra.fabric.mixin;
import net.minecraft.util.Identifier;
import net.minecraft.world.MobSpawnerLogic;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;
@Mixin(MobSpawnerLogic.class)
public interface MobSpawnerLogicAccessor {
@Invoker
Identifier callGetEntityId();
}

View File

@ -1,17 +0,0 @@
package com.dfsek.terra.fabric.mixin;
import net.minecraft.state.State;
import net.minecraft.state.property.Property;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
import java.util.Map;
import java.util.function.Function;
@Mixin(State.class)
public interface StateAccessor {
@Accessor
static Function<Map.Entry<Property<?>, Comparable<?>>, String> getPROPERTY_MAP_PRINTER() {
throw new UnsupportedOperationException();
}
}

View File

@ -2,9 +2,9 @@ package com.dfsek.terra.fabric.world.block;
import com.dfsek.terra.api.platform.block.BlockData; import com.dfsek.terra.api.platform.block.BlockData;
import com.dfsek.terra.api.platform.block.BlockType; import com.dfsek.terra.api.platform.block.BlockType;
import com.dfsek.terra.fabric.mixin.StateAccessor;
import com.dfsek.terra.fabric.world.FabricAdapter; import com.dfsek.terra.fabric.world.FabricAdapter;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.state.State;
import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.Registry;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -40,7 +40,7 @@ public class FabricBlockData implements BlockData {
StringBuilder data = new StringBuilder(Registry.BLOCK.getId(delegate.getBlock()).toString()); StringBuilder data = new StringBuilder(Registry.BLOCK.getId(delegate.getBlock()).toString());
if(!delegate.getEntries().isEmpty()) { if(!delegate.getEntries().isEmpty()) {
data.append('['); data.append('[');
data.append(delegate.getEntries().entrySet().stream().map(StateAccessor.getPROPERTY_MAP_PRINTER()).collect(Collectors.joining(","))); data.append(delegate.getEntries().entrySet().stream().map(State.PROPERTY_MAP_PRINTER).collect(Collectors.joining(",")));
data.append(']'); data.append(']');
} }
return data.toString(); return data.toString();

View File

@ -4,7 +4,6 @@ import com.dfsek.terra.api.platform.block.state.MobSpawner;
import com.dfsek.terra.api.platform.block.state.SerialState; import com.dfsek.terra.api.platform.block.state.SerialState;
import com.dfsek.terra.api.platform.entity.EntityType; import com.dfsek.terra.api.platform.entity.EntityType;
import com.dfsek.terra.fabric.TerraFabricPlugin; import com.dfsek.terra.fabric.TerraFabricPlugin;
import com.dfsek.terra.fabric.mixin.MobSpawnerLogicAccessor;
import com.dfsek.terra.fabric.world.FabricAdapter; import com.dfsek.terra.fabric.world.FabricAdapter;
import net.minecraft.block.entity.MobSpawnerBlockEntity; import net.minecraft.block.entity.MobSpawnerBlockEntity;
import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.Registry;
@ -20,7 +19,7 @@ public class FabricMobSpawner extends FabricBlockState implements MobSpawner { /
@Override @Override
public EntityType getSpawnedType() { public EntityType getSpawnedType() {
return FabricAdapter.adapt(Registry.ENTITY_TYPE.get(((MobSpawnerLogicAccessor) ((MobSpawnerBlockEntity) blockEntity).getLogic()).callGetEntityId())); return FabricAdapter.adapt(Registry.ENTITY_TYPE.get(((MobSpawnerBlockEntity) blockEntity).getLogic().getEntityId()));
} }
@Override @Override

View File

@ -2,5 +2,13 @@ accessWidener v1 named
extendable method net/minecraft/client/world/GeneratorType <init> (Ljava/lang/String;)V extendable method net/minecraft/client/world/GeneratorType <init> (Ljava/lang/String;)V
accessible field net/minecraft/client/world/GeneratorType translationKey Lnet/minecraft/text/Text;
mutable field net/minecraft/client/world/GeneratorType translationKey Lnet/minecraft/text/Text;
accessible field net/minecraft/client/world/GeneratorType VALUES Ljava/util/List;
accessible field net/minecraft/server/world/ServerWorld worldProperties Lnet/minecraft/world/level/ServerWorldProperties; accessible field net/minecraft/server/world/ServerWorld worldProperties Lnet/minecraft/world/level/ServerWorldProperties;
mutable field net/minecraft/server/world/ServerWorld worldProperties Lnet/minecraft/world/level/ServerWorldProperties;
accessible method net/minecraft/world/MobSpawnerLogic getEntityId ()Lnet/minecraft/util/Identifier;
accessible field net/minecraft/state/State PROPERTY_MAP_PRINTER Ljava/util/function/Function;

View File

@ -4,11 +4,8 @@
"package": "com.dfsek.terra.fabric.mixin", "package": "com.dfsek.terra.fabric.mixin",
"compatibilityLevel": "JAVA_8", "compatibilityLevel": "JAVA_8",
"mixins": [ "mixins": [
"MobSpawnerLogicAccessor",
"StateAccessor"
], ],
"client": [ "client": [
"GeneratorTypeAccessor"
], ],
"server": [], "server": [],
"injectors": { "injectors": {