Search in sources :

Example 11 with BolloomBalloonEntity

use of com.minecraftabnormals.endergetic.common.entities.bolloom.BolloomBalloonEntity in project endergetic by team-abnormals.

the class S2CUpdateBalloonsMessage method handle.

public static void handle(S2CUpdateBalloonsMessage message, Supplier<NetworkEvent.Context> ctx) {
    NetworkEvent.Context context = ctx.get();
    if (context.getDirection().getReceptionSide() == LogicalSide.CLIENT) {
        context.enqueueWork(() -> {
            World world = ClientInfo.getClientPlayerWorld();
            Entity entity = world.getEntity(message.entityId);
            if (entity == null) {
                EndergeticExpansion.LOGGER.warn("Received balloons for unknown entity!");
            } else {
                ((BalloonHolder) entity).detachBalloons();
                for (int id : message.balloonIds) {
                    Entity balloon = world.getEntity(id);
                    if (balloon instanceof BolloomBalloonEntity) {
                        ((BolloomBalloonEntity) balloon).attachToEntity(entity);
                    }
                }
            }
        });
    }
    context.setPacketHandled(true);
}
Also used : Entity(net.minecraft.entity.Entity) BolloomBalloonEntity(com.minecraftabnormals.endergetic.common.entities.bolloom.BolloomBalloonEntity) NetworkEvent(net.minecraftforge.fml.network.NetworkEvent) World(net.minecraft.world.World) BalloonHolder(com.minecraftabnormals.endergetic.core.interfaces.BalloonHolder) BolloomBalloonEntity(com.minecraftabnormals.endergetic.common.entities.bolloom.BolloomBalloonEntity)

Aggregations

BolloomBalloonEntity (com.minecraftabnormals.endergetic.common.entities.bolloom.BolloomBalloonEntity)11 BalloonHolder (com.minecraftabnormals.endergetic.core.interfaces.BalloonHolder)9 Inject (org.spongepowered.asm.mixin.injection.Inject)7 Entity (net.minecraft.entity.Entity)4 ServerWorld (net.minecraft.world.server.ServerWorld)4 S2CUpdateBalloonsMessage (com.minecraftabnormals.endergetic.common.network.entity.S2CUpdateBalloonsMessage)3 ServerPlayerEntity (net.minecraft.entity.player.ServerPlayerEntity)3 ClientPlayerEntity (net.minecraft.client.entity.player.ClientPlayerEntity)2 ClientChunkProvider (net.minecraft.client.multiplayer.ClientChunkProvider)2 ClientWorld (net.minecraft.client.world.ClientWorld)2 LivingEntity (net.minecraft.entity.LivingEntity)2 BoatEntity (net.minecraft.entity.item.BoatEntity)2 PlayerEntity (net.minecraft.entity.player.PlayerEntity)2 PotionEntity (net.minecraft.entity.projectile.PotionEntity)2 ThrowableEntity (net.minecraft.entity.projectile.ThrowableEntity)2 World (net.minecraft.world.World)2 ServerChunkProvider (net.minecraft.world.server.ServerChunkProvider)2 SubscribeEvent (net.minecraftforge.eventbus.api.SubscribeEvent)2 EndergeticExpansion (com.minecraftabnormals.endergetic.core.EndergeticExpansion)1 File (java.io.File)1