Skip to content

Commit

Permalink
1.1.0
Browse files Browse the repository at this point in the history
- Changed mace recipe

- Mod is now configurable

- Wind Bounce is no longer built-in to the mace and is now a treasure enchantment (can be changed in config)

- (Disabled by default) New charged Wind Bounce launches you double the height for double the durability (sneak while using Wind Bounce)

- Compatibility with Enchantment Lore mod
  • Loading branch information
kckarnige committed Sep 29, 2024
1 parent 35faa34 commit 7185f5a
Show file tree
Hide file tree
Showing 18 changed files with 293 additions and 39 deletions.
22 changes: 4 additions & 18 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,8 @@ base {
}

repositories {
// Add repositories to retrieve artifacts from in here.
// You should only use this when depending on other mods because
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
// for more information about repositories.
}

loom {
splitEnvironmentSourceSets()

mods {
"wham" {
sourceSet sourceSets.main
sourceSet sourceSets.client
}
}

maven { url 'https://raw.githubusercontent.com/Tre5et/maven/main/' }
maven { url "https://maven.terraformersmc.com/" }
}

fabricApi {
Expand All @@ -42,7 +27,8 @@ dependencies {

// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"

modImplementation "net.treset:vanillaconfig:${project.vanillaconfig_version}"
modImplementation("com.terraformersmc:modmenu:${project.modmenu_version}")
}

processResources {
Expand Down
6 changes: 4 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ yarn_mappings=1.21+build.2
loader_version=0.15.11

# Mod Properties
mod_version=1.0.2
mod_version=1.1.0
maven_group=com.kckarnige
archives_base_name=wham

# Dependencies
fabric_version=0.100.3+1.21
fabric_version=0.100.3+1.21
vanillaconfig_version=1.2.11+1.21
modmenu_version=11.0.0
89 changes: 89 additions & 0 deletions src/main/java/com/kckarnige/wham/config/MainConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
package com.kckarnige.wham.config;

import net.minecraft.client.MinecraftClient;
import net.treset.vanillaconfig.config.*;
import net.treset.vanillaconfig.config.base.BaseConfig;
import net.treset.vanillaconfig.config.managers.SaveLoadManager;
import net.treset.vanillaconfig.screen.ConfigScreen;

public class MainConfig {
static PageConfig configPage;
static PageConfig clientPage;
static PageConfig serverPage;
static ConfigScreen configScreen;
static ConfigScreen clientConfigScreen;
static ConfigScreen serverConfigScreen;
public static ButtonConfig CLIENT_CONFIG;
public static ButtonConfig SERVER_CONFIG;

public static BooleanConfig MACE_MODEL;
public static BooleanConfig MACE_WINDU;
public static BooleanConfig MACE_WINDU_4EVS;
public static BooleanConfig DEFAULT_BOUNCE;
public static BooleanConfig BIG_BOUNCE;


public static void init() {
configPage = new PageConfig("config.wham");
clientPage = new PageConfig("config.wham.client");
serverPage = new PageConfig("config.wham.server");
CLIENT_CONFIG = new ButtonConfig("config.wham.client_button");
SERVER_CONFIG = new ButtonConfig("config.wham.server_button");

MACE_MODEL = new BooleanConfig(true, "config.wham.3d_mace");
MACE_WINDU = new BooleanConfig(true, "config.wham.mace_wind_toggle");
MACE_WINDU_4EVS = new BooleanConfig(false, "config.wham.mace_4ever_wind");

DEFAULT_BOUNCE = new BooleanConfig(false, "config.wham.wind_bounce_default", "config.wham.wind_bounce_default.description");
BIG_BOUNCE = new BooleanConfig(false, "config.wham.toggle_charge_bounce", "config.wham.toggle_charge_bounce.description");

configPage.setOptions(new BaseConfig[]{
CLIENT_CONFIG,
SERVER_CONFIG
});
clientPage.setOptions(new BaseConfig[]{
MACE_MODEL,
MACE_WINDU,
MACE_WINDU_4EVS
});
serverPage.setOptions(new BaseConfig[]{
BIG_BOUNCE,
DEFAULT_BOUNCE
});

clientPage.setSaveName("client");
clientPage.setPath("wham_config");
serverPage.setSaveName("server");
serverPage.setPath("wham_config");

configScreen = new ConfigScreen(configPage, MinecraftClient.getInstance().currentScreen);
clientConfigScreen = new ConfigScreen(clientPage, MinecraftClient.getInstance().currentScreen);
serverConfigScreen = new ConfigScreen(serverPage, MinecraftClient.getInstance().currentScreen);



SaveLoadManager.globalSaveConfig(clientPage);
MACE_MODEL.onChange(MainConfig::onBooleanConfigChanged);
CLIENT_CONFIG.onClickL(MainConfig::onClientButtonClick);
SERVER_CONFIG.onClickL(MainConfig::onServerButtonClick);

}

private static void onClientButtonClick(String s) {
MinecraftClient.getInstance().setScreen(clientConfigScreen);
}

private static void onServerButtonClick(String s) {
MinecraftClient.getInstance().setScreen(serverConfigScreen);
}

static void onBooleanConfigChanged(boolean prevBoolean, String name) {
if (!MainConfig.MACE_MODEL.getBoolean()) {
MainConfig.MACE_WINDU_4EVS.setEditable(false);
MainConfig.MACE_WINDU.setEditable(false);
} else {
MainConfig.MACE_WINDU_4EVS.setEditable(true);
MainConfig.MACE_WINDU.setEditable(true);
}
}
}
16 changes: 16 additions & 0 deletions src/main/java/com/kckarnige/wham/config/ModMenuConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.kckarnige.wham.config;

import com.terraformersmc.modmenu.api.ConfigScreenFactory;
import com.terraformersmc.modmenu.api.ModMenuApi;
import net.minecraft.client.gui.screen.Screen;

public class ModMenuConfig implements ModMenuApi {

public ConfigScreenFactory<?> getModConfigScreenFactory() {
return this::OpenConfig;
}

public Screen OpenConfig (Screen parent) {
return MainConfig.configScreen;
}
}
17 changes: 17 additions & 0 deletions src/main/java/com/kckarnige/wham/enchantments/WhamEnchantment.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.kckarnige.wham.enchantments;

import net.minecraft.enchantment.Enchantment;
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.util.Identifier;

public class WhamEnchantment {
public static final RegistryKey<Enchantment> WIND_BOUNCE = of("wind_bounce");

private static RegistryKey<Enchantment> of(String name) {
return RegistryKey.of(RegistryKeys.ENCHANTMENT, Identifier.of("wham", name));
}

public static void initialize() {
}
}
78 changes: 72 additions & 6 deletions src/main/java/com/kckarnige/wham/mixin/MaceMixin.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
package com.kckarnige.wham.mixin;

import com.kckarnige.wham.config.MainConfig;
import com.kckarnige.wham.enchantments.WhamEnchantment;
import com.kckarnige.wham.wham;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.projectile.WindChargeEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.MaceItem;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.util.Hand;
import net.minecraft.util.TypedActionResult;
import net.minecraft.util.hit.BlockHitResult;
Expand All @@ -32,15 +37,76 @@ public TypedActionResult<ItemStack> use(World world, PlayerEntity player, Hand h
BlockHitResult blockHit = (BlockHitResult) hit;
if (Objects.equals(String.valueOf(blockHit.getSide()), "up")) {
if (!(player.getStackInHand(hand).getMaxDamage() * 0.70 >= player.getStackInHand(hand).getMaxDamage() - player.getStackInHand(hand).getDamage())) {
player.getItemCooldownManager().set(this, 10);

WindChargeEntity windCharge = new WindChargeEntity(EntityType.WIND_CHARGE, world);
windCharge.setPosition(player.getPos());
windCharge.setVelocity(0.0,-2.0,0.0);
world.spawnEntity(windCharge);
windCharge.setVelocity(0.0, -2.0, 0.0);

if (MainConfig.DEFAULT_BOUNCE.getBoolean() && !player.isSneaking()) {
// 4 uses until repair needed (8 with Unbreaking I, 17 with Unbreaking III)
player.getStackInHand(hand).damage(38, player, LivingEntity.getSlotForHand(hand));
player.getItemCooldownManager().set(this, 10);
world.spawnEntity(windCharge);
return TypedActionResult.success(player.getStackInHand(hand));
} else if (MainConfig.DEFAULT_BOUNCE.getBoolean() && !MainConfig.BIG_BOUNCE.getBoolean()) {
// 4 uses until repair needed (8 with Unbreaking I, 17 with Unbreaking III)
player.getStackInHand(hand).damage(38, player, LivingEntity.getSlotForHand(hand));
player.getItemCooldownManager().set(this, 10);
world.spawnEntity(windCharge);
return TypedActionResult.success(player.getStackInHand(hand));
}
// The higher tier "Wind Slam", the less damage the mace takes when used. "Unbreaking" enchantment lets the mace be used even longer.
int WindSlamLV = EnchantmentHelper.getLevel(world.getRegistryManager().getWrapperOrThrow(RegistryKeys.ENCHANTMENT).getOrThrow(WhamEnchantment.WIND_BOUNCE), player.getStackInHand(hand));
if (WindSlamLV != 0) {

if (player.isSneaking() && MainConfig.BIG_BOUNCE.getBoolean()) {
player.getItemCooldownManager().set(this, 30);

WindChargeEntity windCharge2 = new WindChargeEntity(EntityType.BREEZE_WIND_CHARGE, world);
windCharge2.setPosition(player.getPos());
windCharge2.setVelocity(0.0, -2.0, 0.0);
world.spawnEntity(windCharge2);
world.spawnEntity(windCharge);

switch (WindSlamLV) {
case 1:
player.getStackInHand(hand).damage(76, player, LivingEntity.getSlotForHand(hand));
return TypedActionResult.success(player.getStackInHand(hand));
case 2:
player.getStackInHand(hand).damage(64, player, LivingEntity.getSlotForHand(hand));
return TypedActionResult.success(player.getStackInHand(hand));
}
}
else {
player.getItemCooldownManager().set(this, 10);
world.spawnEntity(windCharge);


if (MainConfig.DEFAULT_BOUNCE.getBoolean()) {
switch (WindSlamLV) {
case 1:
// 5 uses until repair needed (10 with Unbreaking I, 19 with Unbreaking III)
player.getStackInHand(hand).damage(32, player, LivingEntity.getSlotForHand(hand));
return TypedActionResult.success(player.getStackInHand(hand));
case 2:
// 6 uses until repair needed (12 with Unbreaking I, 23 with Unbreaking III)
player.getStackInHand(hand).damage(25, player, LivingEntity.getSlotForHand(hand));
return TypedActionResult.success(player.getStackInHand(hand));
}
} else {
switch (WindSlamLV) {
case 1:
// 4 uses until repair needed (8 with Unbreaking I, 17 with Unbreaking III)
player.getStackInHand(hand).damage(38, player, LivingEntity.getSlotForHand(hand));
return TypedActionResult.success(player.getStackInHand(hand));
case 2:
// 5 uses until repair needed (10 with Unbreaking I, 19 with Unbreaking III)
player.getStackInHand(hand).damage(32, player, LivingEntity.getSlotForHand(hand));
return TypedActionResult.success(player.getStackInHand(hand));
}
}

player.getStackInHand(hand).damage(60, player, LivingEntity.getSlotForHand(hand));
return TypedActionResult.success(player.getStackInHand(hand));
}
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.kckarnige.wham.mixin.client;

import com.kckarnige.wham.config.MainConfig;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.item.ItemRenderer;
import net.minecraft.client.render.model.BakedModel;
Expand All @@ -19,13 +20,18 @@
public abstract class ItemRendererMixin {
@ModifyVariable(method = "renderItem", at = @At(value = "HEAD"), argsOnly = true)
public BakedModel useMaceModel(BakedModel value, ItemStack stack, ModelTransformationMode renderMode, boolean leftHanded, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay) {
if (MainConfig.MACE_MODEL.getBoolean()) {
if (stack.isOf(Items.MACE) && renderMode != ModelTransformationMode.GUI && renderMode != ModelTransformationMode.GROUND && renderMode != ModelTransformationMode.FIXED) {
if (stack.getMaxDamage() * 0.70 >= stack.getMaxDamage() - stack.getDamage()) {
return ((ItemRendererAccessor) this).macebut3d$getModels().getModelManager().getModel(ModelIdentifier.ofInventoryVariant(Identifier.of(MOD_ID, "mace_hand")));
} else {
if (MainConfig.MACE_WINDU_4EVS.getBoolean()) {
return ((ItemRendererAccessor) this).macebut3d$getModels().getModelManager().getModel(ModelIdentifier.ofInventoryVariant(Identifier.of(MOD_ID, "mace_hand_wind")));
} else {
if (!(stack.getMaxDamage() * 0.70 >= stack.getMaxDamage() - stack.getDamage()) && MainConfig.MACE_WINDU.getBoolean()) {
return ((ItemRendererAccessor) this).macebut3d$getModels().getModelManager().getModel(ModelIdentifier.ofInventoryVariant(Identifier.of(MOD_ID, "mace_hand_wind")));
} else {
return ((ItemRendererAccessor) this).macebut3d$getModels().getModelManager().getModel(ModelIdentifier.ofInventoryVariant(Identifier.of(MOD_ID, "mace_hand")));
}
}
}
}}
return value;
}
}
4 changes: 4 additions & 0 deletions src/main/java/com/kckarnige/wham/wham.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.kckarnige.wham;

import com.kckarnige.wham.config.MainConfig;
import com.kckarnige.wham.enchantments.WhamEnchantment;
import com.kckarnige.wham.items.ModItems;
import net.fabricmc.api.ModInitializer;

Expand All @@ -13,6 +15,8 @@ public class wham implements ModInitializer {

@Override
public void onInitialize() {
MainConfig.init();
WhamEnchantment.initialize();
ModItems.registerModItems();
LOGGER.info("[Wham!] Now this should pack more of a punch!");
}
Expand Down
22 changes: 21 additions & 1 deletion src/main/resources/assets/wham/lang/en_gb.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
{
"item.wham.mace_head": "Mace Head"
"item.wham.mace_head": "Mace Head",
"enchantment.wham.wind_bounce": "Wind Bounce",

"config.wham": "Wham! Config",
"config.wham.client": "Wham! Config > Client-Side",
"config.wham.server": "Wham! Config > Server-Side",
"config.wham.client_button": "Client Config",
"config.wham.server_button": "Server Config",

"config.wham.3d_mace": "Use 3D Mace Model",
"config.wham.mace_wind_toggle": "Display Wind on 3D Mace Model",
"config.wham.mace_4ever_wind": "Always Display Wind on Mace",

"config.wham.toggle_charge_bounce": "Enable 'Charge Bounce'",
"config.wham.toggle_charge_bounce.description": "Perform a 'Wind Bounce' while sneaking to 'Charge Bounce'.",

"config.wham.wind_bounce_default": "Use 'Wind Bounce' Without Enchant",
"config.wham.wind_bounce_default.description": "Enables the Mace's ability to 'Wind Bounce' even without the enchantment. The enchantment is still obtainable and does still work as intended.",

"enchantment_lore.wham:wind_bounce.lore": "Within this ancient tome lies the stories of an ancient civilization which took pride in the powers and gifts brought by the airs and winds, this was the same civilization responsible for the first documented discovery of the Breeze.\n\nEven though this book has hundreds of pages, it's lighter than a feather.",
"enchantment_lore.wham:wind_bounce.description": "§nWind Bounce§r\n\nMax Level: II\n\nCompatible with: Mace\n\nUsing the mace on the ground launches the wielder into the air, doing so does a considerable amount of damage to the mace.\n\nUsing while crouched will have the wielder launch higher, and deal double the damage to the mace.\n\nThe higher the level the less damage the mace takes when using this ability."
}
22 changes: 21 additions & 1 deletion src/main/resources/assets/wham/lang/en_us.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
{
"item.wham.mace_head": "Mace Head"
"item.wham.mace_head": "Mace Head",
"enchantment.wham.wind_bounce": "Wind Bounce",

"config.wham": "Wham! Config",
"config.wham.client": "Wham! Config > Client-Side",
"config.wham.server": "Wham! Config > Server-Side",
"config.wham.client_button": "Client Config",
"config.wham.server_button": "Server Config",

"config.wham.3d_mace": "Use 3D Mace Model",
"config.wham.mace_wind_toggle": "Display Wind on 3D Mace Model",
"config.wham.mace_4ever_wind": "Always Display Wind on Mace",

"config.wham.toggle_charge_bounce": "Enable 'Charge Bounce'",
"config.wham.toggle_charge_bounce.description": "Perform a 'Wind Bounce' while sneaking to 'Charge Bounce'.",

"config.wham.wind_bounce_default": "Use 'Wind Bounce' Without Enchant",
"config.wham.wind_bounce_default.description": "Enables the Mace's ability to 'Wind Bounce' even without the enchantment. The enchantment is still obtainable and does still work as intended.",

"enchantment_lore.wham:wind_bounce.lore": "Within this ancient tome lies the stories of an ancient civilization which took pride in the powers and gifts brought by the airs and winds, this was the same civilization responsible for the first documented discovery of the Breeze.\n\nEven though this book has hundreds of pages, it's lighter than a feather.",
"enchantment_lore.wham:wind_bounce.description": "§nWind Bounce§r\n\nMax Level: II\n\nCompatible with: Mace\n\nUsing the mace on the ground launches the wielder into the air, doing so does a considerable amount of damage to the mace.\n\nUsing while crouched will have the wielder launch higher, and deal double the damage to the mace.\n\nThe higher the level the less damage the mace takes when using this ability."
}
9 changes: 3 additions & 6 deletions src/main/resources/data/minecraft/recipe/mace.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,14 @@
"type": "minecraft:crafting_shaped",
"category": "equipment",
"pattern": [
"=#=",
" I ",
" - "
"#",
"I",
"-"
],
"key": {
"#": {
"item": "wham:mace_head"
},
"=": {
"item": "minecraft:wind_charge"
},
"-": {
"item": "minecraft:iron_nugget"
},
Expand Down
Loading

0 comments on commit 7185f5a

Please sign in to comment.