Skip to content

Commit

Permalink
added auto-generating wiki
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMarstonConnell committed Sep 9, 2023
1 parent 9f9bb19 commit 45228ae
Show file tree
Hide file tree
Showing 7 changed files with 147 additions and 11 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,5 @@ run
# Files from Forge MDK
forge*changelog.txt
.DS_Store

logs
50 changes: 50 additions & 0 deletions MODIFIERS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Modifiers
This is a full list of modifiers in the game and a description of what they do.
## Breakers
These effects are applied when breaking blocks.
### Veiny
Breaking any block will cause all blocks of the same type adjacent to it to break up to 5 in each direction.
### Magnetic
Upon breaking a block (allowed by tool type), all items at that block's position will teleport to you.
### Learning
After breaking 10 blocks as allowed by this tool, gain 3 experience points.
## Holders
These effects are applied when holding the tool.
### Rainy
While holding the tool in the rain, mine faster!
### Hasty
While holding the tool, get the Haste effect.
### Detecting
While holding the tool, ores around you will glow.
### Appley
While holding the tool, get the absorption effect.
### Tomb Raider
While holding the spawners around you will glow.
### Filling
While holding the tool, get the saturation effect.
## Users
These effects are applied when right clicking.
### Heartha's Grace
Right clicking on the top of a block with the tool in hand will place a dirt block and use 1 durability points.
### Spelunking
Right clicking on the top of a block with the tool in hand will place a torch and use 10 durability points.
### Fire Starter
Right clicking on the top of a block while crouching with the tool in hand will start a fire and use 2 durability points.
## Hurters
These effects are applied when hurting enemies.
### Poisonous
When attacking with tool, apply the poison effect to the target.
### Charged
After 7 seconds, hitting and enemy will summon a lightning bolt and empty the charge meter.
### Necrotic
Heals 10% of damage dealt to target.
### Critical
Always critically strikes enemy.
### Withering
When attacking with tool, apply the wither effect to the target.
### Blinding
When attacking with tool, apply the blindness effect to the target.
### Flaming
Sets enemy on fire for 2 seconds.
### Dexterous
Hitting enemies within 2 seconds after hitting them deals an extra 25% damage.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ Holding Shift while hovering over tools will give you an expanded view on detail
Holding Control (command on a mac) while hovering over tools will give you a description of every trait currently applied to the tool.
![tools with control information](https://raw.githubusercontent.com/TheMarstonConnell/randomloot/main/.github/assets/expanded_info.png)

#### Tool Modifiers
For a complete list of modifiers check out the [modifier list](https://github.com/TheMarstonConnell/randomloot/blob/main/MODIFIERS.md).

## Another Rewrite?
The jump from 1.12 to 1.16 was one of the biggest changes to Forge & the Minecraft codebase making a complete rewrite of the mod very welcome. However, the 1.16 to 1.20 is again, a massive change and I'm overall dissatisfied with the 1.16 version of the mods codebase and sloppy planning. As such, 1.20 is a complete rewrite of Random Loot to make the mod feel more cohesive and less janky.

Expand Down
75 changes: 75 additions & 0 deletions src/main/java/dev/marston/randomloot/GenWiki.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package dev.marston.randomloot;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Iterator;
import java.util.Set;

import dev.marston.randomloot.loot.modifiers.Modifier;
import dev.marston.randomloot.loot.modifiers.ModifierRegistry;

public class GenWiki {

private static void write(String s, FileWriter f) throws IOException {
f.write(s + "\n");
}

private static void writeMod(Modifier m, FileWriter f) throws IOException {
write("### " + m.name(), f);

write(m.description(),f );
}

private static void writeMods(Set<Modifier> mods, FileWriter f) throws IOException {
for (Iterator<Modifier> iterator = mods.iterator(); iterator.hasNext();) {
Modifier modifier = iterator.next();
writeMod(modifier, f);
}
}

private static void writeModifiers(FileWriter f) throws IOException {

write("# Modifiers", f);
write("This is a full list of modifiers in the game and a description of what they do.", f);

write("## Breakers", f);
write("These effects are applied when breaking blocks.", f);
writeMods(ModifierRegistry.BREAKERS, f);

write("## Holders", f);
write("These effects are applied when holding the tool.", f);
writeMods(ModifierRegistry.HOLDERS, f);

write("## Users", f);
write("These effects are applied when right clicking.", f);
writeMods(ModifierRegistry.USERS, f);

write("## Hurters", f);
write("These effects are applied when hurting enemies.", f);
writeMods(ModifierRegistry.HURTERS, f);

}

public static void genWiki() {

String isProd = System.getenv("RL_PROD").strip();
RandomLootMod.LOGGER.info("RL_PROD: " + isProd);

if (isProd.contains("false")) {
RandomLootMod.LOGGER.info("Creating wiki...");

try {
FileWriter wikiWriter = new FileWriter("../MODIFIERS.md");
writeModifiers(wikiWriter);
wikiWriter.close();
} catch (IOException e) {
e.printStackTrace();
}
}



}

}
6 changes: 6 additions & 0 deletions src/main/java/dev/marston/randomloot/Globals.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package dev.marston.randomloot;

public class Globals {
public static long Seed = 0;

}
19 changes: 9 additions & 10 deletions src/main/java/dev/marston/randomloot/RandomLootMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,40 +38,39 @@ public class RandomLootMod {
public static final Logger LOGGER = LogUtils.getLogger();
public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, MODID);

public static long Seed = 0;

public static final DeferredRegister<CreativeModeTab> CREATIVE_MODE_TABS = DeferredRegister
.create(Registries.CREATIVE_MODE_TAB, MODID);

public RandomLootMod() {
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();

modEventBus.addListener(this::commonSetup);
modEventBus.addListener(this::addCreative);
modEventBus.addListener(this::addCreative);

ModLootModifiers.register(modEventBus);

MinecraftForge.EVENT_BUS.register(this);

ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, Config.SPEC);

GenWiki.genWiki();
}

private void commonSetup(final FMLCommonSetupEvent event) {
LOGGER.info("RandomLoot Common Setup");

}

private void addCreative(BuildCreativeModeTabContentsEvent event)
{
if (event.getTabKey() == CreativeModeTabs.TOOLS_AND_UTILITIES)
event.accept(LootRegistry.CaseItem);
}

private void addCreative(BuildCreativeModeTabContentsEvent event) {
if (event.getTabKey() == CreativeModeTabs.TOOLS_AND_UTILITIES)
event.accept(LootRegistry.CaseItem);
}

@SubscribeEvent
public void onServerStarting(ServerStartingEvent event) {
LOGGER.info("Starting server with RandomLoot installed!");

Seed = event.getServer().getWorldData().worldGenOptions().seed();
Globals.Seed = event.getServer().getWorldData().worldGenOptions().seed();
}

@Mod.EventBusSubscriber(modid = MODID, bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/dev/marston/randomloot/loot/NameGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.Random;

import dev.marston.randomloot.Globals;
import dev.marston.randomloot.RandomLootMod;

public class NameGenerator {
Expand Down Expand Up @@ -181,7 +182,7 @@ public static String generateForger(float temp) {
list = HotNames;
}

Random generator = new Random(RandomLootMod.Seed);
Random generator = new Random(Globals.Seed);

String adj = list[generator.nextInt(list.length)];
return adj;
Expand Down

0 comments on commit 45228ae

Please sign in to comment.