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