Skip to content

Commit

Permalink
entity cooldown manager rewrite and bugfixes
Browse files Browse the repository at this point in the history
end server tick callback bug fixes and rewrite
general cleanup
  • Loading branch information
lever1209 committed Jan 26, 2024
1 parent 35cb46d commit 9a9da08
Show file tree
Hide file tree
Showing 11 changed files with 220 additions and 370 deletions.
40 changes: 40 additions & 0 deletions NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@



hip lantern?

light enchantment? glowstone ash and ghast tear paste to become an armor trim instead?

torches burn out and can only be relit twice, after that they turn to ash

ash

glowing armor trim

refil lanterns with phantom membrane, and have 3x slower burn rate

glowstone paste of some kind to augment equipment with light, vanishes on repair and grindstone

render a grue face just out of lantern light range staring at the camera, with the lantern just inside view to the left for the mod icon

option to use entity vs nothing per dimension in config

"tutorial" message first time player gets "Its pitch black, you are likely to be eaten by a grue." then cooldown, and 50% every time you enter darkness, until you get it, then cooldown then chance reduces to 15%, until message has appeared 10 times, then disable message

setup gamerules for select config options

fade light level

particle eyeball monster that lurks in the darkness, multiple floating eye segments? eye stalks?

fix readme, that last line is kinda cringe

add button on worlds menu to recalculate all blocks lighting, potentially dangerous with non vanilla, so throw up a warning, this "solves" the lighting artifacts when changing lighting values without needing too much cpu power in game, should only be used when editing these values or when converting world to pandora since all lighting values are cached

spawn a light generating whisp when respawning, it lasts 2 minutes and follows the player, or until the player enters the light

so, i just make a block entity, make it extend the block its replacing, and
slip that into the original registry call?

effectively, but you have to redirect the original call (or wrap it) since if
it calls the original constructor, an intrusive holder is created
17 changes: 0 additions & 17 deletions src/main/java/pkg/deepCurse/pandora/core/CustomDamageSources.java

This file was deleted.

17 changes: 17 additions & 0 deletions src/main/java/pkg/deepCurse/pandora/core/GrueDamageSource.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package pkg.deepCurse.pandora.core;

import net.minecraft.entity.damage.DamageSource;

public class GrueDamageSource extends DamageSource {
protected boolean fire;
public static final DamageSource GRUE = new GrueDamageSource("pandora.darkness");

protected GrueDamageSource(String name) {
super(name);
}

protected GrueDamageSource setFire() {
this.fire = true;
return this;
}
}
37 changes: 1 addition & 36 deletions src/main/java/pkg/deepCurse/pandora/core/Pandora.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,40 +19,6 @@ public class Pandora implements ModInitializer, PreLaunchEntrypoint {

private static Logger log = LoggerFactory.getLogger(Pandora.class);

// TODO hip lantern?

// TODO light enchantment? glowstone ash and ghast tear paste to become an armor trim instead?

// TODO torches burn out and can only be relit twice, after that they turn to
// ash

// TODO refil lanterns with phantom membrane, and have 3x slower burn rate

// TODO glowstone paste of some kind to augment equipment with light, vanishes
// on repair and grindstone

/*
* TODO "tutorial" message first time player gets
* "Its pitch black, you are likely to be eaten by a grue." then cooldown, and
* 50% every time you enter darkness, until you get it, then cooldown then
* chance reduces to 15%, until message has appeared 10 times, then disable
* message
*/

// TODO setup gamerules for select config options

// TODO fade light level

// TODO fix readme, that last line is kinda cringe

// TODO add button on worlds menu to recalculate all blocks lighting,
// potentially dangerous with non vanilla, so throw up a warning, this "solves"
// the lighting artifacts when changing lighting values without needing too much
// cpu power in game, should only be used when editing these values or when
// converting world to pandora since all lighting values are cached

// TODO spawn a light generating whisp when respawning, it lasts 2 minutes and
// follows the player, or until the player enters the light
@Override
public void onPreLaunch() {
log.info("[Pandora] Running pre launch initializers. . .");
Expand All @@ -65,9 +31,8 @@ public void onInitialize() {

log.info("[Pandora] Initializing mod. . .");

PandoraRegistry.init();
// PandoraRegistry.init();

PandoraConfig.deleteConfig(); // FIXME remove before producton compile
log.info("[Pandora] Loading and applying config. . .");
PandoraConfig.loadConfig();
log.info("[Pandora] Loaded and applied config.");
Expand Down
187 changes: 24 additions & 163 deletions src/main/java/pkg/deepCurse/pandora/core/PandoraConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,17 @@
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.function.ToIntFunction;
import java.util.stream.Collectors;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.snakeyaml.engine.v2.api.Load;
import org.snakeyaml.engine.v2.api.LoadSettings;

import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.client.particle.BlockLeakParticle;
import net.minecraft.state.property.Property;
import net.minecraft.util.Identifier;
import net.minecraft.util.Pair;
import net.minecraft.util.math.Vec3d;
import pkg.deepCurse.pandora.core.PandoraConfig.General.BlockLightLevelSettings;
import pkg.deepCurse.pandora.core.mixins.shared.StateMixin;
import pkg.deepCurse.pandora.core.util.exceptions.PandoraConfigParseException;
import pkg.deepCurse.pandora.core.util.interfaces.ConditionalToIntFunction;
import pkg.deepCurse.pandora.core.util.interfaces.PropertyMapPrinterAccess;
import pkg.deepCurse.pandora.core.util.tools.CalculateFogFunction;

public class PandoraConfig {
Expand Down Expand Up @@ -106,11 +96,11 @@ public MobSettings(double damageMultiplier, boolean fearsDarkness) {
}

public class Debug {
// TODO add support for configs that do not get added, or at least shuffled to
// the bottom
public static double FlameLightSourceDecayRate = 1.0f;
public static boolean ForceGruesAlwaysAttack = false;
public static int GrueAttackInterval = 1; // TODO finish this
public static int GrueMinimumTickWait = 40;
public static int GrueMaximumTickWait = 100;

}

private static Logger log = LoggerFactory.getLogger(PandoraConfig.class);
Expand Down Expand Up @@ -181,7 +171,7 @@ public static void loadConfig() { // TODO write yaml parser to get spans and lin
for (HashMap<String, ?> i : (ArrayList<HashMap<String, ?>>) blockLightSettings) {

if (!i.containsKey("light level")) {
throw new PandoraConfigParseException(
throw new IllegalArgumentException(
"Value for required key \"light level\" not found or invalid. type required: int, example key value pair: \"light level: 7\"");
}

Expand Down Expand Up @@ -221,7 +211,7 @@ public static void loadConfig() { // TODO write yaml parser to get spans and lin
// + ")");
// }
if (identifiers == null) {
throw new PandoraConfigParseException(
throw new IllegalArgumentException(
"Element does not contain required key \"ids\", please add it to the element. (" + dim + ")");
}
// if (infested == null) {
Expand Down Expand Up @@ -274,17 +264,26 @@ public static void loadConfig() { // TODO write yaml parser to get spans and lin
}
}

Debug.FlameLightSourceDecayRate = (double) debug.get("flameLightSourceDecayRate");
Debug.ForceGruesAlwaysAttack = (boolean) debug.get("forceGruesAlwaysAttack");
Debug.FlameLightSourceDecayRate = (double) debug.get("FlameLightSourceDecayRate");
Debug.ForceGruesAlwaysAttack = (boolean) debug.get("ForceGruesAlwaysAttack");

// log.info("CONFIG:\n{}\n{}\n{}\n{}\n{}\n{}\n{}\n{}\n{}\n{}\n{}\n{}\n{}\n{}\n{}\n{}\n{}\n{}\n{}\n{}",
// General.Enabled.EnablePandora, General.Enabled.EnableCustomFog, General.Enabled.EnableCustomAI,
// General.Enabled.EnableCustomLightmap, General.Enabled.EnableGrueWards, General.IgnoreSkyLight,
// General.IgnoreMoonPhase, General.MinimumSafeLightLevel, General.MinimumFadeLightLevel,
// General.HardcoreAffectsOtherMobs, General.ResetGamma, General.GammaValue, General.GruesAttackInWater,
// General.GruesEatItems, General.BlockLightLevelSettings, General.DimensionSettings, General.GrueWards,
// General.MobSettings, Debug.FlameLightSourceDecayRate, Debug.ForceGruesAlwaysAttack);
Debug.GrueMinimumTickWait = (int) debug.get("GrueMinimumTickWait");
Debug.GrueMaximumTickWait = ((int) debug.get("GrueMaximumTickWait"));

if (Debug.GrueMinimumTickWait > Debug.GrueMaximumTickWait) {
throw new IllegalArgumentException(
"Key \"GrueMinimumTickWait\" is larger than key \"GrueMaximumTickWait\"");
}
// if (Debug.GrueMinimumTickWait == Debug.GrueMaximumTickWait) {
// throw new IllegalArgumentException(
// "Key \"GrueMinimumTickWait\" is equal to key \"GrueMaximumTickWait\"");
// }
if (Debug.GrueMaximumTickWait <= 0) {
throw new IllegalArgumentException("Key \"GrueMaximumTickWait\" must be larger than 0");
}
if (Debug.GrueMinimumTickWait <= 0) {
throw new IllegalArgumentException("Key \"GrueMinimumTickWait\" must be larger than 0");
}
}

public static void saveConfigs() { // TODO finish save configs
Expand All @@ -308,142 +307,4 @@ public static void unpackageConfig() throws IOException {
public static void deleteConfig() {
getConfigFile().delete();
}

// public static boolean moblistContains(Identifier identifier) {
// return ANIMALS.contains(identifier) || VILLAGERS.contains(identifier)
// || HOSTILE_MOBS.contains(identifier) || BOSS_MOBS.contains(identifier)
// || MISC_MOBS.contains(identifier);
// }

// HashMap<?,?> load_linked_hashmap_from_config() {

// }

}

// public enum PandoraConfigEnum {

// animalsFearDarkness(false, "Should animals avoid staying in the dark too
// long"),
// blockLightOnly(false,
// "Should the calculation for whether you are in darkness or not only use block
// light, ignoring sky light"),
// bossMobsFearDarkness(false, "Should boss mobs avoid staying in the dark too
// long"),
// defaultGammaResetValue(1.0F,
// "The value pandora will reset your gamma to on boot, resetting your gamma can
// be disabled too"),

//
// dimensionFogFactors(0, "What fog factor should a dimension use"),
// effectiveDimensions(0, "What dimensions should be afflicted by grues"),
// lightLevelBlockPairs(0,
// "What blocks should have what light levels, supports block states (API NOTE:
// an api is available for this value)"),

// flameLightSourceDecayRate(1.0F,
// "The decay rate of torches and similar, 1.0 is 1x the decay rate, 2.0 is 2x,
// 0.5 is half the decay rate, any value can be entered"),
// gruesAttackAnimals(false, "Should grues eat animals"),
// gruesAttackBossMobs(false, "Should grues eat boss monsters"),
// gruesAttackInWater(false, "Should grues eat mobs in dark water"),
// gruesAttackPlayers(true, "Should grues eat players"),
// gruesAttackVillagers(true, "Should grues eat villagers"),
// gruesCanAttackHostileMobs(false, "Should grues attack hostile mobs"),
// gruesEatItems(true, "Should grues eat items (since items do not have health,
// the grue can eat it in one go)"),
// hardcoreAffectsOtherMobs(false,
// "Does being in hardcore mode affect other mobs, in hardcore mode grues will 1
// hit ko"),
// hostileMobsFearDarkness(false, "Should hostile mobs avoid staying in the dark
// too long"),
// ignoreMoonPhase(false,
// "Should the calculation for whether you are in darkness or not use the moon
// phases, full moon you are safe under the moonlight"),
// isEnabled(true, "Is the whole mod enabled"),
// minimumSafeLightLevel(3, "The minimum light level you need to be in to stay
// safe from grues"),
// resetGammaOnLaunch(true, "Should pandora reset your gamma value at launch"),
// villagersFearDarkness(true, "Should villagers avoid staying in the dark too
// long"),
// grueWardsEnabled(true, "Should grue wards be enabled (items you can hold to
// be mostly immune to grues)"),
// isDarknessEnabled(true, "Should the world darken significantly (client side
// only)"),

// // Debug options ahead, will not be stored in config, but will always be
// available in config

// forceGruesAlwaysAttack(false, false);

// public Object object;
// public String comment;
// public boolean canPutInConfig = true;

// PandoraConfigEnum(Object defaultValue, boolean canPutInConfig) {
// this.object = defaultValue;
// this.canPutInConfig = canPutInConfig;
// }

// PandoraConfigEnum(Object defaultValue, String comment) {
// this.object = defaultValue;
// this.comment = comment;
// }
// }

// public static ArrayList<String> blacklistedEntityType = new ArrayList<>();
// public static ArrayList<String> grueWards = new ArrayList<>();
// public static HashMap<Identifier, CalculateFogFunction> effectiveDimensions =
// new HashMap<>();
// public static HashMap<Identifier, Float> dimensionFogFactors = new
// HashMap<>();
// public static HashMap<Identifier, ToIntFunction<BlockState>>
// lightLevelBlockPairs = new HashMap<>();

// static {

// data values i have yet to figure out how to serialize

/*
* dimensionFogFactors.put(new Identifier("minecraft:overworld"), 1.0F);
* dimensionFogFactors.put(new Identifier("minecraft:the_nether"), 0.5F);
* dimensionFogFactors.put(new Identifier("minecraft:the_end"), 0.0F);
*
* double MIN = 0.029999999329447746D; // minimum brightness in grondags
* darkness
*
* effectiveDimensions.putIfAbsent(new Identifier("minecraft:overworld"),
* (effects, color, f, oldValue, world, access, sunHeight, i, j, k) -> { float
* factor = dimensionFogFactors.getOrDefault(new
* Identifier("minecraft:overworld"), 1.0F); return new Vec3d(Math.max(MIN,
* oldValue.x * factor), Math.max(MIN, oldValue.y * factor), Math.max(MIN,
* oldValue.z * factor)); });
*
* effectiveDimensions.putIfAbsent(new Identifier("minecraft:the_nether"),
* (effects, color, f, oldValue, world, access, sunHeight, i, j, k) -> { float
* factor = dimensionFogFactors.getOrDefault(new
* Identifier("minecraft:the_nether"), 0.5F); return new Vec3d(Math.max(MIN,
* oldValue.x * factor), Math.max(MIN, oldValue.y * factor), Math.max(MIN,
* oldValue.z * factor)); });
*
* effectiveDimensions.putIfAbsent(new Identifier("minecraft:the_end"),
* (effects, color, f, oldValue, world, access, sunHeight, i, j, k) -> { float
* factor = dimensionFogFactors.getOrDefault(new
* Identifier("minecraft:the_end"), 0.0F); return new Vec3d(Math.max(MIN,
* oldValue.x * factor), Math.max(MIN, oldValue.y * factor), Math.max(MIN,
* oldValue.z * factor)); });
*/
// }

// public static void saveConfigs() {

// config.commentMap().clear();

// for (PandoraConfigEnum i : PandoraConfigEnum.values()) {
// if (i.canPutInConfig) {
// config.setComment(i.name(), i.comment);
// }
// }

// config.save();
// }
}
Loading

0 comments on commit 9a9da08

Please sign in to comment.