Skip to content

Commit

Permalink
Version 1.5.0
Browse files Browse the repository at this point in the history
- Changes dimension configs from names to IDs
- Adds meteor dimension config
  • Loading branch information
democat3457 committed Jun 8, 2021
1 parent 079c3ff commit 56075f1
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 20 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ buildscript {
apply plugin: 'net.minecraftforge.gradle.forge'
apply plugin: 'maven'

version = "1.4.6"
version = "1.5.0"
group = "de.ellpeck.nyx"
archivesBaseName = "Nyx"

Expand Down
28 changes: 18 additions & 10 deletions src/main/java/de/ellpeck/nyx/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.DimensionType;
import net.minecraft.world.World;
import net.minecraftforge.common.config.Configuration;

Expand All @@ -22,7 +21,7 @@
public final class Config {

public static Configuration instance;
public static Set<String> allowedDimensions;
public static Set<Integer> allowedDimensions;
public static boolean enchantments;
public static boolean lunarWater;
public static String[] lunarWaterItemParts;
Expand Down Expand Up @@ -57,7 +56,7 @@ public final class Config {
public static int[] lunarWaterTicks;
public static double meteorChance;
public static double meteorChanceNight;
public static String meteorGateDimension;
public static int meteorGateDimension;
public static double meteorChanceAfterGate;
public static double meteorChanceAfterGateNight;
public static double meteorChanceStarShower;
Expand All @@ -66,9 +65,10 @@ public final class Config {
public static boolean meteors;
public static int meteorDisallowRadius;
public static int meteorDisallowTime;
public static Set<Integer> meteorSpawnDimensions;
public static boolean meteorKillUnloaded;
public static boolean meteorCacheUnloaded;
public static Set<String> enchantingWhitelistDimensions;
public static Set<Integer> enchantingWhitelistDimensions;
public static boolean eventNotifications;
public static int crystalDurability;
public static int hammerDamage;
Expand Down Expand Up @@ -114,7 +114,7 @@ public static void init() {
}

public static void load() {
allowedDimensions = Sets.newHashSet(instance.get("general", "allowedDimensions", new String[]{"overworld"}, "Names of the dimensions that lunar events should occur in").getStringList());
allowedDimensions = getDimensionConfig("general", "allowedDimensions", new String[]{"0"}, "IDs of the dimensions that lunar events should occur in");
meteorShardGuardianChance = instance.get("general", "meteorShardGuardianChance", 0.05, "The chance in percent (1 = 100%) for a meteor shard to be dropped from an elder guardian", 0, 1).getDouble();
mobDuplicationBlacklist = Sets.newHashSet(instance.get("general", "mobDuplicationBlacklist", new String[0], "The registry names of entities that should not be spawned during the full and blood moons. If isMobDuplicationWhitelist is true, this acts as a whitelist instead.").getStringList());
isMobDuplicationWhitelist = instance.get("general", "isMobDuplicationWhitelist", false, "If the mobDuplicationBlacklist should act as a whitelist instead").getBoolean();
Expand Down Expand Up @@ -155,7 +155,7 @@ public static void load() {
maxLevelLunarEdgeDamage = instance.get("enchantments", "maxLevelLunarEdgeDamage", 3.25, "The amount of additional damage that should be applied to an item with max level lunar edge on a full moon.").getDouble();
baseLunarEdgeDamage = instance.get("enchantments", "baseLunarEdgeDamage", 0, "The amount of additional damage that will always be applied regardless of moon phase.").getDouble();
disallowDayEnchanting = instance.get("enchantments", "disallowDayEnchanting", true, "If enchanting should be disallowed during the day").getBoolean();
enchantingWhitelistDimensions = Sets.newHashSet(instance.get("enchantments", "enchantingWhitelistDimensions", new String[]{"the_nether", "the_end"}, "A list of names of dimensions where enchanting is always allowed, and not just at night").getStringList());
enchantingWhitelistDimensions = getDimensionConfig("enchantments", "enchantingWhitelistDimensions", new String[]{"-1", "1"}, "A list of dimension IDs where enchanting is always allowed, and not just at night");

harvestMoon = new LunarEventConfig("harvestMoon", "harvestMoon", "Harvest Moon", 0.05);
colorHarvestMoon = Integer.parseInt(instance.get("harvestMoon", "harvestMoonColor", "3f3fc0", "The hex code of the harvest moon color").getString(), 16);
Expand All @@ -180,9 +180,10 @@ public static void load() {
bloodMoonOnFull = instance.get("bloodMoon", "bloodMoonOnFull", true, "If the blood moon should only occur on full moon nights").getBoolean();

meteors = instance.get("meteors", "meteors", true, "If meteor content should be enabled").getBoolean();
meteorSpawnDimensions = getDimensionConfig("meteors", "meteorDimensions", new String[]{"0"}, "The IDs of dimensions to spawn meteors in (meteorChanceEnd ignores this!)");
meteorChance = instance.get("meteors", "meteorChance", 0.00014, "The chance of a meteor spawning every second, during the day").getDouble();
meteorChanceNight = instance.get("meteors", "meteorChanceNight", 0.0024, "The chance of a meteor spawning every second, during nighttime").getDouble();
meteorGateDimension = instance.get("meteors", "meteorGateDimension", "the_nether", "The dimension that needs to be entered to increase the spawning of meteors").getString();
meteorGateDimension = instance.get("meteors", "meteorGateDimension", -1, "The dimension that needs to be entered to increase the spawning of meteors").getInt();
meteorChanceAfterGate = instance.get("meteors", "meteorChanceAfterGate", 0.0002, "The chance of a meteor spawning every second, during the day, after the gate dimension has been entered once").getDouble();
meteorChanceAfterGateNight = instance.get("meteors", "meteorChanceAfterGateNight", 0.003, "The chance of a meteor spawning every second, during the night, after the gate dimension has been entered once").getDouble();
meteorChanceStarShower = instance.get("meteors", "meteorChanceStarShower", 0.0075, "The chance of a meteor spawning every second, during a star shower").getDouble();
Expand Down Expand Up @@ -210,11 +211,11 @@ public static void load() {
}

public static double getMeteorChance(World world, NyxWorld data) {
DimensionType dim = world.provider.getDimensionType();
if (dim == DimensionType.THE_END)
int dim = world.provider.getDimension();
if (dim == 1)
return meteorChanceEnd;

if (!Config.allowedDimensions.contains(dim.getName()))
if (!Config.meteorSpawnDimensions.contains(dim))
return 0;
boolean visitedGate = data.visitedDimensions.contains(meteorGateDimension);
if (!NyxWorld.isDaytime(world)) {
Expand Down Expand Up @@ -243,6 +244,13 @@ public static Set<LunarWaterSource> getLunarWaterConfig(String category, String
.collect(Collectors.toSet());
}

public static Set<Integer> getDimensionConfig(String category, String key, String[] defaultValue, String comment) {
return Arrays.stream(instance.get(category, key, defaultValue, comment).getStringList())
.map(s -> MathHelper.getInt(s, Integer.MIN_VALUE))
.filter(i -> i != Integer.MIN_VALUE)
.collect(Collectors.toSet());
}

public static class LunarEventConfig {

public boolean enabled;
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/de/ellpeck/nyx/capabilities/NyxWorld.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
import de.ellpeck.nyx.network.PacketNyxWorld;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagInt;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.nbt.NBTTagLong;
import net.minecraft.nbt.NBTTagString;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos;
Expand All @@ -35,7 +35,7 @@ public class NyxWorld implements ICapabilityProvider, INBTSerializable<NBTTagCom
public final Set<BlockPos> cachedMeteorPositions = new HashSet<>();
public final Map<ChunkPos, MutableInt> playersPresentTicks = new HashMap<>();
public final Set<BlockPos> meteorLandingSites = new HashSet<>();
public final Set<String> visitedDimensions = new HashSet<>();
public final Set<Integer> visitedDimensions = new HashSet<>();
public float eventSkyModifier;
public int currentSkyColor;
public LunarEvent currentEvent;
Expand All @@ -57,7 +57,7 @@ public void update() {
// add to visited dimensions list
if (this.world.getTotalWorldTime() % 200 == 0) {
for (EntityPlayer player : this.world.getMinecraftServer().getPlayerList().getPlayers())
this.visitedDimensions.add(player.world.provider.getDimensionType().getName());
this.visitedDimensions.add(player.world.provider.getDimension());
}

// calculate which chunks have players close to them for meteor spawning
Expand Down Expand Up @@ -87,7 +87,7 @@ public void update() {
}

// moon event stuff
String dimension = this.world.provider.getDimensionType().getName();
int dimension = this.world.provider.getDimension();
if (Config.allowedDimensions.contains(dimension)) {
moonPhase = this.world.getCurrentMoonPhaseFactor();

Expand Down Expand Up @@ -176,8 +176,8 @@ public NBTTagCompound serializeNBT(boolean client) {
}
compound.setTag("players_present_ticks", ticks);
NBTTagList dimensions = new NBTTagList();
for (String dim : this.visitedDimensions)
dimensions.appendTag(new NBTTagString(dim));
for (int dim : this.visitedDimensions)
dimensions.appendTag(new NBTTagInt(dim));
compound.setTag("visited_dims", dimensions);
}
return compound;
Expand Down Expand Up @@ -214,7 +214,7 @@ public void deserializeNBT(NBTTagCompound compound, boolean client) {
this.visitedDimensions.clear();
NBTTagList dimensions = compound.getTagList("visited_dims", Constants.NBT.TAG_STRING);
for (int i = 0; i < dimensions.tagCount(); i++)
this.visitedDimensions.add(((NBTTagString) dimensions.get(i)).getString());
this.visitedDimensions.add(((NBTTagInt) dimensions.get(i)).getInt());
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/de/ellpeck/nyx/events/Events.java
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public static void onWorldTick(TickEvent.WorldTickEvent event) {

// Falling stars
if (!event.world.isRemote && Config.fallingStars && !NyxWorld.isDaytime(event.world) && event.world.getTotalWorldTime() % 20 == 0) {
String dimension = event.world.provider.getDimensionType().getName();
int dimension = event.world.provider.getDimension();
if (Config.allowedDimensions.contains(dimension)) {
for (EntityPlayer player : event.world.playerEntities) {
if (event.world.rand.nextFloat() > (data.currentEvent instanceof StarShower ? Config.fallingStarRarityShower : Config.fallingStarRarity))
Expand Down Expand Up @@ -411,7 +411,7 @@ public static void onInteract(PlayerInteractEvent.RightClickBlock event) {
break ench;
if (!(block instanceof BlockEnchantmentTable))
break ench;
if (Config.enchantingWhitelistDimensions.contains(world.provider.getDimensionType().getName()))
if (Config.enchantingWhitelistDimensions.contains(world.provider.getDimension()))
break ench;
event.setUseBlock(Event.Result.DENY);
player.sendStatusMessage(new TextComponentTranslation("info." + Nyx.ID + ".day_enchanting"), true);
Expand Down

0 comments on commit 56075f1

Please sign in to comment.