Very High Attribute does not change the produced output compared to high
AngryBacteria opened this issue ยท 1 comments
It seems that the very high productivity trait does not matter in terms of the honey comb output.
According to the main constructor of the ProductiveBee Class, the productivity of normally spawned bees ranges from 0 to 2. This can be seen here in the rand.nextInt(3)
part of the code below. This means that very high should be a productivity of 3. I double checked by cloning the source-code, and the productivity modifier of a bee with the "very high" trait is indeed 3.
public ProductiveBee(EntityType<? extends Bee> entityType, Level world) {
super(entityType, world);
Random rand = new Random();
setAttributeValue(BeeAttributes.PRODUCTIVITY, rand.nextInt(3));
setAttributeValue(BeeAttributes.TEMPER, 1);
setAttributeValue(BeeAttributes.ENDURANCE, rand.nextInt(3));
setAttributeValue(BeeAttributes.BEHAVIOR, 0);
setAttributeValue(BeeAttributes.WEATHER_TOLERANCE, 0);
setAttributeValue(BeeAttributes.TYPE, "hive");
// Goal to make entity follow player, must be registered after init to use bee attributes
this.goalSelector.addGoal(3, new ProductiveTemptGoal(this, 1.25D));
this.setPathfindingMalus(BlockPathTypes.TRAPDOOR, -1.0F);
}
Now the formula for calculating the honey comb of a bee is the following
int productivity = ((ProductiveBee) beeEntity).getAttributeValue(BeeAttributes.PRODUCTIVITY);
if (productivity > 0) {
float modifier = (1f / (productivity + 2f) + (productivity + 1f) / 2f) * stack.getCount();
stack.grow(Math.round(modifier));
}
The productivity trait adds the rounded modifier to the stack. This means for a stack size of 1 the outputs are the following:
normal --> 1
medium --> 1
high --> 2
very high --> 2
This problem only applies to stack sizes bigger than 1. But as I see it no bee has a base output of more than 1 comb. The trait modifier is the first that gets added to the stack. Only after that the productivity upgrades are being applied. It could be that this is wanted behavior, but I don't get why the very high trait even exists if this is the case?
Mod Version: dev-1.19.2 (bb26387)
Simple fix:
if (beeEntity instanceof ProductiveBee) {
int productivity = ((ProductiveBee) beeEntity).getAttributeValue(BeeAttributes.PRODUCTIVITY);
if (productivity > 0) {
if(stack.getCount() == 1) {
stack.grow(productivity);
}
else {
float modifier = (1f / (productivity + 2f) + (productivity + 1f) / 2f) * stack.getCount();
stack.grow(Math.round(modifier));
}
}
}