#CustomBee - Pathfinders
1 messages · Page 1 of 1 (latest)
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
It also blacklists old hives it looks like
how tho
theres so many though, like idk which ones to override
public void tick() {
if (Bee.this.hivePos != null) {
++this.travellingTicks;
if (this.travellingTicks > this.adjustedTickDelay(600)) {
this.dropAndBlacklistHive();
} else if (!Bee.this.navigation.isInProgress()) {
if (!Bee.this.closerThan(Bee.this.hivePos, 16)) {
if (Bee.this.isTooFarAway(Bee.this.hivePos)) {
this.dropHive();
} else {
Bee.this.pathfindRandomlyTowards(Bee.this.hivePos);
}
} else {
boolean flag = this.pathfindDirectlyTowards(Bee.this.hivePos);
if (!flag) {
this.dropAndBlacklistHive();
} else if (this.lastPath != null && Bee.this.navigation.getPath().sameAs(this.lastPath)) {
++this.ticksStuck;
if (this.ticksStuck > 60) {
this.dropHive();
this.ticksStuck = 0;
}
} else {
this.lastPath = Bee.this.navigation.getPath();
}
}
}
}
}
if I understand this right... if its flying for too long it drops the hive
How can I override the goal though without breaking the vanilla one?
I tried overriding one already and it broke it
just copypaste most of the code
make it into your own custom class
and apply it only to your custom bee
alright this was an issue I was hitting last time
@Override
public class BeeGoToHiveGoal extends Bee.BaseBeeGoal
net.minecraft.world.entity.animal.Bee.BaseBeeGoal' has private access in 'net.minecraft.world.entity.animal.Bee
and..
BeeGoToHiveGoal() {
super();
this.travellingTicks = Bee.this.level.random.nextInt(10);
this.blacklistedTargets = Lists.newArrayList();
this.setFlags(EnumSet.of(Flag.MOVE));
}
on Bee.this: 'net.minecraft.world.entity.animal.Bee' is not an enclosing class
legit just copy the entire Bee class
copy the pathfinder and all
Once I change the package name to my own everything goes red
well
you gotta like copypaste the classes and rename stuff to have the same behavior
public Bee getBreedOffspring(ServerLevel worldserver, AgeableMob entityageable) {
return (Bee)EntityType.BEE.create(worldserver);
}
Inconvertible types; cannot cast 'net.minecraft.world.entity.animal.@javax.annotation.Nullable Bee' to 'com.squallz.cadiabees.objects.Bee'
I used the imports it wanted 🤷♂️
so weird.
keep changing stuff
@stray thunder If you're just trying to prevent them from going into their Hive, just remove the BeeGoToHiveGoal from your custom entity.
thats not what I want
I need to stop them from switching hives.
they need to always use the same one
Perhaps override canBeeUse() and just add an extra check to the hivePos they want to use. You'd have to also track the one they're always supposed to be in in another field for your custom entity.
If hivePos and defaultHive for example, aren't the same, then return false for canBeeUse.
and that would be checked...on tick...?
It'd be checked whenever Minecraft deemed it necessary I suppose. No idea when it actually checks it.
I imagine it checks it when the bee is looking for a hive to go into.
Even if it checks it every tick, a simple BlockPos comparison won't make hardly any difference I'm guessing.
so override this..?
private class BeeEnterHiveGoal extends Bee.BaseBeeGoal {
BeeEnterHiveGoal() {
super();
}
public boolean canBeeUse() {
if (Bee.this.hasHive() && Bee.this.wantsToEnterHive() && Bee.this.hivePos.closerToCenterThan(Bee.this.position(), 2.0D)) {
BlockEntity tileentity = Bee.this.level.getBlockEntity(Bee.this.hivePos);
if (tileentity instanceof BeehiveBlockEntity) {
BeehiveBlockEntity tileentitybeehive = (BeehiveBlockEntity)tileentity;
if (!tileentitybeehive.isFull()) {
return true;
}
Bee.this.hivePos = null;
}
}
return false;
}
public boolean canBeeContinueToUse() {
return false;
}
public void start() {
BlockEntity tileentity = Bee.this.level.getBlockEntity(Bee.this.hivePos);
if (tileentity instanceof BeehiveBlockEntity) {
BeehiveBlockEntity tileentitybeehive = (BeehiveBlockEntity)tileentity;
tileentitybeehive.addOccupant(Bee.this, Bee.this.hasNectar());
}
}
}
Well, just the canBeeUse method.
Extend the Goal and change it
And then remove the default goal from the bee and add the custom one you modified.
is extending the goal a thing?
the canBeeUse is inside the BeeEnterHiveGoal
well, its inside multiple goals
Does it let you extend BeeEnterHiveGoal?
no
Honestly not sure what the difference between BeeGoToHiveGoal is and BeeEnterHiveGoal lol
BeeGoToHiveGoal is public so that may be easier to deal with
Its canBeeUse is simpler too
public class BeeGoToHiveGoal extends BeeGoToHiveGoal {
}
Cyclic inheritance involving 'com.squallz.cadiabees.objects.CustomBee.BeeGoToHiveGoal'
There is no default constructor available in 'net.minecraft.world.entity.animal.Bee.BeeGoToHiveGoal'
It wants you to define the constructor for BeeGoToHiveGoal, this is getting into Java now.
yeah but there isnt one in the base bee class
There is
?
Wait what do you mean base bee class?
its not defined outside of the other methods
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
The only thing you need to change about the Bee entity is which goals it has.
But like what?
You don't have to do anything with pathfinders, all your custom goal should do is basically the exact same thing as the default goal, except you're adding 1 extra condition to it.
Yeah but how do I override it
Let Minecraft do all the heavy lifting for you and you just extend and modify as you need.
do I need to override
protected void registerGoals() {
this.goalSelector.addGoal(0, new Bee.BeeAttackGoal(this, 1.399999976158142D, true));
this.goalSelector.addGoal(1, new Bee.BeeEnterHiveGoal());
this.goalSelector.addGoal(2, new BreedGoal(this, 1.0D));
this.goalSelector.addGoal(3, new TemptGoal(this, 1.25D, Ingredient.of(ItemTags.FLOWERS), false));
this.beePollinateGoal = new Bee.BeePollinateGoal();
this.goalSelector.addGoal(4, this.beePollinateGoal);
this.goalSelector.addGoal(5, new FollowParentGoal(this, 1.25D));
this.goalSelector.addGoal(5, new Bee.BeeLocateHiveGoal());
this.goToHiveGoal = new Bee.BeeGoToHiveGoal();
this.goalSelector.addGoal(5, this.goToHiveGoal);
this.goToKnownFlowerGoal = new Bee.BeeGoToKnownFlowerGoal();
this.goalSelector.addGoal(6, this.goToKnownFlowerGoal);
this.goalSelector.addGoal(7, new Bee.BeeGrowCropGoal());
this.goalSelector.addGoal(8, new Bee.BeeWanderGoal());
this.goalSelector.addGoal(9, new FloatGoal(this));
this.targetSelector.addGoal(1, (new Bee.BeeHurtByOtherGoal(this)).setAlertOthers(new Class[0]));
this.targetSelector.addGoal(2, new Bee.BeeBecomeAngryTargetGoal(this));
this.targetSelector.addGoal(3, new ResetUniversalAngerTargetGoal(this, true));
}
@cunning imp pls
alright
theres gotta be other ones
The only way I can think to do it is either some convoluted way to somehow call the superclass constructor, which I have no idea how to do, nor do I even know that its possible, or you can literally just copy paste all of Mojang's code into your own class, change what you need, and use that.
Copying Mojang's code probably isn't a great idea if its a public plugin but it's a private then meh 
Honestly I'm not really sure why they made those constructors package private
to fuck us
this current behavior is a HUGE issue
my bees will just wander away and lose the hive that they need to keep
my bees need to have the same hive until its either broken (which despawns them) or they die
Honestly if you can somehow manage to keep hivePos as the hive you want, you wouldn't even have to make any AI changes.
set it every couple seconds... 😓
That is certainly one way
Well, maybe not.
It seems like the only time the hive is ever dropped is in the tick method of Bee
When dropHive and dropAndBlacklistHive are called
If those are the only places it's dropped, then you can override tick, copy the code, and remove the drop calls.
if only i could just override drophive and dropandblacklisthive to be empty functions
^ I was too fucked up mentally to say that

was like 7am
Yeah well Mojang said no to making their constructors public so

So I cant override it?
Not those, thats why you should override tick.
Oh wait no you can override those
God wait Mojang's code is so weird 
I was trying to do this before
@Override
protected PathNavigation createNavigation(Level world) {
final PathNavigation vanillaNav = super.createNavigation(world);
FlyingPathNavigation navigationflying = new FlyingPathNavigation(this, world) {
public boolean isStableDestination(BlockPos blockposition) {
return vanillaNav.isStableDestination(blockposition) && blockposition.closerThan(blockposition, 32);
}
public void tick() {
vanillaNav.tick();
getBukkitEntity().setHive(getHivePos());
}
};
navigationflying.setCanOpenDoors(false);
navigationflying.setCanFloat(false);
navigationflying.setCanPassDoors(true);
return navigationflying;
}
but it just broke the ai entirely
that's a horrible alternative to fixing the pathfinder
Oh yeah I wouldn't deal with Navigation that's overcomplicating it
heh
So I did some testing trying to override the moveTo method
It works fine except when the bee tried to fly to flowers
No idea why though
hmmmm...
this is such a pain in the ass
might just have to go to ol faithful and set its hive back every 5 sec
alright boys
ive run into a new issue
once a bee enters the hive 7 times, or 7 separate bees enter once, it sets the hive's stored bee amount to max hive.getEntityCount()
which makes it so bees can no longer enter
because it thinks its full
but theres not a way to set the amount, only get
Time for reflection
😭
It's not that bad
well, there is hive.setMaxEntities, but thats not whast I want. I need to set the current amount
i dont understand reflection so its bad for me
alright bb
//Stop the bee from randomly switching hives (fuck you mojang)
new BukkitRunnable() {
public void run() {
if(customBee.getBukkitEntity() == null || customBee.getBukkitEntity().isDead()) cancel();
customBee.getBukkitEntity().setHive(customHive.getHiveLocation());
}
}.runTaskTimer(cadiaBees, 0, 100L);
This is the only reliable way ive found to make it so they dont switch hives..
This word is considered offensive.
Incorrect:
Piss off!
I have no idea why mojang made everything package private
Bee is the worst entity class to work with that I've seen
of course it is
because its the first one I decided to mess with
just my luck REEEE
i dont understand reflection
Look it up and do some testing. I will get some sleep
ok ily