Skip to content

Commit

Permalink
fooling around
Browse files Browse the repository at this point in the history
  • Loading branch information
Thepigcat76 committed Jun 8, 2024
1 parent ed91646 commit f667af9
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 27 deletions.
19 changes: 7 additions & 12 deletions src/main/java/com/leclowndu93150/flightutils/FlightUtilsMain.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.leclowndu93150.flightutils;

import com.leclowndu93150.flightutils.items.AngelRingCurioItem;
import com.leclowndu93150.flightutils.items.AngelRingItem;
import com.leclowndu93150.flightutils.items.InertiaRingItem;
import com.leclowndu93150.flightutils.registry.CreativeTabRegistry;
Expand All @@ -11,24 +12,18 @@
import top.theillusivec4.curios.api.CuriosApi;

@Mod(FlightUtilsMain.MODID)
public class FlightUtilsMain
{
public class FlightUtilsMain {
public static final String MODID = "flightutils";

public FlightUtilsMain(IEventBus modEventBus)
{
public FlightUtilsMain(IEventBus modEventBus) {
CreativeTabRegistry.CREATIVE_MODE_TABS.register(modEventBus);
ItemRegistry.ITEMS.register(modEventBus);
modEventBus.addListener(AngelRingItem::registerCapabilities);
//modEventBus.addListener(this::setup);
modEventBus.addListener(FlightUtilsMain::setup);
}

/*
* private void setup(final FMLCommonSetupEvent evt) {
* CuriosApi.registerCurio(ItemRegistry.ANGEL_RING.get(), new AngelRingItem(new Item.Properties()));
* CuriosApi.registerCurio(ItemRegistry.INERTIA_RING.get(), new InertiaRingItem(new Item.Properties()));
*CuriosApi.registerCurio(ItemRegistry.MINING_RING.get(), new AngelRingItem(new Item.Properties()));
}
*/
private static void setup(final FMLCommonSetupEvent evt) {
CuriosApi.registerCurio(ItemRegistry.ANGEL_RING.get(), new AngelRingCurioItem());
}

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

import net.minecraft.world.item.ItemStack;
import top.theillusivec4.curios.api.SlotContext;
import top.theillusivec4.curios.api.type.capability.ICurioItem;

public class AngelRingCurioItem implements ICurioItem {
@Override
public void curioTick(SlotContext slotContext, ItemStack stack) {
ICurioItem.super.curioTick(slotContext, stack);
System.out.println("Test");
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package com.leclowndu93150.flightutils.items;

import com.leclowndu93150.flightutils.registry.ItemRegistry;
import net.minecraft.network.chat.Component;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResultHolder;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent;
import net.neoforged.neoforge.capabilities.RegisterCapabilitiesEvent;
import org.jetbrains.annotations.NotNull;
Expand All @@ -13,7 +17,7 @@
import top.theillusivec4.curios.api.type.capability.ICurio;
import top.theillusivec4.curios.api.type.capability.ICurioItem;

public class AngelRingItem extends Item implements ICurioItem {
public class AngelRingItem extends Item {

public AngelRingItem(Properties pProperties) {
super(pProperties);
Expand All @@ -24,8 +28,8 @@ public int getMaxStackSize(@NotNull ItemStack stack) {
return 1;
}

private static void startFlight(Player player){
if(!player.isCreative() && !player.isSpectator()){
private static void startFlight(Player player) {
if (!player.isCreative() && !player.isSpectator()) {
player.getAbilities().mayfly = true;
player.onUpdateAbilities();
}
Expand All @@ -39,6 +43,13 @@ private static void stopFlight(Player player) {
}
}

@Override
public InteractionResultHolder<ItemStack> use(Level pLevel, Player pPlayer, InteractionHand pUsedHand) {
ItemStack itemStack = pPlayer.getMainHandItem();
pPlayer.sendSystemMessage(Component.literal(itemStack.getTags().toList().toString()));
return super.use(pLevel, pPlayer, pUsedHand);
}

public static void registerCapabilities(final RegisterCapabilitiesEvent evt) {
evt.registerItem(
CuriosCapability.ITEM,
Expand Down Expand Up @@ -70,20 +81,20 @@ public boolean canEquip(SlotContext slotContext) {

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

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

}, ItemRegistry.ANGEL_RING.get()
},
ItemRegistry.ANGEL_RING.get()
);


}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"replace": "false",
"replace": true,
"values": [
"flightutils:angel_ring"
]
Expand Down

This file was deleted.

6 changes: 6 additions & 0 deletions src/main/resources/pack.mcmeta
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"pack": {
"description": "Resources for Flight utils",
"pack_format": 10
}
}

0 comments on commit f667af9

Please sign in to comment.