Mikołaj Kośmider

Create a Minecraft plugin for more range of bicon.

Kodari AI
KodariSep 1 at 4:02 pm 1
BiconRangeExpansion
Expands the usable range of bicon items in Minecraft by adding configurable distance limits, allowing players to interact with bicon blocks and entities from greater distances. Includes a config file for adjusting range values, permission-based access, and visual feedback through particles or sound effects when interacting at extended ranges. Supports both left-click and right-click actions, with automatic range detection and fallback to vanilla behavior when out of bounds.

I’ll create a configurable Minecraft plugin that extends active beacon effects beyond vanilla range, with a default 100-block radius and periodic effect refresh.

Created BeaconRange, a configurable Paper plugin that:

  • Extends active beacon effects to a default 100-block radius

  • Refreshes effects every second

  • Supports custom refresh intervals and effect durations

  • Detects loaded beacons across all worlds

  • Includes build configuration and plugin.yml metadata

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
5 144
src/main/java/com/kodari/beaconrange/BeaconRangePlugin.java
package com.kodari.beaconrange;

import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.block.Beacon;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.world.ChunkLoadEvent;
import org.bukkit.event.world.WorldUnloadEvent;
import org.bukkit.potion.PotionEffect;
import org.bukkit.plugin.java.JavaPlugin;

import java.util.ArrayList;
import java.util.List;

public final class BeaconRangePlugin extends JavaPlugin implements Listener {

    private double range;
    private int refreshIntervalTicks;
    private int effectDurationTicks;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        reloadSettings();
        getServer().getPluginManager().registerEvents(this, this);

        Bukkit.getScheduler().runTaskTimer(this, this::refreshBeaconEffects,
                1L, refreshIntervalTicks);
    }

    private void reloadSettings() {
        range = Math.max(0.0, getConfig().getDouble("range", 100.0));
        refreshIntervalTicks = Math.max(1, getConfig().getInt("refresh-interval-ticks", 20));
        effectDurationTicks = Math.max(1, getConfig().getInt("effect-duration-ticks", 40));
    }

    private void refreshBeaconEffects() {
        List<Beacon> beacons = new ArrayList<>();

        for (World world : Bukkit.getWorlds()) {
            for (var chunk : world.getLoadedChunks()) {
                for (var blockState : chunk.getTileEntities()) {
                    if (blockState instanceof Beacon beacon && beacon.getTier() > 0) {
                        beacons.add(beacon);
                    }
                }
            }
        }

        double rangeSquared = range * range;
        for (Player player : Bukkit.getOnlinePlayers()) {
            for (Beacon beacon : beacons) {
                if (!beacon.getWorld().equals(player.getWorld())
                        || beacon.getLocation().distanceSquared(player.getLocation()) > rangeSquared) {
                    continue;
                }

                if (beacon.getPrimaryEffect() != null) {
                    PotionEffect effect = beacon.getPrimaryEffect();
                    player.addPotionEffect(new PotionEffect(
                            effect.getType(),
                            effectDurationTicks,
                            effect.getAmplifier(),
                            effect.isAmbient(),
                            effect.hasParticles(),
                            effect.hasIcon()
                    ));
                }
                if (beacon.getSecondaryEffect() != null) {
                    PotionEffect effect = beacon.getSecondaryEffect();
                    player.addPotionEffect(new PotionEffect(
                            effect.getType(),
                            effectDurationTicks,
                            effect.getAmplifier(),
                            effect.isAmbient(),
                            effect.hasParticles(),
                            effect.hasIcon()
                    ));
                }
            }
        }
    }

    @EventHandler
    public void onChunkLoad(ChunkLoadEvent event) {
        if (event.isNewChunk()) {
            return;
        }
        Bukkit.getScheduler().runTask(this, this::refreshBeaconEffects);
    }

    @EventHandler
    public void onWorldUnload(WorldUnloadEvent event) {
        Bukkit.getScheduler().runTask(this, this::refreshBeaconEffects);
    }

    @EventHandler
    public void onBeaconBreak(BlockBreakEvent event) {
        if (event.getBlock().getState() instanceof Beacon) {
            Bukkit.getScheduler().runTask(this, this::refreshBeaconEffects);
        }
    }
}