System Information
Field | Value |
---|---|
Operating System | Linux - Debian GNU/Linux 12 on x86_64 |
Product | AMP ‘Phobos’ v2.6.2.4 (Mainline) |
Virtualization | Docker |
Application | Minecraft |
Module | MinecraftModule |
Running in Container | Yes |
Current State | Ready |
Problem Description
Issue
im running a skript, its essentially just calling to spawn zombies at a player, for some reason its maxing out the memory and crashing me
Reproduction Steps
- added skript
- adding the sk code to the sk file
- adding 200+ lines of code
here is the sk code:
command /checkgens:
trigger:
send “&7Active generators: %size of {generators::*}%” to player
command /killzombies:
permission: gens.admin
trigger:
send “&aClearing all Player Hunter zombies and drops within 50 blocks…” to player
loop all zombies in radius 50 of player:
if name of loop-entity contains “[Player Hunter]”:
kill loop-entity
execute console command “kill @e[type=minecraft:item,distance=..50]”
loop {generators::*}:
set {generator-hunters::%loop-value%} to 0
send “&aCleared all Player Hunter zombies, drops, and reset hunter counts.” to player
on join:
if {firstjoin.%player%} is not set:
set {firstjoin.%player%} to true
give player 1 sponge named “&aInfested Generator” with lore “&7Place this to generate resources…”
send “&aYou received your first generator!” to player
command /givegen:
permission: gens.admin
trigger:
give player 1 sponge named “&aInfested Generator” with lore “&7Place this to generate resources…”
send “&aGenerator given.” to player
on place of sponge:
if name of player’s tool is “&aInfested Generator”:
set {_loc} to location of event-block
add {_loc} to {generators::*}
set {generator-heat::%{_loc}%} to 0
set {generator-hunters::%{_loc}%} to 0
set {generator-active::%{_loc}%} to true
set {generator-cycle-start::%{_loc}%} to now
set {generator-last-resource::%{_loc}%} to now
send “&aGenerator placed and active!” to player
on break of sponge:
set {_loc} to location of event-block
if {_loc} is in {generators::}:
remove {_loc} from {generators::}
delete {generator-heat::%{_loc}%}
delete {generator-hunters::%{_loc}%}
delete {generator-active::%{_loc}%}
delete {generator-cycle-start::%{_loc}%}
delete {generator-last-resource::%{_loc}%}
send “&cGenerator removed.” to player
on right click on sponge:
if player is sneaking:
set {_loc} to location of event-block
if {_loc} is in {generators::}:
give player 1 sponge named “&aInfested Generator” with lore “&7Place this to generate resources…”
remove {_loc} from {generators::}
delete {generator-heat::%{_loc}%}
delete {generator-hunters::%{_loc}%}
delete {generator-active::%{_loc}%}
delete {generator-cycle-start::%{_loc}%}
delete {generator-last-resource::%{_loc}%}
set event-block to air
send “&aGenerator picked up!” to player
Resource generation every 30 seconds
every 30 seconds:
loop {generators::*}:
set {_genLoc} to loop-value
# Safety check: make sure generator data exists
if {_genLoc} is set:
if {generator-active::%{_genLoc}%} is set:
# Only generate resources if generator is active
if {generator-active::%{_genLoc}%} is true:
# Random chance for resource generation (80% chance)
set {_resourceRoll} to random integer between 1 and 100
if {_resourceRoll} <= 80:
# Determine rarity and resource type
set {_rarityRoll} to random integer between 1 and 100
# Common resources (60% chance)
if {_rarityRoll} <= 60:
set {_resources::*} to "copper ingot", "iron ingot", and "coal"
set {_amount} to random integer between 1 and 3
# Uncommon resources (25% chance)
else if {_rarityRoll} <= 85:
set {_resources::*} to "gold ingot", "redstone", and "lapis lazuli"
set {_amount} to random integer between 1 and 2
# Rare resources (10% chance)
else if {_rarityRoll} <= 95:
set {_resources::*} to "diamond", "emerald", and "quartz"
set {_amount} to 1
# Very rare resources (5% chance)
else:
set {_resources::*} to "netherite ingot", "ancient debris", and "nether star"
set {_amount} to 1
# Pick random resource from the tier
set {_resourceType} to random element of {_resources::*}
# Drop the resource directly above the generator block
set {_dropLoc} to location above {_genLoc}
drop {_amount} of {_resourceType} at {_dropLoc}
# Update last resource time
set {generator-last-resource::%{_genLoc}%} to now
# Debug message to confirm drops are working
loop all players in radius 20 of {_genLoc}:
send "&7[DEBUG] Dropped %{_amount}% %{_resourceType}% at generator!" to loop-player
# Clear the temporary list
delete {_resources::*}
Heat buildup and mob spawning with cycle management
every 1 minute:
loop {generators::*}:
set {_genLoc} to loop-value
# Safety check: make sure generator data exists
if {_genLoc} is set:
if {generator-cycle-start::%{_genLoc}%} is set:
# Check cycle timing (5 minutes active, 10 minutes break)
set {_cycleStart} to {generator-cycle-start::%{_genLoc}%}
set {_timeSinceStart} to difference between now and {_cycleStart}
# Active phase: 0-5 minutes (300 seconds)
if {_timeSinceStart} <= 300 seconds:
set {generator-active::%{_genLoc}%} to true
# Break phase: 5-15 minutes (300-900 seconds)
else if {_timeSinceStart} <= 900 seconds:
# Only clear once when entering rest phase
if {generator-active::%{_genLoc}%} is true:
set {generator-active::%{_genLoc}%} to false
# Kill Player Hunter zombies within 50 blocks of this generator
loop all zombies in radius 50 of {_genLoc}:
set {_zombie} to loop-entity-2
if name of {_zombie} contains "[Player Hunter]":
kill {_zombie}
# Clear dropped items near this generator
loop all dropped items in radius 50 of {_genLoc}:
set {_item} to loop-entity-2
kill {_item}
# Reset hunter count during rest
set {generator-hunters::%{_genLoc}%} to 0
# Reset cycle after 15 minutes
else:
set {generator-cycle-start::%{_genLoc}%} to now
set {generator-active::%{_genLoc}%} to true
# Only process if generator is active - NO SPAWNING DURING REST
if {generator-active::%{_genLoc}%} is true:
# Increase heat only during active phase - reaches 100% at 4 minutes
add 25 to {generator-heat::%{_genLoc}%}
if {generator-heat::%{_genLoc}%} > 100:
set {generator-heat::%{_genLoc}%} to 100
set {_heat} to {generator-heat::%{_genLoc}%}
# Spawn chance based on heat - ONLY DURING ACTIVE PHASE
if {_heat} >= 10:
set {_spawnChance} to {_heat}
set {_randomRoll} to random integer between 1 and 100
if {_randomRoll} <= {_spawnChance}:
# Calculate spawn location using proper math functions
set {_distance} to random integer between 25 and 50
set {_angle} to random number between 0 and 6.28
# Use Skript's math functions
set {_x} to {_distance} * cos({_angle})
set {_z} to {_distance} * sin({_angle})
set {_spawnX} to x-coordinate of {_genLoc} + {_x}
set {_spawnZ} to z-coordinate of {_genLoc} + {_z}
set {_spawnY} to y-coordinate of {_genLoc} + 1
set {_world} to world of {_genLoc}
set {_spawnLoc} to location({_spawnX}, {_spawnY}, {_spawnZ}, {_world})
# Find safe spawn location (not inside blocks)
set {_attempts} to 0
while block at {_spawnLoc} is not air and {_attempts} < 10:
add 1 to {_spawnY}
set {_spawnLoc} to location({_spawnX}, {_spawnY}, {_spawnZ}, {_world})
add 1 to {_attempts}
spawn 1 zombie at {_spawnLoc}
set name of last spawned entity to "&c[Player Hunter]"
equip last spawned entity with leather helmet
# Count hunters
add 1 to {generator-hunters::%{_genLoc}%}
else:
# During break phase, keep heat at 0
set {generator-heat::%{_genLoc}%} to 0
Status display with active/resting status
every 3 seconds:
loop all players:
set {_currentPlayer} to loop-player
set {_foundGenerator} to false
loop {generators::*}:
set {_genLoc} to loop-value-2
# Safety check: make sure the generator location still exists and has data
if {_genLoc} is set:
if {generator-active::%{_genLoc}%} is set:
if distance between {_currentPlayer} and {_genLoc} < 10:
set {_heat} to {generator-heat::%{_genLoc}%}
set {_hunters} to {generator-hunters::%{_genLoc}%}
set {_active} to {generator-active::%{_genLoc}%}
set {_lastResource} to {generator-last-resource::%{_genLoc}%}
if {_heat} is not set:
set {_heat} to 0
if {_hunters} is not set:
set {_hunters} to 0
if {_lastResource} is not set:
set {_lastResource} to now
# Calculate time until next resource (30 seconds from last)
set {_timeSinceResource} to difference between now and {_lastResource}
set {_timeUntilResource} to 30 seconds - {_timeSinceResource}
# Convert to seconds for display
set {_secondsLeft} to {_timeUntilResource} in seconds
if {_secondsLeft} < 0:
set {_secondsLeft} to 0
# Show different messages based on active status
if {_active} is true:
if {_heat} < 30:
set {_message} to "&aACTIVE - Heat: %{_heat}% | Hunters: %{_hunters}% | Next: %{_secondsLeft}%s"
else if {_heat} < 70:
set {_message} to "&6ACTIVE - Heat: %{_heat}% | Hunters: %{_hunters}% | Next: %{_secondsLeft}%s"
else:
set {_message} to "&cACTIVE - Heat: %{_heat}% | Hunters: %{_hunters}% | Next: %{_secondsLeft}%s"
else:
set {_message} to "&7RESTING - Heat: %{_heat}% | Hunters: %{_hunters}% | No Resources"
send action bar {_message} to {_currentPlayer}
set {_foundGenerator} to true
exit loop
Heat reduction when Player Hunter zombies die
on death of zombie:
if name of victim contains “[Player Hunter]”:
loop {generators::*}:
set {_genLoc} to loop-value
if distance between victim and {_genLoc} < 100:
if {generator-hunters::%{_genLoc}%} > 0:
remove 1 from {generator-hunters::%{_genLoc}%}
if {generator-heat::%{_genLoc}%} > 10:
remove 10 from {generator-heat::%{_genLoc}%}
else:
set {generator-heat::%{_genLoc}%} to 0
stop