๐
1 file
2,136 chars
๐
pasted-code-1791205829297.txt
txt
32 lines
โถ
pasted-code-1791205829297.txt
txt
32 lines
Act as an expert Minecraft Fabric Mod Developer. Write a complete, production-ready Fabric Mod in Java for modern Minecraft versions (using Fabric API and Java 21).
### Mod Title: "Tons of Mass SMP" (Mod ID: `tonsmass`)
### Core Mod Requirements & Mechanics:
1. Dynamic Player Mass Calculation System:
- Calculate total player weight in "Tons" based on equipped armor and inventory items.
- Netherite armor pieces = 2.0 Tons each; Diamond = 1.0 Ton each; Iron = 0.5 Tons each.
- Dense inventory items (Anvils, Netherite Blocks) add +0.1 Ton per item in stack (~6.4 Tons/stack).
- Ores/Raw mineral blocks (Iron, Gold, Raw Iron Blocks) add +0.02 Tons per item in stack (~1.28 Tons/stack).
2. Kinetic Falling Velocity & Gravitational Acceleration:
- On server tick, detect if a player is falling (downward velocity < -0.08), not flying with Elytra, and not in Creative/Spectator mode.
- For every 1 Ton of total mass, increase downward Y-velocity acceleration by 15% (`Y_velocity * (1.0 + (mass * 0.15))`).
- Ensure `player.velocityModified = true` is set so the velocity updates seamlessly on the client.
3. Mace Kinetic Impact & Area-of-Effect (AoE) Shockwave:
- Listen for player melee attacks.
- If the player attacks with a Mace while fall distance is > 1.5 blocks:
a. Calculate additional impact damage scaled exponentially by fall distance AND total weight: `additionalDamage = (fallDistance * 1.5) * (1.0 + (mass / 5.0))`.
b. Play ground smash sound effects (`ITEM_MACE_SMASH_GROUND`).
c. Trigger a radial AoE shockwave in a 3-block radius that knocks back surrounding mobs/players, scaling knockback force with total mass.
### Code Delivery Format:
- Provide the full directory structure.
- Output clean, well-commented code split into standard files:
1. `TonsMassMod.java` (Main initializer & event registration)
2. `MassCalculator.java` (Inventory weight logic)
3. `KineticFallHandler.java` (Server tick gravity adjustment)
4. `KineticMaceHandler.java` (Mace attack hooks & AoE shockwaves)
5. `fabric.mod.json` (Fabric configuration file)
KodariOct 5 at 1:17 pm 2
TonsMassSMP
Dynamic player mass system for Fabric SMP. Calculates player weight in tons from armor and inventory items, applies gravitational acceleration to falling players based on mass, and enables kinetic mace impacts with area-of-effect shockwaves. Netherite armor adds 2 tons per piece, diamond 1 ton, iron 0.5 tons. Dense items like anvils add 0.1 ton each, ores add 0.02 tons. Falling velocity increases by 15% per ton of mass. Mace attacks from falls over 1.5 blocks trigger scaled damage and radial knockback in a 3-block radius.
Created the Tons of Mass SMP Fabric mod for Minecraft 26.2 and Java 25.
Added the initializer, mass calculator, server-tick gravity handler, mace shockwave handler, and attack mixin.
Added Fabric metadata, mixin configuration, and Gradle project files.
Gravity uses 26.2โs
needsSyncfield to synchronize velocity changes.No new items were added; the mechanics use vanilla armor, inventory items, and the mace.
Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
settings.gradle
Code
10 258
src/main/java/com/tonsmass/TonsMassMod.java
package com.tonsmass;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
import net.minecraft.server.level.ServerPlayer;
public class TonsMassMod implements ModInitializer {
public static final String MOD_ID = "tonsmass";
@Override
public void onInitialize() {
ServerTickEvents.END_SERVER_TICK.register(server -> {
for (ServerPlayer player : server.getPlayerList().getPlayers()) {
KineticFallHandler.applyGravity(player);
}
});
}
}