Skip to content

Latest commit

 

History

History
94 lines (69 loc) · 3.53 KB

File metadata and controls

94 lines (69 loc) · 3.53 KB

CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

Build Commands

# Build the mod (creates JAR in build/libs/)
./gradlew build

# Clean build artifacts
./gradlew clean

# Run Minecraft client with the mod loaded (for testing)
./gradlew runClient

# Run Minecraft server with the mod loaded
./gradlew runServer

# Generate data (datagen)
./gradlew runDatagen

Project Overview

WesterosCraftEssentials is a Fabric mod for Minecraft 1.21.1 that provides server-side gameplay modifications for the WesterosCraft server. It uses mixins to modify vanilla Minecraft behavior.

Architecture

Entry Point: WesterosCraftEssentials.java - Implements ModInitializer, loads config on initialization.

Configuration System: config/WesterosCraftConfig.java - JSON-based config stored at config/westeroscraft-essentials.json. Static fields are loaded from JSON at startup. To add a new config option:

  1. Add static field to WesterosCraftConfig
  2. Add corresponding field to inner ConfigData class
  3. Add assignment in load() method

Mixin System: All mixins are in westeroscraft.mixin package and registered in westeroscraft-essentials.mixins.json. Mixins inject into vanilla Minecraft classes to:

  • Cancel behaviors (e.g., ice melting, snow melting)
  • Override survival checks (e.g., allow snow on any surface)

Pattern for adding new block behavior modifications:

  1. Create mixin class in src/main/java/westeroscraft/mixin/
  2. Register mixin in src/main/resources/westeroscraft-essentials.mixins.json
  3. Add config option to control the behavior

LuckPerms Integration

Optional permission system integration via LuckPermsIntegration.java. LuckPerms must be installed separately on the server.

// Check permission (returns true if LuckPerms not installed - fail-open)
LuckPermsIntegration.hasPermission(serverPlayer, "westeroscraft.somepermission");

// Check permission (returns false if LuckPerms not installed - fail-closed)
LuckPermsIntegration.hasPermissionStrict(serverPlayer, "westeroscraft.somepermission");

Auto-Restore System

The restore/AutoRestoreManager.java handles automatic restoration of doors, trapdoors, and fence gates for players with a specific permission. Used for creative servers where guests can interact with doors but changes should revert.

How it works:

  1. Mixins (DoorBlockMixin, TrapDoorBlockMixin, FenceGateBlockMixin) intercept player interactions
  2. If player has the configured permission (default: westeroscraft.autorestore), the original state is recorded
  3. After a configurable delay, the block reverts to its original state
  4. Creative mode players are exempt - their changes are permanent and cancel pending restores

Config structure (in config/westeroscraft-essentials.json):

{
  "autoRestore": {
    "enabled": true,
    "delaySeconds": 30,
    "permission": "westeroscraft.autorestore",
    "allDoors": false,
    "allGates": false,
    "allTrapDoors": false,
    "doors": ["minecraft:oak_door"],
    "gates": ["minecraft:oak_fence_gate"],
    "trapDoors": ["minecraft:oak_trapdoor"]
  }
}

Use allDoors/allGates/allTrapDoors to apply to all blocks of that type, or specify individual block IDs in the lists.

Key Dependencies

  • Fabric Loader 0.18.4+
  • Fabric API
  • Minecraft 1.21.1
  • Java 21
  • LuckPerms API 5.4 (compileOnly - optional runtime dependency)
  • Uses official Mojang mappings (not Yarn)