mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-06-18 14:50:56 +00:00
replace most access wideners with mixins
This commit is contained in:
@@ -39,7 +39,8 @@ import com.dfsek.terra.config.pack.ConfigPack;
|
|||||||
import com.dfsek.terra.config.templates.BiomeTemplate;
|
import com.dfsek.terra.config.templates.BiomeTemplate;
|
||||||
import com.dfsek.terra.fabric.handle.FabricItemHandle;
|
import com.dfsek.terra.fabric.handle.FabricItemHandle;
|
||||||
import com.dfsek.terra.fabric.handle.FabricWorldHandle;
|
import com.dfsek.terra.fabric.handle.FabricWorldHandle;
|
||||||
import com.dfsek.terra.fabric.mixin.GeneratorTypeAccessor;
|
import com.dfsek.terra.fabric.mixin.access.BiomeEffectsAccessor;
|
||||||
|
import com.dfsek.terra.fabric.mixin.access.GeneratorTypeAccessor;
|
||||||
import com.dfsek.terra.fabric.world.TerraBiomeSource;
|
import com.dfsek.terra.fabric.world.TerraBiomeSource;
|
||||||
import com.dfsek.terra.fabric.world.features.PopulatorFeature;
|
import com.dfsek.terra.fabric.world.features.PopulatorFeature;
|
||||||
import com.dfsek.terra.fabric.world.generator.FabricChunkGeneratorWrapper;
|
import com.dfsek.terra.fabric.world.generator.FabricChunkGeneratorWrapper;
|
||||||
@@ -259,23 +260,23 @@ public class TerraFabricPlugin implements TerraPlugin, ModInitializer {
|
|||||||
generationSettings.feature(GenerationStep.Feature.VEGETAL_DECORATION, POPULATOR_CONFIGURED_FEATURE);
|
generationSettings.feature(GenerationStep.Feature.VEGETAL_DECORATION, POPULATOR_CONFIGURED_FEATURE);
|
||||||
|
|
||||||
|
|
||||||
|
BiomeEffectsAccessor accessor = (BiomeEffectsAccessor) vanilla.getEffects();
|
||||||
BiomeEffects.Builder effects = new BiomeEffects.Builder()
|
BiomeEffects.Builder effects = new BiomeEffects.Builder()
|
||||||
.waterColor(colors.getOrDefault("water", vanilla.getEffects().waterColor))
|
.waterColor(colors.getOrDefault("water", accessor.getWaterColor()))
|
||||||
.waterFogColor(colors.getOrDefault("water-fog", vanilla.getEffects().waterFogColor))
|
.waterFogColor(colors.getOrDefault("water-fog", accessor.getWaterFogColor()))
|
||||||
.fogColor(colors.getOrDefault("fog", vanilla.getEffects().fogColor))
|
.fogColor(colors.getOrDefault("fog", accessor.getFogColor()))
|
||||||
.skyColor(colors.getOrDefault("sky", vanilla.getEffects().skyColor))
|
.skyColor(colors.getOrDefault("sky", accessor.getSkyColor()))
|
||||||
.grassColorModifier(vanilla.getEffects().grassColorModifier);
|
.grassColorModifier(accessor.getGrassColorModifier());
|
||||||
|
|
||||||
if(colors.containsKey("grass")) {
|
if(colors.containsKey("grass")) {
|
||||||
effects.grassColor(colors.get("grass"));
|
effects.grassColor(colors.get("grass"));
|
||||||
} else {
|
} else {
|
||||||
vanilla.getEffects().grassColor.ifPresent(effects::grassColor);
|
accessor.getGrassColor().ifPresent(effects::grassColor);
|
||||||
}
|
}
|
||||||
vanilla.getEffects().foliageColor.ifPresent(effects::foliageColor);
|
|
||||||
if(colors.containsKey("foliage")) {
|
if(colors.containsKey("foliage")) {
|
||||||
effects.foliageColor(colors.get("foliage"));
|
effects.foliageColor(colors.get("foliage"));
|
||||||
} else {
|
} else {
|
||||||
vanilla.getEffects().foliageColor.ifPresent(effects::foliageColor);
|
accessor.getFoliageColor().ifPresent(effects::foliageColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Biome.Builder()
|
return new Biome.Builder()
|
||||||
@@ -328,7 +329,7 @@ public class TerraFabricPlugin implements TerraPlugin, ModInitializer {
|
|||||||
};
|
};
|
||||||
//noinspection ConstantConditions
|
//noinspection ConstantConditions
|
||||||
((GeneratorTypeAccessor) generatorType).setTranslationKey(new LiteralText("Terra:" + pack.getTemplate().getID()));
|
((GeneratorTypeAccessor) generatorType).setTranslationKey(new LiteralText("Terra:" + pack.getTemplate().getID()));
|
||||||
GeneratorTypeAccessor.getVALUES().add(generatorType);
|
GeneratorTypeAccessor.getValues().add(generatorType);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+31
@@ -0,0 +1,31 @@
|
|||||||
|
package com.dfsek.terra.fabric.mixin.access;
|
||||||
|
|
||||||
|
import net.minecraft.world.biome.BiomeEffects;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@Mixin(BiomeEffects.class)
|
||||||
|
public interface BiomeEffectsAccessor {
|
||||||
|
@Accessor("fogColor")
|
||||||
|
int getFogColor();
|
||||||
|
|
||||||
|
@Accessor("waterColor")
|
||||||
|
int getWaterColor();
|
||||||
|
|
||||||
|
@Accessor("waterFogColor")
|
||||||
|
int getWaterFogColor();
|
||||||
|
|
||||||
|
@Accessor("skyColor")
|
||||||
|
int getSkyColor();
|
||||||
|
|
||||||
|
@Accessor("foliageColor")
|
||||||
|
Optional<Integer> getFoliageColor();
|
||||||
|
|
||||||
|
@Accessor("grassColor")
|
||||||
|
Optional<Integer> getGrassColor();
|
||||||
|
|
||||||
|
@Accessor("grassColorModifier")
|
||||||
|
BiomeEffects.GrassColorModifier getGrassColorModifier();
|
||||||
|
}
|
||||||
+4
-4
@@ -1,4 +1,4 @@
|
|||||||
package com.dfsek.terra.fabric.mixin;
|
package com.dfsek.terra.fabric.mixin.access;
|
||||||
|
|
||||||
import net.minecraft.client.world.GeneratorType;
|
import net.minecraft.client.world.GeneratorType;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
@@ -10,12 +10,12 @@ import java.util.List;
|
|||||||
|
|
||||||
@Mixin(GeneratorType.class)
|
@Mixin(GeneratorType.class)
|
||||||
public interface GeneratorTypeAccessor {
|
public interface GeneratorTypeAccessor {
|
||||||
@Accessor
|
@Accessor("VALUES")
|
||||||
static List<GeneratorType> getVALUES() {
|
static List<GeneratorType> getValues() {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Mutable
|
@Mutable
|
||||||
@Accessor
|
@Accessor("translationKey")
|
||||||
void setTranslationKey(Text translationKey);
|
void setTranslationKey(Text translationKey);
|
||||||
}
|
}
|
||||||
+12
@@ -0,0 +1,12 @@
|
|||||||
|
package com.dfsek.terra.fabric.mixin.access;
|
||||||
|
|
||||||
|
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("getEntityId")
|
||||||
|
Identifier callGetEntityId();
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package com.dfsek.terra.fabric.mixin.access;
|
||||||
|
|
||||||
|
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("PROPERTY_MAP_PRINTER")
|
||||||
|
static Function<Map.Entry<Property<?>, Comparable<?>>, String> getPropertyMapPrinter() {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
}
|
||||||
+2
-1
@@ -4,6 +4,7 @@ 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.access.MobSpawnerLogicAccessor;
|
||||||
import net.minecraft.block.entity.MobSpawnerBlockEntity;
|
import net.minecraft.block.entity.MobSpawnerBlockEntity;
|
||||||
import net.minecraft.util.registry.Registry;
|
import net.minecraft.util.registry.Registry;
|
||||||
import net.minecraft.world.MobSpawnerLogic;
|
import net.minecraft.world.MobSpawnerLogic;
|
||||||
@@ -20,7 +21,7 @@ public abstract class MobSpawnerBlockEntityMixin {
|
|||||||
public abstract MobSpawnerLogic getLogic();
|
public abstract MobSpawnerLogic getLogic();
|
||||||
|
|
||||||
public EntityType terra$getSpawnedType() {
|
public EntityType terra$getSpawnedType() {
|
||||||
return (EntityType) Registry.ENTITY_TYPE.get(getLogic().getEntityId());
|
return (EntityType) Registry.ENTITY_TYPE.get(((MobSpawnerLogicAccessor) getLogic()).callGetEntityId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void terra$setSpawnedType(@NotNull EntityType creatureType) {
|
public void terra$setSpawnedType(@NotNull EntityType creatureType) {
|
||||||
|
|||||||
+2
-3
@@ -2,10 +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.world.FabricAdapter;
|
import com.dfsek.terra.fabric.mixin.access.StateAccessor;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.block.Blocks;
|
||||||
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;
|
||||||
@@ -41,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(State.PROPERTY_MAP_PRINTER).collect(Collectors.joining(",")));
|
data.append(delegate.getEntries().entrySet().stream().map(StateAccessor.getPropertyMapPrinter()).collect(Collectors.joining(",")));
|
||||||
data.append(']');
|
data.append(']');
|
||||||
}
|
}
|
||||||
return data.toString();
|
return data.toString();
|
||||||
|
|||||||
@@ -1,19 +1,3 @@
|
|||||||
accessWidener v1 named
|
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/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;
|
|
||||||
|
|
||||||
|
|
||||||
accessible field net/minecraft/world/biome/BiomeEffects fogColor I
|
|
||||||
accessible field net/minecraft/world/biome/BiomeEffects waterColor I
|
|
||||||
accessible field net/minecraft/world/biome/BiomeEffects waterFogColor I
|
|
||||||
accessible field net/minecraft/world/biome/BiomeEffects skyColor I
|
|
||||||
|
|
||||||
accessible field net/minecraft/world/biome/BiomeEffects foliageColor Ljava/util/Optional;
|
|
||||||
accessible field net/minecraft/world/biome/BiomeEffects grassColor Ljava/util/Optional;
|
|
||||||
accessible field net/minecraft/world/biome/BiomeEffects grassColorModifier Lnet/minecraft/world/biome/BiomeEffects$GrassColorModifier;
|
|
||||||
|
|||||||
@@ -5,6 +5,9 @@
|
|||||||
"compatibilityLevel": "JAVA_8",
|
"compatibilityLevel": "JAVA_8",
|
||||||
"mixins": [
|
"mixins": [
|
||||||
"GeneratorOptionsMixin",
|
"GeneratorOptionsMixin",
|
||||||
|
"access.BiomeEffectsAccessor",
|
||||||
|
"access.MobSpawnerLogicAccessor",
|
||||||
|
"access.StateAccessor",
|
||||||
"implementations.BiomeMixin",
|
"implementations.BiomeMixin",
|
||||||
"implementations.ChunkGeneratorMixin",
|
"implementations.ChunkGeneratorMixin",
|
||||||
"implementations.ConfiguredFeatureMixin",
|
"implementations.ConfiguredFeatureMixin",
|
||||||
@@ -30,7 +33,7 @@
|
|||||||
"implementations.world.ServerWorldMixin"
|
"implementations.world.ServerWorldMixin"
|
||||||
],
|
],
|
||||||
"client": [
|
"client": [
|
||||||
"GeneratorTypeAccessor"
|
"access.GeneratorTypeAccessor"
|
||||||
],
|
],
|
||||||
"server": [],
|
"server": [],
|
||||||
"injectors": {
|
"injectors": {
|
||||||
|
|||||||
Reference in New Issue
Block a user