Search in sources :

Example 36 with Identifier

use of net.minecraft.util.Identifier in project fabricskyboxes by AMereBagatelle.

the class SkyboxResourceListener method reload.

@Override
public void reload(ResourceManager manager) {
    SkyboxManager skyboxManager = SkyboxManager.getInstance();
    // clear registered skyboxes on reload
    skyboxManager.clearSkyboxes();
    // load new skyboxes
    Collection<Identifier> resources = manager.findResources("sky", (string) -> string.endsWith(".json"));
    for (Identifier id : resources) {
        Resource resource;
        try {
            resource = manager.getResource(id);
            try {
                JsonObject json = GSON.fromJson(new InputStreamReader(resource.getInputStream()), JsonObject.class);
                objectWrapper.setFocusedObject(json);
                AbstractSkybox skybox = this.parseSkyboxJson(id);
                if (skybox != null) {
                    skyboxManager.addSkybox(skybox);
                }
            } finally {
                try {
                    resource.close();
                } catch (IOException e) {
                    FabricSkyBoxesClient.getLogger().error("Error closing resource " + id.toString());
                    e.printStackTrace();
                }
            }
        } catch (IOException e) {
            FabricSkyBoxesClient.getLogger().error("Error reading skybox " + id.toString());
            e.printStackTrace();
        }
    }
}
Also used : Identifier(net.minecraft.util.Identifier) AbstractSkybox(io.github.amerebagatelle.fabricskyboxes.skyboxes.AbstractSkybox) InputStreamReader(java.io.InputStreamReader) SkyboxManager(io.github.amerebagatelle.fabricskyboxes.SkyboxManager) Resource(net.minecraft.resource.Resource) JsonObject(com.google.gson.JsonObject) IOException(java.io.IOException)

Example 37 with Identifier

use of net.minecraft.util.Identifier in project fabricskyboxes by AMereBagatelle.

the class SkyboxGenerationTest method init.

@Test
public void init() throws IOException {
    DefaultProperties props = new DefaultProperties.Builder().changesFog().rotates().rotation(new Rotation(new Vec3f(0.1F, 0.0F, 0.1F), new Vec3f(0.0F, 0.0F, 0.0F), 1)).maxAlpha(0.99F).transitionSpeed(0.7F).fade(new Fade(1000, 2000, 11000, 12000, false)).build();
    Conditions conditions = new Conditions.Builder().biomes(new Identifier("minecraft:plains")).worlds(new Identifier("minecraft:overworld")).weather(Weather.CLEAR).yRanges(new MinMaxEntry(40, 120)).build();
    Decorations decorations = new Decorations(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, SpriteAtlasTexture.PARTICLE_ATLAS_TEXTURE, true, true, false, Rotation.DEFAULT);
    Gson gson = new GsonBuilder().setPrettyPrinting().serializeNulls().setLenient().create();
    this.test(gson, MonoColorSkybox.CODEC, new MonoColorSkybox(props, conditions, decorations, new RGBA(0.5F, 0.8F, 0.6F, 0.99F)));
    this.test(gson, SquareTexturedSkybox.CODEC, new SquareTexturedSkybox(props, conditions, decorations, Blend.DEFAULT, new Textures(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, PlayerScreenHandler.EMPTY_BOOTS_SLOT_TEXTURE, PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, PlayerScreenHandler.EMPTY_OFFHAND_ARMOR_SLOT, PlayerScreenHandler.EMPTY_BOOTS_SLOT_TEXTURE, new Identifier("missingno"))));
    this.test(gson, AnimatedSquareTexturedSkybox.CODEC, new AnimatedSquareTexturedSkybox(props, conditions, decorations, Blend.DEFAULT, Arrays.asList(new Textures(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, PlayerScreenHandler.EMPTY_BOOTS_SLOT_TEXTURE, PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, PlayerScreenHandler.EMPTY_OFFHAND_ARMOR_SLOT, PlayerScreenHandler.EMPTY_BOOTS_SLOT_TEXTURE, new Identifier("missingno")), new Textures(SpriteAtlasTexture.PARTICLE_ATLAS_TEXTURE, SpriteAtlasTexture.PARTICLE_ATLAS_TEXTURE, SpriteAtlasTexture.PARTICLE_ATLAS_TEXTURE, SpriteAtlasTexture.PARTICLE_ATLAS_TEXTURE, new Identifier("missingno"), SpriteAtlasTexture.PARTICLE_ATLAS_TEXTURE), new Textures(SpriteAtlasTexture.PARTICLE_ATLAS_TEXTURE, PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, SpriteAtlasTexture.PARTICLE_ATLAS_TEXTURE, SpriteAtlasTexture.PARTICLE_ATLAS_TEXTURE, SpriteAtlasTexture.PARTICLE_ATLAS_TEXTURE)), 0.2F));
}
Also used : GsonBuilder(com.google.gson.GsonBuilder) Gson(com.google.gson.Gson) AnimatedSquareTexturedSkybox(io.github.amerebagatelle.fabricskyboxes.skyboxes.textured.AnimatedSquareTexturedSkybox) Vec3f(net.minecraft.util.math.Vec3f) Identifier(net.minecraft.util.Identifier) SquareTexturedSkybox(io.github.amerebagatelle.fabricskyboxes.skyboxes.textured.SquareTexturedSkybox) AnimatedSquareTexturedSkybox(io.github.amerebagatelle.fabricskyboxes.skyboxes.textured.AnimatedSquareTexturedSkybox) MonoColorSkybox(io.github.amerebagatelle.fabricskyboxes.skyboxes.MonoColorSkybox) Test(org.junit.jupiter.api.Test)

Example 38 with Identifier

use of net.minecraft.util.Identifier in project bewitchment by MoriyaShiine.

the class BWWorldGenerators method init.

public static void init() {
    Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, new Identifier(Bewitchment.MODID, "juniper_tree"), JUNIPER_TREE);
    Registry.register(BuiltinRegistries.PLACED_FEATURE, new Identifier(Bewitchment.MODID, "juniper_tree"), JUNIPER_TREE_WITH_CHANCE);
    Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, new Identifier(Bewitchment.MODID, "cypress_tree"), CYPRESS_TREE);
    Registry.register(BuiltinRegistries.PLACED_FEATURE, new Identifier(Bewitchment.MODID, "cypress_tree"), CYPRESS_TREE_WITH_CHANCE);
    Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, new Identifier(Bewitchment.MODID, "elder_tree"), ELDER_TREE);
    Registry.register(BuiltinRegistries.PLACED_FEATURE, new Identifier(Bewitchment.MODID, "elder_tree"), ELDER_TREE_WITH_CHANCE);
    Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, new Identifier(Bewitchment.MODID, "silver_ore"), SILVER_ORE);
    Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, new Identifier(Bewitchment.MODID, "silver_ore_buried"), SILVER_ORE_BURIED);
    Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, new Identifier(Bewitchment.MODID, "salt_ore"), SALT_ORE);
    Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, new Identifier(Bewitchment.MODID, "salt_ore_buried"), SALT_ORE_BURIED);
    Registry.register(BuiltinRegistries.PLACED_FEATURE, new Identifier(Bewitchment.MODID, "silver_ore_upper"), SILVER_ORE_UPPER);
    Registry.register(BuiltinRegistries.PLACED_FEATURE, new Identifier(Bewitchment.MODID, "silver_ore_lower"), SILVER_ORE_LOWER);
    Registry.register(BuiltinRegistries.PLACED_FEATURE, new Identifier(Bewitchment.MODID, "salt_ore_upper"), SALT_ORE_UPPER);
    Registry.register(BuiltinRegistries.PLACED_FEATURE, new Identifier(Bewitchment.MODID, "salt_ore_lower"), SALT_ORE_LOWER);
    BiomeModification worldGen = BiomeModifications.create(new Identifier(Bewitchment.MODID, "world_features"));
    worldGen.add(ModificationPhase.ADDITIONS, BiomeSelectors.categories(Biome.Category.SAVANNA), context -> context.getGenerationSettings().addBuiltInFeature(GenerationStep.Feature.VEGETAL_DECORATION, JUNIPER_TREE_WITH_CHANCE));
    worldGen.add(ModificationPhase.ADDITIONS, BiomeSelectors.categories(Biome.Category.TAIGA, Biome.Category.SWAMP), context -> context.getGenerationSettings().addBuiltInFeature(GenerationStep.Feature.VEGETAL_DECORATION, CYPRESS_TREE_WITH_CHANCE));
    worldGen.add(ModificationPhase.ADDITIONS, BiomeSelectors.categories(Biome.Category.FOREST), context -> context.getGenerationSettings().addBuiltInFeature(GenerationStep.Feature.VEGETAL_DECORATION, ELDER_TREE_WITH_CHANCE));
    worldGen.add(ModificationPhase.ADDITIONS, foundInOverworld(), context -> {
        if (Bewitchment.config.generateSilver) {
            context.getGenerationSettings().addBuiltInFeature(GenerationStep.Feature.UNDERGROUND_ORES, SILVER_ORE_UPPER);
            context.getGenerationSettings().addBuiltInFeature(GenerationStep.Feature.UNDERGROUND_ORES, SILVER_ORE_LOWER);
        }
        if (Bewitchment.config.generateSalt) {
            context.getGenerationSettings().addBuiltInFeature(GenerationStep.Feature.UNDERGROUND_ORES, SALT_ORE_UPPER);
            context.getGenerationSettings().addBuiltInFeature(GenerationStep.Feature.UNDERGROUND_ORES, SALT_ORE_LOWER);
        }
    });
    if (registerEntitySpawn(BWEntityTypes.OWL, foundInOverworld().and(context -> Bewitchment.config.owlBiomeCategories.contains(context.getBiome().getCategory().getName())), Bewitchment.config.owlWeight, Bewitchment.config.owlMinGroupCount, Bewitchment.config.owlMaxGroupCount)) {
        SpawnRestrictionAccessor.callRegister(BWEntityTypes.OWL, SpawnRestriction.Location.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, AnimalEntity::isValidNaturalSpawn);
    }
    if (registerEntitySpawn(BWEntityTypes.RAVEN, foundInOverworld().and(context -> Bewitchment.config.ravenBiomeCategories.contains(context.getBiome().getCategory().getName())), Bewitchment.config.ravenWeight, Bewitchment.config.ravenMinGroupCount, Bewitchment.config.ravenMaxGroupCount)) {
        SpawnRestrictionAccessor.callRegister(BWEntityTypes.RAVEN, SpawnRestriction.Location.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, AnimalEntity::isValidNaturalSpawn);
    }
    if (registerEntitySpawn(BWEntityTypes.SNAKE, foundInOverworld().and(context -> Bewitchment.config.snakeBiomeCategories.contains(context.getBiome().getCategory().getName())), Bewitchment.config.snakeWeight, Bewitchment.config.snakeMinGroupCount, Bewitchment.config.snakeMaxGroupCount)) {
        SpawnRestrictionAccessor.callRegister(BWEntityTypes.SNAKE, SpawnRestriction.Location.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, AnimalEntity::isValidNaturalSpawn);
    }
    if (registerEntitySpawn(BWEntityTypes.TOAD, foundInOverworld().and(context -> Bewitchment.config.toadBiomeCategories.contains(context.getBiome().getCategory().getName())), Bewitchment.config.toadWeight, Bewitchment.config.toadMinGroupCount, Bewitchment.config.toadMaxGroupCount)) {
        SpawnRestrictionAccessor.callRegister(BWEntityTypes.TOAD, SpawnRestriction.Location.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, AnimalEntity::isValidNaturalSpawn);
    }
    if (registerEntitySpawn(BWEntityTypes.GHOST, foundInOverworld().and(context -> !context.getBiome().getSpawnSettings().getSpawnEntries(BWEntityTypes.GHOST.getSpawnGroup()).isEmpty()), Bewitchment.config.ghostWeight, Bewitchment.config.ghostMinGroupCount, Bewitchment.config.ghostMaxGroupCount)) {
        SpawnRestrictionAccessor.callRegister(BWEntityTypes.GHOST, SpawnRestriction.Location.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, GhostEntity::canSpawn);
    }
    if (registerEntitySpawn(BWEntityTypes.VAMPIRE, foundInOverworld().and(context -> !context.getBiome().getSpawnSettings().getSpawnEntries(BWEntityTypes.VAMPIRE.getSpawnGroup()).isEmpty()).and(context -> context.getBiome().getCategory() == Biome.Category.TAIGA || context.getBiome().getCategory() == Biome.Category.PLAINS), Bewitchment.config.vampireWeight, Bewitchment.config.vampireMinGroupCount, Bewitchment.config.vampireMaxGroupCount)) {
        SpawnRestrictionAccessor.callRegister(BWEntityTypes.VAMPIRE, SpawnRestriction.Location.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, VampireEntity::canSpawn);
    }
    if (registerEntitySpawn(BWEntityTypes.WEREWOLF, foundInOverworld().and(context -> !context.getBiome().getSpawnSettings().getSpawnEntries(BWEntityTypes.WEREWOLF.getSpawnGroup()).isEmpty()).and(context -> context.getBiome().getCategory() == Biome.Category.TAIGA || context.getBiome().getCategory() == Biome.Category.FOREST), Bewitchment.config.werewolfWeight, Bewitchment.config.werewolfMinGroupCount, Bewitchment.config.werewolfMaxGroupCount)) {
        SpawnRestrictionAccessor.callRegister(BWEntityTypes.WEREWOLF, SpawnRestriction.Location.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, WerewolfEntity::canSpawn);
    }
    if (registerEntitySpawn(BWEntityTypes.HELLHOUND, BiomeSelectors.categories(Biome.Category.NETHER), Bewitchment.config.hellhoundWeight, Bewitchment.config.hellhoundMinGroupCount, Bewitchment.config.hellhoundMaxGroupCount)) {
        SpawnRestrictionAccessor.callRegister(BWEntityTypes.HELLHOUND, SpawnRestriction.Location.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, HellhoundEntity::canSpawn);
    }
    LootTableLoadingCallback.EVENT.register((resourceManager, lootManager, identifier, fabricLootSupplierBuilder, lootTableSetter) -> {
        Identifier seeds = new Identifier(Bewitchment.MODID, "inject/seeds");
        Identifier nether_fortress = new Identifier(Bewitchment.MODID, "inject/nether_fortress");
        if (Blocks.GRASS.getLootTableId().equals(identifier) || Blocks.TALL_GRASS.getLootTableId().equals(identifier) || Blocks.FERN.getLootTableId().equals(identifier) || Blocks.LARGE_FERN.getLootTableId().equals(identifier)) {
            fabricLootSupplierBuilder.withPool(LootPool.builder().with(LootTableEntry.builder(seeds).weight(1)).build());
        }
        if (LootTables.NETHER_BRIDGE_CHEST.equals(identifier)) {
            fabricLootSupplierBuilder.withPool(LootPool.builder().with(LootTableEntry.builder(nether_fortress).weight(1)).build());
        }
    });
}
Also used : WerewolfEntity(moriyashiine.bewitchment.common.entity.living.WerewolfEntity) EntityType(net.minecraft.entity.EntityType) VampireEntity(moriyashiine.bewitchment.common.entity.living.VampireEntity) SpawnRestriction(net.minecraft.entity.SpawnRestriction) MegaPineFoliagePlacer(net.minecraft.world.gen.foliage.MegaPineFoliagePlacer) SimpleBlockStateProviderAccessor(moriyashiine.bewitchment.mixin.SimpleBlockStateProviderAccessor) net.fabricmc.fabric.api.biome.v1(net.fabricmc.fabric.api.biome.v1) LootTableEntry(net.minecraft.loot.entry.LootTableEntry) RarityFilterPlacementModifier(net.minecraft.world.gen.decorator.RarityFilterPlacementModifier) StraightTrunkPlacer(net.minecraft.world.gen.trunk.StraightTrunkPlacer) SpawnRestrictionAccessor(net.fabricmc.fabric.mixin.object.builder.SpawnRestrictionAccessor) ConstantIntProvider(net.minecraft.util.math.intprovider.ConstantIntProvider) BuiltinRegistries(net.minecraft.util.registry.BuiltinRegistries) HellhoundEntity(moriyashiine.bewitchment.common.entity.living.HellhoundEntity) AnimalEntity(net.minecraft.entity.passive.AnimalEntity) YOffset(net.minecraft.world.gen.YOffset) FeatureSize(net.minecraft.world.gen.feature.size.FeatureSize) AcaciaFoliagePlacer(net.minecraft.world.gen.foliage.AcaciaFoliagePlacer) Bewitchment(moriyashiine.bewitchment.common.Bewitchment) LootTables(net.minecraft.loot.LootTables) Heightmap(net.minecraft.world.Heightmap) GhostEntity(moriyashiine.bewitchment.common.entity.living.GhostEntity) Predicate(java.util.function.Predicate) GenerationStep(net.minecraft.world.gen.GenerationStep) Blocks(net.minecraft.block.Blocks) Registry(net.minecraft.util.registry.Registry) LootTableLoadingCallback(net.fabricmc.fabric.api.loot.v1.event.LootTableLoadingCallback) LargeOakFoliagePlacer(net.minecraft.world.gen.foliage.LargeOakFoliagePlacer) ForkingTrunkPlacer(net.minecraft.world.gen.trunk.ForkingTrunkPlacer) net.minecraft.world.gen.feature(net.minecraft.world.gen.feature) List(java.util.List) UniformIntProvider(net.minecraft.util.math.intprovider.UniformIntProvider) LootPool(net.minecraft.loot.LootPool) OrePlacedFeaturesAccessor(moriyashiine.bewitchment.mixin.OrePlacedFeaturesAccessor) Identifier(net.minecraft.util.Identifier) HeightRangePlacementModifier(net.minecraft.world.gen.decorator.HeightRangePlacementModifier) Biome(net.minecraft.world.biome.Biome) CountPlacementModifier(net.minecraft.world.gen.decorator.CountPlacementModifier) TwoLayersFeatureSize(net.minecraft.world.gen.feature.size.TwoLayersFeatureSize) WerewolfEntity(moriyashiine.bewitchment.common.entity.living.WerewolfEntity) Identifier(net.minecraft.util.Identifier) HellhoundEntity(moriyashiine.bewitchment.common.entity.living.HellhoundEntity) VampireEntity(moriyashiine.bewitchment.common.entity.living.VampireEntity) AnimalEntity(net.minecraft.entity.passive.AnimalEntity) GhostEntity(moriyashiine.bewitchment.common.entity.living.GhostEntity)

Example 39 with Identifier

use of net.minecraft.util.Identifier in project bewitchment by MoriyaShiine.

the class BWEntityTypes method create.

private static <T extends LivingEntity> EntityType<T> create(String name, DefaultAttributeContainer.Builder attributes, EntityType<T> type) {
    FabricDefaultAttributeRegistry.register(type, attributes);
    ENTITY_TYPES.put(type, new Identifier(Bewitchment.MODID, name));
    return type;
}
Also used : Identifier(net.minecraft.util.Identifier)

Example 40 with Identifier

use of net.minecraft.util.Identifier in project bewitchment by MoriyaShiine.

the class BWRecipeTypes method create.

private static <T extends Recipe<?>> RecipeType<T> create(String name) {
    RecipeType<T> type = new RecipeType<>() {

        @Override
        public String toString() {
            return name;
        }
    };
    RECIPE_TYPES.put(type, new Identifier(Bewitchment.MODID, name));
    return type;
}
Also used : Identifier(net.minecraft.util.Identifier) RecipeType(net.minecraft.recipe.RecipeType)

Aggregations

Identifier (net.minecraft.util.Identifier)343 NbtList (net.minecraft.nbt.NbtList)36 ItemStack (net.minecraft.item.ItemStack)31 Item (net.minecraft.item.Item)28 NbtCompound (net.minecraft.nbt.NbtCompound)22 NbtElement (net.minecraft.nbt.NbtElement)22 Inject (org.spongepowered.asm.mixin.injection.Inject)22 IOException (java.io.IOException)18 Block (net.minecraft.block.Block)18 MinecraftClient (net.minecraft.client.MinecraftClient)15 BlockItem (net.minecraft.item.BlockItem)15 BlockPos (net.minecraft.util.math.BlockPos)15 Map (java.util.Map)12 BlockState (net.minecraft.block.BlockState)12 ArrayList (java.util.ArrayList)11 VertexConsumer (net.minecraft.client.render.VertexConsumer)11 ResourceManager (net.minecraft.resource.ResourceManager)11 SoundEvent (net.minecraft.sound.SoundEvent)11 ServerPlayerEntity (net.minecraft.server.network.ServerPlayerEntity)10 LiteralText (net.minecraft.text.LiteralText)10