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();
}
}
}
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));
}
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());
}
});
}
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;
}
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;
}
Aggregations