Resourceful Bees

Resourceful Bees

10M Downloads

Support for non-EntityBee mobs to enter apiaries

Thutmose opened this issue · 18 comments

commented

Is your feature request related to a problem? Please describe.

This is related to support for modded insects which may want to enter bee hives, for whatever reason.

The vanilla behaviour is as follows:

Any entity can be added to the hive via tryEnterHive, however only instances of BeeEntity will set the flower pos

Entities contained in the tag "minecraft:beehive_inhabitors", can properly exit the hive, but likewise some behaviour is not tracked (honey delivery in this case)

A custom mob added, can be flagged as having nectar by accessing the last element of the bees list, and then setting "HasNectar" to true in the contained entityData.

Apiart behaviour is as follows:

Only instances of BeeEntity can be added to the hive, though the only BeeEntity specific code is getFlowerPos()

releaseBee then specifically requires the contained entity to be a BeeEntity, though due to the above, this makes sense.

Describe the solution you'd like

Hoped for solution:

I would like to be able to add any random mob to the hive, maybe so long as it is tagged with "minecraft:beehive_inhabitors". Likewise it would be useful to be able to access the nbt of the last added bee somehow, so that I can set the "HasNectar" boolean, or some other way to specify that the mob brought in some nectar (capability, nbt access, however works best here).

Describe alternatives you've considered

An alternative solution would be to add a capability which determines bees for this, and use access from that to add/remove bees to the hive, and to manage nectar

Additional context

I am working on getting my pokemobs able to do vanilla bee like things, currently they can make honey in the vanilla hives, and can enter/exit vanilla hives and nests, but due to the above, they don't work in apiaries.

commented

We don't let other modded bees use apiaries because of how they function, unfortunately i dont think it will be possible currently to allow other mod's bees to use apiaries unless you use the resourceful bees BeeEntity as a base

commented

Reopening in case oreo or gravy have any extra input

commented

The apiary currently lets anything that extends vanilla BeeEntity enter it:

https://github.com/Resourceful-Bees/ResourcefulBees/blob/master/src/main/java/com/resourcefulbees/resourcefulbees/tileentity/multiblocks/apiary/ApiaryTileEntity.java#L219

The idea in this case would be say API access so that other mobs could potentially bring say just nectar back to the apiary, as works for the vanilla hives/bee nests

commented

We won’t be changing the apiary to handle other entity types besides bee entity.

commented

Any particular reason for why? I would be willing to do a pull request if needed

commented

Because it’s a mod regarding bees and allowing other entity types in hives besides bees makes no sense.

commented

but mods can add bees, which are not specifically extending the vanilla BeeEntity, but are tagged with minecraft:beehive_inhabitors, and otherwise act like bees

commented

Make a PR and we’ll review it

commented

Ok, I will probably see about sending a PR in the next few days

commented

When I get to making the pull request it will do the following:

TieredBeehiveTileEntity

Custom Modded Bees Entering

https://github.com/Resourceful-Bees/ResourcefulBees/blob/master/src/main/java/com/resourcefulbees/resourcefulbees/tileentity/TieredBeehiveTileEntity.java#L143-L148

Modify this check here, so that the maxTimeInHive check is the only thing in the if statement, and the adding the bee is not. Currently this block deletes my bees, as they try to enter this hive, thinking it is a vanilla hive (tile instanceof BeehiveTileEntity is true, as yours extends that)

Custom Modded Bees exiting

Releasing bees from the TieredBeehiveTileEntity works fine, if they can get in, as it does the bee checks in a separate scope from where it spawns the mob.

ApiaryTileEntity

Custom Modded Bees Entering

Only use the if (bee instanceof BeeEntity) to get the flower pos, this is nullable anyway, so it can be null for non-BeeEntity bees.

In the case of a bee not being an instanceof BeeEntity, and the nbt tag doesn't have a "HasNectar" boolean, then set that based on the value of hasNectar passed in as an argument.

Custom Modded Bees exiting

https://github.com/Resourceful-Bees/ResourcefulBees/blob/master/src/main/java/com/resourcefulbees/resourcefulbees/tileentity/multiblocks/apiary/ApiaryTileEntity.java#L197-L204

Move this block outside of the if (entity instanceof BeeEntity), so that the non-EntityBee can be released

commented

Is there a specific reason you want this to happen because I don't see a point to add it if it's not gonna be used.

commented

Also whatever entity that wants to work with our hive would need to use our ICustomBee interface so we can get what honeycomb it makes and what "type" it is

commented

My mod adds a large number of misc tameable mobs, a few of them are bee-like or bees. The next update to the mod adds in AI for the bee-like ones to act somewhat like vanilla bees, they fly around flowers, return to the hive, and make standard honeycombs in the hive.

Currently, the bees get deleted if they try to enter a TieredBeehiveTileEntity, as that calls remove() regardless of if the bee actually entered, and I figured it would be nice if they could interact with the Apiary to just generate the standard vanilla honeycomb.

The vanilla base class for these mobs is ShoulderRidingEntity, rather than BeeEntity, as they all use the same class for that, just different EntityTypes, the mod adds on the order of 1000 mobs, but it is trivial to flag the specific bee ones via the minecraft:beehive_inhabitors tag, and then have those get the custom bee ai added to them.

With the vanilla behaviour, they can enter the normal BeehiveTileEntity, increment the value of BeehiveBlock.HONEY_LEVEL when they leave, and the work as vanilla bees do. I figured it would be interesting if they would also be able to interact with the hives from this mob, or at least not get deleted when they try to enter the hive.

commented

but your bee-like entities won't increment in a vanilla hive either they'll just enter and leave as vanilla also requires the entity to be an instance of BeeEntity to increment the honey level and give honeycombs

commented

mine increment it after they leave

commented

Looking through the code its more than just the moving things out of an instanceof check, I will reconsider this in 1.17 but this would require rewriting and changing major core to certain features in the mod.

commented

I will fix the thing where your entities do get removed even when they don't actually enter the hives.

commented

Ok, I will wait until 1.17 before I work on my side of the support, thanks for looking into the other one where it removes the bees that don't enter

One possible way to go about it would be to add a ICustomBee capability, then do checks for that, instead of the instanceof ICustomBee, and then have that provide the type, etc, I would then be able to attach that to my bees.