Skip to content

Commit

Permalink
Add configurable durability to gliders (Closes #186)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaargolo committed Jan 18, 2023
1 parent e875d1c commit b6f2b84
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 18 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ modrinth_version=1.2.1
github_api_version=1.114

# Mod Properties
mod_version=1.9.10-BETA+1.18
mod_version=1.9.11-BETA+1.18
maven_group=io.github.lucaargolo

# Fabric Properties
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import io.github.ladysnake.pal.PlayerAbility;
import io.github.ladysnake.pal.impl.PlayerAbilityView;
import io.github.lucaargolo.kibe.KibeModKt;
import io.github.lucaargolo.kibe.items.ItemCompendiumKt;
import io.github.lucaargolo.kibe.items.miscellaneous.AbilityRing;
import io.github.lucaargolo.kibe.items.miscellaneous.Glider;
Expand All @@ -13,6 +14,7 @@
import kotlin.Pair;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.effect.StatusEffect;
import net.minecraft.entity.effect.StatusEffectInstance;
Expand Down Expand Up @@ -82,10 +84,26 @@ private void tick(CallbackInfo info) {
if(!isOnGround() && !isTouchingWater() && !isFallFlying() && getVelocity().y < 0.0) {
ItemStack mainHandStack = player.getMainHandStack();
ItemStack offHandStack = player.getOffHandStack();
boolean isGliding = (mainHandStack.getItem() instanceof Glider && Glider.Companion.isEnabled(mainHandStack)) || (offHandStack.getItem() instanceof Glider && Glider.Companion.isEnabled(offHandStack));
ItemStack stack;
EquipmentSlot slot;
if(mainHandStack.getItem() instanceof Glider && Glider.Companion.isEnabled(mainHandStack)) {
slot = EquipmentSlot.MAINHAND;
stack = mainHandStack;
}else if(offHandStack.getItem() instanceof Glider && Glider.Companion.isEnabled(offHandStack)) {
slot = EquipmentSlot.OFFHAND;
stack = offHandStack;
} else {
slot = EquipmentSlot.MAINHAND;
stack = ItemStack.EMPTY;
}
boolean isGliding = !stack.isEmpty();
if(isGliding) {
GliderHelper.INSTANCE.setPlayerGliding(player, true);

if(!KibeModKt.getMOD_CONFIG().getMiscellaneousModule().getGliderUnbreakable()) {
stack.damage(1, player, (e) -> e.sendEquipmentBreakStatus(slot));
}

float hSpeed = 0.05f;
float vSpeed = 0.5f;

Expand Down
33 changes: 17 additions & 16 deletions src/main/kotlin/io/github/lucaargolo/kibe/items/ItemCompendium.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package io.github.lucaargolo.kibe.items

import com.mojang.datafixers.util.Pair
import io.github.ladysnake.pal.VanillaAbilities
import io.github.lucaargolo.kibe.MOD_CONFIG
import io.github.lucaargolo.kibe.MOD_ID
import io.github.lucaargolo.kibe.items.cooler.CoolerBlockItem
import io.github.lucaargolo.kibe.items.cooler.CoolerBlockItemScreen
Expand Down Expand Up @@ -177,22 +178,22 @@ val WATER_WOODEN_BUCKET = register(Identifier(MOD_ID, "water_wooden_bucket"), Wo
val GLIDER_LEFT_WING = register(Identifier(MOD_ID, "glider_left_wing"), Item(settingsWithTab()))
val GLIDER_RIGHT_WING = register(Identifier(MOD_ID, "glider_right_wing"), Item(settingsWithTab()))

val WHITE_GLIDER = register(Identifier(MOD_ID, "white_glider"), Glider(settingsWithTab().maxCount(1).rarity(Rarity.UNCOMMON)))
val ORANGE_GLIDER = register(Identifier(MOD_ID, "orange_glider"), Glider(settingsWithTab().maxCount(1).rarity(Rarity.UNCOMMON)))
val MAGENTA_GLIDER = register(Identifier(MOD_ID, "magenta_glider"), Glider(settingsWithTab().maxCount(1).rarity(Rarity.UNCOMMON)))
val LIGHT_BLUE_GLIDER = register(Identifier(MOD_ID, "light_blue_glider"), Glider(settingsWithTab().maxCount(1).rarity(Rarity.UNCOMMON)))
val YELLOW_GLIDER = register(Identifier(MOD_ID, "yellow_glider"), Glider(settingsWithTab().maxCount(1).rarity(Rarity.UNCOMMON)))
val LIME_GLIDER = register(Identifier(MOD_ID, "lime_glider"), Glider(settingsWithTab().maxCount(1).rarity(Rarity.UNCOMMON)))
val PINK_GLIDER = register(Identifier(MOD_ID, "pink_glider"), Glider(settingsWithTab().maxCount(1).rarity(Rarity.UNCOMMON)))
val GRAY_GLIDER = register(Identifier(MOD_ID, "gray_glider"), Glider(settingsWithTab().maxCount(1).rarity(Rarity.UNCOMMON)))
val LIGHT_GRAY_GLIDER = register(Identifier(MOD_ID, "light_gray_glider"), Glider(settingsWithTab().maxCount(1).rarity(Rarity.UNCOMMON)))
val CYAN_GLIDER = register(Identifier(MOD_ID, "cyan_glider"), Glider(settingsWithTab().maxCount(1).rarity(Rarity.UNCOMMON)))
val BLUE_GLIDER = register(Identifier(MOD_ID, "blue_glider"), Glider(settingsWithTab().maxCount(1).rarity(Rarity.UNCOMMON)))
val PURPLE_GLIDER = register(Identifier(MOD_ID, "purple_glider"), Glider(settingsWithTab().maxCount(1).rarity(Rarity.UNCOMMON)))
val GREEN_GLIDER = register(Identifier(MOD_ID, "green_glider"), Glider(settingsWithTab().maxCount(1).rarity(Rarity.UNCOMMON)))
val BROWN_GLIDER = register(Identifier(MOD_ID, "brown_glider"), Glider(settingsWithTab().maxCount(1).rarity(Rarity.UNCOMMON)))
val RED_GLIDER = register(Identifier(MOD_ID, "red_glider"), Glider(settingsWithTab().maxCount(1).rarity(Rarity.UNCOMMON)))
val BLACK_GLIDER = register(Identifier(MOD_ID, "black_glider"), Glider(settingsWithTab().maxCount(1).rarity(Rarity.UNCOMMON)))
val WHITE_GLIDER = register(Identifier(MOD_ID, "white_glider"), Glider(settingsWithTab().maxCount(1).rarity(Rarity.UNCOMMON).maxDamage(MOD_CONFIG.miscellaneousModule.gliderDurability)))
val ORANGE_GLIDER = register(Identifier(MOD_ID, "orange_glider"), Glider(settingsWithTab().maxCount(1).rarity(Rarity.UNCOMMON).maxDamage(MOD_CONFIG.miscellaneousModule.gliderDurability)))
val MAGENTA_GLIDER = register(Identifier(MOD_ID, "magenta_glider"), Glider(settingsWithTab().maxCount(1).rarity(Rarity.UNCOMMON).maxDamage(MOD_CONFIG.miscellaneousModule.gliderDurability)))
val LIGHT_BLUE_GLIDER = register(Identifier(MOD_ID, "light_blue_glider"), Glider(settingsWithTab().maxCount(1).rarity(Rarity.UNCOMMON).maxDamage(MOD_CONFIG.miscellaneousModule.gliderDurability)))
val YELLOW_GLIDER = register(Identifier(MOD_ID, "yellow_glider"), Glider(settingsWithTab().maxCount(1).rarity(Rarity.UNCOMMON).maxDamage(MOD_CONFIG.miscellaneousModule.gliderDurability)))
val LIME_GLIDER = register(Identifier(MOD_ID, "lime_glider"), Glider(settingsWithTab().maxCount(1).rarity(Rarity.UNCOMMON).maxDamage(MOD_CONFIG.miscellaneousModule.gliderDurability)))
val PINK_GLIDER = register(Identifier(MOD_ID, "pink_glider"), Glider(settingsWithTab().maxCount(1).rarity(Rarity.UNCOMMON).maxDamage(MOD_CONFIG.miscellaneousModule.gliderDurability)))
val GRAY_GLIDER = register(Identifier(MOD_ID, "gray_glider"), Glider(settingsWithTab().maxCount(1).rarity(Rarity.UNCOMMON).maxDamage(MOD_CONFIG.miscellaneousModule.gliderDurability)))
val LIGHT_GRAY_GLIDER = register(Identifier(MOD_ID, "light_gray_glider"), Glider(settingsWithTab().maxCount(1).rarity(Rarity.UNCOMMON).maxDamage(MOD_CONFIG.miscellaneousModule.gliderDurability)))
val CYAN_GLIDER = register(Identifier(MOD_ID, "cyan_glider"), Glider(settingsWithTab().maxCount(1).rarity(Rarity.UNCOMMON).maxDamage(MOD_CONFIG.miscellaneousModule.gliderDurability)))
val BLUE_GLIDER = register(Identifier(MOD_ID, "blue_glider"), Glider(settingsWithTab().maxCount(1).rarity(Rarity.UNCOMMON).maxDamage(MOD_CONFIG.miscellaneousModule.gliderDurability)))
val PURPLE_GLIDER = register(Identifier(MOD_ID, "purple_glider"), Glider(settingsWithTab().maxCount(1).rarity(Rarity.UNCOMMON).maxDamage(MOD_CONFIG.miscellaneousModule.gliderDurability)))
val GREEN_GLIDER = register(Identifier(MOD_ID, "green_glider"), Glider(settingsWithTab().maxCount(1).rarity(Rarity.UNCOMMON).maxDamage(MOD_CONFIG.miscellaneousModule.gliderDurability)))
val BROWN_GLIDER = register(Identifier(MOD_ID, "brown_glider"), Glider(settingsWithTab().maxCount(1).rarity(Rarity.UNCOMMON).maxDamage(MOD_CONFIG.miscellaneousModule.gliderDurability)))
val RED_GLIDER = register(Identifier(MOD_ID, "red_glider"), Glider(settingsWithTab().maxCount(1).rarity(Rarity.UNCOMMON).maxDamage(MOD_CONFIG.miscellaneousModule.gliderDurability)))
val BLACK_GLIDER = register(Identifier(MOD_ID, "black_glider"), Glider(settingsWithTab().maxCount(1).rarity(Rarity.UNCOMMON).maxDamage(MOD_CONFIG.miscellaneousModule.gliderDurability)))

val VOID_BUCKET = register(Identifier(MOD_ID, "void_bucket"), VoidBucket(settingsWithTab().maxCount(1).rarity(Rarity.RARE)))

Expand Down
4 changes: 4 additions & 0 deletions src/main/kotlin/io/github/lucaargolo/kibe/utils/ModConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ class ModConfig {
var xpShowerSpeedMultiplier = 1.0
//The range of the magnet
var magnetRange = 8.0
//If glider has any durability
var gliderUnbreakable: Boolean = true
//Glider durability in ticks (36000 = 30 minutes)
var gliderDurability: Int = 36000
}

class ChunkLoaderModule {
Expand Down

0 comments on commit b6f2b84

Please sign in to comment.