Skip to content

Commit

Permalink
why did it take me so long to update this it was literlaly painless
Browse files Browse the repository at this point in the history
also add possibility for infinite range
  • Loading branch information
LemmaEOF committed Jan 23, 2021
1 parent 777c7ce commit f168ae5
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 41 deletions.
30 changes: 7 additions & 23 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,26 +1,9 @@
buildscript {
repositories {
jcenter()
maven {
name = 'Fabric'
url = 'http://maven.modmuss50.me/'
}
}
dependencies {
classpath "net.fabricmc:fabric-loom:0.2.6-SNAPSHOT"
}
}

plugins {
id 'java'
id 'eclipse'
id 'idea'
id 'maven-publish'
id "com.jfrog.artifactory" version "4.9.0"
id "fabric-loom" version "0.5-SNAPSHOT"
id "maven-publish"
id "com.jfrog.artifactory" version "4.15.2"
}

apply plugin: net.fabricmc.loom.LoomGradlePlugin

sourceCompatibility = 1.8
targetCompatibility = 1.8

Expand All @@ -37,10 +20,11 @@ minecraft {

repositories {
mavenCentral()
maven { url "https://dl.bintray.com/ladysnake/libs" }
maven { url "http://maven.fabricmc.net/" }
maven { url "http://server.bbkr.space:8081/artifactory/libs-release" }
maven { url "https://server.bbkr.space/artifactory/libs-release" }
maven { url "https://jitpack.io" }
maven { url "https://maven.pkg.github.com" }
// maven { url "https://maven.pkg.github.com" }
}

dependencies {
Expand Down Expand Up @@ -121,7 +105,7 @@ publishing {

artifactory {
if (project.hasProperty("artifactoryUsername")) {
contextUrl = "http://server.bbkr.space:8081/artifactory/"
contextUrl = "https://server.bbkr.space/artifactory/"
publish {
repository {
if (version.contains("SNAPSHOT")) {
Expand Down
16 changes: 8 additions & 8 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check these on https://fabricmc.net/use
minecraft_version=1.15
yarn_build=1
loader_version=0.7.2+build.174
minecraft_version=1.16.5
yarn_build=3
loader_version=0.11.1

# Mod Properties
mod_version = 1.1.1
mod_version = 1.1.2
maven_group = space.bbkr
archives_base_name = shulkercharm

# Dependencies
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
fabric_version=0.4.20+build.273-1.15
trinkets_version=v2.4.0
jankson_version=2.0.1+j1.2.0
pal_version=1.0.0
fabric_version=0.29.4+1.16
trinkets_version=v2.6.7
jankson_version=3.0.1+j1.2.0
pal_version=1.2.1
10 changes: 10 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
pluginManagement {
repositories {
jcenter()
maven {
name = 'Fabric'
url = 'https://maven.fabricmc.net/'
}
gradlePluginPortal()
}
}
2 changes: 1 addition & 1 deletion src/main/java/space/bbkr/shulkercharm/ShulkerCharm.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public ShulkerCharmConfig loadConfig() {
JsonElement jsonElementNew = jankson.toJson(new ShulkerCharmConfig());
if(jsonElementNew instanceof JsonObject){
JsonObject jsonNew = (JsonObject) jsonElementNew;
if(json.getDelta(jsonNew).size()>= 0){
if(json.getDelta(jsonNew).size() > 0){
saveConfig(result);
}
}
Expand Down
16 changes: 7 additions & 9 deletions src/main/java/space/bbkr/shulkercharm/ShulkerCharmItem.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package space.bbkr.shulkercharm;

import dev.emi.trinkets.api.ITrinket;
import dev.emi.trinkets.api.SlotGroups;
import dev.emi.trinkets.api.Slots;
import dev.emi.trinkets.api.TrinketInventory;
import dev.emi.trinkets.api.TrinketItem;
import io.github.ladysnake.pal.VanillaAbilities;
import net.fabricmc.fabric.api.util.NbtType;
import net.minecraft.client.item.TooltipContext;
Expand All @@ -22,19 +23,15 @@
import javax.annotation.Nullable;
import java.util.List;

public class ShulkerCharmItem extends Item implements ITrinket, CustomDurabilityItem {
public class ShulkerCharmItem extends TrinketItem implements CustomDurabilityItem {
public ShulkerCharmItem(Settings settings) {
super(settings);
}

@Override
public TypedActionResult<ItemStack> use(World world, PlayerEntity user, Hand hand) {
return ITrinket.equipTrinket(user, hand);
}

@Override
public void tick(PlayerEntity player, ItemStack stack) {
int power = getPower(stack);
if (player.world.isClient) return;
if (ShulkerCharm.CHARM_FLIGHT.grants(player, VanillaAbilities.ALLOW_FLYING)) {
if (power == 0) {
ShulkerCharm.CHARM_FLIGHT.revokeFrom(player, VanillaAbilities.ALLOW_FLYING);
Expand All @@ -48,14 +45,14 @@ public void tick(PlayerEntity player, ItemStack stack) {
ShulkerCharm.CHARM_FLIGHT.grantTo(player, VanillaAbilities.ALLOW_FLYING);
}
}
if (VanillaAbilities.FLYING.isEnabledFor(player)) {
if (VanillaAbilities.FLYING.isEnabledFor(player) && ShulkerCharm.config.rangeModifier != -1) {
setPower(stack, power - 1);
}
}

@Override
public void onUnequip(PlayerEntity player, ItemStack stack) {
if (ShulkerCharm.CHARM_FLIGHT.grants(player, VanillaAbilities.ALLOW_FLYING)) {
if (!player.world.isClient && ShulkerCharm.CHARM_FLIGHT.grants(player, VanillaAbilities.ALLOW_FLYING)) {
ShulkerCharm.CHARM_FLIGHT.revokeFrom(player, VanillaAbilities.ALLOW_FLYING);
if (!VanillaAbilities.ALLOW_FLYING.isEnabledFor(player)) {
player.abilities.flying = false;
Expand Down Expand Up @@ -106,6 +103,7 @@ public void appendTooltip(ItemStack stack, @Nullable World world, List<Text> too
* @return The amount of power it currently has.
*/
public int getPower(ItemStack stack) {
if (ShulkerCharm.config.rangeModifier == -1) return ShulkerCharm.config.maxPower;
CompoundTag tag = stack.getOrCreateTag();
if (tag.contains("Energy", NbtType.INT)) {
tag.putInt("Power", tag.getInt("Energy"));
Expand Down

0 comments on commit f168ae5

Please sign in to comment.