Search in sources :

Example 6 with Bee

use of net.minecraft.world.entity.animal.Bee in project Minecraft_AP_Randomizer by KonoTyran.

the class BeeTrap method trigger.

@Override
public void trigger(ServerPlayer player) {
    APRandomizer.getServer().execute(() -> {
        ServerLevel world = player.getLevel();
        Vec3 pos = player.position();
        for (int i = 0; i < numberOfBees; i++) {
            Bee bee = EntityType.BEE.create(world);
            Vec3 offset = Utils.getRandomPosition(pos, 5);
            bee.moveTo(offset);
            bee.setPersistentAngerTarget(player.getUUID());
            bee.setRemainingPersistentAngerTime(1200);
            world.addFreshEntity(bee);
        }
    });
}
Also used : ServerLevel(net.minecraft.server.level.ServerLevel) Bee(net.minecraft.world.entity.animal.Bee) Vec3(net.minecraft.world.phys.Vec3)

Example 7 with Bee

use of net.minecraft.world.entity.animal.Bee in project AlexsMobs by Alex-the-666.

the class GrizzlyBearAIBeehive method eatHive.

private void eatHive() {
    if (net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(bear.level, bear)) {
        BlockState blockstate = bear.level.getBlockState(this.blockPos);
        if (blockstate.is(AMTagRegistry.GRIZZLY_BEEHIVE)) {
            if (bear.level.getBlockEntity(this.blockPos) instanceof BeehiveBlockEntity) {
                Random rand = new Random();
                BeehiveBlockEntity beehivetileentity = (BeehiveBlockEntity) bear.level.getBlockEntity(this.blockPos);
                beehivetileentity.emptyAllLivingFromHive(null, blockstate, BeehiveBlockEntity.BeeReleaseStatus.EMERGENCY);
                bear.level.updateNeighbourForOutputSignal(this.blockPos, blockstate.getBlock());
                ItemStack stack = new ItemStack(Items.HONEYCOMB);
                int level = 0;
                if (blockstate.getBlock() instanceof BeehiveBlock) {
                    level = blockstate.getValue(BeehiveBlock.HONEY_LEVEL);
                }
                for (int i = 0; i < level; i++) {
                    ItemEntity itementity = new ItemEntity(bear.level, blockPos.getX() + rand.nextFloat(), blockPos.getY() + rand.nextFloat(), blockPos.getZ() + rand.nextFloat(), stack);
                    itementity.setDefaultPickUpDelay();
                    bear.level.addFreshEntity(itementity);
                }
                bear.level.destroyBlock(blockPos, false);
                if (blockstate.getBlock() instanceof BeehiveBlock) {
                    bear.level.setBlockAndUpdate(blockPos, blockstate.setValue(BeehiveBlock.HONEY_LEVEL, 0));
                }
                double d0 = 15;
                for (Bee bee : bear.level.getEntitiesOfClass(Bee.class, new AABB((double) blockPos.getX() - d0, (double) blockPos.getY() - d0, (double) blockPos.getZ() - d0, (double) blockPos.getX() + d0, (double) blockPos.getY() + d0, (double) blockPos.getZ() + d0))) {
                    bee.setRemainingPersistentAngerTime(100);
                    bee.setTarget(bear);
                    bee.setStayOutOfHiveCountdown(400);
                }
                stop();
            }
        }
    }
}
Also used : ItemEntity(net.minecraft.world.entity.item.ItemEntity) BlockState(net.minecraft.world.level.block.state.BlockState) Bee(net.minecraft.world.entity.animal.Bee) Random(java.util.Random) ItemStack(net.minecraft.world.item.ItemStack) BeehiveBlockEntity(net.minecraft.world.level.block.entity.BeehiveBlockEntity) BeehiveBlock(net.minecraft.world.level.block.BeehiveBlock) AABB(net.minecraft.world.phys.AABB)

Example 8 with Bee

use of net.minecraft.world.entity.animal.Bee in project Bumblezone by TelepathicGrunt.

the class BumblezoneClient method onClientSetup.

public static void onClientSetup(FMLClientSetupEvent event) {
    // enqueueWork because I have been told RenderTypeLookup is not thread safe
    event.enqueueWork(() -> {
        DimensionSpecialEffectsAccessor.thebumblezone_getBY_ResourceLocation().put(new ResourceLocation(Bumblezone.MODID, "sky_property"), new BzSkyProperty());
        registerRenderLayers();
        if (BzClientConfigs.enableAltBeeSkinRenderer.get()) {
            // noinspection unchecked cast
            BeeVariantRenderer.OLD_BEE_RENDER_FACTORY = (EntityRendererProvider<Bee>) RenderingRegistryAccessor.getEntityRenderers().get(EntityType.BEE);
            EntityRenderers.register(EntityType.BEE, BeeVariantRenderer::new);
        }
        // Allows shield to use the blocking json file for offset
        ItemProperties.register(BzItems.HONEY_CRYSTAL_SHIELD.get(), new ResourceLocation("blocking"), (itemStack, world, livingEntity, integer) -> livingEntity != null && livingEntity.isUsingItem() && livingEntity.getUseItem() == itemStack ? 1.0F : 0.0F);
        // Correct model when about to throw
        ItemProperties.register(BzItems.STINGER_SPEAR.get(), new ResourceLocation("throwing"), (itemStack, world, livingEntity, integer) -> livingEntity != null && livingEntity.isUsingItem() && livingEntity.getUseItem() == itemStack ? 1.0F : 0.0F);
        // Allows honey compass to render the correct texture
        ItemProperties.register(BzItems.HONEY_COMPASS.get(), new ResourceLocation("angle"), HoneyCompassItemProperty.getClampedItemPropertyFunction());
        // Correct model when about to fire
        ItemProperties.register(BzItems.BEE_CANNON.get(), new ResourceLocation("primed"), (itemStack, world, livingEntity, int1) -> livingEntity != null && livingEntity.isUsingItem() && livingEntity.getUseItem() == itemStack ? 1.0F : 0.0F);
        // Correct model based on bees
        ItemProperties.register(BzItems.BEE_CANNON.get(), new ResourceLocation("bee_count"), (itemStack, world, livingEntity, int1) -> BeeCannon.getNumberOfBees(itemStack) / 10f);
        MenuScreens.register(BzMenuTypes.STRICT_9x1.get(), StrictChestScreen::new);
        MenuScreens.register(BzMenuTypes.STRICT_9x2.get(), StrictChestScreen::new);
        MenuScreens.register(BzMenuTypes.STRICT_9x3.get(), StrictChestScreen::new);
        MenuScreens.register(BzMenuTypes.STRICT_9x4.get(), StrictChestScreen::new);
        MenuScreens.register(BzMenuTypes.STRICT_9x5.get(), StrictChestScreen::new);
        MenuScreens.register(BzMenuTypes.STRICT_9x6.get(), StrictChestScreen::new);
    });
}
Also used : BeeVariantRenderer(com.telepathicgrunt.the_bumblezone.client.rendering.BeeVariantRenderer) Bee(net.minecraft.world.entity.animal.Bee) ResourceLocation(net.minecraft.resources.ResourceLocation) BzSkyProperty(com.telepathicgrunt.the_bumblezone.world.dimension.BzSkyProperty) StrictChestScreen(com.telepathicgrunt.the_bumblezone.screens.StrictChestScreen)

Example 9 with Bee

use of net.minecraft.world.entity.animal.Bee in project Bumblezone by TelepathicGrunt.

the class GeneralUtils method updateEntityCount.

public static void updateEntityCount(ServerLevel world) {
    BEE_SET.clear();
    int counter = 0;
    for (Entity entity : world.getAllEntities()) {
        counter++;
        if (entity instanceof Bee) {
            BEE_SET.add((Bee) entity);
        }
    }
    ACTIVE_ENTITIES = counter;
    BEE_SET.removeIf(bee -> bee.isPersistenceRequired() || bee.hasHive() || bee.hasCustomName() || bee.isLeashed() || bee.isVehicle());
}
Also used : Entity(net.minecraft.world.entity.Entity) Bee(net.minecraft.world.entity.animal.Bee)

Example 10 with Bee

use of net.minecraft.world.entity.animal.Bee in project Bumblezone by TelepathicGrunt.

the class BeeBread method interactLivingEntity.

@Override
public InteractionResult interactLivingEntity(ItemStack stack, Player playerEntity, LivingEntity entity, InteractionHand playerHand) {
    if (!(entity instanceof Bee) && entity.getType() != BzEntities.BEEHEMOTH.get())
        return InteractionResult.PASS;
    int currentEffectAmplifier = 0;
    if (entity.hasEffect(BzEffects.BEENERGIZED.get())) {
        currentEffectAmplifier = Math.min(entity.getEffect(BzEffects.BEENERGIZED.get()).getAmplifier() + 1, 2);
        if (currentEffectAmplifier == 2 && playerEntity instanceof ServerPlayer) {
            BzCriterias.BEENERGIZED_MAXED_TRIGGER.trigger((ServerPlayer) playerEntity);
        }
    }
    entity.addEffect(new MobEffectInstance(BzEffects.BEENERGIZED.get(), 6000, currentEffectAmplifier, true, true, true));
    ItemStack itemstack = playerEntity.getItemInHand(playerHand);
    if (!playerEntity.isCreative()) {
        itemstack.shrink(1);
    }
    playerEntity.swing(playerHand, true);
    return InteractionResult.SUCCESS;
}
Also used : Bee(net.minecraft.world.entity.animal.Bee) ServerPlayer(net.minecraft.server.level.ServerPlayer) MobEffectInstance(net.minecraft.world.effect.MobEffectInstance) ItemStack(net.minecraft.world.item.ItemStack)

Aggregations

Bee (net.minecraft.world.entity.animal.Bee)31 BlockPos (net.minecraft.core.BlockPos)12 ItemStack (net.minecraft.world.item.ItemStack)9 Entity (net.minecraft.world.entity.Entity)8 CompoundTag (net.minecraft.nbt.CompoundTag)6 Level (net.minecraft.world.level.Level)6 NotNull (org.jetbrains.annotations.NotNull)6 ICustomBee (com.teamresourceful.resourcefulbees.api.ICustomBee)5 LivingEntity (net.minecraft.world.entity.LivingEntity)5 Player (net.minecraft.world.entity.player.Player)5 AABB (net.minecraft.world.phys.AABB)5 ResourcefulBee (com.teamresourceful.resourcefulbees.entity.passive.ResourcefulBee)4 Direction (net.minecraft.core.Direction)4 BeehiveBlockEntity (net.minecraft.world.level.block.entity.BeehiveBlockEntity)4 BlockState (net.minecraft.world.level.block.state.BlockState)4 CustomBeeEntity (com.teamresourceful.resourcefulbees.entity.passive.CustomBeeEntity)3 List (java.util.List)3 MobEffectInstance (net.minecraft.world.effect.MobEffectInstance)3 Mob (net.minecraft.world.entity.Mob)3 BlockEntity (net.minecraft.world.level.block.entity.BlockEntity)3