use of net.minecraft.world.entity.animal.Bee in project Bumblezone by TelepathicGrunt.
the class WrathOfTheHiveEffect method setAggression.
private static void setAggression(Level world, LivingEntity livingEntity, Class<? extends Mob> entityToFind, TargetingConditions sightMode, int speed, int absorption, int strength) {
if (livingEntity instanceof Bee) {
return;
}
boolean isHiding = false;
MobEffectInstance hiddenEffect = livingEntity.getEffect(BzEffects.HIDDEN.get());
if (hiddenEffect != null && hiddenEffect.getAmplifier() >= 1) {
isHiding = true;
}
sightMode.range(BzBeeAggressionConfigs.aggressionTriggerRadius.get());
List<? extends Mob> beeList = world.getNearbyEntities(entityToFind, sightMode, livingEntity, livingEntity.getBoundingBox().inflate(BzBeeAggressionConfigs.aggressionTriggerRadius.get()));
for (Mob bee : beeList) {
if (bee instanceof NeutralMob) {
((NeutralMob) bee).setRemainingPersistentAngerTime(20);
((NeutralMob) bee).setPersistentAngerTarget(livingEntity.getUUID());
}
if (isHiding) {
bee.setTarget(null);
} else {
bee.setTarget(livingEntity);
MobEffectInstance effect = livingEntity.getEffect(BzEffects.WRATH_OF_THE_HIVE.get());
if (effect != null) {
int leftoverDuration = effect.getDuration();
bee.addEffect(new MobEffectInstance(MobEffects.MOVEMENT_SPEED, leftoverDuration, speed, false, false));
bee.addEffect(new MobEffectInstance(MobEffects.ABSORPTION, leftoverDuration, absorption, false, false));
bee.addEffect(new MobEffectInstance(MobEffects.DAMAGE_BOOST, leftoverDuration, strength, false, true));
}
}
}
}
use of net.minecraft.world.entity.animal.Bee in project Bumblezone by TelepathicGrunt.
the class WrathOfTheHiveEffect method applyEffectTick.
/**
* Makes the bees swarm at the entity
*/
@Override
public void applyEffectTick(LivingEntity entity, int amplifier) {
Level world = entity.level;
// Maximum aggression
if (amplifier >= 2) {
unBEElievablyHighAggression(world, entity);
if (GeneralUtils.getEntityCountInBz() < BzGeneralConfigs.broodBlocksBeeSpawnCapacity.get() * 3.0f) {
// We don't want to spawn millions of bees
if (!world.isClientSide() && world.random.nextFloat() <= 0.0045f) {
// Grab a nearby air materialposition a bit away
BlockPos spawnBlockPos = GeneralUtils.getRandomBlockposWithinRange(world, entity, 30, 10);
if (world.getBlockState(spawnBlockPos).getMaterial() != Material.AIR) {
return;
}
Bee bee = EntityType.BEE.create(world);
if (bee == null)
return;
bee.absMoveTo(spawnBlockPos.getX() + 0.5D, spawnBlockPos.getY() + 0.5D, spawnBlockPos.getZ() + 0.5D, world.random.nextFloat() * 360.0F, 0.0F);
bee.finalizeSpawn((ServerLevel) world, world.getCurrentDifficultyAt(spawnBlockPos), MobSpawnType.TRIGGERED, null, null);
world.addFreshEntity(bee);
}
}
} else // Anything lower than 2 is medium aggression
{
mediumAggression(world, entity);
}
// makes brood blocks grow faster near wrath of the hive entities.
if (!world.isClientSide()) {
PoiManager pointofinterestmanager = ((ServerLevel) world).getPoiManager();
List<PoiRecord> poiInRange = pointofinterestmanager.getInSquare((pointOfInterestType) -> pointOfInterestType == BzPOI.BROOD_BLOCK_POI.get(), entity.blockPosition(), NEARBY_WRATH_EFFECT_RADIUS, PoiManager.Occupancy.ANY).collect(Collectors.toList());
float chanceofGrowth = 0.001f;
if (poiInRange.size() != 0) {
for (int index = poiInRange.size() - 1; index >= 0; index--) {
PoiRecord poi = poiInRange.remove(index);
if (world.random.nextFloat() < chanceofGrowth) {
BlockState state = world.getBlockState(poi.getPos());
if (state.getBlock() instanceof HoneycombBrood) {
state.tick((ServerLevel) world, poi.getPos(), world.random);
}
}
}
}
}
}
use of net.minecraft.world.entity.animal.Bee in project AlexsMobs by Alex-the-666.
the class GrizzlyBearAIFleeBees method canUse.
public boolean canUse() {
if (this.entity.isTame()) {
return false;
}
if (this.entity.isSitting() && !entity.forcedSit) {
this.entity.setOrderedToSit(false);
}
if (this.entity.isSitting()) {
return false;
}
List<Bee> beeEntities = this.entity.level.getEntitiesOfClass(Bee.class, this.entity.getBoundingBox().inflate((double) avoidDistance, 8.0D, (double) avoidDistance), this.avoidTargetSelector);
if (beeEntities.isEmpty()) {
return false;
} else {
this.closestLivingEntity = beeEntities.get(0);
Vec3 vec3d = LandRandomPos.getPosAway(this.entity, 16, 7, new Vec3(this.closestLivingEntity.getX(), this.closestLivingEntity.getY(), this.closestLivingEntity.getZ()));
if (vec3d == null) {
return false;
} else if (this.closestLivingEntity.distanceToSqr(vec3d.x, vec3d.y, vec3d.z) < this.closestLivingEntity.distanceToSqr(this.entity)) {
return false;
} else {
this.path = entity.getNavigation().createPath(new BlockPos(vec3d.x, vec3d.y, vec3d.z), 0);
return this.path != null;
}
}
}
use of net.minecraft.world.entity.animal.Bee in project BYG by AOCAWOL.
the class BeeHiveFeature method place.
public boolean place(WorldGenLevel world, ChunkGenerator generator, Random rand, BlockPos pos, NoneFeatureConfiguration config) {
if (world.isEmptyBlock(pos) && world.isEmptyBlock(pos.below())) {
if (world.getBlockState(pos.above()).is(BlockTags.LEAVES) || world.getBlockState(pos.above()).is(BlockTags.LOGS) || world.getBlockState(pos.above()).is(BYGBlocks.EMBUR_GEL_BLOCK)) {
Direction direction;
if (world.isEmptyBlock(pos.north()))
direction = Direction.NORTH;
else if (world.isEmptyBlock(pos.south()))
direction = Direction.SOUTH;
else if (world.isEmptyBlock(pos.west()))
direction = Direction.WEST;
else
direction = Direction.EAST;
BlockState beeHiveState = Blocks.BEE_NEST.defaultBlockState().setValue(BeehiveBlock.FACING, direction);
world.setBlock(pos, beeHiveState, 2);
BlockEntity tileEntity = world.getBlockEntity(pos);
if (tileEntity instanceof BeehiveBlockEntity) {
BeehiveBlockEntity beehiveTileEntity = (BeehiveBlockEntity) tileEntity;
int beeCount = rand.nextInt(4);
for (int bee = 0; bee <= beeCount; bee++) {
Bee beeEntity = new Bee(EntityType.BEE, world.getLevel());
beehiveTileEntity.addOccupantWithPresetTicks(beeEntity, false, rand.nextInt(599));
}
}
return true;
}
}
return false;
}
use of net.minecraft.world.entity.animal.Bee in project ResourcefulBees by Resourceful-Bees.
the class BeeBox method useOn.
@Override
@NotNull
public InteractionResult useOn(UseOnContext context) {
Player player = context.getPlayer();
if (player != null) {
Level playerWorld = context.getPlayer().getCommandSenderWorld();
ItemStack stack = context.getItemInHand();
if (!context.getPlayer().isShiftKeyDown())
return InteractionResult.FAIL;
if (playerWorld.isClientSide() || !isFilled(stack))
return InteractionResult.FAIL;
Level worldIn = context.getLevel();
BlockPos pos = context.getClickedPos();
List<Entity> entities = getEntitiesFromStack(stack, worldIn, true);
for (Entity entity : entities) {
if (entity != null) {
BlockPos blockPos = pos.relative(context.getClickedFace());
entity.absMoveTo(blockPos.getX() + 0.5, blockPos.getY(), blockPos.getZ() + 0.5, 0, 0);
worldIn.addFreshEntity(entity);
if (entity instanceof Bee) {
Bee beeEntity = (Bee) entity;
BeeJar.resetBee(beeEntity);
BeeJar.setBeeAngry(beeEntity, player);
}
}
}
if (isTemp)
stack.shrink(1);
else
stack.setTag(null);
return InteractionResult.SUCCESS;
}
return InteractionResult.FAIL;
}
Aggregations