Skip to content
This repository has been archived by the owner on Oct 26, 2022. It is now read-only.

Commit

Permalink
- Added a config option to reset skills on death (false by default).
Browse files Browse the repository at this point in the history
- Added a skill level return value to the get skill command (for technical use).
  • Loading branch information
majikdev committed Jul 11, 2021
1 parent d3f4b3f commit 9ea8924
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 5 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'eclipse'
apply plugin: 'maven-publish'

version = '1.3.4'
version = '1.3.5'
group = 'majik.rereskillable'
archivesBaseName = name + '-' + project.mcVersion

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ org.gradle.daemon=false

name = Rereskillable
author = majik
version = 1.3.4
version = 1.3.5
mcVersion = 1.16.5
11 changes: 11 additions & 0 deletions src/main/java/majik/rereskillable/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ public class Configuration
{
private static final ForgeConfigSpec CONFIG_SPEC;
private static final ForgeConfigSpec.BooleanValue DISABLE_WOOL;
private static final ForgeConfigSpec.BooleanValue DEATH_RESET;
private static final ForgeConfigSpec.IntValue STARTING_COST;
private static final ForgeConfigSpec.IntValue COST_INCREASE;
private static final ForgeConfigSpec.IntValue MAXIMUM_LEVEL;
private static final ForgeConfigSpec.ConfigValue<List<? extends String>> SKILL_LOCKS;

private static boolean disableWool;
private static boolean deathReset;
private static int startingCost;
private static int costIncrease;
private static int maximumLevel;
Expand All @@ -31,6 +33,9 @@ public class Configuration

builder.comment("Disable wool drops to force the player to get shears.");
DISABLE_WOOL = builder.define("disableWoolDrops", true);

builder.comment("Reset all skills to 1 when a player dies.");
DEATH_RESET = builder.define("deathSkillReset", false);

builder.comment("Starting cost of upgrading to level 2, in levels.");
STARTING_COST = builder.defineInRange("startingCost", 2, 0, 10);
Expand All @@ -52,6 +57,7 @@ public class Configuration
public static void load()
{
disableWool = DISABLE_WOOL.get();
deathReset = DEATH_RESET.get();
startingCost = STARTING_COST.get();
costIncrease = COST_INCREASE.get();
maximumLevel = MAXIMUM_LEVEL.get();
Expand Down Expand Up @@ -84,6 +90,11 @@ public static boolean getDisableWool()
return disableWool;
}

public static boolean getDeathReset()
{
return deathReset;
}

public static int getStartCost()
{
return startingCost;
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/majik/rereskillable/common/EventHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import majik.rereskillable.common.capabilities.SkillModel;
import majik.rereskillable.common.capabilities.SkillProvider;
import majik.rereskillable.common.network.SyncToClient;
import majik.rereskillable.common.skills.Skill;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.passive.SheepEntity;
Expand All @@ -13,6 +14,7 @@
import net.minecraft.tags.ItemTags;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.event.AttachCapabilitiesEvent;
import net.minecraftforge.event.entity.living.LivingDeathEvent;
import net.minecraftforge.event.entity.living.LivingDropsEvent;
import net.minecraftforge.event.entity.living.LivingEquipmentChangeEvent;
import net.minecraftforge.event.entity.player.AttackEntityEvent;
Expand Down Expand Up @@ -134,6 +136,17 @@ public void onEntityDrops(LivingDropsEvent event)
}
}

// Player Death

@SubscribeEvent
public void onPlayerDeath(LivingDeathEvent event)
{
if (Configuration.getDeathReset() && event.getEntity() instanceof PlayerEntity)
{
SkillModel.get((PlayerEntity) event.getEntity()).skillLevels = new int[]{1, 1, 1, 1, 1, 1, 1, 1};
}
}

// Capabilities

@SubscribeEvent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ private static int execute(CommandContext<CommandSource> context) throws Command
{
ServerPlayerEntity player = EntityArgument.getPlayer(context, "player");
Skill skill = context.getArgument("skill", Skill.class);
int level = SkillModel.get(player).getSkillLevel(skill);

context.getSource().sendSuccess(new TranslationTextComponent(skill.displayName).append(" " + SkillModel.get(player).getSkillLevel(skill)), true);
context.getSource().sendSuccess(new TranslationTextComponent(skill.displayName).append(" " + level), true);

return 1;
return level;
}
}
2 changes: 1 addition & 1 deletion src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ license="All rights reserved"

[[mods]]
modId="rereskillable"
version="1.3.4"
version="1.3.5"
displayName="Rereskillable"
displayURL="https://www.curseforge.com/minecraft/mc-mods/rereskillable"
credits="Skillable and Reskillable"
Expand Down

0 comments on commit 9ea8924

Please # to comment.