Search in sources :

Example 1 with EvokerEntity

use of net.minecraft.entity.mob.EvokerEntity in project Biome-Makeover by Lemonszz.

the class BMWorldEvents method init.

public static void init() {
    DispenserBlock.registerBehavior(Items.CROSSBOW, new FallibleItemDispenserBehavior() {

        public ItemStack dispenseSilently(BlockPointer pointer, ItemStack stack) {
            BlockPos blockPos = pointer.getBlockPos().offset(pointer.getBlockState().get(DispenserBlock.FACING));
            List<StoneGolemEntity> list = pointer.getWorld().getEntitiesByClass(StoneGolemEntity.class, new Box(blockPos), (golem) -> !golem.isHolding(Items.CROSSBOW) && golem.isPlayerCreated() && golem.isAlive());
            if (!list.isEmpty()) {
                list.get(0).equipStack(EquipmentSlot.MAINHAND, stack.copy());
                stack.decrement(1);
                this.setSuccess(true);
                return stack;
            } else {
                return super.dispenseSilently(pointer, stack);
            }
        }
    });
    // Adjudicator Drop Illunite Shard
    ServerEntityCombatEvents.AFTER_KILLED_OTHER_ENTITY.register((world, entity, killedEntity) -> {
        if (!world.isClient() && entity instanceof PlayerEntity && killedEntity instanceof EvokerEntity) {
            if (!LootBlocker.isBlocked(killedEntity)) {
                if (world.random.nextFloat() < 0.15F) {
                    killedEntity.dropStack(new ItemStack(BMItems.ILLUNITE_SHARD, 1 + world.random.nextInt(2)));
                }
            }
        }
    });
}
Also used : CarvedPumpkinBlockAccess(party.lemons.biomemakeover.util.access.CarvedPumpkinBlockAccess) StoneGolemEntity(party.lemons.biomemakeover.entity.StoneGolemEntity) ServerWorld(net.minecraft.server.world.ServerWorld) BlockPointer(net.minecraft.util.math.BlockPointer) EvokerEntity(net.minecraft.entity.mob.EvokerEntity) Random(java.util.Random) ItemStack(net.minecraft.item.ItemStack) net.minecraft.block(net.minecraft.block) BlockPlacer(net.minecraft.world.gen.placer.BlockPlacer) LootBlocker(party.lemons.biomemakeover.util.extensions.LootBlocker) SmallLilyPadBlock(party.lemons.biomemakeover.block.SmallLilyPadBlock) EquipmentSlot(net.minecraft.entity.EquipmentSlot) DoublePlantPlacer(net.minecraft.world.gen.placer.DoublePlantPlacer) FallibleItemDispenserBehavior(net.minecraft.block.dispenser.FallibleItemDispenserBehavior) PlayerEntity(net.minecraft.entity.player.PlayerEntity) World(net.minecraft.world.World) Box(net.minecraft.util.math.Box) BlockPos(net.minecraft.util.math.BlockPos) Items(net.minecraft.item.Items) BlockPatternBuilder(net.minecraft.block.pattern.BlockPatternBuilder) BlockPattern(net.minecraft.block.pattern.BlockPattern) SimpleBlockPlacer(net.minecraft.world.gen.placer.SimpleBlockPlacer) List(java.util.List) BMBlocks(party.lemons.biomemakeover.init.BMBlocks) MaterialPredicate(net.minecraft.util.function.MaterialPredicate) ServerEntityCombatEvents(net.fabricmc.fabric.api.entity.event.v1.ServerEntityCombatEvents) BlockStatePredicate(net.minecraft.predicate.block.BlockStatePredicate) CachedBlockPosition(net.minecraft.block.pattern.CachedBlockPosition) BMItems(party.lemons.biomemakeover.init.BMItems) StoneGolemEntity(party.lemons.biomemakeover.entity.StoneGolemEntity) EvokerEntity(net.minecraft.entity.mob.EvokerEntity) BlockPos(net.minecraft.util.math.BlockPos) List(java.util.List) Box(net.minecraft.util.math.Box) BlockPointer(net.minecraft.util.math.BlockPointer) ItemStack(net.minecraft.item.ItemStack) FallibleItemDispenserBehavior(net.minecraft.block.dispenser.FallibleItemDispenserBehavior) PlayerEntity(net.minecraft.entity.player.PlayerEntity)

Example 2 with EvokerEntity

use of net.minecraft.entity.mob.EvokerEntity in project Biome-Makeover by Lemonszz.

the class SummonPhase method spawnEntity.

protected void spawnEntity() {
    BlockPos spawnPos = spawnPositions[spawnIndex];
    if (world.getBlockState(spawnPos.down()).isAir())
        world.setBlockState(spawnPos.down(), Blocks.COBBLESTONE.getDefaultState());
    LivingEntity entity = entities[random.nextInt(entities.length)].create(world);
    if (entity instanceof MobEntity)
        ((MobEntity) entity).initialize((ServerWorldAccess) world, world.getLocalDifficulty(spawnPos), SpawnReason.EVENT, null, null);
    ((LootBlocker) entity).setLootBlocked(true);
    entity.refreshPositionAndAngles((double) spawnPos.getX() + 0.5D, (double) spawnPos.getY(), (double) spawnPos.getZ() + 0.5D, 0.0F, 0.0F);
    world.spawnEntity(entity);
    adjudicator.clearArea(entity);
    if (entity instanceof EvokerEntity) {
        GoalSelectorExtension.removeGoal((MobEntity) entity, EvokerEntity.SummonVexGoal.class);
    }
    world.playSound(null, spawnPos, SoundEvents.ENTITY_EVOKER_CAST_SPELL, SoundCategory.HOSTILE, 10F, 1F);
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) LootBlocker(party.lemons.biomemakeover.util.extensions.LootBlocker) ServerWorldAccess(net.minecraft.world.ServerWorldAccess) EvokerEntity(net.minecraft.entity.mob.EvokerEntity) BlockPos(net.minecraft.util.math.BlockPos) MobEntity(net.minecraft.entity.mob.MobEntity)

Aggregations

EvokerEntity (net.minecraft.entity.mob.EvokerEntity)2 BlockPos (net.minecraft.util.math.BlockPos)2 LootBlocker (party.lemons.biomemakeover.util.extensions.LootBlocker)2 List (java.util.List)1 Random (java.util.Random)1 ServerEntityCombatEvents (net.fabricmc.fabric.api.entity.event.v1.ServerEntityCombatEvents)1 net.minecraft.block (net.minecraft.block)1 FallibleItemDispenserBehavior (net.minecraft.block.dispenser.FallibleItemDispenserBehavior)1 BlockPattern (net.minecraft.block.pattern.BlockPattern)1 BlockPatternBuilder (net.minecraft.block.pattern.BlockPatternBuilder)1 CachedBlockPosition (net.minecraft.block.pattern.CachedBlockPosition)1 EquipmentSlot (net.minecraft.entity.EquipmentSlot)1 LivingEntity (net.minecraft.entity.LivingEntity)1 MobEntity (net.minecraft.entity.mob.MobEntity)1 PlayerEntity (net.minecraft.entity.player.PlayerEntity)1 ItemStack (net.minecraft.item.ItemStack)1 Items (net.minecraft.item.Items)1 BlockStatePredicate (net.minecraft.predicate.block.BlockStatePredicate)1 ServerWorld (net.minecraft.server.world.ServerWorld)1 MaterialPredicate (net.minecraft.util.function.MaterialPredicate)1