Skip to content

Commit

Permalink
Pain and Suffering
Browse files Browse the repository at this point in the history
  • Loading branch information
Leclowndu93150 committed Jun 8, 2024
1 parent 925d0ff commit ae9f39d
Show file tree
Hide file tree
Showing 7 changed files with 109 additions and 36 deletions.
39 changes: 6 additions & 33 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ group = mod_group_id

repositories {
mavenLocal()
maven {
name = "Illusive Soulworks maven"
url = "https://maven.theillusivec4.top/"
}
}

base {
Expand All @@ -20,11 +24,6 @@ base {
// Mojang ships Java 21 to end users starting in 1.20.5, so mods should target Java 21.
java.toolchain.languageVersion = JavaLanguageVersion.of(21)

//minecraft.accessTransformers.file rootProject.file('src/main/resources/META-INF/accesstransformer.cfg')
//minecraft.accessTransformers.entry public net.minecraft.client.Minecraft textureManager # textureManager

// Default run configurations.
// These can be tweaked, removed, or duplicated as needed.
runs {
// applies to all the run configs below
configureEach {
Expand Down Expand Up @@ -81,35 +80,9 @@ configurations {
}

dependencies {
// Specify the version of Minecraft to use.
// Depending on the plugin applied there are several options. We will assume you applied the userdev plugin as shown above.
// The group for userdev is net.neoforged, the module name is neoforge, and the version is the same as the neoforge version.
// You can however also use the vanilla plugin (net.neoforged.gradle.vanilla) to use a version of Minecraft without the neoforge loader.
// And its provides the option to then use net.minecraft as the group, and one of; client, server or joined as the module name, plus the game version as version.
// For all intends and purposes: You can treat this dependency as if it is a normal library you would use.
implementation "net.neoforged:neoforge:${neo_version}"

// Example optional mod dependency with JEI
// The JEI API is declared for compile time use, while the full JEI artifact is used at runtime
// compileOnly "mezz.jei:jei-${mc_version}-common-api:${jei_version}"
// compileOnly "mezz.jei:jei-${mc_version}-neoforge-api:${jei_version}"
// We add the full version to localRuntime, not runtimeOnly, so that we do not publish a dependency on it
// localRuntime "mezz.jei:jei-${mc_version}-neoforge:${jei_version}"

// Example mod dependency using a mod jar from ./libs with a flat dir repository
// This maps to ./libs/coolmod-${mc_version}-${coolmod_version}.jar
// The group id is ignored when searching -- in this case, it is "blank"
// implementation "blank:coolmod-${mc_version}:${coolmod_version}"

// Example mod dependency using a file as dependency
// implementation files("libs/coolmod-${mc_version}-${coolmod_version}.jar")

// Example project dependency using a sister or child project:
// implementation project(":myproject")

// For more info:
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
// http://www.gradle.org/docs/current/userguide/dependency_management.html
compileOnly("top.theillusivec4.curios:curios-neoforge:${curios_version}:api")
runtimeOnly("top.theillusivec4.curios:curios-neoforge:${curios_version}")
}

// This block of code expands all declared replace properties in the specified resource targets.
Expand Down
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ minecraft_version=1.20.6
minecraft_version_range=[1.20.6,1.21)
# The Neo version must agree with the Minecraft version to get a valid artifact
neo_version=20.6.112-beta

curios_version=8.0.0-beta.5+1.20.6
# The Neo version range can use any version of Neo as bounds
neo_version_range=[20.6,)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.leclowndu93150.flightutils;

import com.leclowndu93150.flightutils.curio.FlightCapability;
import com.leclowndu93150.flightutils.registry.CreativeTabRegistry;
import com.leclowndu93150.flightutils.registry.ItemRegistry;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.fml.common.Mod;

// The value here should match an entry in the META-INF/neoforge.mods.toml file
@Mod(FlightUtilsMain.MODID)
public class FlightUtilsMain
{
Expand All @@ -15,5 +15,6 @@ public FlightUtilsMain(IEventBus modEventBus)
{
CreativeTabRegistry.CREATIVE_MODE_TABS.register(modEventBus);
ItemRegistry.ITEMS.register(modEventBus);
modEventBus.addListener(new FlightCapability()::registerCapabilities);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package com.leclowndu93150.flightutils.curio;

import com.leclowndu93150.flightutils.registry.ItemRegistry;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.neoforge.capabilities.RegisterCapabilitiesEvent;
import top.theillusivec4.curios.api.CuriosApi;
import top.theillusivec4.curios.api.CuriosCapability;
import top.theillusivec4.curios.api.SlotContext;
import top.theillusivec4.curios.api.type.capability.ICurio;

public class FlightCapability {

private void startFlight(Player player){
if(!player.isCreative() && !player.isSpectator()){
player.getAbilities().mayfly = true;
player.onUpdateAbilities();
}
}

private void stopFlight(Player player) {
if (!player.isCreative() && !player.isSpectator()) {
player.getAbilities().flying = false;
player.getAbilities().mayfly = false;
player.onUpdateAbilities();
}
}

public void registerCapabilities(final RegisterCapabilitiesEvent evt) {
evt.registerItem(
CuriosCapability.ITEM,
(stack, context) -> new ICurio() {

@Override
public ItemStack getStack() {
return ItemRegistry.ANGEL_RING.toStack();
}

@Override
public void curioTick(SlotContext slotContext) {
if (slotContext.entity() instanceof Player player) {
if (!player.getAbilities().mayfly) {
startFlight(player);
}
}
}

@Override
public boolean canEquipFromUse(SlotContext slotContext) {
return true;
}

@Override
public boolean canEquip(SlotContext slotContext) {
return CuriosApi.getCuriosHelper().findEquippedCurio(ItemRegistry.ANGEL_RING.get(), slotContext.entity()).isEmpty();
}

@Override
public void onEquip(SlotContext slotContext, ItemStack prevStack) {
if (slotContext.getWearer() instanceof Player)
startFlight((Player) slotContext.getWearer());
}

@Override
public void onUnequip(SlotContext slotContext, ItemStack newStack) {
if (slotContext.getWearer() instanceof Player)
stopFlight((Player) slotContext.getWearer());
}

}

);
}
}

Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
package com.leclowndu93150.flightutils.items;

import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import org.jetbrains.annotations.NotNull;
import top.theillusivec4.curios.api.type.capability.ICurioItem;

public class AngelRingItem extends Item {

public class AngelRingItem extends Item implements ICurioItem {

public AngelRingItem(Properties pProperties) {
super(pProperties);
}

@Override
public int getMaxStackSize(@NotNull ItemStack stack) {
return 1;
}

}
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
package com.leclowndu93150.flightutils.items;

import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;

public class IntertiaRingItem extends Item {

public IntertiaRingItem(Properties pProperties) {
super(pProperties);
}

@Override
public int getMaxStackSize(ItemStack stack) {
return 1;
}

}
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
package com.leclowndu93150.flightutils.items;

import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;

public class MiningRingItem extends Item {

public MiningRingItem(Properties pProperties) {
super(pProperties);
}

@Override
public int getMaxStackSize(ItemStack stack) {
return 1;
}
}

0 comments on commit ae9f39d

Please sign in to comment.