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);
}
});
}
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();
}
}
}
}
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);
});
}
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());
}
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;
}
Aggregations