tungstonminer / brunel-3

2 stars 0 forks source link

Prevent land animals from swimming endlessly #82

Open GnarlyOldGuy opened 3 years ago

GnarlyOldGuy commented 3 years ago

One of the things in the game that was annoying (at least to me so maybe it's just a me issue), land animals that move in to the ocean and live forever. There was a particular place where there were more animals in the ocean than there was on land. One of the things in, I believe Animania, is that if you take an ocean animal to the land, it will eventually die. Shouldn't this be something for any animal that is not situated within its native land or ocean environment? Can this be coded for the land animals?

tungstonminer commented 3 years ago

I completely agree that it's a problem, but I'm not at all sure if or how you could fix that. I can have a look over the CraftTweaker documents to see if there's something which could help, but I'm skeptical.

GnarlyOldGuy commented 3 years ago

image

tungstonminer commented 3 years ago

After a quick scan, my best idea is to capture the EntityLivingUpdate event and check whether the entity (i.e., an IEntity) has recently entered the water by using the isInWater property. If it has, then we execute a few things right away:

Then, on each subsequent event, we can re-adjust the animal's yaw so it's pointed for shore so long as it's still in the water. Once it climbs back on land, we take out all the NBT tags we've been using to track things. But, if the animal remains in the water for too long (i.e., it's been more than 2min since it entered the water), we cause the animal to start taking damage on each new event until it dies.

It will be necessary, of course, to have a list of "land" animals to which these rules apply.

GnarlyOldGuy commented 3 years ago

This sounds good. It shouldn't be too hard to determine the land versus ocean animals, we have a list in two places, the brunel.py file and also in the Excel file I created for the spawning.

tungstonminer commented 3 years ago

If you could paste the list of land animals in here, it would be a nice help.

GnarlyOldGuy commented 3 years ago

Below is the list of the mobs I know of. This is directly from the spawn list. I removed the obvious ocean animals and a couple of the others that probably will never end up in the water, like the Naga. There are others you could make a case for, but it's probably easier just to include them at the outset instead of having to add them later.

badger
blackbear
boar
brownbear
buck_alpine
buck_angora
buck_chinchilla
buck_cottontail
buck_dutch
buck_fainting
buck_havana
buck_jack
buck_kiko
buck_kinder
buck_lop
buck_new_zealand
buck_nigerian_dwarf
buck_pygmy
buck_rex
bull_angus
bull_friesian
bull_hereford
bull_highland
bull_holstein
bull_jersey
bull_longhorn
bull_mooshroom
calf_angus
calf_friesian
calf_hereford
calf_highland
calf_holstein
calf_jersey
calf_longhorn
calf_mooshroom
chick_leghorn
chick_orpington
chick_plymouth_rock
chick_rhode_island_red
chick_wyandotte
cow_angus
cow_friesian
cow_hereford
cow_highland
cow_holstein
cow_jersey
cow_longhorn
cow_mooshroom
coyote
creeper
deer
doe_alpine
doe_angora
doe_chinchilla
doe_cottontail
doe_dutch
doe_fainting
doe_havana
doe_jack
doe_kiko
doe_kinder
doe_lop
doe_new_zealand
doe_nigerian_dwarf
doe_pygmy
doe_rex
donkey
enderman
evocation_illager
ewe_dorper
ewe_dorset
ewe_friesian
ewe_jacob
ewe_merino
ewe_suffolk
feralwolf
ferret_grey
ferret_white
foal_draft
fox
frostmaw
ghast
goose
grottol
hamster
hedgehog
hedgehog_albino
hen_leghorn
hen_orpington
hen_plymouth_rock
hen_rhode_island_red
hen_wyandotte
hirschgeist
hog_duroc
hog_hampshire
hog_large_black
hog_large_white
hog_old_spot
hog_yorkshire
horse
husk
illusion_illager
kid_alpine
kid_angora
kid_fainting
kid_kiko
kid_kinder
kid_nigerian_dwarf
kid_pygmy
kit_chinchilla
kit_cottontail
kit_dutch
kit_havana
kit_jack
kit_lop
kit_new_zealand
kit_rex
lamb_dorper
lamb_dorset
lamb_friesian
lamb_jacob
lamb_merino
lamb_suffolk
lammergeier
lantern
llama
mare_draft
moose
mule
ocelot
parrot
peachick_blue
peachick_charcoal
peachick_opal
peachick_peach
peachick_purple
peachick_taupe
peachick_white
peacock_blue
peacock_charcoal
peacock_opal
peacock_peach
peacock_purple
peacock_taupe
peacock_white
peahen_blue
peahen_charcoal
peahen_opal
peahen_peach
peahen_purple
peahen_taupe
peahen_white
pheasant
piglet_duroc
piglet_hampshire
piglet_large_black
piglet_large_white
piglet_old_spot
piglet_yorkshire
polar_bear
ram_dorper
ram_dorset
ram_friesian
ram_jacob
ram_merino
ram_suffolk
reindeer
rooster_leghorn
rooster_orpington
rooster_plymouth_rock
rooster_rhode_island_red
rooster_wyandotte
shulker
silverfish
skeleton
skeleton_horse
snowman
songbird
sow_duroc
sow_hampshire
sow_large_black
sow_large_white
sow_old_spot
sow_yorkshire
spider
squirrel
stallion_draft
stray
tarantula
turkey
vex
villager
villager_golem
vindication_illager
witch
wither
wither_skeleton
wolf
zombie
zombie_horse
zombie_pigman
zombie_villager
zotzpyre
tungstonminer commented 3 years ago

Awesome, thanks!

tungstonminer commented 3 years ago

I've spent far more time trying to get this to work than it was really worth. I've pushed up the code I have (all commented out) so that I might give it a try again later.