Color provider mixin

This commit is contained in:
paulevsGitch 2021-07-10 16:18:05 +03:00
parent 5a9365e2bb
commit f4df53b171
4 changed files with 50 additions and 5 deletions

View file

@ -0,0 +1,46 @@
package ru.bclib.mixin.client;
import net.minecraft.client.Minecraft;
import net.minecraft.client.color.block.BlockColors;
import net.minecraft.client.color.item.ItemColors;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.gui.screens.WinScreen;
import net.minecraft.client.main.GameConfig;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.core.Registry;
import net.minecraft.sounds.Music;
import net.minecraft.sounds.Musics;
import net.minecraft.world.level.Level;
import org.spongepowered.asm.mixin.Final;
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.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import ru.bclib.interfaces.IColorProvider;
import ru.bclib.util.MHelper;
@Mixin(Minecraft.class)
public class MinecraftMixin {
@Final
@Shadow
private BlockColors blockColors;
@Final
@Shadow
private ItemColors itemColors;
@Inject(method = "<init>*", at = @At("TAIL"))
private void bclib_onMCInit(GameConfig args, CallbackInfo info) {
Registry.BLOCK.forEach(block -> {
if (block instanceof IColorProvider) {
IColorProvider provider = (IColorProvider) block;
blockColors.register(provider.getProvider(), block);
itemColors.register(provider.getItemProvider(), block.asItem());
}
});
}
}

View file

@ -19,9 +19,7 @@ public class BCLStructureFeature {
public BCLStructureFeature(ResourceLocation id, StructureFeature<NoneFeatureConfiguration> structure, GenerationStep.Decoration step, int spacing, int separation) {
this.featureStep = step;
this.structure = FabricStructureBuilder.create(id, structure).step(step).defaultConfig(spacing, separation, RANDOM.nextInt(8192)).register();
this.featureConfigured = this.structure.configured(NoneFeatureConfiguration.NONE);
BuiltinRegistries.register(BuiltinRegistries.CONFIGURED_STRUCTURE_FEATURE, id, this.featureConfigured);
FlatChunkGeneratorConfigAccessor.getStructureToFeatures().put(this.structure, this.featureConfigured);

View file

@ -2,11 +2,12 @@
"required": true,
"minVersion": "0.8",
"package": "ru.bclib.mixin.client",
"compatibilityLevel": "JAVA_8",
"compatibilityLevel": "JAVA_16",
"client": [
"EnchantingTableBlockMixin",
"BackgroundRendererMixin",
"ModelBakeryMixin"
"ModelBakeryMixin",
"MinecraftMixin"
],
"injectors": {
"defaultRequire": 1

View file

@ -2,7 +2,7 @@
"required": true,
"minVersion": "0.8",
"package": "ru.bclib.mixin.common",
"compatibilityLevel": "JAVA_8",
"compatibilityLevel": "JAVA_16",
"mixins": [
"ComposterBlockAccessor",
"PotionBrewingAccessor",