Skip to content
This repository has been archived by the owner on Aug 25, 2024. It is now read-only.

Commit

Permalink
Merge pull request #29 from Ladysnake/1.16
Browse files Browse the repository at this point in the history
Illuminations client only overhaul release
  • Loading branch information
doctor4t authored Jul 22, 2020
2 parents 1ffc8f5 + 1d1578f commit 8aed1f1
Show file tree
Hide file tree
Showing 102 changed files with 1,181 additions and 2,218 deletions.
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
# Illuminations - Changelog

### Illuminations 0.5.1 - 20w06a
### Illuminations 1.0 - 1.16.1
The great overhaul is here! Illuminations is now client only for better performance, spawn control, and the ability to connect to vanilla servers with it.
- Illuminations are now particles instead of entities, enjoy being able having ten million fireflies without your server committing seppuku
- Fireflies will now appear regularly in varying quantities depending on the various biomes instead of clouds
- Added glowworms, illuminations that will stick to cave ceilings
- Added glowing plankton, illuminations that will spawn in the dark sea depths
- Removed firefly grass and firefly lantern blocks, glowmeal and firefly items and firefly grass world features
- Introduced auras, special Illuminations effects around the player visible to other players that have the mod. These auras are currently a bonus for donators but some may be available through giveaways and other special events in the future.
- Added the Twilight aura

### Illuminations 0.5.1 - 1.16.1
- Updated to Minecraft 1.16.1 (thanks to Bulldog83 for the contribution!)

### Illuminations 0.5 - 20w06a
Expand Down
Binary file added README.assets/illuminations-1.0-fireflies.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added README.assets/illuminations-1.0-glowworms.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added README.assets/illuminations-1.0-plankton.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
53 changes: 53 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Illuminations

**Illuminations** is a client sided Minecraft Fabric mod that adds multiple ambient particles in order to make your world more enjoyable at night or in dark places.

## Illuminations types

### Fireflies

**Fireflies** are small flying insects that come out during the night and disappear when the sun rises. They will appear in small quantities in jungle, plains, savanna and taiga type biomes, medium quantities in forest and river type biomes and great quantity in swamp type biomes.![illuminations-1.0-fireflies](README.assets/illuminations-1.0-fireflies.png)

### Glowworms

**Glowworms** are small larvae living in caves by sticking to the ceiling that will fall down if their support block is removed. They will appear in small quantities in jungle, plains, savanna and taiga type biomes, medium quantities in forest and river type biomes and great quantity in swamp type biomes.

![illuminations-1.0-glowworms](README.assets/illuminations-1.0-glowworms.png)

### Plankton

Glowing **plankton** - even though difficult to notice because of its size - can be found floating around in the dark parts of the oceanic depths. They appear in any ocean biome as long as the light is sufficiently low.

![illuminations-1.0-plankton](README.assets/illuminations-1.0-plankton.png)

## Auras

**Auras** are special Illuminations effects around the player visible to other players that have the mod. Auras currently serve as a bonus for donators that support the mod and are purely cosmetic with no other provided advantage whatsoever. They are visible to other players with Illuminations installed (even on vanilla servers).

### Twilight aura

The **Twilight** aura creates magenta colored fireflies that will orbit around the player. If the player moves, they will leave a trail of these fireflies.

![illuminations-1.0-twilight-aura](README.assets/illuminations-1.0-twilight-aura.gif)

## FAQ

#### Can I include this mod in a modpack?

**Yes**: You can. Go ahead, don't bother asking. Please however provide credit and a link to either the GitHub repository or Curse Forge project page.

#### Can I use this mod on a vanilla server?

**Yes**: If you have installed this mod on your Minecraft client, you will be able to connect to vanilla Minecraft servers and the ambient illuminations will work as intended.

#### Are auras visible to other players?

**Yes**: If the player has the mod installed on their client, your aura will be visible to them, just like their aura will be visible to you if they possess one.

#### How to get an aura?

**Auras are currently only available to donators**, if they have donated more than 1$.

#### I wish to support the mod and get an aura. What steps do I need to follow?

In order to get an aura, you will need to make a PayPal donation by following [this link](https://www.paypal.com/donate/?token=khJOtftVs9CuPqxETbT8q2MyRlCrQXkpw-iOaI9NOPJSOpQouUb2Xg1uOifF8ZZDkSoi-W&Z3JncnB0) or via the Curse Forge donate button available on the project page. **When making your donation, please include your Minecraft UUID as well as a valid email address (so I may contact you in case of any problem) in your message.** All donations and aura attributions are manually processed and done as soon as possible, but may take up to a day so please be patient.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ loader_version=0.9.0+build.204
fabric_version=0.14.1+build.372-1.16

# Mod Properties
mod_version = 0.5.1
mod_version = 1.0
maven_group = io.github.ladysnake
archives_base_name = illuminations

Expand Down
32 changes: 32 additions & 0 deletions src/main/java/ladysnake/illuminations/client/AuraData.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package ladysnake.illuminations.client;

import net.minecraft.particle.DefaultParticleType;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;

import java.util.Random;
import java.util.function.BiPredicate;
import java.util.function.Predicate;

public class AuraData {
private final DefaultParticleType particle;
private final float chance;

public AuraData(DefaultParticleType particle, float chance) {
this.particle = particle;
this.chance = chance;
}

public DefaultParticleType getParticle() {
return particle;
}

public float getChance() {
return chance;
}

public boolean shouldAddParticle(Random random) {
float rand = random.nextFloat();
return rand <= this.chance;
}
}
43 changes: 43 additions & 0 deletions src/main/java/ladysnake/illuminations/client/IlluminationData.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package ladysnake.illuminations.client;

import net.minecraft.particle.DefaultParticleType;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;

import java.util.Random;
import java.util.function.BiPredicate;
import java.util.function.Predicate;

public class IlluminationData {
private final DefaultParticleType illuminationType;
private final Predicate<Long> timeSpawnPredicate;
private final BiPredicate<World, BlockPos> locationSpawnPredicate;
private final float chance;

public IlluminationData(DefaultParticleType illuminationType, Predicate<Long> timeSpawnPredicate, BiPredicate<World, BlockPos> locationSpawnPredicate, float chance) {
this.illuminationType = illuminationType;
this.timeSpawnPredicate = timeSpawnPredicate;
this.locationSpawnPredicate = locationSpawnPredicate;
this.chance = chance;
}

public DefaultParticleType getIlluminationType() {
return illuminationType;
}

public Predicate<Long> getTimeSpawnPredicate() {
return timeSpawnPredicate;
}

public BiPredicate<World, BlockPos> getLocationSpawnPredicate() {
return locationSpawnPredicate;
}

public float getChance() {
return chance;
}

public boolean shouldAddParticle(Random random) {
return random.nextFloat() <= this.chance;
}
}
140 changes: 112 additions & 28 deletions src/main/java/ladysnake/illuminations/client/IlluminationsClient.java
Original file line number Diff line number Diff line change
@@ -1,47 +1,131 @@
package ladysnake.illuminations.client;

import ladysnake.illuminations.client.renders.entities.FireflyRender;
import ladysnake.illuminations.common.init.IlluminationsBlocks;
import ladysnake.illuminations.common.init.IlluminationsEntities;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
import ladysnake.illuminations.client.particle.FireflyParticle;
import ladysnake.illuminations.client.particle.GlowwormParticle;
import ladysnake.illuminations.client.particle.PlanktonParticle;
import ladysnake.illuminations.client.particle.aura.TwilightFireflyParticle;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
import net.fabricmc.fabric.api.client.rendereregistry.v1.EntityRendererRegistry;
import net.fabricmc.fabric.api.client.rendering.v1.ColorProviderRegistry;
import net.fabricmc.fabric.api.client.particle.v1.ParticleFactoryRegistry;
import net.fabricmc.fabric.api.particle.v1.FabricParticleTypes;
import net.minecraft.block.Blocks;
import net.minecraft.client.color.block.BlockColorProvider;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.particle.DefaultParticleType;
import net.minecraft.tag.FluidTags;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.lang.reflect.Type;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Map;
import java.util.UUID;
import java.util.function.BiPredicate;
import java.util.function.Predicate;

@Environment(EnvType.CLIENT)
public class IlluminationsClient implements ClientModInitializer {
public static final Logger logger = LogManager.getLogger("Illuminations");

// illuminations auras
private static final String URL = "https://illuminations.glitch.me/auras.json";
private static final Gson GSON = new GsonBuilder().create();
private static final Type AURA_SELECT_TYPE = new TypeToken<Map<UUID, String>>(){}.getType();
public static ImmutableMap<UUID, String> PLAYER_AURAS;
public static ImmutableMap<String, AuraData> AURAS_DATA;

// particle types
public static DefaultParticleType FIREFLY;
public static DefaultParticleType GLOWWORM;
public static DefaultParticleType PLANKTON;

// aura particle types
public static DefaultParticleType TWILIGHT_AURA;

// spawn biomes
public static ImmutableMap<Biome.Category, ImmutableSet<IlluminationData>> ILLUMINATIONS_BIOME_CATEGORIES;

// spawn predicates
public static final Predicate<Long> FIREFLY_TIME_PREDICATE = aLong -> !(aLong >= 1000 && aLong < 13000);
public static final BiPredicate<World, BlockPos> FIREFLY_LOCATION_PREDICATE = (world, blockPos) -> world.getBlockState(blockPos).getBlock() == Blocks.AIR;
public static final Predicate<Long> GLOWWORM_TIME_PREDICATE = aLong -> true;
public static final BiPredicate<World, BlockPos> GLOWWORM_LOCATION_PREDICATE = (world, blockPos) -> world.getBlockState(blockPos).getBlock() == Blocks.CAVE_AIR;
public static final Predicate<Long> PLANKTON_TIME_PREDICATE = aLong -> true;
public static final BiPredicate<World, BlockPos> PLANKTON_LOCATION_PREDICATE = (world, blockPos) -> world.getBlockState(blockPos).getFluidState().isIn(FluidTags.WATER) && world.getLightLevel(blockPos) < 2;

@Override
public void onInitializeClient() {
registerRenders();
registerColors();
registerCutouts();
}
// get illuminations users
getUsers();

public static void registerRenders() {
EntityRendererRegistry.INSTANCE.register(IlluminationsEntities.FIREFLY, (manager, context) -> new FireflyRender<>(manager));
}
// particles
FIREFLY = Registry.register(Registry.PARTICLE_TYPE, "illuminations:firefly", FabricParticleTypes.simple(true));
ParticleFactoryRegistry.getInstance().register(IlluminationsClient.FIREFLY, FireflyParticle.DefaultFactory::new);
GLOWWORM = Registry.register(Registry.PARTICLE_TYPE, "illuminations:glowworm", FabricParticleTypes.simple(true));
ParticleFactoryRegistry.getInstance().register(IlluminationsClient.GLOWWORM, GlowwormParticle.DefaultFactory::new);
PLANKTON = Registry.register(Registry.PARTICLE_TYPE, "illuminations:plankton", FabricParticleTypes.simple(true));
ParticleFactoryRegistry.getInstance().register(IlluminationsClient.PLANKTON, PlanktonParticle.DefaultFactory::new);

// aura particles
TWILIGHT_AURA = Registry.register(Registry.PARTICLE_TYPE, "illuminations:twilight_aura", FabricParticleTypes.simple(true));
ParticleFactoryRegistry.getInstance().register(IlluminationsClient.TWILIGHT_AURA, TwilightFireflyParticle.DefaultFactory::new);

// spawn biomes for Illuminations
ILLUMINATIONS_BIOME_CATEGORIES = ImmutableMap.<Biome.Category, ImmutableSet<IlluminationData>>builder()
.put(Biome.Category.JUNGLE, ImmutableSet.of(
new IlluminationData(FIREFLY, FIREFLY_TIME_PREDICATE, FIREFLY_LOCATION_PREDICATE, 0.00002F), // few
new IlluminationData(GLOWWORM, GLOWWORM_TIME_PREDICATE, GLOWWORM_LOCATION_PREDICATE, 0.00004F))) // few
.put(Biome.Category.PLAINS, ImmutableSet.of(
new IlluminationData(FIREFLY, FIREFLY_TIME_PREDICATE, FIREFLY_LOCATION_PREDICATE, 0.00002F), // few
new IlluminationData(GLOWWORM, GLOWWORM_TIME_PREDICATE, GLOWWORM_LOCATION_PREDICATE, 0.00004F))) // few
.put(Biome.Category.SAVANNA, ImmutableSet.of(
new IlluminationData(FIREFLY, FIREFLY_TIME_PREDICATE, FIREFLY_LOCATION_PREDICATE, 0.00002F), // few
new IlluminationData(GLOWWORM, GLOWWORM_TIME_PREDICATE, GLOWWORM_LOCATION_PREDICATE, 0.00004F))) // few
.put(Biome.Category.TAIGA, ImmutableSet.of(
new IlluminationData(FIREFLY, FIREFLY_TIME_PREDICATE, FIREFLY_LOCATION_PREDICATE, 0.00002F), // few
new IlluminationData(GLOWWORM, GLOWWORM_TIME_PREDICATE, GLOWWORM_LOCATION_PREDICATE, 0.00004F))) // few
.put(Biome.Category.FOREST, ImmutableSet.of(
new IlluminationData(FIREFLY, FIREFLY_TIME_PREDICATE, FIREFLY_LOCATION_PREDICATE, 0.00010F), // some
new IlluminationData(GLOWWORM, GLOWWORM_TIME_PREDICATE, GLOWWORM_LOCATION_PREDICATE, 0.00020F))) // some
.put(Biome.Category.RIVER, ImmutableSet.of(
new IlluminationData(FIREFLY, FIREFLY_TIME_PREDICATE, FIREFLY_LOCATION_PREDICATE, 0.00010F), // some
new IlluminationData(GLOWWORM, GLOWWORM_TIME_PREDICATE, GLOWWORM_LOCATION_PREDICATE, 0.00020F))) // some
.put(Biome.Category.SWAMP, ImmutableSet.of(
new IlluminationData(FIREFLY, FIREFLY_TIME_PREDICATE, FIREFLY_LOCATION_PREDICATE, 0.00025F), // many
new IlluminationData(GLOWWORM, GLOWWORM_TIME_PREDICATE, GLOWWORM_LOCATION_PREDICATE, 0.00050F))) // many
.put(Biome.Category.OCEAN, ImmutableSet.of(
new IlluminationData(PLANKTON, PLANKTON_TIME_PREDICATE, PLANKTON_LOCATION_PREDICATE, 0.00250F) // many
))
.build();

public static void registerColors() {
ColorProviderRegistry.BLOCK.register((block, pos, world, layer) -> {
BlockColorProvider provider = ColorProviderRegistry.BLOCK.get(Blocks.GRASS);
return provider == null ? -1 : provider.getColor(block, pos, world, layer);
}, IlluminationsBlocks.FIREFLY_GRASS);
ColorProviderRegistry.BLOCK.register((block, pos, world, layer) -> {
BlockColorProvider provider = ColorProviderRegistry.BLOCK.get(Blocks.GRASS);
return provider == null ? -1 : provider.getColor(block, pos, world, layer);
}, IlluminationsBlocks.FIREFLY_TALL_GRASS);
// aura spawn chances
AURAS_DATA = ImmutableMap.<String, AuraData>builder()
.put("twilight", new AuraData(TWILIGHT_AURA, 0.1f))
.build();
}

public static void registerCutouts() {
BlockRenderLayerMap.INSTANCE.putBlock(IlluminationsBlocks.FIREFLY_GRASS, RenderLayer.getCutout());
BlockRenderLayerMap.INSTANCE.putBlock(IlluminationsBlocks.FIREFLY_TALL_GRASS, RenderLayer.getCutout());
BlockRenderLayerMap.INSTANCE.putBlock(IlluminationsBlocks.FIREFLY_IN_A_BOTTLE, RenderLayer.getCutout());
public static void getUsers() {
try(Reader reader = new InputStreamReader(new URL(URL).openStream())) {
PLAYER_AURAS = ImmutableMap.copyOf((Map<? extends UUID, ? extends String>) GSON.fromJson(reader, AURA_SELECT_TYPE));
logger.log(Level.INFO, "Illuminations player auras retrieved");
} catch (MalformedURLException e) {
logger.log(Level.ERROR, "Could not get Illuminations player auras because of malformed URL: " + e.getMessage());
} catch (IOException e) {
logger.log(Level.ERROR, "Could not get Illuminations player auras because of I/O Error: " + e.getMessage());
}
}

}
Loading

0 comments on commit 8aed1f1

Please sign in to comment.