Skip to content

Commit

Permalink
Update to 1.18-pre1
Browse files Browse the repository at this point in the history
  • Loading branch information
Pyrofab committed Nov 12, 2021
1 parent 1dd2783 commit 96fb8c6
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 19 deletions.
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check these on https://fabricmc.net/use
minecraft_version=1.17.1
yarn_mappings=1.17.1+build.10
minecraft_version=1.18-pre1
yarn_mappings=1.18-pre1+build.3
loader_version=0.12.5
#Fabric api
fabric_version=0.42.1+1.17
fabric_version=0.42.2+1.18

# Mod Properties
mod_version = 1.4.0
Expand All @@ -20,7 +20,7 @@ display_name = PlayerAbilityLib
license_header = LGPL
gpl_version = 3
curseforge_id = 359522
curseforge_versions = 1.17; 1.17.1
curseforge_versions = 1.18-Snapshot; 1.18
cf_requirements = fabric-api
release_type = release
changelog_url = https://github.com/Ladysnake/PlayerAbilityLib/blob/1.17/changelog.md
changelog_url = https://github.com/Ladysnake/PlayerAbilityLib/blob/1.18/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.text.LiteralText;
import net.minecraft.util.Formatting;
import net.minecraft.util.Hand;
Expand All @@ -45,16 +46,16 @@ public AbilityToggleItem(Settings settings, PlayerAbility abilityId, Identifier

@Override
public TypedActionResult<ItemStack> use(World world, PlayerEntity user, Hand hand) {
if (!world.isClient) {
if (abilitySource.grants(user, this.ability)) { // check whether the source is granting the ability
abilitySource.revokeFrom(user, this.ability); // if it is, revoke it
if (user instanceof ServerPlayerEntity sp) {
if (abilitySource.grants(sp, this.ability)) { // check whether the source is granting the ability
abilitySource.revokeFrom(sp, this.ability); // if it is, revoke it
} else {
abilitySource.grantTo(user, this.ability); // otherwise, grant it
abilitySource.grantTo(sp, this.ability); // otherwise, grant it
}
// Feedback message
user.sendMessage(new LiteralText("")
.append(new LiteralText(abilitySource.getId().toString()).styled(s -> s.withColor(Formatting.YELLOW)))
.append(abilitySource.grants(user, this.ability) ? new LiteralText(" added").styled(s -> s.withColor(Formatting.GREEN)) : new LiteralText(" removed").styled(s -> s.withColor(Formatting.RED)))
.append(abilitySource.grants(sp, this.ability) ? new LiteralText(" added").styled(s -> s.withColor(Formatting.GREEN)) : new LiteralText(" removed").styled(s -> s.withColor(Formatting.RED)))
.append(" (")
.append(new LiteralText(this.ability.getId().toString()).styled(s -> s.withColor(Formatting.YELLOW)))
.append(" is ")
Expand Down
14 changes: 7 additions & 7 deletions src/testmod/java/io/github/ladysnake/paltest/FlightEffect.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,32 +23,32 @@
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.attribute.AttributeContainer;
import net.minecraft.entity.effect.StatusEffect;
import net.minecraft.entity.effect.StatusEffectType;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.effect.StatusEffectCategory;
import net.minecraft.server.network.ServerPlayerEntity;

/**
* A status effect that gives creative flight to players
*/
public class FlightEffect extends StatusEffect {
public static final AbilitySource FLIGHT_POTION = Pal.getAbilitySource(PalTest.id("potion_flight"));

public FlightEffect(StatusEffectType statusEffectType, int color) {
public FlightEffect(StatusEffectCategory statusEffectType, int color) {
super(statusEffectType, color);
}

@Override
public void onApplied(LivingEntity effected, AttributeContainer abstractEntityAttributeContainer, int amplifier) {
super.onApplied(effected, abstractEntityAttributeContainer, amplifier);
if (effected instanceof PlayerEntity) {
Pal.grantAbility((PlayerEntity) effected, VanillaAbilities.ALLOW_FLYING, FLIGHT_POTION);
if (effected instanceof ServerPlayerEntity sp) {
Pal.grantAbility(sp, VanillaAbilities.ALLOW_FLYING, FLIGHT_POTION);
}
}

@Override
public void onRemoved(LivingEntity effected, AttributeContainer abstractEntityAttributeContainer, int amplifier) {
super.onRemoved(effected, abstractEntityAttributeContainer, amplifier);
if (effected instanceof PlayerEntity) {
Pal.revokeAbility((PlayerEntity) effected, VanillaAbilities.ALLOW_FLYING, FLIGHT_POTION);
if (effected instanceof ServerPlayerEntity sp) {
Pal.revokeAbility(sp, VanillaAbilities.ALLOW_FLYING, FLIGHT_POTION);
}
}
}
4 changes: 2 additions & 2 deletions src/testmod/java/io/github/ladysnake/paltest/PalTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.entity.effect.StatusEffectType;
import net.minecraft.entity.effect.StatusEffectCategory;
import net.minecraft.item.ArmorItem;
import net.minecraft.item.ArmorMaterials;
import net.minecraft.item.Item;
Expand All @@ -45,7 +45,7 @@ public void onInitialize() {
Registry.register(Registry.ITEM, id("bad_charm"), new BadFlightItem(new Item.Settings()));
Registry.register(Registry.ITEM, id("flight_charm"), new AbilityToggleItem(new Item.Settings(), VanillaAbilities.ALLOW_FLYING, id("charm_flight")));
Registry.register(Registry.ITEM, id("kryptonite"), new AbilityToggleItem(new Item.Settings(), PalTestAbilities.LIMIT_FLIGHT, id("kryptonite")));
Registry.register(Registry.STATUS_EFFECT, id("flight"), new FlightEffect(StatusEffectType.BENEFICIAL, 0xFFFFFF));
Registry.register(Registry.STATUS_EFFECT, id("flight"), new FlightEffect(StatusEffectCategory.BENEFICIAL, 0xFFFFFF));
}

private void registerWaxWings() {
Expand Down

0 comments on commit 96fb8c6

Please sign in to comment.