Jump to content

Recommended Posts

Posted (edited)

Hey all, I am very new to modding (started a week ago lol) and I have an ap computer science course level of java info. With some help of chatGPT and looking through forge api (trying to fix the things that arent in 1.21 since i can't find the api for that and I am using forge 1.21) I am trying to make a devil fruit mod. For all you non one piece fans, basically when you eat it it gives you a power (I will implement that later), It makes it so that you can't eat another without dying (Already implemented), and it makes it so that you can't swim. For now, I am trying to make the player really slowed down while going into the water. This is my code (except for my imported classes and package (YES I HAVE IMPORTED EVERYTHING :))):

 

@Mod.EventBusSubscriber(modid = DevilFruitMod.MOD_ID)
public class PlayerEventHandler {

    @SubscribeEvent
    public static void onLivingUpdate(LivingEvent event) {
        if (event.getEntity() instanceof Player player) {
            if (player.isInWater()) {
                applySlownessEffect(player, 60, 2);
            }

        }
    }

   /* @SubscribeEvent
    public static void onLivingJump(LivingEvent.LivingJumpEvent event) {
        if (event.getEntity() instanceof Player player) {

            // Check if you want to prevent jumping under certain conditions
            if (player.isInWater()) {
                event.setCanceled(true); // Cancel the jump event
            }
        }
    }*/

    public static void applySlownessEffect(Player player, int durationInTicks, int amplifier) {
        MobEffectInstance slownessEffect = new MobEffectInstance(MobEffects.MOVEMENT_SLOWDOWN, durationInTicks, amplifier);
        player.addEffect(slownessEffect);
    }
}

However, whenever I go into water (im testing it without the devil fruit part rn), the game crashes and I get this error in my run client:

Caused by: java.lang.LinkageError: loader constraint violation: loader 'SECURE-BOOTSTRAP' @add0edd wants to load interface org.apache.logging.log4j.util.MessageSupplier. (org.apache.logging.log4j.util.MessageSupplier is in module org.apache.logging.log4j@2.22.1 of loader 'SECURE-BOOTSTRAP' @add0edd, parent loader 'app')

I would also like to be able to make them unable to jump, or if someone had a suggestion to make them completely unable to swim instead of slow and jump please tell me. Or if there was a way I could make it so that right after they eat the fruit they cant swim for the rest of the game in my fdevilfruit class after they use the item. Sorry if it is hard to help me since I havent shown the rest of my classes.

Can anyone please help, and aa good explantion would be nice since I am relatively new to modding but I love programming and want to understand what is happening. 

Thanks :)!

Edited by Ants1207

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • You are using Create 6 - some addons are not compatible with it Remove all addons and add these one by one littlecontraptions is mentioned - keep this one removed
    • Different problem now. https://paste.ee/p/iDo8lS35
    • I would like to have a BoP sapling drop from my block if it is also installed. I think I have done everything and I cannot pinpoint the problem, which is the error in the logs that appears when joining a world:   [Worker-Main-11/ERROR] [ne.mi.co.ForgeHooks/]: Couldn't parse element loot_tables:grasses:blocks/leaves_block com.google.gson.JsonSyntaxException: Expected name to be an item, was unknown string 'biomesoplenty:magic_sapling' My code:   LootItemConditions.CONDITIONS.register(modEventBus); public class LootItemConditions { public static final DeferredRegister<LootItemConditionType> CONDITIONS = DeferredRegister.create(Registries.LOOT_CONDITION_TYPE, Grasses.MOD_ID); public static final RegistryObject<LootItemConditionType> IS_MOD_LOADED = CONDITIONS.register("is_mod_loaded", () -> new LootItemConditionType(new IsModLoaded.ConditionSerializer())); } public class IsModLoaded implements LootItemCondition { private final boolean exists; private final String modID; public IsModLoaded(String modID) { this.exists = ModList.get().isLoaded(modID); this.modID = modID; } @Override public LootItemConditionType getType() { return LootItemConditions.IS_MOD_LOADED.get(); } @Override public boolean test(LootContext context) { return this.exists; } public static LootItemCondition.Builder builder(String modid) { return () -> new IsModLoaded(modid); } public static class ConditionSerializer implements Serializer<IsModLoaded> { @Override public void serialize(JsonObject json, IsModLoaded instance, JsonSerializationContext ctx) { json.addProperty("modid", instance.modID); } @Override public IsModLoaded deserialize(JsonObject json, JsonDeserializationContext ctx) { return new IsModLoaded(GsonHelper.getAsString(json, "modid")); } } } protected LootTable.Builder createLeavesDropsWithModIDCheck(Block selfBlock, Item sapling, Property<?>[] properties, String modIDToCheck, float... chances) { CopyBlockState.Builder blockStateCopyBuilder = CopyBlockState.copyState(selfBlock); for(Property<?> property : properties) { blockStateCopyBuilder.copy(property); } return LootTable.lootTable() .withPool(LootPool.lootPool().setRolls(ConstantValue.exactly(1.0F)) .add(LootItem.lootTableItem(selfBlock) .when(HAS_SHEARS_OR_SILK_TOUCH) .apply(blockStateCopyBuilder))) .withPool(LootPool.lootPool().setRolls(ConstantValue.exactly(1.0F)) .add(this.applyExplosionCondition(selfBlock, LootItem.lootTableItem(sapling)) .when(IsModLoaded.builder(modIDToCheck))) .when(BonusLevelTableCondition.bonusLevelFlatChance(Enchantments.BLOCK_FORTUNE, chances)) .when(HAS_NO_SHEARS_OR_SILK_TOUCH)) .withPool(LootPool.lootPool().name("sticks").setRolls(ConstantValue.exactly(1.0F)) .add(this.applyExplosionDecay(selfBlock, LootItem.lootTableItem(Items.STICK). apply(SetItemCountFunction.setCount(UniformGenerator.between(1.0F, 2.0F)))) .when(BonusLevelTableCondition.bonusLevelFlatChance(Enchantments.BLOCK_FORTUNE, NORMAL_LEAVES_STICK_CHANCES)) .when(HAS_NO_SHEARS_OR_SILK_TOUCH))); } I don't know. Am I making a mistake somewhere? Am I forgetting something? Should there be something else?
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.