محمد احمد

Create an airplane airport mod

Kodari AI
KodariOct 14 at 10:53 pm 8
AirportManager
Adds functional airports to Minecraft with runways, control towers, and hangars. Players can construct airports using specialized blocks, then manage flight schedules for custom aircraft entities. Includes a radar system displaying incoming and outgoing flights, passenger boarding mechanics with NPCs, and a ticketing system using in-game currency. Features configurable flight routes between multiple airports, weather-dependent takeoff conditions, and an air traffic control GUI for monitoring and directing aircraft. Supports multiplayer coordination with shared airport networks and automatic collision avoidance between planes.
  1. Set up a Fabric 1.20.4 mod with a craftable runway block and airplane item.

  2. Make the airplane item launch the player with a short flight/slow-fall effect.

  3. Add the textures, models, recipe, loot table, language entry, and creative-tab registration.

Created Skyport, a Fabric 1.20.4 mod with an airport runway block and a textured Pocket Airplane item.

  • Survival crafting: make 4 runway blocks from smooth stone and white dye; craft the Pocket Airplane from paper, an iron ingot, and a feather.

  • The runway requires a stone-tier pickaxe and drops itself. Using the airplane gives a brief lift and slow falling, with a launch sound and cooldown.

The Pocket Airplane is a flight-burst item, not a steerable, rideable aircraft.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
settings.gradle
Code
18 276
src/main/java/com/kodari/skyport/SkyportMod.java
package com.kodari.skyport;

import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents;
import net.minecraft.block.AbstractBlock;
import net.minecraft.block.Block;
import net.minecraft.block.MapColor;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemGroups;
import net.minecraft.item.ItemStack;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvents;
import net.minecraft.util.Hand;
import net.minecraft.util.Identifier;
import net.minecraft.util.TypedActionResult;
import net.minecraft.world.World;

public final class SkyportMod implements ModInitializer {
    public static final String MOD_ID = "skyport";

    public static final Block RUNWAY = Registry.register(
            Registries.BLOCK,
            new Identifier(MOD_ID, "runway"),
            new Block(AbstractBlock.Settings.create()
                    .mapColor(MapColor.STONE_GRAY)
                    .strength(2.0f)
                    .requiresTool()
                    .sounds(BlockSoundGroup.STONE))
    );

    public static final Item RUNWAY_ITEM = Registry.register(
            Registries.ITEM,
            new Identifier(MOD_ID, "runway"),
            new BlockItem(RUNWAY, new Item.Settings())
    );

    public static final Item AIRPLANE = Registry.register(
            Registries.ITEM,
            new Identifier(MOD_ID, "airplane"),
            new AirplaneItem(new Item.Settings())
    );

    @Override
    public void onInitialize() {
        RegistryKey<ItemGroup> buildingBlocks = RegistryKey.of(
                RegistryKeys.ITEM_GROUP,
                new Identifier("minecraft", "building_blocks")
        );
        ItemGroupEvents.modifyEntriesEvent(buildingBlocks).register(entries -> {
            entries.add(RUNWAY_ITEM);
            entries.add(AIRPLANE);
        });
    }

    private static final class AirplaneItem extends Item {
        private AirplaneItem(Settings settings) {
            super(settings);
        }

        @Override
        public TypedActionResult<ItemStack> use(World world, PlayerEntity user, Hand hand) {
            ItemStack stack = user.getStackInHand(hand);
            if (!world.isClient) {
                user.addStatusEffect(new StatusEffectInstance(StatusEffects.LEVITATION, 80));
                user.addStatusEffect(new StatusEffectInstance(StatusEffects.SLOW_FALLING, 240));
                user.getItemCooldownManager().set(this, 100);
                world.playSound(
                        user,
                        user.getX(),
                        user.getY(),
                        user.getZ(),
                        SoundEvents.ENTITY_FIREWORK_ROCKET_LAUNCH,
                        SoundCategory.PLAYERS,
                        0.8f,
                        1.1f
                );
            }
            return TypedActionResult.success(stack);
        }
    }
}