make me a minecraft plugin that makes the beacon range be 200 blocks version 1.21.11
Here’s what the plugin does:
Repeating task — every 3 seconds, scans all loaded chunks within 200 blocks of each online player for active beacons and applies their effects (4-second duration + refresh = permanent uptime)
Move detection — also triggers on block-change movement so effects kick in immediately when a player walks into range
Respects beacon tier — skips beacons with tier 0 (not enough pyramid layers to be active)
Uses
beacon.getActiveEffects()— reads whatever effects the beacon owner configured, no hardcodingAmbient effect — applies with fewer particles so it doesn’t look spammy
The compilation failed with this error:
Compilation failed with 2 error(s):
ERROR in src/main/java/com/kodari/beaconrange/BeaconListener.java at line 80: incompatible types: BlockState cannot be converted to Block
for (Block block : playerLoc.getWorld().getChunkAt(cx, cz).getTileEntities(
^
ERROR in src/main/java/com/kodari/beaconrange/BeaconListener.java at line 97: cannot find symbol
Collection<PotionEffect> effects = beacon.getActiveEffects();
^
symbol: method getActiveEffects()
location: variable beacon of type Beacon
=== COMPILATION ERROR ANALYSIS ===
MISSING METHODS:
- getActiveEffects()
ACTION: Check method names and signatures
TYPE MISMATCHES:
- incompatible types: BlockState cannot be converted to Block
ACTION: Fix variable types or casting
FILES TO INVESTIGATE:
- src/main/java/com/kodari/beaconrange/BeaconListener.java
Please fix this error by creating a new artifact with the corrected code.
Two fixes needed:
getTileEntities()returnsBlockState[], notBlock[]— iterate asBlockStatedirectlyBeacon.getActiveEffects()doesn’t exist in 1.21.1 — usegetPrimaryEffect()/getSecondaryEffect()instead
Three changes made:
Block→BlockState—getTileEntities()returnsBlockState[], so the loop variable and location call are updated accordinglygetActiveEffects()removed — replaced withgetPrimaryEffect()/getSecondaryEffect(), which are the actual Bukkit 1.21.1BeaconAPI methodsAmplifier logic — tier 4 beacons that have the same effect in both slots get amplifier 1 (level II), matching vanilla beacon behaviour
make it that the beacon still works after i travel 16 chunks so iget the effects from 16 chunks
The core problem: when the player is 16+ chunks from a beacon, that beacon’s chunk is unloaded and simply skipped (isChunkLoaded returns false). The fix is to force-load the beacon chunks around every player at startup/login and keep them loaded as the player moves, then unload them when no player needs them anymore. We track every known beacon location and force-load its chunk when any player is within 200 blocks.
Here’s what changed:
knownBeaconsregistry — every time a chunk loads, it’s scanned for beacons and their locations are stored in memory. This means we always know where beacons are, even if their chunk is currently unloaded.setChunkForceLoaded(cx, cz, true)— any beacon chunk that a player is within 200 blocks of gets force-loaded by Bukkit. The server keeps it ticking regardless of the player’s actual view distance.updateForceLoadedChunks()— runs every 3 seconds (same as the effect task). It computes which beacon chunks are needed, force-loads new ones, and releases chunks that no player needs anymore so you don’t leak memory.onChunkUnload— if Minecraft tries to unload a force-loaded beacon chunk, this handler re-applies the force-load flag and cleans the beacon registry so it’s re-scanned on next load.onPlayerJoin/onPlayerQuit— rescans the area on join and re-evaluates the force-load set on quit so solo players don’t keep every chunk in memory unnecessarily.
make it 32 chunks
32 chunks = 512 blocks.
CUSTOM_RANGE changed from 256 → 512 (32 × 16). The chunk scan radius and distance checks all derive from that constant so nothing else needs touching.
package com.kodari.beaconrange;
import org.bukkit.plugin.java.JavaPlugin;
public class BeaconRangeExpander extends JavaPlugin {
@Override
public void onEnable() {
getServer().getPluginManager().registerEvents(new BeaconListener(this), this);
getLogger().info("BeaconRangeExpander enabled — range set to 200 blocks.");
}
@Override
public void onDisable() {
getLogger().info("BeaconRangeExpander disabled.");
}
}