Search in sources :

Example 1 with MobEntity

use of net.minecraft.entity.mob.MobEntity in project ImmersivePortalsMod by qouteall.

the class MixinThreadedAnvilChunkStorage method sendChunkDataPackets.

/**
 * @author qouteall
 */
@Overwrite
private void sendChunkDataPackets(ServerPlayerEntity player, Packet<?>[] packets_1, WorldChunk worldChunk_1) {
    // vanilla will not manage interdimensional chunk loading
    if (player.dimension != world.dimension.getType()) {
        return;
    }
    DimensionalChunkPos chunkPos = new DimensionalChunkPos(world.dimension.getType(), worldChunk_1.getPos());
    boolean isChunkDataSent = SGlobal.chunkTrackingGraph.isChunkDataSent(player, chunkPos);
    if (isChunkDataSent) {
        return;
    }
    ModMain.serverTaskList.addTask(() -> {
        SGlobal.chunkTrackingGraph.onChunkDataSent(player, chunkPos);
        return true;
    });
    if (packets_1[0] == null) {
        packets_1[0] = MyNetwork.createRedirectedMessage(world.dimension.getType(), new ChunkDataS2CPacket(worldChunk_1, 65535));
        packets_1[1] = MyNetwork.createRedirectedMessage(world.dimension.getType(), new LightUpdateS2CPacket(worldChunk_1.getPos(), this.serverLightingProvider));
    }
    player.sendInitialChunkPackets(worldChunk_1.getPos(), packets_1[0], packets_1[1]);
    DebugRendererInfoManager.method_19775(this.world, worldChunk_1.getPos());
    List<Entity> list_1 = Lists.newArrayList();
    List<Entity> list_2 = Lists.newArrayList();
    ObjectIterator var6 = this.entityTrackers.values().iterator();
    while (var6.hasNext()) {
        IEEntityTracker threadedAnvilChunkStorage$EntityTracker_1 = (IEEntityTracker) var6.next();
        Entity entity_1 = threadedAnvilChunkStorage$EntityTracker_1.getEntity_();
        if (entity_1 != player && entity_1.chunkX == worldChunk_1.getPos().x && entity_1.chunkZ == worldChunk_1.getPos().z) {
            threadedAnvilChunkStorage$EntityTracker_1.updateCameraPosition_(player);
            if (entity_1 instanceof MobEntity && ((MobEntity) entity_1).getHoldingEntity() != null) {
                list_1.add(entity_1);
            }
            if (!entity_1.getPassengerList().isEmpty()) {
                list_2.add(entity_1);
            }
        }
    }
    Iterator var9;
    Entity entity_3;
    if (!list_1.isEmpty()) {
        var9 = list_1.iterator();
        while (var9.hasNext()) {
            entity_3 = (Entity) var9.next();
            player.networkHandler.sendPacket(MyNetwork.createRedirectedMessage(world.getDimension().getType(), new EntityAttachS2CPacket(entity_3, ((MobEntity) entity_3).getHoldingEntity())));
        }
    }
    if (!list_2.isEmpty()) {
        var9 = list_2.iterator();
        while (var9.hasNext()) {
            entity_3 = (Entity) var9.next();
            player.networkHandler.sendPacket(MyNetwork.createRedirectedMessage(world.getDimension().getType(), new EntityPassengersSetS2CPacket(entity_3)));
        }
    }
}
Also used : MobEntity(net.minecraft.entity.mob.MobEntity) Entity(net.minecraft.entity.Entity) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) IEEntityTracker(com.qouteall.immersive_portals.ducks.IEEntityTracker) DimensionalChunkPos(com.qouteall.immersive_portals.chunk_loading.DimensionalChunkPos) EntityPassengersSetS2CPacket(net.minecraft.client.network.packet.EntityPassengersSetS2CPacket) LightUpdateS2CPacket(net.minecraft.client.network.packet.LightUpdateS2CPacket) ChunkDataS2CPacket(net.minecraft.client.network.packet.ChunkDataS2CPacket) ObjectIterator(it.unimi.dsi.fastutil.objects.ObjectIterator) Iterator(java.util.Iterator) EntityAttachS2CPacket(net.minecraft.client.network.packet.EntityAttachS2CPacket) MobEntity(net.minecraft.entity.mob.MobEntity) ObjectIterator(it.unimi.dsi.fastutil.objects.ObjectIterator) Overwrite(org.spongepowered.asm.mixin.Overwrite)

Example 2 with MobEntity

use of net.minecraft.entity.mob.MobEntity in project Neutrino by FrostWizard4.

the class LightningRodArtifact method summonLightning.

public void summonLightning(PlayerEntity playerEntity, World world) {
    for (Entity e : world.getOtherEntities(playerEntity, Box.of(playerEntity.getPos(), 10, 10, 10))) {
        if (e instanceof MobEntity && (playerEntity.distanceTo(e) < 10)) {
            LightningEntity lightningEntity = new LightningEntity(EntityType.LIGHTNING_BOLT, world);
            lightningEntity.setPos(e.getX(), e.getY(), e.getZ());
            world.spawnEntity(lightningEntity);
        }
    }
}
Also used : Entity(net.minecraft.entity.Entity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) MobEntity(net.minecraft.entity.mob.MobEntity) LightningEntity(net.minecraft.entity.LightningEntity) LightningEntity(net.minecraft.entity.LightningEntity) MobEntity(net.minecraft.entity.mob.MobEntity)

Example 3 with MobEntity

use of net.minecraft.entity.mob.MobEntity in project Neutrino by FrostWizard4.

the class EndGatewayBlockEntityMixin method serverTick.

@Inject(at = @At("HEAD"), method = "serverTick")
private static void serverTick(World world, BlockPos pos, BlockState state, EndGatewayBlockEntity blockEntity, CallbackInfo ci) {
    if (world instanceof ServerWorld) {
        if (world.getTime() % 100L == 0L) {
            for (MobEntity e : world.getEntitiesByClass(MobEntity.class, Box.of(Vec3d.ofCenter(pos), 1000, 1000, 1000), EndGatewayBlockEntity::canTeleport)) {
                e.addStatusEffect(new StatusEffectInstance(StatusEffects.STRENGTH, 1200, 1));
                e.addStatusEffect(new StatusEffectInstance(StatusEffects.REGENERATION, 1200, 1));
                e.addStatusEffect(new StatusEffectInstance(StatusEffects.SPEED, 1200, 2));
                e.addStatusEffect(new StatusEffectInstance(StatusEffects.ABSORPTION, 1200, 1));
            }
        }
    }
}
Also used : ServerWorld(net.minecraft.server.world.ServerWorld) EndGatewayBlockEntity(net.minecraft.block.entity.EndGatewayBlockEntity) StatusEffectInstance(net.minecraft.entity.effect.StatusEffectInstance) MobEntity(net.minecraft.entity.mob.MobEntity) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 4 with MobEntity

use of net.minecraft.entity.mob.MobEntity in project Carrier by GabrielOlvH.

the class MixinMobEntity method carrier_interactMob.

@Inject(method = "interactMob", at = @At("HEAD"), cancellable = true)
private void carrier_interactMob(PlayerEntity player, Hand hand, CallbackInfoReturnable<ActionResult> cir) {
    MobEntity entity = (MobEntity) (Object) this;
    ActionResult actionResult = HolderInteractCallback.INSTANCE.interact(player, player.world, hand, entity);
    if (actionResult.isAccepted())
        cir.setReturnValue(actionResult);
}
Also used : ActionResult(net.minecraft.util.ActionResult) MobEntity(net.minecraft.entity.mob.MobEntity) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 5 with MobEntity

use of net.minecraft.entity.mob.MobEntity 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

MobEntity (net.minecraft.entity.mob.MobEntity)10 Entity (net.minecraft.entity.Entity)5 StatusEffectInstance (net.minecraft.entity.effect.StatusEffectInstance)3 PlayerEntity (net.minecraft.entity.player.PlayerEntity)3 NavigatingEntity (me.jellysquid.mods.lithium.common.entity.NavigatingEntity)2 ServerWorldExtended (me.jellysquid.mods.lithium.common.world.ServerWorldExtended)2 EntityNavigation (net.minecraft.entity.ai.pathing.EntityNavigation)2 Inject (org.spongepowered.asm.mixin.injection.Inject)2 Redirect (org.spongepowered.asm.mixin.injection.Redirect)2 AreaIsometricRenderScreen (com.glisco.isometricrenders.client.gui.AreaIsometricRenderScreen)1 IsometricRenderScreen (com.glisco.isometricrenders.client.gui.IsometricRenderScreen)1 DimensionalChunkPos (com.qouteall.immersive_portals.chunk_loading.DimensionalChunkPos)1 IEEntityTracker (com.qouteall.immersive_portals.ducks.IEEntityTracker)1 ObjectIterator (it.unimi.dsi.fastutil.objects.ObjectIterator)1 Iterator (java.util.Iterator)1 BlockWithEntity (net.minecraft.block.BlockWithEntity)1 BlockEntity (net.minecraft.block.entity.BlockEntity)1 EndGatewayBlockEntity (net.minecraft.block.entity.EndGatewayBlockEntity)1 MinecraftClient (net.minecraft.client.MinecraftClient)1 ChunkDataS2CPacket (net.minecraft.client.network.packet.ChunkDataS2CPacket)1