Fix automated wool farm crash and elytra fly over unknown block crash #3809
No reviewers
Labels
No Label
#P1 CRITICAL
#P2: HIGH
#P3: elevated
#P4 priority: medium
#P6: low
#Review
annoying
API
bug
code quality
combat
commands
compatibility
configurability
contribution inside
controls
core feature
creative mode
delayed for engine release
documentation
duplicate
enhancement
environment
feature request
gameplay
graphics
ground content conflict
GUI/HUD
help wanted
incomplete feature
invalid / won't fix
items
looking for contributor
mapgen
meta
mineclone2+
Minecraft >= 1.13
Minecraft >= 1.17
missing feature
mobile
mobs
mod support
model needed
multiplayer
Needs adoption
needs discussion
needs engine change
needs more information
needs research
nodes
non-mob entities
performance
player
possible close
redstone
release notes
schematics
Skyblock
sounds
Testing / Retest
tools
translation
unconfirmed
mcl5
mcla
Media missing
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: VoxeLibre/VoxeLibre#3809
Loading…
Reference in New Issue
No description provided.
Delete Branch "fix_unknown_block_crash"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Wool crash bug
Crash line:
minetest.add_item(pos, entity.drops[2].name .. " " .. math.random(1, 3))
Basically, we remove the second drop when they are sheared. We need to add it back immediately so when observer sees grass eaten, it triggers shears and shears can find the required drop.
I've made this a bit safer so it checks the drop is there first.
Elytra flying above unknown bug
We try to check walkable, but if it isn't a registers block, it crashes. So made this safer and non-crashable.
Testing
Tested flying above unknown blocks (tested on cherry blossom trees which aren't on this branch). It no longer crashes.
Changed replace rate to 1 on sheep and change grass grown and mycellium abm to every second. Automated farm will now shear sheep and sheep eats and it shears and it eats etc. etc.
I got a (very nitpicky) suggestion
@ -6,6 +6,8 @@ local S = minetest.get_translator("mobs_mc")
--################### SHEEP
--###################
local WOOL_REPLACE_RATE = 80
It seems like this variable ONLY get used once, unless you consider adding a setting for the replace rate, it should stay hardcoded in my opinion
I appreciate the feedback, but I don't agree with that. From a computer perspective (if the PC was the only thing reading the code), your suggestion makes sense. However in most languages, it is often standard practice to put things that change or can change at the top in a constant. I often change this variable when testing sheep and wool farms, and digging through code every time is a PITA to find the changeable values. As a result, I tend to put these sort of values at the top of files in a constant.
Sure, this is why
#define
in C and C++ exists, however, in that situation, it makes no difference as the compiler takes care of it...Anyways, I agree, in the end, it is just 8 bytes of RAM (lua uses 64 bit doubles), which makes pretty much no difference on a modern computer.
1f1d1ca1f5
to8b9b4b00e5