This commit is contained in:
Liz Graham
2022-03-03 01:12:52 +00:00
parent 84e3926a63
commit 3f34718284
6 changed files with 44 additions and 51 deletions

View File

@@ -3,14 +3,14 @@ org.gradle.jvmargs=-Xmx1G
# Fabric Properties # Fabric Properties
# check these on https://fabricmc.net/develop # check these on https://fabricmc.net/develop
minecraft_version=1.18.2 minecraft_version=1.18.1
yarn_mappings=1.18.2+build.1 yarn_mappings=1.18.1+build.22
loader_version=0.13.3 loader_version=0.13.3
# Mod Properties # Mod Properties
mod_version = 1.0.0 mod_version = 1.0.0
maven_group = com.example maven_group = com.lizistired
archives_base_name = fabric-example-mod archives_base_name = dust
# Dependencies # Dependencies
fabric_version=0.47.8+1.18.2 fabric_version=0.46.4+1.18

View File

@@ -1,21 +1,47 @@
package net.fabricmc.example; package net.fabricmc.example;
import net.fabricmc.api.ModInitializer; import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents;
import net.minecraft.particle.ParticleTypes;
import net.minecraft.world.World;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.Random;
public class ExampleMod implements ModInitializer { public class ExampleMod implements ModInitializer {
// This logger is used to write text to the console and the log file.
// It is considered best practice to use your mod id as the logger's name.
// That way, it's clear which mod wrote info, warnings, and errors.
public static final Logger LOGGER = LoggerFactory.getLogger("modid"); public static final Logger LOGGER = LoggerFactory.getLogger("modid");
@Override @Override
public void onInitialize() { public void onInitialize() {
// This code runs as soon as Minecraft is in a mod-load-ready state. ClientPlayConnectionEvents.JOIN.register((handler, sender, client) -> {
// However, some things (like resources) may still be uninitialized. ClientTickEvents.START_CLIENT_TICK.register((client1) -> {
// Proceed with mild caution.
LOGGER.info("Hello Fabric world!"); World world = client1.world;
if (!client1.player.clientWorld.isSkyVisible(client.player.getBlockPos())) {
double d = 0;
double e = 0;
double f = 0;
double probabilityClamped = lerp(64,-64,client.player.getBlockY());
for (int i = 0; i < probabilityClamped; i++) {
d = client.player.getPos().getX() + getRandomNumberUsingInts(-5, 5);
e = client.player.getPos().getY() + getRandomNumberUsingInts(-20, 20);
f = client.player.getPos().getZ() + getRandomNumberUsingInts(-5, 5);
world.addParticle(ParticleTypes.WHITE_ASH, d, e, f, getRandomNumberUsingInts(-5, 20), getRandomNumberUsingInts(-5, 20), getRandomNumberUsingInts(-5, 20));
}
}
});
});
}
public int getRandomNumberUsingInts(int min, int max) {
Random random = new Random();
return random.ints(min,max)
.findFirst()
.getAsInt();
}
public static double lerp(double min, double max, double val) {
return 1 - ((val - min) / (max - min));
} }
} }

View File

@@ -1,16 +0,0 @@
package net.fabricmc.example.mixin;
import net.fabricmc.example.ExampleMod;
import net.minecraft.client.gui.screen.TitleScreen;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(TitleScreen.class)
public class ExampleMixin {
@Inject(at = @At("HEAD"), method = "init()V")
private void init(CallbackInfo info) {
ExampleMod.LOGGER.info("This line is printed by an example mod mixin!");
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 453 B

After

Width:  |  Height:  |  Size: 126 KiB

View File

@@ -3,14 +3,14 @@
"id": "modid", "id": "modid",
"version": "${version}", "version": "${version}",
"name": "Example Mod", "name": "Dust",
"description": "This is an example description! Tell everyone what your mod is about!", "description": "Makes dust underground that scales with depth!",
"authors": [ "authors": [
"Me!" "LizIsTired"
], ],
"contact": { "contact": {
"homepage": "https://fabricmc.net/", "homepage": "https://github.com/LizIsTired/dust",
"sources": "https://github.com/FabricMC/fabric-example-mod" "sources": "https://github.com/LizIsTired/dust"
}, },
"license": "CC0-1.0", "license": "CC0-1.0",
@@ -22,12 +22,9 @@
"net.fabricmc.example.ExampleMod" "net.fabricmc.example.ExampleMod"
] ]
}, },
"mixins": [
"modid.mixins.json"
],
"depends": { "depends": {
"fabricloader": ">=0.13.3", "fabricloader": ">=0.12.11",
"fabric": "*", "fabric": "*",
"minecraft": "1.18.x", "minecraft": "1.18.x",
"java": ">=17" "java": ">=17"

View File

@@ -1,14 +0,0 @@
{
"required": true,
"minVersion": "0.8",
"package": "net.fabricmc.example.mixin",
"compatibilityLevel": "JAVA_17",
"mixins": [
],
"client": [
"ExampleMixin"
],
"injectors": {
"defaultRequire": 1
}
}